Ignore:
Timestamp:
Mar 23, 2006, 2:49:04 AM (19 years ago)
Author:
rvelices
Message:

URL rewrite: 3 options in the config file define behaviour (question mark
removal, file name for picture and .php extension removal)

fix: added unsigned for column in install sql - for the sake of uniformization

change: add_url_param is now add_url_params and takes an array as parameter
instead of a string

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/section_init.inc.php

    r1092 r1094  
    8484
    8585$next_token = 0;
    86 if (basename($_SERVER['SCRIPT_NAME']) == 'picture.php')
     86if (basename($_SERVER['SCRIPT_FILENAME']) == 'picture.php')
    8787{ // the last token must be the identifier for the picture
    8888  $token = array_pop($tokens);
     
    9494  {
    9595    preg_match('/^(\d+-)?((.*)[_\.]html?)?$/', $token, $matches);
    96     if ( isset($matches[1]) and is_numeric($matches[1]) )
     96    if (isset($matches[1]) and is_numeric($matches[1]=rtrim($matches[1],'-')) )
    9797    {
    9898      $page['image_id'] = $matches[1];
     
    101101        $page['image_file'] = $matches[3];
    102102      }
     103
    103104    }
    104105    else
     
    508509}
    509510
    510 if (basename($_SERVER['SCRIPT_NAME']) == 'picture.php'
     511if (basename($_SERVER['SCRIPT_FILENAME']) == 'picture.php'
    511512    and !isset($page['image_id']) )
    512513{
    513   $query = '
     514  if ( !empty($page['items']) )
     515  {
     516    $query = '
    514517SELECT id,file
    515518  FROM '.IMAGES_TABLE .'
     
    517520  AND file LIKE "' . $page['image_file'] . '.%" ESCAPE "|"'
    518521;
    519   $result = pwg_query($query);
    520   if (mysql_num_rows($result)>0)
    521   {
    522     list($page['image_id'], $page['image_file']) = mysql_fetch_row($result);
     522    $result = pwg_query($query);
     523    if (mysql_num_rows($result)>0)
     524    {
     525      list($page['image_id'], $page['image_file']) = mysql_fetch_row($result);
     526    }
     527  }
     528  if ( !isset($page['image_id']) )
     529  {
     530    $page['image_id'] = -1; // will fail in picture.php
    523531  }
    524532}
Note: See TracChangeset for help on using the changeset viewer.