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

git-svn-id: http://piwigo.org/svn/trunk@1094 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
rvelices
2006-03-23 01:49:04 +00:00
parent 4cb765e783
commit 5c7d655005
12 changed files with 159 additions and 65 deletions

View File

@@ -83,7 +83,7 @@ $tokens = explode(
// );
$next_token = 0;
if (basename($_SERVER['SCRIPT_NAME']) == 'picture.php')
if (basename($_SERVER['SCRIPT_FILENAME']) == 'picture.php')
{ // the last token must be the identifier for the picture
$token = array_pop($tokens);
if ( is_numeric($token) )
@@ -93,13 +93,14 @@ if (basename($_SERVER['SCRIPT_NAME']) == 'picture.php')
else
{
preg_match('/^(\d+-)?((.*)[_\.]html?)?$/', $token, $matches);
if ( isset($matches[1]) and is_numeric($matches[1]) )
if (isset($matches[1]) and is_numeric($matches[1]=rtrim($matches[1],'-')) )
{
$page['image_id'] = $matches[1];
if ( !empty($matches[3]) )
{
$page['image_file'] = $matches[3];
}
}
else
{
@@ -507,19 +508,26 @@ if (isset($page['chronology_field']))
initialize_calendar();
}
if (basename($_SERVER['SCRIPT_NAME']) == 'picture.php'
if (basename($_SERVER['SCRIPT_FILENAME']) == 'picture.php'
and !isset($page['image_id']) )
{
$query = '
if ( !empty($page['items']) )
{
$query = '
SELECT id,file
FROM '.IMAGES_TABLE .'
WHERE id IN ('.implode(',',$page['items']).')
AND file LIKE "' . $page['image_file'] . '.%" ESCAPE "|"'
;
$result = pwg_query($query);
if (mysql_num_rows($result)>0)
$result = pwg_query($query);
if (mysql_num_rows($result)>0)
{
list($page['image_id'], $page['image_file']) = mysql_fetch_row($result);
}
}
if ( !isset($page['image_id']) )
{
list($page['image_id'], $page['image_file']) = mysql_fetch_row($result);
$page['image_id'] = -1; // will fail in picture.php
}
}
?>