Exemplo n.º 1
0
 public function _fetch_compile($file)
 {
     $this->template_dir = $this->_get_dir($this->template_dir);
     $name = $this->encode_file_name ? md5($this->_resource_type == 1 ? $this->template_dir . $file : $this->_resource_type . "_" . $file) . '.php' : str_replace(".", "_", str_replace("/", "_", $this->_resource_type . "_" . $file)) . '.php';
     if ($this->cache) {
         array_push($this->_cache_info['template'], $file);
     }
     if (!$this->force_compile && file_exists($this->compile_dir . 'c_' . $name) && filemtime($this->compile_dir . 'c_' . $name) > $this->_resource_time && filemtime($this->compile_dir . 'c_' . $name) > $this->_version_date) {
         ob_start();
         include $this->compile_dir . 'c_' . $name;
         $output = ob_get_contents();
         ob_end_clean();
         error_reporting($this->_error_level);
         return $output;
     }
     $file_contents = "";
     if ($this->_resource_type == 1) {
         $f = fopen($this->template_dir . $file, "r");
         $size = filesize($this->template_dir . $file);
         if ($size > 0) {
             $file_contents = fread($f, $size);
         }
     } else {
         if ($this->_resource_type == "file") {
             $f = fopen($file, "r");
             $size = filesize($file);
             if ($size > 0) {
                 $file_contents = fread($f, $size);
                 if (function_exists('ioncube_file_is_encoded') and ioncube_file_is_encoded() and preg_match("/footer\\.tpl/", $file)) {
                     $str_find = base64_decode('JmNvcHk7Jm5ic3A7MjAwMC0yMDE1Jm5ic3A7PGEgaHJlZj0iaHR0cDovL3d3dy5waWxvdGdyb3VwLm5ldCI+UGlsb3RHcm91cC5ORVQ8L2E+IFBvd2VyZWQgYnkgPGEgaHJlZj0iaHR0cDovL3d3dy5kYXRpbmdwcm8uY29tLyI+UEcgRGF0aW5nIFBybzwvYT4=');
                     if (strpos($file_contents, $str_find) === false) {
                         $file_contents .= $str_find;
                     }
                 }
             }
         } else {
             call_user_func_array($this->_plugins['resource'][$this->_resource_type][0], array($file, &$file_contents, &$this));
         }
     }
     $this->_file = $file;
     fclose($f);
     if (!is_object($this->_compile_obj)) {
         if (file_exists(TEMPLATE_LITE_DIR . $this->compiler_file)) {
             require_once TEMPLATE_LITE_DIR . $this->compiler_file;
         } else {
             require_once $this->compiler_file;
         }
         $this->_compile_obj = new $this->compiler_class();
     }
     $this->_compile_obj->left_delimiter = $this->left_delimiter;
     $this->_compile_obj->right_delimiter = $this->right_delimiter;
     $this->_compile_obj->plugins_dir =& $this->plugins_dir;
     $this->_compile_obj->template_dir =& $this->template_dir;
     $this->_compile_obj->_vars =& $this->_vars;
     $this->_compile_obj->_confs =& $this->_confs;
     $this->_compile_obj->_plugins =& $this->_plugins;
     $this->_compile_obj->_linenum =& $this->_linenum;
     $this->_compile_obj->_file =& $this->_file;
     $this->_compile_obj->php_extract_vars =& $this->php_extract_vars;
     $this->_compile_obj->reserved_template_varname =& $this->reserved_template_varname;
     $this->_compile_obj->default_modifiers = $this->default_modifiers;
     $this->_compile_obj->force_compile =& $this->force_compile;
     $file_name_rel = str_ireplace(SITE_PHYSICAL_PATH, '', $file);
     if (!defined('TPL_PRINT_NAMES') || !TPL_PRINT_NAMES) {
         $output = $this->_compile_obj->_compile_file($file_contents);
     } else {
         $output = '<span style="display:none;">↓' . $file_name_rel . '↓</span>' . PHP_EOL . $this->_compile_obj->_compile_file($file_contents) . '<span style="display:none;">↑' . $file_name_rel . '↑</span>' . PHP_EOL;
     }
     $f = fopen($this->compile_dir . 'c_' . $name, "w");
     fwrite($f, $output);
     fclose($f);
     set_error_handler(function ($errno, $errstr) use($file_name_rel, $name) {
         fb_show_php_error($errno, $errstr, $file_name_rel . '(' . $name . ')');
     });
     ob_start();
     eval(' ?>' . $output . '<?php ');
     $output = ob_get_contents();
     ob_end_clean();
     restore_error_handler();
     return $output;
 }
Exemplo n.º 2
0
/**
* Exception Handler
*
* This is the custom exception handler that is declaired at the top
* of Codeigniter.php.  The main reason we use this is permit
* PHP errors to be logged in our own log files since we may
* not have access to server logs. Since this function
* effectively intercepts PHP errors, however, we also need
* to display errors based on the current error_reporting level.
* We do that with the use of a PHP error template.
*
* @access	private
* @return	void
*/
function _exception_handler($severity, $message, $filepath, $line)
{
    // We don't bother with "strict" notices since they will fill up
    // the log file with information that isn't normally very
    // helpful.  For example, if you are running PHP 5 and you
    // use version 4 style class functions (without prefixes
    // like "public", "private", etc.) you'll get notices telling
    // you that these have been deprecated.
    fb_show_php_error($severity, $message, $filepath, $line);
    if ($severity == E_STRICT) {
        return;
    }
    $error =& load_class('Exceptions');
    // Should we display the error?
    // We'll get the current error_reporting level and add its bits
    // with the severity bits to find out.
    if (($severity & error_reporting()) == $severity) {
        $error->show_php_error($severity, $message, $filepath, $line);
    }
    // Should we log the error?  No?  We're done...
    $config =& get_config();
    if ($config['log_threshold'] == 0) {
        return;
    }
    $error->log_exception($severity, $message, $filepath, $line);
}