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

Diff for Metafox/lib/Platon.php between version 1.12 and 1.13

version 1.12, 2017/11/08 01:12:03 version 1.13, 2024/11/20 15:48:03
Line 15 
Line 15 
  * Usage:   * Usage:
  *   <?php   *   <?php
  *       require_once 'Platon.php';   *       require_once 'Platon.php';
  *       Platon::function_name();   *       Platon::function_name();
  *   ?>   *   ?>
  *   *
  * @author      Ondrej Jombik <nepto@platon.sk>   * @author      Ondrej Jombik <nepto@platon.sk>
Line 25 
Line 25 
  * @access      public   * @access      public
  */   */
   
 /* $Platon: phpPlatonLib/Platon/Platon.php,v 1.43 2017/11/08 01:09:07 nepto Exp $ */  /* $Platon: Metafox/lib/Platon.php,v 1.12 2017/11/08 01:12:03 nepto Exp $ */
   
 class Platon  class Platon
 {  {
Line 82  class Platon
Line 82  class Platon
      */       */
     static function get_cgi_var($name, $default_value = null) /* {{{ */      static function get_cgi_var($name, $default_value = null) /* {{{ */
     {      {
         static $magic_quotes_gpc = null;                  $var = $_GET[$name] ?? $_POST[$name] ?? $default_value;
         if ($magic_quotes_gpc === null) {                  if (isset($var)) {
             $magic_quotes_gpc = get_magic_quotes_gpc();                          if (is_array($var)) {
         }                                  foreach ($var as $key => $value) {
         $var = @$_GET[$name];                                          $var[$key] = stripslashes($value);
         if (! isset($var)) {                                  }
             $var = @$_POST[$name];                          } else {
         }                                  $var = stripslashes($var);
         if (isset($var)) {                          }
             if ($magic_quotes_gpc) {                  }
                 if (is_array($var)) {                  return $var;
                     foreach (array_keys($var) as $key) {  
                         $var[$key] = stripslashes($var[$key]);  
                     }  
                 } else {  
                     $var = stripslashes($var);  
                 }  
             }  
         } else {  
             $var = @$default_value;  
         }  
         return $var;  
     } /* }}} */      } /* }}} */
   
    /**     /**
Line 131  class Platon
Line 120  class Platon
         $dir_back = '';          $dir_back = '';
         $i = substr_count(Platon::append_slash($dir), '/');          $i = substr_count(Platon::append_slash($dir), '/');
         for (; $i > 0; $i--)          for (; $i > 0; $i--)
             $dir_back .= '../';              $dir_back .= '../';
         return $dir_back;          return $dir_back;
     } /* }}} */      } /* }}} */
   
Line 153  class Platon
Line 142  class Platon
   
     /**      /**
      * Performs a HTTP/1.1 redirect according to RFC 2068       * Performs a HTTP/1.1 redirect according to RFC 2068
      *       *
      * @param   string  $where      where to redirect (URL or local script)       * @param   string  $where      where to redirect (URL or local script)
      * @param   boolean $temporary  if such redirect is only temporary one       * @param   boolean $temporary  if such redirect is only temporary one
      * @todo    implement HTML page redirecting if output was aleady sent       * @todo    implement HTML page redirecting if output was aleady sent
Line 201  class Platon
Line 190  class Platon
   
     /**      /**
      * Changes a HTTP host using permanent redirect       * Changes a HTTP host using permanent redirect
      *       *
      * @param   string  $new_http_host  destination HTTP host       * @param   string  $new_http_host  destination HTTP host
      * @param   string  $old_http_host  source HTTP host (string or array)       * @param   string  $old_http_host  source HTTP host (string or array)
      *                                  empty string means any host       *                                  empty string means any host
Line 229  class Platon
Line 218  class Platon
         $request_uri = $_SERVER['REQUEST_URI'];          $request_uri = $_SERVER['REQUEST_URI'];
         return Platon::redirect("$schema://$new_http_host$request_uri");          return Platon::redirect("$schema://$new_http_host$request_uri");
     } /* }}} */      } /* }}} */
   
     /**      /**
      * Redirects if it is neccessary for particular file.       * Redirects if it is neccessary for particular file.
      *       *
Line 377  class Platon
Line 366  class Platon
     {      {
         // Pronounceable pieces of words          // Pronounceable pieces of words
         $array = array(          $array = array(
                 'ap', 'baz', 'car', 'dus', 'tin', 'rog', 'sti',                  'ap', 'baz', 'car', 'dus', 'tin', 'rog', 'sti',
                 'rev', 'pik', 'sty', 'lev', 'qot', 'rel', 'vid',                  'rev', 'pik', 'sty', 'lev', 'qot', 'rel', 'vid',
                 'kro', 'xo', 'pro', 'wia', 'axi', 'jer', 'foh',                  'kro', 'xo', 'pro', 'wia', 'axi', 'jer', 'foh',
                 'mu', 'ya', 'zol', 'gu', 'pli', 'cra', 'den',                  'mu', 'ya', 'zol', 'gu', 'pli', 'cra', 'den',
                 'bi', 'sat', 'ry', 'qui', 'wip', 'fla', 'gro',                  'bi', 'sat', 'ry', 'qui', 'wip', 'fla', 'gro',
                 'tav', 'peh', 'gil', 'lot', 'kal', 'zan', 'noc',                  'tav', 'peh', 'gil', 'lot', 'kal', 'zan', 'noc',
                 'bat', 'tev', 'lun', 'pal', 'hom', 'cun', 'wos', 'vox');                  'bat', 'tev', 'lun', 'pal', 'hom', 'cun', 'wos', 'vox');
   
         // Randomize on microseconds          // Randomize on microseconds
Line 412  class Platon
Line 401  class Platon
         return $pass;          return $pass;
     } /* }}} */      } /* }}} */
   
     /**      /**
      * Returns random string of length $len consisting of A-Z and 0-9; first       * Returns random string of length $len consisting of A-Z and 0-9; first
      * character will always be an alphabet; requires srand().       * character will always be an alphabet; requires srand().
      *       *
Line 437  class Platon
Line 426  class Platon
         return $s;          return $s;
     } /* }}} */      } /* }}} */
   
     /**      /**
      * Appends slash at the end of string if it is not empty and slash is not       * Appends slash at the end of string if it is not empty and slash is not
      * already present at the end of string.       * already present at the end of string.
      *       *
Line 451  class Platon
Line 440  class Platon
             return false;              return false;
         }          }
         if (strlen($string) > 0) {          if (strlen($string) > 0) {
             if ($string[strlen($string) - 1] != $char[0])              if ($string[strlen($string) - 1] != $char[0])
                 $string .= $char[0];                  $string .= $char[0];
         }          }
         return $string;          return $string;
     } /* }}} */      } /* }}} */
   
     /**      /**
      * Returns appropriate value from array according to key compared with       * Returns appropriate value from array according to key compared with
      * passed string or false when no key contains passed string.       * passed string or false when no key contains passed string.
      *       *
Line 515  class Platon
Line 504  class Platon
   
     /**      /**
      * Returns pretty formated substring.       * Returns pretty formated substring.
      *       *
      * @param   string  $string     string to format       * @param   string  $string     string to format
      * @param   int     $length     maximum length       * @param   int     $length     maximum length
      * @param   int     $slop       slop       * @param   int     $slop       slop
Line 541  class Platon
Line 530  class Platon
 # warning: code below contains at least one bug  # warning: code below contains at least one bug
   
 # set define off; -- makes it so SQL*Plus doesn't choke on the '&'  # set define off; -- makes it so SQL*Plus doesn't choke on the '&'
 #  #
 # create or replace  # create or replace
 # static function pretty_substr  # static function pretty_substr
 # (  # (
Line 555  class Platon
Line 544  class Platon
 # begin  # begin
 #    if length(str) > len then  #    if length(str) > len then
 #       result := substr(str, 0, len - 1);  #       result := substr(str, 0, len - 1);
 #  #
 #       last_space := instr(result, ' ', (-1 * slop), 1);  #       last_space := instr(result, ' ', (-1 * slop), 1);
 #  #
 #       if last_space > 0 then  #       if last_space > 0 then
 #          result := substr(result, 0, last_space - 1);  #          result := substr(result, 0, last_space - 1);
 #       end if;  #       end if;
 #  #
 #       result := result || '&hellip;';  #       result := result || '&hellip;';
 #    else  #    else
 #       result := str;  #       result := str;
 #    end if;  #    end if;
 #  #
 #    return result;  #    return result;
 # end pretty_substr;  # end pretty_substr;
 # }}}  # }}}
   
     /**      /**
      * Insert element into array on specific index.       * Insert element into array on specific index.
      *       *
Line 593  class Platon
Line 582  class Platon
         array_push($before, $element);          array_push($before, $element);
         return array_merge($before, $arr);          return array_merge($before, $arr);
     } /* }}} */      } /* }}} */
   
     /**      /**
      * Returns english grammar related number.       * Returns english grammar related number.
      *       *
Line 857  class Platon
Line 846  class Platon
         return $path;          return $path;
     } /* }}} */      } /* }}} */
   
     /**      /**
      * Creates URL string from components; components are array as it is       * Creates URL string from components; components are array as it is
      * returned from glue_url() function.       * returned from glue_url() function.
      *       *
Line 867  class Platon
Line 856  class Platon
      * @date    19/Feb/2001       * @date    19/Feb/2001
      */       */
     static function glue_url($url) /* {{{ */      static function glue_url($url) /* {{{ */
     {      {
         if (! is_array($url))          if (! is_array($url))
             return false;              return false;
         // scheme          // scheme
         $uri = empty($url['scheme']) ? '' : $url['scheme'] . '://';          $uri = empty($url['scheme']) ? '' : $url['scheme'] . '://';
         // user and pass          // user and pass
         if (! empty($url['user'])) {          if (! empty($url['user'])) {
             $uri .= $url['user'].':'.$url['pass'].'@';              $uri .= $url['user'].':'.$url['pass'].'@';
         }          }
         // host          // host
         $uri .= $url['host'];          $uri .= $url['host'];
         // port          // port
         $port = empty($url['port']) ? '' : ':'.$url['port'];          $port = empty($url['port']) ? '' : ':'.$url['port'];
         $uri .= $port;          $uri .= $port;
         // path          // path
         $uri .= $url['path'];          $uri .= $url['path'];
         // fragment or query          // fragment or query
         if (isset($url['fragment'])) {          if (isset($url['fragment'])) {
             $uri .= '#' . $url['fragment'];              $uri .= '#' . $url['fragment'];
         }          }
         elseif (isset($url['query'])) {          elseif (isset($url['query'])) {
             $uri .= '?' . $url['query'];              $uri .= '?' . $url['query'];
         }          }
         return $uri;          return $uri;
     } /* }}} */      } /* }}} */
   
     /**      /**

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

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