diff options
author | rvelices <rv-github@modusoptimus.com> | 2008-10-18 01:08:58 +0000 |
---|---|---|
committer | rvelices <rv-github@modusoptimus.com> | 2008-10-18 01:08:58 +0000 |
commit | 3326f742fe2a1745dc1ebdd060d023263af299b9 (patch) | |
tree | b5ec4cadf5e37a39e83e978af1bd8da9d1c2dea9 /include | |
parent | 90be9fbb84623095a360cfa6e9c1955a891eeba5 (diff) |
merge rev 2771,2772 from branch 2.0
- 2771 event tracer improvement: option to show all registered event handlers for every page
- 2772 php optims (small): remove/replace preg_xxx with faster simple string functions
git-svn-id: http://piwigo.org/svn/trunk@2773 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include')
-rw-r--r-- | include/functions_html.inc.php | 7 | ||||
-rw-r--r-- | include/functions_url.inc.php | 38 | ||||
-rw-r--r-- | include/section_init.inc.php | 11 |
3 files changed, 25 insertions, 31 deletions
diff --git a/include/functions_html.inc.php b/include/functions_html.inc.php index 0a09ab31a..cb530749a 100644 --- a/include/functions_html.inc.php +++ b/include/functions_html.inc.php @@ -81,7 +81,7 @@ function create_navigation_bar( $pages_around = $conf['paginate_pages_around']; $start_str = $clean_url ? '/start-' : - ( ( strstr($url, '?')===false ? '?':'&') . 'start=' ); + ( ( strpos($url, '?')===false ? '?':'&') . 'start=' ); $navbar = ''; @@ -781,8 +781,7 @@ function set_status_header($code, $text='') function render_category_description($desc) { global $conf; - if ( !( $conf['allow_html_descriptions'] and - preg_match('/<(div|br|img|script).*>/i', $desc) ) ) + if ( !$conf['allow_html_descriptions'] ) { $desc = nl2br($desc); } @@ -827,4 +826,4 @@ function register_default_menubar_blocks( $menu_ref_arr ) $menu->register_block( new RegisteredBlock( 'mbIdentification', 'identification', 'piwigo') ); } -?> +?>
\ No newline at end of file diff --git a/include/functions_url.inc.php b/include/functions_url.inc.php index 9921237a6..d58e94590 100644 --- a/include/functions_url.inc.php +++ b/include/functions_url.inc.php @@ -99,7 +99,7 @@ function add_url_params($url, $params) if ($is_first) { $is_first = false; - $url .= ( strstr($url, '?')===false ) ? '?' :'&'; + $url .= ( strpos($url, '?')===false ) ? '?' :'&'; } else { @@ -245,7 +245,7 @@ function make_picture_url($params) if ( isset($params['image_file']) ) { $fname_wo_ext = get_filename_wo_extension($params['image_file']); - if (! preg_match('/^\d+(-|$)/', $fname_wo_ext) ) + if ( ord($fname_wo_ext)>ord('9') or !preg_match('/^\d+(-|$)/', $fname_wo_ext) ) { $url .= $fname_wo_ext; break; @@ -440,7 +440,7 @@ function make_section_in_url($params) function parse_section_url( $tokens, &$next_token) { $page=array(); - if (0 === strpos(@$tokens[$next_token], 'categor')) + if (strncmp(@$tokens[$next_token], 'categor', 7)==0 ) { $page['section'] = 'categories'; $next_token++; @@ -505,7 +505,7 @@ function parse_section_url( $tokens, &$next_token) $page['category']=$result; } } - else if (0 === strpos(@$tokens[$next_token], 'tag')) + elseif ( 'tags' == @$tokens[$next_token] ) { $page['section'] = 'tags'; $page['tags'] = array(); @@ -518,7 +518,9 @@ function parse_section_url( $tokens, &$next_token) while (isset($tokens[$i])) { - if ( preg_match('/^(created-|posted-|start-(\d)+)/', $tokens[$i]) ) + if (strpos($tokens[$i], 'created-')===0 + or strpos($tokens[$i], 'posted-')===0 + or strpos($tokens[$i], 'start-')===0 ) break; if ( preg_match('/^(\d+)(?:-(.*))?/', $tokens[$i], $matches) ) @@ -544,32 +546,32 @@ function parse_section_url( $tokens, &$next_token) page_not_found('Requested tag does not exist', get_root_url().'tags.php' ); } } - else if (0 === strpos(@$tokens[$next_token], 'fav')) + elseif ( 'favorites' == @$tokens[$next_token] ) { $page['section'] = 'favorites'; $next_token++; } - else if ('most_visited' == @$tokens[$next_token]) + elseif ('most_visited' == @$tokens[$next_token]) { $page['section'] = 'most_visited'; $next_token++; } - else if ('best_rated' == @$tokens[$next_token]) + elseif ('best_rated' == @$tokens[$next_token]) { $page['section'] = 'best_rated'; $next_token++; } - else if ('recent_pics' == @$tokens[$next_token]) + elseif ('recent_pics' == @$tokens[$next_token]) { $page['section'] = 'recent_pics'; $next_token++; } - else if ('recent_cats' == @$tokens[$next_token]) + elseif ('recent_cats' == @$tokens[$next_token]) { $page['section'] = 'recent_cats'; $next_token++; } - else if ('search' == @$tokens[$next_token]) + elseif ('search' == @$tokens[$next_token]) { $page['section'] = 'search'; $next_token++; @@ -582,7 +584,7 @@ function parse_section_url( $tokens, &$next_token) $page['search'] = $matches[1]; $next_token++; } - else if ('list' == @$tokens[$next_token]) + elseif ('list' == @$tokens[$next_token]) { $page['section'] = 'list'; $next_token++; @@ -621,18 +623,12 @@ function parse_well_known_params_url($tokens, &$i) $page = array(); while (isset($tokens[$i])) { - if (preg_match('/^start-(\d+)/', $tokens[$i], $matches)) - { - $page['start'] = $matches[1]; - } - if ( 'flat' == $tokens[$i] ) { // indicate a special list of images $page['flat'] = true; } - - if (preg_match('/^(posted|created)/', $tokens[$i] )) + elseif (strpos($tokens[$i], 'created-')===0 or strpos($tokens[$i], 'posted-')===0) { $chronology_tokens = explode('-', $tokens[$i] ); @@ -653,6 +649,10 @@ function parse_well_known_params_url($tokens, &$i) $page['chronology_date'] = $chronology_tokens; } } + elseif (preg_match('/^start-(\d+)/', $tokens[$i], $matches)) + { + $page['start'] = $matches[1]; + } $i++; } return $page; diff --git a/include/section_init.inc.php b/include/section_init.inc.php index 97f2f0a42..0d8659113 100644 --- a/include/section_init.inc.php +++ b/include/section_init.inc.php @@ -65,10 +65,7 @@ else } // deleting first "/" if displayed -$tokens = explode( - '/', - preg_replace('#^/#', '', $rewritten) - ); +$tokens = explode('/', ltrim($rewritten, '/') ); // $tokens = array( // 0 => category, // 1 => 12-foo, @@ -183,7 +180,7 @@ if ('categories' == $page['section'] and !isset($page['flat'])) if (pwg_get_session_var('image_order',0) > 0) { $image_order_id = pwg_get_session_var('image_order'); - + $orders = get_category_preferred_image_orders(); // the current session stored image_order might be not compatible with @@ -339,12 +336,10 @@ SELECT DISTINCT image_id $items = array_from_query($query, 'image_id'); } - $title = get_tags_content_title(); - $page = array_merge( $page, array( - 'title' => $title, + 'title' => get_tags_content_title(), 'items' => $items, ) ); |