Fixed some E_ALL warnings, should now be E_ALL clean.
[squirrelmail.git] / functions / html.php
index d49617344cb85cee6cab339d66a93e941069c592..b926f736960cc7cceb57e4a5f828fd22134a4d9c 100644 (file)
 
     /* handy function to set url vars */
     /* especially usefull when $url = $PHP_SELF */
-    function set_url_var($url, $var, $val=0) {
+    function set_url_var($url, $var, $val=0, $link=true) {
         $k = '';
         $ret = '';
-        $url = trim(preg_replace('/&/','&',$url));
-
         $pat_a = array (
                        '/.+(\\&'.$var.')=(.*)\\&/AU',   /* in the middle */
                        '/.+\\?('.$var.')=(.*\\&).+/AU', /* at front, more follow */
                        '/.+(\\?'.$var.')=(.*)$/AU',     /* at front and only var */
                        '/.+(\\&'.$var.')=(.*)$/AU'      /* at the end */
                      );
+       preg_replace('/&/','&',$url);            
         switch (true) {
             case (preg_match($pat_a[0],$url,$regs)):
                 $k = $regs[1];
         if ($k) {
             if ($val) {
                 $rpl = "$k=$val";
+               if ($link) {
+                   $rpl = preg_replace('/&/','&',$rpl);
+               }
             } else {
                 $rpl = '';
             }
             $pat = "/$k=$v/";
             $url = preg_replace($pat,$rpl,$url);
         }
-        return  preg_replace('/&/','&',$url);
+        return $url;
     }
 
     /* Temporary test function to proces template vars with formatting.