<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* File: outputfilter.addsessid.php
* Type: outputfilter
* Name: addsessid
* Version: 1.0
* Date: Febrero 16, 2006
* Purpose: include dinamically the PHPSESSID in all <a href> tags.
* Author: Juan Camilo Rincon <jcrincon@parquesoft.com>
* -------------------------------------------------------------
*/
function smarty_outputfilter_addsessid($source, &$smarty)
{
$source = preg_replace_callback("`\<a href=(\"|\')([(https|http)://]*)([^\?|\"|\']+)(\?*)([^\"|\']*)([^\s]?)(\s+)([^\>]*)\>(.*)\<\/a>`i",
"buildhyperlink",
$source);
return $source;
}
function buildhyperlink($matches) {
// Pull out the script blocks
$getdata = "";
if(strcmp($matches[4],"?") == 0) {
$getdata = $matches[4];
if(!empty($getdata) && !empty($matches[5]))
$getdata .= $matches[5]."&PHPSESSID=".strip_tags($_REQUEST["PHPSESSID"]);
}
else
$getdata = "?PHPSESSID=".strip_tags($_REQUEST["PHPSESSID"]);
return "<a href=".$matches[1].$matches[2].$matches[3].$getdata.$matches[6].$matches[7].$matches[8].">".$matches[9]."</a>";
}
?>
|