|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
php-general Digest 15 Aug 2006 10:28:27 -0000 Issue 4294
php-general-digest-help
lists.php.net
Date: Tue Aug 15 2006 - 05:28:27 CDT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
php-general Digest 15 Aug 2006 10:28:27 -0000 Issue 4294
Topics (messages 240652 through 240693):
OT? XUL XML-RPC Client
240652 by: Ray Hauge
Re: Why does count() make copies of arrays?
240653 by: Robert Cummings
240657 by: Robert Cummings
240658 by: Adam Zey
240660 by: Robert Cummings
240661 by: Adam Zey
240662 by: Robert Cummings
Re: header lost session variables.
240654 by: João Cândido de Souza Neto
240664 by: J R
240673 by: Richard Lynch
240675 by: Richard Lynch
Include and require
240655 by: Dave Goodchild
240656 by: Adam Zey
240659 by: Adam Zey
240667 by: Richard Lynch
240671 by: Chris
Re: system, exec, shell_exec, passthru
240663 by: Richard Lynch
240665 by: Richard Lynch
Re: Creating custom superglobals
240666 by: Richard Lynch
240674 by: Dave Goodchild
Re: break up variable and put each element in an array
240668 by: Richard Lynch
240692 by: Ivo F.A.C. Fokkema
Re: Functions
240669 by: Richard Lynch
Re: page redirecting
240670 by: Richard Lynch
Re: OT? Verifying mail was received
240672 by: Richard Lynch
Re: SETCOOKIE
240676 by: Richard Lynch
Re: Codigo de Captcha en PHP
240677 by: Richard Lynch
240693 by: Julio B.
Re: Internet Explorer doesn't display UTF-8 page using UTF-8 encoding
240678 by: Richard Lynch
240679 by: Richard Lynch
240684 by: Richard Lynch
Re: script to check if form is submitted from the same page?
240680 by: Richard Lynch
240682 by: Peter Lauri
Re: proxy server
240681 by: Richard Lynch
240686 by: John Taylor-Johnston
Re: Chicago PHP Conference
240683 by: Richard Lynch
240685 by: Paul Reinheimer
php and dynamic forms
240687 by: Bigmark
240688 by: Robert Cummings
240689 by: Bigmark
240690 by: Robert Cummings
240691 by: Robert Cummings
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscribe
lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscribe
lists.php.net
To post to the list, e-mail:
php-general
lists.php.net
----------------------------------------------------------------------
attached mail follows:
We've decided to start using XUL for intranet applications. I've written up
my XML-RPC server (php script) and I had found a tutorial showing how to use
XML-RPC through XUL/JavaScript, but now I can't find any information on it.
Anyone have any experience/links to information about XML-RPC with XUL?
Thanks,
--
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099
attached mail follows:
On Mon, 2006-08-14 at 13:16 -0400, Adam Zey wrote:
> I was writing a shell script in PHP (4.4.2) that dealt with a rather
> large array. To figure out what I needed the new memory limit to be, I
> did a memory_get_usage() at the end of my script, and came up with about
> 5.5MB. I then set the memory limit to 8MB.
>
> When I tried to run it, the script ran out of memory on the line:
>
> $numwords = count($words);
>
> However, when I switched to simply incrementing $numwords every time I
> added an element to $words, the memory limit of 8MB was fine.
>
> So my question is, if PHP does copy-on-write, why does PHP make a copy
> of an array when you use count() on it, which should NOT be modifying
> the array?
For some reason the memory_get_usage() function wouldn't appear in my
PHP compilation even after using the --enable-memory-limit flag, and
rather than dig very deep, I whipped up the following script to test
your issue (under PHP 4.2.2):
<?php
//echo 'Mem Usage: '.memory_get_usage()."\n";
$foo = array();
for( $i = 0; $i < 10000000; $i++ )
{
$foo[$i] = $i;
}
echo 'Created big array!'."\n";
sleep( 10 );
//echo 'Mem Usage: '.memory_get_usage()."\n";
$numEntries = count( $foo );
echo 'Counted big array!'."\n";
sleep( 10 );
//echo 'Mem Usage: '.memory_get_usage()."\n";
?>
Using the following command:
watch -n 0 'ps awxu | grep foo.php | grep -v grep'
I got the following snapshots during the two sleep steps:
rob 16018 66.7 44.7 935084 928684 pts/7 S+ 17:11
0:18 /usr/local/bin/php -qC ./foo.php
rob 16018 43.9 44.7 935084 928684 pts/7 S+ 17:11
0:18 /usr/local/bin/php -qC ./foo.php
Which indicated no change from the 935 megs of memory already allocated
before the count().
You've either encountered a bug in your version, or a confounding
variable :)
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. |
`------------------------------------------------------------'
attached mail follows:
On Mon, 2006-08-14 at 17:20 -0400, Robert Cummings wrote:
> On Mon, 2006-08-14 at 13:16 -0400, Adam Zey wrote:
> > I was writing a shell script in PHP (4.4.2) that dealt with a rather
> > large array. To figure out what I needed the new memory limit to be, I
> > did a memory_get_usage() at the end of my script, and came up with about
> > 5.5MB. I then set the memory limit to 8MB.
> >
> > When I tried to run it, the script ran out of memory on the line:
> >
> > $numwords = count($words);
> >
> > However, when I switched to simply incrementing $numwords every time I
> > added an element to $words, the memory limit of 8MB was fine.
> >
> > So my question is, if PHP does copy-on-write, why does PHP make a copy
> > of an array when you use count() on it, which should NOT be modifying
> > the array?
>
> For some reason the memory_get_usage() function wouldn't appear in my
> PHP compilation even after using the --enable-memory-limit flag, and
> rather than dig very deep, I whipped up the following script to test
> your issue (under PHP 4.2.2):
That last line should have said 4.4.2 :)
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. |
`------------------------------------------------------------'
attached mail follows:
Robert Cummings wrote:
> On Mon, 2006-08-14 at 13:16 -0400, Adam Zey wrote:
>> I was writing a shell script in PHP (4.4.2) that dealt with a rather
>> large array. To figure out what I needed the new memory limit to be, I
>> did a memory_get_usage() at the end of my script, and came up with about
>> 5.5MB. I then set the memory limit to 8MB.
>>
>> When I tried to run it, the script ran out of memory on the line:
>>
>> $numwords = count($words);
>>
>> However, when I switched to simply incrementing $numwords every time I
>> added an element to $words, the memory limit of 8MB was fine.
>>
>> So my question is, if PHP does copy-on-write, why does PHP make a copy
>> of an array when you use count() on it, which should NOT be modifying
>> the array?
>
> For some reason the memory_get_usage() function wouldn't appear in my
> PHP compilation even after using the --enable-memory-limit flag, and
> rather than dig very deep, I whipped up the following script to test
> your issue (under PHP 4.2.2):
>
> <?php
>
> //echo 'Mem Usage: '.memory_get_usage()."\n";
>
> $foo = array();
>
> for( $i = 0; $i < 10000000; $i++ )
> {
> $foo[$i] = $i;
> }
>
> echo 'Created big array!'."\n";
> sleep( 10 );
>
> //echo 'Mem Usage: '.memory_get_usage()."\n";
>
> $numEntries = count( $foo );
>
> echo 'Counted big array!'."\n";
> sleep( 10 );
>
> //echo 'Mem Usage: '.memory_get_usage()."\n";
> ?>
>
> Using the following command:
>
> watch -n 0 'ps awxu | grep foo.php | grep -v grep'
>
> I got the following snapshots during the two sleep steps:
>
> rob 16018 66.7 44.7 935084 928684 pts/7 S+ 17:11
> 0:18 /usr/local/bin/php -qC ./foo.php
>
> rob 16018 43.9 44.7 935084 928684 pts/7 S+ 17:11
> 0:18 /usr/local/bin/php -qC ./foo.php
>
> Which indicated no change from the 935 megs of memory already allocated
> before the count().
>
> You've either encountered a bug in your version, or a confounding
> variable :)
>
> Cheers,
> Rob.
That's the thing, count only creates a duplicate of the array (or
consumes massive amounts of memory) *during* the call of count(). It
frees the memory right after. The problem is that if you've got a 2MB
array, you can't call count() on it because the temporarily increased
memory usage will break the 4MB memory limit.
Here's a better test case:
1) Ensure the memory limit is enabled and set to 4MB
2) Create an array that is 3MB in size
3) Try to call count() on that array
With PHP 4.4.2, this will fail, because count will try to copy the array
(or do something else that consumes a lot of memory). If you increase
the memory limit to compensate, the memory usage goes back down
immediately after the count call. For this reason, memory_get_usage()
will never show the extra memory usage; it's allocated and freed
entirely during the count() call.
Regards, Adam.
attached mail follows:
On Mon, 2006-08-14 at 17:24 -0400, Adam Zey wrote:
> Robert Cummings wrote:
> > On Mon, 2006-08-14 at 13:16 -0400, Adam Zey wrote:
> >> I was writing a shell script in PHP (4.4.2) that dealt with a rather
> >> large array. To figure out what I needed the new memory limit to be, I
> >> did a memory_get_usage() at the end of my script, and came up with about
> >> 5.5MB. I then set the memory limit to 8MB.
> >>
> >> When I tried to run it, the script ran out of memory on the line:
> >>
> >> $numwords = count($words);
> >>
> >> However, when I switched to simply incrementing $numwords every time I
> >> added an element to $words, the memory limit of 8MB was fine.
> >>
> >> So my question is, if PHP does copy-on-write, why does PHP make a copy
> >> of an array when you use count() on it, which should NOT be modifying
> >> the array?
> >
> > For some reason the memory_get_usage() function wouldn't appear in my
> > PHP compilation even after using the --enable-memory-limit flag, and
> > rather than dig very deep, I whipped up the following script to test
> > your issue (under PHP 4.2.2):
> >
> > <?php
> >
> > //echo 'Mem Usage: '.memory_get_usage()."\n";
> >
> > $foo = array();
> >
> > for( $i = 0; $i < 10000000; $i++ )
> > {
> > $foo[$i] = $i;
> > }
> >
> > echo 'Created big array!'."\n";
> > sleep( 10 );
> >
> > //echo 'Mem Usage: '.memory_get_usage()."\n";
> >
> > $numEntries = count( $foo );
> >
> > echo 'Counted big array!'."\n";
> > sleep( 10 );
> >
> > //echo 'Mem Usage: '.memory_get_usage()."\n";
> > ?>
> >
> > Using the following command:
> >
> > watch -n 0 'ps awxu | grep foo.php | grep -v grep'
> >
> > I got the following snapshots during the two sleep steps:
> >
> > rob 16018 66.7 44.7 935084 928684 pts/7 S+ 17:11
> > 0:18 /usr/local/bin/php -qC ./foo.php
> >
> > rob 16018 43.9 44.7 935084 928684 pts/7 S+ 17:11
> > 0:18 /usr/local/bin/php -qC ./foo.php
> >
> > Which indicated no change from the 935 megs of memory already allocated
> > before the count().
> >
> > You've either encountered a bug in your version, or a confounding
> > variable :)
> >
> > Cheers,
> > Rob.
>
> That's the thing, count only creates a duplicate of the array (or
> consumes massive amounts of memory) *during* the call of count(). It
> frees the memory right after. The problem is that if you've got a 2MB
> array, you can't call count() on it because the temporarily increased
> memory usage will break the 4MB memory limit.
>
> Here's a better test case:
>
> 1) Ensure the memory limit is enabled and set to 4MB
> 2) Create an array that is 3MB in size
> 3) Try to call count() on that array
>
> With PHP 4.4.2, this will fail, because count will try to copy the array
> (or do something else that consumes a lot of memory). If you increase
> the memory limit to compensate, the memory usage goes back down
> immediately after the count call. For this reason, memory_get_usage()
> will never show the extra memory usage; it's allocated and freed
> entirely during the count() call.
When I ran the original test I was watching the process, it generally
takes more than a second on most system to allocate several hundred
megabytes which would have exposed your problem as a spike. At any
rate...
I figured out my problem with the recompile and then ran the script with
appropriate settings. On the first run I determined the memory required
and then for the second run I set the memory to an amount very close to
what was used. Here is second script:
#!/usr/local/bin/php -qC
<?php
ini_set( 'memory_limit', '627150412' );
echo 'Mem Usage: '.memory_get_usage()."\n";
$foo = array();
for( $i = 0; $i < 10000000; $i++ )
{
$foo[$i] = $i;
}
echo 'Created big array!'."\n";
echo 'Mem Usage: '.memory_get_usage()."\n";
$numEntries = count( $foo );
echo 'Counted big array!'."\n";
echo 'Mem Usage: '.memory_get_usage()."\n";
?>
Following I the output:
Mem Usage: 41296
Created big array!
Mem Usage: 627150256
Counted big array!
Mem Usage: 627150320
Changing the memory limit from '627150412' to '627150212' result sin the
expected memory limit exception:
Mem Usage: 41296
<br />
<b>Fatal error</b>: Allowed memory size of 627150212 bytes exhausted
(tried to allocate 12 bytes) in <b>/home/suds/foo.php</b> on line
<b>10</b><br />
So I'm not experiencing your memory issue since due to the the immense
size of the array I'm creating it would certainly show if a copy was
performed. That said (and maybe this is related to the recent memory
thread on internals that I sort of skipped over), I'm very surprised
that while I allowed '627150412' bytes for memory, that the PHP process
climbed to 900+ megs. It seems as though it doesn't account for it's own
usage of memory, which is extremely misleading. Admittedly this kind of
allocation on a production web site would normally be considered
ludicrous, it still strikes me that the memory_limit ini setting is
somewhat misleading -- in this case by about 30%.
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. |
`------------------------------------------------------------'
attached mail follows:
Robert Cummings wrote:
> On Mon, 2006-08-14 at 17:24 -0400, Adam Zey wrote:
>> Robert Cummings wrote:
>>> On Mon, 2006-08-14 at 13:16 -0400, Adam Zey wrote:
>>>> I was writing a shell script in PHP (4.4.2) that dealt with a rather
>>>> large array. To figure out what I needed the new memory limit to be, I
>>>> did a memory_get_usage() at the end of my script, and came up with about
>>>> 5.5MB. I then set the memory limit to 8MB.
>>>>
>>>> When I tried to run it, the script ran out of memory on the line:
>>>>
>>>> $numwords = count($words);
>>>>
>>>> However, when I switched to simply incrementing $numwords every time I
>>>> added an element to $words, the memory limit of 8MB was fine.
>>>>
>>>> So my question is, if PHP does copy-on-write, why does PHP make a copy
>>>> of an array when you use count() on it, which should NOT be modifying
>>>> the array?
>>> For some reason the memory_get_usage() function wouldn't appear in my
>>> PHP compilation even after using the --enable-memory-limit flag, and
>>> rather than dig very deep, I whipped up the following script to test
>>> your issue (under PHP 4.2.2):
>>>
>>> <?php
>>>
>>> //echo 'Mem Usage: '.memory_get_usage()."\n";
>>>
>>> $foo = array();
>>>
>>> for( $i = 0; $i < 10000000; $i++ )
>>> {
>>> $foo[$i] = $i;
>>> }
>>>
>>> echo 'Created big array!'."\n";
>>> sleep( 10 );
>>>
>>> //echo 'Mem Usage: '.memory_get_usage()."\n";
>>>
>>> $numEntries = count( $foo );
>>>
>>> echo 'Counted big array!'."\n";
>>> sleep( 10 );
>>>
>>> //echo 'Mem Usage: '.memory_get_usage()."\n";
>>> ?>
>>>
>>> Using the following command:
>>>
>>> watch -n 0 'ps awxu | grep foo.php | grep -v grep'
>>>
>>> I got the following snapshots during the two sleep steps:
>>>
>>> rob 16018 66.7 44.7 935084 928684 pts/7 S+ 17:11
>>> 0:18 /usr/local/bin/php -qC ./foo.php
>>>
>>> rob 16018 43.9 44.7 935084 928684 pts/7 S+ 17:11
>>> 0:18 /usr/local/bin/php -qC ./foo.php
>>>
>>> Which indicated no change from the 935 megs of memory already allocated
>>> before the count().
>>>
>>> You've either encountered a bug in your version, or a confounding
>>> variable :)
>>>
>>> Cheers,
>>> Rob.
>> That's the thing, count only creates a duplicate of the array (or
>> consumes massive amounts of memory) *during* the call of count(). It
>> frees the memory right after. The problem is that if you've got a 2MB
>> array, you can't call count() on it because the temporarily increased
>> memory usage will break the 4MB memory limit.
>>
>> Here's a better test case:
>>
>> 1) Ensure the memory limit is enabled and set to 4MB
>> 2) Create an array that is 3MB in size
>> 3) Try to call count() on that array
>>
>> With PHP 4.4.2, this will fail, because count will try to copy the array
>> (or do something else that consumes a lot of memory). If you increase
>> the memory limit to compensate, the memory usage goes back down
>> immediately after the count call. For this reason, memory_get_usage()
>> will never show the extra memory usage; it's allocated and freed
>> entirely during the count() call.
>
> When I ran the original test I was watching the process, it generally
> takes more than a second on most system to allocate several hundred
> megabytes which would have exposed your problem as a spike. At any
> rate...
>
> I figured out my problem with the recompile and then ran the script with
> appropriate settings. On the first run I determined the memory required
> and then for the second run I set the memory to an amount very close to
> what was used. Here is second script:
>
> #!/usr/local/bin/php -qC
> <?php
>
> ini_set( 'memory_limit', '627150412' );
>
> echo 'Mem Usage: '.memory_get_usage()."\n";
>
> $foo = array();
>
> for( $i = 0; $i < 10000000; $i++ )
> {
> $foo[$i] = $i;
> }
>
> echo 'Created big array!'."\n";
> echo 'Mem Usage: '.memory_get_usage()."\n";
>
> $numEntries = count( $foo );
>
> echo 'Counted big array!'."\n";
> echo 'Mem Usage: '.memory_get_usage()."\n";
>
> ?>
>
> Following I the output:
>
> Mem Usage: 41296
> Created big array!
> Mem Usage: 627150256
> Counted big array!
> Mem Usage: 627150320
>
> Changing the memory limit from '627150412' to '627150212' result sin the
> expected memory limit exception:
>
> Mem Usage: 41296
> <br />
> <b>Fatal error</b>: Allowed memory size of 627150212 bytes exhausted
> (tried to allocate 12 bytes) in <b>/home/suds/foo.php</b> on line
> <b>10</b><br />
>
> So I'm not experiencing your memory issue since due to the the immense
> size of the array I'm creating it would certainly show if a copy was
> performed. That said (and maybe this is related to the recent memory
> thread on internals that I sort of skipped over), I'm very surprised
> that while I allowed '627150412' bytes for memory, that the PHP process
> climbed to 900+ megs. It seems as though it doesn't account for it's own
> usage of memory, which is extremely misleading. Admittedly this kind of
> allocation on a production web site would normally be considered
> ludicrous, it still strikes me that the memory_limit ini setting is
> somewhat misleading -- in this case by about 30%.
>
> Cheers,
> Rob.
Further experimentation shows that the problem only occurs if the
variable being count'd is a static variable inside a function. Of
course, the original point still stands, static or no, count shouldn't
make a copy. Here is a sample script that I can confirm reproduces the
issue:
<?php
use_mem();
function use_mem()
{
static $foo = "";
for ( $x=0; $x <= 70000; $x++ )
$foo[] = "BwaHA" . mt_rand(0, 1000000);
echo memory_get_usage();
$numrows = count($foo);
}
?>
PHP's default memory limit is 8MB. This script creates an array that's
about 5.5MB. That part's fine. But it fails on that last line with the
count($foo).
I realize that this particular function doesn't need the variable to be
static, but it's just a demonstration. My actual script had a function
that needed some data to be read in from a file into an array. Rather
than reading it in in the main script and passing it to the function, or
having the function read the data in every execution, I simply made
the variable static and had the function check if the variable was empty
to see if it was the first time the function had been called.
Sorry for not realizing that the static variable is the key to
reproducing this issue. Does the script that I've pasted here give you
any better luck in reproducing?
Regards, Adam Zey.
attached mail follows:
On Mon, 2006-08-14 at 18:35 -0400, Adam Zey wrote:
>
> Further experimentation shows that the problem only occurs if the
> variable being count'd is a static variable inside a function. Of
> course, the original point still stands, static or no, count shouldn't
> make a copy. Here is a sample script that I can confirm reproduces the
> issue:
>
> <?php
>
> use_mem();
>
> function use_mem()
> {
> static $foo = "";
>
> for ( $x=0; $x <= 70000; $x++ )
> $foo[] = "BwaHA" . mt_rand(0, 1000000);
>
> echo memory_get_usage();
> $numrows = count($foo);
> }
>
> ?>
>
> PHP's default memory limit is 8MB. This script creates an array that's
> about 5.5MB. That part's fine. But it fails on that last line with the
> count($foo).
>
> I realize that this particular function doesn't need the variable to be
> static, but it's just a demonstration. My actual script had a function
> that needed some data to be read in from a file into an array. Rather
> than reading it in in the main script and passing it to the function, or
> having the function read the data in every execution, I simply made
> the variable static and had the function check if the variable was empty
> to see if it was the first time the function had been called.
>
> Sorry for not realizing that the static variable is the key to
> reproducing this issue. Does the script that I've pasted here give you
> any better luck in reproducing?
Yep looks like a bug or a design choice based on static variables. I'm
not sure what the reasoning is, but it sounds like static vars currently
take a huge performance hit when containing large chunks of memory :/ I
just tested your code using is_array() and got the same failure.
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. |
`------------------------------------------------------------'
attached mail follows:
I´m in the follow location:
https://www2......./?modulo=seguro&acao=identifica
And in my script i use header("Location:
./?modulo=seguro&acao=novo_cadastro")
When it run, my system lost all session variables.
""BBC"" <bbc_danang
telkom.net> escreveu na mensagem
news:01a501c6bfe0$cd6f22b0$f38c5e3d
bbc...
>> Hi guys.
>>
>> Anyone here know why in some cases when i use (header("Location: ???");
>> the
>> system lost the session variables?
>>
>> Any tips will be apreciated.
>> Thanks in advantge.
>
> Please tell me the cases you mean..!
attached mail follows:
On 8/15/06, João Cândido de Souza Neto <joao
curitibaonline.com.br> wrote:
>
> I´m in the follow location:
>
> https://www2......./?modulo=seguro&acao=identifica
>
> And in my script i use header("Location:
> ./?modulo=seguro&acao=novo_cadastro")
i normally do
header("Location: ?modulo=seguro&acao=novo_cadastro");
thats with out the "./" but i'm not sure if its has any effect. try it out
anyway. i could not think of any reason why your session variables
will disappear,
unless you don't do session start() :) hehehe...(in which of course you do)
if possible could you paste some of your codes so others can take a look at
it.
When it run, my system lost all session variables.
>
> ""BBC"" <bbc_danang
telkom.net> escreveu na mensagem
> news:01a501c6bfe0$cd6f22b0$f38c5e3d
bbc...
> >> Hi guys.
> >>
> >> Anyone here know why in some cases when i use (header("Location: ???");
> >> the
> >> system lost the session variables?
> >>
> >> Any tips will be apreciated.
> >> Thanks in advantge.
> >
> > Please tell me the cases you mean..!
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
GMail Rocks!!!
attached mail follows:
On Mon, August 14, 2006 8:04 am, João Cândido de Souza Neto wrote:
> Anyone here know why in some cases when i use (header("Location:
> ???"); the
> system lost the session variables?
Yes.
The browser gets headers such as this:
Location: http://example.com
Cookie: Example Value
*SOME* browsers, as soon as they see that Location: line, will
IMMEDIATELY go to the other URL, ignoring the Cookie line.
Don't do that.
If the Location: is your own PHP code, just include() it and do exit;
and call it fixed.
You can also try to throw a session_write_close (?) before the
header("Location: ") line -- Others have posted some success with
that, but I suspect it won't fix things for EVERY browser out there.
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
On Mon, August 14, 2006 6:56 pm, J R wrote:
> On 8/15/06, João Cândido de Souza Neto <joao
curitibaonline.com.br>
> wrote:
>>
>> I´m in the follow location:
>>
>> https://www2......./?modulo=seguro&acao=identifica
>>
>> And in my script i use header("Location:
>> ./?modulo=seguro&acao=novo_cadastro")
>
>
> i normally do
>
> header("Location: ?modulo=seguro&acao=novo_cadastro");
>
> thats with out the "./" but i'm not sure if its has any effect. try it
> out
> anyway. i could not think of any reason why your session variables
> will disappear,
> unless you don't do session start() :) hehehe...(in which of course
> you do)
HTTP RFC Specs require that Location be a complete URL starting with
"http://" so you're pretty much both making a fundamental error
here...
:-) :-) :-)
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
Hi all - I have several require_once statements in my web app to load in
small function libraries. A common one bundles a variety of functions to
handle date math and map month numbers to month names. I originally defined
an array in that file plus a bunch of functions but when I loaded the page,
the array variable, referenced further down the page, was NULL. I wrapped a
function def around the array and returned it and all was fine.
I may be suffering from mild hallucinations, but can you not define
variables in a required file? It is not a scope issue as the array variable
is referenced in the web page, not in any function.
--
http://www.web-buddha.co.uk
http://www.projectkarma.co.uk
attached mail follows:
Dave Goodchild wrote:
> Hi all - I have several require_once statements in my web app to load in
> small function libraries. A common one bundles a variety of functions to
> handle date math and map month numbers to month names. I originally defined
> an array in that file plus a bunch of functions but when I loaded the page,
> the array variable, referenced further down the page, was NULL. I wrapped a
> function def around the array and returned it and all was fine.
>
> I may be suffering from mild hallucinations, but can you not define
> variables in a required file? It is not a scope issue as the array variable
> is referenced in the web page, not in any function.
>
I know for a fact that you can define variables in PHP 4 and 5. The idea
behind include and require is little more complex than copying and
pasting the code. Many of my scripts include a config.php which has
various variables created with setting information.
Regards, Adam Zey.
attached mail follows:
Dave Goodchild wrote:
> I use a config file too. That was a sanity check. The file extract
> looked like this:
>
> $months = array(1 => 'January', 2 => 'February', 3 => 'March', 4 =>
> 'April', 5 => 'May', 6=> 'June',
> 7 => 'July', 8 => 'August', 9 => 'September', 10 =>
> 'October', 11 => 'November', 12 => 'December');
>
> which was called in with require_once. The reference to $months in the
> calling page, checked with var_dump, was NULL.
>
> When I wrapped it like this:
>
> function getmonths() {
>
> $months = array(1 => 'January', 2 => 'February', 3 => 'March', 4
> => 'April', 5 => 'May', 6=> 'June',
> 7 => 'July', 8 => 'August', 9 => 'September', 10 =>
> 'October', 11 => 'November', 12 => 'December');
> return $months;
> }
>
> it worked. Not sure why the simple variable didn't work.
>
> On 14/08/06, *Adam Zey* <azey
nit.ca <mailto:azey
nit.ca>> wrote:
>
> Dave Goodchild wrote:
> > Hi all - I have several require_once statements in my web app to
> load in
> > small function libraries. A common one bundles a variety of
> functions to
> > handle date math and map month numbers to month names. I
> originally defined
> > an array in that file plus a bunch of functions but when I
> loaded the page,
> > the array variable, referenced further down the page, was NULL.
> I wrapped a
> > function def around the array and returned it and all was fine.
> >
> > I may be suffering from mild hallucinations, but can you not define
> > variables in a required file? It is not a scope issue as the
> array variable
> > is referenced in the web page, not in any function.
> >
>
> I know for a fact that you can define variables in PHP 4 and 5.
> The idea
> behind include and require is little more complex than copying and
> pasting the code. Many of my scripts include a config.php which has
> various variables created with setting information.
>
> Regards, Adam Zey.
>
>
>
>
> --
> http://www.web-buddha.co.uk
> http://www.projectkarma.co.uk
Was the $months variable created inside an if statement or something
else? PHP's rules of scope say that variables created inside a code
block (like an if, a for, a while, a foreach), they stop existing the
moment you exit that code block. So this:
$foo = "bar";
if ( $foo == "bar" )
{
$baz = "narf";
}
echo $baz;
That code will output nothing, because $baz is empty by the time I try
to output it. The solution that I use is this:
$foo = "bar";
$baz = "";
if ( $foo == "bar" )
{
$baz = "narf";
}
echo $baz;
In which case the output would be "narf", because the variable existed
before I changed it in the if. This sounds like it might be your
problem, though I can't know without seeing the code.
Regards, Adam Zey.
attached mail follows:
On Mon, August 14, 2006 4:20 pm, Dave Goodchild wrote:
> Hi all - I have several require_once statements in my web app to load
> in
> small function libraries. A common one bundles a variety of functions
> to
> handle date math and map month numbers to month names. I originally
> defined
> an array in that file plus a bunch of functions but when I loaded the
> page,
> the array variable, referenced further down the page, was NULL. I
> wrapped a
> function def around the array and returned it and all was fine.
>
> I may be suffering from mild hallucinations, but can you not define
> variables in a required file? It is not a scope issue as the array
> variable
> is referenced in the web page, not in any function.
Be 100% sure that the include_once is not being done inside of another
function...
If you can't figure it out, one quick test is to put 'global ' in
front of the variable.
If that fixes the problem, then you know that you DO in fact have a
scope issue, whether you know why you have it or not. :-)
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
Adam Zey wrote:
> Dave Goodchild wrote:
>> I use a config file too. That was a sanity check. The file extract
>> looked like this:
>>
>> $months = array(1 => 'January', 2 => 'February', 3 => 'March', 4 =>
>> 'April', 5 => 'May', 6=> 'June',
>> 7 => 'July', 8 => 'August', 9 => 'September', 10 =>
>> 'October', 11 => 'November', 12 => 'December');
>>
>> which was called in with require_once. The reference to $months in the
>> calling page, checked with var_dump, was NULL.
>>
>> When I wrapped it like this:
>>
>> function getmonths() {
>>
>> $months = array(1 => 'January', 2 => 'February', 3 => 'March', 4
>> => 'April', 5 => 'May', 6=> 'June',
>> 7 => 'July', 8 => 'August', 9 => 'September', 10 =>
>> 'October', 11 => 'November', 12 => 'December');
>> return $months;
>> }
>>
>> it worked. Not sure why the simple variable didn't work.
>>
>> On 14/08/06, *Adam Zey* <azey
nit.ca <mailto:azey
nit.ca>> wrote:
>>
>> Dave Goodchild wrote:
>> > Hi all - I have several require_once statements in my web app to
>> load in
>> > small function libraries. A common one bundles a variety of
>> functions to
>> > handle date math and map month numbers to month names. I
>> originally defined
>> > an array in that file plus a bunch of functions but when I
>> loaded the page,
>> > the array variable, referenced further down the page, was NULL.
>> I wrapped a
>> > function def around the array and returned it and all was fine.
>> >
>> > I may be suffering from mild hallucinations, but can you not define
>> > variables in a required file? It is not a scope issue as the
>> array variable
>> > is referenced in the web page, not in any function.
>> >
>>
>> I know for a fact that you can define variables in PHP 4 and 5.
>> The idea
>> behind include and require is little more complex than copying and
>> pasting the code. Many of my scripts include a config.php which has
>> various variables created with setting information.
>>
>> Regards, Adam Zey.
>>
>>
>>
>>
>> --
>> http://www.web-buddha.co.uk
>> http://www.projectkarma.co.uk
> Was the $months variable created inside an if statement or something
> else? PHP's rules of scope say that variables created inside a code
> block (like an if, a for, a while, a foreach), they stop existing the
> moment you exit that code block. So this:
>
> $foo = "bar";
>
> if ( $foo == "bar" )
> {
> $baz = "narf";
> }
>
> echo $baz;
>
> That code will output nothing, because $baz is empty by the time I try
> to output it.
That's wrong sorry :)
$ php -a
Interactive mode enabled
<?php
$foo = "bar";
if ( $foo == "bar" )
{
$baz = "narf";
}
echo $baz;
narf
Works fine.
If you only create the variable inside the "if" you won't be able to use
it if the code doesn't get into the if (it'll be an undefined variable):
$ php -a
Interactive mode enabled
<?php
error_reporting(E_ALL);
if (1 == 0) {
$foo = "blah";
}
echo $foo;
Notice: Undefined variable: foo in - on line 6
--
Postgresql & php tutorials
http://www.designmagick.com/
attached mail follows:
Use exec() instead of system() and pass in args for output and error
number and then you'll get an error number telling you what went
wrong.
You'll have to look up the error number in a shell with 'perror' (man
perror) unless you dig my modest extension to do it from PHP:
http://l-i-e.com/perror
On Mon, August 14, 2006 10:23 am, p.willis
telus.net wrote:
> Hello,
>
> I am trying the run an external application with
> command line arguments using PHP under linux.
>
> ie:
>
> $command="myprog $arg1 $arg2 > textfile.txt";
> system("echo \"$command\" > test.txt");
> system($command);
>
> $handle=fopen("textfile.txt","r");
> if($handle!=NULL)
> {
> while(!feof($handle))
> {
> ...
> }
> fclose($handle);
> }
>
>
> I test my input arguments for the 'system' call by dumping
> the command into a text file. I can then test the command in
> the console. The commands work fine when run from the console.
>
> The commands don't work when run through the system command.
> I have tried system, exec, passthru, and shell_exec to no avail.
>
> Am I missing some permissions thing in my php.ini file?
>
> Thanks for any insight,
>
> Peter
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
On Mon, August 14, 2006 12:25 pm, Michael Jonsson wrote:
> I can run any external program like ls, cp, uptime...
> But if a try to run my shell script a get error.
>
> $passwdexe = "sudo /usr/bin/webpasswd";
> $user=$_POST[name];
> $passwd="$passwdexe $user 123456";
> echo $passwd;
> $result = system($passwd);
>
> Resultat from the web, "sudo /usr/sbin/webpasswd billy 12345678"
> and from the error_log, "couldn't read file "./usr/sbin/webpasswd.":
> no
> such file or directory".
In addition the the problem you know that you have, you're also
blindly passing $_POST['name'] into the shell undo a sudo which is a
pretty monstrous security hole...
Use a full path to sudo for starters.
And use escapeshellarg on $user
Plus, given that it is a Un*x username, it almost for sure has a
rather simple PCRE you could use on it to validate it.
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
On Mon, August 14, 2006 8:40 am, Ville Mattila wrote:
> Does the PHP environment (5.1.4) provide a way to define some custom
> variables as a superglobal? It would be useful for saving certain site
> preferences and settings that must be referred in many variables and
> classes, without every time writing global keyword at the beginning of
> a
> function definition.
Not unless you want to install the RunKit extension, which pretty much
lets you re-define ANYTHING in PHP...
Probably a Bad Idea...
$_SESSION might be a reasonable place to store your data, however,
depending on what it is...
Maybe I'm mis-understanding what you are storing, but it seems like
the kind of stuff that belongs in $_SESSION...
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
On 15/08/06, Richard Lynch <ceo
l-i-e.com> wrote:
>
> On Mon, August 14, 2006 8:40 am, Ville Mattila wrote:
> > Does the PHP environment (5.1.4) provide a way to define some custom
> > variables as a superglobal? It would be useful for saving certain site
> > preferences and settings that must be referred in many variables and
> > classes, without every time writing global keyword at the beginning of
> > a
> > function definition.
>
> ...or why not keep it simple and use include_once/require_once? I
> generally have a config file for every app that contains constants,
> variables and so on that are used across the application.
>
attached mail follows:
On Mon, August 14, 2006 2:41 am, Ivo F.A.C. Fokkema wrote:
> On Sat, 12 Aug 2006 16:36:36 -0500, Richard Lynch wrote:
>> On Fri, August 11, 2006 3:11 am, Ivo F.A.C. Fokkema wrote:
>>> Well, if it's true that some browsers on some platforms ignore the
>>> W3C
>>> standard, I guess we could use:
>>
>> Or perhaps these browsers pre-date W3C standards. :-)
>
> Sure, but in newer versions, they might update their code to follow
> the standards after all... wouldn't they?
Of course!
But are all my users going to run out and upgrade because some W3C
weenie (from their persepctive) told them to?
No.
In fact, *some* of my users are so economically-challenged that their
hardware doesn't support a W3C-compliant browser due to memory
constraints.
So I'm going to provide backwards-compatible code which:
does not break anything for W3C-compliant browsers
supports ancient browsers
costs almost nothing in CPU time for any reasonable-sized GET/POST
Do you want to add to the Digital Divide by not supporting ancient
hardware/software, or do you want to only provide web services to the
wealthy :-) :-) :-)
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
On Mon, 14 Aug 2006 19:14:42 -0500, Richard Lynch wrote:
> On Mon, August 14, 2006 2:41 am, Ivo F.A.C. Fokkema wrote:
>> On Sat, 12 Aug 2006 16:36:36 -0500, Richard Lynch wrote:
>>> On Fri, August 11, 2006 3:11 am, Ivo F.A.C. Fokkema wrote:
>>>> Well, if it's true that some browsers on some platforms ignore the
>>>> W3C
>>>> standard, I guess we could use:
>>>
>>> Or perhaps these browsers pre-date W3C standards. :-)
>>
>> Sure, but in newer versions, they might update their code to follow
>> the standards after all... wouldn't they?
>
> Of course!
>
> But are all my users going to run out and upgrade because some W3C
> weenie (from their persepctive) told them to?
>
> No.
>
> In fact, *some* of my users are so economically-challenged that their
> hardware doesn't support a W3C-compliant browser due to memory
> constraints.
Holy sh*t! Seriously? Since it became a HTML specification back in 1999,
that must be quite some old software. I just assumed people upgraded by
then, so it wouldn't be a problem at all. Not too sure if it's the best
"economically-challenged" way to go, since they're probably waiting for
ever to get their system booted, but that's a different story. Do you
happen to know their browser specs?
I've went through the list of browsers visiting our website (based on JS
statistics). These are the oldest, of every browser type, taken from the
last 5000 page hits:
Firefox 1.0
Mozilla 1.0
MS Internet Explorer 5.0
Netscape 7.0
Opera 7.5
Profile 1.0
Safari 1.2
WebTV/MSTV 2.6
MS IE 5.0 is pretty old :) And I don't even know 'Profile 1.0'...
> So I'm going to provide backwards-compatible code which:
> does not break anything for W3C-compliant browsers
> supports ancient browsers
> costs almost nothing in CPU time for any reasonable-sized GET/POST
OK, OK, you won me over :)
> Do you want to add to the Digital Divide by not supporting ancient
> hardware/software, or do you want to only provide web services to the
> wealthy :-) :-) :-)
<Evil>MUHAHAHAHAHAAAAH!</Evil>
Oh, sorry, was that out loud?
attached mail follows:
On Sun, August 13, 2006 8:45 pm, Gerry D wrote:
> On 6/30/06, Richard Lynch <ceo
l-i-e.com> wrote:
>
>> #2. Don't alter the case of the input data, if at all possible.
>> Accept what the user has given, and take it as it is. You can make
>> your application not care about case, and you can format the case on
>> ouput (maybe even with fancy CSS stuff) but don't mess with their
>> input.
>
> Why not clean up crappy input right at the source, Richard?
Clean up crappy input, of course.
Convert perfectly-valid NEWLINE into a tag <BR> for browser output, no.
The conversion of the data for OUTPUT to a specific medium (browser,
RSS, XML, WAP, FUTURE TECH #1*) should be done on OUTPUT, not INPUT.
Othewise, to convert your input plain -> HTML data to WAP, you first
have to UNDO the plain -> HTML conversion, then do a plain -> WAP
conversion.
That's just daft.
* You should get a warm fuzzy for recognizing this phrase. :-)
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
On Sun, August 13, 2006 6:49 pm, Gerry D wrote:
> On 6/28/06, Richard Lynch <ceo
l-i-e.com> wrote:
>> On Wed, June 28, 2006 5:17 am, kristianto adi widiatmoko wrote:
>> > i need to redirecting page, it could be done by using header
>> function
>> > like this
>> >
>> > header("Location : page2.php?var1=foo");
>>
>> Then, the URL should be a full, complete URL, and not just a local
>> reference.
>
> Sure you can use a local page, I do it all the time.
Allow me to re-phrase:
The HTTP RFC Specs require that a Location: be a full complete URL
starting with http://
It might "work" in all the browsers you have tested so far, but that
does not make it right... :-)
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
On Sun, August 13, 2006 9:01 am, tedd wrote:
>>Not because of any inherent problem with PayPal itself, but because
>>the sheer volume of phishing/spam claiming to be PayPal made it
>>impossible to find the legitimate PayPal traffic, which made PayPal
>>useless to me.
>
> Different strokes for different folks. I've had very good experience
> with PayPal personally and with selling things via several sites
> world wide -- it works for me.
PayPal worked great until I was getting several hundred bogus emails
per day, which were resistant to automated filtering...
Maybe I just wasn't smart enough to filter them correctly, or maybe
the value of PayPal wasn't high enough for me, as I used it so seldom,
but I haven't really felt this big gaping hole in my life without it
:-)
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
On Sun, August 13, 2006 2:20 am, Peter Lauri wrote:
> [snip]
>
> On Sat, August 12, 2006 8:00 am, Peter Lauri wrote:
>> When you just use time() you tell the cookie to just live until now,
>> so it
>> dies directly. You have to add some seconds to determine how long
>> the
>> cookie
>> will live.
>
> Unfortunately, no...
>
> The above solution relies on the USER computer clock being set
> correctly.
>
> [/snip]
>
> This is interesting. Because you set the time as the Server time, it
> will
> then just assume that the time is the same. However, is the system not
> that
> smart that it do translate the time when being sent (timestamp and
> expire
> time sent the same way, or just the number of seconds that the cookie
> will
> be alive from.
>
> If this is correct, what will happen if the server is in a different
> time
> zone?
The time is GMT, so if everybody's computer clock is set correctly,
and their BIOS setting for UTC versus GMT or whatever is correct, and
...
So, pretty much, it's not something you want to rely on for short time
periods...
Probably better to set a very long expiration (2 years is max
guaranteed to work by spec) and then manage all the expiration issues
on the server, using the server clock, which should be
self-consistent, if not correct.
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
On Mon, August 14, 2006 3:32 am, Julio B. wrote:
> Hay muchos y muy variados en Internet. En alguna ocasión he usado el
> que
> viene en sBlog. Es muy sencillo de implementar y para la mayoría de
> los
> casos suficiente para evitarnos problemas de spam.
>
> En código es:
>
> <?php
>
> $key = (array_key_exists('k', $_GET) && strlen($_GET['k']) == 4) ?
> $_GET['k'] : strtolower(substr(md5(rand()), 0, 4));
>
> $im = imagecreatetruecolor(40, 20);
>
> $bg = imagecolorallocate($im, 0, 0, 0);
> $col_text = imagecolorallocate($im, 255, 255, 255);
>
> imagestring($im, 4, 4, 1, $key, $col_text);
>
> header('Content-type: image/png');
> imagepng($im);
> imagedestroy($im);
>
> ?>
I can't read Spanish and am probably not answering your question, but
if you are passing in ?k=ABCD and the image just contains ABCD, then
the Bad Guy only has to see the URL and figure out how to get ABCD to
break your CAPTCHA...
Here is a very crude minimalistic example CAPTCHA implementation that
you may find useful:
http://voodookings.net/eyesonly_example.htm
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
Hi Richard, my example is not safe, but already I wrote in the last part of
my message to Ricardo that, by security, would be necessary to make use of
session variables, for example, to pass the value of catpcha generated and
to be able to compare it.
The modification would be like this:
<?php
session_start();
$key = strtolower(substr(md5(rand()), 0, 4));
$_SESSION['captcha'] = $key;
$im = imagecreatetruecolor(40, 20);
$bg = imagecolorallocate($im, 0, 0, 0);
$col_text = imagecolorallocate($im, 255, 255, 255);
imagestring($im, 4, 4, 1, $key, $col_text);
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
?>
And the comparison would be between the value introduced by the user and the
stored one in the session variable.
Saludos,
Julio Barroso
attached mail follows:
IE does some really funky things attempting to "guess" the charset,
because it assumes that web developers and web designers just don't
understand this charset stuff...
And they may be correct, as a general rule, but it sure makes life
tough when you actually send out the correct headers and META tags and
it doesn't work...
I think one other wrinkle is in the DOCTYPE -- A more current DOCTYPE
is assumed by IE, I think, to mean that you know what you are doing,
and it pays attention to the META tag.
It's still a lot like Voodoo to get IE to do anything, though...
I know in at least one instance, IE honored the META tag, but not the
header() charset. Sigh. Took me days to track that one down.
On Sat, August 12, 2006 7:47 pm, Jonny Bergström wrote:
> ....but Firefox does.
>
> this is the page: http://shiinaringo.se/guestbook.php
>
> You can see that a lot of characters (Swedish, Japanese) are totally
> garbled
> when using IE. Works fine in FF. If you try to look at some of the
> other
> pages linked to in the menu, they will work with IE as well. So I just
> don't
> know what is the problem with this one page.
> All pages on this site includes a header file which starts with:
>
> ---cut---
> <?php echo '<?xml version="1.0" encoding="UTF-8"?>';?>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
> http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html>
> <head>
> <meta name="Content-type" content="text/html; charset=UTF-8"
> />
> ---cut---
>
>
> Which means that in my view I tell the browser through the meta tag
> which
> charset is used (UTF-8). However IE doesn't seem to give a damn about
> this.
> I'm pulling my hair. :-(
>
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
My current theory is that IE needs BOTH header() and META charset to
agree before it will believe you. :-)
On Sat, August 12, 2006 8:05 pm, Jonny Bergström wrote:
> It's me again. I might have solved it... in a way. Still quite puzzled
> about
> why IE don't give a dime about the meta encoding line in the html head
> tag.
>
> Here's what I did. The aforementioned header file now adds a header()
> statement sending a content-type that also tells the charset, utf-8. :
>
> ---snip---
> <?php
> header('Content-Type: text/html; charset=utf-8');
> echo '<?xml version="1.0" encoding="UTF-8"?>';?>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
> http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html>
> <head>
> <meta name="Content-type" content="text/html; charset=UTF-8"
> />
>
> ---snip---
>
>
> I don't know if it's the best way to solve it but IE seems happy with
> it,
> and I haven't seen any sideeffects in FF so far.
>
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
On Sun, August 13, 2006 1:43 pm, Rasmus Lerdorf wrote:
> tedd wrote:
>> At 6:48 PM -0700 8/12/06, Rasmus Lerdorf wrote:
>>> By the way, everyone should be setting a charset. If you don't set
>>> it, IE will look at the first 4k of the body of the page and take a
>>> wild guess.
>>>
>>> -Rasmus
>>
>> -Rasmus:
>>
>> Ok, but why doesn't w3c use it?
>>
>> http://validator.w3.org (check source)
>>
>> I'm not sure what to do re charset. I've been told by credible
>> sources
>> to "always use it" and "never use it" -- which is correct? Or, is
>> this
>> one of those "it depends" things?
>
> W3C is all about standards. IE is all about not following standards.
> If you want your site to work in the real world you should always set
> a
> charset. If you set it in your response header there is no need to
> set
> it in each page, and if you look closely, you will see that this is
> what
> w3.org is doing:
>
> 9:55am shiny:~> telnet validator.w3.org 80
> Trying 133.27.228.132...
> Connected to validator.w3.org.
> Escape character is '^]'.
> HEAD / HTTP/1.0
>
> HTTP/1.1 200 OK
> Date: Sun, 13 Aug 2006 18:42:15 GMT
> Server: Apache/2.0.54 (Debian GNU/Linux) mod_perl/1.999.21 Perl/v5.8.4
> Accept-Ranges: bytes
> Connection: close
> Content-Type: text/html; charset=utf-8
If you want it to actually WORK in IE, you need both header() and META
tag...
At least in my limited testing so far under UTF-8 and Transition DOCTYPE.
YMMV
This is no guarantee that IE will work under any other DOCTYPEs, nor
in any other versions of IE.
Only that I know that's what it took for the current version of IE I
was using a month or two ago.
It would be interesting if somebody who understood charsets MUCH
better than I were to test all the combinations of:
IE version X header/meta charset X many charsets
and see just how many of them actually work, and how many of them open
up IE to XSS attacks...
What a mess MS makes of things!
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
On Sat, August 12, 2006 5:57 pm, Afan Pasalic wrote:
> You're talking about something like captcha, right?
No.
FORM PAGE:
<?php
$token = uniqid();
//the following line is a gross abuse of a lack of error-checking:
mysql_query("insert into tokens (token, used) values('$token',
'valid')";
?>
<form ...>
<input type="hidden" name="token" value="<?php echo
htmlentities($token);?>" />
</form>
PROCESSING PAGE:
<?php
$token = $_POST['token'];
//validate token here as 32-char alphanumeric or whatever uniqid()
outputs...
$used = mysql_query("select used from tokens where token = '$token'");
$used = mysql_result($used, 0, 0);
if ($used == 'valid'){
//process form (more bad code follows)
mysql_query("update tokens set used = 'invalid' where token =
'$token'");
}
else{
//You cannot re-submit this form. Sorry.
}
?>
> Richard Lynch wrote: On Sat, August 12, 2006 1:55 pm, Afan Pasalic
> wrote: could I use this code to check if form is submitted
> from the same page/same domain if ($_POST['form_submitted'] ==
> 'Yes') { if (preg_match($_SERVER['HTTP_HOST'],
> $_SERVER["HTTP_REFERER"]) == 0) { die ('^&%*^%#
#');
> } } No. HTTP_REFERER is completely unreliable. If you
> want to be sure of the source of your POST data coming from your
> form, you need to send a unique unpredictable token in the FORM, and
> log it when you send the FORM, and then compare what comes back.
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
And I assume that this should be reused to minimize the time spent on this
by creating a form class or function, correct?
I have been thinking about this too, and it makes a lot sense to do like
this.
/Peter
-----Original Message-----
From: Richard Lynch [mailto:ceo
l-i-e.com]
Sent: Tuesday, August 15, 2006 7:47 AM
To: Afan Pasalic
Cc: ceo
l-i-e.com; php-general
lists.php.net
Subject: Re: [PHP] script to check if form is submitted from the same page?
On Sat, August 12, 2006 5:57 pm, Afan Pasalic wrote:
> You're talking about something like captcha, right?
No.
FORM PAGE:
<?php
$token = uniqid();
//the following line is a gross abuse of a lack of error-checking:
mysql_query("insert into tokens (token, used) values('$token',
'valid')";
?>
<form ...>
<input type="hidden" name="token" value="<?php echo
htmlentities($token);?>" />
</form>
PROCESSING PAGE:
<?php
$token = $_POST['token'];
//validate token here as 32-char alphanumeric or whatever uniqid()
outputs...
$used = mysql_query("select used from tokens where token = '$token'");
$used = mysql_result($used, 0, 0);
if ($used == 'valid'){
//process form (more bad code follows)
mysql_query("update tokens set used = 'invalid' where token =
'$token'");
}
else{
//You cannot re-submit this form. Sorry.
}
?>
> Richard Lynch wrote: On Sat, August 12, 2006 1:55 pm, Afan Pasalic
> wrote: could I use this code to check if form is submitted
> from the same page/same domain if ($_POST['form_submitted'] ==
> 'Yes') { if (preg_match($_SERVER['HTTP_HOST'],
> $_SERVER["HTTP_REFERER"]) == 0) { die ('^&%*^%#
#');
> } } No. HTTP_REFERER is completely unreliable. If you
> want to be sure of the source of your POST data coming from your
> form, you need to send a unique unpredictable token in the FORM, and
> log it when you send the FORM, and then compare what comes back.
--
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
attached mail follows:
On Sat, August 12, 2006 10:57 pm, John Taylor-Johnston wrote:
> I have a bulk emailing list to a select group (I never spam, only to
> those who want it). Sometimes their imap/pop servers block my mail.
> I know I can assign another smtp over-riding what is in the php.ini
> file. I can likely find enough code here:
> http://ca3.php.net/manual/en/ref.mail.php
> So, where can I find another smtp server that will send my mail (using
> php) and certify that it comes from me?
> Is a proxy server the way to go? Costly?
Unless you know for 100% certain it is being filtered out based on the
IP address being logged as a spammer somewhere, changing SMTP servers
won't do diddly-squat...
In other words, if the email LOOKS like a spam, and the spam filters
are kicking in based on content, then it don't matter where it comes
from.
If, in fact, the IP you use to send email is in a list of known
spammers (which is far too easy to happen) and then the email is
getting blocked for that reason, finding another host to run email out
is pretty much just finding another webhost.
There presumably are "specialists" who handle bulk email that you can
pay just for sending email, but their prices may well be no better
than just setting up a different cheap webhost, unless you have SUPER
high volume email.
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
>>I have a bulk emailing list to a select group (I never spam, only to
>>those who want it). Sometimes their imap/pop servers block my mail.
>>I know I can assign another smtp over-riding what is in the php.ini
>>file. I can likely find enough code here:
>>http://ca3.php.net/manual/en/ref.mail.php
>>So, where can I find another smtp server that will send my mail (using
>>php) and certify that it comes from me?
>>Is a proxy server the way to go? Costly?
>>
>>
>
>Unless you know for 100% certain it is being filtered out based on the
>IP address being logged as a spammer somewhere, changing SMTP servers
>won't do diddly-squat...
>
>
I'm sure. CGI proxy I think is the key word I'm looking for.
I would even pay $10 per year for an SMTP access account if it fixed my
problems.
John
--
John Taylor-Johnston
-----------------------------------------------------------------------------
"If it's not Open Source, it's Murphy's Law."
''' Cégep de Sherbrooke:
ô¿ô http://www.cegepsherbrooke.qc.ca/languesmodernes/
- 819-569-2064
°v° Bibliography of Comparative Studies in Canadian, Québec and Foreign Literatures
/(_)\ Université de Sherbrooke
^ ^ http://compcanlit.ca/ T: 819.569.2064
attached mail follows:
For the US folks, Chicago is centrally-located, and flights to O'Hare
and Midway are generally frequent and often go on sale.
Global visitors might want to fly to Toronto or some other CA city
"close" to Chicago and drive, though :-)
I'm hopeful that by Spring 2007, flying to the US will be a less
unpleasant experience than it is currently...
On Sat, August 12, 2006 5:23 pm, Gerry D wrote:
> Richard,
>
> Within the US that might be ok, but given latest developments, who
> wants to fly into the US from elsewhere? I could drive from Canada if
> I take 2 weeks vacation...
>
> I don't want to be a show stopper, but I think you need to explain
> what your target audience is re global travel, not just weather in
> Chicago.
>
> Having said that, I like your idea.
>
> Gerry
>
> On 8/12/06, Richard Lynch <ceo
l-i-e.com> wrote:
>> It may have started as a joke on PHP-General, but this just isn't
>> funny anymore.
>>
>> I'm in the pre-planning phase of organizing a PHP Conference in
>> Chicago.
>>
>> Due to Chicago weather patterns, the ideal time would be Spring or
>> Autumn.
>>
>> Given that cheap airfare generally requires significant advance
>> notice, I am pre-emptorily eliminating Autumn 2006 as a viable
>> option.
>>
>> If you are interested in attending please reply OFF-LIST with your
>> name, email, and some basic input for ideal time-frames in the FALL
>> or
>> SPRING of 2007.
>>
>> Suggested Topics would be great, and offers to be a Speaker by
>> well-known responders would also be MOST welcome.
>
--
Like Music?
http://l-i-e.com/artists.htm
attached mail follows:
--
I'm hopeful that by Spring 2007, flying to the US will be a less
unpleasant experience than it is currently...
--
As in the border guards would start stocking lubricant as well
as rubber gloves?
Windsor, Ontario Canada would probably be a better flight
destination (you would likely end up hubing through toronto
anyways, but would save you 3 hours of driving). Though the
Windsor/Detroit border crossing is the busiest, and the guards
there take it pretty seriously (ok, so I may have been deported
once).
paul
On 8/14/06, Richard Lynch <ceo
l-i-e.com> wrote:
>
> For the US folks, Chicago is centrally-located, and flights to O'Hare
> and Midway are generally frequent and often go on sale.
>
> Global visitors might want to fly to Toronto or some other CA city
> "close" to Chicago and drive, though :-)
>
> I'm hopeful that by Spring 2007, flying to the US will be a less
> unpleasant experience than it is currently...
>
> On Sat, August 12, 2006 5:23 pm, Gerry D wrote:
> > Richard,
> >
> > Within the US that might be ok, but given latest developments, who
> > wants to fly into the US from elsewhere? I could drive from Canada if
> > I take 2 weeks vacation...
> >
> > I don't want to be a show stopper, but I think you need to explain
> > what your target audience is re global travel, not just weather in
> > Chicago.
> >
> > Having said that, I like your idea.
> >
> > Gerry
> >
> > On 8/12/06, Richard Lynch <ceo
l-i-e.com> wrote:
> >> It may have started as a joke on PHP-General, but this just isn't
> >> funny anymore.
> >>
> >> I'm in the pre-planning phase of organizing a PHP Conference in
> >> Chicago.
> >>
> >> Due to Chicago weather patterns, the ideal time would be Spring or
> >> Autumn.
> >>
> >> Given that cheap airfare generally requires significant advance
> >> notice, I am pre-emptorily eliminating Autumn 2006 as a viable
> >> option.
> >>
> >> If you are interested in attending please reply OFF-LIST with your
> >> name, email, and some basic input for ideal time-frames in the FALL
> >> or
> >> SPRING of 2007.
> >>
> >> Suggested Topics would be great, and offers to be a Speaker by
> >> well-known responders would also be MOST welcome.
> >
>
>
> --
> 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
>
>
--
Paul Reinheimer
Zend Certified Engineer
attached mail follows:
Can anyone tell me if this is possible-
I currrently have a simple form with a textbox and submit button where a
user chooses a number from 1-22 then on submit it opens another page with a
table of results within another form.
What i need is for the second form to be shown on the same page and just
below form 1, then when the second form is submitted it then goes back to
just form1.
What i am trying to do is get rid of multiple pages and have the user stay
on the same page for all admin functions.
Bigmark
attached mail follows:
On Tue, 2006-08-15 at 11:01 +0800, Bigmark wrote:
> Can anyone tell me if this is possible-
Yes it is.
> I currrently have a simple form with a textbox and submit button where a
> user chooses a number from 1-22 then on submit it opens another page with a
> table of results within another form.
> What i need is for the second form to be shown on the same page and just
> below form 1, then when the second form is submitted it then goes back to
> just form1.
> What i am trying to do is get rid of multiple pages and have the user stay
> on the same page for all admin functions.
>
> Bigmark
>
--
.------------------------------------------------------------.
| 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. |
`------------------------------------------------------------'
attached mail follows:
Does anyone have a simple example script.
attached mail follows:
On Tue, 2006-08-15 at 01:24 -0400, Robert Cummings wrote:
> On Tue, 2006-08-15 at 13:02 +0800, Bigmark wrote:
> > Does anyone have a simple example script.
> >
>
> In the first form include a hidden field that identifies the form when
> you are checking the post values after submission. This way you know
> exactly what form was submitted. Second if the first form has been
> submitted then you know that you need to present the second form also.
> THe second form should also have a hidden field so that it may be
> identified upon submission. In this way you can detect which form was
> submitted (submit buttons are problematic for determining which form was
> submitted). Then when you detect that the second form was submitted you
> can handle it's data as you please and then only present the first form.
>
> A basic example follows (completely unchecked for typos/errors):
And of course it had errors :) See below...
>
> <?php
>
> $submittedForm = null;
> if( isset( $_POST['formSubmitted'] ) )
> {
> $submittedForm = $_POST['formSubmitted'];
>
> if( $_POST['formSubmitted'] == 'form1' )
> {
> // do something with its data.
> }
> else
> if( $_POST['formSubmitted'] == 'form2' )
> {
> // do something with its data.
> }
> }
> ?>
>
> <form name="form1" method="post" action="<?= $_SERVER['PHP_SELF'] ?>">
> <input type="hidden" value="form1" />
Should be:
<input type="hidden" name="formSubmitted" value="form1" />
> <select name="game">
> <option value="1">1</option>
> <option value="2">2</option>
> <option value="3">3</option>
> <option value="...">...</option>
> </select>
> <input type="submit" name="continue" value="Continue" />
> </form>
>
> <?php
> if( $submittedForm == 'form1' )
> {
> ?>
>
> <form name="form2" method="post" action="<?= $_SERVER['PHP_SELF'] ?>">
> <input type="hidden" value="form2" />
Should be:
<input type="hidden" name="formSubmitted" value="form2" />
> <select name="blah">
> <option value="foo">Foo</option>
> <option value="fee">Fee</option>
> <option value="fii">Fii</option>
> <option value="foh">Foh</option>
> <option value="fum">Fum</option>
> </select>
> <input type="submit" name="continue" value="Continue" />
> </form>
>
> <?php
> }
> ?>
>
> 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. |
`------------------------------------------------------------'
attached mail follows:
On Tue, 2006-08-15 at 13:02 +0800, Bigmark wrote:
> Does anyone have a simple example script.
>
In the first form include a hidden field that identifies the form when
you are checking the post values after submission. This way you know
exactly what form was submitted. Second if the first form has been
submitted then you know that you need to present the second form also.
THe second form should also have a hidden field so that it may be
identified upon submission. In this way you can detect which form was
submitted (submit buttons are problematic for determining which form was
submitted). Then when you detect that the second form was submitted you
can handle it's data as you please and then only present the first form.
A basic example follows (completely unchecked for typos/errors):
<?php
$submittedForm = null;
if( isset( $_POST['formSubmitted'] ) )
{
$submittedForm = $_POST['formSubmitted'];
if( $_POST['formSubmi