/** * Constructor * @param string $template [optional] : name of the template to load (without the .tpl) * @param array $info [optional default Array()] : array containing page's meta informations, title, cache, cache_version, etc... * cach_lifetime : false or 0 to disactivate caching, null for default, or int to set cache lifetime * Set cache_version if you want to separate cache into versions */ public function __construct($template = false, $info = array()) { BF::register_error_output_callback(array($this, "show_error")); // > Define runtime variables parent::__construct(); $this->compile_check = BF::gc('template_compile_check'); $this->debugging = BF::gc('template_smarty_debug'); $this->template_dir = BF::gf('tpl')->path(); $this->compile_dir = BF::gf('compiled')->path(); $this->cache_dir = BF::gf('cached')->path(); $this->addPluginsDir(BF::gf('tags')->path()); $this->content_type = BF::gc('template_default_content_type'); $this->error_reporting = BF::gc('error_reporting'); // > Caching // block for non-cachable content $this->cache_lifetime = BF::gc('template_cache_lifetime'); $this->caching = BF::gc('template_cache') ? 1 : 0; //$this->cache_version = null; // > Register template infos $this->data = array(); $this->assignByRef("_data", $this->data); // > Register common template functions and blocks. Others will be found in the tags dir $this->loadFilter('pre', 'translate'); // trim top and bottom $this->registerFilter("output", create_function('$x', 'return trim($x);')); if ($template !== false) { $this->load($template, $info); } }
public function log() { // timestamp for the error entry $dt = date("Y-m-d H:i:s (T)", BF::$time); // define an assoc array of error string // in reality the only entries we should // consider are E_WARNING, E_NOTICE, E_USER_ERROR, // E_USER_WARNING and E_USER_NOTICE $errortype = array(E_WARNING => 'Warning', E_NOTICE => 'Notice', E_USER_ERROR => 'User Error', E_USER_WARNING => 'User Warning', E_USER_NOTICE => 'User Notice', E_STRICT => 'Runtime Notice'); if (defined('E_RECOVERABLE_ERROR')) { $errortype[E_RECOVERABLE_ERROR] = 'Catchable Fatal Error'; } $this->debug_html = "<b><u>Debug Info</u></b>\n\n"; $this->debug_html .= "Date time : <b>" . $dt . "</b>\n"; $this->debug_html .= "Error num : <b>" . $this->e->getCode() . "</b>\n"; $this->debug_html .= "Error type : <b>" . (isset($errortype[$this->e->getCode()]) ? $errortype[$this->e->getCode()] : '-') . "</b>\n"; $this->debug_html .= "Error msg : <b>" . $this->e->getMessage() . "</b>\n"; $this->debug_html .= "Script name : <b>" . $this->e->getFile() . "</b>\n"; $this->debug_html .= "Script line num : <b>" . $this->e->getLine() . "</b>\n"; $this->debug_html .= "Trace : \n\t" . str_replace("\n", "\n\t", htmlentities($this->e->getTraceAsString())); $debug_xml = "<errorentry>\n"; $debug_xml .= "\t<datetime>" . $dt . "</datetime>\n"; $debug_xml .= "\t<errornum>" . $this->e->getCode() . "</errornum>\n"; $debug_xml .= "\t<errortype>" . (isset($errortype[$this->e->getCode()]) ? $errortype[$this->e->getCode()] : '-') . "</errortype>\n"; $debug_xml .= "\t<errormsg>" . $this->e->getMessage() . "</errormsg>\n"; $debug_xml .= "\t<scriptname>" . $this->e->getFile() . "</scriptname>\n"; $debug_xml .= "\t<scriptlinenum>" . $this->e->getLine() . "</scriptlinenum>\n"; $debug_xml .= "\t<trace><entry>" . implode('</entry><entry>', explode("\n", $this->e->getTraceAsString())) . "</entry></trace>\n"; $debug_xml .= "</errorentry>\n\n"; // send error mail try { if (BF::gc('error_send_mail')) { if (!BF::gc('error_email') || !@mail(BF::gc('error_email'), 'Critical error on ' . $_SERVER['HTTP_HOST'], $debug_xml, 'From: Error Handler')) { // if failed sending mail, add a notice to the log $this->debug_html .= "\nFailed sending error mail to " . BF::gc('error_email'); $debug_xml .= "<errorentry>\n"; $debug_xml .= "\t<datetime>" . $dt . "</datetime>\n"; $debug_xml .= "\t<errormsg>Failed sending error mail to " . BF::gc('error_email') . "</errormsg>\n"; $debug_xml .= "</errorentry>\n\n"; } } } catch (exception $new_e) { } // log error if (BF::gc('error_log')) { @error_log($this->debug_xml, 3, BF::gf('log')->path() . 'errorlog.txt'); } }
/** * Constructor : parse a RID */ public function __construct($rid, $default_folder_id = "") { if (strpos($rid, "://")) { $this->type = self::URL; $this->sub = $rid; } else { $this->type = self::RID; if (strpos('/' . $rid . '/', '/../') !== false) { throw new exception("For security concern, Ressource ID should not contain link to parent folder (../). RID : '" . $path . "' is not valid"); } if ($rid[0] == "/") { if (strpos($rid, "/", 1) === false) { $rid .= '/'; } $folderID = substr($rid, 1, strpos($rid, "/", 1) - 1); $this->sub = substr($rid, strpos($rid, "/", 1) + 1); } else { $folderID = $default_folder_id; $this->sub = $rid; } $this->folder = BF::gf($folderID); } }