URL rewriting: capable of fully working with urls without ?

URL rewriting: works with image file instead of image id (change
make_picture_url to generate urls with file name instead of image id)

URL rewriting: completely works with category/best_rated and
picture/best_rated/534 (change 'category.php?' to 'category' in make_index_url
and 'picture.php?' to 'picture' in make_picture_url to see it)

fix: picture category display in upper bar

fix: function rate_picture variables and use of the new user type

fix: caddie icon appears now on category page

fix: admin element_set sql query was using storage_category_id column
(column has moved to #image_categories)

fix: replaced some old $_GET[xxx] with $page[xxx]

fix: pictures have metadata url (use ? parameter - might change later)

git-svn-id: http://piwigo.org/svn/trunk@1092 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
rvelices 2006-03-22 01:01:47 +00:00
parent 3609c224c7
commit 0971ce48d2
28 changed files with 373 additions and 310 deletions

View file

@ -379,7 +379,7 @@ SELECT DISTINCT(category_id) AS id, c.name, uppercats, global_rank
WHERE ic.image_id IN ('.implode(',', $page['cat_elements_id']).') WHERE ic.image_id IN ('.implode(',', $page['cat_elements_id']).')
AND ic.category_id = c.id AND ic.category_id = c.id
AND ic.image_id = i.id AND ic.image_id = i.id
AND ic.category_id != i.storage_category_id AND ic.is_storage = \'false\'
;'; ;';
display_select_cat_wrapper($query, array(), $blockname, true); display_select_cat_wrapper($query, array(), $blockname, true);
} }

View file

@ -213,6 +213,7 @@ SELECT *
$row = mysql_fetch_array(pwg_query($query)); $row = mysql_fetch_array(pwg_query($query));
$storage_category_id = $row['category_id']; $storage_category_id = $row['category_id'];
$image_file = $row['file'];
// Navigation path // Navigation path
@ -354,6 +355,7 @@ if (isset($_GET['cat_id'])
$url_img = make_picture_URL( $url_img = make_picture_URL(
array( array(
'image_id' => $_GET['image_id'], 'image_id' => $_GET['image_id'],
'image_file' => $image_file,
'category' => $_GET['cat_id'], 'category' => $_GET['cat_id'],
) )
); );
@ -365,6 +367,7 @@ else
$url_img = make_picture_URL( $url_img = make_picture_URL(
array( array(
'image_id' => $_GET['image_id'], 'image_id' => $_GET['image_id'],
'image_file' => $image_file,
'category' => $category, 'category' => $category,
) )
); );

View file

@ -177,7 +177,7 @@ if (mysql_num_rows($result) > 0)
$template->assign_block_vars( $template->assign_block_vars(
'groups.category', 'groups.category',
array( array(
'NAME' => get_cat_display_name_cache($category['uppercats'], '', false) 'NAME' => get_cat_display_name_cache($category['uppercats'], null, false)
) )
); );
} }

View file

@ -45,8 +45,7 @@ if ( isset( $_GET['act'] )
session_unset(); session_unset();
session_destroy(); session_destroy();
setcookie(session_name(),'',0, cookie_path() ); setcookie(session_name(),'',0, cookie_path() );
$url = 'category.php'; redirect( make_index_url() );
redirect( $url );
} }
//---------------------------------------------- change of image display order //---------------------------------------------- change of image display order
@ -113,11 +112,7 @@ $template->set_filenames( array('category'=>'category.tpl') );
//-------------------------------------------------------------- category title //-------------------------------------------------------------- category title
if (isset($page['category'])) if (isset($page['category']))
{ {
$template_title = get_cat_display_name( $template_title = get_cat_display_name( $page['cat_name'], '', false );
$page['cat_name'],
'category.php?/category/',
false
);
} }
else else
{ {
@ -206,7 +201,7 @@ if ('search' == $page['section'])
$template->assign_block_vars( $template->assign_block_vars(
'search_rules', 'search_rules',
array( array(
'URL' => PHPWG_ROOT_PATH.'/search_rules.php?search_id='.$page['search'], 'URL' => get_root_url().'search_rules.php?search_id='.$page['search'],
) )
); );
} }
@ -264,7 +259,7 @@ if ($conf['rate'])
$template->assign_block_vars( $template->assign_block_vars(
'special_cat', 'special_cat',
array( array(
'URL' => PHPWG_ROOT_PATH.'random.php', 'URL' => get_root_url().'random.php',
'TITLE' => $lang['random_cat_hint'], 'TITLE' => $lang['random_cat_hint'],
'NAME' => $lang['random_cat'] 'NAME' => $lang['random_cat']
)); ));
@ -395,6 +390,17 @@ if (isset($page['category']) and is_admin())
); );
} }
if (is_admin() and !empty($page['items']) )
{
$template->assign_block_vars(
'caddie',
array(
'URL' =>
add_url_param(duplicate_index_url(),'caddie=1')
)
);
}
//------------------------------------------------------ main part : thumbnails //------------------------------------------------------ main part : thumbnails
if (isset($page['thumbnails_include'])) if (isset($page['thumbnails_include']))
{ {
@ -453,7 +459,7 @@ if (isset($page['category']))
// upload a picture in the category // upload a picture in the category
if ($page['cat_uploadable']) if ($page['cat_uploadable'])
{ {
$url = PHPWG_ROOT_PATH.'upload.php?cat='.$page['category']; $url = get_root_url().'upload.php?cat='.$page['category'];
$template->assign_block_vars( $template->assign_block_vars(
'upload', 'upload',
array( array(

View file

@ -66,7 +66,7 @@ $since_options = array(
'clause' => '1=1') // stupid but generic 'clause' => '1=1') // stupid but generic
); );
$page['since'] = isset($_GET['since']) ? $_GET['since'] : 1; $page['since'] = isset($_GET['since']) ? $_GET['since'] : 3;
// on which field sorting // on which field sorting
// //
@ -393,7 +393,7 @@ SELECT id, uppercats
{ {
// name of the picture // name of the picture
$name = get_cat_display_name_cache( $name = get_cat_display_name_cache(
$categories[$comment['category_id']]['uppercats'], '', false); $categories[$comment['category_id']]['uppercats'], null, false);
$name.= $conf['level_separator']; $name.= $conf['level_separator'];
if (!empty($elements[$comment['image_id']]['name'])) if (!empty($elements[$comment['image_id']]['name']))
{ {
@ -411,9 +411,6 @@ SELECT id, uppercats
); );
// link to the full size picture // link to the full size picture
$url = PHPWG_ROOT_PATH.'picture.php?cat='.$comment['category_id'];
$url.= '&image_id='.$comment['image_id'];
$url = make_picture_url( $url = make_picture_url(
array( array(
'category' => $comment['category_id'], 'category' => $comment['category_id'],

View file

@ -261,8 +261,14 @@ SELECT DISTINCT('.$this->calendar_levels[$level]['sql']
} }
} }
$dates = $page['chronology_date'];
while ($level<count($dates))
{
array_pop($dates);
}
$nav_bar = $this->get_nav_bar_from_items( $nav_bar = $this->get_nav_bar_from_items(
$page['chronology_date'], $dates,
$level_items, $level_items,
null, null,
'calItem', 'calItem',

View file

@ -224,7 +224,7 @@ function build_global_calendar()
$query.= $this->get_date_where(); $query.= $this->get_date_where();
$query.= ' $query.= '
GROUP BY period GROUP BY period
ORDER BY YEAR('.$this->date_field.') DESC'; ORDER BY YEAR('.$this->date_field.') DESC, MONTH('.$this->date_field.')';
$result = pwg_query($query); $result = pwg_query($query);
$items=array(); $items=array();
@ -350,7 +350,9 @@ SELECT file,tn_ext,path, width, height, DAYOFWEEK('.$this->date_field.')-1 as do
$row = mysql_fetch_array(pwg_query($query)); $row = mysql_fetch_array(pwg_query($query));
$items[$day]['tn_path'] = get_thumbnail_src($row['path'], @$row['tn_ext']); $items[$day]['tn_path'] = get_thumbnail_src($row['path'], @$row['tn_ext']);
$items[$day]['tn_file'] = $row['file']; $items[$day]['file'] = $row['file'];
$items[$day]['path'] = $row['path'];
$items[$day]['tn_ext'] = @$row['tn_ext'];
$items[$day]['width'] = $row['width']; $items[$day]['width'] = $row['width'];
$items[$day]['height'] = $row['height']; $items[$day]['height'] = $row['height'];
$items[$day]['dow'] = $row['dow']; $items[$day]['dow'] = $row['dow'];
@ -445,7 +447,10 @@ SELECT file,tn_ext,path, width, height, DAYOFWEEK('.$this->date_field.')-1 as do
} }
else else
{// item not an image (tn is either mime type or an image) {// item not an image (tn is either mime type or an image)
$tn_size = @getimagesize($items[$day]['tn_path']); $thumb = get_thumbnail_src(
$items[$day]['path'], @$items[$day]['tn_ext'], false
);
$tn_size = @getimagesize($thumb);
} }
$tn_width = $tn_size[0]; $tn_width = $tn_size[0];
$tn_height = $tn_size[1]; $tn_height = $tn_size[1];
@ -548,7 +553,7 @@ SELECT file,tn_ext,path, width, height, DAYOFWEEK('.$this->date_field.')-1 as do
'thumbnails.line.thumbnail', 'thumbnails.line.thumbnail',
array( array(
'IMAGE'=>$data['tn_path'], 'IMAGE'=>$data['tn_path'],
'IMAGE_ALT'=>$data['tn_file'], 'IMAGE_ALT'=>$data['file'],
'IMAGE_TITLE'=>$thumbnail_title, 'IMAGE_TITLE'=>$thumbnail_title,
'U_IMG_LINK'=>$url 'U_IMG_LINK'=>$url
) )

View file

@ -126,7 +126,7 @@ foreach ($pictures as $row)
} }
case 'search' : case 'search' :
{ {
$name = replace_search($name, $_GET['search']); $name = replace_search($name, $page['search']);
break; break;
} }
} }

View file

@ -83,7 +83,7 @@ while ( $row = mysql_fetch_array( $result ) )
$template->assign_block_vars( $template->assign_block_vars(
'thumbnails.line.thumbnail.category_name', 'thumbnails.line.thumbnail.category_name',
array( array(
'NAME' => get_cat_display_name_cache($row['uppercats'], '', false), 'NAME' => get_cat_display_name_cache($row['uppercats'], null, false),
) )
); );

View file

@ -1141,11 +1141,13 @@ function make_picture_URL($params)
$url = $url =
get_root_url().'picture.php?' get_root_url().'picture.php?'
.'/'.$params['image_id']
.'/'.make_section_in_URL($params) .'/'.make_section_in_URL($params)
; ;
$url = add_well_known_params_in_url($url, $params); $url = add_well_known_params_in_url($url, $params);
$url.= '/'.
$params['image_id']//.'-'.
//get_filename_wo_extension($params['image_file']).'.htm'
;
return $url; return $url;
} }

View file

@ -47,7 +47,7 @@ function check_restrictions($category_id)
if (in_array($category_id, explode(',', $user['forbidden_categories']))) if (in_array($category_id, explode(',', $user['forbidden_categories'])))
{ {
$login_url = $login_url =
'./identification.php?redirect=' get_root_url().'identification.php?redirect='
.urlencode(urlencode($_SERVER['REQUEST_URI'])); .urlencode(urlencode($_SERVER['REQUEST_URI']));
if (!$user['is_the_guest']) if (!$user['is_the_guest'])
@ -278,7 +278,7 @@ function display_select_categories($categories,
if ($fullname) if ($fullname)
{ {
$option = get_cat_display_name_cache($category['uppercats'], $option = get_cat_display_name_cache($category['uppercats'],
'', null,
false); false);
} }
else else

View file

@ -66,6 +66,7 @@ function get_icon($date)
$title .= $user['recent_period']; $title .= $user['recent_period'];
$title .= '&nbsp;'.$lang['days']; $title .= '&nbsp;'.$lang['days'];
$size = getimagesize( $icon_url ); $size = getimagesize( $icon_url );
$icon_url = get_root_url().$icon_url;
$output = '<img title="'.$title.'" src="'.$icon_url.'" class="icon" style="border:0;'; $output = '<img title="'.$title.'" src="'.$icon_url.'" class="icon" style="border:0;';
$output.= 'height:'.$size[1].'px;width:'.$size[0].'px" alt="(!)" />'; $output.= 'height:'.$size[1].'px;width:'.$size[0].'px" alt="(!)" />';
} }
@ -244,7 +245,7 @@ function language_select($default, $select_name = "language")
* *
* categories string returned contains categories as given in the input * categories string returned contains categories as given in the input
* array $cat_informations. $cat_informations array must be an association * array $cat_informations. $cat_informations array must be an association
* of {category_id => category_name}. If url input parameter is empty, * of {category_id => category_name}. If url input parameter is null,
* returns only the categories name without links. * returns only the categories name without links.
* *
* @param array cat_informations * @param array cat_informations
@ -253,7 +254,7 @@ function language_select($default, $select_name = "language")
* @return string * @return string
*/ */
function get_cat_display_name($cat_informations, function get_cat_display_name($cat_informations,
$url = 'category.php?/category/', $url = '',
$replace_space = true) $replace_space = true)
{ {
global $conf; global $conf;
@ -271,10 +272,16 @@ function get_cat_display_name($cat_informations,
$output.= $conf['level_separator']; $output.= $conf['level_separator'];
} }
if ($url == '') if ( !isset($url) )
{ {
$output.= $name; $output.= $name;
} }
elseif ($url == '')
{
$output.= '<a class=""';
$output.= ' href="'.make_index_url( array('category'=>$id) ).'">';
$output.= $name.'</a>';
}
else else
{ {
$output.= '<a class=""'; $output.= '<a class=""';
@ -306,7 +313,7 @@ function get_cat_display_name($cat_informations,
* @return string * @return string
*/ */
function get_cat_display_name_cache($uppercats, function get_cat_display_name_cache($uppercats,
$url = 'category.php?/category/', $url = '',
$replace_space = true) $replace_space = true)
{ {
global $cat_names, $conf; global $cat_names, $conf;
@ -339,10 +346,16 @@ SELECT id,name
$output.= $conf['level_separator']; $output.= $conf['level_separator'];
} }
if ($url == '') if ( !isset($url) )
{ {
$output.= $name; $output.= $name;
} }
elseif ($url == '')
{
$output.= '
<a class=""
href="'.make_index_url( array('category'=>$category_id) ).'">'.$name.'</a>';
}
else else
{ {
$output.= ' $output.= '
@ -474,7 +487,7 @@ function parse_comment_content($content)
} }
function get_cat_display_name_from_id($cat_id, function get_cat_display_name_from_id($cat_id,
$url = 'category.php?/category/', $url = '',
$replace_space = true) $replace_space = true)
{ {
$cat_info = get_cat_info($cat_id); $cat_info = get_cat_info($cat_id);

View file

@ -6,10 +6,9 @@
// +-----------------------------------------------------------------------+ // +-----------------------------------------------------------------------+
// | branch : BSF (Best So Far) // | branch : BSF (Best So Far)
// | file : $RCSfile$ // | file : $RCSfile$
// | last update : $Date: 2006-03-15 03:26:25 +0100 (mer, 15 mar 2006) $ // | last update : $Date$
// | last modifier : $Author: rvelices $ // | last modifier : $Author$
// | revision : $Revision: 1081 $ // | revision : $Revision$
// | revision : $Revision: 1081 $
// +-----------------------------------------------------------------------+ // +-----------------------------------------------------------------------+
// | This program is free software; you can redistribute it and/or modify | // | This program is free software; you can redistribute it and/or modify |
// | it under the terms of the GNU General Public License as published by | // | it under the terms of the GNU General Public License as published by |
@ -29,37 +28,28 @@
/** /**
* rate a picture by a user * rate a picture by a user
* *
* @param int user identifier
* @param int image identifier * @param int image identifier
* @param int rate * @param int rate
* @return void * @return void
*/ */
function rate_picture($user_id, $image_id, $rate) function rate_picture($image_id, $rate)
{ {
global $conf; global $conf, $user;
$query = ' if (!isset($rate)
SELECT status or !$conf['rate']
FROM '.USER_INFOS_TABLE.' or !in_array($rate, $conf['rate_items']))
WHERE user_id = '.$user_id.'
;';
list($user_status) = mysql_fetch_array(pwg_query($query));
if ('guest' == $user_status
or 'generic' == $user_status)
{ {
$user_anonymous = true; return;
}
else
{
$user_anonymous = false;
} }
if (isset($rate) $user_anonymous = is_autorize_status(ACCESS_CLASSIC) ? false : true;
and $conf['rate']
and (!$user_anonymous or $conf['rate_anonymous']) if ($user_anonymous and !$conf['rate_anonymous'])
and in_array($rate, $conf['rate_items']))
{ {
return;
}
if ($user_anonymous) if ($user_anonymous)
{ {
$ip_components = explode('.', $_SERVER["REMOTE_ADDR"]); $ip_components = explode('.', $_SERVER["REMOTE_ADDR"]);
@ -108,8 +98,8 @@ UPDATE
strtotime('+10 years'), strtotime('+10 years'),
cookie_path() cookie_path()
); );
} } // end client changed ip
} } // end client has cookie
else else
{ {
setcookie( setcookie(
@ -119,13 +109,12 @@ UPDATE
cookie_path() cookie_path()
); );
} }
} } // end anonymous user
$query = ' $query = '
DELETE DELETE
FROM '.RATE_TABLE.' FROM '.RATE_TABLE.'
WHERE element_id = '.$image_id.' WHERE element_id = '.$image_id.'
AND user_id = '.$user_id.' AND user_id = '.$user['id'].'
'; ';
if (isset($anonymous_id)) if (isset($anonymous_id))
{ {
@ -138,7 +127,7 @@ INSERT
(user_id,anonymous_id,element_id,rate,date) (user_id,anonymous_id,element_id,rate,date)
VALUES VALUES
(' ('
.$user_id.',' .$user['id'].','
.(isset($anonymous_id) ? '\''.$anonymous_id.'\'' : "''").',' .(isset($anonymous_id) ? '\''.$anonymous_id.'\'' : "''").','
.$image_id.',' .$image_id.','
.$rate .$rate
@ -159,7 +148,6 @@ UPDATE '.IMAGES_TABLE.'
WHERE id = '.$image_id.' WHERE id = '.$image_id.'
;'; ;';
pwg_query($query); pwg_query($query);
}
} }
?> ?>

View file

@ -81,11 +81,26 @@ function cookie_path()
if ( isset($_SERVER['REDIRECT_URL']) ) if ( isset($_SERVER['REDIRECT_URL']) )
{ // mod_rewrite is activated for upper level directories. we must set the { // mod_rewrite is activated for upper level directories. we must set the
// cookie to the path shown in the browser otherwise it will be discarded. // cookie to the path shown in the browser otherwise it will be discarded.
$scr = $_SERVER['REDIRECT_URL']; if ( isset($_SERVER['PATH_INFO']) )
{
$idx = strpos( $_SERVER['REDIRECT_URL'], $_SERVER['PATH_INFO'] );
if ($idx !== false)
{
$scr = substr($_SERVER['REDIRECT_URL'], 0, $idx);
}
else
{//this should never happen
$scr='//';
}
} }
else else
{ {
$scr = $_SERVER['PHP_SELF']; $scr = $_SERVER['REDIRECT_URL'];
}
}
else
{
$scr = $_SERVER['SCRIPT_NAME'];
} }
return substr($scr,0,strrpos( $scr,'/')); return substr($scr,0,strrpos( $scr,'/'));
} }

View file

@ -30,11 +30,7 @@ $template->assign_vars(
array( array(
'VERSION' => $conf['show_version'] ? PHPWG_VERSION : '', 'VERSION' => $conf['show_version'] ? PHPWG_VERSION : '',
'L_GEN_TIME' => $lang['generation_time'],
'L_SQL_QUERIES_IN' => $lang['sql_queries_in'],
'L_SEND_MAIL' => $lang['send_mail'],
'L_TITLE_MAIL' => urlencode($lang['title_send_mail']), 'L_TITLE_MAIL' => urlencode($lang['title_send_mail']),
'L_POWERED_BY'=>$lang['powered_by']
)); ));
//--------------------------------------------------------------------- contact //--------------------------------------------------------------------- contact
@ -50,6 +46,7 @@ if (!$user['is_the_guest'])
} }
//------------------------------------------------------------- generation time //------------------------------------------------------------- generation time
$debug_vars = array();
if ($conf['show_gt']) if ($conf['show_gt'])
{ {
$time = get_elapsed_time($t2, get_moment()); $time = get_elapsed_time($t2, get_moment());
@ -60,19 +57,21 @@ if ($conf['show_gt'])
$page['queries_time'] = 0; $page['queries_time'] = 0;
} }
$template->assign_block_vars( $debug_vars = array_merge($debug_vars,
'debug',
array('TIME' => $time, array('TIME' => $time,
'NB_QUERIES' => $page['count_queries'], 'NB_QUERIES' => $page['count_queries'],
'SQL_TIME' => number_format($page['queries_time'],3,'.',' ').' s')); 'SQL_TIME' => number_format($page['queries_time'],3,'.',' ').' s')
);
} }
if ($conf['show_queries']) if ($conf['show_queries'])
{ {
$template->assign_block_vars( $debug_vars = array_merge($debug_vars, array('QUERIES_LIST' => $debug) );
'debug', }
array('QUERIES_LIST' => $debug)
); if ( !empty($debug_vars) )
{
$template->assign_block_vars('debug',$debug_vars );
} }
// //

View file

@ -6,9 +6,9 @@
// +-----------------------------------------------------------------------+ // +-----------------------------------------------------------------------+
// | branch : BSF (Best So Far) // | branch : BSF (Best So Far)
// | file : $RCSfile$ // | file : $RCSfile$
// | last update : $Date: 2006-03-09 00:14:53 +0100 (jeu, 09 mar 2006) $ // | last update : $Date$
// | last modifier : $Author: rub $ // | last modifier : $Author$
// | revision : $Revision: 1070 $ // | revision : $Revision$
// +-----------------------------------------------------------------------+ // +-----------------------------------------------------------------------+
// | This program is free software; you can redistribute it and/or modify | // | This program is free software; you can redistribute it and/or modify |
// | it under the terms of the GNU General Public License as published by | // | it under the terms of the GNU General Public License as published by |
@ -30,7 +30,7 @@
* *
*/ */
if ($metadata_showable and isset($_GET['show_metadata'])) if ($metadata_showable and isset($_GET['metadata']))
{ {
include_once(PHPWG_ROOT_PATH.'/include/functions_metadata.inc.php'); include_once(PHPWG_ROOT_PATH.'/include/functions_metadata.inc.php');
$template->assign_block_vars('metadata', array()); $template->assign_block_vars('metadata', array());
@ -41,7 +41,7 @@ if ($metadata_showable and isset($_GET['show_metadata']))
die('Exif extension not available, admin should disable exif display'); die('Exif extension not available, admin should disable exif display');
} }
if ($exif = @read_exif_data($picture['current']['src'])) if ($exif = @read_exif_data($picture['current']['src_file_system']))
{ {
$template->assign_block_vars( $template->assign_block_vars(
'metadata.headline', 'metadata.headline',

View file

@ -6,9 +6,9 @@
// +-----------------------------------------------------------------------+ // +-----------------------------------------------------------------------+
// | branch : BSF (Best So Far) // | branch : BSF (Best So Far)
// | file : $RCSfile$ // | file : $RCSfile$
// | last update : $Date: 2006-03-09 00:14:53 +0100 (jeu, 09 mar 2006) $ // | last update : $Date$
// | last modifier : $Author: rub $ // | last modifier : $Author$
// | revision : $Revision: 1070 $ // | revision : $Revision$
// +-----------------------------------------------------------------------+ // +-----------------------------------------------------------------------+
// | This program is free software; you can redistribute it and/or modify | // | This program is free software; you can redistribute it and/or modify |
// | it under the terms of the GNU General Public License as published by | // | it under the terms of the GNU General Public License as published by |
@ -54,7 +54,7 @@ SELECT COUNT(rate) AS count
); );
} }
if ($conf['rate_anonymous'] or !$user['is_the_guest']) if ($conf['rate_anonymous'] or is_autorize_status(ACCESS_CLASSIC) )
{ {
if ($row['count']>0) if ($row['count']>0)
{ {
@ -63,7 +63,7 @@ SELECT COUNT(rate) AS count
WHERE element_id = '.$page['image_id'] . ' WHERE element_id = '.$page['image_id'] . '
AND user_id = '.$user['id'] ; AND user_id = '.$user['id'] ;
if ($user['is_the_guest']) if ( !is_autorize_status(ACCESS_CLASSIC) )
{ {
$ip_components = explode('.', $_SERVER['REMOTE_ADDR']); $ip_components = explode('.', $_SERVER['REMOTE_ADDR']);
if ( count($ip_components)>3 ) if ( count($ip_components)>3 )

View file

@ -6,9 +6,9 @@
// +-----------------------------------------------------------------------+ // +-----------------------------------------------------------------------+
// | branch : BSF (Best So Far) // | branch : BSF (Best So Far)
// | file : $RCSfile$ // | file : $RCSfile$
// | last update : $Date: 2006-01-27 02:11:43 +0100 (ven, 27 jan 2006) $ // | last update : $Date$
// | last modifier : $Author: rvelices $ // | last modifier : $Author$
// | revision : $Revision: 1014 $ // | revision : $Revision$
// +-----------------------------------------------------------------------+ // +-----------------------------------------------------------------------+
// | This program is free software; you can redistribute it and/or modify | // | This program is free software; you can redistribute it and/or modify |
// | it under the terms of the GNU General Public License as published by | // | it under the terms of the GNU General Public License as published by |
@ -84,17 +84,35 @@ $tokens = explode(
$next_token = 0; $next_token = 0;
if (basename($_SERVER['SCRIPT_NAME']) == 'picture.php') if (basename($_SERVER['SCRIPT_NAME']) == 'picture.php')
{ { // the last token must be the identifier for the picture
$token = array_pop($tokens);
// the first token must be the numeric identifier of the picture if ( is_numeric($token) )
preg_match('/(\d+)/', $tokens[$next_token], $matches); {
if (!isset($matches[1])) $page['image_id'] = $token;
}
else
{
preg_match('/^(\d+-)?((.*)[_\.]html?)?$/', $token, $matches);
if ( isset($matches[1]) and is_numeric($matches[1]) )
{
$page['image_id'] = $matches[1];
if ( !empty($matches[3]) )
{
$page['image_file'] = $matches[3];
}
}
else
{
if ( !empty($matches[3]) )
{
$page['image_file'] = $matches[3];
}
else
{ {
die('Fatal: picture identifier is missing'); die('Fatal: picture identifier is missing');
} }
$page['image_id'] = $matches[1]; }
}
$next_token++;
} }
if (0 === strpos($tokens[$next_token], 'cat')) if (0 === strpos($tokens[$next_token], 'cat'))
@ -273,11 +291,11 @@ if ('categories' == $page['section'])
'cat_id_uppercat' => $result['id_uppercat'], 'cat_id_uppercat' => $result['id_uppercat'],
'uppercats' => $result['uppercats'], 'uppercats' => $result['uppercats'],
'title' => get_cat_display_name($result['name'], '', false), 'title' => get_cat_display_name($result['name'], null, false),
) )
); );
if (!isset($_GET['calendar'])) if (!isset($page['chronology_field']))
{ {
$query = ' $query = '
SELECT image_id SELECT image_id
@ -321,7 +339,7 @@ else
SELECT DISTINCT(id) SELECT DISTINCT(id)
FROM '.IMAGES_TABLE.' FROM '.IMAGES_TABLE.'
INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id
WHERE '.get_sql_search_clause($_GET['search']).' WHERE '.get_sql_search_clause($page['search']).'
AND '.$forbidden.' AND '.$forbidden.'
'.$conf['order_by'].' '.$conf['order_by'].'
;'; ;';
@ -489,4 +507,19 @@ if (isset($page['chronology_field']))
initialize_calendar(); initialize_calendar();
} }
if (basename($_SERVER['SCRIPT_NAME']) == 'picture.php'
and !isset($page['image_id']) )
{
$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)
{
list($page['image_id'], $page['image_file']) = mysql_fetch_row($result);
}
}
?> ?>

View file

@ -328,6 +328,7 @@ class Template {
*/ */
function compile($code, $do_not_echo = false, $retvar = '') function compile($code, $do_not_echo = false, $retvar = '')
{ {
$code = preg_replace('/\{pwg_root\}/e', "get_root_url()", $code);
// PWG specific : communication between template and $lang // PWG specific : communication between template and $lang
$code = preg_replace('/\{lang:([^}]+)\}/e', "l10n('$1')", $code); $code = preg_replace('/\{lang:([^}]+)\}/e', "l10n('$1')", $code);
// PWG specific : expand themeconf.inc.php variables // PWG specific : expand themeconf.inc.php variables

View file

@ -168,7 +168,7 @@ UPDATE '.CATEGORIES_TABLE.'
} }
case 'rate' : case 'rate' :
{ {
rate_picture($user['id'], $page['image_id'], $_GET['rate']); rate_picture($page['image_id'], $_GET['rate']);
redirect($url_self); redirect($url_self);
} }
case 'delete_comment' : case 'delete_comment' :
@ -370,14 +370,14 @@ if ( isset( $_GET['slideshow'] ) and isset($page['next_item']) )
} }
$title_img = $picture['current']['name']; $title_img = $picture['current']['name'];
if ( isset( $page['cat'] ) ) if ( isset( $page['category'] ) )
{ {
if (is_numeric( $page['cat'] )) if (is_numeric( $page['category'] ))
{ {
$title_img = replace_space(get_cat_display_name($page['cat_name'])); $title_img = replace_space(get_cat_display_name($page['cat_name']));
} }
else if ( $page['cat'] == 'search' ) else if ( $page['cat'] == 'search' )
{ { // ??? TODO -remove or change some remainings from old variables
$title_img = replace_search( $title_img, $_GET['search'] ); $title_img = replace_search( $title_img, $_GET['search'] );
} }
} }
@ -404,25 +404,20 @@ $picture_size = get_picture_size(
); );
// metadata // metadata
$url_metadata = duplicate_picture_URL();
if ($conf['show_exif'] or $conf['show_iptc']) if ($conf['show_exif'] or $conf['show_iptc'])
{ {
$metadata_showable = true; $metadata_showable = true;
if ( !isset($_GET['metadata']) )
{
$url_metadata = add_url_param( $url_metadata, 'metadata' );
}
} }
else else
{ {
$metadata_showable = false; $metadata_showable = false;
} }
// $url_metadata = PHPWG_ROOT_PATH.'picture.php';
// $url_metadata .= get_query_string_diff(array('add_fav', 'slideshow', 'show_metadata'));
// if ($metadata_showable and !isset($_GET['show_metadata']))
// {
// $url_metadata.= '&amp;show_metadata=1';
// }
// TODO: rewrite metadata display to toggle on/off user_infos.show_metadata
$url_metadata = duplicate_picture_URL();
$page['body_id'] = 'thePicturePage'; $page['body_id'] = 'thePicturePage';
//------------------------------------------------------- navigation management //------------------------------------------------------- navigation management
foreach ( array('first','previous','next','last') as $which_image ) foreach ( array('first','previous','next','last') as $which_image )

View file

@ -140,7 +140,7 @@ SELECT id, uppercats, global_rank
array( array(
'NAME' => get_cat_display_name_cache( 'NAME' => get_cat_display_name_cache(
$category['uppercats'], $category['uppercats'],
'', // no url on category names null, // no url on category names
false // no blank replacement false // no blank replacement
) )
) )

View file

@ -91,8 +91,8 @@
<input type="submit" name="login" value="{lang:submit}"> <input type="submit" name="login" value="{lang:submit}">
</p> </p>
<ul class="actions"> <ul class="actions">
<li><a href="{U_LOST_PASSWORD}" title="{lang:Forgot your password?}"><img src="{themeconf:icon_dir}/lost_password.png" class="button" alt="{lang:Forgot your password?}"></a></li> <li><a href="{U_LOST_PASSWORD}" title="{lang:Forgot your password?}"><img src="{pwg_root}{themeconf:icon_dir}/lost_password.png" class="button" alt="{lang:Forgot your password?}"></a></li>
<li><a href="{U_REGISTER}" title="{lang:Create a new account}"><img src="{themeconf:icon_dir}/register.png" class="button" alt="{lang:register}"/></a></li> <li><a href="{U_REGISTER}" title="{lang:Create a new account}"><img src="{pwg_root}{themeconf:icon_dir}/register.png" class="button" alt="{lang:register}"/></a></li>
</ul> </ul>
</fieldset> </fieldset>
@ -119,25 +119,25 @@
<!-- END preferred_image_order --> <!-- END preferred_image_order -->
<!-- BEGIN caddie --> <!-- BEGIN caddie -->
<li><a href="{caddie.URL}" title="{lang:add to caddie}"><img src="{themeconf:icon_dir}/caddie_add.png" class="button" alt="{lang:caddie}"/></a></li> <li><a href="{caddie.URL}" title="{lang:add to caddie}"><img src="{pwg_root}{themeconf:icon_dir}/caddie_add.png" class="button" alt="{lang:caddie}"/></a></li>
<!-- END caddie --> <!-- END caddie -->
<!-- BEGIN edit --> <!-- BEGIN edit -->
<li><a href="{edit.URL}" title="{lang:edit category informations}"><img src="{themeconf:icon_dir}/category_edit.png" class="button" alt="{lang:edit}"/></a></li> <li><a href="{edit.URL}" title="{lang:edit category informations}"><img src="{pwg_root}{themeconf:icon_dir}/category_edit.png" class="button" alt="{lang:edit}"/></a></li>
<!-- END edit --> <!-- END edit -->
<!-- BEGIN search_rules --> <!-- BEGIN search_rules -->
<li><a href="{search_rules.URL}" style="border:none;" onclick="popuphelp(this.href); return false;" title="{lang:Search rules}"><img src="{themeconf:icon_dir}/search_rules.png" class="button" alt="(?)"></a></li> <li><a href="{search_rules.URL}" style="border:none;" onclick="popuphelp(this.href); return false;" title="{lang:Search rules}"><img src="{pwg_root}{themeconf:icon_dir}/search_rules.png" class="button" alt="(?)"></a></li>
<!-- END search_rules --> <!-- END search_rules -->
<!-- BEGIN mode_normal --> <!-- BEGIN mode_normal -->
<li><a href="{mode_normal.URL}" title="{lang:mode_normal_hint}"><img src="{themeconf:icon_dir}/normal_mode.png" class="button" alt="{lang:mode_normal_hint}"></a></li> <li><a href="{mode_normal.URL}" title="{lang:mode_normal_hint}"><img src="{pwg_root}{themeconf:icon_dir}/normal_mode.png" class="button" alt="{lang:mode_normal_hint}"></a></li>
<!-- END mode_normal --> <!-- END mode_normal -->
<!-- BEGIN mode_posted --> <!-- BEGIN mode_posted -->
<li><a href="{mode_posted.URL}" title="{lang:mode_posted_hint}"><img src="{themeconf:icon_dir}/calendar.png" class="button" alt="{lang:mode_posted_hint}"></a></li> <li><a href="{mode_posted.URL}" title="{lang:mode_posted_hint}"><img src="{pwg_root}{themeconf:icon_dir}/calendar.png" class="button" alt="{lang:mode_posted_hint}"></a></li>
<!-- END mode_posted --> <!-- END mode_posted -->
<!-- BEGIN mode_created --> <!-- BEGIN mode_created -->
<li><a href="{mode_created.URL}" title="{lang:mode_created_hint}"><img src="{themeconf:icon_dir}/calendar_created.png" class="button" alt="{lang:mode_created_hint}"></a></li> <li><a href="{mode_created.URL}" title="{lang:mode_created_hint}"><img src="{pwg_root}{themeconf:icon_dir}/calendar_created.png" class="button" alt="{lang:mode_created_hint}"></a></li>
<!-- END mode_created --> <!-- END mode_created -->
</ul> </ul>

View file

@ -1,16 +1,16 @@
<div id="copyright"> <div id="copyright">
<!-- BEGIN debug --> <!-- BEGIN debug -->
{L_GEN_TIME} {debug.TIME} ({debug.NB_QUERIES} {L_SQL_QUERIES_IN} {debug.SQL_TIME}) - {lang:generation_time} {debug.TIME} ({debug.NB_QUERIES} {lang:sql_queries_in} {debug.SQL_TIME}) -
<!-- END debug --> <!-- END debug -->
<!-- Please, do not remove this copyright. If you really want to, <!-- Please, do not remove this copyright. If you really want to,
contact us on http://phpwebgallery.net to find a solution on how contact us on http://phpwebgallery.net to find a solution on how
to show the origin of the script...--> to show the origin of the script...-->
{L_POWERED_BY} <a href="http://www.phpwebgallery.net" class="back">PhpWebGallery</a> {lang:powered_by} <a href="http://www.phpwebgallery.net" class="back">PhpWebGallery</a>
{VERSION} {VERSION}
<!-- BEGIN contact --> <!-- BEGIN contact -->
- {L_SEND_MAIL} - {lang:send_mail}
<a href="mailto:{contact.MAIL}?subject={L_TITLE_MAIL}">{lang:Webmaster}</a> <a href="mailto:{contact.MAIL}?subject={L_TITLE_MAIL}">{lang:Webmaster}</a>
<!-- END contact --> <!-- END contact -->

View file

@ -3,14 +3,14 @@
<html lang="{LANG}" dir="{DIR}"> <html lang="{LANG}" dir="{DIR}">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset={CONTENT_ENCODING}"> <meta http-equiv="Content-Type" content="text/html; charset={CONTENT_ENCODING}">
<link rel="shortcut icon" type="image/x-icon" href="template-common/favicon.ico" /> <link rel="shortcut icon" type="image/x-icon" href="{pwg_root}template-common/favicon.ico" />
<link rel="stylesheet" type="text/css" href="template/{themeconf:template}/default-layout.css"> <link rel="stylesheet" type="text/css" href="{pwg_root}template/{themeconf:template}/default-layout.css">
<!-- the next css is used to fix khtml (Konqueror/Safari) issue <!-- the next css is used to fix khtml (Konqueror/Safari) issue
the "text/nonsense" prevents gecko based browsers to load it --> the "text/nonsense" prevents gecko based browsers to load it -->
<link rel="stylesheet" type="text/nonsense" href="template/{themeconf:template}/fix-khtml.css"> <link rel="stylesheet" type="text/nonsense" href="{pwg_root}template/{themeconf:template}/fix-khtml.css">
<link rel="stylesheet" type="text/css" media="print" href="template/{themeconf:template}/print.css"> <link rel="stylesheet" type="text/css" media="print" href="{pwg_root}template/{themeconf:template}/print.css">
<link rel="stylesheet" type="text/css" href="template/{themeconf:template}/default-colors.css"> <link rel="stylesheet" type="text/css" href="{pwg_root}template/{themeconf:template}/default-colors.css">
<link rel="stylesheet" type="text/css" href="template/{themeconf:template}/theme/{themeconf:theme}/theme.css"> <link rel="stylesheet" type="text/css" href="{pwg_root}template/{themeconf:template}/theme/{themeconf:theme}/theme.css">
<!-- BEGIN next --> <!-- BEGIN next -->
<link rel="prefetch" href="{next.U_IMG_SRC}"> <link rel="prefetch" href="{next.U_IMG_SRC}">
<!-- END next --> <!-- END next -->
@ -18,9 +18,9 @@ the "text/nonsense" prevents gecko based browsers to load it -->
<meta http-equiv="refresh" content="{REFRESH_TIME};url={U_REFRESH}"> <meta http-equiv="refresh" content="{REFRESH_TIME};url={U_REFRESH}">
<!-- END refresh --> <!-- END refresh -->
<title>{GALLERY_TITLE}:{PAGE_TITLE}</title> <title>{GALLERY_TITLE}:{PAGE_TITLE}</title>
<script type="text/javascript" src="include/scripts.js"></script> <script type="text/javascript" src="{pwg_root}include/scripts.js"></script>
<!--[if gte IE 5.5000]> <!--[if gte IE 5.5000]>
<script type="text/javascript" src="include/pngfix.js"></script> <script type="text/javascript" src="{pwg_root}include/pngfix.js"></script>
<![endif]--> <![endif]-->
</head> </head>

View file

@ -14,38 +14,38 @@
<div id="imageToolBar"> <div id="imageToolBar">
<div class="randomButtons"> <div class="randomButtons">
<a href="{U_SLIDESHOW}" title="{L_SLIDESHOW}" rel="nofollow"><img src="{themeconf:icon_dir}/slideshow.png" class="button" alt="{L_SLIDESHOW}"></a> <a href="{U_SLIDESHOW}" title="{L_SLIDESHOW}" rel="nofollow"><img src="{pwg_root}{themeconf:icon_dir}/slideshow.png" class="button" alt="{L_SLIDESHOW}"></a>
<a href="{U_METADATA}" title="{L_PICTURE_METADATA}"><img src="{themeconf:icon_dir}/metadata.png" class="button" alt="{L_PICTURE_METADATA}"></a> <a href="{U_METADATA}" title="{L_PICTURE_METADATA}"><img src="{pwg_root}{themeconf:icon_dir}/metadata.png" class="button" alt="{L_PICTURE_METADATA}"></a>
<!-- BEGIN representative --> <!-- BEGIN representative -->
<a href="{representative.URL}" title="{lang:set as category representative}"><img src="{themeconf:icon_dir}/representative.png" class="button" alt="{lang:representative}"/></a> <a href="{representative.URL}" title="{lang:set as category representative}"><img src="{pwg_root}{themeconf:icon_dir}/representative.png" class="button" alt="{lang:representative}"/></a>
<!-- END representative --> <!-- END representative -->
<!-- BEGIN favorite --> <!-- BEGIN favorite -->
<a href="{favorite.U_FAVORITE}" title="{favorite.FAVORITE_HINT}"><img src="{favorite.FAVORITE_IMG}" class="button" alt="{favorite.FAVORITE_ALT}"></a> <a href="{favorite.U_FAVORITE}" title="{favorite.FAVORITE_HINT}"><img src="{favorite.FAVORITE_IMG}" class="button" alt="{favorite.FAVORITE_ALT}"></a>
<!-- END favorite --> <!-- END favorite -->
<!-- BEGIN download --> <!-- BEGIN download -->
<a href="{download.U_DOWNLOAD}" title="{L_DOWNLOAD}"><img src="{themeconf:icon_dir}/save.png" class="button" alt="{L_DOWNLOAD}"></a> <a href="{download.U_DOWNLOAD}" title="{L_DOWNLOAD}"><img src="{pwg_root}{themeconf:icon_dir}/save.png" class="button" alt="{L_DOWNLOAD}"></a>
<!-- END download --> <!-- END download -->
<!-- BEGIN admin --> <!-- BEGIN admin -->
<a href="{U_ADMIN}" title="{L_ADMIN}"><img src="{themeconf:icon_dir}/preferences.png" class="button" alt="{L_ADMIN}"></a> <a href="{U_ADMIN}" title="{L_ADMIN}"><img src="{pwg_root}{themeconf:icon_dir}/preferences.png" class="button" alt="{L_ADMIN}"></a>
<!-- END admin --> <!-- END admin -->
<!-- BEGIN caddie --> <!-- BEGIN caddie -->
<a href="{caddie.URL}" title="{lang:add to caddie}"><img src="{themeconf:icon_dir}/caddie_add.png" class="button" alt="{lang:caddie}"/></a> <a href="{caddie.URL}" title="{lang:add to caddie}"><img src="{pwg_root}{themeconf:icon_dir}/caddie_add.png" class="button" alt="{lang:caddie}"/></a>
<!-- END caddie --> <!-- END caddie -->
</div> </div>
<div class="navButtons"> <div class="navButtons">
<!-- BEGIN last --> <!-- BEGIN last -->
<a class="navButton prev" href="{last.U_IMG}" rel="last"><img src="{themeconf:icon_dir}/last.png" class="button" alt="{lang:last_page}"></a> <a class="navButton prev" href="{last.U_IMG}" rel="last"><img src="{pwg_root}{themeconf:icon_dir}/last.png" class="button" alt="{lang:last_page}"></a>
<!-- END last --> <!-- END last -->
<!-- BEGIN next --> <!-- BEGIN next -->
<a class="navButton next" href="{next.U_IMG}" title="{L_NEXT_IMG}{next.TITLE_IMG}" rel="next"><img src="{themeconf:icon_dir}/right.png" class="button" alt="next"></a> <a class="navButton next" href="{next.U_IMG}" title="{L_NEXT_IMG}{next.TITLE_IMG}" rel="next"><img src="{pwg_root}{themeconf:icon_dir}/right.png" class="button" alt="next"></a>
<!-- END next --> <!-- END next -->
<a class="navButton up" href="{U_UP}" title="{L_UP_HINT}" rel="up"><img src="{themeconf:icon_dir}/up.png" class="button" alt="{L_UP_ALT}"></a> <a class="navButton up" href="{U_UP}" title="{L_UP_HINT}" rel="up"><img src="{pwg_root}{themeconf:icon_dir}/up.png" class="button" alt="{L_UP_ALT}"></a>
<!-- BEGIN previous --> <!-- BEGIN previous -->
<a class="navButton prev" href="{previous.U_IMG}" title="{L_PREV_IMG}{previous.TITLE_IMG}" rel="prev"><img src="{themeconf:icon_dir}/left.png" class="button" alt="previous"></a> <a class="navButton prev" href="{previous.U_IMG}" title="{L_PREV_IMG}{previous.TITLE_IMG}" rel="prev"><img src="{pwg_root}{themeconf:icon_dir}/left.png" class="button" alt="previous"></a>
<!-- END previous --> <!-- END previous -->
<!-- BEGIN first --> <!-- BEGIN first -->
<a class="navButton prev" href="{first.U_IMG}" rel="first"><img src="{themeconf:icon_dir}/first.png" class="button" alt="{lang:first_page}"></a> <a class="navButton prev" href="{first.U_IMG}" rel="first"><img src="{pwg_root}{themeconf:icon_dir}/first.png" class="button" alt="{lang:first_page}"></a>
<!-- END first --> <!-- END first -->
</div> </div>
@ -170,7 +170,7 @@
<!-- BEGIN delete --> <!-- BEGIN delete -->
<p class="userCommentDelete"> <p class="userCommentDelete">
<a href="{comments.comment.delete.U_COMMENT_DELETE}" title="{L_DELETE_COMMENT}"> <a href="{comments.comment.delete.U_COMMENT_DELETE}" title="{L_DELETE_COMMENT}">
<img src="{themeconf:icon_dir}/delete.png" class="button" style="border:none;vertical-align:middle; margin-left:5px;" alt="[{L_DELETE}]"/> <img src="{pwg_root}{themeconf:icon_dir}/delete.png" class="button" style="border:none;vertical-align:middle; margin-left:5px;" alt="[{L_DELETE}]"/>
</a> </a>
</p> </p>
<!-- END delete --> <!-- END delete -->

View file

@ -2,8 +2,8 @@
$themeconf = array( $themeconf = array(
'template' => 'yoga', 'template' => 'yoga',
'theme' => 'clear', 'theme' => 'clear',
'icon_dir' => PHPWG_ROOT_PATH.'template/yoga/icon', 'icon_dir' => 'template/yoga/icon',
'admin_icon_dir' => PHPWG_ROOT_PATH.'template/yoga/icon/admin', 'admin_icon_dir' => 'template/yoga/icon/admin',
'mime_icon_dir' => PHPWG_ROOT_PATH.'template/yoga/icon/mimetypes/' 'mime_icon_dir' => 'template/yoga/icon/mimetypes/'
); );
?> ?>

View file

@ -2,8 +2,8 @@
$themeconf = array( $themeconf = array(
'template' => 'yoga', 'template' => 'yoga',
'theme' => 'dark', 'theme' => 'dark',
'icon_dir' => PHPWG_ROOT_PATH.'template/yoga/icon', 'icon_dir' => 'template/yoga/icon',
'admin_icon_dir' => PHPWG_ROOT_PATH.'template/yoga/icon/admin', 'admin_icon_dir' => 'template/yoga/icon/admin',
'mime_icon_dir' => PHPWG_ROOT_PATH.'template/yoga/icon/mimetypes/' 'mime_icon_dir' => 'template/yoga/icon/mimetypes/'
); );
?> ?>