Changeset 2772


Ignore:
Timestamp:
Oct 18, 2008, 3:07:13 AM (16 years ago)
Author:
rvelices
Message:
  • php optims (small): remove/replace preg_xxx with faster simple string functions ...
Location:
branches/2.0/include
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/2.0/include/functions_html.inc.php

    r2748 r2772  
    8282  $pages_around = $conf['paginate_pages_around'];
    8383  $start_str = $clean_url ? '/start-' :
    84     ( ( strstr($url, '?')===false ? '?':'&') . 'start=' );
     84    ( ( strpos($url, '?')===false ? '?':'&') . 'start=' );
    8585
    8686  $navbar = '';
     
    782782{
    783783  global $conf;
    784   if ( !( $conf['allow_html_descriptions'] and
    785           preg_match('/<(div|br|img|script).*>/i', $desc) ) )
     784  if ( !$conf['allow_html_descriptions'] )
    786785  {
    787786    $desc = nl2br($desc);
  • branches/2.0/include/functions_url.inc.php

    r2502 r2772  
    100100      {
    101101        $is_first = false;
    102         $url .= ( strstr($url, '?')===false ) ? '?' :'&amp;';
     102        $url .= ( strpos($url, '?')===false ) ? '?' :'&amp;';
    103103      }
    104104      else
     
    246246      {
    247247        $fname_wo_ext = get_filename_wo_extension($params['image_file']);
    248         if (! preg_match('/^\d+(-|$)/', $fname_wo_ext) )
     248        if ( ord($fname_wo_ext)>ord('9') or !preg_match('/^\d+(-|$)/', $fname_wo_ext) )
    249249        {
    250250          $url .= $fname_wo_ext;
     
    441441{
    442442  $page=array();
    443   if (0 === strpos(@$tokens[$next_token], 'categor'))
     443  if (strncmp(@$tokens[$next_token], 'categor', 7)==0 )
    444444  {
    445445    $page['section'] = 'categories';
     
    506506    }
    507507  }
    508   else if (0 === strpos(@$tokens[$next_token], 'tag'))
     508  elseif ( 'tags' == @$tokens[$next_token] )
    509509  {
    510510    $page['section'] = 'tags';
     
    519519    while (isset($tokens[$i]))
    520520    {
    521       if ( preg_match('/^(created-|posted-|start-(\d)+)/', $tokens[$i]) )
     521      if (strpos($tokens[$i], 'created-')===0
     522           or strpos($tokens[$i], 'posted-')===0
     523           or strpos($tokens[$i], 'start-')===0 )
    522524        break;
    523525
     
    545547    }
    546548  }
    547   else if (0 === strpos(@$tokens[$next_token], 'fav'))
     549  elseif ( 'favorites' == @$tokens[$next_token] )
    548550  {
    549551    $page['section'] = 'favorites';
    550552    $next_token++;
    551553  }
    552   else if ('most_visited' == @$tokens[$next_token])
     554  elseif ('most_visited' == @$tokens[$next_token])
    553555  {
    554556    $page['section'] = 'most_visited';
    555557    $next_token++;
    556558  }
    557   else if ('best_rated' == @$tokens[$next_token])
     559  elseif ('best_rated' == @$tokens[$next_token])
    558560  {
    559561    $page['section'] = 'best_rated';
    560562    $next_token++;
    561563  }
    562   else if ('recent_pics' == @$tokens[$next_token])
     564  elseif ('recent_pics' == @$tokens[$next_token])
    563565  {
    564566    $page['section'] = 'recent_pics';
    565567    $next_token++;
    566568  }
    567   else if ('recent_cats' == @$tokens[$next_token])
     569  elseif ('recent_cats' == @$tokens[$next_token])
    568570  {
    569571    $page['section'] = 'recent_cats';
    570572    $next_token++;
    571573  }
    572   else if ('search' == @$tokens[$next_token])
     574  elseif ('search' == @$tokens[$next_token])
    573575  {
    574576    $page['section'] = 'search';
     
    583585    $next_token++;
    584586  }
    585   else if ('list' == @$tokens[$next_token])
     587  elseif ('list' == @$tokens[$next_token])
    586588  {
    587589    $page['section'] = 'list';
     
    622624  while (isset($tokens[$i]))
    623625  {
    624     if (preg_match('/^start-(\d+)/', $tokens[$i], $matches))
    625     {
    626       $page['start'] = $matches[1];
    627     }
    628 
    629626    if ( 'flat' == $tokens[$i] )
    630627    {
     
    632629      $page['flat'] = true;
    633630    }
    634 
    635     if (preg_match('/^(posted|created)/', $tokens[$i] ))
     631    elseif (strpos($tokens[$i], 'created-')===0 or strpos($tokens[$i], 'posted-')===0)
    636632    {
    637633      $chronology_tokens = explode('-', $tokens[$i] );
     
    654650      }
    655651    }
     652    elseif (preg_match('/^start-(\d+)/', $tokens[$i], $matches))
     653    {
     654      $page['start'] = $matches[1];
     655    }
    656656    $i++;
    657657  }
  • branches/2.0/include/section_init.inc.php

    r2517 r2772  
    6666
    6767// deleting first "/" if displayed
    68 $tokens = explode(
    69   '/',
    70   preg_replace('#^/#', '', $rewritten)
    71   );
     68$tokens = explode('/', ltrim($rewritten, '/') );
    7269// $tokens = array(
    7370//   0 => category,
     
    184181{
    185182  $image_order_id = pwg_get_session_var('image_order');
    186  
     183
    187184  $orders = get_category_preferred_image_orders();
    188185
     
    340337    }
    341338
    342     $title = get_tags_content_title();
    343 
    344     $page = array_merge(
    345       $page,
    346       array(
    347         'title' => $title,
     339    $page = array_merge(
     340      $page,
     341      array(
     342        'title' => get_tags_content_title(),
    348343        'items' => $items,
    349344        )
Note: See TracChangeset for help on using the changeset viewer.