note 31703 deleted from function.preg-replace-callback by sniper
| From: | sniper@php.net | Date: | Tue, 30 Sep 2003 12:26:08 +0000 |
| Subject: | note 31703 deleted from function.preg-replace-callback by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-57452@lists.php.net to get a copy of this message | ||
Note Submitter: fabrizio - > effepi.system at inwind.it
----
if you cannot modify the PHP.INI and you need to insert the PHPSESSID in all the links and pages,
here the solution:
ob_start("callback");
//here your page
function callback($buffer)
{
$buffer = preg_replace_callback
("/(href|action)+[\s]*=[\s]*[\"|'](.*?)[\"|']/i",
create_function('$matches','
global $PHPSESSID;
$m=$matches[2];
$queryNew="PID=$PHPSESSID";
$url = parse_url($m);
parse_str($url[\'query\'],$array1);
parse_str($queryNew,$array2);
$newQuery = array_merge($array1, $array2);
foreach($newQuery as $key => $value)
$newQry[]=$key."=".$value;
$url = substr($m,0,strpos($m,"?"));
if ($url=="")
$url = $m;
return " $matches[1]=\'{$url}?".implode("&",$newQry)."\'
";
')
,$buffer);
return $buffer;
}