Re: [PHP] DOMDocument::loadXML() failed when parsing comments inside a script tag

2010-06-08 Thread Andrew Ballard
On Tue, Jun 8, 2010 at 2:50 AM, Raymond Irving  wrote:
> Well it actually failed when loadHTML() is used.
> The strange thing is that it will fail regardless of the "--" characters:
>
> "Unexpected end tag : strong in Entity"
>
> __
> Raymond Irving

What failed? I copied your example and pasted it into a new file in
Zend Studio and it ran without any errors or warnings when I changed
loadXML to loadHTML. It WILL fail if you use loadXML unless the
contents of the script are properly enclosed in a CDATA section
because a script tag has no meaning in regular XML.

I don't know if you have control over the XHTML code or not, but if
you want to use loadXML for the document in your example, it should
look like this, based on what I have read on the web:

http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>

   
   
   // Bold Text,Normal Text";
   document.write(html);
   i--; // this line causes the parser to fail
   alert(html);
   // ]]>
   
   
';
$dom = new DOMDocument();
$dom->loadXML($html);
echo $dom->saveHTML();
?>

Andrew

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



[PHP] array key's: which is correct?

2010-06-08 Thread Tanel Tammik
Hi,

which one is correct or "better"?

$array[3] = '';
or
$array['3'] = '';

$i = 7;

$array[$i] = '';
or
$array["$i"] = '';


Br
Tanel 



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



Re: [PHP] Re: DOMDocument throws Unexpected end tag error when loading valid HTML

2010-06-08 Thread Peter Lind
2010/6/7 Raymond Irving :
> Thanks Nisse. This works great!
>
> I just wish the HTML DOM parser could just ignore the contents of the
> 

Re: [PHP] array key's: which is correct?

2010-06-08 Thread Paul M Foster
On Tue, Jun 08, 2010 at 04:12:42PM +0300, Tanel Tammik wrote:

> Hi,
> 
> which one is correct or "better"?
> 
> $array[3] = '';
> or
> $array['3'] = '';

If the index for (integer) 3, the first example is correct. If the index
is (string) '3', the second example is correct.

> 
> $i = 7;
> 
> $array[$i] = '';
> or
> $array["$i"] = '';
> 

There's no reason to use "$i". The end result will be the same, but in
the case of "$i", you're forcing the PHP interpreter to interpret the
string "$i", looking for variables (like $i), and output whatever else
is in the string (which in this case is nothing). Also, if $i is an
integer, you have the same problem as above. In the first case, you get
$array[7]. In the second case, you get $array['7'].

Paul

-- 
Paul M. Foster

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



Re: [PHP] array key's: which is correct?

2010-06-08 Thread Ashley Sheridan
On Tue, 2010-06-08 at 16:12 +0300, Tanel Tammik wrote:

> Hi,
> 
> which one is correct or "better"?
> 
> $array[3] = '';
> or
> $array['3'] = '';
> 
> $i = 7;
> 
> $array[$i] = '';
> or
> $array["$i"] = '';
> 
> 
> Br
> Tanel 
> 
> 
> 


The two indexes are equivalent, although I reckon the integer one will
give better performance over the string.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] array key's: which is correct?

2010-06-08 Thread Robert Cummings

Tanel Tammik wrote:

Hi,

which one is correct or "better"?

$array[3] = '';
or
$array['3'] = '';

$i = 7;

$array[$i] = '';
or
$array["$i"] = '';


Sometimes it is good to illustrate the correct answer:

 '1',
'2' => '2',
'three' => 'three',
'4.0'   => '4.0',
5.0 => 5.0,
);

var_dump( array_keys( $array ) );

?>

The answer is surprising (well, not really :) and certainly advocates 
against making literal strings of integers or manually converting a 
string integer to a real integer or using floating point keys.


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Blowfish Encryption

2010-06-08 Thread Adam Richardson
Hi Paul,


> > If one has multiple samples of encrypted emails, it's likely that the
> several
> > of the samples will end using the same cipher text, as many people end
> their
> > emails with a consistent signature.  This repeated cipher text improves
> the
> > ability of those trying to attack (decrypt the message.)  Hence, most
> > professionals recommend avoiding ECB mode.
>
> Well, bcrypt mentions CBC in the (brief) documentation, but the C code
> contains a couple of tables, one containing probably 1024 32-bit long
> integer values. Based on your description, that sounds like ECB, right?
>

I provided the description of ECB merely to provide a general theoretical
understanding of ECB (i.e., there is a one-to-one correspondence between any
chunk of plaintext and any resulting ciphertext that is always the same.)
 However, in practical terms, tables you see in code usually have to do with
S-boxes, or some other type of the implementation.  So, seeing tables in the
implementation code gives you no more info as to the mode.


>
> Bcrypt doesn't all the specification of what mode enc/dec is done in.
> That is, I can't specify to the program ECB, CBC or other.
>

Sounds likely, given the goal for portability.


>
> Also, according to the docs for bcrypt, it hashes your password out to
> he maximum size for the cipher (448 bytes?). This sounds like an
> implementation-specific decision which may not be echoed by PHP's mcrypt
> functions. Does that sound reasonable?
>
>
You'll have to match the hashing process to generate your key.


> >
> > Now, looking at your PHP code, I see that it appears your mixing and
> matching
> > some of the families of calls in ways that might lead to unexpected
> results.
> > Try the below:
> >
> > $ciphertext = mcrypt_encrypt(
> > $cipher = MCRYPT_BLOWFISH,
> > $key,
> > $plaintext,
> > $mode = 'cbc', // I just tossed this in as an example, but you should
> match
> > the mode bcrypt is using
> > $iv = 'use only once, sometimes a count, or a date' // needed for
> > decryption, too, although it doesn't have to remain a secret.
> > );
>
> Another point: my code above is actually from a post by someone else on
> this list. Now, the iv above is based on a random number. If I encrypt
> the file on Monday, and then attempt to decrypt it on Tuesday using a
> different (random-number-based) iv, will the file decrypt properly?
>

NO, if you're using a mode other than ECB.  If you're using CBC or some
other mode that utilizes the IV, the same IV must be used for encryption AND
decryption.  However, when using ECB, the IV isn't used, so it wouldn't
matter (if you pass in an IV, it's just ignored.)

The IV is used to make sure no two plaintexts will be represented by the
same cipher texts, and must be shared between those wishing to encrypt and
decrypt the message.  However, it doesn't have to kept secret.


>
> Paul
>
> --
> Paul M. Foster
>

Sounds like you're making progress :)  I'm busy today (off to the doctor for
a bum knee), but I'll probably look through bcrypt later this week just to
better understand its implementation (that is to say, sorry I don't have
more implementation details of that particular encryption scheme right now,
but maybe later.)

Adam

-- 
Nephtali:  PHP web framework that functions beautifully
http://nephtaliproject.com


Re: [PHP] array key's: which is correct?

2010-06-08 Thread Ashley Sheridan
On Tue, 2010-06-08 at 09:38 -0400, Robert Cummings wrote:

> Tanel Tammik wrote:
> > Hi,
> > 
> > which one is correct or "better"?
> > 
> > $array[3] = '';
> > or
> > $array['3'] = '';
> > 
> > $i = 7;
> > 
> > $array[$i] = '';
> > or
> > $array["$i"] = '';
> 
> Sometimes it is good to illustrate the correct answer:
> 
>  
> $array = array
> (
>  '1' => '1',
>  '2' => '2',
>  'three' => 'three',
>  '4.0'   => '4.0',
>  5.0 => 5.0,
> );
> 
> var_dump( array_keys( $array ) );
> 
> ?>
> 
> The answer is surprising (well, not really :) and certainly advocates 
> against making literal strings of integers or manually converting a 
> string integer to a real integer or using floating point keys.
> 
> Cheers,
> Rob.
> -- 
> E-Mail Disclaimer: Information contained in this message and any
> attached documents is considered confidential and legally protected.
> This message is intended solely for the addressee(s). Disclosure,
> copying, and distribution are prohibited unless authorized.
> 


Yeah, I found that out the hard way when I was trying to make an array
of Gantt tasks, and realised that all my nice task numbers were changed!

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] Security Issue

2010-06-08 Thread Igor Escobar
Hey Richard,

I'll find more about this parameter allow_url_include, thank you!


Regards,
Igor Escobar
Systems Analyst & Interface Designer

+ http://blog.igorescobar.com
+ http://www.igorescobar.com
+ @igorescobar (twitter)





On Mon, Jun 7, 2010 at 5:26 PM, richard gray  wrote:

> On 07/06/2010 20:00, Igor Escobar wrote:
>
>> PHP Injection is the technical name given to a security hole in PHP
>> applications. When this gap there is a hacker can do with an external code
>> that is interpreted as an inner code as if the code included was more a
>> part
>> of the script.
>>
>> // my code...
>> // my code...
>> include ('http:///externalhackscript.txt');
>> //my code...
>> //my code..
>>
> can you not switch off remote file includes in php.ini?
> This will stop include/require from a remote host..
> i.e. /allow_url_include = Off in php.ini
>
> HTH
> Rich
> /
>


Re: [PHP] Blowfish Encryption

2010-06-08 Thread Paul M Foster
On Tue, Jun 08, 2010 at 09:48:43AM -0400, Adam Richardson wrote:

> Hi Paul,
>  
> 
> > If one has multiple samples of encrypted emails, it's likely that the
> several
> > of the samples will end using the same cipher text, as many people end
> their
> > emails with a consistent signature.  This repeated cipher text improves
> the
> > ability of those trying to attack (decrypt the message.)  Hence, most
> > professionals recommend avoiding ECB mode.
> 
> Well, bcrypt mentions CBC in the (brief) documentation, but the C code
> contains a couple of tables, one containing probably 1024 32-bit long
> integer values. Based on your description, that sounds like ECB, right?
> 
> 
> I provided the description of ECB merely to provide a general theoretical
> understanding of ECB (i.e., there is a one-to-one correspondence between any
> chunk of plaintext and any resulting ciphertext that is always the same.)  
> However, in practical terms, tables you see in code usually have to do with
> S-boxes, or some other type of the implementation.  So, seeing tables in the
> implementation code gives you no more info as to the mode.

Makes sense. In the code, they're labeled that way (e.g. S[4][256]).

>  
> 
> 
> Bcrypt doesn't all the specification of what mode enc/dec is done in.
> That is, I can't specify to the program ECB, CBC or other.
> 
> 
> Sounds likely, given the goal for portability.
>  
> 
> 
> Also, according to the docs for bcrypt, it hashes your password out to
> he maximum size for the cipher (448 bytes?). This sounds like an
> implementation-specific decision which may not be echoed by PHP's mcrypt
> functions. Does that sound reasonable?
> 
> 
> 
> You'll have to match the hashing process to generate your key.
>  
> 
> >
> > Now, looking at your PHP code, I see that it appears your mixing and
> matching
> > some of the families of calls in ways that might lead to unexpected
> results.
> > Try the below:
> >
> > $ciphertext = mcrypt_encrypt(
> > $cipher = MCRYPT_BLOWFISH,
> > $key,
> > $plaintext,
> > $mode = 'cbc', // I just tossed this in as an example, but you 
> should
> match
> > the mode bcrypt is using
> > $iv = 'use only once, sometimes a count, or a date' // needed for
> > decryption, too, although it doesn't have to remain a secret.
> > );
> 
> Another point: my code above is actually from a post by someone else on
> this list. Now, the iv above is based on a random number. If I encrypt
> the file on Monday, and then attempt to decrypt it on Tuesday using a
> different (random-number-based) iv, will the file decrypt properly?
> 
> 
> NO, if you're using a mode other than ECB.  If you're using CBC or some other
> mode that utilizes the IV, the same IV must be used for encryption AND
> decryption.  However, when using ECB, the IV isn't used, so it wouldn't matter
> (if you pass in an IV, it's just ignored.)  
> 
> The IV is used to make sure no two plaintexts will be represented by the same
> cipher texts, and must be shared between those wishing to encrypt and decrypt
> the message.  However, it doesn't have to kept secret.
>  
> 
> 
> Paul
> 
> --
> Paul M. Foster
> 
> 
> Sounds like you're making progress :)  I'm busy today (off to the doctor for a
> bum knee), but I'll probably look through bcrypt later this week just to 
> better
> understand its implementation (that is to say, sorry I don't have more
> implementation details of that particular encryption scheme right now, but
> maybe later.)

Yeah, this is great. Thanks so much for your help. I really know very
little about encryption. If you think of something else, feel free to
comment.

Paul

-- 
Paul M. Foster

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



Re: [PHP] array key's: which is correct?

2010-06-08 Thread Paul M Foster
On Tue, Jun 08, 2010 at 09:38:58AM -0400, Robert Cummings wrote:

> Tanel Tammik wrote:
>> Hi,
>>
>> which one is correct or "better"?
>>
>> $array[3] = '';
>> or
>> $array['3'] = '';
>>
>> $i = 7;
>>
>> $array[$i] = '';
>> or
>> $array["$i"] = '';
>
> Sometimes it is good to illustrate the correct answer:
>
> 
> $array = array
> (
> '1' => '1',
> '2' => '2',
> 'three' => 'three',
> '4.0'   => '4.0',
> 5.0 => 5.0,
> );
>
> var_dump( array_keys( $array ) );
>
> ?>
>
> The answer is surprising (well, not really :) and certainly advocates
> against making literal strings of integers or manually converting a
> string integer to a real integer or using floating point keys.

Curse you, Rob Cummings! ;-}

I was stunned at the results of this. I assumed that integers cast as
strings would remain strings as indexes. Not so. And then float indexes
cast to ints. Argh!

My advice to the original poster was slightly incorrect. But I would
still encourage you to avoid enclosing variables in double-quotes
unnecessarily. (And integers in single-quotes for that matter.)

Paul

-- 
Paul M. Foster

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



[PHP] Pagination?

2010-06-08 Thread Paul Halliday
I just spent the last 1/2 hour looking at many different solutions for
this. Is there a universal favorite?

Thanks.

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



Re: [PHP] array key's: which is correct?

2010-06-08 Thread Ashley Sheridan
On Tue, 2010-06-08 at 10:35 -0400, Paul M Foster wrote:

> On Tue, Jun 08, 2010 at 09:38:58AM -0400, Robert Cummings wrote:
> 
> > Tanel Tammik wrote:
> >> Hi,
> >>
> >> which one is correct or "better"?
> >>
> >> $array[3] = '';
> >> or
> >> $array['3'] = '';
> >>
> >> $i = 7;
> >>
> >> $array[$i] = '';
> >> or
> >> $array["$i"] = '';
> >
> > Sometimes it is good to illustrate the correct answer:
> >
> >  >
> > $array = array
> > (
> > '1' => '1',
> > '2' => '2',
> > 'three' => 'three',
> > '4.0'   => '4.0',
> > 5.0 => 5.0,
> > );
> >
> > var_dump( array_keys( $array ) );
> >
> > ?>
> >
> > The answer is surprising (well, not really :) and certainly advocates
> > against making literal strings of integers or manually converting a
> > string integer to a real integer or using floating point keys.
> 
> Curse you, Rob Cummings! ;-}
> 
> I was stunned at the results of this. I assumed that integers cast as
> strings would remain strings as indexes. Not so. And then float indexes
> cast to ints. Argh!
> 
> My advice to the original poster was slightly incorrect. But I would
> still encourage you to avoid enclosing variables in double-quotes
> unnecessarily. (And integers in single-quotes for that matter.)
> 
> Paul
> 
> -- 
> Paul M. Foster
> 


The obvious way around this would be to include some sort of character
in the index that can't be cast to an integer, so instead of $array[1.0]
which would equate to $array[1] maybe add an underscore to make it
$array['_1.0']. It's not the prettiest of solutions, but it does mean
that indexes are kept as you intended, and you need only strip out the
first character, although I imagine a lot of string manipulation on a
large array would decrease performance.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] Pagination?

2010-06-08 Thread Ashley Sheridan
On Tue, 2010-06-08 at 11:37 -0300, Paul Halliday wrote:

> I just spent the last 1/2 hour looking at many different solutions for
> this. Is there a universal favorite?
> 
> Thanks.
> 


It depends what you mean by pagination, as there are two parts to it.
There is the display of the pagination nav and then the retrieval of
paginated results:

Use LIMIT in the SQL to paginate the data retrieved. I usually just use
a few variables to determine the pagination display; $current_page,
$items_per_page, $total_pages (which can be got by issuing a COUNT() in
the SQL for all possible records that match.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] array key's: which is correct?

2010-06-08 Thread Peter Lind
On 8 June 2010 16:38, Ashley Sheridan  wrote:
> On Tue, 2010-06-08 at 10:35 -0400, Paul M Foster wrote:
>
>> On Tue, Jun 08, 2010 at 09:38:58AM -0400, Robert Cummings wrote:
>>
>> > Tanel Tammik wrote:
>> >> Hi,
>> >>
>> >> which one is correct or "better"?
>> >>
>> >> $array[3] = '';
>> >> or
>> >> $array['3'] = '';
>> >>
>> >> $i = 7;
>> >>
>> >> $array[$i] = '';
>> >> or
>> >> $array["$i"] = '';
>> >
>> > Sometimes it is good to illustrate the correct answer:
>> >
>> > > >
>> > $array = array
>> > (
>> >     '1'     => '1',
>> >     '2'     => '2',
>> >     'three' => 'three',
>> >     '4.0'   => '4.0',
>> >     5.0     => 5.0,
>> > );
>> >
>> > var_dump( array_keys( $array ) );
>> >
>> > ?>
>> >
>> > The answer is surprising (well, not really :) and certainly advocates
>> > against making literal strings of integers or manually converting a
>> > string integer to a real integer or using floating point keys.
>>
>> Curse you, Rob Cummings! ;-}
>>
>> I was stunned at the results of this. I assumed that integers cast as
>> strings would remain strings as indexes. Not so. And then float indexes
>> cast to ints. Argh!
>>
>> My advice to the original poster was slightly incorrect. But I would
>> still encourage you to avoid enclosing variables in double-quotes
>> unnecessarily. (And integers in single-quotes for that matter.)
>>
>> Paul
>>
>> --
>> Paul M. Foster
>>
>
>
> The obvious way around this would be to include some sort of character
> in the index that can't be cast to an integer, so instead of $array[1.0]
> which would equate to $array[1] maybe add an underscore to make it
> $array['_1.0']. It's not the prettiest of solutions, but it does mean
> that indexes are kept as you intended, and you need only strip out the
> first character, although I imagine a lot of string manipulation on a
> large array would decrease performance.

Floats in quotes are not cast to int when used as array keys. Just an FYI :)

Regards
Peter

-- 

WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15


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



Re: [PHP] array key's: which is correct?

2010-06-08 Thread Ashley Sheridan
On Tue, 2010-06-08 at 16:44 +0200, Peter Lind wrote:

> On 8 June 2010 16:38, Ashley Sheridan  wrote:
> > On Tue, 2010-06-08 at 10:35 -0400, Paul M Foster wrote:
> >
> >> On Tue, Jun 08, 2010 at 09:38:58AM -0400, Robert Cummings wrote:
> >>
> >> > Tanel Tammik wrote:
> >> >> Hi,
> >> >>
> >> >> which one is correct or "better"?
> >> >>
> >> >> $array[3] = '';
> >> >> or
> >> >> $array['3'] = '';
> >> >>
> >> >> $i = 7;
> >> >>
> >> >> $array[$i] = '';
> >> >> or
> >> >> $array["$i"] = '';
> >> >
> >> > Sometimes it is good to illustrate the correct answer:
> >> >
> >> >  >> >
> >> > $array = array
> >> > (
> >> > '1' => '1',
> >> > '2' => '2',
> >> > 'three' => 'three',
> >> > '4.0'   => '4.0',
> >> > 5.0 => 5.0,
> >> > );
> >> >
> >> > var_dump( array_keys( $array ) );
> >> >
> >> > ?>
> >> >
> >> > The answer is surprising (well, not really :) and certainly advocates
> >> > against making literal strings of integers or manually converting a
> >> > string integer to a real integer or using floating point keys.
> >>
> >> Curse you, Rob Cummings! ;-}
> >>
> >> I was stunned at the results of this. I assumed that integers cast as
> >> strings would remain strings as indexes. Not so. And then float indexes
> >> cast to ints. Argh!
> >>
> >> My advice to the original poster was slightly incorrect. But I would
> >> still encourage you to avoid enclosing variables in double-quotes
> >> unnecessarily. (And integers in single-quotes for that matter.)
> >>
> >> Paul
> >>
> >> --
> >> Paul M. Foster
> >>
> >
> >
> > The obvious way around this would be to include some sort of character
> > in the index that can't be cast to an integer, so instead of $array[1.0]
> > which would equate to $array[1] maybe add an underscore to make it
> > $array['_1.0']. It's not the prettiest of solutions, but it does mean
> > that indexes are kept as you intended, and you need only strip out the
> > first character, although I imagine a lot of string manipulation on a
> > large array would decrease performance.
> 
> Floats in quotes are not cast to int when used as array keys. Just an FYI :)
> 
> Regards
> Peter
> 


They are. Go look at Robs earlier example. Even building upon that to
make a float value where it doesn't equate to an integer, it is still
cast as an integer unless it's inside a string:

$array = array
(
 '1' => '1',
 '2' => '2',
 'three' => 'three',
 '4.0'   => '4.0',
 5.0 => 5.0,
 6.5=> 6.5,
);

var_dump( array_keys( $array ) );

That's Robs code, but I added in the last element to show how a float
index is converted to an integer. Putting the float value inside a
string solves the issue.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] array key's: which is correct?

2010-06-08 Thread Peter Lind
On 8 June 2010 16:53, Ashley Sheridan  wrote:
>
> On Tue, 2010-06-08 at 16:44 +0200, Peter Lind wrote:
>
> On 8 June 2010 16:38, Ashley Sheridan  wrote:
> > On Tue, 2010-06-08 at 10:35 -0400, Paul M Foster wrote:
> >
> >> On Tue, Jun 08, 2010 at 09:38:58AM -0400, Robert Cummings wrote:
> >>
> >> > Tanel Tammik wrote:
> >> >> Hi,
> >> >>
> >> >> which one is correct or "better"?
> >> >>
> >> >> $array[3] = '';
> >> >> or
> >> >> $array['3'] = '';
> >> >>
> >> >> $i = 7;
> >> >>
> >> >> $array[$i] = '';
> >> >> or
> >> >> $array["$i"] = '';
> >> >
> >> > Sometimes it is good to illustrate the correct answer:
> >> >
> >> >  >> >
> >> > $array = array
> >> > (
> >> >     '1'     => '1',
> >> >     '2'     => '2',
> >> >     'three' => 'three',
> >> >     '4.0'   => '4.0',
> >> >     5.0     => 5.0,
> >> > );
> >> >
> >> > var_dump( array_keys( $array ) );
> >> >
> >> > ?>
> >> >
> >> > The answer is surprising (well, not really :) and certainly advocates
> >> > against making literal strings of integers or manually converting a
> >> > string integer to a real integer or using floating point keys.
> >>
> >> Curse you, Rob Cummings! ;-}
> >>
> >> I was stunned at the results of this. I assumed that integers cast as
> >> strings would remain strings as indexes. Not so. And then float indexes
> >> cast to ints. Argh!
> >>
> >> My advice to the original poster was slightly incorrect. But I would
> >> still encourage you to avoid enclosing variables in double-quotes
> >> unnecessarily. (And integers in single-quotes for that matter.)
> >>
> >> Paul
> >>
> >> --
> >> Paul M. Foster
> >>
> >
> >
> > The obvious way around this would be to include some sort of character
> > in the index that can't be cast to an integer, so instead of $array[1.0]
> > which would equate to $array[1] maybe add an underscore to make it
> > $array['_1.0']. It's not the prettiest of solutions, but it does mean
> > that indexes are kept as you intended, and you need only strip out the
> > first character, although I imagine a lot of string manipulation on a
> > large array would decrease performance.
>
> Floats in quotes are not cast to int when used as array keys. Just an FYI :)
>
> Regards
> Peter
>
>
> They are. Go look at Robs earlier example. Even building upon that to make a 
> float value where it doesn't equate to an integer, it is still cast as an 
> integer unless it's inside a string:
>
> $array = array
> (
>  '1' => '1',
>  '2' => '2',
>  'three' => 'three',
>  '4.0'   => '4.0',
>  5.0 => 5.0,
>  6.5 => 6.5,
> );
>
> var_dump( array_keys( $array ) );
>
> That's Robs code, but I added in the last element to show how a float index 
> is converted to an integer. Putting the float value inside a string solves 
> the issue.
>

Did you read what I wrote?

> ***Floats in quotes*** are not cast to int when used as array keys. Just an 
> FYI :)

I tested Robs example, that's how I know that floats in quotes are not
converted to ints, whether or not you use '4.0' or '6.5'

Regards
Peter

--

WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15


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



Re: [PHP] array key's: which is correct?

2010-06-08 Thread Ashley Sheridan
On Tue, 2010-06-08 at 17:11 +0200, Peter Lind wrote:

> On 8 June 2010 16:53, Ashley Sheridan  wrote:
> >
> > On Tue, 2010-06-08 at 16:44 +0200, Peter Lind wrote:
> >
> > On 8 June 2010 16:38, Ashley Sheridan  wrote:
> > > On Tue, 2010-06-08 at 10:35 -0400, Paul M Foster wrote:
> > >
> > >> On Tue, Jun 08, 2010 at 09:38:58AM -0400, Robert Cummings wrote:
> > >>
> > >> > Tanel Tammik wrote:
> > >> >> Hi,
> > >> >>
> > >> >> which one is correct or "better"?
> > >> >>
> > >> >> $array[3] = '';
> > >> >> or
> > >> >> $array['3'] = '';
> > >> >>
> > >> >> $i = 7;
> > >> >>
> > >> >> $array[$i] = '';
> > >> >> or
> > >> >> $array["$i"] = '';
> > >> >
> > >> > Sometimes it is good to illustrate the correct answer:
> > >> >
> > >> >  > >> >
> > >> > $array = array
> > >> > (
> > >> > '1' => '1',
> > >> > '2' => '2',
> > >> > 'three' => 'three',
> > >> > '4.0'   => '4.0',
> > >> > 5.0 => 5.0,
> > >> > );
> > >> >
> > >> > var_dump( array_keys( $array ) );
> > >> >
> > >> > ?>
> > >> >
> > >> > The answer is surprising (well, not really :) and certainly advocates
> > >> > against making literal strings of integers or manually converting a
> > >> > string integer to a real integer or using floating point keys.
> > >>
> > >> Curse you, Rob Cummings! ;-}
> > >>
> > >> I was stunned at the results of this. I assumed that integers cast as
> > >> strings would remain strings as indexes. Not so. And then float indexes
> > >> cast to ints. Argh!
> > >>
> > >> My advice to the original poster was slightly incorrect. But I would
> > >> still encourage you to avoid enclosing variables in double-quotes
> > >> unnecessarily. (And integers in single-quotes for that matter.)
> > >>
> > >> Paul
> > >>
> > >> --
> > >> Paul M. Foster
> > >>
> > >
> > >
> > > The obvious way around this would be to include some sort of character
> > > in the index that can't be cast to an integer, so instead of $array[1.0]
> > > which would equate to $array[1] maybe add an underscore to make it
> > > $array['_1.0']. It's not the prettiest of solutions, but it does mean
> > > that indexes are kept as you intended, and you need only strip out the
> > > first character, although I imagine a lot of string manipulation on a
> > > large array would decrease performance.
> >
> > Floats in quotes are not cast to int when used as array keys. Just an FYI :)
> >
> > Regards
> > Peter
> >
> >
> > They are. Go look at Robs earlier example. Even building upon that to make 
> > a float value where it doesn't equate to an integer, it is still cast as an 
> > integer unless it's inside a string:
> >
> > $array = array
> > (
> >  '1' => '1',
> >  '2' => '2',
> >  'three' => 'three',
> >  '4.0'   => '4.0',
> >  5.0 => 5.0,
> >  6.5 => 6.5,
> > );
> >
> > var_dump( array_keys( $array ) );
> >
> > That's Robs code, but I added in the last element to show how a float index 
> > is converted to an integer. Putting the float value inside a string solves 
> > the issue.
> >
> 
> Did you read what I wrote?
> 
> > ***Floats in quotes*** are not cast to int when used as array keys. Just an 
> > FYI :)
> 
> I tested Robs example, that's how I know that floats in quotes are not
> converted to ints, whether or not you use '4.0' or '6.5'
> 
> Regards
> Peter
> 
> --
> 
> WWW: http://plphp.dk / http://plind.dk
> LinkedIn: http://www.linkedin.com/in/plind
> BeWelcome/Couchsurfing: Fake51
> Twitter: http://twitter.com/kafe15
> 


Sorry, my bad, I misread your email, you were right!

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] array key's: which is correct?

2010-06-08 Thread Paul M Foster
On Tue, Jun 08, 2010 at 04:44:53PM +0200, Peter Lind wrote:

> On 8 June 2010 16:38, Ashley Sheridan  wrote:
> > On Tue, 2010-06-08 at 10:35 -0400, Paul M Foster wrote:
> >
> >> On Tue, Jun 08, 2010 at 09:38:58AM -0400, Robert Cummings wrote:
> >>
> >> > Tanel Tammik wrote:
> >> >> Hi,
> >> >>
> >> >> which one is correct or "better"?
> >> >>
> >> >> $array[3] = '';
> >> >> or
> >> >> $array['3'] = '';
> >> >>
> >> >> $i = 7;
> >> >>
> >> >> $array[$i] = '';
> >> >> or
> >> >> $array["$i"] = '';
> >> >
> >> > Sometimes it is good to illustrate the correct answer:
> >> >
> >> >  >> >
> >> > $array = array
> >> > (
> >> >     '1'     => '1',
> >> >     '2'     => '2',
> >> >     'three' => 'three',
> >> >     '4.0'   => '4.0',
> >> >     5.0     => 5.0,
> >> > );
> >> >
> >> > var_dump( array_keys( $array ) );
> >> >
> >> > ?>
> >> >
> >> > The answer is surprising (well, not really :) and certainly advocates
> >> > against making literal strings of integers or manually converting a
> >> > string integer to a real integer or using floating point keys.
> >>
> >> Curse you, Rob Cummings! ;-}
> >>
> >> I was stunned at the results of this. I assumed that integers cast as
> >> strings would remain strings as indexes. Not so. And then float indexes
> >> cast to ints. Argh!
> >>
> >> My advice to the original poster was slightly incorrect. But I would
> >> still encourage you to avoid enclosing variables in double-quotes
> >> unnecessarily. (And integers in single-quotes for that matter.)
> >>
> >> Paul
> >>
> >> --
> >> Paul M. Foster
> >>
> >
> >
> > The obvious way around this would be to include some sort of character
> > in the index that can't be cast to an integer, so instead of $array[1.0]
> > which would equate to $array[1] maybe add an underscore to make it
> > $array['_1.0']. It's not the prettiest of solutions, but it does mean
> > that indexes are kept as you intended, and you need only strip out the
> > first character, although I imagine a lot of string manipulation on a
> > large array would decrease performance.
> 
> Floats in quotes are not cast to int when used as array keys. Just an FYI :)

Umm, yes, you are correct. I pasted Rob's code into a test file, added
some other print_r()s and such, just to look at the whole issue. I'm
*still* examining the results, trying to wrap my wits around why things
are done this way.

Paul

-- 
Paul M. Foster

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



Re: [PHP] combo box validation

2010-06-08 Thread Gerardo Benitez
Hi Dave,

In general, you can validate this condition with javascript before to send
the form, and if some errors exist, the form is not submitted.

or validate the conditions in the server side with php.

Gerardo.
www.webseficientes.com.ar


On Mon, Jun 7, 2010 at 2:49 PM, David Mehler  wrote:

> Hello,
> I've got a form with two combo boxes, one for the month one for the
> day. Both are required. I've got code that checks the post submission
> to ensure neither is empty. My problem is that if a user does not
> select anything in the combo boxes January first is sent, this i don't
> want. If they haven't selected anything i'd like that to show as an
> error.
> Thanks.
> Dave.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] session variables in tmp

2010-06-08 Thread Gerardo Benitez
Hi Stephen,

you can try setting the session path using session_save_path
http://www.php.net/manual/en/function.session-save-path.php.

Gerardo
www.webseficientes.com.ar



On Sat, Jun 5, 2010 at 2:18 AM, Stephen Sunderlin <
stephen.sunder...@verizon.net> wrote:

> trying out a CentOS release 5.2 (Final) V4_1_0  on AWS.  Was working fine
> and now it seems that php has stopped writing any session variable to /tmp.
>  I was cleaning up the user table in mysql and limiting permissions.   Not
> sure that this would have anything to do with it.  Restarted apache/mysql.
>  tmp is  set to drwxrwxrwt  4 root root  4096 Jun  5 00:46 tmp
> PHP 5.2.4
> MySQL 5.0.45
> any thought on where else to look.
>
> Thanks.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Gerardo Benitez


Re: [PHP] combo box validation

2010-06-08 Thread Ashley Sheridan
On Tue, 2010-06-08 at 12:57 -0300, Gerardo Benitez wrote:

> Hi Dave,
> 
> In general, you can validate this condition with javascript before to send
> the form, and if some errors exist, the form is not submitted.
> 
> or validate the conditions in the server side with php.
> 
> Gerardo.
> www.webseficientes.com.ar
> 
> 
> On Mon, Jun 7, 2010 at 2:49 PM, David Mehler  wrote:
> 
> > Hello,
> > I've got a form with two combo boxes, one for the month one for the
> > day. Both are required. I've got code that checks the post submission
> > to ensure neither is empty. My problem is that if a user does not
> > select anything in the combo boxes January first is sent, this i don't
> > want. If they haven't selected anything i'd like that to show as an
> > error.
> > Thanks.
> > Dave.
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >


You should change that to 'and' instead of an 'or'. Javascript
validation is nice, but you should always validate everything on the
server too.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] combo box validation

2010-06-08 Thread Gerardo Benitez
your advice is welcome!


Gerardo
www.webseficientes.com.ar

On Tue, Jun 8, 2010 at 1:01 PM, Ashley Sheridan 
wrote:

>  On Tue, 2010-06-08 at 12:57 -0300, Gerardo Benitez wrote:
>
> Hi Dave,
>
> In general, you can validate this condition with javascript before to send
> the form, and if some errors exist, the form is not submitted.
>
> or validate the conditions in the server side with php.
>
> Gerardo.www.webseficientes.com.ar
>
>
> On Mon, Jun 7, 2010 at 2:49 PM, David Mehler  wrote:
>
> > Hello,
> > I've got a form with two combo boxes, one for the month one for the
> > day. Both are required. I've got code that checks the post submission
> > to ensure neither is empty. My problem is that if a user does not
> > select anything in the combo boxes January first is sent, this i don't
> > want. If they haven't selected anything i'd like that to show as an
> > error.
> > Thanks.
> > Dave.
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
>
> You should change that to 'and' instead of an 'or'. Javascript validation
> is nice, but you should always validate everything on the server too.
>
>
>   Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>


-- 
Gerardo Benitez


[PHP] PHP app & Server Load

2010-06-08 Thread Dan Joseph
Hi,

This is slightly OT...

We're wrapping up a new PHP/MySQL driven web site built on the Zend
Framework.  We're anticipating a couple hundred thousand members with
several thousand of them coming to the site at once.  I'm trying to figure
out how to determine how many servers we need to support the load.

I've done initial testing on a Xeon 3220 server, but we're looking at an i7
cpu based server now.

Anyone know a good way to estimate load based on actually numbers compared
to benchmark results from intel on a faster server?

-- 
-Dan Joseph

www.canishosting.com - Unlimited Hosting Plans start @ $3.95/month.  Promo
Code "NEWTHINGS" for 10% off initial order

http://www.facebook.com/canishosting
http://www.facebook.com/originalpoetry


Re: [PHP] PHP app & Server Load

2010-06-08 Thread Daniel Brown
On Tue, Jun 8, 2010 at 12:12, Dan Joseph  wrote:
>
> Anyone know a good way to estimate load based on actually numbers compared
> to benchmark results from intel on a faster server?

Run a DDoS-style (but not legitimate DDoS attack) load-balance
simulator against your site and see where the bottlenecks lie.  The
biggest problems are general filesystem writes (including sessions)
and database queries.

If you have multiple servers from which you can run test scripts,
do that (preferrably from various networks).  If not, do what you can
with what you have.  Make sure your testing system simulates the
traffic in the manner you expect (clicking links before the page fully
loads, closing the connection and immediately refreshing it, et
cetera).

Tools of the trade:

top/htop (for general system process watching)
mtop (for MySQL)
mod-top (for PHP process watching)
apachetop (for Apache)

And invaluable things to remember with regard to MySQL:

The 'log-slow-queries' option
The SQL statement: SHOW PROCESSLIST;

-- 

daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
We now offer SAME-DAY SETUP on a new line of servers!

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



Re: [PHP] array key's: which is correct?

2010-06-08 Thread Robert Cummings

Paul M Foster wrote:

On Tue, Jun 08, 2010 at 04:44:53PM +0200, Peter Lind wrote:


On 8 June 2010 16:38, Ashley Sheridan  wrote:

On Tue, 2010-06-08 at 10:35 -0400, Paul M Foster wrote:


On Tue, Jun 08, 2010 at 09:38:58AM -0400, Robert Cummings wrote:


Tanel Tammik wrote:

Hi,

which one is correct or "better"?

$array[3] = '';
or
$array['3'] = '';

$i = 7;

$array[$i] = '';
or
$array["$i"] = '';

Sometimes it is good to illustrate the correct answer:

 '1',
'2' => '2',
'three' => 'three',
'4.0'   => '4.0',
5.0 => 5.0,
);

var_dump( array_keys( $array ) );

?>

The answer is surprising (well, not really :) and certainly advocates
against making literal strings of integers or manually converting a
string integer to a real integer or using floating point keys.

Curse you, Rob Cummings! ;-}

I was stunned at the results of this. I assumed that integers cast as
strings would remain strings as indexes. Not so. And then float indexes
cast to ints. Argh!

My advice to the original poster was slightly incorrect. But I would
still encourage you to avoid enclosing variables in double-quotes
unnecessarily. (And integers in single-quotes for that matter.)

Paul

--
Paul M. Foster



The obvious way around this would be to include some sort of character
in the index that can't be cast to an integer, so instead of $array[1.0]
which would equate to $array[1] maybe add an underscore to make it
$array['_1.0']. It's not the prettiest of solutions, but it does mean
that indexes are kept as you intended, and you need only strip out the
first character, although I imagine a lot of string manipulation on a
large array would decrease performance.

Floats in quotes are not cast to int when used as array keys. Just an FYI :)


Umm, yes, you are correct. I pasted Rob's code into a test file, added
some other print_r()s and such, just to look at the whole issue. I'm
*still* examining the results, trying to wrap my wits around why things
are done this way.


If I were to hazard a guess as to the "why" of the current 
functionality, I would say converting an integer string to a real i nt 
is optimal with respect to both memory and processing when trying to 
find values by key. As for floating points... Due to the inability to 
accurately represent some floating point numbers in binary, one would 
often not get what one expects even when converting to a string. So 
maybe integer was chosen since it was more optimal than a string.


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] session variables in tmp

2010-06-08 Thread Stephen Sunderlin

Thanks Gerardo.

I send a large dump.sql file to my /tmp dir and filled up the remaining
space so PHP was not able to write any more session variable.  Took me a
little while to figure that one out.

Thanks for your response.




On Tue, 08 Jun 2010 12:00:23 -0400, Gerardo Benitez
 wrote:


Hi Stephen,

you can try setting the session path using session_save_path
http://www.php.net/manual/en/function.session-save-path.php.

Gerardo
www.webseficientes.com.ar



On Sat, Jun 5, 2010 at 2:18 AM, Stephen Sunderlin <
stephen.sunder...@verizon.net> wrote:

trying out a CentOS release 5.2 (Final) V4_1_0  on AWS.  Was working  
fine
and now it seems that php has stopped writing any session variable to  
/tmp.
 I was cleaning up the user table in mysql and limiting permissions.
Not
sure that this would have anything to do with it.  Restarted  
apache/mysql.

 tmp is  set to drwxrwxrwt  4 root root  4096 Jun  5 00:46 tmp
PHP 5.2.4
MySQL 5.0.45
any thought on where else to look.

Thanks.

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








--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

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



Re: [PHP] date_default_timezone_get() differs from ini_get('date.timezone');

2010-06-08 Thread Paul

no idea anybody?
problem still exists

On 05/30/2010 11:05 AM, php wrote:

Hi there

i think i did not understand the timezone-settings right.
In php.ini, i wrote

date.timezone="Europe/Berlin".

echo ini_get('date.timezone');

returns "Europe/Berlin".

But the Class "DateTime" is using another timezone (Europe/London).

When i do 'echo date_default_timezone_get()', it returns 
"Europe/London" and not the same as described in php.ini.


In phpinfo() the date.timezone-setting will also be empty.

I am sure to work with the right php.ini, due two facts:
1. phpinfo() displays the same ini and all settings from the file (but 
not timezone)

2. ini_get() returns the right setting as well (but it will not be used).

Can somebody explain to me, what happens here?

Thanks a lot and kind regards, Paul




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



Re: [PHP] session variables in tmp

2010-06-08 Thread Gerardo Benitez
Ok, that usually happens.

Gerardo
www.webseficientes.com.ar

On Tue, Jun 8, 2010 at 1:48 PM, Stephen Sunderlin <
stephen.sunder...@verizon.net> wrote:

> Thanks Gerardo.
>
> I send a large dump.sql file to my /tmp dir and filled up the remaining
> space so PHP was not able to write any more session variable.  Took me a
> little while to figure that one out.
>
> Thanks for your response.
>
>
>
>
>
> On Tue, 08 Jun 2010 12:00:23 -0400, Gerardo Benitez
>  wrote:
>
>  Hi Stephen,
>>
>> you can try setting the session path using session_save_path
>> http://www.php.net/manual/en/function.session-save-path.php.
>>
>> Gerardo
>> www.webseficientes.com.ar
>>
>>
>>
>> On Sat, Jun 5, 2010 at 2:18 AM, Stephen Sunderlin <
>> stephen.sunder...@verizon.net> wrote:
>>
>>  trying out a CentOS release 5.2 (Final) V4_1_0  on AWS.  Was working fine
>>> and now it seems that php has stopped writing any session variable to
>>> /tmp.
>>>  I was cleaning up the user table in mysql and limiting permissions.
>>> Not
>>> sure that this would have anything to do with it.  Restarted
>>> apache/mysql.
>>>  tmp is  set to drwxrwxrwt  4 root root  4096 Jun  5 00:46 tmp
>>> PHP 5.2.4
>>> MySQL 5.0.45
>>> any thought on where else to look.
>>>
>>> Thanks.
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>>>
>>
>>
>
> --
> Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
>



-- 
Gerardo Benitez


Re: [PHP] PHP app & Server Load

2010-06-08 Thread Dan Joseph
On Tue, Jun 8, 2010 at 12:19 PM, Daniel Brown  wrote:

> On Tue, Jun 8, 2010 at 12:12, Dan Joseph  wrote:
> >
> > Anyone know a good way to estimate load based on actually numbers
> compared
> > to benchmark results from intel on a faster server?
>
> Run a DDoS-style (but not legitimate DDoS attack) load-balance
> simulator against your site and see where the bottlenecks lie.  The
> biggest problems are general filesystem writes (including sessions)
> and database queries.
>
>If you have multiple servers from which you can run test scripts,
> do that (preferrably from various networks).  If not, do what you can
> with what you have.  Make sure your testing system simulates the
> traffic in the manner you expect (clicking links before the page fully
> loads, closing the connection and immediately refreshing it, et
> cetera).
>
>Tools of the trade:
>
>top/htop (for general system process watching)
>mtop (for MySQL)
>mod-top (for PHP process watching)
>apachetop (for Apache)
>
>And invaluable things to remember with regard to MySQL:
>
>The 'log-slow-queries' option
>The SQL statement: SHOW PROCESSLIST;
>
> --
> 
> daniel.br...@parasane.net || danbr...@php.net
> http://www.parasane.net/ || http://www.pilotpig.net/
> We now offer SAME-DAY SETUP on a new line of servers!
>


Thanks, some of those I wasn't aware of.  I've got them setup now and I'm
going to try and test on the server I have again.

As for estimating how things would run on a better server.  There are
benchmarks that score the CPUs.  Let's say one scored 5500, and one scored
1100, is it safe to say the higher one can handle 5x the load?

-- 
-Dan Joseph

www.canishosting.com - Unlimited Hosting Plans start @ $3.95/month.  Promo
Code "NEWTHINGS" for 10% off initial order

http://www.facebook.com/canishosting
http://www.facebook.com/originalpoetry


Re: [PHP] PHP app & Server Load

2010-06-08 Thread Daniel P. Brown
On Tue, Jun 8, 2010 at 13:29, Dan Joseph  wrote:
>
> As for estimating how things would run on a better server.  There are
> benchmarks that score the CPUs.  Let's say one scored 5500, and one scored
> 1100, is it safe to say the higher one can handle 5x the load?

Very, very loosely, yes.  Keep in mind that multiple things
directly affect CPU performance, including disk speed and block size,
RAM availability and speed, motherboard speed, kernel tuning,
operating system and environment, optimally-compiled code, et cetera.
So while one may bench five times the other, a realistic expectation
may be somewhere in the three to 3.5x mark.

Some of the servers we've been selling a lot of lately are
high-cache quad-core Xeon's with 12GB RAM.  Should be sufficient to
handle a decent amount of load but we used one as a demo machine
last month during a conference presentation for a subject very similar
to this, and showed that the larger machine with poor handling and
configuration could be outdone by a dual-core Celeron with 4GB RAM
with the same amount of stress.  Things like poor coding, using 32-bit
binaries on a 64-bit capable system, compiling generically instead of
specifically for the target architecture, keeping the system updated,
not compiling in unnecessary options (read: don't bloat your
binaries), having sufficient scratch disk space, and so forth.  It
sounds daunting, but it's really not.

-- 

daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
We now offer SAME-DAY SETUP on a new line of servers!

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



[PHP] finding the web root

2010-06-08 Thread Tanel Tammik
Hi,

i like to find the web root where the current file is. is there a better 
solution? it must work both on linux and windows machines...



maybe there is a function for that :D:D:D

Br
Tanel 



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



RE: [PHP] Security Issue

2010-06-08 Thread David Stoltz
allow_url_include is (or should be) disabled by default.

http://us2.php.net/manual/en/filesystem.configuration.php#ini.allow-url-
include

I can't think of one good reason to ever enable this, it would be a
security issue no matter how you slice it...

-Original Message-
From: Igor Escobar [mailto:titiolin...@gmail.com] 
Sent: Tuesday, June 08, 2010 10:11 AM
To: richg...@gmail.com
Cc: 
Subject: Re: [PHP] Security Issue

Hey Richard,

I'll find more about this parameter allow_url_include, thank you!


Regards,
Igor Escobar
Systems Analyst & Interface Designer

+ http://blog.igorescobar.com
+ http://www.igorescobar.com
+ @igorescobar (twitter)





On Mon, Jun 7, 2010 at 5:26 PM, richard gray  wrote:

> On 07/06/2010 20:00, Igor Escobar wrote:
>
>> PHP Injection is the technical name given to a security hole in PHP
>> applications. When this gap there is a hacker can do with an external
code
>> that is interpreted as an inner code as if the code included was more
a
>> part
>> of the script.
>>
>> // my code...
>> // my code...
>> include ('http:///externalhackscript.txt');
>> //my code...
>> //my code..
>>
> can you not switch off remote file includes in php.ini?
> This will stop include/require from a remote host..
> i.e. /allow_url_include = Off in php.ini
>
> HTH
> Rich
> /
>

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



Re: [PHP] Security Issue

2010-06-08 Thread Michael Shadle
Yes and scrubbing the input to ensure the field used for this URL  
rejects certain characters or does sanity checking on it would also be  
another suggestion. Turning this off would fix remote include  
requests. But still need to check for people requesting local files.  
Should never take user input and put it directly into include or shell  
execs or anything.


On Jun 8, 2010, at 11:55 AM, "David Stoltz"  wrote:


allow_url_include is (or should be) disabled by default.

http://us2.php.net/manual/en/filesystem.configuration.php#ini.allow-url-
include

I can't think of one good reason to ever enable this, it would be a
security issue no matter how you slice it...

-Original Message-
From: Igor Escobar [mailto:titiolin...@gmail.com]
Sent: Tuesday, June 08, 2010 10:11 AM
To: richg...@gmail.com
Cc: 
Subject: Re: [PHP] Security Issue

Hey Richard,

I'll find more about this parameter allow_url_include, thank you!


Regards,
Igor Escobar
Systems Analyst & Interface Designer

+ http://blog.igorescobar.com
+ http://www.igorescobar.com
+ @igorescobar (twitter)





On Mon, Jun 7, 2010 at 5:26 PM, richard gray   
wrote:



On 07/06/2010 20:00, Igor Escobar wrote:


PHP Injection is the technical name given to a security hole in PHP
applications. When this gap there is a hacker can do with an  
external

code
that is interpreted as an inner code as if the code included was  
more

a

part
of the script.

// my code...
// my code...
include ('http:///externalhackscript.txt');
//my code...
//my code..


can you not switch off remote file includes in php.ini?
This will stop include/require from a remote host..
i.e. /allow_url_include = Off in php.ini

HTH
Rich
/



--
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] finding the web root

2010-06-08 Thread Jim Lucas
Tanel Tammik wrote:
> Hi,
> 
> i like to find the web root where the current file is. is there a better 
> solution? it must work both on linux and windows machines...
> 
>  $root = explode('/', $_SERVER['DOCUMENT_ROOT']);
> $cwd = explode(DIRECTORY_SEPARATOR, __DIR__);
> $web_root = '/' . implode('/', array_diff($cwd, $root));
> echo $web_root;
> ?>
> 
> maybe there is a function for that :D:D:D
> 
> Br
> Tanel 
> 
> 
> 

If I understand what you are asking for, I think this will work.



-- 
Jim Lucas

A: Maybe because some people are too annoyed by top-posting.
Q: Why do I not get an answer to my question(s)?
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?

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



Re: [PHP] finding the web root

2010-06-08 Thread Tanel Tammik

"Jim Lucas"  wrote in message 
news:4c0e99d9.20...@cmsws.com...
> Tanel Tammik wrote:
>> Hi,
>>
>> i like to find the web root where the current file is. is there a better
>> solution? it must work both on linux and windows machines...
>>
>> > $root = explode('/', $_SERVER['DOCUMENT_ROOT']);
>> $cwd = explode(DIRECTORY_SEPARATOR, __DIR__);
>> $web_root = '/' . implode('/', array_diff($cwd, $root));
>> echo $web_root;
>> ?>
>>
>> maybe there is a function for that :D:D:D
>>
>> Br
>> Tanel
>>
>>
>>
>
> If I understand what you are asking for, I think this will work.
>
> 
> $web_root = basename($_SERVER['QUERY_STRING']);
>
> ?>
>
> -- 
> Jim Lucas
>
> A: Maybe because some people are too annoyed by top-posting.
> Q: Why do I not get an answer to my question(s)?
> A: Because it messes up the order in which people normally read text.
> Q: Why is top-posting such a bad thing?

var_dump($_SERVER['QUERY_STRING']); //outputs: string(0) ""

Br
Tanel 



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



Re: [PHP] finding the web root

2010-06-08 Thread Nathan Nobbe
On Tue, Jun 8, 2010 at 12:27 PM, Tanel Tammik  wrote:

> Hi,
>
> i like to find the web root where the current file is. is there a better
> solution? it must work both on linux and windows machines...
>
>  $root = explode('/', $_SERVER['DOCUMENT_ROOT']);
> $cwd = explode(DIRECTORY_SEPARATOR, __DIR__);
> $web_root = '/' . implode('/', array_diff($cwd, $root));
> echo $web_root;
> ?>


$_SERVER['DOCUMENT_ROOT']

although a post on the manual mentions some variability between
environments.

-nathan


Re: [PHP] finding the web root

2010-06-08 Thread Micky Hulse
> $_SERVER['DOCUMENT_ROOT']
> although a post on the manual mentions some variability between
> environments.

$root = (array_key_exists('DOCUMENT_ROOT', $_ENV)) ?
$_ENV['DOCUMENT_ROOT'] : $_SERVER['DOCUMENT_ROOT'];

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



Re: [PHP] finding the web root

2010-06-08 Thread Jim Lucas
Tanel Tammik wrote:
> "Jim Lucas"  wrote in message 
> news:4c0e99d9.20...@cmsws.com...
>> Tanel Tammik wrote:
>>> Hi,
>>>
>>> i like to find the web root where the current file is. is there a better
>>> solution? it must work both on linux and windows machines...
>>>
>>> >> $root = explode('/', $_SERVER['DOCUMENT_ROOT']);
>>> $cwd = explode(DIRECTORY_SEPARATOR, __DIR__);
>>> $web_root = '/' . implode('/', array_diff($cwd, $root));
>>> echo $web_root;
>>> ?>
>>>
>>> maybe there is a function for that :D:D:D
>>>
>>> Br
>>> Tanel
>>>
>>>
>>>
>> If I understand what you are asking for, I think this will work.
>>
>> >
>> $web_root = basename($_SERVER['QUERY_STRING']);
>>
>> ?>
>>
>> -- 
>> Jim Lucas
>>
>> A: Maybe because some people are too annoyed by top-posting.
>> Q: Why do I not get an answer to my question(s)?
>> A: Because it messes up the order in which people normally read text.
>> Q: Why is top-posting such a bad thing?
> 
> var_dump($_SERVER['QUERY_STRING']); //outputs: string(0) ""
> 
> Br
> Tanel 
> 
> 
> 

WOW, totally backwards on that one

try this




-- 
Jim Lucas

A: Maybe because some people are too annoyed by top-posting.
Q: Why do I not get an answer to my question(s)?
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?

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



Re: [PHP] finding the web root

2010-06-08 Thread Jim Lucas
Jim Lucas wrote:
> Tanel Tammik wrote:
>> "Jim Lucas"  wrote in message 
>> news:4c0e99d9.20...@cmsws.com...
>>> Tanel Tammik wrote:
 Hi,

 i like to find the web root where the current file is. is there a better
 solution? it must work both on linux and windows machines...

 >>> $root = explode('/', $_SERVER['DOCUMENT_ROOT']);
 $cwd = explode(DIRECTORY_SEPARATOR, __DIR__);
 $web_root = '/' . implode('/', array_diff($cwd, $root));
 echo $web_root;
 ?>

 maybe there is a function for that :D:D:D

 Br
 Tanel



>>> If I understand what you are asking for, I think this will work.
>>>
>>> >>
>>> $web_root = basename($_SERVER['QUERY_STRING']);
>>>
>>> ?>
>>>
>>> -- 
>>> Jim Lucas
>>>
>>> A: Maybe because some people are too annoyed by top-posting.
>>> Q: Why do I not get an answer to my question(s)?
>>> A: Because it messes up the order in which people normally read text.
>>> Q: Why is top-posting such a bad thing?
>> var_dump($_SERVER['QUERY_STRING']); //outputs: string(0) ""
>>
>> Br
>> Tanel 
>>
>>
>>
> 
> WOW, totally backwards on that one
> 
> try this
> 
>  
> var_dump( dirname( $_SERVER['PHP_SELF'] ) );
> 
> ?>
> 
> 

Although, after looking a little closer, it has a weird behavior that I didn't
expect.

if you call it from within a file from your DOCUMENT_ROOT it returns the
filename itself.  But, if you call it from a file within a subdirectory it gives
you the expected behavior of returning the parent directory structure.

I would have thought it would simply return / if it were in the DOCUMENT_ROOT.

Strange!

-- 
Jim Lucas

A: Maybe because some people are too annoyed by top-posting.
Q: Why do I not get an answer to my question(s)?
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?

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



Re: [PHP] Finding a font.

2010-06-08 Thread David McGlone
On Monday 07 June 2010 22:22:31 Karl DeSaulniers wrote:
> Hi Dave,
> It is called "Fine Hand" I believe. Found a copy here.
> 
> http://www.fonts.com/FindFonts/Detail.htm?pid=203813&/cgi-bin/
> MsmGo.exe?grab_id=0&page_id=8346&query=HANDWRITING&SCOPE=Fonts

Thank you Karl,  how did you find it? every google search I did, I could find 
all types of fonts, but never could find that "A" to compare it.

-- 
Blessings,
David M.

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



Re: [PHP] Finding a font.

2010-06-08 Thread David McGlone
On Monday 07 June 2010 23:22:14 Adam Richardson wrote:
> On Mon, Jun 7, 2010 at 10:22 PM, Karl DeSaulniers 
wrote:
> > Hi Dave,
> > It is called "Fine Hand" I believe. Found a copy here.
> > 

> 
> I believe Karl nailed it.  And, for future reference, WhatTheFont works
> quite well for this type of thing most of the time.  I quick tested the
> image (after quick pulling out the background), and it was one of the top
> suggestions.

Thanks Adam. I just read your e-mail and I didn't know what you were referring 
to, so I Googled it and I see what you are talking about.

Thanks for the information, I'll surely be using that site from now on.

-- 
Blessings,
David M.

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



Re: [PHP] Finding a font.

2010-06-08 Thread Karl DeSaulniers

I knew it had to be a script or handwriting font.
I googled script font, went to that site and had all the fonts  
display the "A" and started scrolling.

Gave up on script fonts and typed in handwriting fonts and BAM!

;)

Karl


On Jun 8, 2010, at 7:45 PM, David McGlone wrote:


On Monday 07 June 2010 22:22:31 Karl DeSaulniers wrote:

Hi Dave,
It is called "Fine Hand" I believe. Found a copy here.

http://www.fonts.com/FindFonts/Detail.htm?pid=203813&/cgi-bin/
MsmGo.exe?grab_id=0&page_id=8346&query=HANDWRITING&SCOPE=Fonts


Thank you Karl,  how did you find it? every google search I did, I  
could find

all types of fonts, but never could find that "A" to compare it.

--
Blessings,
David M.

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



Karl DeSaulniers
Design Drumm
http://designdrumm.com


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



Re: [PHP] Finding a font.

2010-06-08 Thread Karl DeSaulniers

That and I have an uncanny scanning ability while scrolling.
Don't know where it comes from, but glad its there.

lol

Karl


On Jun 8, 2010, at 7:45 PM, David McGlone wrote:


On Monday 07 June 2010 22:22:31 Karl DeSaulniers wrote:

Hi Dave,
It is called "Fine Hand" I believe. Found a copy here.

http://www.fonts.com/FindFonts/Detail.htm?pid=203813&/cgi-bin/
MsmGo.exe?grab_id=0&page_id=8346&query=HANDWRITING&SCOPE=Fonts


Thank you Karl,  how did you find it? every google search I did, I  
could find

all types of fonts, but never could find that "A" to compare it.

--
Blessings,
David M.

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



Karl DeSaulniers
Design Drumm
http://designdrumm.com


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