[pmwiki-users] Fourth Post--ZAP bugs

The Editor editor at fast.st
Fri Oct 27 06:25:15 CDT 2006


On 10/27/06, Crisses <crisses at kinhost.org> wrote:
> Oh no!
>
> you're changing $_POST[$field] several times and OVERWRITING it with
> something completely new.  This isn't a chain of events happening to $value.
>  This is "Place A in the bucket.  Dump the bucket out and place B in the
> bucket.  Dump the bucket out and place C in the bucket."

Ahhh Crisses, you got it.  How obvious!  Thanks a million...

> You see, when you read $value from $_POST $value becomes it's own copy.
> Changing $_POST[$field] = "X"; will not change $value to "X".  $value stays
> the same through the whole chain, because you're not explicitly changing
> $value.
>
> Try this:
>  foreach ($_POST as $field => $value) {
>  if (get_magic_quotes_gpc()) $value = stripslashes($value);
>  $value = preg_replace('/\\(:/', '(&#x3a;', $value);
>  $value = preg_replace('/\\{(\\w+)\\}/e', "\$_POST[$1]", $value);
>  if (is_array($value)) $value = implode(",", $value);
>  $_POST[$field] = $value;
>  }
>
> I'm not exactly sure what line
>  $value = preg_replace('/\\{(\\w+)\\}/e', "\$_POST[$1]", $value);
> is doing with the "\$_POST[$1]" value -- you may want to change that too?
> It's too early for me to really parse the code, sorry.  But it's one line I
> think you said worked....

Yes, this allows for field replacement so if I put Field1={Field2} it
automatically swaps in that value.  If I have problems with it I can
move it elsewhere in the processing. But it should work like this.

Thanks again!  What a relief...  Knew it had to be something obvious.

Cheerier still,
Caveman




More information about the pmwiki-users mailing list