--- a/includes/clientside/jsres.php Wed Dec 24 10:04:48 2008 -0500
+++ b/includes/clientside/jsres.php Wed Dec 31 08:40:38 2008 -0500
@@ -255,7 +255,7 @@
}
// generate expires header
-$expires = date('r', mktime(-1, -1, -1, -1, -1, intval(date('y'))+1));
+$expires = date('r', mktime(0, 0, 0, intval(date('m')), intval(date('d')), intval(date('y'))+1));
$everything = str_replace('/* JavaScriptCompressor 0.8 [www.devpro.it], thanks to Dean Edwards for idea [dean.edwards.name] */' . "\r\n", '', $everything);
@@ -270,6 +270,7 @@
header("Last-Modified: $date");
header("ETag: \"$etag\"");
header("Expires: $expires");
+header("Content-Length: " . strlen($everything));
$local_end = microtime_float();
$local_gentime = $local_end - $local_start;
--- a/includes/dbal.php Wed Dec 24 10:04:48 2008 -0500
+++ b/includes/dbal.php Wed Dec 31 08:40:38 2008 -0500
@@ -132,8 +132,6 @@
function connect($manual_credentials = false, $dbhost = false, $dbuser = false, $dbpasswd = false, $dbname = false)
{
- $this->enable_errorhandler();
-
if ( !defined('ENANO_SQL_CONSTANTS') )
{
define('ENANO_SQL_CONSTANTS', '');
@@ -220,15 +218,11 @@
}
// We're in!
- $this->disable_errorhandler();
return true;
}
function sql_query($q, $log_query = true)
{
- if ( $log_query || defined('ENANO_DEBUG') )
- $this->enable_errorhandler();
-
if ( $this->debug && function_exists('debug_backtrace') )
{
$backtrace = @debug_backtrace();
@@ -279,15 +273,11 @@
$this->latest_result = $r;
- if ( $log_query )
- $this->disable_errorhandler();
return $r;
}
function sql_unbuffered_query($q, $log_query = true)
{
- $this->enable_errorhandler();
-
$this->num_queries++;
if ( $log_query || defined('ENANO_DEBUG') )
$this->query_backtrace[] = '(UNBUFFERED) ' . $q;
@@ -309,7 +299,6 @@
$r = @mysql_unbuffered_query($q, $this->_conn);
$this->query_times[$q] = microtime_float() - $time_start;
$this->latest_result = $r;
- $this->disable_errorhandler();
return $r;
}
@@ -366,22 +355,18 @@
function sql_data_seek($pos, $result = false)
{
- $this->enable_errorhandler();
if(!$result)
$result = $this->latest_result;
if(!$result)
{
- $this->disable_errorhandler();
return false;
}
if(mysql_data_seek($result, $pos))
{
- $this->disable_errorhandler();
return true;
}
else
{
- $this->disable_errorhandler();
return false;
}
}
@@ -415,53 +400,42 @@
}
function fetchrow($r = false) {
- $this->enable_errorhandler();
if(!$this->_conn) return false;
if(!$r) $r = $this->latest_result;
if(!$r) $this->_die('$db->fetchrow(): an invalid MySQL resource was passed.');
$row = mysql_fetch_assoc($r);
- $this->disable_errorhandler();
return integerize_array($row);
}
function fetchrow_num($r = false) {
- $this->enable_errorhandler();
if(!$r) $r = $this->latest_result;
if(!$r) $this->_die('$db->fetchrow(): an invalid MySQL resource was passed.');
$row = mysql_fetch_row($r);
- $this->disable_errorhandler();
return integerize_array($row);
}
function numrows($r = false) {
- $this->enable_errorhandler();
if(!$r) $r = $this->latest_result;
if(!$r) $this->_die('$db->fetchrow(): an invalid MySQL resource was passed.');
$n = mysql_num_rows($r);
- $this->disable_errorhandler();
return $n;
}
function escape($str)
{
- $this->enable_errorhandler();
$str = mysql_real_escape_string($str);
- $this->disable_errorhandler();
return $str;
}
function free_result($result = false)
{
- $this->enable_errorhandler();
if(!$result)
$result = $this->latest_result;
if(!$result)
{
- $this->disable_errorhandler();
return null;
}
@mysql_free_result($result);
- $this->disable_errorhandler();
return null;
}
@@ -798,28 +772,6 @@
var $rowset = array();
var $errhandler;
- function enable_errorhandler()
- {
- // echo "DBAL: enabling error handler<br />";
- if ( function_exists('debug_backtrace') )
- {
- $this->errhandler = set_error_handler('db_error_handler');
- }
- }
-
- function disable_errorhandler()
- {
- // echo "DBAL: disabling error handler<br />";
- if ( $this->errhandler )
- {
- set_error_handler($this->errhandler);
- }
- else
- {
- restore_error_handler();
- }
- }
-
function sql_backtrace()
{
return implode("\n-------------------------------------------------------------------\n", $this->query_backtrace);
@@ -881,8 +833,6 @@
function connect($manual_credentials = false, $dbhost = false, $dbuser = false, $dbpasswd = false, $dbname = false)
{
- $this->enable_errorhandler();
-
if ( !defined('ENANO_SQL_CONSTANTS') )
{
define('ENANO_SQL_CONSTANTS', '');
@@ -954,14 +904,11 @@
$this->debug = ( defined('ENANO_DEBUG') );
// We're in!
- $this->disable_errorhandler();
return true;
}
function sql_query($q)
{
- $this->enable_errorhandler();
-
if ( $this->debug && function_exists('debug_backtrace') )
{
$backtrace = @debug_backtrace();
@@ -999,7 +946,6 @@
$r = pg_query($q);
$this->query_times[$q] = microtime_float() - $time_start;
$this->latest_result = $r;
- $this->disable_errorhandler();
return $r;
}
@@ -1061,22 +1007,18 @@
function sql_data_seek($pos, $result = false)
{
- $this->enable_errorhandler();
if(!$result)
$result = $this->latest_result;
if(!$result)
{
- $this->disable_errorhandler();
return false;
}
if(pg_result_seek($result, $pos))
{
- $this->disable_errorhandler();
return true;
}
else
{
- $this->disable_errorhandler();
return false;
}
}
@@ -1159,53 +1101,42 @@
}
function fetchrow($r = false) {
- $this->enable_errorhandler();
if(!$this->_conn) return false;
if(!$r) $r = $this->latest_result;
if(!$r) $this->_die('$db->fetchrow(): an invalid MySQL resource was passed.');
$row = pg_fetch_assoc($r);
- $this->disable_errorhandler();
return integerize_array($row);
}
function fetchrow_num($r = false) {
- $this->enable_errorhandler();
if(!$r) $r = $this->latest_result;
if(!$r) $this->_die('$db->fetchrow(): an invalid MySQL resource was passed.');
$row = pg_fetch_row($r);
- $this->disable_errorhandler();
return integerize_array($row);
}
function numrows($r = false) {
- $this->enable_errorhandler();
if(!$r) $r = $this->latest_result;
if(!$r) $this->_die('$db->fetchrow(): an invalid MySQL resource was passed.');
$n = pg_num_rows($r);
- $this->disable_errorhandler();
return $n;
}
function escape($str)
{
- $this->enable_errorhandler();
$str = pg_escape_string($str);
- $this->disable_errorhandler();
return $str;
}
function free_result($result = false)
{
- $this->enable_errorhandler();
if(!$result)
$result = $this->latest_result;
if(!$result)
{
- $this->disable_errorhandler();
return null;
}
@pg_free_result($result);
- $this->disable_errorhandler();
return null;
}
--- a/includes/functions.php Wed Dec 24 10:04:48 2008 -0500
+++ b/includes/functions.php Wed Dec 31 08:40:38 2008 -0500
@@ -3254,6 +3254,70 @@
pack("VV", crc32($data), strlen($data)));
}
+$php_errors = array();
+
+/**
+ * Enano's PHP error handler.
+ * handler ( int $errno , string $errstr [, string $errfile [, int $errline [, array $errcontext ]]] )
+ * @access private
+ */
+
+function enano_handle_error($errno, $errstr, $errfile, $errline)
+{
+ global $db, $session, $paths, $template, $plugins; // Common objects
+
+ $er = error_reporting();
+ if ( ! $er & $errno || $er == 0 )
+ {
+ return true;
+ }
+ global $do_gzip, $php_errors;
+
+ if ( defined('ENANO_DEBUG') )
+ {
+ // turn off gzip and echo out error immediately for debug installs
+ $do_gzip = false;
+ }
+
+ $error_type = 'error';
+ if ( in_array($errno, array(E_WARNING, E_USER_WARNING)) )
+ $error_type = 'warning';
+ else if ( in_array($errno, array(E_NOTICE, E_USER_NOTICE)) )
+ $error_type = 'notice';
+
+ if ( @is_object(@$plugins) )
+ {
+ $code = $plugins->setHook('php_error');
+ foreach ( $code as $cmd )
+ {
+ eval($cmd);
+ }
+ }
+
+ // bypass errors in date() and mktime() (Enano has its own code for this anyway)
+ if ( strstr($errstr, "It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier.") )
+ {
+ return true;
+ }
+
+ if ( $do_gzip )
+ {
+ $php_errors[] = array(
+ 'num' => $errno,
+ 'type' => $error_type,
+ 'error' => $errstr,
+ 'file' => $errfile,
+ 'line' => $errline
+ );
+ }
+ else
+ {
+ echo "[ <b>PHP $error_type:</b> $errstr in <b>$errfile</b>:<b>$errline</b> ]<br />";
+ }
+}
+
+set_error_handler('enano_handle_error');
+
/**
* Gzips the output buffer.
*/
@@ -3271,6 +3335,17 @@
$gzip_contents = ob_get_contents();
ob_end_clean();
+ global $php_errors;
+ if ( !empty($php_errors) )
+ {
+ $errors = '';
+ foreach ( $php_errors as $error )
+ {
+ $errors .= "[ <b>PHP {$error['type']}:</b> {$error['error']} in <b>{$error['file']}</b>:<b>{$error['line']}</b> ]<br />";
+ }
+ $gzip_contents = str_replace("</body>", "$errors</body>", $gzip_contents);
+ }
+
$return = @enano_gzencode($gzip_contents);
if ( $return )
{
--- a/includes/js-compressor.php Wed Dec 24 10:04:48 2008 -0500
+++ b/includes/js-compressor.php Wed Dec 31 08:40:38 2008 -0500
@@ -270,7 +270,7 @@
array_push($this->__sources, array('code'=>$code, 'name'=>$name));
}
function __wordsParser($str, &$d) {
- if(is_null($key = array_shift($key = array_keys($d,$str))))
+ if(@is_null($key = array_shift($key = array_keys($d,$str))))
$key = array_push($d, $str) - 1;
return $key;
}
--- a/includes/render.php Wed Dec 24 10:04:48 2008 -0500
+++ b/includes/render.php Wed Dec 31 08:40:38 2008 -0500
@@ -286,7 +286,7 @@
$text = preg_replace('/<nodisplay>(.*?)<\/nodisplay>/is', '', $text);
}
- preg_match_all('/<lang code="([a-z0-9_-]+)">([\w\W]+?)<\/lang>/', $text, $langmatch);
+ preg_match_all('/<lang (?:code|id)="([a-z0-9_-]+)">([\w\W]+?)<\/lang>/', $text, $langmatch);
foreach ( $langmatch[0] as $i => $match )
{
if ( $langmatch[1][$i] == $lang->lang_code )
@@ -316,6 +316,12 @@
$text = RenderMan::include_templates($text);
}
+ $code = $plugins->setHook('render_wikiformat_posttemplates');
+ foreach ( $code as $cmd )
+ {
+ eval($cmd);
+ }
+
if ( !$plaintext )
{
// Process images
--- a/includes/template.php Wed Dec 24 10:04:48 2008 -0500
+++ b/includes/template.php Wed Dec 31 08:40:38 2008 -0500
@@ -1376,7 +1376,7 @@
$t = str_replace('[[EnanoPoweredLink]]', $lang->get('page_enano_powered', array('about_uri' => $this->tpl_strings['URL_ABOUT_ENANO'])), $t);
$t = str_replace('[[EnanoPoweredLinkLong]]', $lang->get('page_enano_powered_long', array('about_uri' => $this->tpl_strings['URL_ABOUT_ENANO'])), $t);
- if ( defined('ENANO_DEBUG') )
+ if ( defined('ENANO_PROFILE') )
{
$t = str_replace('</body>', '<div id="profile" style="margin: 10px;">' . profiler_make_html() . '</div></body>', $t);
// ob_end_clean();
@@ -2983,8 +2983,10 @@
$t = str_replace('[[NumQueriesLoc]]', $q_loc, $t);
$t = str_replace('[[GenTimeLoc]]', $t_loc, $t);
- if ( defined('ENANO_DEBUG') )
+ if ( defined('ENANO_PROFILE') )
+ {
$t = str_replace('</body>', '<div id="profile" style="margin: 10px;">' . profiler_make_html() . '</div></body>', $t);
+ }
echo $t;
}
--- a/index.php Wed Dec 24 10:04:48 2008 -0500
+++ b/index.php Wed Dec 31 08:40:38 2008 -0500
@@ -13,7 +13,6 @@
*
* @package Enano
* @subpackage Frontend
- *
*/
define('ENANO_INTERFACE_INDEX', '');