diff options
author | rvelices <rv-github@modusoptimus.com> | 2009-02-05 03:04:27 +0000 |
---|---|---|
committer | rvelices <rv-github@modusoptimus.com> | 2009-02-05 03:04:27 +0000 |
commit | b019ad9b5556b96342aa4c271143219261432229 (patch) | |
tree | 7c917eca8d78af02fa915909efa8fec0039b7aee | |
parent | a44e905d0ba68c995ebe066792b9b348c45599cc (diff) |
merge r 3126 from trunk
- embellish_url compacts now ..
- some trigger improvements (render_category_description)
- improved perf of duplicate_xxx_url ( rewrote func params_for_duplication and remove some vars from $page )
git-svn-id: http://piwigo.org/svn/branches/2.0@3127 68402e56-0260-453c-a942-63ccdbb3a9ee
-rw-r--r-- | include/category_default.inc.php | 5 | ||||
-rw-r--r-- | include/common.inc.php | 5 | ||||
-rw-r--r-- | include/functions_html.inc.php | 39 | ||||
-rw-r--r-- | include/functions_url.inc.php | 31 | ||||
-rw-r--r-- | include/functions_user.inc.php | 24 |
5 files changed, 48 insertions, 56 deletions
diff --git a/include/category_default.inc.php b/include/category_default.inc.php index 804f2a5fa..c83d5cd00 100644 --- a/include/category_default.inc.php +++ b/include/category_default.inc.php @@ -27,8 +27,6 @@ * */ -$page['rank_of'] = array_flip($page['items']); - $pictures = array(); $selection = array_slice( @@ -39,6 +37,8 @@ $selection = array_slice( if (count($selection) > 0) { + $rank_of = array_flip($page['items']); + $query = ' SELECT * FROM '.IMAGES_TABLE.' @@ -53,6 +53,7 @@ SELECT * } usort($pictures, 'rank_compare'); + unset($rank_of); } if (count($pictures) > 0) diff --git a/include/common.inc.php b/include/common.inc.php index e08e74afa..db50f31f2 100644 --- a/include/common.inc.php +++ b/include/common.inc.php @@ -233,7 +233,10 @@ if (isset($conf['header_notes'])) // default event handlers add_event_handler('render_category_literal_description', 'render_category_literal_description'); -add_event_handler('render_category_description', 'render_category_description'); +if ( !$conf['allow_html_descriptions'] ) +{ + add_event_handler('render_category_description', 'nl2br'); +} add_event_handler('render_comment_content', 'htmlspecialchars'); add_event_handler('render_comment_content', 'parse_comment_content'); add_event_handler('render_comment_author', 'strip_tags'); diff --git a/include/functions_html.inc.php b/include/functions_html.inc.php index f5d1f9dea..462bfe222 100644 --- a/include/functions_html.inc.php +++ b/include/functions_html.inc.php @@ -23,32 +23,32 @@ function get_icon($date, $is_child_date = false) { - global $page, $user; + global $cache, $user; if (empty($date)) { return ''; } - if (isset($page['get_icon_cache'][$date])) + if (isset($cache['get_icon'][$date])) { - if (! $page['get_icon_cache'][$date] ) + if (! $cache['get_icon'][$date] ) return ''; - return $page['get_icon_cache']['_icons_'][$is_child_date]; + return $cache['get_icon']['_icons_'][$is_child_date]; } - if (!isset($page['get_icon_cache']['sql_recent_date'])) + if (!isset($cache['get_icon']['sql_recent_date'])) { // Use MySql date in order to standardize all recent "actions/queries" - list($page['get_icon_cache']['sql_recent_date']) = + list($cache['get_icon']['sql_recent_date']) = mysql_fetch_array(pwg_query('select SUBDATE( CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY)')); } - $page['get_icon_cache'][$date] = false; - if ( $date > $page['get_icon_cache']['sql_recent_date'] ) + $cache['get_icon'][$date] = false; + if ( $date > $cache['get_icon']['sql_recent_date'] ) { - if ( !isset($page['get_icon_cache']['_icons_'] ) ) + if ( !isset($cache['get_icon']['_icons_'] ) ) { $icons = array(false => 'recent', true => 'recent_by_child' ); $title = sprintf( @@ -62,15 +62,15 @@ function get_icon($date, $is_child_date = false) $icon_url = get_root_url().$icon_url; $output = '<img title="'.$title.'" src="'.$icon_url.'" class="icon" style="border:0;'; $output.= 'height:'.$size[1].'px;width:'.$size[0].'px" alt="(!)" />'; - $page['get_icon_cache']['_icons_'][$key] = $output; + $cache['get_icon']['_icons_'][$key] = $output; } } - $page['get_icon_cache'][$date] = true; + $cache['get_icon'][$date] = true; } - if (! $page['get_icon_cache'][$date] ) + if (! $cache['get_icon'][$date] ) return ''; - return $page['get_icon_cache']['_icons_'][$is_child_date]; + return $cache['get_icon']['_icons_'][$is_child_date]; } function create_navigation_bar( @@ -776,19 +776,6 @@ function set_status_header($code, $text='') trigger_action('set_status_header', $code, $text); } -/** returns the category comment for rendering in html. - * this is an event handler. don't call directly - */ -function render_category_description($desc) -{ - global $conf; - if ( !$conf['allow_html_descriptions'] ) - { - $desc = nl2br($desc); - } - return $desc; -} - /** returns the category comment for rendering in html textual mode (subcatify) * this is an event handler. don't call directly */ diff --git a/include/functions_url.inc.php b/include/functions_url.inc.php index d06221edc..49e3fa429 100644 --- a/include/functions_url.inc.php +++ b/include/functions_url.inc.php @@ -38,7 +38,7 @@ function get_root_url() {// TODO - add HERE the possibility to call PWG functions from external scripts $root_url = PHPWG_ROOT_PATH; } - if ( dirname($root_url)!='.' ) + if ( strncmp($root_url, './', 2) != 0 ) { return $root_url; } @@ -170,21 +170,11 @@ function params_for_duplication($redefined, $removed) { global $page; - if (count($removed) > 0) - { - $params = array(); + $params = $page; - foreach ($page as $page_item_key => $page_item_value) - { - if (!in_array($page_item_key, $removed)) - { - $params[$page_item_key] = $page_item_value; - } - } - } - else + foreach ($removed as $param_key) { - $params = $page; + unset($params[$param_key]); } foreach ($redefined as $redefined_param => $redefined_value) @@ -722,7 +712,18 @@ function unset_make_full_url() */ function embellish_url($url) { - return str_replace('/./', '/', $url); + $url = str_replace('/./', '/', $url); + while ( ($dotdot = strpos($url, '/../', 1) ) !== false ) + { + $before = strrpos($url, '/', -(strlen($url)-$dotdot+1) ); + if ($before !== false) + { + $url = substr_replace($url, '', $before, $dotdot-$before+3); + } + else + break; + } + return $url; } ?>
\ No newline at end of file diff --git a/include/functions_user.inc.php b/include/functions_user.inc.php index d82da2213..1b85ba44f 100644 --- a/include/functions_user.inc.php +++ b/include/functions_user.inc.php @@ -760,28 +760,28 @@ SELECT COUNT(*) */ function get_default_user_info($convert_str = true) { - global $page, $conf; + global $cache, $conf; - if (!isset($page['cache_default_user'])) + if (!isset($cache['default_user'])) { - $query = 'select * from '.USER_INFOS_TABLE. - ' where user_id = '.$conf['default_user_id'].';'; + $query = 'SELECT * FROM '.USER_INFOS_TABLE. + ' WHERE user_id = '.$conf['default_user_id'].';'; $result = pwg_query($query); - $page['cache_default_user'] = mysql_fetch_assoc($result); + $cache['default_user'] = mysql_fetch_assoc($result); - if ($page['cache_default_user'] !== false) + if ($cache['default_user'] !== false) { - unset($page['cache_default_user']['user_id']); - unset($page['cache_default_user']['status']); - unset($page['cache_default_user']['registration_date']); + unset($cache['default_user']['user_id']); + unset($cache['default_user']['status']); + unset($cache['default_user']['registration_date']); } } - if (is_array($page['cache_default_user']) and $convert_str) + if (is_array($cache['default_user']) and $convert_str) { $default_user = array(); - foreach ($page['cache_default_user'] as $name => $value) + foreach ($cache['default_user'] as $name => $value) { // If the field is true or false, the variable is transformed into a // boolean value. @@ -798,7 +798,7 @@ function get_default_user_info($convert_str = true) } else { - return $page['cache_default_user']; + return $cache['default_user']; } } |