includes/lang.php
changeset 590 03a60844c7c5
parent 555 ac4c6a7f01d8
child 593 4f9bec0d65c1
equal deleted inserted replaced
589:88d4ed0a2898 590:03a60844c7c5
   166   
   166   
   167   function load_cache_file($file)
   167   function load_cache_file($file)
   168   {
   168   {
   169     global $db, $session, $paths, $template, $plugins; // Common objects
   169     global $db, $session, $paths, $template, $plugins; // Common objects
   170     
   170     
   171     // We're using eval() here because it makes handling scope easier.
       
   172     
       
   173     if ( !file_exists($file) )
   171     if ( !file_exists($file) )
   174       $db->_die('lang.php - requested cache file doesn\'t exist');
   172       $db->_die('lang.php - requested cache file doesn\'t exist');
   175     
   173     
   176     $contents = file_get_contents($file);
   174     @include($file);
   177     $contents = preg_replace('/([\s]*)<\?php/', '', $contents);
   175         
   178     
       
   179     @eval($contents);
       
   180     
       
   181     if ( !isset($lang_cache) || ( isset($lang_cache) && !is_array($lang_cache) ) )
   176     if ( !isset($lang_cache) || ( isset($lang_cache) && !is_array($lang_cache) ) )
   182       $db->_die('lang.php - the cache file is invalid (didn\'t set $lang_cache as an array)');
   177       $db->_die('lang.php - the cache file is invalid (didn\'t set $lang_cache as an array)');
   183     
   178     
   184     $this->merge($lang_cache);
   179     $this->merge($lang_cache);
   185   }
   180   }
   574    * Calls var_export() on whatever, and returns the function's output.
   569    * Calls var_export() on whatever, and returns the function's output.
   575    * @param mixed Whatever you want var_exported. Usually an array.
   570    * @param mixed Whatever you want var_exported. Usually an array.
   576    * @return string
   571    * @return string
   577    */
   572    */
   578   
   573   
   579   function var_export_string($val)
   574   static function var_export_string($val)
   580   {
   575   {
   581     ob_start();
   576     ob_start();
   582     var_export($val);
   577     var_export($val);
   583     $contents = ob_get_contents();
   578     $contents = ob_get_contents();
   584     ob_end_clean();
   579     ob_end_clean();
   633       // Or if it's the installer, no use in refetching, so just fail.
   628       // Or if it's the installer, no use in refetching, so just fail.
   634       if ( defined('IN_ENANO_INSTALL') )
   629       if ( defined('IN_ENANO_INSTALL') )
   635       {
   630       {
   636         return $string_id;
   631         return $string_id;
   637       }
   632       }
       
   633       profiler_log('Language(' . $this->lang_code . '): refetching due to missing string: ' . $string_id);
   638       $this->fetch();
   634       $this->fetch();
   639       if ( isset($this->strings[$category]) && isset($this->strings[$category][$string_name]) )
   635       if ( isset($this->strings[$category]) && isset($this->strings[$category][$string_name]) )
   640       {
   636       {
   641         $found = true;
   637         $found = true;
   642         $string = $this->strings[$category][$string_name];
   638         $string = $this->strings[$category][$string_name];