# HG changeset patch # User Dan Fuhry # Date 1353343235 18000 # Node ID 851b91febb85357bbeda97b7c352484bf22309fe # Parent 947153b432eabe4f17d8126d22712e69dbfdebaa# Parent 68c17d935750bbbe2a869381b84ea30acf4aeb33 Merged diff -r 947153b432ea -r 851b91febb85 includes/clientside/static/enano-lib-basic.js --- a/includes/clientside/static/enano-lib-basic.js Mon Nov 19 11:39:25 2012 -0500 +++ b/includes/clientside/static/enano-lib-basic.js Mon Nov 19 11:40:35 2012 -0500 @@ -22,15 +22,13 @@ // placeholder for window.console - used if firebug isn't present // http://getfirebug.com/firebug/firebugx.js -if (!window.console || !console.firebug) -{ - var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", - "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"]; +var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", +"group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"]; - window.console = {}; - for (var i = 0; i < names.length; ++i) - window.console[names[i]] = function() {} -} +window.console || (window.console = {}); +for (var i = 0; i < names.length; ++i) + if ( typeof(window.console[names[i]]) != 'function' ) + window.console[names[i]] = function() {} console.info('Enano::JS runtime: starting system init'); diff -r 947153b432ea -r 851b91febb85 includes/functions.php --- a/includes/functions.php Mon Nov 19 11:39:25 2012 -0500 +++ b/includes/functions.php Mon Nov 19 11:40:35 2012 -0500 @@ -4268,6 +4268,7 @@ { die('SECURITY: ImageMagick path is screwy'); } + $magick_path = escapeshellcmd($magick_path); $cmdline = "$magick_path $in_file_sh -resize \"{$width}x{$height}>\" $out_file_sh"; system($cmdline, $return); if ( !file_exists($out_file) ) @@ -4291,7 +4292,7 @@ else if ( $ratio < 1 ) { // orig. height is greater than width - $new_width = round( $height / $ratio ); + $new_width = round( $height * $ratio ); $new_height = $height; } else if ( $ratio == 1 ) @@ -4313,6 +4314,13 @@ if ( !$oldimage ) throw new Exception('GD: Request to load input image file failed.'); + if ( $file_ext == 'png' || $file_ext == 'gif' ) + { + imagecolortransparent($newimage, imagecolorallocatealpha($newimage, 0, 0, 0, 127)); + imagealphablending($newimage, false); + imagesavealpha($newimage, true); + } + // Perform scaling imagecopyresampled($newimage, $oldimage, 0, 0, 0, 0, $new_width, $new_height, $width_orig, $height_orig); @@ -4870,7 +4878,7 @@ if ( function_exists('json_decode') ) { // using PHP5 with JSON support - return json_decode($data); + return json_decode($data, true); } */ diff -r 947153b432ea -r 851b91febb85 includes/render.php --- a/includes/render.php Mon Nov 19 11:39:25 2012 -0500 +++ b/includes/render.php Mon Nov 19 11:40:35 2012 -0500 @@ -45,7 +45,14 @@ $text = $page->fetch_text(); if ( !$render ) + { + $code = $plugins->setHook('render_getpage_norender'); + foreach ( $code as $cmd ) + { + eval($cmd); + } return $text; + } $text = self::render($text, $wiki, $smilies, $filter_links); return $text; @@ -54,10 +61,14 @@ public static function getTemplate($id, $parms) { global $db, $session, $paths, $template, $plugins; // Common objects + + // Verify target exists -- if not, double-bracket it to convert it to a redlink if ( !isPage($paths->get_pathskey($id, 'Template')) ) { return '[['.$paths->nslist['Template'].$id.']]'; } + + // fetch from DB or template cache if(isset($paths->template_cache[$id])) { $text = $paths->template_cache[$id]; @@ -69,6 +80,8 @@ $paths->template_cache[$id] = $text; } + // noinclude is not shown within the included template, only on the template's page when you load it + // nodisplay is not shown on the template's page, only in the included template $text = preg_replace('/(.*?)<\/noinclude>/is', '', $text); $text = preg_replace('/(.*?)<\/nodisplay>/is', '\\1', $text); @@ -91,7 +104,7 @@ return $text; } - public static function fetch_template_text($id) + public static function fetch_template_text($id, $params) { global $db, $session, $paths, $template, $plugins; // Common objects $fetch_ns = 'Template'; @@ -131,6 +144,11 @@ return '[['.$paths->nslist['Template'].$id.']]'; } } + + $template->context_push(); + + $template->assign_vars($params); + if(isset($paths->template_cache[$id])) { $text = $paths->template_cache[$id]; @@ -141,6 +159,8 @@ $paths->template_cache[$id] = $text; } + $template->context_pop(); + if ( is_string($text) ) { $text = preg_replace('/(.*?)<\/noinclude>/is', '', $text); @@ -894,7 +914,7 @@ { $parms = Array(); } - if ( $tpl_code = RenderMan::fetch_template_text($matches[1][$i]) ) + if ( $tpl_code = RenderMan::fetch_template_text($matches[1][$i], $parms) ) { // Intelligent paragraphs. // If: diff -r 947153b432ea -r 851b91febb85 includes/sessions.php --- a/includes/sessions.php Mon Nov 19 11:39:25 2012 -0500 +++ b/includes/sessions.php Mon Nov 19 11:40:35 2012 -0500 @@ -4623,7 +4623,7 @@ if ( !isset($this->acl_deps[$deps[$i]]) ) { // Action $type depends on action $deps[$i] which cannot be satisfied because $deps[$i] is out of scope. - trigger_error("acl_check_deps: $type depends on {$deps[$i]} which is not within scope of $this->namespace; this indicats a bug in ACL rule specification", E_USER_WARNING); + trigger_error("acl_check_deps: $type depends on {$deps[$i]} which is not within scope of $this->namespace; this indicates a bug in ACL rule specification", E_USER_WARNING); return false; } $deps = array_merge($deps, $this->acl_deps[$deps[$i]]); diff -r 947153b432ea -r 851b91febb85 includes/template.php --- a/includes/template.php Mon Nov 19 11:39:25 2012 -0500 +++ b/includes/template.php Mon Nov 19 11:40:35 2012 -0500 @@ -60,6 +60,13 @@ var $fading_button = ''; + /** + * Context stack. You can save and restore the var set. + * @var array + */ + + var $context_stack = array('bool' => array(), 'str' => array(), 'history' => array()); + function __construct() { global $db, $session, $paths, $template, $plugins; // Common objects @@ -119,6 +126,24 @@ } /** + * Save the current context and start a blank one. + */ + + function context_push() + { + array_push($this->context_stack['str'], $this->tpl_strings); + array_push($this->context_stack['bool'], $this->tpl_bool); + array_push($this->context_stack['history'], $this->vars_assign_history); + } + + function context_pop() + { + $this->tpl_strings = array_pop($this->context_stack['str']); + $this->tpl_bool = array_pop($this->context_stack['bool']); + $this->vars_assign_history = array_pop($this->context_stack['history']); + } + + /** * Gets the list of available CSS files (styles) for the specified theme. * @param string Theme ID * @return array @@ -1447,7 +1472,7 @@ $f = microtime_float(); $f = $f - $_starttime; - $f = round($f, 2); + $f = sprintf("%.02f", $f); $t_loc = $lang->get('page_msg_stats_gentime_short', array('time' => $f)); $t_loc_long = $lang->get('page_msg_stats_gentime_long', array('time' => $f)); diff -r 947153b432ea -r 851b91febb85 includes/wikiengine/parse_mediawiki.php --- a/includes/wikiengine/parse_mediawiki.php Mon Nov 19 11:39:25 2012 -0500 +++ b/includes/wikiengine/parse_mediawiki.php Mon Nov 19 11:40:35 2012 -0500 @@ -54,11 +54,15 @@ while ( preg_match($template_regex, $text, $match) ) { $i++; + // we can go up to 5 levels of templates deep if ( $i == 5 ) break; $text = RenderMan::include_templates($text); } + //header('Content-type: text/plain'); + //die($text); + return array(); } diff -r 947153b432ea -r 851b91febb85 plugins/SpecialPageFuncs.php --- a/plugins/SpecialPageFuncs.php Mon Nov 19 11:39:25 2012 -0500 +++ b/plugins/SpecialPageFuncs.php Mon Nov 19 11:40:35 2012 -0500 @@ -716,7 +716,15 @@ $key = "upload_progress_{$_GET['uploadstatus']}"; $info = isset($_SESSION[$key]) ? $_SESSION[$key] : array(); if ( isset($_SESSION[$key]) && $_SESSION[$key]['done'] ) + { unset($_SESSION[$key]); + } + + if ( !isset($_SESSION[$key]) ) + { + // workaround to cause stuck uploads on the client side to shut up + $info['done'] = true; + } if ( is_array($info) ) { diff -r 947153b432ea -r 851b91febb85 plugins/SpecialUpdownload.php --- a/plugins/SpecialUpdownload.php Mon Nov 19 11:39:25 2012 -0500 +++ b/plugins/SpecialUpdownload.php Mon Nov 19 11:40:35 2012 -0500 @@ -250,7 +250,7 @@ $extension = ".{$_GET['fmt']}"; $cache_filename = ENANO_ROOT . "/cache/{$filename}-{$row['time_id']}-{$width}x{$height}$extension"; - if ( file_exists($cache_filename) ) + if ( file_exists($cache_filename) && !isset($_GET['cache_override']) ) { $fname = $cache_filename; } @@ -281,7 +281,7 @@ } if ( $allow_scale ) { - $result = scale_image($orig_fname, $fname, $width, $height); + $result = scale_image($orig_fname, $fname, $width, $height, isset($_GET['cache_override'])); if ( !$result ) $fname = $orig_fname; } @@ -301,19 +301,20 @@ { header('Content-disposition: attachment, filename="' . $filename . '";'); } - if ( !@$GLOBALS['do_gzip'] ) + //if ( !@$GLOBALS['do_gzip'] ) header('Content-length: ' . $len); header('Last-Modified: '.enano_date('r', $row['time_id'])); // using this method limits RAM consumption + @ob_end_flush(); while ( !feof($handle) ) { echo fread($handle, 512000); } fclose($handle); - gzip_output(); + $db->close(); exit;