Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Wednesday, October 14, 2026

Diff for phpPlatonLib/Platon/Platon.php between version 1.11 and 1.12

version 1.11, 2003/01/13 13:34:00 version 1.12, 2003/01/13 23:04:15
Line 26 
Line 26 
   
 class Platon  class Platon
 {  {
     /** common/cgi/fnc.http_prefix_on_CGI_vars.php - adds 'http://'  
      * prefix on passed CGI variables if it is missing; accepts string  
      * or array of strings on input  
      */  
     function http_prefix_on_CGI_vars($param) /* {{{ */  
     {  
         $ret = true;  
         if (is_string($param)) {  
             global $HTTP_GET_VARS;  
             global $HTTP_POST_VARS;  
             global $$param;  
   
             $$param = trim($$param);  
             if (! empty($$param)) {  
                 if (! preg_match('|^http[s]?://|', $$param))  
                     $$param = 'http://' . $$param;  
             }  
             $HTTP_GET_VARS[$param] = trim($HTTP_GET_VARS[$param]);  
             if (! empty($HTTP_GET_VARS[$param])) {  
                 if (! preg_match('|^http[s]?://|', $HTTP_GET_VARS[$param]))  
                     $HTTP_GET_VARS[$param] =  
                         'http://' . $HTTP_GET_VARS[$param];  
             }  
             $HTTP_POST_VARS[$param] = trim($HTTP_POST_VARS[$param]);  
             if (! empty($HTTP_POST_VARS[$param])) {  
                 if (! preg_match('|^http[s]?://|', $HTTP_POST_VARS[$param]))  
                     $HTTP_POST_VARS[$param] =  
                         'http://' . $HTTP_POST_VARS[$param];  
             }  
         }  
         elseif (is_array($param)) {  
             foreach ($param as $var) {  
                 $ret = $ret && http_prefix_on_CGI_vars($var);  
             }  
         }  
         else {  
             $ret = false;  
         }  
         return $ret;  
     } /* }}} */  
   
     /** common/cgi/fnc.parse_id_param.php - parses ID param from CGI      /**
        * Parses ID parameter from separate value in query string
        * or fallback to $key_name CGI variable.
        *
        * @param   string  $key_name       name of ID parameter
        * @param   mixed   $exploded_qs    exploded query string (array)
        *                                  or true to perform split method itself
        *                                  or false to skip extraction from QS
        * @return          parsed ID param
      */       */
     function parse_id_param($key_name = 'id', $exploded_qs = true) /* {{{ */      function parse_id_param($key_name = 'id', $exploded_qs = true) /* {{{ */
     {      {
Line 105  class Platon
Line 73  class Platon
         return $ret;          return $ret;
     } /* }}} */      } /* }}} */
   
     /** common/cgi/fnc.stripslashes_from_CGI_vars.php - strips slashes  
      * from CGI variables; accepts string or array of strings on input  
      */  
     function stripslashes_from_CGI_vars($param) /* {{{ */  
     {  
         $ret = true;  
         if (is_string($param)) {  
             global $HTTP_GET_VARS;  
             global $HTTP_POST_VARS;  
             global $$param;  
             if (isset($$param))  
                 $$param = stripslashes($$param);  
             if (isset($HTTP_GET_VARS[$param]))  
                 $HTTP_GET_VARS[$param] =  
                     stripslashes($HTTP_GET_VARS[$param]);  
             if (isset($HTTP_POST_VARS[$param]))  
                 $HTTP_POST_VARS[$param] =  
                     stripslashes($HTTP_POST_VARS[$param]);  
         } elseif (is_array($param)) {  
             foreach ($param as $var)  
                 $ret = $ret && stripslashes_from_CGI_vars($var);  
         } else {  
             $ret = false;  
         }  
         return $ret;  
     } /* }}} */  
   
     /** common/cgi/fnc.unset_all.php - unsets all CGI types of variable  
      */  
   
     function unset_all($var) /* {{{ */  
     {  
         global $HTTP_POST_VARS;  
         global $HTTP_GET_VARS;  
         global $HTTP_COOKIE_VARS;  
         global $$var;  
         unset($HTTP_POST_VARS[$var]);  
         unset($HTTP_GET_VARS[$var]);  
         unset($HTTP_COOKIE_VARS[$var]);  
         //unset($$var);  
         $$var = '';  
         return true;  
     } /* }}} */  
   
     /**      /**
      * Returns value of CGI variable.       * Returns value of CGI variable.
      *       *
Line 265  class Platon
Line 189  class Platon
     } /* }}} */      } /* }}} */
   
     /**      /**
      * Creates HTML hidden form fields for passed GET variables.       * Returns original variables HTML code for use in forms or links.
      *       *
      * @param   mixed   $origvars   string or array fo original varaibles       * @param   mixed   $origvars       string or array of original varaibles
      * @param   mixed   $default_value  default value       * @param   string  $method         type of method ("POST" or "GET")
      * @return          TODO       * @param   mixed   $default_value  default value of variables
        *                                  if null, empty values will be skipped
        * @return                          get HTML code of original varaibles
      */       */
     function write_origvars_html($origvars, $default_value = null, $method = 'POST') /* {{{ */      function get_origvars_html($origvars, $method = 'POST', $default_value = '') /* {{{ */
     {      {
         if (! is_array($origvars)) {          $ret    = '';
           $method = strtoupper($method);
           if ($method == 'POST') {
               if (! is_array($origvars)) {
                   foreach (explode('&', $origvars) as $param) {
                       $parts = explode('=', $param, 2);
                       if (! isset($parts[1])) {
                           $parts[1] = $default_value;
                       }
                       if (strlen($parts[0]) <= 0) {
                           continue;
                       }
                       $origvars[$parts[0]] = $parts[1];
                   }
               }
               foreach ($origvars as $key => $val) {
                   if (strlen($val) <= 0 && $default_value === null) {
                       continue;
                   }
                   $key = rawurldecode($key);
                   $val = rawurldecode($val);
                   $ret .= '<input type="hidden" name="';
                   $ret .= htmlspecialchars($key).'"';
                   $ret .= ' value="'.htmlspecialchars($val).'"';
                   $ret .= " />\n";
               }
           } else if (! strncmp('GET', $method, 3)) {
               if (! is_array($origvars)) {
                   $ret .= $origvars;
               } else {
                   foreach ($origvars as $key => $val) {
                       if (strlen($val) <= 0 && $default_value === null) {
                           continue;
                       }
                       $ret == '' || $ret .= '&amp;';
                       $ret .= htmlspecialchars(rawurlencode($key));
                       $ret .= '=';
                       $ret .= htmlspecialchars(rawurlencode($val));
                   }
               }
               if ($method[strlen($method) - 1] == '+') {
                   $ret = "?$ret";
               }
           } else {
               trigger_error('Unsupported Platon::get_origvars_html() method: '
                       .$method, E_USER_ERROR);
           }
           return $ret;
       }
   
         /*  if (! is_array($origvars)) {
             foreach (explode('&', $origvars) as $param) {              foreach (explode('&', $origvars) as $param) {
                 $parts = explode('=', $param, 2);                  $parts = explode('=', $param, 2);
                 if (! isset($parts[1])) {                  if (! isset($parts[1])) {
Line 305  class Platon
Line 281  class Platon
     } /* }}} */      } /* }}} */
   
     /**      /**
        * Reverse of the standard htmlspecialchars() PHP function.
        *
        * @param   string  $str    input string
        * @return                  descaped string
        * @author  Nathan Codding
        * @date    24/Aug/2000
        */
       function undo_htmlspecialchars($str) /* {{{ */
       {
           $str = preg_replace('/&gt;/i',   '>',  $str);
           $str = preg_replace('/&lt;/i',   '<',  $str);
           $str = preg_replace('/&quot;/i', '\'', $str);
           $str = preg_replace('/&amp;/i',  '&',  $str);
           return $str;
       } /* }}} */
   
       /**
      * Returns pronounceable random password       * Returns pronounceable random password
      *       *
      * @param   array   $array          array of sylables or null for default       * @param   array   $array          array of sylables or null for default

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top