pastebin - collaborative debugging tool
kpaste.net RSS


ipb33_oct12.diff
Posted by Anonymous on Fri 26th Oct 2012 06:58
raw | new post

  1. --- ../admin/sources/base/core.php      (original)
  2. +++ ../admin/sources/base/core.php      Thu Oct 25 22:48:40 2012
  3. @@ -2,21 +2,21 @@
  4.  /**
  5.   * <pre>
  6.   * Invision Power Services
  7. - * IP.Board v3.3.2
  8. + * IP.Board v3.3.4
  9.   * Static Classes for IP.Board 3
  10.   *
  11.   * These classes are not required as objects. We have grouped
  12.   * together several singletons to prevent multiple file loads
  13. - * Last Updated: $Date: 2012-05-07 12:13:15 -0400 (Mon, 07 May 2012) $
  14. + * Last Updated: $Date: 2012-07-04 13:32:40 -0400 (Wed, 04 Jul 2012) $
  15.   * </pre>
  16.   *
  17. - * @author             $Author: ips_terabyte $
  18. + * @author             $Author: AndyMillne $
  19.   * @copyright  (c) 2001 - 2009 Invision Power Services, Inc.
  20. - * @license            http://www.invisionpower.com/community/board/license.html
  21. + * @license            http://www.invisionpower.com/company/standards.php#license
  22.   * @package            IP.Board
  23.   * @link               http://www.invisionpower.com
  24.   * @since              12th March 2002
  25. - * @version            $Revision: 10698 $
  26. + * @version            $Revision: 11032 $
  27.   *
  28.   * @author     Matt
  29.   */
  30. @@ -1117,6 +1117,36 @@
  31.         static protected $_lims                    = array();
  32.        
  33.         /**
  34. +       * mixed safe_unserialize(string $serialized)
  35. +       * Safely unserialize, that is only unserialize string, numbers and arrays, not objects
  36. +       *
  37. +       * @license Public Domain
  38. +       * @author dcz (at) phpbb-seo (dot) com
  39. +       */
  40. +       static public function safeUnserialize( $serialized )
  41. +       {
  42. +               // unserialize will return false for object declared with small cap o
  43. +               // as well as if there is any ws between O and :
  44. +               if ( is_string( $serialized ) && strpos( $serialized, "\0" ) === false )
  45. +               {
  46. +                       if ( strpos( $serialized, 'O:' ) === false )
  47. +                       {
  48. +                                // the easy case, nothing to worry about
  49. +                                // let unserialize do the job
  50. +                                return @unserialize( $serialized );
  51. +                        }
  52. +                        else if ( ! preg_match('/(^|;|{|})O:[0-9]+:"/', $serialized ) )
  53. +                        {
  54. +                                // in case we did have a string with O: in it,
  55. +                                // but it was not a true serialized object
  56. +                                return @unserialize( $serialized );
  57. +                        }
  58. +                }
  59. +
  60. +                return false;
  61. +       }
  62. +              
  63. +       /**
  64.          * Returns the class name to be instantiated, the class file will already be included
  65.          *
  66.          * @param       string  $filePath               File location of the class (leave an empty string if you've already loaded the main file)
  67. @@ -4025,31 +4055,34 @@
  68.          * @return      mixed
  69.          * @since       2.0
  70.          */
  71. -    static public function get($name)
  72. -    {
  73. +       static public function get($name)
  74. +       {
  75.                 /* Check internal data first */
  76.                 if ( isset( self::$_cookiesSet[ $name ] ) )
  77.                 {
  78.                         return self::$_cookiesSet[ $name ];
  79.                 }
  80. -       else if ( isset( $_COOKIE[ipsRegistry::$settings['cookie_id'].$name] ) )
  81. -       {
  82. +               else if ( isset( $_COOKIE[ipsRegistry::$settings['cookie_id'].$name] ) )
  83. +               {
  84.                         $_value = $_COOKIE[ ipsRegistry::$settings['cookie_id'].$name ];
  85.  
  86. -               if ( substr( $_value, 0, 2 ) == 'a:' )
  87. -               {
  88. -                               return unserialize( stripslashes( urldecode( $_value ) ) );
  89. -               }
  90. -               else
  91. -               {
  92. +                       $_couldBeSerialized = stripslashes( urldecode( $_value ) );
  93. +
  94. +                       if ( substr( $_couldBeSerialized, 0, 2 ) == 'a:' )
  95. +                       {
  96. +                               return IPSLib::safeUnserialize( $_couldBeSerialized );
  97. +                       }
  98. +                       else
  99. +                       {
  100.                                 return IPSText::parseCleanValue( urldecode( $_value ) );
  101. -               }
  102. -       }
  103. -       else
  104. -       {
  105. -               return FALSE;
  106. -       }
  107. -    }
  108. +                       }
  109. +               }
  110. +               else
  111. +               {
  112. +                       return FALSE;
  113. +               }
  114. +       }
  115. +
  116.  }
  117.  
  118.  /**
  119. @@ -4610,12 +4643,37 @@
  120.         }
  121.        
  122.         /**
  123. +        * Strips out all non UTF-8 characters from a string
  124. +        * This is best used when you have already converted / got UTF-8 data
  125. +        * @param       string  In
  126. +        * @return      string  Cleaned
  127. +        */
  128. +       public static function stripNonUtf8( $string )
  129. +       {
  130. +               $string = preg_replace('/[\x00-\x08\x10\x0B\x0C\x0E-\x19\x7F]|(?<=^|[\x00-\x7F])[\x80-\xBF]+|([\xC0\xC1]|[\xF0-\xFF])[\x80-\xBF]*'.
  131. +                                                          '|[\xC2-\xDF]((?![\x80-\xBF])|[\x80-\xBF]{2,})|[\xE0-\xEF](([\x80-\xBF](?![\x80-\xBF]))|(?![\x80-\xBF]{2})|[\x80-\xBF]{3,})/', '?', $string );
  132. +              
  133. +              
  134. +               $string = preg_replace('/\xE0[\x80-\x9F][\x80-\xBF]|\xED[\xA0-\xBF][\x80-\xBF]/S','?', $string );
  135. +              
  136. +               return $string;
  137. +       }
  138. +      
  139. +       /**
  140.          * Decodes long named HTML entities in a string &eacute; without affecting other HTML entities (&lt; etc) etc
  141.          * @param string        Raw string
  142.          * @param string        Converted string
  143.          */
  144.         public static function decodeNamedHtmlEntities( $string )
  145.         {
  146. +               /* Some manual conversions */
  147. +               $manual = array( 'Alpha' => 'A', 'Beta' => 'B', 'alpha' => 'a', 'beta' => 'b' );
  148. +              
  149. +               foreach( $manual as $o => $r )
  150. +               {
  151. +                       $string = str_replace( '&' . $o . ';', $r, $string );
  152. +               }
  153. +              
  154.                 preg_match_all( '#&([^;\s]+?);#', $string, $matches );
  155.                 $entities = array();
  156.                 $notList  = array( 'amp', 'para', 'middot', 'gt', 'lt' );
  157. @@ -4630,9 +4688,11 @@
  158.                                 }
  159.                         }
  160.                 }
  161. -              
  162. -               $translated = @explode( ' ', @html_entity_decode( @implode( ' ', $entities ), ENT_NOQUOTES, IPS_DOC_CHAR_SET ) );
  163.  
  164. +               /* -15 is the same as -1 but with Euro plus French and Finnish */
  165. +               $charSet    = ( IPS_DOC_CHAR_SET == 'ISO-8859-1' ) ? 'ISO-8859-15' : IPS_DOC_CHAR_SET;
  166. +               $translated = @explode( ' ', @html_entity_decode( @implode( ' ', $entities ), ENT_NOQUOTES, $charSet ) );
  167. +
  168.                 if ( is_array( $translated ) AND count( $translated ) AND count( $translated ) == count( $entities ) )
  169.                 {
  170.                         return str_replace( $entities, $translated, $string );
  171. @@ -5006,12 +5066,23 @@
  172.          */
  173.         static public function searchHighlight( $text, $highlight )
  174.         {
  175. -               //-----------------------------------------
  176. -               // INIT
  177. -               //-----------------------------------------
  178. -
  179. +               /* No highlight to do (1)? No point in wasting time then.. */
  180. +               if ( $highlight == '' )
  181. +               {
  182. +                       return $text;
  183. +               }
  184. +              
  185.                 $highlight  = self::parseCleanValue( urldecode( $highlight ) );
  186. +              
  187. +               /* No highlight to do (2)? No point in wasting time then.. */
  188. +               if ( $highlight == '' )
  189. +               {
  190. +                       return $text;
  191. +               }
  192. +              
  193. +               /* Init some more vars */
  194.                 $loosematch = 1;//strstr( $highlight, '*' ) ? 1 : 0;
  195. +               $isPhrase   = preg_match( '#("|&(amp;)?quot;)#', $highlight );
  196.                 $keywords   = str_replace( '*', '', str_replace( "+", " ", str_replace( "++", "+", str_replace( '-', '', trim($highlight) ) ) ) );
  197.                 $keywords       = str_replace( '&quot;', '', str_replace( '\\', '&#092;', str_replace( '&amp;quot;', '', $keywords ) ) );
  198.                 $word_array = array();
  199. @@ -5049,7 +5120,7 @@
  200.                                         $keywords   = str_replace( $match[0], '',       $keywords );
  201.                                 }
  202.                         }
  203. -                       else if ( strstr( $keywords, ' ' ) )
  204. +                       else if ( ! $isPhrase && strstr( $keywords, ' ' ) )
  205.                         {
  206.                                 $word_array = explode( ' ', str_replace( '  ', ' ', $keywords ) );
  207.                         }
  208. @@ -5757,6 +5828,7 @@
  209.         static public function UNhtmlspecialchars($t="")
  210.         {
  211.                 $t = str_replace( "&amp;" , "&", $t );
  212. +               $t = str_replace( "&#38;" , "&", $t );
  213.                 $t = str_replace( "&lt;"  , "<", $t );
  214.                 $t = str_replace( "&gt;"  , ">", $t );
  215.                 $t = str_replace( "&quot;", '"', $t );

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at