Login   Register  
PHP Classes
elePHPant
Icontem

File: plugins/outputfilter.addsessid.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of juan camilo rincon  >  Secure use_trans_sid  >  plugins/outputfilter.addsessid.php  >  Download  
File: plugins/outputfilter.addsessid.php
Role: Auxiliary script
Content type: text/plain
Description: output filter for smarty
Class: Secure use_trans_sid
Emulate the use_trans_sid option using Smarty
Author: By
Last change:
Date: 8 years ago
Size: 1,210 bytes
 

Contents

Class file image Download
<?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>";
 }

?>