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 Metafox/lib/Platon.php between version 1.11 and 1.12

version 1.11, 2015/01/20 15:20:17 version 1.12, 2017/11/08 01:12:03
Line 16 
Line 16 
  *   <?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>
    * @author      Igor Mino <igor@platon.sk>
  * @package     Platon   * @package     Platon
  * @version     1.0   * @version     1.1
  * @access      public   * @access      public
  */   */
   
 /* $Platon: Metafox/lib/Platon.php,v 1.10 2014-10-15 13:00:16 igor Exp $ */  /* $Platon: phpPlatonLib/Platon/Platon.php,v 1.43 2017/11/08 01:09:07 nepto Exp $ */
   
 class Platon  class Platon
 {  {
Line 182  class Platon
Line 183  class Platon
   
         header('Location: '.$url);          header('Location: '.$url);
         if (! $temporary) {          if (! $temporary) {
                         switch($status_code) {              switch($status_code) {
                                 case 303:                  case 303:
                                         header('HTTP/1.1 303 See Other');                      header('HTTP/1.1 303 See Other');
                                         break;                      break;
                                 case 302:                  case 302:
                                         header('HTTP/1.1 302 Found');                      header('HTTP/1.1 302 Found');
                                         break;                      break;
                                 case 301:                  case 301:
                                 default:                  default:
                                         header('HTTP/1.1 301 Moved Permanently');                      header('HTTP/1.1 301 Moved Permanently');
                                         break;                      break;
                         }              }
         }          }
         exit;          exit;
     } /* }}} */      } /* }}} */
Line 570  class Platon
Line 571  class Platon
 # end pretty_substr;  # end pretty_substr;
 # }}}  # }}}
   
         /**      /**
          * Insert element into array on specific index.       * Insert element into array on specific index.
          *       *
          * @param   array   $arr       input array       * @param   array   $arr       input array
          * @param   int     $index     position in array       * @param   int     $index     position in array
          * @param   mix     $element   inserted element       * @param   mix     $element   inserted element
          * @return  array              output array       * @return  array              output array
          */       */
         static function array_insert($arr, $index, $element) {      static function array_insert($arr, $index, $element) /* {{{ */
                 if (!is_array($arr)) {      {
                         return false;          if (!is_array($arr)) {
                 }              return false;
                 $index = intval($index);          }
                 if ($index > count($arr)-1) {          $index = intval($index);
                         array_push($arr, $element);          if ($index > count($arr)-1) {
                         return $arr;              array_push($arr, $element);
                 }              return $arr;
                 $before = array_splice($arr, 0, $index);          }
                 array_push($before, $element);          $before = array_splice($arr, 0, $index);
                 return array_merge($before, $arr);          array_push($before, $element);
         }          return array_merge($before, $arr);
       } /* }}} */
   
     /**      /**
      * Returns english grammar related number.       * Returns english grammar related number.
      *       *
Line 610  class Platon
Line 612  class Platon
         return $number;          return $number;
     } /* }}} */      } /* }}} */
   
           private static $_htmlspecialchars_encoding = '';
   
       /**
        * Set charset/encoding for out Platon::htmlspecialchars()
        *
        * @param   string  $encoding  encoding, for more info
        *                             see _deduct_htmlspecialchars_encoding()
        * @return  boolean            always true
        */
       static function htmlspecialchars_encoding($encoding) /* {{{ */
           {
                   Platon::$_htmlspecialchars_encoding = $encoding;
           return true;
           } /* }}} */
   
       /**
        * Encode special HTML characters based on encoding and PHP version
        *
        * @param   string  $string    string to encode
        * @param   string  $encoding  encoding to use (use default when empty)
        * @return  string             HTML encoded string
        */
           static function htmlspecialchars($string, $encoding = '') /* {{{ */
           {
           // no default encoding maps to no special transformation
           static $map = array('' => '');
           if (strlen($encoding) <= 0) {
               $encoding = Platon::$_htmlspecialchars_encoding;
           }
           if (! array_key_exists($encoding, $map)) {
                       if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION == 4) {
                   $map[$encoding]['flags']    = ENT_COMPAT | ENT_HTML401;
                   $map[$encoding]['encoding'] = Platon::_deduct_htmlspecialchars_encoding($encoding);
               } elseif ((PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 6)
                       || PHP_MAJOR_VERSION >= 7) {
                   $map[$encoding]['flags']    = ENT_QUOTES | ENT_HTML5 | ENT_DISALLOWED | ENT_SUBSTITUTE;
                   $map[$encoding]['encoding'] = Platon::_deduct_htmlspecialchars_encoding($encoding);
               } else {
                   $map[$encoding] = ''; // no special htmlspecialchars()
               }
           }
           if (is_array($map[$encoding])) {
               return htmlspecialchars($string,
                       $map[$encoding]['flags'],
                       $map[$encoding]['encoding']);
           }
                   // default
                   return htmlspecialchars($string);
           } /* }}} */
   
           static function _deduct_htmlspecialchars_encoding($encoding) /* {{{ */
           {
                   // List of supported charsets http://php.net/manual/en/function.htmlspecialchars.php
                   $allowed = array(
                           'ISO-8859-1', 'ISO8859-1',                                                      // Western European, Latin-1
                           'ISO-8859-5', 'ISO8859-5',                                                      // Little used cyrillic charset (Latin/Cyrillic)
                           'ISO-8859-15', 'ISO8859-15',                                            // Western European, Latin-9. Adds the Euro sign and others
                           'UTF-8',                                                                                        // ASCII compatible multi-byte 8-bit Unicode
                           'cp866', 'ibm866', '866',                                                       // DOS-specific Cyrillic charset
                           'cp1251', 'Windows-1251', 'win-1251', '1251',           // Windows-specific Cyrillic charset
                           'cp1252', 'Windows-1252', '1252',                                       // Windows specific charset for Western European
                           'KOI8-R', 'koi8-ru', 'koi8r',                                           // Russian
                           'BIG5', '950',                                                                          // Traditional Chinese, mainly used in Taiwan
                           'GB2312', '936',                                                                        // Simplified Chinese, national standard character set
                           'BIG5-HKSCS',                                                                           // Big5 with Hong Kong extensions, Traditional Chinese
                           'Shift_JIS', 'SJIS', 'SJIS-win', 'cp932', '932',        // Japanese
                           'EUC-JP', 'EUCJP', 'eucJP-win',                                         // Japanese
                           'MacRoman',                                                                                     // Charset that was used by Mac OS.
                           ''  // An empty string activates detection from script encoding (Zend multibyte),
                   // default_charset and current locale (see nl_langinfo() and setlocale()), in this order. Not recommended.
                   );
           if (in_array($encoding, $allowed)) {
               return $encoding;
           }
           $encoding_upper = strtoupper($encoding);
           foreach ($allowed as $allow) {
               if (strtoupper($allow) == $encoding_upper) {
                   return $allow;
               }
           }
           for ($len = strlen($encoding) - 1; $len > 0; $len--) {
               $encoding_prefix = substr($encoding_upper, 0, $len);
               foreach ($allowed as $allow) {
                   if (strtoupper(substr($allow, 0, min($len, strlen($allow)))) == $encoding_prefix) {
                       return $allow;
                   }
               }
           }
           return null;
       } /* }}} */
   
     /**      /**
      * HTML special characters substitution with replacing space for '&nbsp;'.       * HTML special characters substitution with replacing space for '&nbsp;'.
      *       *
Line 618  class Platon
Line 711  class Platon
      */       */
     static function htmlspecialchars2($str) /* {{{ */      static function htmlspecialchars2($str) /* {{{ */
     {      {
         return str_replace(' ', '&nbsp;', htmlspecialchars($str));          return str_replace(' ', '&nbsp;', Platon::htmlspecialchars($str));
     } /* }}} */      } /* }}} */
   
     /*      /*
Line 817  class Platon
Line 910  class Platon
         $accepted    = preg_split('/,[[:space:]]*/', $accept_lang);          $accepted    = preg_split('/,[[:space:]]*/', $accept_lang);
         $candidates  = array();          $candidates  = array();
         for ($i = 0; $i < count($accepted); $i++) {          for ($i = 0; $i < count($accepted); $i++) {
             if (preg_match('/^([a-z0-9_-]+);[[:space:]]*q=([0-9\.]+)/', $accepted[$i], $arr)) {              if (preg_match('/^([a-z0-9_-]+);[[:space:]]*q=([0-9\.]+)/i', $accepted[$i], $arr)) {
                 $q = (double)$arr[2];                  $q = (double)$arr[2];
                 $l = $arr[1];                  $l = $arr[1];
             } else {              } else {

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