RE: [PHP] Mixing sprintf and mysql_real_escape_string

2006-08-07 Thread Peter Lauri
[snip]My guess: magic_quotes_gpc is enabled where you're running the script.
Therefore slashes are already present in the data from the form post.[/snip]

Should I turn it off? Adding slashes and mysql_real_escape_string is not
exactly the same thing, correct?

/Peter

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Mixing sprintf and mysql_real_escape_string

2006-08-07 Thread Martin Alterisio

2006/8/7, Peter Lauri <[EMAIL PROTECTED]>:


I should maybe add that the data actually comes from a form:

mysql_query(sprintf("INSERT INTO table (value1, value2) VALUES (1,
'%s')", mysql_real_escape_string($_POST['formvalue'])));

And when I have ' in the field, it will insert \' into the database in
pure
form. If I do this it will add just ' (with the $_POST['formvalue']="'";

mysql_query(sprintf("INSERT INTO table (value1, value2) VALUES (1,
'%s')", $_POST['formvalue']));

Something that we are missing out here?



My guess: magic_quotes_gpc is enabled where you're running the script.
Therefore slashes are already present in the data from the form post.

-Original Message-

From: Richard Lynch [mailto:[EMAIL PROTECTED]
Sent: Tuesday, August 08, 2006 5:54 AM
To: Peter Lauri
Cc: php-general@lists.php.net
Subject: Re: [PHP] Mixing sprintf and mysql_real_escape_string

On Mon, August 7, 2006 12:35 pm, Peter Lauri wrote:
> I get strange output if I combine sprintf and
> mysql_real_escape_string. If I
> do this the resulting into the database is \' not ' as I want.
>
> mysql_query(sprintf("INSERT INTO table (value1, value2) VALUES (1,
> '%s')",
> mysql_real_escape_string(" ' ")));
>
> Should this be like this? Do the sprintf already add slashes or
> something?

mysql_real_escape_string(" ' ") will yield:   \'

This is because the ' is a "special" character to the MySQL parser --
It indicates the beginning and end of character-based data.

So if you want ' to *BE* part of your data, it needs to be escaped
with \ in front of ' and that tells MySQL, "Yo, this apostrophe is
data, not a delimiter".

sprintf should simply output:
INSERT INTO table (value1, value2) VALUES(1, ' \' ')
because is just slams the output into the %s part.

mysql_query() sends that whole thing off to MySQL.

When MySQL "reads" the SQL statement, and tries to figure out what to
do, it "sees" that line.

Because of the \' in there, it knows that the middle ' is not the end
of the string, but is part of the data.

So what MySQL actually stores for value2 is just:
'

MySQL does *NOT* store \' for that data -- The \ part of \' gets
"eaten" by MySQL parser as it works through the SQL statement, and it
just turns into plain old ' to get stored on the hard drive.

If you think it did store that, then either you didn't tell us the
correct thing for what you did, or your test for what MySQL stored is
flawed.

The usual suspect, in PHP, for this problem, is that the data is
coming from GET/POST (or COOKIES) and you have Magic Quotes turned
"ON" and the data is already getting escaped by
http://php.net/addslashes, and then you escape it *AGAIN* with
mysql_real_escape_string.

mysql_real_escape_string is better than addslashes (and/or Magic
Quotes) so turn off Magic Quotes and keep the mysql_real_escape_string
bit.

--
Like Music?
http://l-i-e.com/artists.htm

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Mixing sprintf and mysql_real_escape_string

2006-08-07 Thread Peter Lauri
I should maybe add that the data actually comes from a form:

mysql_query(sprintf("INSERT INTO table (value1, value2) VALUES (1,
'%s')", mysql_real_escape_string($_POST['formvalue'])));

And when I have ' in the field, it will insert \' into the database in pure
form. If I do this it will add just ' (with the $_POST['formvalue']="'";

mysql_query(sprintf("INSERT INTO table (value1, value2) VALUES (1,
'%s')", $_POST['formvalue']));

Something that we are missing out here?


-Original Message-
From: Richard Lynch [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, August 08, 2006 5:54 AM
To: Peter Lauri
Cc: php-general@lists.php.net
Subject: Re: [PHP] Mixing sprintf and mysql_real_escape_string

On Mon, August 7, 2006 12:35 pm, Peter Lauri wrote:
> I get strange output if I combine sprintf and
> mysql_real_escape_string. If I
> do this the resulting into the database is \' not ' as I want.
>
> mysql_query(sprintf("INSERT INTO table (value1, value2) VALUES (1,
> '%s')",
> mysql_real_escape_string(" ' ")));
>
> Should this be like this? Do the sprintf already add slashes or
> something?

mysql_real_escape_string(" ' ") will yield:   \'

This is because the ' is a "special" character to the MySQL parser --
It indicates the beginning and end of character-based data.

So if you want ' to *BE* part of your data, it needs to be escaped
with \ in front of ' and that tells MySQL, "Yo, this apostrophe is
data, not a delimiter".

sprintf should simply output:
INSERT INTO table (value1, value2) VALUES(1, ' \' ')
because is just slams the output into the %s part.

mysql_query() sends that whole thing off to MySQL.

When MySQL "reads" the SQL statement, and tries to figure out what to
do, it "sees" that line.

Because of the \' in there, it knows that the middle ' is not the end
of the string, but is part of the data.

So what MySQL actually stores for value2 is just:
 '

MySQL does *NOT* store \' for that data -- The \ part of \' gets
"eaten" by MySQL parser as it works through the SQL statement, and it
just turns into plain old ' to get stored on the hard drive.

If you think it did store that, then either you didn't tell us the
correct thing for what you did, or your test for what MySQL stored is
flawed.

The usual suspect, in PHP, for this problem, is that the data is
coming from GET/POST (or COOKIES) and you have Magic Quotes turned
"ON" and the data is already getting escaped by
http://php.net/addslashes, and then you escape it *AGAIN* with
mysql_real_escape_string.

mysql_real_escape_string is better than addslashes (and/or Magic
Quotes) so turn off Magic Quotes and keep the mysql_real_escape_string
bit.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Mixing sprintf and mysql_real_escape_string

2006-08-07 Thread Richard Lynch
On Mon, August 7, 2006 12:35 pm, Peter Lauri wrote:
> I get strange output if I combine sprintf and
> mysql_real_escape_string. If I
> do this the resulting into the database is \' not ' as I want.
>
> mysql_query(sprintf("INSERT INTO table (value1, value2) VALUES (1,
> '%s')",
> mysql_real_escape_string(" ' ")));
>
> Should this be like this? Do the sprintf already add slashes or
> something?

mysql_real_escape_string(" ' ") will yield:   \'

This is because the ' is a "special" character to the MySQL parser --
It indicates the beginning and end of character-based data.

So if you want ' to *BE* part of your data, it needs to be escaped
with \ in front of ' and that tells MySQL, "Yo, this apostrophe is
data, not a delimiter".

sprintf should simply output:
INSERT INTO table (value1, value2) VALUES(1, ' \' ')
because is just slams the output into the %s part.

mysql_query() sends that whole thing off to MySQL.

When MySQL "reads" the SQL statement, and tries to figure out what to
do, it "sees" that line.

Because of the \' in there, it knows that the middle ' is not the end
of the string, but is part of the data.

So what MySQL actually stores for value2 is just:
 '

MySQL does *NOT* store \' for that data -- The \ part of \' gets
"eaten" by MySQL parser as it works through the SQL statement, and it
just turns into plain old ' to get stored on the hard drive.

If you think it did store that, then either you didn't tell us the
correct thing for what you did, or your test for what MySQL stored is
flawed.

The usual suspect, in PHP, for this problem, is that the data is
coming from GET/POST (or COOKIES) and you have Magic Quotes turned
"ON" and the data is already getting escaped by
http://php.net/addslashes, and then you escape it *AGAIN* with
mysql_real_escape_string.

mysql_real_escape_string is better than addslashes (and/or Magic
Quotes) so turn off Magic Quotes and keep the mysql_real_escape_string
bit.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] yahoo thinks html mail is spam, what's wrong with header?

2006-08-07 Thread Richard Lynch
On Mon, August 7, 2006 7:21 am, blackwater dev wrote:
> When I try to send email from my server as html, my yahoo account and
> several of my user's email accounts mark it as spam.  I can send a
> normal
> email via mail() just fine but when I try to to html, it's bad.

Yes.

Because most HTML "enhanced" (cough, cough) email *IS* spam.

> I've
> played
> with a few things but can't seem to figure it out.

You'll have to compare email that makes it through that *IS* HTML
enhanced with your email, and compare all the headers and body and see
what telltales triggered the spam filter.

Spam filters these days are complex operations calculating the "odds"
that any given piece of email is or isn't junk.

If you can find out exactly what software / rules Yahoo uses to
determine what is/isn't spam, then you could compose your email to not
get caught -- But I doubt that Yahoo publishes this info.  And it's
subject to change without notice anyway.

Your best bet is to get the recipients to whitelist your sending
address so they always get your email.

If you can't get them to do that, then they must not want your email
all that badly, and you might as well give up on them.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: php/ajax..

2006-08-07 Thread Manuel Lemos
Hello,

on 08/07/2006 04:11 PM bruce said the following:
> will php allow a user to enter field on a form, and compute aresult based on
> the field, without having to reload the entire form, or will i need ajax...
> 
> any good examples on how to accomplish this..

You may want to take a look at this forms generation class that comes
with plug-in to submit and process forms using AJAX. It lets you execute
arbitrary actions on the server side with PHP and you can tell it to
update as many parts of your page as you want. With this plug-in you can
do it all in PHP without writing a single line of Javascript.

Take a look in particular at the example test_ajax_form.php . It shows
how to submit a form with a simple text field and a file upload field,
and then process it on the server side and some progress report feedback.

http://www.phpclasses.org/formsgeneration

Also take a look at the test_linked_select.php and
test_auto_complete.php examples that take advantage of the class AJAX
plug-in features.

-- 

Regards,
Manuel Lemos

Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PDO and PGSQL: ERROR: syntax error at or near "SET"

2006-08-07 Thread Richard Lynch
On Mon, August 7, 2006 6:48 am, Erik Gyepes wrote:
> I'm trying to learn using PDO and PostgreSQL together a little bit and
> I
> have some problems with (I thinks, auto incrementing fields)
> I have the following sample DB:
>
> CREATE TABLE users (
> uid SERIAL UNIQUE NOT NULL,

My PostgreSQL knowledge is very out-dated, but I always used to have
to do:

create sequence users_id;
create table users (
  uid int4 unique not null primary key default 'nextval(users_id)',

as I recall.

It's quite likely that PostgreSQL added the SERIAL type and I'm just
an old dog...

>$query = "INSERT INTO users SET uid = :uid, login = :login,
> password
> = :password";

As far as I know, only MySQL actually lets you mangle SQL in that
particular fashion...

insert into users (uid, login, password) values(:uid, :login, :password)

is probably what you want, assuming the :variable is how PDO does things.

You're on your own for the PDO stuff...

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] saving and retrieving an array from a database

2006-08-07 Thread Richard Lynch
On Mon, August 7, 2006 7:52 am, [EMAIL PROTECTED] wrote:
> ok this seem to work but how do I bring it back? This is what I have
> so far.
>
>  $first[] = array('appple', 'pear', 'banana');
> $second = serialize($first);

Store $second in the DB here.

It's just a big long-ass string at this point.

You can use echo $second; to see what it looks like.


[cue clock fast-forward visual sequence]

Pull $second (or whatever you want to call it) out of the database.

It's just a big long string.

> $third[]= unserialize($second);

This de-constructs that big string into an array, and you are back in
business.

> echo $second; //outputs serialized data
> echo $third[1];
>
> ?>

NOTE:
90% of the time, you should be putting each array item into the
database separately, so you can use SQL to retrieve only the bits you
need instead of schlepping the whole thing back and forth all the
time...

If you are new to programming, think long and hard about what you will
be doing with these array elements, and if you plan on using PHP to
search/sort/filter them at some point, don't do that.  Put them in as
individual data in the DB.

If you always use the whole array, and never search it, sort it, or
filter it down to fewer elements, and are just shuffling it
back-and-forth, then serializing it and storing it en masse is fine.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Mixing sprintf and mysql_real_escape_string

2006-08-07 Thread Peter Lauri
Hi,

I get strange output if I combine sprintf and mysql_real_escape_string. If I
do this the resulting into the database is \' not ' as I want.

mysql_query(sprintf("INSERT INTO table (value1, value2) VALUES (1, '%s')",
mysql_real_escape_string(" ' ")));

Should this be like this? Do the sprintf already add slashes or something?

/Peter

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Declaring variables from the url

2006-08-07 Thread Richard Lynch
On Mon, August 7, 2006 8:13 am, Dave M G wrote:
> I have many times set the value of a variable by declaring it in the
> URL, like so:
>
> http://www.domain.com/index.php?var=1
>
> And then, to use the variable, all I have to do is use it in the
> script,
> like so:
>
> echo "This is the value of the variable: " . $var;
>
> But, for some reason, in a script I'm writing now, this simple process
> isn't working.
>
> The only thing I can think of that is different between before and now
> is that the new script is being executed in PHP5, whereas before was
> with PHP4.
>
> In my new script, I check the value of $_SERVER['QUERY_STRING'], the
> value is contained in there, so it is being assigned and contained
> somehow.
>
> What could I possibly be missing in what should be a super simple
> process?

http://php.net/register_globals

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Is this really a pdf?

2006-08-07 Thread Richard Lynch
On Mon, August 7, 2006 10:04 am, Ed Curtis wrote:
>
> On Mon, 7 Aug 2006, Sjef wrote:
>
>> Is it possible to recognize if a file for upload really is a pdf
>> (like the
>> function getimagesize retuns the file type of the image)?
>> Thanxs,
>> Sjef
>
>  Yes it is.
>
>  $_FILES['{form_field_name}']['type'] is your friend here. Just match
> it
> against a mime type your looking for.

$_FILE[*]['type'] is pretty useless all around...

It's useless as a Security method because a Bad Guy can send anything
they want for that.

It's useless in the general sense because IE and Mozilla-esque
browsers send *different* MIME types for the same file.

There is no standard they are following for what is the MIME type of a
JPEG, PNG, etc.  So you'd have to predict every possible MIME type
that a browser *might* send for any given file type, and there's no
predicting IE, for starters.

It would be nice if the browsers provided standardized info, as this
would be one more hurdle to put in the way of errors, but as it stands
now, I'd avoid bothering with it.  Too much hassle for too little
payoff.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Is this really a pdf?

2006-08-07 Thread Richard Lynch
On Mon, August 7, 2006 9:08 am, Sjef wrote:
> Is it possible to recognize if a file for upload really is a pdf (like
> the
> function getimagesize retuns the file type of the image)?

It should be noted that getimagesize is also not fool-proof for the
same reasons as the PDF first-4 bytes == '%PDF' is not "secure"

getimagesize only looks at the first N bytes to figure out
width/height/etc.

It's a bit more complex than the PDF version, as it has to choose the
right bytes for the given image type, but it's not an exhaustive check
that the file *IS* a valid image file.

That said, this can be one more simple/easy barrier in place in a
series of security checks, both for Images and PDFs.

The only way to be 99.9% certain an image is a valid image is to
have a human eyeball look at it -- leaving the remainder of a
percentage for "art" images too weird to be distinguished from noise.

It's also theoretically possible that some single specific image "out
there" could "look" fine, but by sheer coincidence that specific
sequency of bytes could ALSO be a malicious program.

That's kind of pointless in the general sense, except as an indicator
that you will never get 100% certainty, so it's probably best to do
several fast easy checks that rely on un-related data so that you have
a series of barriers rather than a single point of failure in your
security.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] stupid question...compiling php

2006-08-07 Thread Andrew Kreps

I'll bet your hosting environment has not installed the php sources.
If the server is shared with other clients, you'll probably need to
download the source and compile php in your user space and run it as a
CGI (if your host allows this configuration).  Hopefully they have
some allowances for this, you may want to check with them.

On 8/7/06, Jochem Maas <[EMAIL PROTECTED]> wrote:

blackwater dev wrote:
I can do phpinfo but that
> tells
> me the config line and where the ini files are, not necessarily where the
> configure stuff is to recompile...correct?



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Sending data to persistent process stdin

2006-08-07 Thread Richard Lynch
On Sat, August 5, 2006 8:08 am, Ville Mattila wrote:
> I have been thinking of making a simple web-based interface to control
> my media center box (running debian linux). Being a bit enthustiatic,
> I
> thought I could use some generic tools for playing media files and
> write
> the whole UI by my own.

There are more than a few PHP Jukebox applications out there...

Maybe see how they did it.

> I found mpg123 program that can be run in "remote mode" (mpg123 -R) so
> that playback can be controlled via stdin. Writing "LOAD "
> to
> the stdin will begin output, "PAUSE" will stop it and so on.
>
> How could I use PHP and its process functions to send something to
> stdin
> of a persistent process? I would like to run mpg123 only once,
> whichafter a few PHP scripts would send data and proper commands to
> its
> stdin. Maybe a kind of daemon process would be needed? Anyway, sending
> data to a daemon can be problematic... Maybe a kind of socket wrapper?
> Well - I have no experience about socket functions of PHP...

http://php.net/socket

should get you started on this road.

> Tips and tricks are welcome, or should I just go to the local hi-tech
> market and by a CD player LOL :D



-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Newbie Form Question

2006-08-07 Thread Andrew Kreps

Better yet, don't allow the user to enter a From address.  Simply give
them subscribe and unsubscribe radio buttons, and make sure the
un/subscribe-ee gets a confirmation email.  And certainly check your
input fields for newlines.  :)

On 8/7/06, Richard Lynch <[EMAIL PROTECTED]> wrote:

On Mon, August 7, 2006 2:37 am, David Dorward wrote:
> Richard Lynch wrote:
>
>> >   if (isset($_REQUEST['email'])){
>> $success = mail($_REQUEST['action'], 'un/subscribe',
>> 'un/subscribe', "From: $_REQUEST[email]\r\nReply-to:
>> $_REQUEST[email]");
>> if ($success) echo "Status Change Sent";
>> else echo "Unable to send Status Change";
>>   }
>> ?>
>
> What if someone submitted:
>
> action = [EMAIL PROTECTED]
>
> email = [EMAIL PROTECTED] long winded evil spam message here
>
> ?


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Using preg_match to find Japanese text

2006-08-07 Thread Richard Lynch
On Sat, August 5, 2006 9:06 pm, Dave M G wrote:
> While I'm only just learning about regular expressions in another
> thread, I still seem to be finding exceptional situations which have
> me
> questioning the extent to which preg expressions can be implemented.
>
> (The following contains UTF-8 encoded Japanese text. Apologies if it
> comes out as ASCII gibberish.)
>
> What I have are sentences that look like this:
> 気温 【きおん】 (n) atmospheric temperature; (P); EP
> について (exp) concerning; along; under; per; KD

Can you be sure that '(' will not appear in the Japanese part?

preg_match('/^(.*)(\\(.*$)/', $text, $parts);
echo "Japanese: $parts[1]\n";
echo "Definition: $parts[2]\n";

Then you could break apart the Japanese part based on whether there
are or aren't the delimiters for the "reading" -- they looked kinda
like parentheses before my ascii-centric email munged them.

You might even be able to combine it all into one big preg_match if
you worked at it.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] client<->server upload communication?

2006-08-07 Thread Richard Lynch
On Sun, August 6, 2006 9:56 am, tedd wrote:
> I posted this question on a js list, but didn't received an answer.
> Maybe someone here might be able to provide some insight or direction.
>
> In my ajax "experiment" monitoring states, namely:
>
> http://xn--ovg.com/ajax_readystate
>
> I can see the readyState replies/conditions.
>
> Is there something similar when uploading a file or image?

Not yet, in PHP, unless you patch it, or do some kind of icky hack
with Javascript and a ton of overhead HTTP traffic.

> There has to be some sort of communication between the sender and the
> receiver, right?

Yes.

> If so, is there a way to tap into that communication?

Not yet, in PHP, but there is a patch in the works for it, from what
I've seen on 'internals' list, and you can Google for "PHP File Upload
Progress Meter Patch" and find several variants on the same theme.

Apparently every Designer in the world wants their own upload progress
meter because none of them like the browser's upload meter. :-;

Of course, you still need to get that info *BACK* to the browser if
PHP is the one monitoring the upload progress -- It seems to me like
the BROWSER ought to be providing a hook to this client-side, since
that's where you want the progress meter.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Newbie Form Question

2006-08-07 Thread Richard Lynch
On Mon, August 7, 2006 2:37 am, David Dorward wrote:
> Richard Lynch wrote:
>
>> >   if (isset($_REQUEST['email'])){
>> $success = mail($_REQUEST['action'], 'un/subscribe',
>> 'un/subscribe', "From: $_REQUEST[email]\r\nReply-to:
>> $_REQUEST[email]");
>> if ($success) echo "Status Change Sent";
>> else echo "Unable to send Status Change";
>>   }
>> ?>
>
> What if someone submitted:
>
> action = [EMAIL PROTECTED]
>
> email = [EMAIL PROTECTED] long winded evil spam message here
>
> ?


-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Image list performance ISSUE

2006-08-07 Thread Richard Lynch
On Mon, August 7, 2006 2:44 am, Andy wrote:
> The performance Issue that I asked was:
> Is there a difference if apache sends the image or If I output it with
> php
> with readfile.

Yes.

How much of a difference it makes depends on YOUR hardware.

Test it and see is the only sensible answer we can give.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Re: php/ajax..

2006-08-07 Thread bruce
thanks for the reply...

that's pretty much what i had read/found out..

'ppreciate it..

-Original Message-
From: Adam Zey [mailto:[EMAIL PROTECTED]
Sent: Monday, August 07, 2006 12:04 PM
To: [EMAIL PROTECTED]
Cc: php-general@lists.php.net
Subject: [PHP] Re: php/ajax..


bruce wrote:
> hi..
>
> will php allow a user to enter field on a form, and compute aresult based
on
> the field, without having to reload the entire form, or will i need
ajax...
>
> any good examples on how to accomplish this..
>
> thanks

PHP is a server-side language. Javascript is a client-side language.
Such things need to be done on the client side, at which point they're
usually called AJAX. PHP can be used for the server-side of an AJAX
application.

Regards, Adam Zey.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] php/ajax..

2006-08-07 Thread Robert Cummings
On Mon, 2006-08-07 at 21:15 +0700, Peter Lauri wrote:
> Robert, have you studied Neuron Networks?

I've touched on them. Though I'm sure we both know to which kind of
neuron I was referring :)

Cheers,
Rob.


> 
> -Original Message-
> From: Robert Cummings [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, August 08, 2006 2:16 AM
> To: [EMAIL PROTECTED]
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] php/ajax..
> 
> On Mon, 2006-08-07 at 12:11 -0700, bruce wrote:
> > hi..
> > 
> > will php allow a user to enter field on a form, and compute aresult based
> on
> > the field, without having to reload the entire form, or will i need
> ajax...
> > 
> > any good examples on how to accomplish this..
> 
> You have 150 posts since February 5th 2005, are you pulling our leg? or
> are you missing a few neurons?
> 

-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: php/ajax..

2006-08-07 Thread Adam Zey

bruce wrote:

hi..

will php allow a user to enter field on a form, and compute aresult based on
the field, without having to reload the entire form, or will i need ajax...

any good examples on how to accomplish this..

thanks


PHP is a server-side language. Javascript is a client-side language. 
Such things need to be done on the client side, at which point they're 
usually called AJAX. PHP can be used for the server-side of an AJAX 
application.


Regards, Adam Zey.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] php/ajax..

2006-08-07 Thread Peter Lauri
Robert, have you studied Neuron Networks?

-Original Message-
From: Robert Cummings [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, August 08, 2006 2:16 AM
To: [EMAIL PROTECTED]
Cc: php-general@lists.php.net
Subject: Re: [PHP] php/ajax..

On Mon, 2006-08-07 at 12:11 -0700, bruce wrote:
> hi..
> 
> will php allow a user to enter field on a form, and compute aresult based
on
> the field, without having to reload the entire form, or will i need
ajax...
> 
> any good examples on how to accomplish this..

You have 150 posts since February 5th 2005, are you pulling our leg? or
are you missing a few neurons?

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] php/ajax..

2006-08-07 Thread Mariano Guadagnini

bruce wrote:

hi..

will php allow a user to enter field on a form, and compute aresult based on
the field, without having to reload the entire form, or will i need ajax...

any good examples on how to accomplish this..

thanks

  


PHP is executed on the server, so you cannot campute something without 
sending it back, reprocessing the form and put the result on the client 
browser's. Some basic tasks can be done in the client with javascript, 
but you have no much choices to accomplish what you want:
1)Ajax (change or reload a section or node of your document based on an 
action)

2)Frames and Javascript (reload only a frame with javascript, for example)


There are many good examples out there of either ways.

Regards,

Mariano.


--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.405 / Virus Database: 268.10.7/410 - Release Date: 05/08/2006

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] php/ajax..

2006-08-07 Thread Robert Cummings
On Mon, 2006-08-07 at 12:11 -0700, bruce wrote:
> hi..
> 
> will php allow a user to enter field on a form, and compute aresult based on
> the field, without having to reload the entire form, or will i need ajax...
> 
> any good examples on how to accomplish this..

You have 150 posts since February 5th 2005, are you pulling our leg? or
are you missing a few neurons?

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] php/ajax..

2006-08-07 Thread Jay Blanchard
[snip]
will php allow a user to enter field on a form, and compute aresult
based on
the field, without having to reload the entire form, or will i need
ajax...
[/snip]

You will only need JavaScript.

Remember, JavaScript is client-side, PHP is server-side.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] php/ajax..

2006-08-07 Thread bruce
hi..

will php allow a user to enter field on a form, and compute aresult based on
the field, without having to reload the entire form, or will i need ajax...

any good examples on how to accomplish this..

thanks

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] stupid question...compiling php

2006-08-07 Thread Jochem Maas
blackwater dev wrote:
> Ok, doing that now and it's taking a while.  

it might take forever. I made a thinko, it should have been:

php -i | grep configure

(it should be pretty much instantaneous)

I can do phpinfo but that
> tells
> me the config line and where the ini files are, not necessarily where the
> configure stuff is to recompile...correct?

correct, other than the system libs (which you refer to for some configure 
options)
- I doubt those would have change.

which pretty much leaves the php sources - and this you can download from
lots of places (you don't need to recompile from the same directory), if php
was installed as a package you will not have the source locally (probably) and
the chances are you'll be missing a stack of libs and/or development header 
files
which you would then need to install (again this depends on what configure flag
you're going to use)

> 
> On 8/7/06, Jochem Maas <[EMAIL PROTECTED]> wrote:
>>
>> blackwater dev wrote:
>> > Ok,
>> >
>> > I am using a hosted server and php is installed from the linux
>> distro.  I
>> > usually have all the stuff in a php file somewhere so I can just go
>> back
>> > ./configure, etc.  I can't seem to find the configure for php on this
>> > box so
>> > I can recompile but I know it is there as I can use php and see the
>> > version,
>> > how can I find the configure to use?
>>
>> php -l | grep configure
>>
>> or
>>
>> >
>> >
>> > Thanks!
>> >
>>
>>
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] stupid question...compiling php

2006-08-07 Thread blackwater dev

Ok, doing that now and it's taking a while.  I can do phpinfo but that tells
me the config line and where the ini files are, not necessarily where the
configure stuff is to recompile...correct?

On 8/7/06, Jochem Maas <[EMAIL PROTECTED]> wrote:


blackwater dev wrote:
> Ok,
>
> I am using a hosted server and php is installed from the linux
distro.  I
> usually have all the stuff in a php file somewhere so I can just go back
> ./configure, etc.  I can't seem to find the configure for php on this
> box so
> I can recompile but I know it is there as I can use php and see the
> version,
> how can I find the configure to use?

php -l | grep configure

or


> Thanks!
>




Re: [PHP] stupid question...compiling php

2006-08-07 Thread Jochem Maas
blackwater dev wrote:
> Ok,
> 
> I am using a hosted server and php is installed from the linux distro.  I
> usually have all the stuff in a php file somewhere so I can just go back
> ./configure, etc.  I can't seem to find the configure for php on this
> box so
> I can recompile but I know it is there as I can use php and see the
> version,
> how can I find the configure to use?

php -l | grep configure

or

 
> Thanks!
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] stupid question...compiling php

2006-08-07 Thread blackwater dev

Ok,

I am using a hosted server and php is installed from the linux distro.  I
usually have all the stuff in a php file somewhere so I can just go back
./configure, etc.  I can't seem to find the configure for php on this box so
I can recompile but I know it is there as I can use php and see the version,
how can I find the configure to use?

Thanks!


Re: [PHP] session array

2006-08-07 Thread Jochem Maas
Ross wrote:
> I am creating an array of sessions
> 
> $_SESSION['results'][]

always call session_start() before using $_SESSION

> 
> 
> There may be up to 7 and I need to know why do  I always get the 
> notice'Undefined index: results in...'?
> 
> How do I define or initialise the array if it only gets set once the form 
> has been posted (an answer has been given) on the page.
> 
> Is there a way to count/output (FOR EACH?) a set of session arrays like 

if (is_array($_SESSION['results'])) echo 'number of results is ', 
count($_SESSION['results']);

foreach ($_SESSION['results'] as $number => $data) {
echo "result number $number contains:";
var_dump($data);
}

> this?
> 
> 
> Ta,
> 
> Ross
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How to get rid off empty elements of an array?

2006-08-07 Thread Martin Alterisio

2006/8/7, [EMAIL PROTECTED] <[EMAIL PROTECTED]>:


Hi to all!

I have a form with 6 text fields where visitor has to enter product serial
number (same type data). he has to enter AT LEAST ONE.

for ($i=0; $i<6; $i++)
{
echo '';
}

After the form is submitted I'm getting an array

Array
(
[0] => abc123
[1] => ddd111
[2] => poi987
[3] =>
[4] =>
[5] =>
)

Now, I need to get rid off empty elements of the array, to get this:

Array
(
[0] => abc123
[1] => ddd111
[2] => poi987
)

To do that I tried:
foreach ($PSN as $value)
{
   if (!empty($value))$PSN_New[] = $value;
}
but every time I'm getting one additional element of the array:

I tried
foreach ($PSN as $value)
{
   if ($value != '')$PSN_New[] = $value;
}
too - same result.

Array
(
[0] => abc123
[1] => ddd111
[2] => poi987
[3] =>
)

No space or anything else is "entered" in 4th field.

What I'm doing wrong?

Thanks for any help.

-afan

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



There are probably some whitespaces in the elements which refuse to be
deleted.
Also consider using array_filter() instead of looping through the array
(used without a callback function filter all elements which evaluate to
boolean false).


[PHP] Re: Is this really a pdf?

2006-08-07 Thread Colin Guthrie

Rory Browne wrote:

http://uk.php.net/manual/en/function.mime-content-type.php



Is this to protect against somebody trying to pass an mp3 off as a PDF, or
to stop people mistakenly uploading PDF's. If it's the latter, then mime
functions are probably okay. If the former, then you may want something a
little more through.

snip

(or other versions - perhaps just verify the first 4 chars.

You can do this with a simple

snip

This is very simple.



And very insecure. All it takes is a cat and echo to disguise a file as a
PDF, and a quick 'dd skip' to Undisguise it.


Absolutely! Incredibly insecure! :)

But again as you stated yourself, if it's just to help users rather than 
preventing unotherised content, then either way would work most of the 
time. It would be fairly trivial to write a valid PDF that was actually 
an MP3 encoded specially, a few pages or so of base64 would do!!


Col.


Col.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How to get rid off empty elements of an array?

2006-08-07 Thread John Wells

Check the 5th and 6th fields.  Something is in one of them.  Because
based on your checks, it will work:

[php]
$first_array = array(
   'first',
   'second',
   'third',
   '',
   '',
   '');

foreach ($first_array as $value)
{
if (!empty($value))$second_array[] = $value;
}

var_dump($second_array);

foreach ($first_array as $value)
{
if ($value != '')$third_array[] = $value;
}

var_dump($third_array);
[/php]

HTH,
John W

On 8/7/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

Hi to all!

I have a form with 6 text fields where visitor has to enter product serial
number (same type data). he has to enter AT LEAST ONE.

for ($i=0; $i<6; $i++)
{
echo '';
}

After the form is submitted I'm getting an array

Array
(
[0] => abc123
[1] => ddd111
[2] => poi987
[3] =>
[4] =>
[5] =>
)

Now, I need to get rid off empty elements of the array, to get this:

Array
(
[0] => abc123
[1] => ddd111
[2] => poi987
)

To do that I tried:
foreach ($PSN as $value)
{
   if (!empty($value))$PSN_New[] = $value;
}
but every time I'm getting one additional element of the array:

I tried
foreach ($PSN as $value)
{
   if ($value != '')$PSN_New[] = $value;
}
too - same result.

Array
(
[0] => abc123
[1] => ddd111
[2] => poi987
[3] =>
)

No space or anything else is "entered" in 4th field.

What I'm doing wrong?

Thanks for any help.

-afan

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] session arrays

2006-08-07 Thread Ross
I am creating an array of sessions

$_SESSION['results'][]


There may be up to 7 and I need to know why do  I always get the
notice'Undefined index: results in...'?

How do I define or initialise the array if it only gets set once the form
has been posted (an answer has been given) on the page.

Is there a way to count/output (FOR EACH?) a set of session arrays like
this?


Ta,

Ross

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Declaring variables from the url

2006-08-07 Thread Adam Zey

Dave M G wrote:

PHP list,

I have many times set the value of a variable by declaring it in the 
URL, like so:


http://www.domain.com/index.php?var=1

And then, to use the variable, all I have to do is use it in the script, 
like so:


echo "This is the value of the variable: " . $var;

But, for some reason, in a script I'm writing now, this simple process 
isn't working.


The only thing I can think of that is different between before and now 
is that the new script is being executed in PHP5, whereas before was 
with PHP4.


In my new script, I check the value of $_SERVER['QUERY_STRING'], the 
value is contained in there, so it is being assigned and contained somehow.


What could I possibly be missing in what should be a super simple process?

--
Dave M G


Before, you were relying on PHP's register_globals setting, which did 
what you describe. Since the use of this setting is an enormous security 
hole, and there is zero reason to use it outside of backwards 
compatibility with old scripts, it has long since been disabled by default.


You should instead reference GET variables like so:

$_GET['var']

And POST like this:

$_POST['var']

This is much safer. If you REALLY want to turn on register_globals (And 
I strongly recommend against it, it's a huge risk), information on how 
to do this can be found in the PHP manual.


Regards, Adam.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Is this really a pdf?

2006-08-07 Thread Rory Browne

On 8/7/06, Colin Guthrie <[EMAIL PROTECTED]> wrote:


Sjef wrote:
> Is it possible to recognize if a file for upload really is a pdf (like
the
> function getimagesize retuns the file type of the image)?

If you have a suitible mime.magic file, and your PHP has the
functionality built into it, you could try the mime_content_type()
function.
http://uk.php.net/manual/en/function.mime-content-type.php



Is this to protect against somebody trying to pass an mp3 off as a PDF, or
to stop people mistakenly uploading PDF's. If it's the latter, then mime
functions are probably okay. If the former, then you may want something a
little more through.



Or if not available, read the first few bytes of the file and verify

that it begins with:
%PDF-1.3
(or other versions - perhaps just verify the first 4 chars.

You can do this with a simple

$fp = fopen($filename, 'rb'));
if ('%PDF' == fread($fp, 4))
   // PDF
else
   // Not PDF

This is very simple.



And very insecure. All it takes is a cat and echo to disguise a file as a
PDF, and a quick 'dd skip' to Undisguise it.


You could also use the "file" commandline utility if the server is a

*nix machine and parse it's output.

e.g. on my machine:
[EMAIL PROTECTED] www]$ file ~/Desktop/svn-book.pdf
/home/colin/Desktop/svn-book.pdf: PDF document, version 1.3

or easier:

[EMAIL PROTECTED] www]$ file -i ~/Desktop/svn-book.pdf
/home/colin/Desktop/svn-book.pdf: application/pdf


Col.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] session array

2006-08-07 Thread Stut

Ross wrote:

I am creating an array of sessions

$_SESSION['results'][]


There may be up to 7 and I need to know why do  I always get the 
notice'Undefined index: results in...'?


How do I define or initialise the array if it only gets set once the form 
has been posted (an answer has been given) on the page.


Is there a way to count/output (FOR EACH?) a set of session arrays like 
this?


Before you try to access the $_SESSION['results'] array, do this...

if (!isset($_SESSION['results'])) $_SESSION['results'] = array();

As far as counting and outputting a session array there is nothing 
special about them - they are the same as any other array variable. This 
means you can use foreach, print_r, var_dump, etc on them.


-Stut

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] POST on redirects?

2006-08-07 Thread Adam Zey

Chris Shiflett wrote:

Adam Zey wrote:
  

$headers .= "Content-Type: application/octet-stream\r\n";



I missed the context of this function, but it seems like you probably
mean to send:

Content-Type: application/x-www-form-urlencoded

Chris

  


The context is a bit strange, these POST transactions are being used to 
send data packets, since it's really the only way to send data to a 
server-side PHP script. The scripts involved are used to tunnel 
arbitrary TCP/IP data over a standard HTTP connection. The keepalive 
means that many POST transactions can be done in one connection, saving 
the latency and overhead involved in establishing new TCP/IP 
connections. And the content type of an octet stream is used because 
x-www-form-urlencoded would have to be decoded by the script on the 
server side. With an octet stream, the server-side script can just read 
the data in from php://input.


Thanks for the hint on the Connection header. It'll save me from more 
overhead :)


Regards, Adam Zey.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] session array

2006-08-07 Thread Ross
I am creating an array of sessions

$_SESSION['results'][]


There may be up to 7 and I need to know why do  I always get the 
notice'Undefined index: results in...'?

How do I define or initialise the array if it only gets set once the form 
has been posted (an answer has been given) on the page.

Is there a way to count/output (FOR EACH?) a set of session arrays like 
this?


Ta,

Ross

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] POST on redirects?

2006-08-07 Thread Chris Shiflett
Adam Zey wrote:
> $headers .= "Content-Type: application/octet-stream\r\n";

I missed the context of this function, but it seems like you probably
mean to send:

Content-Type: application/x-www-form-urlencoded

Chris

-- 
Chris Shiflett
Principal, OmniTI
http://omniti.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] POST on redirects?

2006-08-07 Thread Chris Shiflett
Adam Zey wrote:
> function make_post($message)
> {
> $headers .= "POST /foo.php HTTP/1.1\r\n";
> $headers .= "Host: bar.com\r\n";
> $headers .= "Content-Type: application/octet-stream\r\n";
> $headers .= "Connection: keep-alive\r\n";
> $headers .= "Content-Length: " . strlen($message) . "\r\n";
> $headers .= "\r\n";
> return $headers . $message;
> }
> 
> As far as I can tell, these are the absolute minimum set of
> headers you can get away with for a POST transaction (If you
> know how to use less, let me know, I use this in a situation
> where overhead matters).

Your Connection header is redundant, since that's the default value in
HTTP/1.1.

I would send the header but give it a value of close, since I see no
good reason to leave the TCP connection open until it times out. That's
a pretty big waste in a situation where overhead matters.

Hope that helps.

Chris

-- 
Chris Shiflett
Principal, OmniTI
http://omniti.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] SOLVED (spelling error) - Re: [PHP] How to get rid off empty elements of an array?

2006-08-07 Thread afan
Sorry for this. Spelling error.
:(

-afan

> Hi to all!
>
> I have a form with 6 text fields where visitor has to enter product serial
> number (same type data). he has to enter AT LEAST ONE.
>
> for ($i=0; $i<6; $i++)
> {
> echo ' size="25">';
> }
>
> After the form is submitted I'm getting an array
>
> Array
> (
> [0] => abc123
> [1] => ddd111
> [2] => poi987
> [3] =>
> [4] =>
> [5] =>
> )
>
> Now, I need to get rid off empty elements of the array, to get this:
>
> Array
> (
> [0] => abc123
> [1] => ddd111
> [2] => poi987
> )
>
> To do that I tried:
> foreach ($PSN as $value)
> {
>if (!empty($value))$PSN_New[] = $value;
> }
> but every time I'm getting one additional element of the array:
>
> I tried
> foreach ($PSN as $value)
> {
>if ($value != '')$PSN_New[] = $value;
> }
> too - same result.
>
> Array
> (
> [0] => abc123
> [1] => ddd111
> [2] => poi987
> [3] =>
> )
>
> No space or anything else is "entered" in 4th field.
>
> What I'm doing wrong?
>
> Thanks for any help.
>
> -afan
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Is this really a pdf?

2006-08-07 Thread Colin Guthrie

Sjef wrote:
Is it possible to recognize if a file for upload really is a pdf (like the 
function getimagesize retuns the file type of the image)?


If you have a suitible mime.magic file, and your PHP has the 
functionality built into it, you could try the mime_content_type() function.

http://uk.php.net/manual/en/function.mime-content-type.php


Or if not available, read the first few bytes of the file and verify 
that it begins with:

%PDF-1.3
(or other versions - perhaps just verify the first 4 chars.

You can do this with a simple

$fp = fopen($filename, 'rb'));
if ('%PDF' == fread($fp, 4))
  // PDF
else
  // Not PDF

This is very simple.


You could also use the "file" commandline utility if the server is a 
*nix machine and parse it's output.


e.g. on my machine:
[EMAIL PROTECTED] www]$ file ~/Desktop/svn-book.pdf
/home/colin/Desktop/svn-book.pdf: PDF document, version 1.3

or easier:

[EMAIL PROTECTED] www]$ file -i ~/Desktop/svn-book.pdf
/home/colin/Desktop/svn-book.pdf: application/pdf


Col.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Is this really a pdf?

2006-08-07 Thread Ed Curtis


On Mon, 7 Aug 2006, Sjef wrote:

> Is it possible to recognize if a file for upload really is a pdf (like the
> function getimagesize retuns the file type of the image)?
> Thanxs,
> Sjef

 Yes it is.

 $_FILES['{form_field_name}']['type'] is your friend here. Just match it
against a mime type your looking for.

Ed Curtis

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] How to get rid off empty elements of an array?

2006-08-07 Thread afan
Hi to all!

I have a form with 6 text fields where visitor has to enter product serial
number (same type data). he has to enter AT LEAST ONE.

for ($i=0; $i<6; $i++)
{
echo '';
}

After the form is submitted I'm getting an array

Array
(
[0] => abc123
[1] => ddd111
[2] => poi987
[3] =>
[4] =>
[5] =>
)

Now, I need to get rid off empty elements of the array, to get this:

Array
(
[0] => abc123
[1] => ddd111
[2] => poi987
)

To do that I tried:
foreach ($PSN as $value)
{
   if (!empty($value))$PSN_New[] = $value;
}
but every time I'm getting one additional element of the array:

I tried
foreach ($PSN as $value)
{
   if ($value != '')$PSN_New[] = $value;
}
too - same result.

Array
(
[0] => abc123
[1] => ddd111
[2] => poi987
[3] =>
)

No space or anything else is "entered" in 4th field.

What I'm doing wrong?

Thanks for any help.

-afan

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Is this really a pdf?

2006-08-07 Thread Barry

Sjef schrieb:
Is it possible to recognize if a file for upload really is a pdf (like the 
function getimagesize retuns the file type of the image)?

Thanxs,
Sjef 

this "might" help

http://de3.php.net/manual/en/function.mime-content-type.php

--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: saving and retrieving an array from a database

2006-08-07 Thread Colin Guthrie

[EMAIL PROTECTED] wrote:
ok this seem to work but how do I bring it back? This is what I have so 
far.





I think you misunderstand how arrays work (at least in your example)

I think you really meant to try something like this:



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] yahoo thinks html mail is spam, what's wrong with header?

2006-08-07 Thread Austin Denyer
blackwater dev wrote:
> Hello all,
> 
> When I try to send email from my server as html, my yahoo account and
> several of my user's email accounts mark it as spam.  I can send a normal
> email via mail() just fine but when I try to to html, it's bad.  I've
> played
> with a few things but can't seem to figure it out.  The html I am sending
> just includes a table, no body, head, etc, just table html code.



Well, html e-mail is generally a Bad Thing.  Many people (myself
included) use applications such as SpamAssassin and html in e-mail
increases it's 'spamminess' from a scoring point of view.

Regards,
Austin.


signature.asc
Description: OpenPGP digital signature


[PHP] Is this really a pdf?

2006-08-07 Thread Sjef
Is it possible to recognize if a file for upload really is a pdf (like the 
function getimagesize retuns the file type of the image)?
Thanxs,
Sjef 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] design?

2006-08-07 Thread Sjef
Thanks, John.
It's probably also a matter of how you name the classes. It needs to be a 
clear name that describes what it 'is'. Hence, the depot name.
Anyway, indeed I have finished the concept of the app.
Sjef

""John Wells"" <[EMAIL PROTECTED]> schreef in bericht 
news:[EMAIL PROTECTED]
> On 6/30/06, Sjef <[EMAIL PROTECTED]> wrote:
>> Thanks, John,
>> I'm not sure I completely get the idea of a pair class.
>>
>> As an question and answer are in the same database tabel I now created a
>> questionDepot class that gets the array from the db, does save and update
>> operations, and for example, sets a flag in the db tabel when a question 
>> is
>> accepted for the list.
>>
>
> Hi Sjef,
>
> It sounds as if you've got the idea, even if I didn't explain myself
> well.  My point was to *not* create a Question class that maintained
> an array of questions, which was only _implicitly_ related to a
> similarly-structured but disparate Answers class.  An array of
> questions sitting beside an array of answers is, in my opinion, not a
> proper abstraction of the objects you're dealing with.
>
> Perhaps it is out of experience that I'm harping on this point,
> because I've been burned by a similar design before.  One of my first
> OO projects was a weblog, and I had built a Post class, and then for
> posts with galleries, a separate Gallery class that contained *only*
> image information for it's parent Post.
>
> On it's own, this wasn't all bad, but the big mistake I made was how I
> handled multiple posts and multiple galleries (like for building out
> the homepage where I showed 5 recent posts and a thumbnail from each,
> if they were galleries).  Within each Post and Gallery class, I turned
> the properties into _arrays_.  So what originally was a string for the
> post's title, now became an array of strings for many posts.  Likewise
> for the Gallery class.  Arrays of thumbnails became arrays of arrays
> of thumbnails.
>
> I'm sure The List will shudder at this design, but hey, I've learned
> my lesson.  Be-lieve-me.  Anyway, the point is, your initial approach
> was the same (if I read it correctly).  You suggested an array of
> questions, and an array of answers, which would only be implicitly
> related.  Your design started with the concept of many questions, and
> many answers, but my argument is that, abstractly, you should begin
> with one question, and one answer.  Then think in terms of a
> question-answer pair that *belong to each other*.  And then think of
> many question-answer pairs.
>
> Anyway, I'm sure that by the time you've finished reading this
> hair-splitting rambling, you've already finished your app and moved on
> to something else entirely.  :)
>
> -John W 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: yahoo thinks html mail is spam, what's wrong with header?

2006-08-07 Thread Colin Guthrie

blackwater dev wrote:

Hello all,

When I try to send email from my server as html, my yahoo account and
several of my user's email accounts mark it as spam.  I can send a normal
email via mail() just fine but when I try to to html, it's bad.  I've 
played

with a few things but can't seem to figure it out.  The html I am sending
just includes a table, no body, head, etc, just table html code.Here is 
what


Some spam filters mark poorly formed HTML as SPAM, so make sure that 
your message complies to the HTML standards. e.g. Just a table without a 
body and opening html tags is probably invalid HTML...


Just a thought.

Col.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PDO and PGSQL: ERROR: syntax error at or near "SET"

2006-08-07 Thread David Tulloh
Erik Gyepes wrote:
> ...
>   $query = "INSERT INTO users SET uid = :uid, login = :login, password =
> :password";
>   ...
> When running the script I get the following error message: Error!:
> SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "SET" at
> character 19
> 

The INSERT INTO ... SET ... syntax is not standard SQL.  It's a mysql
extension that isn't supported by any other sql databases, such as
postgresql.

The proper insert syntax is here:
http://www.postgresql.org/docs/8.0/interactive/dml.html#DML-INSERT


David

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] php and printing

2006-08-07 Thread Peter Lauri
You can generate a PDF with fpdf and then print that.

-Original Message-
From: Jef Sullivan [mailto:[EMAIL PROTECTED] 
Sent: Monday, August 07, 2006 8:50 PM
To: php-general@lists.php.net
Subject: [PHP] php and printing

Greetings to everyone,

 

I have been able to program the capability of printing several
end-of-month statements at the click of a 

button using php. The problem I am faced with is when one of these
statements has more than one page.

Management would like to have the second page have a header similar to
the first page. 

 

My question is this, has anyone here ever set up printing through php
(or javascript) and dealt with 

multiple pages before? If so, where can you direct me for assistance?

 

 

 

 

 

Jef

 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Declaring variables from the url

2006-08-07 Thread Andrei
Also check in php.ini register_globals to be On if you want to have vars
directly available in the script...

Andy

Jay Blanchard wrote:
> [snip]
> http://www.domain.com/index.php?var=1
> 
> And then, to use the variable, all I have to do is use it in the script,
> 
> like so:
> 
> echo "This is the value of the variable: " . $var;
> [/snip]
> 
> echo $_GET['var'];
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] php and printing

2006-08-07 Thread Jef Sullivan
Greetings to everyone,

 

I have been able to program the capability of printing several
end-of-month statements at the click of a 

button using php. The problem I am faced with is when one of these
statements has more than one page.

Management would like to have the second page have a header similar to
the first page. 

 

My question is this, has anyone here ever set up printing through php
(or javascript) and dealt with 

multiple pages before? If so, where can you direct me for assistance?

 

 

 

 

 

Jef

 



RE: [PHP] Declaring variables from the url

2006-08-07 Thread Jim Moseby
> PHP list,
> 
> I have many times set the value of a variable by declaring it in the 
> URL, like so:
> 
> http://www.domain.com/index.php?var=1
> 
> And then, to use the variable, all I have to do is use it in 
> the script, 
> like so:
> 
> echo "This is the value of the variable: " . $var;
> 
> But, for some reason, in a script I'm writing now, this 
> simple process 
> isn't working.
> 
> The only thing I can think of that is different between 
> before and now 
> is that the new script is being executed in PHP5, whereas before was 
> with PHP4.
> 
> In my new script, I check the value of $_SERVER['QUERY_STRING'], the 
> value is contained in there, so it is being assigned and 
> contained somehow.
> 
> What could I possibly be missing in what should be a super 
> simple process?

To expand on Jay's excellent advice, you have been depending on "register
globals" to set the variable names for you.  This is widely regarded as a
bad practice, because you don't know for sure where $var came from.  You
should ALWAYS use $var=$_GET['var'] when taking values from the url to set a
variable.

For more information on the evils of register globals, STFA.  There have
been many discussions in this list on that topic.

JM  

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Declaring variables from the url

2006-08-07 Thread Jay Blanchard
[snip]
http://www.domain.com/index.php?var=1

And then, to use the variable, all I have to do is use it in the script,

like so:

echo "This is the value of the variable: " . $var;
[/snip]

echo $_GET['var'];

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Declaring variables from the url

2006-08-07 Thread Dave M G

PHP list,

I have many times set the value of a variable by declaring it in the 
URL, like so:


http://www.domain.com/index.php?var=1

And then, to use the variable, all I have to do is use it in the script, 
like so:


echo "This is the value of the variable: " . $var;

But, for some reason, in a script I'm writing now, this simple process 
isn't working.


The only thing I can think of that is different between before and now 
is that the new script is being executed in PHP5, whereas before was 
with PHP4.


In my new script, I check the value of $_SERVER['QUERY_STRING'], the 
value is contained in there, so it is being assigned and contained somehow.


What could I possibly be missing in what should be a super simple process?

--
Dave M G

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] saving and retrieving an array from a database

2006-08-07 Thread Peter Lauri
http://se2.php.net/serialize

/Peter

-Original Message-
From: Ross [mailto:[EMAIL PROTECTED] 
Sent: Monday, August 07, 2006 7:19 PM
To: php-general@lists.php.net
Subject: [PHP] saving and retrieving an array from a database

Hi,

I have an array of values. I want to save them with php to a single field in

my database and then retrieve them to an array.


What is the simplest way to achive this?


Ross 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] saving and retrieving an array from a database

2006-08-07 Thread Andrei
Well it seems like u made a mess there with arrays...



>From definition of first I understand it's an array of arrays with
element on position 0 (ZERO) set to an array of apple, pear, banana
elements.
If u serialize it and unserialize it you will obtain same thing...

so at the end of the script you should

echo $third[0];

Andy

[EMAIL PROTECTED] wrote:
> ok this seem to work but how do I bring it back? This is what I have so
> far.
> 
>  $first[] = array('appple', 'pear', 'banana');
> $second = serialize($first);
> $third[]= unserialize($second);
> 
> echo $second; //outputs serialized data
> echo $third[1];
> 
> ?>
> - Original Message - From: "Peter Lauri" <[EMAIL PROTECTED]>
> To: "'Ross'" <[EMAIL PROTECTED]>; 
> Sent: Monday, August 07, 2006 8:23 AM
> Subject: RE: [PHP] saving and retrieving an array from a database
> 
> 
>> http://se2.php.net/serialize
>>
>> /Peter
>>
>> -Original Message-
>> From: Ross [mailto:[EMAIL PROTECTED]
>> Sent: Monday, August 07, 2006 7:19 PM
>> To: php-general@lists.php.net
>> Subject: [PHP] saving and retrieving an array from a database
>>
>> Hi,
>>
>> I have an array of values. I want to save them with php to a single
>> field in
>>
>> my database and then retrieve them to an array.
>>
>>
>> What is the simplest way to achive this?
>>
>>
>> Ross
>>
>> -- 
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>>
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] saving and retrieving an array from a database

2006-08-07 Thread ross

ok this seem to work but how do I bring it back? This is what I have so far.


- Original Message - 
From: "Peter Lauri" <[EMAIL PROTECTED]>

To: "'Ross'" <[EMAIL PROTECTED]>; 
Sent: Monday, August 07, 2006 8:23 AM
Subject: RE: [PHP] saving and retrieving an array from a database



http://se2.php.net/serialize

/Peter

-Original Message-
From: Ross [mailto:[EMAIL PROTECTED]
Sent: Monday, August 07, 2006 7:19 PM
To: php-general@lists.php.net
Subject: [PHP] saving and retrieving an array from a database

Hi,

I have an array of values. I want to save them with php to a single field 
in


my database and then retrieve them to an array.


What is the simplest way to achive this?


Ross

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] saving and retrieving an array from a database

2006-08-07 Thread Jim Moseby
> 
> Hi,
> 
> I have an array of values. I want to save them with php to a 
> single field in 
> my database and then retrieve them to an array.
> 
> 
> What is the simplest way to achive this?
> 
> 

http://us3.php.net/serialize

Cheers!

JM

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] yahoo thinks html mail is spam, what's wrong with header?

2006-08-07 Thread blackwater dev

Hello all,

When I try to send email from my server as html, my yahoo account and
several of my user's email accounts mark it as spam.  I can send a normal
email via mail() just fine but when I try to to html, it's bad.  I've played
with a few things but can't seem to figure it out.  The html I am sending
just includes a table, no body, head, etc, just table html code.Here is what
I am using for the header:


$header="From:[EMAIL PROTECTED] <[EMAIL PROTECTED]>
\r\nContent-Type:text/html\r\n";

Here are some of the headers from yahoo:

X-Apparently-To: [EMAIL PROTECTED] via 66.196.97.50; Sun, 06 Aug 2006
13:46:30 -0700 X-YahooFilteredBulk: 64.140.230.68 X-Originating-IP: [
64.140.230.68] Return-Path: <[EMAIL PROTECTED]>
Authentication-Results: mta333.mail.re4.yahoo.com from=bwdev.com;
domainkeys=neutral (no sig) Received: from 64.140.230.68 (EHLO
localhost.localdomain) (64.140.230.68) by mta333.mail.re4.yahoo.com with
SMTP; Sun, 06 Aug 2006 13:46:30 -0700 Received: from
localhost.localdomain(web5 [
127.0.0.1]) by localhost.localdomain (8.13.1/8.13.1) with ESMTP id
k76JlHch008629 for <[EMAIL PROTECTED]>; Sun, 6 Aug 2006 15:47:17 -0400
Received: (from [EMAIL PROTECTED]) by localhost.localdomain 
(8.13.1/8.13.1/Submit)
id k76JlH8k008628; Sun, 6 Aug 2006 15:47:17 -0400 Date: Sun, 6 Aug 2006
15:47:17 -0400 Message-Id: <
[EMAIL PROTECTED]>

Thanks for any info!


[PHP] saving and retrieving an array from a database

2006-08-07 Thread Ross
Hi,

I have an array of values. I want to save them with php to a single field in 
my database and then retrieve them to an array.


What is the simplest way to achive this?


Ross 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] PDO and PGSQL: ERROR: syntax error at or near "SET"

2006-08-07 Thread Erik Gyepes

Hi all!

I'm trying to learn using PDO and PostgreSQL together a little bit and I 
have some problems with (I thinks, auto incrementing fields)

I have the following sample DB:

CREATE TABLE users (
uid SERIAL UNIQUE NOT NULL,
login TEXT NOT NULL,
password TEXT NOT NULL,
PRIMARY KEY (uid)
);

and the following PHP code:

setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

  $query = "INSERT INTO users SET uid = :uid, login = :login, password 
= :password";

  $stmt = $db->prepare($query);

  $uid = "";
  $login = "erik";
  $password = "erikSecretPass";
 
  $stmt->bindParam(':uid', $uid);

  $stmt->bindParam(':login', $login);
  $stmt->bindParam(':password', $password);
 
  $stmt->execute();
 
  $db = null;

} catch (PDOException $e) {
  print "Error!: " . $e->getMessage() . "";
  die();
}
?>

When running the script I get the following error message: Error!: 
SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "SET" at 
character 19


I know that I doing something bad, maybe with the udi column, how to use 
auto incrementing columns with PDO?


Thanks very much for your time.

Erik Gyepes

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: looking for a short/simple kind of app...

2006-08-07 Thread David Robley
bruce wrote:

> hi...
> 
> i'm looking for a short/simple kind of app to allow me to play around with
> some different tbls..
> 
> basically.. i have a couple of tbls where i have a top level tbls, and a
> few subordinate child tbls
> 
>  parent
>child
>  child
> 
> i'd like to be able to add/modify/delete items from the various tbls.. i'd
> also like to be able to display a kind of breadcrumb across the top of the
> page allowing me to get back to the selected item/tbl...
> 
> i'm willing to bet that there are numerous examples of this kind of app.
> i'm simply hoping that someone can point me to one that i can play around
> with...
> 
> thanks
> 
> -bruce

This is probably a good starting point:
http://www.sitepoint.com/article/hierarchical-data-database/3

and also, but you'll have to write your own script
http://www.dbazine.com/oracle/or-articles/tropashko4



Cheers
-- 
David Robley

I like to think of myself as a divide overflow.
Today is Prickle-Prickle, the 73rd day of Confusion in the YOLD 3172. 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Image list performance ISSUE

2006-08-07 Thread David Tulloh
Andy wrote:
> ...
> I want to know... is this a big performance issue or not(the image is handled 
> by php and not by apache directly)
> 
> OR...
> 
> Is there any other way to handle this situation???
> 
> Thanx,
> Andy.

I'd recomend doing a bit of benchmarking to figure out if the
performance hit is acceptable.  Using php is the easiest solution.

Assuming that PHP is too slow for you, you can actually solve this issue
with some abuse of mod_rewrite.

You can use cookies to control the access by using the cookie variable
with mod_rewrite, it's accessible as HTTP_COOKIE.  You will need to
parse the cookie string yourself.
This allows you to do something like link to user.png and set a cookie
user=35 and have mod_rewrite change it to access the 35.png file.  You
can also do things like block anything that doesn't match 35.png.
You can't do anything fancy like DB based permissions though.

Using cookies is still not secure however.  You can obstuficate it
fairly well but a determined user can still get around any cookie
protections.  You can beef up the mod_rewrite to handle this by using an
external program via RewriteMap and php session files, even database
access is possible.  However 99% of the time I don't think that it would
be worth it.


David

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] [Solved] Re: [PHP] shebang line drive me nuts.

2006-08-07 Thread Jochem Maas
hi Duncan,

the disk the home dirs are situated on (where the script was living)
was indeed mounted as noexec.

THANK YOU for saving me hours of mental torture (and teaching me
something in the process), thanks to everyone else for giving
their time/energy.

kind regards,
Jochem

Duncan Hill wrote:
> On Monday 07 August 2006 09:11, Jochem Maas wrote:
>> hi Robert,
>>
>> thanks for thinking with me 
> 
> Answer to list doesn't seem to have arrived.
> 
> Check that your filesystem isn't mounted noexec.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Ru locale + UTF-8

2006-08-07 Thread Tony Aldrich

Good day,
I try to set ru locale that is converted to UTF-8 in output.
I tried ru_ru.UTF-8 - with no results.
"ru" returns week and month names in win-1251.
What I missed?

Apache/2.0.55 Win32 PHP/5.1.2

Tony.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] shebang line drive me nuts.

2006-08-07 Thread Stut

Jochem Maas wrote:

I wish it was the line endings - I checked and they where unix-style.
I do edit on windows normally (unless it's some rush fix and then I'll
use vi or nano) but I have the line-endings set to unix.

vi gave no sign of a ^M and I rewrote the shebang there just to be
safe.

alas no joy.
  


There are only 2 other possibilities I can think of...

1) PHP CLI is not installed correctly
2) The mount you are executing it on is mounted noexec

-Stut

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] shebang line drive me nuts.

2006-08-07 Thread Duncan Hill
On Monday 07 August 2006 09:11, Jochem Maas wrote:
> hi Robert,
>
> thanks for thinking with me 

If the FS permissions to the binary are correct, odds are the file system is 
actually mounted noexec.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] shebang line drive me nuts.

2006-08-07 Thread Chris

Jochem Maas wrote:

Chris wrote:

Jochem Maas wrote:

Robert Cummings wrote:

On Mon, 2006-08-07 at 09:59 +0200, Jochem Maas wrote:

I have a php shell script (the execute bit of the file is set)
of which the first line is this:

#!/usr/lib/php5/bin/php -q

or this:

#!/usr/bin/php -q

or this:

#!php -q


in all cases I get the following error when I run (as root) the script:

-bash: ./makemicrositeml: /usr/lib/php5/bin/php: bad interpreter:
Permission denied


php is where I think it is:

# which php
/usr/bin/php
# ls -lart /usr/bin/php
lrwxrwxrwx 1 root root 21 May  9 11:40 /usr/bin/php ->
/usr/lib/php5/bin/php

any know what idiot thing I'm doing wrong?

Check the permissions on /usr/lib/php5 and on /usr/lib/php5/bin and
on /usr/lib/php5/bin/php

Any one of those being set incorrectly can deny you access.

all dirs in that path are readable by everyone (read and execute flag
set),
the executable is also readable & executable by everyone.

that is correct right?

Yeh, dirs should be 755, the file should be at least 755.

What o/s is this? If it's fedora 4+ do you have seLinux enabled or
something? I wonder if something else is getting in the way..


it's debian, no selinux installed. the mystery continues :-)


damn ;)

maybe time to try strac'ing it?

strace ./file.php

--
Postgresql & php tutorials
http://www.designmagick.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: shebang line drive me nuts.

2006-08-07 Thread Colin Guthrie

Jochem Maas wrote:

in all cases I get the following error when I run (as root) the script:

-bash: ./makemicrositeml: /usr/lib/php5/bin/php: bad interpreter: Permission 
denied


Do you have root access on this machine? Perhaps the sysadmin as 
configured bash to not accept "unknown" interpreters? I'd image that 
this is fairly easy to do, tho' not looked into it before.


You could also try:

#!/usr/bin/env php

instead and see if that works.

Col.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] shebang line drive me nuts.

2006-08-07 Thread Sameer N Ingole

Jochem Maas wrote:

I have a php shell script (the execute bit of the file is set)
of which the first line is this:

#!/usr/lib/php5/bin/php -q

or this:

#!/usr/bin/php -q

or this:

#!php -q


in all cases I get the following error when I run (as root) the script:

-bash: ./makemicrositeml: /usr/lib/php5/bin/php: bad interpreter: Permission 
denied


php is where I think it is:

# which php
/usr/bin/php
# ls -lart /usr/bin/php
lrwxrwxrwx 1 root root 21 May  9 11:40 /usr/bin/php -> /usr/lib/php5/bin/php

Does *any* php script give same error?
Even the simplest one like:
-- sample --
#!/path/to/php -q

-- end sample --

--
Sameer N. Ingole
http://weblogic.noroot.org/
---
Better to light one candle than to curse the darkness.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] shebang line drive me nuts.

2006-08-07 Thread Jochem Maas
Chris wrote:
> Jochem Maas wrote:
>> Robert Cummings wrote:
>>> On Mon, 2006-08-07 at 09:59 +0200, Jochem Maas wrote:
 I have a php shell script (the execute bit of the file is set)
 of which the first line is this:

 #!/usr/lib/php5/bin/php -q

 or this:

 #!/usr/bin/php -q

 or this:

 #!php -q


 in all cases I get the following error when I run (as root) the script:

 -bash: ./makemicrositeml: /usr/lib/php5/bin/php: bad interpreter:
 Permission denied


 php is where I think it is:

 # which php
 /usr/bin/php
 # ls -lart /usr/bin/php
 lrwxrwxrwx 1 root root 21 May  9 11:40 /usr/bin/php ->
 /usr/lib/php5/bin/php

 any know what idiot thing I'm doing wrong?
>>> Check the permissions on /usr/lib/php5 and on /usr/lib/php5/bin and
>>> on /usr/lib/php5/bin/php
>>>
>>> Any one of those being set incorrectly can deny you access.
>>
>> all dirs in that path are readable by everyone (read and execute flag
>> set),
>> the executable is also readable & executable by everyone.
>>
>> that is correct right?
> 
> Yeh, dirs should be 755, the file should be at least 755.
> 
> What o/s is this? If it's fedora 4+ do you have seLinux enabled or
> something? I wonder if something else is getting in the way..

it's debian, no selinux installed. the mystery continues :-)

> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] shebang line drive me nuts.

2006-08-07 Thread Chris

Jochem Maas wrote:

Robert Cummings wrote:

On Mon, 2006-08-07 at 09:59 +0200, Jochem Maas wrote:

I have a php shell script (the execute bit of the file is set)
of which the first line is this:

#!/usr/lib/php5/bin/php -q

or this:

#!/usr/bin/php -q

or this:

#!php -q


in all cases I get the following error when I run (as root) the script:

-bash: ./makemicrositeml: /usr/lib/php5/bin/php: bad interpreter: Permission 
denied


php is where I think it is:

# which php
/usr/bin/php
# ls -lart /usr/bin/php
lrwxrwxrwx 1 root root 21 May  9 11:40 /usr/bin/php -> /usr/lib/php5/bin/php

any know what idiot thing I'm doing wrong?

Check the permissions on /usr/lib/php5 and on /usr/lib/php5/bin and
on /usr/lib/php5/bin/php

Any one of those being set incorrectly can deny you access.


all dirs in that path are readable by everyone (read and execute flag set),
the executable is also readable & executable by everyone.

that is correct right?


Yeh, dirs should be 755, the file should be at least 755.

What o/s is this? If it's fedora 4+ do you have seLinux enabled or 
something? I wonder if something else is getting in the way..


--
Postgresql & php tutorials
http://www.designmagick.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Image list performance ISSUE

2006-08-07 Thread Andy

Thanks for the answers.

I will launch anyway this solution, it is more secure for us... I will 
monitor the server to see if it can handle the load.


Regards,
Andy.

- Original Message - 
From: "Chris" <[EMAIL PROTECTED]>

To: "Andy" <[EMAIL PROTECTED]>
Cc: "WeberSites LTD" <[EMAIL PROTECTED]>; 
Sent: Monday, August 07, 2006 10:58 AM
Subject: Re: [PHP] Image list performance ISSUE



Andy wrote:

Sorry for the late answer,

I have different applications and the users are kept in DB so I cannot 
make for every user a directory.
I made a solution with .htaccess from apache and redirection to a php 
script that outputs the image if the user has rights to the images.


I will still have to check the performance of the system in this case, 
but I think it will be the same.


The performance Issue that I asked was:
Is there a difference if apache sends the image or If I output it with 
php with readfile.


Yes there will be a difference.

If apache sends the image, it just does:

- is the path valid?
- send it.

If you use readfile, apache has to fire up php, process the php script 
which then sends the image (which means another handle to read the file 
and so on), so there is a big difference between the two.


Depending on how busy your server is, it may or may not be measurable but 
there is a big difference in terms of processing.


--
Postgresql & php tutorials
http://www.designmagick.com/




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] shebang line drive me nuts.

2006-08-07 Thread Jochem Maas
Robert Cummings wrote:
> On Mon, 2006-08-07 at 09:59 +0200, Jochem Maas wrote:
>> I have a php shell script (the execute bit of the file is set)
>> of which the first line is this:
>>
>> #!/usr/lib/php5/bin/php -q
>>
>> or this:
>>
>> #!/usr/bin/php -q
>>
>> or this:
>>
>> #!php -q
>>
>>
>> in all cases I get the following error when I run (as root) the script:
>>
>> -bash: ./makemicrositeml: /usr/lib/php5/bin/php: bad interpreter: Permission 
>> denied
>>
>>
>> php is where I think it is:
>>
>> # which php
>> /usr/bin/php
>> # ls -lart /usr/bin/php
>> lrwxrwxrwx 1 root root 21 May  9 11:40 /usr/bin/php -> /usr/lib/php5/bin/php
>>
>> any know what idiot thing I'm doing wrong?
> 
> Check the permissions on /usr/lib/php5 and on /usr/lib/php5/bin and
> on /usr/lib/php5/bin/php
> 
> Any one of those being set incorrectly can deny you access.

all dirs in that path are readable by everyone (read and execute flag set),
the executable is also readable & executable by everyone.

that is correct right?

> 
> Cheers,
> Rob.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] shebang line drive me nuts.

2006-08-07 Thread Jochem Maas
hi Robert,

thanks for thinking with me 

Robert Cummings wrote:
> On Mon, 2006-08-07 at 09:59 +0200, Jochem Maas wrote:
>> I have a php shell script (the execute bit of the file is set)
>> of which the first line is this:
>>
>> #!/usr/lib/php5/bin/php -q
>>
>> or this:
>>
>> #!/usr/bin/php -q
>>
>> or this:
>>
>> #!php -q
>>
>>
>> in all cases I get the following error when I run (as root) the script:
>>
>> -bash: ./makemicrositeml: /usr/lib/php5/bin/php: bad interpreter: Permission 
>> denied
>>
>>
>> php is where I think it is:
>>
>> # which php
>> /usr/bin/php
>> # ls -lart /usr/bin/php
>> lrwxrwxrwx 1 root root 21 May  9 11:40 /usr/bin/php -> /usr/lib/php5/bin/php
>>
>> any know what idiot thing I'm doing wrong?
> 
> Check the permissions on /usr/lib/php5 and on /usr/lib/php5/bin and
> on /usr/lib/php5/bin/php
> 
> Any one of those being set incorrectly can deny you access.

the php binary is executable for everyone:

 # ls -lart /usr/lib/php5/bin/php
-rwxr-xr-x 1 root root 7012544 Jul  5 18:26 /usr/lib/php5/bin/php

and running the script as follows doesn't give any errors:

# /usr/lib/php5/bin/php -q ./makemicrositeml -h

(it shows the help message - I haven't got round to exactly testing the
script proper ;-)

any ideas>

> 
> Cheers,
> Rob.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] shebang line drive me nuts.

2006-08-07 Thread Chris

Jochem Maas wrote:

I have a php shell script (the execute bit of the file is set)
of which the first line is this:

#!/usr/lib/php5/bin/php -q

or this:

#!/usr/bin/php -q

or this:

#!php -q


in all cases I get the following error when I run (as root) the script:

-bash: ./makemicrositeml: /usr/lib/php5/bin/php: bad interpreter: Permission 
denied


php is where I think it is:

# which php
/usr/bin/php
# ls -lart /usr/bin/php
lrwxrwxrwx 1 root root 21 May  9 11:40 /usr/bin/php -> /usr/lib/php5/bin/php


3 things to check:

- /usr/lib/php5/bin/php exists
- /usr/lib/php5/bin/php is executable
- your script is executable.


If you run:

/usr/lib/php5/bin/php -q /path/to/your/script.php

does it work?

--
Postgresql & php tutorials
http://www.designmagick.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] shebang line drive me nuts.

2006-08-07 Thread Jochem Maas
hi Stut,

I wish it was the line endings - I checked and they where unix-style.
I do edit on windows normally (unless it's some rush fix and then I'll
use vi or nano) but I have the line-endings set to unix.

vi gave no sign of a ^M and I rewrote the shebang there just to be
safe.

alas no joy.

Stut wrote:
> Jochem Maas wrote:
>> I have a php shell script (the execute bit of the file is set)
>> of which the first line is this:
>>
>> #!/usr/lib/php5/bin/php -q
>>
>> or this:
>>
>> #!/usr/bin/php -q
>>
>> or this:
>>
>> #!php -q
>>
>>
>> in all cases I get the following error when I run (as root) the script:
>>
>> -bash: ./makemicrositeml: /usr/lib/php5/bin/php: bad interpreter:
>> Permission denied
>>
>>
>> php is where I think it is:
>>
>> # which php
>> /usr/bin/php
>> # ls -lart /usr/bin/php
>> lrwxrwxrwx 1 root root 21 May  9 11:40 /usr/bin/php ->
>> /usr/lib/php5/bin/php
>>
>> any know what idiot thing I'm doing wrong?
> 
> This can happen if the line ending in the script are DOS not UNIX - have
> you been editing the file on Windows and then uploading it? Easiest way
> to check is to open the file with vi and check for ^M on the end of the
> lines. If it's there, remove it from the first line and try again.
> 
> -Stut

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] shebang line drive me nuts.

2006-08-07 Thread Stut

Jochem Maas wrote:

I have a php shell script (the execute bit of the file is set)
of which the first line is this:

#!/usr/lib/php5/bin/php -q

or this:

#!/usr/bin/php -q

or this:

#!php -q


in all cases I get the following error when I run (as root) the script:

-bash: ./makemicrositeml: /usr/lib/php5/bin/php: bad interpreter: Permission 
denied


php is where I think it is:

# which php
/usr/bin/php
# ls -lart /usr/bin/php
lrwxrwxrwx 1 root root 21 May  9 11:40 /usr/bin/php -> /usr/lib/php5/bin/php

any know what idiot thing I'm doing wrong?


This can happen if the line ending in the script are DOS not UNIX - have 
you been editing the file on Windows and then uploading it? Easiest way 
to check is to open the file with vi and check for ^M on the end of the 
lines. If it's there, remove it from the first line and try again.


-Stut

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] shebang line drive me nuts.

2006-08-07 Thread Jochem Maas
hi Chris,

Chris wrote:
> Jochem Maas wrote:
>> I have a php shell script (the execute bit of the file is set)
>> of which the first line is this:
>>
>> #!/usr/lib/php5/bin/php -q
>>
>> or this:
>>
>> #!/usr/bin/php -q
>>
>> or this:
>>
>> #!php -q
>>
>>
>> in all cases I get the following error when I run (as root) the script:
>>
>> -bash: ./makemicrositeml: /usr/lib/php5/bin/php: bad interpreter:
>> Permission denied
>>
>>
>> php is where I think it is:
>>
>> # which php
>> /usr/bin/php
>> # ls -lart /usr/bin/php
>> lrwxrwxrwx 1 root root 21 May  9 11:40 /usr/bin/php ->
>> /usr/lib/php5/bin/php
> 
> 3 things to check:
> 
> - /usr/lib/php5/bin/php exists
> - /usr/lib/php5/bin/php is executable
> - your script is executable.

these I had checked already - I didn't make that clear, sorry.

> 
> 
> If you run:
> 
> /usr/lib/php5/bin/php -q /path/to/your/script.php
> 
> does it work?

yup that works fine.
weird huh!

> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] shebang line drive me nuts.

2006-08-07 Thread Robert Cummings
On Mon, 2006-08-07 at 09:59 +0200, Jochem Maas wrote:
> I have a php shell script (the execute bit of the file is set)
> of which the first line is this:
> 
> #!/usr/lib/php5/bin/php -q
> 
> or this:
> 
> #!/usr/bin/php -q
> 
> or this:
> 
> #!php -q
> 
> 
> in all cases I get the following error when I run (as root) the script:
> 
> -bash: ./makemicrositeml: /usr/lib/php5/bin/php: bad interpreter: Permission 
> denied
> 
> 
> php is where I think it is:
> 
> # which php
> /usr/bin/php
> # ls -lart /usr/bin/php
> lrwxrwxrwx 1 root root 21 May  9 11:40 /usr/bin/php -> /usr/lib/php5/bin/php
> 
> any know what idiot thing I'm doing wrong?

Check the permissions on /usr/lib/php5 and on /usr/lib/php5/bin and
on /usr/lib/php5/bin/php

Any one of those being set incorrectly can deny you access.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How to install PHP 4 on Apache 2.2

2006-08-07 Thread Chris

Ko Ko wrote:

Hi,
   
  I have Apache 2.2 and PHP 5 on Fedora 5. And since I am writing a lot of my php code which is only compatible with PHP 4 I remove the PHP 5 rpm and installed the PHP 4. But I notice that Apache 2.2 doesn't recognize PHP 4 right away. I can't find out on the net how to tweak the system to recognize PHP 4. Can anyone help me?


No particular "tweaks" necessary.

Guess you didn't search too hard, the first item in search results for 
"php4 apache2" was this page:


http://dan.drydog.com/apache2php.html


--
Postgresql & php tutorials
http://www.designmagick.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] shebang line drive me nuts.

2006-08-07 Thread Jochem Maas
I have a php shell script (the execute bit of the file is set)
of which the first line is this:

#!/usr/lib/php5/bin/php -q

or this:

#!/usr/bin/php -q

or this:

#!php -q


in all cases I get the following error when I run (as root) the script:

-bash: ./makemicrositeml: /usr/lib/php5/bin/php: bad interpreter: Permission 
denied


php is where I think it is:

# which php
/usr/bin/php
# ls -lart /usr/bin/php
lrwxrwxrwx 1 root root 21 May  9 11:40 /usr/bin/php -> /usr/lib/php5/bin/php

any know what idiot thing I'm doing wrong?
cheers.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Image list performance ISSUE

2006-08-07 Thread Chris

Andy wrote:

Sorry for the late answer,

I have different applications and the users are kept in DB so I cannot 
make for every user a directory.
I made a solution with .htaccess from apache and redirection to a php 
script that outputs the image if the user has rights to the images.


I will still have to check the performance of the system in this case, 
but I think it will be the same.


The performance Issue that I asked was:
Is there a difference if apache sends the image or If I output it with 
php with readfile.


Yes there will be a difference.

If apache sends the image, it just does:

- is the path valid?
- send it.

If you use readfile, apache has to fire up php, process the php script 
which then sends the image (which means another handle to read the file 
and so on), so there is a big difference between the two.


Depending on how busy your server is, it may or may not be measurable 
but there is a big difference in terms of processing.


--
Postgresql & php tutorials
http://www.designmagick.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Image list performance ISSUE

2006-08-07 Thread Andy

Sorry for the late answer,

I have different applications and the users are kept in DB so I cannot make 
for every user a directory.
I made a solution with .htaccess from apache and redirection to a php script 
that outputs the image if the user has rights to the images.


I will still have to check the performance of the system in this case, but I 
think it will be the same.


The performance Issue that I asked was:
Is there a difference if apache sends the image or If I output it with php 
with readfile.


Andy.


- Original Message - 
From: "WeberSites LTD" <[EMAIL PROTECTED]>

To: "'Andy'" <[EMAIL PROTECTED]>; 
Sent: Thursday, August 03, 2006 9:32 PM
Subject: RE: [PHP] Image list performance ISSUE



Why don't you name the images with the GUID of the user?
I want to see someone try to guess another user's GUID...

-Original Message-
From: Andy [mailto:[EMAIL PROTECTED]
Sent: Wednesday, August 02, 2006 11:16 AM
To: php-general@lists.php.net
Subject: [PHP] Image list performance ISSUE

Hi,

I have tons of images, which belongs to different users. In the software 
we
show to the users only the images that they have, but If they take the 
image

links manually they can also see the other images if they modify the image
name in the link.

Now, I can override the image request with apache rewrite and send the
request to a php file, which analizes the user rights and if the user has
rights to see that image. After that I output the image file with php this
way:
   header("Content-Type: image/jpeg");
   header("Content-Length: ".filesize($fname));
   readfile($fname);

... where fname is the image file.

I want to know... is this a big performance issue or not(the image is
handled by php and not by apache directly)

OR...

Is there any other way to handle this situation???

Thanx,
Andy.





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] How to install PHP 4 on Apache 2.2

2006-08-07 Thread Ko Ko
Hi,
   
  I have Apache 2.2 and PHP 5 on Fedora 5. And since I am writing a lot of my 
php code which is only compatible with PHP 4 I remove the PHP 5 rpm and 
installed the PHP 4. But I notice that Apache 2.2 doesn't recognize PHP 4 right 
away. I can't find out on the net how to tweak the system to recognize PHP 4. 
Can anyone help me?
   
  Regards,
   
  Leo



Reality starts with Dream 


-
See the all-new, redesigned Yahoo.com.  Check it out.

Re: [PHP] Newbie Form Question

2006-08-07 Thread David Dorward
Richard Lynch wrote:

>if (isset($_REQUEST['email'])){
> $success = mail($_REQUEST['action'], 'un/subscribe',
> 'un/subscribe', "From: $_REQUEST[email]\r\nReply-to:
> $_REQUEST[email]");
> if ($success) echo "Status Change Sent";
> else echo "Unable to send Status Change";
>   }
> ?>

What if someone submitted:

action = [EMAIL PROTECTED]

email = [EMAIL PROTECTED] long winded evil spam message here

?

-- 
David Dorward      
 Home is where the ~/.bashrc is

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php