aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2006-03-15 22:44:35 +0000
committerplegall <plg@piwigo.org>2006-03-15 22:44:35 +0000
commit114ae324452ac88fe7b672338cba931d838ee2a4 (patch)
tree2ccc8e920a04fae1f97732f6490fa7c67594c05e
parent88e3b36e2f805404e0bfd56d865e317495e9c973 (diff)
new: cleaner URL. Instead of category.php?cat=search&search=123&start=42,
you now have category.php?/search/123/start-42. Functions make_index_url and make_picture_url build these new URLs. Functions duplicate_picture_url and duplicate_index_url provide shortcuts to URL creation. The current main page page is still category.php but this can be modified easily in make_index_url function. In this first version, no backward compatibility. Calendar definition in URL must be discussed with rvelices. improvement: picture.php redesigned. First actions like "set as representative" or "delete a comment" which all lead to a redirection. Then the page (the big mess) and includes of new sub pages to manage specific parts of the page (metadata, user comments, rates). new: with the cleaner URL comes a new terminology. $page['cat'] doesn't exist anymore. $page['section'] is among 'categories', 'tags' (TODO), 'list', 'most_seen'... And sub parameters are set : $page['category'] if $page['section'] is "categories". See URL analyse in include/section_init.inc.php for details. git-svn-id: http://piwigo.org/svn/trunk@1082 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--about.php2
-rw-r--r--admin.php2
-rw-r--r--admin/cat_list.php17
-rw-r--r--admin/cat_modify.php69
-rw-r--r--admin/include/functions.php79
-rw-r--r--admin/picture_modify.php24
-rw-r--r--category.php351
-rw-r--r--comments.php2
-rw-r--r--identification.php4
-rw-r--r--include/category_default.inc.php51
-rw-r--r--include/category_recent_cats.inc.php24
-rw-r--r--include/category_subcats.inc.php30
-rw-r--r--include/functions.inc.php229
-rw-r--r--include/functions_category.inc.php15
-rw-r--r--include/functions_html.inc.php16
-rw-r--r--include/index.php3
-rw-r--r--include/picture_comment.inc.php229
-rw-r--r--include/picture_metadata.inc.php127
-rw-r--r--include/picture_rate.inc.php126
-rw-r--r--include/section_init.inc.php450
-rw-r--r--notification.php2
-rw-r--r--password.php2
-rw-r--r--picture.php1059
-rw-r--r--profile.php5
-rw-r--r--random.php25
-rw-r--r--register.php4
-rw-r--r--search.php12
-rw-r--r--upload.php60
28 files changed, 1774 insertions, 1245 deletions
diff --git a/about.php b/about.php
index 5e3102fbf..56f0a36d1 100644
--- a/about.php
+++ b/about.php
@@ -51,7 +51,7 @@ $template->set_filenames(
$template->assign_vars(
array(
- 'U_HOME' => PHPWG_ROOT_PATH.'category.php'
+ 'U_HOME' => make_index_url(),
)
);
diff --git a/admin.php b/admin.php
index d15fd1651..a965e2878 100644
--- a/admin.php
+++ b/admin.php
@@ -95,7 +95,7 @@ $template->assign_vars(
'U_THUMBNAILS'=> $link_start.'thumbnail',
'U_USERS'=> $link_start.'user_list',
'U_GROUPS'=> $link_start.'group_list',
- 'U_RETURN'=> PHPWG_ROOT_PATH.'category.php',
+ 'U_RETURN'=> make_index_url(),
'U_ADMIN'=> PHPWG_ROOT_PATH.'admin.php',
'L_ADMIN' => $lang['admin'],
'L_ADMIN_HINT' => $lang['hint_admin']
diff --git a/admin/cat_list.php b/admin/cat_list.php
index 4abc5b069..510f5e284 100644
--- a/admin/cat_list.php
+++ b/admin/cat_list.php
@@ -269,13 +269,18 @@ foreach ($categories as $category)
$template->assign_block_vars(
'category',
array(
- 'NAME'=>$category['name'],
- 'ID'=>$category['id'],
- 'RANK'=>$category['rank']*10,
+ 'NAME' => $category['name'],
+ 'ID' => $category['id'],
+ 'RANK' => $category['rank']*10,
- 'U_JUMPTO'=>PHPWG_ROOT_PATH.'category.php?cat='.$category['id'],
- 'U_CHILDREN'=>$cat_list_url.'&amp;parent_id='.$category['id'],
- 'U_EDIT'=>$base_url.'cat_modify&amp;cat_id='.$category['id']
+ 'U_JUMPTO' => make_index_url(
+ array(
+ 'category' => $category['id'],
+ )
+ ),
+
+ 'U_CHILDREN' => $cat_list_url.'&amp;parent_id='.$category['id'],
+ 'U_EDIT' => $base_url.'cat_modify&amp;cat_id='.$category['id'],
)
);
diff --git a/admin/cat_modify.php b/admin/cat_modify.php
index d1aad58c0..cfff0d31f 100644
--- a/admin/cat_modify.php
+++ b/admin/cat_modify.php
@@ -269,37 +269,44 @@ if (!empty($category['id_uppercat']))
$self_url.= '&amp;parent_id='.$category['id_uppercat'];
}
-$template->assign_vars(array(
- 'CATEGORIES_NAV'=>$navigation,
- 'CAT_NAME'=>$category['name'],
- 'CAT_COMMENT'=>$category['comment'],
-
- $status=>'checked="checked"',
- $lock=>'checked="checked"',
- $commentable=>'checked="checked"',
- $uploadable=>'checked="checked"',
-
- 'L_EDIT_NAME'=>$lang['name'],
- 'L_STORAGE'=>$lang['storage'],
- 'L_REMOTE_SITE'=>$lang['remote_site'],
- 'L_EDIT_COMMENT'=>$lang['description'],
- 'L_EDIT_STATUS'=>$lang['conf_access'],
- 'L_STATUS_PUBLIC'=>$lang['public'],
- 'L_STATUS_PRIVATE'=>$lang['private'],
- 'L_EDIT_LOCK'=>$lang['lock'],
- 'L_EDIT_UPLOADABLE'=>$lang['editcat_uploadable'],
- 'L_EDIT_COMMENTABLE'=>$lang['comments'],
- 'L_YES'=>$lang['yes'],
- 'L_NO'=>$lang['no'],
- 'L_SUBMIT'=>$lang['submit'],
- 'L_SET_RANDOM_REPRESENTANT'=>$lang['cat_representant'],
-
- 'U_JUMPTO'=>PHPWG_ROOT_PATH.'category.php?cat='.$category['id'],
- 'U_CHILDREN'=>$cat_list_url.'&amp;parent_id='.$category['id'],
- 'U_HELP' => PHPWG_ROOT_PATH.'/popuphelp.php?page=cat_modify',
-
- 'F_ACTION'=>$form_action
- ));
+$template->assign_vars(
+ array(
+ 'CATEGORIES_NAV' => $navigation,
+ 'CAT_NAME' => $category['name'],
+ 'CAT_COMMENT' => $category['comment'],
+
+ $status => 'checked="checked"',
+ $lock => 'checked="checked"',
+ $commentable => 'checked="checked"',
+ $uploadable => 'checked="checked"',
+
+ 'L_EDIT_NAME' => $lang['name'],
+ 'L_STORAGE' => $lang['storage'],
+ 'L_REMOTE_SITE' => $lang['remote_site'],
+ 'L_EDIT_COMMENT' => $lang['description'],
+ 'L_EDIT_STATUS' => $lang['conf_access'],
+ 'L_STATUS_PUBLIC' => $lang['public'],
+ 'L_STATUS_PRIVATE' => $lang['private'],
+ 'L_EDIT_LOCK' => $lang['lock'],
+ 'L_EDIT_UPLOADABLE' => $lang['editcat_uploadable'],
+ 'L_EDIT_COMMENTABLE' => $lang['comments'],
+ 'L_YES' => $lang['yes'],
+ 'L_NO' => $lang['no'],
+ 'L_SUBMIT' => $lang['submit'],
+ 'L_SET_RANDOM_REPRESENTANT'=>$lang['cat_representant'],
+
+ 'U_JUMPTO' => make_index_url(
+ array(
+ 'category' => $category['id'],
+ )
+ ),
+
+ 'U_CHILDREN' => $cat_list_url.'&amp;parent_id='.$category['id'],
+ 'U_HELP' => PHPWG_ROOT_PATH.'/popuphelp.php?page=cat_modify',
+
+ 'F_ACTION' => $form_action,
+ )
+ );
if ('private' == $category['status'])
diff --git a/admin/include/functions.php b/admin/include/functions.php
index 9a748ef44..076c69fb4 100644
--- a/admin/include/functions.php
+++ b/admin/include/functions.php
@@ -780,14 +780,22 @@ PRIMARY KEY ('.implode(',', $dbfields['primary']).')
// update of images table by joining with temporary table
$query = '
UPDATE '.$tablename.' AS t1, '.$temporary_tablename.' AS t2
- SET '.implode("\n , ",
- array_map(
- create_function('$s', 'return "t1.$s = t2.$s";')
- , $dbfields['update'])).'
- WHERE '.implode("\n AND ",
- array_map(
- create_function('$s', 'return "t1.$s = t2.$s";')
- , $dbfields['primary'])).'
+ SET '.
+ implode(
+ "\n , ",
+ array_map(
+ create_function('$s', 'return "t1.$s = t2.$s";'),
+ $dbfields['update']
+ )
+ ).'
+ WHERE '.
+ implode(
+ "\n AND ",
+ array_map(
+ create_function('$s', 'return "t1.$s = t2.$s";'),
+ $dbfields['primary']
+ )
+ ).'
;';
pwg_query($query);
$query = '
@@ -840,17 +848,27 @@ SELECT id,uppercats
$datas = array();
foreach ($uppercats_array as $id => $uppercats)
{
- $data = array();
- $data['id'] = $id;
- $global_rank = preg_replace('/(\d+)/e',
- "\$ranks_array['$1']",
- str_replace(',', '.', $uppercats));
- $data['global_rank'] = $global_rank;
- array_push($datas, $data);
+ array_push(
+ $datas,
+ array(
+ 'id' => $id,
+ 'global_rank' => preg_replace(
+ '/(\d+)/e',
+ "\$ranks_array['$1']",
+ str_replace(',', '.', $uppercats)
+ ),
+ )
+ );
}
- $fields = array('primary' => array('id'), 'update' => array('global_rank'));
- mass_updates(CATEGORIES_TABLE, $fields, $datas);
+ mass_updates(
+ CATEGORIES_TABLE,
+ array(
+ 'primary' => array('id'),
+ 'update' => array('global_rank')
+ ),
+ $datas
+ );
}
/**
@@ -1253,26 +1271,25 @@ SELECT user_id
// users present in user related tables must be present in the base user
// table
- $tables =
- array(
- USER_MAIL_NOTIFICATION_TABLE,
- USER_FEED_TABLE,
- USER_INFOS_TABLE,
- USER_ACCESS_TABLE,
- USER_CACHE_TABLE,
- USER_GROUP_TABLE
- );
+ $tables = array(
+ USER_MAIL_NOTIFICATION_TABLE,
+ USER_FEED_TABLE,
+ USER_INFOS_TABLE,
+ USER_ACCESS_TABLE,
+ USER_CACHE_TABLE,
+ USER_GROUP_TABLE
+ );
+
foreach ($tables as $table)
{
$query = '
SELECT user_id
FROM '.$table.'
;';
- $to_delete =
- array_diff(
- array_from_query($query, 'user_id'),
- $base_users
- );
+ $to_delete = array_diff(
+ array_from_query($query, 'user_id'),
+ $base_users
+ );
if (count($to_delete) > 0)
{
diff --git a/admin/picture_modify.php b/admin/picture_modify.php
index 9e165b96b..0e20f9290 100644
--- a/admin/picture_modify.php
+++ b/admin/picture_modify.php
@@ -333,31 +333,41 @@ while ($row = mysql_fetch_array($result))
// 3. if URL category not available or reachable, use the first reachable
// linked category
// 4. if no category reachable, no jumpto link
-$base_url_img = PHPWG_ROOT_PATH.'picture.php';
-$base_url_img.= '?image_id='.$_GET['image_id'];
-$base_url_img.= '&amp;cat=';
-unset($url_img);
$query = '
SELECT category_id
FROM '.IMAGE_CATEGORY_TABLE.'
WHERE image_id = '.$_GET['image_id'].'
;';
+
$authorizeds = array_diff(
array_from_query($query, 'category_id'),
- explode(',', calculate_permissions($user['id'], $user['status']))
+ explode(
+ ',',
+ calculate_permissions($user['id'], $user['status'])
+ )
);
if (isset($_GET['cat_id'])
and in_array($_GET['cat_id'], $authorizeds))
{
- $url_img = $base_url_img.$_GET['cat_id'];
+ $url_img = make_picture_URL(
+ array(
+ 'image_id' => $_GET['image_id'],
+ 'category' => $_GET['cat_id'],
+ )
+ );
}
else
{
foreach ($authorizeds as $category)
{
- $url_img = $base_url_img.$category;
+ $url_img = make_picture_URL(
+ array(
+ 'image_id' => $_GET['image_id'],
+ 'category' => $category,
+ )
+ );
break;
}
}
diff --git a/category.php b/category.php
index 2bc078598..b467836e8 100644
--- a/category.php
+++ b/category.php
@@ -57,67 +57,31 @@ if (isset($_GET['image_order']))
);
redirect(
- PHPWG_ROOT_PATH
- .'category.php'
- .get_query_string_diff(array('image_order'))
+ make_index_URL(
+ array(),
+ array('image_order')
+ )
);
}
//-------------------------------------------------------------- initialization
+include(PHPWG_ROOT_PATH.'include/section_init.inc.php');
// detection of the start picture to display
-if ( !isset( $_GET['start'] )
- or !is_numeric( $_GET['start'] )
- or ( is_numeric( $_GET['start'] ) and $_GET['start'] < 0 ) )
+if (!isset($page['start']))
{
$page['start'] = 0;
}
-else
-{
- $page['start'] = $_GET['start'];
-}
-
-include(PHPWG_ROOT_PATH.'include/section_init.inc.php');
// access authorization check
-if (isset($page['cat']) and is_numeric($page['cat']))
+if (isset($page['category']))
{
- check_restrictions($page['cat']);
+ check_restrictions($page['category']);
}
-if ( isset($page['cat_nb_images'])
+if (isset($page['cat_nb_images'])
and $page['cat_nb_images'] > $user['nb_image_page'])
{
- // $nav_url is used to create the navigation bar
- $nav_url = PHPWG_ROOT_PATH.'category.php?';
- if ( isset($page['cat']) )
- {
- $nav_url .= 'cat='.$page['cat'].'&amp;';
-
- switch ($page['cat'])
- {
- case 'search':
- {
- $nav_url.= 'search='.$_GET['search'].'&amp;';
- break;
- }
- case 'list':
- {
- $nav_url.= 'list='.$_GET['list'].'&amp;';
- break;
- }
- }
- }
-
- if ( isset($_GET['calendar']) )
- {
- $nav_url.= 'calendar='.$_GET['calendar'];
- }
- else
- {
- $nav_url = preg_replace('/&amp;$/', '', $nav_url);
- }
-
$page['navigation_bar'] = create_navigation_bar(
- $nav_url,
+ duplicate_index_URL(array(), array('start')),
$page['cat_nb_images'],
$page['start'],
$user['nb_image_page'],
@@ -133,6 +97,7 @@ else
if (isset($_GET['caddie']))
{
fill_caddie($page['items']);
+ // redirect();
}
//----------------------------------------------------- template initialization
@@ -145,117 +110,125 @@ include(PHPWG_ROOT_PATH.'include/page_header.php');
$template->set_filenames( array('category'=>'category.tpl') );
//-------------------------------------------------------------- category title
-if (isset($page['cat']) and is_numeric($page['cat']))
+if (isset($page['category']))
{
- $template_title = get_cat_display_name($page['cat_name'],
- 'category.php?cat=',
- false);
+ $template_title = get_cat_display_name(
+ $page['cat_name'],
+ 'category.php?/category/',
+ false
+ );
}
else
{
$template_title = $page['title'];
}
-if ( isset( $page['cat_nb_images'] ) and $page['cat_nb_images'] > 0 )
+if (isset($page['cat_nb_images']) and $page['cat_nb_images'] > 0)
{
$template_title.= ' ['.$page['cat_nb_images'].']';
}
$icon_recent = get_icon(date('Y-m-d'));
-$calendar_view_link = PHPWG_ROOT_PATH.'category.php'
- .get_query_string_diff(array('start','calendar'));
-if ( ! isset($_GET['calendar']) )
+$calendar_view_link = duplicate_index_URL(
+ array(), // nothing to redefine
+ array('chronology_type', 'start') // what to remove ?
+ );
+
+if (!isset($page['chronology_type']))
{
- $calendar_view_link .= (empty($_GET)? '?':'&' ) . 'calendar=';
+ $calendar_view_link.= '/calendar-';
+
$template->assign_block_vars(
'mode_created',
- array( 'URL' => $calendar_view_link.'created' )
+ array(
+ 'URL' => $calendar_view_link.'created'
+ )
);
+
$template->assign_block_vars(
'mode_posted',
- array( 'URL' => $calendar_view_link.'posted' )
+ array(
+ 'URL' => $calendar_view_link.'posted'
+ )
);
-
}
else
{
$template->assign_block_vars(
'mode_normal',
- array( 'URL' => $calendar_view_link )
+ array(
+ 'URL' => $calendar_view_link
+ )
);
- if (get_query_string_diff( array('start','calendar') )=='')
- {
- $calendar_view_link .= '?';
- }
- else
- {
- $calendar_view_link .= '&';
- }
- $calendar_view_link .= 'calendar=';
- if ( strpos($_GET['calendar'], 'posted') === false)
+ $calendar_view_link .= '/calendar-';
+ if ($page['chronology_type'] == 'created')
{
$template->assign_block_vars(
'mode_posted',
- array( 'URL' => $calendar_view_link.'posted' )
+ array(
+ 'URL' => $calendar_view_link.'posted'
+ )
);
}
else
{
$template->assign_block_vars(
'mode_created',
- array( 'URL' => $calendar_view_link.'created' )
+ array(
+ 'URL' => $calendar_view_link.'created'
+ )
);
}
}
$template->assign_vars(
array(
- 'NB_PICTURE' => $user['nb_total_images'],
- 'TITLE' => $template_title,
- 'USERNAME' => $user['username'],
- 'TOP_NUMBER'=>$conf['top_number'],
- 'MENU_CATEGORIES_CONTENT'=>get_categories_menu(),
-
- 'L_CATEGORIES' => $lang['categories'],
- 'L_HINT_CATEGORY' => $lang['hint_category'],
- 'L_SUBCAT' => $lang['sub-cat'],
- 'L_IMG_AVAILABLE' => $lang['images_available'],
- 'L_TOTAL' => $lang['total'],
- 'L_SPECIAL_CATEGORIES' => $lang['special_categories'],
- 'L_SUMMARY' => $lang['title_menu'],
- 'L_UPLOAD' => $lang['upload_picture'],
- 'L_COMMENT' => $lang['comments'],
- 'L_IDENTIFY' => $lang['identification'],
- 'L_PASSWORD' => $lang['password'],
- 'L_HELLO' => $lang['hello'],
- 'L_REGISTER' => $lang['ident_register'],
- 'L_LOGOUT' => $lang['logout'],
- 'L_ADMIN' => $lang['admin'],
- 'L_ADMIN_HINT' => $lang['hint_admin'],
- 'L_PROFILE' => $lang['customize'],
- 'L_PROFILE_HINT' => $lang['hint_customize'],
- 'L_REMEMBER_ME' => $lang['remember_me'],
-
- 'F_IDENTIFY' => PHPWG_ROOT_PATH.'identification.php',
- 'T_RECENT' => $icon_recent,
-
- 'U_HOME' => PHPWG_ROOT_PATH.'category.php',
- 'U_REGISTER' => PHPWG_ROOT_PATH.'register.php',
- 'U_LOST_PASSWORD' => PHPWG_ROOT_PATH.'password.php',
- 'U_LOGOUT' => PHPWG_ROOT_PATH.'category.php?act=logout',
- 'U_ADMIN'=> PHPWG_ROOT_PATH.'admin.php',
- 'U_PROFILE'=> PHPWG_ROOT_PATH.'profile.php',
- )
-);
-
-if (isset($page['cat']) and 'search' == $page['cat'])
+ 'NB_PICTURE' => $user['nb_total_images'],
+ 'TITLE' => $template_title,
+ 'USERNAME' => $user['username'],
+ 'TOP_NUMBER' => $conf['top_number'],
+ 'MENU_CATEGORIES_CONTENT' => get_categories_menu(),
+
+ 'L_CATEGORIES' => $lang['categories'],
+ 'L_HINT_CATEGORY' => $lang['hint_category'],
+ 'L_SUBCAT' => $lang['sub-cat'],
+ 'L_IMG_AVAILABLE' => $lang['images_available'],
+ 'L_TOTAL' => $lang['total'],
+ 'L_SPECIAL_CATEGORIES' => $lang['special_categories'],
+ 'L_SUMMARY' => $lang['title_menu'],
+ 'L_UPLOAD' => $lang['upload_picture'],
+ 'L_COMMENT' => $lang['comments'],
+ 'L_IDENTIFY' => $lang['identification'],
+ 'L_PASSWORD' => $lang['password'],
+ 'L_HELLO' => $lang['hello'],
+ 'L_REGISTER' => $lang['ident_register'],
+ 'L_LOGOUT' => $lang['logout'],
+ 'L_ADMIN' => $lang['admin'],
+ 'L_ADMIN_HINT' => $lang['hint_admin'],
+ 'L_PROFILE' => $lang['customize'],
+ 'L_PROFILE_HINT' => $lang['hint_customize'],
+ 'L_REMEMBER_ME' => $lang['remember_me'],
+
+ 'F_IDENTIFY' => PHPWG_ROOT_PATH.'identification.php',
+ 'T_RECENT' => $icon_recent,
+
+ 'U_HOME' => make_index_URL(),
+ 'U_REGISTER' => PHPWG_ROOT_PATH.'register.php',
+ 'U_LOST_PASSWORD' => PHPWG_ROOT_PATH.'password.php',
+ 'U_LOGOUT' => make_index_URL().'&amp;act=logout',
+ 'U_ADMIN'=> PHPWG_ROOT_PATH.'admin.php',
+ 'U_PROFILE'=> PHPWG_ROOT_PATH.'profile.php',
+ )
+ );
+
+if ('search' == $page['section'])
{
$template->assign_block_vars(
'search_rules',
array(
- 'URL' => PHPWG_ROOT_PATH.'/search_rules.php?search_id='.$_GET['search'],
+ 'URL' => PHPWG_ROOT_PATH.'/search_rules.php?search_id='.$page['search'],
)
);
}
@@ -271,7 +244,8 @@ if (count($conf['links']) > 0)
array(
'URL' => $url,
'LABEL' => $label
- ));
+ )
+ );
}
}
//---------------------------------------------------------- special categories
@@ -283,7 +257,7 @@ if ( !$user['is_the_guest'] )
$template->assign_block_vars(
'special_cat',
array(
- 'URL' => PHPWG_ROOT_PATH.'category.php?cat=fav',
+ 'URL' => make_index_URL(array('section' => 'favorites')),
'TITLE' => $lang['favorite_cat_hint'],
'NAME' => $lang['favorite_cat']
));
@@ -292,7 +266,7 @@ if ( !$user['is_the_guest'] )
$template->assign_block_vars(
'special_cat',
array(
- 'URL' => PHPWG_ROOT_PATH.'category.php?cat=most_visited',
+ 'URL' => make_index_URL(array('section' => 'most_visited')),
'TITLE' => $lang['most_visited_cat_hint'],
'NAME' => $lang['most_visited_cat']
));
@@ -302,7 +276,7 @@ if ($conf['rate'])
$template->assign_block_vars(
'special_cat',
array(
- 'URL' => PHPWG_ROOT_PATH.'category.php?cat=best_rated',
+ 'URL' => make_index_URL(array('section' => 'best_rated')),
'TITLE' => $lang['best_rated_cat_hint'],
'NAME' => $lang['best_rated_cat']
)
@@ -320,7 +294,7 @@ $template->assign_block_vars(
$template->assign_block_vars(
'special_cat',
array(
- 'URL' => PHPWG_ROOT_PATH.'category.php?cat=recent_pics',
+ 'URL' => make_index_URL(array('section' => 'recent_pics')),
'TITLE' => $lang['recent_pics_cat_hint'],
'NAME' => $lang['recent_pics_cat']
));
@@ -328,27 +302,24 @@ $template->assign_block_vars(
$template->assign_block_vars(
'special_cat',
array(
- 'URL' => PHPWG_ROOT_PATH.'category.php?cat=recent_cats',
+ 'URL' => make_index_URL(array('section' => 'recent_cats')),
'TITLE' => $lang['recent_cats_cat_hint'],
'NAME' => $lang['recent_cats_cat']
));
+
// calendar
-if ( $conf['calendar_datefield'] == 'date_available' )
-{
- $calendar_link = 'posted';
-}
-else
-{
- $calendar_link = 'created';
-}
-$calendar_link .= '-monthly-c';
$template->assign_block_vars(
'special_cat',
array(
- 'URL' => PHPWG_ROOT_PATH.'category.php?calendar='.$calendar_link,
+ 'URL' =>
+ make_index_URL()
+ .'/calendar-'
+ .($conf['calendar_datefield'] == 'date_available' ? 'posted' : 'created')
+ .'-monthly-c',
'TITLE' => $lang['calendar_hint'],
'NAME' => $lang['calendar']
- ));
+ )
+ );
//--------------------------------------------------------------------- summary
if ($user['is_the_guest'])
@@ -385,26 +356,39 @@ else
}
// search link
-$template->assign_block_vars('summary', array(
-'TITLE'=>$lang['hint_search'],
-'NAME'=>$lang['search'],
-'U_SUMMARY'=> 'search.php',
-'REL'=> 'rel="search"'
-));
+$template->assign_block_vars(
+ 'summary',
+ array(
+ 'TITLE'=>$lang['hint_search'],
+ 'NAME'=>$lang['search'],
+ 'U_SUMMARY'=> 'search.php',
+ 'REL'=> 'rel="search"'
+ )
+ );
// comments link
-$template->assign_block_vars('summary', array(
-'TITLE'=>$lang['hint_comments'],
-'NAME'=>$lang['comments'],
-'U_SUMMARY'=> 'comments.php',
-));
+$template->assign_block_vars(
+ 'summary',
+ array(
+ 'TITLE'=>$lang['hint_comments'],
+ 'NAME'=>$lang['comments'],
+ 'U_SUMMARY'=> 'comments.php',
+ )
+ );
// about link
-$template->assign_block_vars('summary', array(
-'TITLE'=>$lang['about_page_title'],
-'NAME'=>$lang['About'],
-'U_SUMMARY'=> 'about.php?'.str_replace( '&', '&amp;', $_SERVER['QUERY_STRING'] )
-));
+$template->assign_block_vars(
+ 'summary',
+ array(
+ 'TITLE' => $lang['about_page_title'],
+ 'NAME' => $lang['About'],
+ 'U_SUMMARY' => 'about.php?'.str_replace(
+ '&',
+ '&amp;',
+ $_SERVER['QUERY_STRING']
+ )
+ )
+ );
// notification
$template->assign_block_vars(
@@ -414,96 +398,101 @@ $template->assign_block_vars(
'NAME'=>l10n('Notification'),
'U_SUMMARY'=> PHPWG_ROOT_PATH.'notification.php',
'REL'=> 'rel="nofollow"'
-));
+ )
+ );
-if (isset($page['cat'])
- and is_numeric($page['cat'])
- and is_admin())
+if (isset($page['category']) and is_admin())
{
$template->assign_block_vars(
'edit',
array(
'URL' =>
- PHPWG_ROOT_PATH.'admin.php?page=cat_modify'
- .'&amp;cat_id='.$page['cat']
+ PHPWG_ROOT_PATH.'admin.php?page=cat_modify'
+ .'&amp;cat_id='.$page['category']
)
);
}
//------------------------------------------------------ main part : thumbnails
-if ( isset($page['thumbnails_include']) )
+if (isset($page['thumbnails_include']))
{
include(PHPWG_ROOT_PATH.$page['thumbnails_include']);
}
//------------------------------------------------------- category informations
-if ( $page['navigation_bar'] != ''
- or ( isset( $page['comment'] ) and $page['comment'] != '' ) )
+if (
+ $page['navigation_bar'] != ''
+ or (isset($page['comment']) and $page['comment'] != '')
+ )
{
$template->assign_block_vars('cat_infos',array());
}
// navigation bar
-if ( $page['navigation_bar'] != '' )
+if ($page['navigation_bar'] != '')
{
$template->assign_block_vars(
'cat_infos.navigation',
- array('NAV_BAR' => $page['navigation_bar'])
+ array(
+ 'NAV_BAR' => $page['navigation_bar'],
+ )
);
}
-if ( ( isset($page['cat_nb_images']) and $page['cat_nb_images']>0 )
- and
- ( !isset($page['cat'])
- or ($page['cat'] != 'most_visited' and $page['cat'] != 'best_rated') )
- )
+if (isset($page['cat_nb_images']) and $page['cat_nb_images'] > 0
+ and $page['section'] != 'most_visited'
+ and $page['section'] != 'best_rated')
{
// image order
$template->assign_block_vars( 'preferred_image_order', array() );
- $order_idx = isset($_COOKIE['pwg_image_order']) ?
- $_COOKIE['pwg_image_order'] : 0;
+ $order_idx = isset($_COOKIE['pwg_image_order'])
+ ? $_COOKIE['pwg_image_order']
+ : 0
+ ;
$orders = get_category_preferred_image_orders();
- for ( $i = 0; $i < count($orders); $i++)
+ for ($i = 0; $i < count($orders); $i++)
{
if ($orders[$i][2])
{
- $url = PHPWG_ROOT_PATH.'category.php'
- .get_query_string_diff(array('image_order'));
- $url .= '&amp;image_order='.$i;
- $template->assign_block_vars( 'preferred_image_order.order', array(
- 'DISPLAY' => $orders[$i][0],
- 'URL' => $url,
- 'SELECTED_OPTION' => ($order_idx==$i ? 'SELECTED' : '' ),
- ) );
+ $template->assign_block_vars(
+ 'preferred_image_order.order',
+ array(
+ 'DISPLAY' => $orders[$i][0],
+ 'URL' => duplicate_index_URL().'&amp;image_order='.$i,
+ 'SELECTED_OPTION' => ($order_idx==$i ? 'SELECTED' : ''),
+ )
+ );
}
}
}
-if ( isset ( $page['cat'] ) )
+if (isset($page['category']))
{
// upload a picture in the category
- if (is_numeric($page['cat'])
-// and $page['cat_site_id'] == 1
- and $page['cat_dir'] != ''
- and $page['cat_uploadable'])
+ if ($page['cat_uploadable'])
{
- $url = PHPWG_ROOT_PATH.'upload.php?cat='.$page['cat'];
+ $url = PHPWG_ROOT_PATH.'upload.php?cat='.$page['category'];
$template->assign_block_vars(
'upload',
- array('U_UPLOAD'=> $url )
+ array(
+ 'U_UPLOAD'=> $url
+ )
);
}
+
// category comment
- if ( isset( $page['comment'] ) and $page['comment'] != '' )
+ if (isset($page['comment']) and $page['comment'] != '')
{
$template->assign_block_vars(
'cat_infos.comment',
- array('COMMENTS' => $page['comment'])
+ array(
+ 'COMMENTS' => $page['comment']
+ )
);
}
}
//------------------------------------------------------------ log informations
-pwg_log( 'category', $page['title'] );
+pwg_log('category', $page['title']);
$template->parse('category');
include(PHPWG_ROOT_PATH.'include/page_tail.php');
diff --git a/comments.php b/comments.php
index fa18ada15..8fa0dec3c 100644
--- a/comments.php
+++ b/comments.php
@@ -184,7 +184,7 @@ $template->assign_vars(
'F_KEYWORD'=>@$_GET['keyword'],
'F_AUTHOR'=>@$_GET['author'],
- 'U_HOME' => PHPWG_ROOT_PATH.'category.php'
+ 'U_HOME' => make_index_url(),
)
);
diff --git a/identification.php b/identification.php
index a5b14b825..df2df9b87 100644
--- a/identification.php
+++ b/identification.php
@@ -64,7 +64,7 @@ SELECT '.$conf['user_fields']['id'].' AS id,
$remember_me = true;
}
log_user( $row['id'], $remember_me);
- redirect(empty($redirect_to) ? 'category.php' : $redirect_to);
+ redirect(empty($redirect_to) ? make_index_url() : $redirect_to);
}
else
{
@@ -94,7 +94,7 @@ $template->assign_vars(
'U_REGISTER' => PHPWG_ROOT_PATH.'register.php',
'U_LOST_PASSWORD' => PHPWG_ROOT_PATH.'password.php',
- 'U_HOME' => PHPWG_ROOT_PATH.'category.php',
+ 'U_HOME' => make_index_url(),
'U_REDIRECT' => $redirect_to,
'F_LOGIN_ACTION' => PHPWG_ROOT_PATH.'identification.php'
diff --git a/include/category_default.inc.php b/include/category_default.inc.php
index e401aec9b..599c527a9 100644
--- a/include/category_default.inc.php
+++ b/include/category_default.inc.php
@@ -26,7 +26,7 @@
// +-----------------------------------------------------------------------+
/**
- * This file is included by category.php to show thumbnails for the default
+ * This file is included by the main page to show thumbnails for the default
* case
*
*/
@@ -81,25 +81,39 @@ foreach ($pictures as $row)
}
// url link on picture.php page
- $url_link = PHPWG_ROOT_PATH.'picture.php?image_id='.$row['id'];
+ $url_link = PHPWG_ROOT_PATH.'picture.php?/'.$row['id'];
- if (isset($page['cat']))
+ switch ($page['section'])
{
- $url_link.= '&amp;cat='.$page['cat'];
-
- if ($page['cat'] == 'search')
+ case 'categories' :
+ {
+ $url_link.= '/category/'.$page['category'];
+ break;
+ }
+ case 'tags' :
+ {
+ // TODO
+ break;
+ }
+ case 'search' :
{
- $url_link.= '&amp;search='.$_GET['search'];
+ $url_link.= '/search/'.$page['search'];
+ break;
}
- else if ($page['cat'] == 'list')
+ case 'list' :
{
- $url_link.= '&amp;list='.$_GET['list'];
+ $url_link.= '/list/'.implode(',', $page['list']);
+ break;
+ }
+ default :
+ {
+ $url_link.= '/'.$page['section'];
}
}
- if (isset($_GET['calendar']))
+ if (isset($page['chronology']))
{
- $url_link.= '&amp;calendar='.$_GET['calendar'];
+ $url_link.= '/chronology='.$page['chronology'];
}
$template->assign_block_vars(
@@ -125,20 +139,23 @@ foreach ($pictures as $row)
{
$name = str_replace('_', ' ', get_filename_wo_extension($row['file']));
}
- if ( isset($page['cat']) )
+
+ switch ($page['section'])
{
- if ($page['cat'] == 'best_rated')
+ case 'best_rated' :
{
$name = '('.$row['average_rate'].') '.$name;
+ break;
}
- elseif ($page['cat'] == 'most_visited')
+ case 'most_visited' :
{
$name = '('.$row['hit'].') '.$name;
+ break;
}
-
- if ($page['cat'] == 'search')
+ case 'search' :
{
$name = replace_search($name, $_GET['search']);
+ break;
}
}
@@ -151,7 +168,7 @@ foreach ($pictures as $row)
}
if ($user['show_nb_comments']
- and is_numeric($page['cat'])
+ and isset($page['category'])
and $page['cat_commentable'])
{
$query = '
diff --git a/include/category_recent_cats.inc.php b/include/category_recent_cats.inc.php
index 298def21d..2bc028ced 100644
--- a/include/category_recent_cats.inc.php
+++ b/include/category_recent_cats.inc.php
@@ -26,7 +26,7 @@
// +-----------------------------------------------------------------------+
/**
- * This file is included by category.php to show thumbnails for recent_cats
+ * This file is included by the main page to show thumbnails for recent_cats
* category
*
*/
@@ -65,27 +65,25 @@ $conf['level_separator'] = '<br />';
// the name to display
while ( $row = mysql_fetch_array( $result ) )
{
- $name = get_cat_display_name_cache($row['uppercats'], '', false);
-
- $thumbnail_src = get_thumbnail_src($row['path'], @$row['tn_ext']);
-
- $url_link = PHPWG_ROOT_PATH.'category.php?cat='.$row['category_id'];
-
$template->assign_block_vars(
'thumbnails.line.thumbnail',
array(
- 'IMAGE' => $thumbnail_src,
- 'IMAGE_ALT' => $row['file'],
- 'IMAGE_TITLE' => $lang['hint_category'],
-
- 'U_IMG_LINK' => $url_link
+ 'IMAGE' => get_thumbnail_src($row['path'], @$row['tn_ext']),
+ 'IMAGE_ALT' => $row['file'],
+ 'IMAGE_TITLE' => $lang['hint_category'],
+
+ 'U_IMG_LINK' => make_index_url(
+ array(
+ 'category' => $row['category_id'],
+ )
+ ),
)
);
$template->assign_block_vars(
'thumbnails.line.thumbnail.category_name',
array(
- 'NAME' => $name
+ 'NAME' => get_cat_display_name_cache($row['uppercats'], '', false),
)
);
diff --git a/include/category_subcats.inc.php b/include/category_subcats.inc.php
index 5f64a3a7f..3aa091269 100644
--- a/include/category_subcats.inc.php
+++ b/include/category_subcats.inc.php
@@ -26,7 +26,7 @@
// +-----------------------------------------------------------------------+
/**
- * This file is included by category.php to show thumbnails for a category
+ * This file is included by the main page to show thumbnails for a category
* that have only subcategories
*
*/
@@ -34,16 +34,8 @@
$query = '
SELECT id, name, date_last, representative_picture_id
FROM '.CATEGORIES_TABLE.'
- WHERE id_uppercat ';
-if (!isset($page['cat']) or !is_numeric($page['cat']))
-{
- $query.= 'is NULL';
-}
-else
-{
- $query.= '= '.$page['cat'];
-}
- $query.= '
+ WHERE id_uppercat '.
+ (!isset($page['category']) ? 'is NULL' : '= '.$page['category']).'
AND id NOT IN ('.$user['forbidden_categories'].')
ORDER BY rank
;';
@@ -142,17 +134,19 @@ SELECT id, path, tn_ext
foreach ($cat_thumbnails as $item)
{
- $url_link = PHPWG_ROOT_PATH.'category.php?cat='.$row['id'];
-
$template->assign_block_vars(
'thumbnails.line.thumbnail',
array(
- 'IMAGE' => $images[$item['picture']],
- 'IMAGE_ALT' => $item['name'],
+ 'IMAGE' => $images[$item['picture']],
+ 'IMAGE_ALT' => $item['name'],
'IMAGE_TITLE' => $lang['hint_category'],
- 'IMAGE_TS' => get_icon(@$item['date_last']),
- 'U_IMG_LINK' =>
- PHPWG_ROOT_PATH.'category.php?cat='.$item['category']
+ 'IMAGE_TS' => get_icon(@$item['date_last']),
+
+ 'U_IMG_LINK' => make_index_url(
+ array(
+ 'category' => $item['category'],
+ )
+ ),
)
);
diff --git a/include/functions.inc.php b/include/functions.inc.php
index 205b61a70..9b628a93c 100644
--- a/include/functions.inc.php
+++ b/include/functions.inc.php
@@ -582,10 +582,12 @@ function get_thumbnail_src($path, $tn_ext = '')
if ($tn_ext != '')
{
- $src = substr_replace(get_filename_wo_extension($path),
- '/thumbnail/'.$conf['prefix_thumbnail'],
- strrpos($path,'/'),
- 1);
+ $src = substr_replace(
+ get_filename_wo_extension($path),
+ '/thumbnail/'.$conf['prefix_thumbnail'],
+ strrpos($path,'/'),
+ 1
+ );
$src.= '.'.$tn_ext;
}
else
@@ -1000,4 +1002,223 @@ function get_available_upgrade_ids()
return $available_upgrade_ids;
}
+
+/**
+ * build an index URL for a specific section
+ *
+ * @param array
+ * @return string
+ */
+function make_index_URL($params = array())
+{
+ $url =
+ PHPWG_ROOT_PATH.'category.php?'
+ .'/'.make_section_in_URL($params)
+ ;
+
+ if (isset($params['start']) and $params['start'] > 0)
+ {
+ $url.= '/start-'.$params['start'];
+ }
+
+ return $url;
+}
+
+/**
+ * build an index URL with current page parameters, but with redefinitions
+ * and removes.
+ *
+ * duplicate_index_URL(array('category' => 12), array('start')) will create
+ * an index URL on the current section (categories), but on a redefined
+ * category and without the start URL parameter.
+ *
+ * @param array redefined keys
+ * @param array removed keys
+ * @return string
+ */
+function duplicate_index_URL($redefined = array(), $removed = array())
+{
+ return make_index_URL(
+ params_for_duplication($redefined, $removed)
+ );
+}
+
+/**
+ * returns $page global array with key redefined and key removed
+ *
+ * @param array redefined keys
+ * @param array removed keys
+ * @return array
+ */
+function params_for_duplication($redefined, $removed)
+{
+ global $page;
+
+ if (count($removed) > 0)
+ {
+ $params = array();
+
+ foreach ($page as $page_item_key => $page_item_value)
+ {
+ if (!in_array($page_item_key, $removed))
+ {
+ $params[$page_item_key] = $page_item_value;
+ }
+ }
+ }
+ else
+ {
+ $params = $page;
+ }
+
+ foreach ($redefined as $redefined_param => $redefined_value)
+ {
+ $params[$redefined_param] = $redefined_value;
+ }
+
+ return $params;
+}
+
+/**
+ * create a picture URL with current page parameters, but with redefinitions
+ * and removes. See duplicate_index_URL.
+ *
+ * @param array redefined keys
+ * @param array removed keys
+ * @return string
+ */
+function duplicate_picture_URL($redefined = array(), $removed = array())
+{
+ return make_picture_URL(
+ params_for_duplication($redefined, $removed)
+ );
+}
+
+/**
+ * create a picture URL on a specific section for a specific picture
+ *
+ * @param array
+ * @return string
+ */
+function make_picture_URL($params)
+{
+ if (!isset($params['image_id']))
+ {
+ die('make_picture_URL: image_id is a required parameter');
+ }
+
+ $url =
+ PHPWG_ROOT_PATH.'picture.php?'
+ .'/'.$params['image_id']
+ .'/'.make_section_in_URL($params)
+ ;
+
+ // first comment to start on
+ if (isset($params['start']) and $params['start'] > 0)
+ {
+ $url.= '/start-'.$params['start'];
+ }
+
+ return $url;
+}
+
+/**
+ * return the section token of an index or picture URL.
+ *
+ * Depending on section, other parameters are required (see function code
+ * for details)
+ *
+ * @param array
+ * @return string
+ */
+function make_section_in_URL($params)
+{
+ $section_string = '';
+
+ if (!isset($params['section']))
+ {
+ if (isset($params['section']))
+ {
+ $params['section'] = 'categories';
+ }
+ else if (isset($params['tags']))
+ {
+ $params['section'] = 'tags';
+ }
+ else if (isset($params['list']))
+ {
+ $params['section'] = 'list';
+ }
+ else if (isset($params['search']))
+ {
+ $params['section'] = 'search';
+ }
+ }
+
+ if (!isset($params['section']))
+ {
+ $params['section'] = 'categories';
+ }
+
+ switch($params['section'])
+ {
+ case 'categories' :
+ {
+ if (!isset($params['category']))
+ {
+ $section_string.= 'categories';
+ }
+ else
+ {
+ $section_string.= 'category/'.$params['category'];
+ }
+
+ break;
+ }
+ case 'tags' :
+ {
+ if (!isset($params['tags']) or count($params['tags']) == 0)
+ {
+ die('make_section_in_URL: require at least one tag');
+ }
+
+ $section_string.= 'tags';
+
+ foreach ($params['tags'] as $tag)
+ {
+ $section_string.= '/'.$tag;
+ }
+
+ break;
+ }
+ case 'search' :
+ {
+ if (!isset($params['search']))
+ {
+ die('make_section_in_URL: require a search identifier');
+ }
+
+ $section_string.= 'search/'.$params['search'];
+
+ break;
+ }
+ case 'list' :
+ {
+ if (!isset($params['list']))
+ {
+ die('make_section_in_URL: require a list of items');
+ }
+
+ $section_string.= 'list/'.implode(',', $params['list']);
+
+ break;
+ }
+ default :
+ {
+ $section_string.= $params['section'];
+ }
+ }
+
+ return $section_string;
+}
?>
diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php
index 2bc455775..8b5bd58a4 100644
--- a/include/functions_category.inc.php
+++ b/include/functions_category.inc.php
@@ -46,16 +46,13 @@ function check_restrictions($category_id)
if (in_array($category_id, explode(',', $user['forbidden_categories'])))
{
- $login_url = './identification.php?redirect='.
- urlencode(urlencode($_SERVER['REQUEST_URI']));
- if ( ! $user['is_the_guest'] )
+ $login_url =
+ './identification.php?redirect='
+ .urlencode(urlencode($_SERVER['REQUEST_URI']));
+
+ if (!$user['is_the_guest'])
{
- echo '<div style="text-align:center;">';
- echo $lang['hello'].' '.$user['username'].'! ';
- echo $lang['access_forbiden'].'<br />';
- echo '<a href="./category.php">'.$lang['thumbnails'].'</a> ';
- echo '</div>';
- exit();
+ die('Fatal: you are trying to reach a forbidden category');
}
else
{
diff --git a/include/functions_html.inc.php b/include/functions_html.inc.php
index d6bcdaf63..6e8a6c4d8 100644
--- a/include/functions_html.inc.php
+++ b/include/functions_html.inc.php
@@ -247,7 +247,7 @@ function language_select($default, $select_name = "language")
* @return string
*/
function get_cat_display_name($cat_informations,
- $url = 'category.php?cat=',
+ $url = 'category.php?/category/',
$replace_space = true)
{
global $conf;
@@ -300,7 +300,7 @@ function get_cat_display_name($cat_informations,
* @return string
*/
function get_cat_display_name_cache($uppercats,
- $url = 'category.php?cat=',
+ $url = 'category.php?/category/',
$replace_space = true)
{
global $cat_names, $conf;
@@ -355,7 +355,7 @@ SELECT id,name
}
/**
- * returns the HTML code for a category item in the menu (for category.php)
+ * returns the HTML code for a category item in the menu (for the main page)
*
* HTML code generated uses logical list tags ul and each category is an
* item li. The paramter given is the category informations as an array,
@@ -374,10 +374,11 @@ function get_html_menu_category($categories)
// $page_cat value remains 0 for special sections
$page_cat = 0;
- if (isset($page['cat']) and is_numeric($page['cat']) )
+ if (isset($page['category']))
{
- $page_cat = $page['cat'];
+ $page_cat = $page['category'];
}
+
foreach ($categories as $category)
{
$level = substr_count($category['global_rank'], '.') + 1;
@@ -404,7 +405,8 @@ function get_html_menu_category($categories)
}
$menu.= '>';
- $url = PHPWG_ROOT_PATH.'category.php?cat='.$category['id'];
+ $url = make_index_url(array('category' => $category['id']));
+
$menu.= "\n".'<a href="'.$url.'"';
if ($page_cat != 0
and $category['id'] == $page['cat_id_uppercat'])
@@ -466,7 +468,7 @@ function parse_comment_content($content)
}
function get_cat_display_name_from_id($cat_id,
- $url = 'category.php?cat=',
+ $url = 'category.php?/category/',
$replace_space = true)
{
$cat_info = get_cat_info($cat_id);
diff --git a/include/index.php b/include/index.php
index 84199eb29..0f1d97083 100644
--- a/include/index.php
+++ b/include/index.php
@@ -24,7 +24,8 @@
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
// | USA. |
// +-----------------------------------------------------------------------+
-$url = '../category.php';
+
+$url = '../index.php';
header( 'Request-URI: '.$url );
header( 'Content-Location: '.$url );
header( 'Location: '.$url );
diff --git a/include/picture_comment.inc.php b/include/picture_comment.inc.php
new file mode 100644
index 000000000..79373d2f7
--- /dev/null
+++ b/include/picture_comment.inc.php
@@ -0,0 +1,229 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | PhpWebGallery - a PHP based picture gallery |
+// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
+// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
+// +-----------------------------------------------------------------------+
+// | branch : BSF (Best So Far)
+// | file : $RCSfile$
+// | last update : $Date: 2006-03-09 00:14:53 +0100 (jeu, 09 mar 2006) $
+// | last modifier : $Author: rub $
+// | revision : $Revision: 1070 $
+// +-----------------------------------------------------------------------+
+// | 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 |
+// | the Free Software Foundation |
+// | |
+// | This program is distributed in the hope that it will be useful, but |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
+// | General Public License for more details. |
+// | |
+// | You should have received a copy of the GNU General Public License |
+// | along with this program; if not, write to the Free Software |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA. |
+// +-----------------------------------------------------------------------+
+
+/**
+ * This file is included by the picture page to manage user comments
+ *
+ */
+
+if ( isset( $_POST['content'] ) && !empty($_POST['content']) )
+{
+ $register_comment = true;
+ $author = !empty($_POST['author'])?$_POST['author']:$lang['guest'];
+ // if a guest try to use the name of an already existing user, he must be
+ // rejected
+ if ( $author != $user['username'] )
+ {
+ $query = 'SELECT COUNT(*) AS user_exists';
+ $query.= ' FROM '.USERS_TABLE;
+ $query.= ' WHERE '.$conf['user_fields']['username']." = '".$author."'";
+ $query.= ';';
+ $row = mysql_fetch_array( pwg_query( $query ) );
+ if ( $row['user_exists'] == 1 )
+ {
+ $template->assign_block_vars(
+ 'information',
+ array('INFORMATION'=>$lang['comment_user_exists']));
+ $register_comment = false;
+ }
+ }
+
+ if ( $register_comment )
+ {
+ // anti-flood system
+ $reference_date = time() - $conf['anti-flood_time'];
+ $query = 'SELECT id FROM '.COMMENTS_TABLE;
+ $query.= ' WHERE date > FROM_UNIXTIME('.$reference_date.')';
+ $query.= " AND author = '".$author."'";
+ $query.= ';';
+ if ( mysql_num_rows( pwg_query( $query ) ) == 0
+ or $conf['anti-flood_time'] == 0 )
+ {
+ list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();'));
+
+ $data = array();
+ $data{'author'} = $author;
+ $data{'date'} = $dbnow;
+ $data{'image_id'} = $page['image_id'];
+ $data{'content'} = htmlspecialchars( $_POST['content'], ENT_QUOTES);
+
+ if (!$conf['comments_validation'] or is_admin())
+ {
+ $data{'validated'} = 'true';
+ $data{'validation_date'} = $dbnow;
+ }
+ else
+ {
+ $data{'validated'} = 'false';
+ }
+
+ include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
+ $fields = array('author', 'date', 'image_id', 'content', 'validated',
+ 'validation_date');
+ mass_inserts(COMMENTS_TABLE, $fields, array($data));
+
+ // information message
+ $message = $lang['comment_added'];
+
+ if (!$conf['comments_validation'] or is_admin())
+
+ if ( $conf['comments_validation'] and !is_admin() )
+ {
+ $message.= '<br />'.$lang['comment_to_validate'];
+ }
+ $template->assign_block_vars('information',
+ array('INFORMATION'=>$message));
+ }
+ else
+ {
+ // information message
+ $template->assign_block_vars(
+ 'information',
+ array('INFORMATION'=>$lang['comment_anti-flood']));
+ }
+ }
+}
+
+// the picture is commentable if it belongs at least to one category which
+// is commentable
+$page['show_comments'] = false;
+foreach ($related_categories as $category)
+{
+ if ($category['commentable'] == 'true')
+ {
+ $page['show_comments'] = true;
+ }
+}
+
+if ($page['show_comments'])
+{
+ // number of comment for this picture
+ $query = 'SELECT COUNT(*) AS nb_comments';
+ $query.= ' FROM '.COMMENTS_TABLE.' WHERE image_id = '.$page['image_id'];
+ $query.= " AND validated = 'true'";
+ $query.= ';';
+ $row = mysql_fetch_array( pwg_query( $query ) );
+
+ // navigation bar creation
+ $url = PHPWG_ROOT_PATH.'picture.php';
+ $url.= get_query_string_diff(array('add_fav','start'));
+
+// $url = duplicate_picture_URL(
+// array(),
+// array('start')
+// );
+
+ if (!isset($_GET['start'])
+ or !is_numeric($_GET['start'])
+ or (is_numeric($_GET['start']) and $_GET['start'] < 0))
+ {
+ $page['start'] = 0;
+ }
+ else
+ {
+ $page['start'] = $_GET['start'];
+ }
+ $page['navigation_bar'] = create_navigation_bar(
+ $url,
+ $row['nb_comments'],
+ $page['start'],
+ $conf['nb_comment_page'],
+ ''
+ );
+
+ $template->assign_block_vars(
+ 'comments',
+ array(
+ 'NB_COMMENT' => $row['nb_comments'],
+ 'NAV_BAR' => $page['navigation_bar'],
+ )
+ );
+
+ if ($row['nb_comments'] > 0)
+ {
+ $query = '
+SELECT id,author,date,image_id,content
+ FROM '.COMMENTS_TABLE.'
+ WHERE image_id = '.$page['image_id'].'
+ AND validated = \'true\'
+ ORDER BY date ASC
+ LIMIT '.$page['start'].', '.$conf['nb_comment_page'].'
+;';
+ $result = pwg_query( $query );
+
+ while ($row = mysql_fetch_array($result))
+ {
+ $template->assign_block_vars(
+ 'comments.comment',
+ array(
+ 'COMMENT_AUTHOR' => empty($row['author'])
+ ? $lang['guest']
+ : $row['author'],
+
+ 'COMMENT_DATE' => format_date(
+ $row['date'],
+ 'mysql_datetime',
+ true),
+
+ 'COMMENT' => parse_comment_content($row['content']),
+ )
+ );
+
+ if (is_admin())
+ {
+ $template->assign_block_vars(
+ 'comments.comment.delete',
+ array(
+ 'U_COMMENT_DELETE' => $url.'&amp;del='.$row['id']
+ )
+ );
+ }
+ }
+ }
+
+ if (!$user['is_the_guest']
+ or ($user['is_the_guest'] and $conf['comments_forall']))
+ {
+ $template->assign_block_vars('comments.add_comment', array());
+ // display author field if the user is not logged in
+ if (!$user['is_the_guest'])
+ {
+ $template->assign_block_vars(
+ 'comments.add_comment.author_known',
+ array('KNOWN_AUTHOR'=>$user['username'])
+ );
+ }
+ else
+ {
+ $template->assign_block_vars(
+ 'comments.add_comment.author_field', array()
+ );
+ }
+ }
+}
+
+?> \ No newline at end of file
diff --git a/include/picture_metadata.inc.php b/include/picture_metadata.inc.php
new file mode 100644
index 000000000..de910ad07
--- /dev/null
+++ b/include/picture_metadata.inc.php
@@ -0,0 +1,127 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | PhpWebGallery - a PHP based picture gallery |
+// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
+// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
+// +-----------------------------------------------------------------------+
+// | branch : BSF (Best So Far)
+// | file : $RCSfile$
+// | last update : $Date: 2006-03-09 00:14:53 +0100 (jeu, 09 mar 2006) $
+// | last modifier : $Author: rub $
+// | revision : $Revision: 1070 $
+// +-----------------------------------------------------------------------+
+// | 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 |
+// | the Free Software Foundation |
+// | |
+// | This program is distributed in the hope that it will be useful, but |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
+// | General Public License for more details. |
+// | |
+// | You should have received a copy of the GNU General Public License |
+// | along with this program; if not, write to the Free Software |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA. |
+// +-----------------------------------------------------------------------+
+
+/**
+ * This file is included by the picture page to manage picture metadata
+ *
+ */
+
+if ($metadata_showable and isset($_GET['show_metadata']))
+{
+ include_once(PHPWG_ROOT_PATH.'/include/functions_metadata.inc.php');
+ $template->assign_block_vars('metadata', array());
+ if ($conf['show_exif'])
+ {
+ if (!function_exists('read_exif_data'))
+ {
+ die('Exif extension not available, admin should disable exif display');
+ }
+
+ if ($exif = @read_exif_data($picture['current']['src']))
+ {
+ $template->assign_block_vars(
+ 'metadata.headline',
+ array('TITLE' => 'EXIF Metadata')
+ );
+
+ foreach ($conf['show_exif_fields'] as $field)
+ {
+ if (strpos($field, ';') === false)
+ {
+ if (isset($exif[$field]))
+ {
+ $key = $field;
+ if (isset($lang['exif_field_'.$field]))
+ {
+ $key = $lang['exif_field_'.$field];
+ }
+
+ $template->assign_block_vars(
+ 'metadata.line',
+ array(
+ 'KEY' => $key,
+ 'VALUE' => $exif[$field]
+ )
+ );
+ }
+ }
+ else
+ {
+ $tokens = explode(';', $field);
+ if (isset($exif[$tokens[0]][$tokens[1]]))
+ {
+ $key = $tokens[1];
+ if (isset($lang['exif_field_'.$tokens[1]]))
+ {
+ $key = $lang['exif_field_'.$tokens[1]];
+ }
+
+ $template->assign_block_vars(
+ 'metadata.line',
+ array(
+ 'KEY' => $key,
+ 'VALUE' => $exif[$tokens[0]][$tokens[1]]
+ )
+ );
+ }
+ }
+ }
+ }
+ }
+ if ($conf['show_iptc'])
+ {
+ $iptc = get_iptc_data($picture['current']['src'],
+ $conf['show_iptc_mapping']);
+
+ if (count($iptc) > 0)
+ {
+ $template->assign_block_vars(
+ 'metadata.headline',
+ array('TITLE' => 'IPTC Metadata')
+ );
+ }
+
+ foreach ($iptc as $field => $value)
+ {
+ $key = $field;
+ if (isset($lang[$field]))
+ {
+ $key = $lang[$field];
+ }
+
+ $template->assign_block_vars(
+ 'metadata.line',
+ array(
+ 'KEY' => $key,
+ 'VALUE' => $value
+ )
+ );
+ }
+ }
+}
+
+?> \ No newline at end of file
diff --git a/include/picture_rate.inc.php b/include/picture_rate.inc.php
new file mode 100644
index 000000000..67da9f0e8
--- /dev/null
+++ b/include/picture_rate.inc.php
@@ -0,0 +1,126 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | PhpWebGallery - a PHP based picture gallery |
+// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
+// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
+// +-----------------------------------------------------------------------+
+// | branch : BSF (Best So Far)
+// | file : $RCSfile$
+// | last update : $Date: 2006-03-09 00:14:53 +0100 (jeu, 09 mar 2006) $
+// | last modifier : $Author: rub $
+// | revision : $Revision: 1070 $
+// +-----------------------------------------------------------------------+
+// | 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 |
+// | the Free Software Foundation |
+// | |
+// | This program is distributed in the hope that it will be useful, but |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
+// | General Public License for more details. |
+// | |
+// | You should have received a copy of the GNU General Public License |
+// | along with this program; if not, write to the Free Software |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA. |
+// +-----------------------------------------------------------------------+
+
+/**
+ * This file is included by the picture page to manage rates
+ *
+ */
+
+$rate_items = array(0,1,2,3,4,5);
+
+if ($conf['rate'])
+{
+ $query = '
+SELECT COUNT(rate) AS count
+ , ROUND(AVG(rate),2) AS average
+ , ROUND(STD(rate),2) AS STD
+ FROM '.RATE_TABLE.'
+ WHERE element_id = '.$picture['current']['id'].'
+;';
+ $row = mysql_fetch_array(pwg_query($query));
+ if ($row['count'] == 0)
+ {
+ $value = $lang['no_rate'];
+ }
+ else
+ {
+ $value = sprintf(
+ l10n('%.2f (rated %d times, standard deviation = %.2f)'),
+ $row['average'],
+ $row['count'],
+ $row['STD']
+ );
+ }
+
+ if ($conf['rate_anonymous'] or !$user['is_the_guest'])
+ {
+ if ($row['count']>0)
+ {
+ $query = 'SELECT rate
+ FROM '.RATE_TABLE.'
+ WHERE element_id = '.$page['image_id'] . '
+ AND user_id = '.$user['id'] ;
+
+ if ($user['is_the_guest'])
+ {
+ $ip_components = explode('.', $_SERVER['REMOTE_ADDR']);
+ if ( count($ip_components)>3 )
+ {
+ array_pop($ip_components);
+ }
+ $anonymous_id = implode ('.', $ip_components);
+ $query .= ' AND anonymous_id = \''.$anonymous_id . '\'';
+ }
+
+ $result = pwg_query($query);
+ if (mysql_num_rows($result) > 0)
+ {
+ $row = mysql_fetch_array($result);
+ $sentence = $lang['already_rated'];
+ $sentence.= ' ('.$row['rate'].'). ';
+ $sentence.= $lang['update_rate'];
+ }
+ else
+ {
+ $sentence = $lang['never_rated'].'. '.$lang['Rate'];
+ }
+ }
+ else
+ {
+ $sentence = $lang['never_rated'].'. '.$lang['Rate'];
+ }
+ $template->assign_block_vars(
+ 'rate',
+ array(
+ 'CONTENT' => $value,
+ 'SENTENCE' => $sentence
+ )
+ );
+
+ $template->assign_block_vars('info_rate', array('CONTENT' => $value));
+
+ $template->assign_vars(
+ array(
+ 'INFO_RATE' => $value
+ )
+ );
+
+ foreach ($rate_items as $num => $mark)
+ {
+ $template->assign_block_vars(
+ 'rate.rate_option',
+ array(
+ 'OPTION' => $mark,
+ 'URL' => $url_self.'&amp;action=rate&amp;rate='.$mark,
+ 'SEPARATOR' => ($num > 0 ? '|' : ''),
+ )
+ );
+ }
+ }
+}
+
+?> \ No newline at end of file
diff --git a/include/section_init.inc.php b/include/section_init.inc.php
index 68b82d463..c707e1e85 100644
--- a/include/section_init.inc.php
+++ b/include/section_init.inc.php
@@ -40,55 +40,170 @@
* display
*/
-unset($page['cat']);
+// "index.php?/category/12-foo/start-24&action=fill_caddie" must return :
+//
+// array(
+// 'section' => 'categories',
+// 'category' => 12,
+// 'start' => 24
+// 'action' => 'fill_caddie'
+// );
-if (isset($_GET['cat']))
+$page['section'] = 'categories';
+
+foreach (array_keys($_GET) as $keynum => $key)
{
- if (is_numeric($_GET['cat']))
- {
- $page['cat'] = $_GET['cat'];
- }
- else if ($_GET['cat'] == 'fav'
- or $_GET['cat'] == 'most_visited'
- or $_GET['cat'] == 'best_rated'
- or $_GET['cat'] == 'recent_pics'
- or $_GET['cat'] == 'recent_cats')
- {
- $page['cat'] = $_GET['cat'];
- }
- else if ($_GET['cat'] == 'search')
+ if (0 == $keynum)
{
- if (!isset($_GET['search']))
+ // deleting first "/" if displayed
+ $tokens = explode(
+ '/',
+ preg_replace('#^/#', '', $key)
+ );
+
+ // $tokens = array(
+ // 0 => category,
+ // 1 => 12-foo,
+ // 2 => start-24
+ // );
+
+ $next_token = 0;
+
+ if (basename($_SERVER['PHP_SELF']) == 'picture.php')
{
- die('search GET parameter is missing');
+ // the first token must be the numeric identifier of the picture
+ preg_match('/(\d+)/', $tokens[$next_token], $matches);
+ if (!isset($matches[1]))
+ {
+ die('Fatal: picture identifier is missing');
+ }
+ $page['image_id'] = $matches[1];
+
+ $next_token++;
}
- else if (!is_numeric($_GET['search']))
+
+ if (0 === strpos($tokens[$next_token], 'cat'))
{
- die('wrong format on search GET parameter');
+ $page['section'] = 'categories';
+ $next_token++;
+
+ if (isset($tokens[$next_token])
+ and preg_match('/(\d+)/', $tokens[$next_token], $matches))
+ {
+ $page['category'] = $matches[1];
+ $next_token++;
+ }
}
- else
+ else if (0 === strpos($tokens[$next_token], 'tag'))
{
- $page['cat'] = 'search';
+ $page['section'] = 'tags';
+ $page['tags'] = array();
+
+ $next_token++;
+
+ for ($i = $next_token; ; $i++)
+ {
+ if (!isset($tokens[$i]))
+ {
+ break;
+ }
+
+ preg_match('/^(\d+)/', $tokens[$i], $matches);
+ if (!isset($matches[1]))
+ {
+ if (0 == count($page['tags']))
+ {
+ die('Fatal: at least one tag required');
+ }
+ else
+ {
+ break;
+ }
+ }
+ array_push($page['tags'], $matches[1]);
+ }
+
+ $next_token = $i;
}
- }
- else if ($_GET['cat'] == 'list')
- {
- if (!isset($_GET['list']))
+ else if (0 === strpos($tokens[$next_token], 'fav'))
+ {
+ $page['section'] = 'favorites';
+ $next_token++;
+ }
+ else if ('most_visited' == $tokens[$next_token])
+ {
+ $page['section'] = 'most_visited';
+ $next_token++;
+ }
+ else if ('best_rated' == $tokens[$next_token])
{
- die('list GET parameter is missing');
+ $page['section'] = 'best_rated';
+ $next_token++;
}
- else if (!preg_match('/^\d+(,\d+)*$/', $_GET['list']))
+ else if ('recent_pics' == $tokens[$next_token])
{
- die('wrong format on list GET parameter');
+ $page['section'] = 'recent_pics';
+ $next_token++;
+ }
+ else if ('recent_cats' == $tokens[$next_token])
+ {
+ $page['section'] = 'recent_cats';
+ $next_token++;
+ }
+ else if ('search' == $tokens[$next_token])
+ {
+ $page['section'] = 'search';
+ $next_token++;
+
+ preg_match('/(\d+)/', $tokens[$next_token], $matches);
+ if (!isset($matches[1]))
+ {
+ die('Fatal: search identifier is missing');
+ }
+ $page['search'] = $matches[1];
+ $next_token++;
+ }
+ else if ('list' == $tokens[$next_token])
+ {
+ $page['section'] = 'list';
+ $next_token++;
+
+ $page['list'] = array();
+ if (!preg_match('/^\d+(,\d+)*$/', $tokens[$next_token]))
+ {
+ die('wrong format on list GET parameter');
+ }
+ foreach (explode(',', $tokens[$next_token]) as $image_id)
+ {
+ array_push($page['list'], $image_id);
+ }
+ $next_token++;
}
else
{
- $page['cat'] = 'list';
+ $page['section'] = 'categories';
+ $next_token++;
+ }
+
+ for ($i = $next_token; ; $i++)
+ {
+ if (!isset($tokens[$i]))
+ {
+ break;
+ }
+
+ if (preg_match('/^start-(\d+)/', $tokens[$i], $matches))
+ {
+ $page['start'] = $matches[1];
+ }
+
+ if (preg_match('/^calendar-(.+)$/', $tokens[$i], $matches))
+ {
+ // TODO: decide with rvelices how we name calendar/chronology is the
+ // URL
+ $_GET['calendar'] = $matches[1];
+ }
}
- }
- else
- {
- die('unknown cat GET parameter value');
}
}
@@ -110,16 +225,15 @@ if (isset($_COOKIE['pwg_image_order'])
$page['super_order_by'] = true;
}
-if (isset($page['cat']))
-{
-
// +-----------------------------------------------------------------------+
// | category |
// +-----------------------------------------------------------------------+
- if (is_numeric($page['cat']))
+if ('categories' == $page['section'])
+{
+ if (isset($page['category']))
{
- $result = get_cat_info($page['cat']);
-
+ $result = get_cat_info($page['category']);
+
$page = array_merge(
$page,
array(
@@ -132,45 +246,52 @@ if (isset($page['cat']))
'cat_commentable' => $result['commentable'],
'cat_id_uppercat' => $result['id_uppercat'],
'uppercats' => $result['uppercats'],
-
+
'title' => get_cat_display_name($result['name'], '', false),
)
);
- if ( !isset($_GET['calendar']) )
+
+ if (!isset($_GET['calendar']))
{
$query = '
SELECT image_id
FROM '.IMAGE_CATEGORY_TABLE.'
INNER JOIN '.IMAGES_TABLE.' ON id = image_id
- WHERE category_id = '.$page['cat'].'
+ WHERE category_id = '.$page['category'].'
'.$conf['order_by'].'
;';
$page['items'] = array_from_query($query, 'image_id');
+
$page['thumbnails_include'] =
- $result['nb_images'] > 0
- ? 'include/category_default.inc.php'
- : 'include/category_subcats.inc.php';
- }//otherwise the calendar will requery all subitems
+ $result['nb_images'] > 0
+ ? 'include/category_default.inc.php'
+ : 'include/category_subcats.inc.php';
+ } //otherwise the calendar will requery all subitems
}
- // special section
else
{
- if (!empty($user['forbidden_categories']))
- {
- $forbidden =
- ' category_id NOT IN ('.$user['forbidden_categories'].')';
- }
- else
- {
- $forbidden = ' 1=1';
- }
-
+ $page['title'] = $lang['no_category'];
+ $page['thumbnails_include'] = 'include/category_subcats.inc.php';
+ }
+}
+// special sections
+else
+{
+ if (!empty($user['forbidden_categories']))
+ {
+ $forbidden =
+ ' category_id NOT IN ('.$user['forbidden_categories'].')';
+ }
+ else
+ {
+ $forbidden = ' 1 = 1';
+ }
// +-----------------------------------------------------------------------+
// | search section |
// +-----------------------------------------------------------------------+
- if ( $page['cat'] == 'search' )
- {
- $query = '
+ if ($page['section'] == 'search')
+ {
+ $query = '
SELECT DISTINCT(id)
FROM '.IMAGES_TABLE.'
INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id
@@ -179,23 +300,23 @@ SELECT DISTINCT(id)
'.$conf['order_by'].'
;';
- $page = array_merge(
- $page,
- array(
- 'title' => $lang['search_result'],
- 'items' => array_from_query($query, 'id'),
- 'thumbnails_include' => 'include/category_default.inc.php',
- )
- );
- }
+ $page = array_merge(
+ $page,
+ array(
+ 'title' => $lang['search_result'],
+ 'items' => array_from_query($query, 'id'),
+ 'thumbnails_include' => 'include/category_default.inc.php',
+ )
+ );
+ }
// +-----------------------------------------------------------------------+
// | favorite section |
// +-----------------------------------------------------------------------+
- else if ($page['cat'] == 'fav')
- {
- check_user_favorites();
+ else if ($page['section'] == 'favorites')
+ {
+ check_user_favorites();
- $query = '
+ $query = '
SELECT image_id
FROM '.FAVORITES_TABLE.'
INNER JOIN '.IMAGES_TABLE.' ON image_id = id
@@ -203,147 +324,146 @@ SELECT image_id
'.$conf['order_by'].'
;';
- $page = array_merge(
- $page,
- array(
- 'title' => $lang['favorites'],
- 'items' => array_from_query($query, 'image_id'),
- 'thumbnails_include' => 'include/category_default.inc.php',
- )
- );
- }
+ $page = array_merge(
+ $page,
+ array(
+ 'title' => $lang['favorites'],
+ 'items' => array_from_query($query, 'image_id'),
+ 'thumbnails_include' => 'include/category_default.inc.php',
+ )
+ );
+ }
// +-----------------------------------------------------------------------+
// | recent pictures section |
// +-----------------------------------------------------------------------+
- else if ($page['cat'] == 'recent_pics')
- {
- $query = '
+ else if ($page['section'] == 'recent_pics')
+ {
+ $query = '
SELECT DISTINCT(id)
FROM '.IMAGES_TABLE.'
INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id
WHERE date_available > \''.
- date('Y-m-d', time() - 60*60*24*$user['recent_period']).'\'
+ date('Y-m-d', time() - 60*60*24*$user['recent_period']).'\'
AND '.$forbidden.'
'.$conf['order_by'].'
;';
- $page = array_merge(
- $page,
- array(
- 'title' => $lang['recent_pics_cat'],
- 'items' => array_from_query($query, 'id'),
- 'thumbnails_include' => 'include/category_default.inc.php',
- )
- );
- }
+ $page = array_merge(
+ $page,
+ array(
+ 'title' => $lang['recent_pics_cat'],
+ 'items' => array_from_query($query, 'id'),
+ 'thumbnails_include' => 'include/category_default.inc.php',
+ )
+ );
+ }
// +-----------------------------------------------------------------------+
// | recently updated categories section |
// +-----------------------------------------------------------------------+
- else if ($page['cat'] == 'recent_cats')
- {
- $page = array_merge(
- $page,
- array(
- 'title' => $lang['recent_cats_cat'],
- 'cat_nb_images' => 0,
- 'thumbnails_include' => 'include/category_recent_cats.inc.php',
- )
- );
- }
+ else if ($page['section'] == 'recent_cats')
+ {
+ $page = array_merge(
+ $page,
+ array(
+ 'title' => $lang['recent_cats_cat'],
+ 'cat_nb_images' => 0,
+ 'thumbnails_include' => 'include/category_recent_cats.inc.php',
+ )
+ );
+ }
// +-----------------------------------------------------------------------+
// | most visited section |
// +-----------------------------------------------------------------------+
- else if ($page['cat'] == 'most_visited')
- {
- $page['super_order_by'] = true;
- $conf['order_by'] = ' ORDER BY hit DESC, file ASC';
- $query = '
+ else if ($page['section'] == 'most_visited')
+ {
+ $page['super_order_by'] = true;
+ $conf['order_by'] = ' ORDER BY hit DESC, file ASC';
+ $query = '
SELECT DISTINCT(id)
FROM '.IMAGES_TABLE.'
INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id
WHERE hit > 0
- AND '.$forbidden.
- $conf['order_by'].'
+ AND '.$forbidden.'
+ '.$conf['order_by'].'
LIMIT 0, '.$conf['top_number'].'
;';
-
- $page = array_merge(
- $page,
- array(
- 'title' => $conf['top_number'].' '.$lang['most_visited_cat'],
- 'items' => array_from_query($query, 'id'),
- 'thumbnails_include' => 'include/category_default.inc.php',
- )
- );
- }
+
+ $page = array_merge(
+ $page,
+ array(
+ 'title' => $conf['top_number'].' '.$lang['most_visited_cat'],
+ 'items' => array_from_query($query, 'id'),
+ 'thumbnails_include' => 'include/category_default.inc.php',
+ )
+ );
+ }
// +-----------------------------------------------------------------------+
// | best rated section |
// +-----------------------------------------------------------------------+
- else if ($page['cat'] == 'best_rated')
- {
- $page['super_order_by'] = true;
- $conf['order_by'] = ' ORDER BY average_rate DESC, id ASC';
-
- $query ='
+ else if ($page['section'] == 'best_rated')
+ {
+ $page['super_order_by'] = true;
+ $conf['order_by'] = ' ORDER BY average_rate DESC, id ASC';
+
+ $query ='
SELECT DISTINCT(id)
FROM '.IMAGES_TABLE.'
INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id
WHERE average_rate IS NOT NULL
- AND '.$forbidden.
- $conf['order_by'].'
+ AND '.$forbidden.'
+ '.$conf['order_by'].'
LIMIT 0, '.$conf['top_number'].'
;';
- $page = array_merge(
- $page,
- array(
- 'title' => $conf['top_number'].' '.$lang['best_rated_cat'],
- 'items' => array_from_query($query, 'id'),
- 'thumbnails_include' => 'include/category_default.inc.php',
- )
- );
- }
+ $page = array_merge(
+ $page,
+ array(
+ 'title' => $conf['top_number'].' '.$lang['best_rated_cat'],
+ 'items' => array_from_query($query, 'id'),
+ 'thumbnails_include' => 'include/category_default.inc.php',
+ )
+ );
+ }
// +-----------------------------------------------------------------------+
// | list section |
// +-----------------------------------------------------------------------+
- else if ($page['cat'] == 'list')
- {
- $query ='
+ else if ($page['section'] == 'list')
+ {
+ $query ='
SELECT DISTINCT(id)
FROM '.IMAGES_TABLE.'
INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id
- WHERE image_id IN ('.$_GET['list'].')
+ WHERE image_id IN ('.implode(',', $page['list']).')
AND '.$forbidden.'
'.$conf['order_by'].'
;';
- $page = array_merge(
- $page,
- array(
- 'title' => $lang['random_cat'],
- 'items' => array_from_query($query, 'id'),
- 'thumbnails_include' => 'include/category_default.inc.php',
- )
- );
- }
-
- if (!isset($page['cat_nb_images']))
- {
- $page['cat_nb_images'] = count($page['items']);
- }
+
+ $page = array_merge(
+ $page,
+ array(
+ 'title' => $lang['random_cat'],
+ 'items' => array_from_query($query, 'id'),
+ 'thumbnails_include' => 'include/category_default.inc.php',
+ )
+ );
+ }
+
+ if (!isset($page['cat_nb_images']))
+ {
+ $page['cat_nb_images'] = count($page['items']);
}
}
+
// +-----------------------------------------------------------------------+
-// | root category |
+// | chronology |
// +-----------------------------------------------------------------------+
-else
-{
- $page['title'] = $lang['no_category'];
- $page['thumbnails_include'] = 'include/category_subcats.inc.php';
-}
-if ( isset($_GET['calendar']) )
+if (isset($_GET['calendar']))
{
include_once( PHPWG_ROOT_PATH.'include/functions_calendar.inc.php' );
initialize_calendar();
}
+// echo '<pre>'; print_r($page); echo '</pre>';
+
+
?> \ No newline at end of file
diff --git a/notification.php b/notification.php
index b28472d31..b1d1d8db7 100644
--- a/notification.php
+++ b/notification.php
@@ -63,7 +63,7 @@ $template->set_filenames(array('notification'=>'notification.tpl'));
$template->assign_vars(
array(
'FEED_URL' => PHPWG_ROOT_PATH.'feed.php?feed='.$page['feed'],
- 'U_HOME' => PHPWG_ROOT_PATH.'category.php'
+ 'U_HOME' => make_index_url(),
)
);
diff --git a/password.php b/password.php
index 3a15d270f..942540253 100644
--- a/password.php
+++ b/password.php
@@ -150,7 +150,7 @@ $template->set_filenames(array('password'=>'password.tpl'));
$template->assign_vars(
array(
- 'U_HOME' => PHPWG_ROOT_PATH.'category.php'
+ 'U_HOME' => make_index_url(),
)
);
diff --git a/picture.php b/picture.php
index 6a6bab850..f95f39124 100644
--- a/picture.php
+++ b/picture.php
@@ -25,44 +25,40 @@
// | USA. |
// +-----------------------------------------------------------------------+
-$rate_items = array(0,1,2,3,4,5);
-//--------------------------------------------------------------------- include
define('PHPWG_ROOT_PATH','./');
include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
+include(PHPWG_ROOT_PATH.'include/section_init.inc.php');
-// +-----------------------------------------------------------------------+
-// | Check Access and exit when user status is not ok |
-// +-----------------------------------------------------------------------+
+// Check Access and exit when user status is not ok
check_status(ACCESS_GUEST);
-include(PHPWG_ROOT_PATH.'include/section_init.inc.php');
-//-------------------------------------------------- access authorization check
-if (isset($page['cat']) and is_numeric($page['cat']))
+// access authorization check
+if (isset($page['category']))
{
- check_restrictions($page['cat']);
+ check_restrictions($page['category']);
}
-//-------------------------------------------------------------- initialization
+
// if this image_id doesn't correspond to this category, an error message is
// displayed, and execution is stopped
-if (!in_array($_GET['image_id'], $page['items']))
+if (!in_array($page['image_id'], $page['items']))
{
- echo '
-<div style="text-align:center;">'.$lang['access_forbiden'].'<br />
- <a href="'.PHPWG_ROOT_PATH.'category.php'.'">'.$lang['thumbnails'].'</a>
-</div>';
- exit();
+ die('Fatal: this picture does not belong to this section');
}
+// +-----------------------------------------------------------------------+
+// | initialization |
+// +-----------------------------------------------------------------------+
+
$page['rank_of'] = array_flip($page['items']);
// caching first_rank, last_rank, current_rank in the displayed
// section. This should also help in readability.
$page['first_rank'] = 0;
$page['last_rank'] = count($page['items']) - 1;
-$page['current_rank'] = $page['rank_of'][ $_GET['image_id'] ];
+$page['current_rank'] = $page['rank_of'][ $page['image_id'] ];
// caching current item : readability purpose
-$page['current_item'] = $_GET['image_id'];
+$page['current_item'] = $page['image_id'];
if ($page['current_rank'] != $page['first_rank'])
{
@@ -71,12 +67,14 @@ if ($page['current_rank'] != $page['first_rank'])
$template->assign_block_vars(
'first',
array(
- 'U_IMG' =>
- PHPWG_ROOT_PATH.'picture.php'.
- get_query_string_diff(
- array('image_id', 'add_fav', 'slideshow')
- ).
- '&amp;image_id='.$page['items'][ $page['first_rank'] ],
+ 'U_IMG' => duplicate_picture_URL(
+ // redefinitions
+ array(
+ 'image_id' => $page['items'][ $page['first_rank'] ],
+ ),
+ // removes
+ array()
+ )
)
);
@@ -91,12 +89,14 @@ if ($page['current_rank'] != $page['last_rank'])
$template->assign_block_vars(
'last',
array(
- 'U_IMG' =>
- PHPWG_ROOT_PATH.'picture.php'.
- get_query_string_diff(
- array('image_id', 'add_fav', 'slideshow')
- ).
- '&amp;image_id='.$page['items'][ $page['last_rank'] ],
+ 'U_IMG' => duplicate_picture_URL(
+ // redefinitions
+ array(
+ 'image_id' => $page['items'][ $page['last_rank'] ],
+ ),
+ // removes
+ array()
+ )
)
);
@@ -104,155 +104,240 @@ if ($page['current_rank'] != $page['last_rank'])
$page['next_item'] = $page['items'][ $page['current_rank'] + 1 ];
}
-//---------------------------------------- incrementation of the number of hits
-if ( count(array_intersect(
- array_keys($_GET),
- array('add_fav', 'caddie', 'rate', 'representative', 'del') )
- )==0 )
-{
- $query = '
- UPDATE '.IMAGES_TABLE.'
- SET hit = hit+1
- WHERE id = '.$_GET['image_id'].'
- ;';
- @pwg_query( $query );
-}
-
-//-------------------------------------------------------------- representative
-if (is_admin() and isset($_GET['representative']))
-{
- $query = '
-UPDATE '.CATEGORIES_TABLE.'
- SET representative_picture_id = '.$_GET['image_id'].'
- WHERE id = '.$page['cat'].'
-;';
- pwg_query($query);
-
- $url =
- PHPWG_ROOT_PATH
- .'picture.php'
- .get_query_string_diff(array('representative'));
- redirect($url);
-}
-
-//-------------------------------------------------------------- caddie filling
+$url_up = duplicate_index_URL(
+ array(
+ 'start' =>
+ floor($page['current_rank'] / $user['nb_image_page'])
+ * $user['nb_image_page']
+ ),
+ array(
+ 'start',
+ )
+ );
-if (isset($_GET['caddie']))
-{
- fill_caddie(array($_GET['image_id']));
+$url_self = duplicate_picture_URL();
- $url =
- PHPWG_ROOT_PATH
- .'picture.php'
- .get_query_string_diff(array('caddie'));
- redirect($url);
-}
+// +-----------------------------------------------------------------------+
+// | actions |
+// +-----------------------------------------------------------------------+
+/**
+ * Actions are favorite adding, user comment deletion, setting the picture
+ * as representative of the current category...
+ *
+ * Actions finish by a redirection
+ */
-//----------------------------------------------------------- rate registration
-if (isset($_GET['rate'])
- and $conf['rate']
- and ( !$user['is_the_guest'] or $conf['rate_anonymous'] )
- and in_array($_GET['rate'], $rate_items))
+if (isset($_GET['action']))
{
- if ($user['is_the_guest'])
+ switch ($_GET['action'])
{
- $ip_components = explode('.', $_SERVER["REMOTE_ADDR"]);
- if ( count($ip_components)>3 )
+ case 'add_to_favorites' :
{
- array_pop($ip_components);
+ $query = '
+INSERT INTO '.FAVORITES_TABLE.'
+ (image_id,user_id)
+ VALUES
+ ('.$page['image_id'].','.$user['id'].')
+;';
+ pwg_query($query);
+
+ redirect($url_self);
+
+ break;
}
- $anonymous_id = implode ('.', $ip_components);
+ case 'remove_from_favorites' :
+ {
+ $query = '
+DELETE FROM '.FAVORITES_TABLE.'
+ WHERE user_id = '.$user['id'].'
+ AND image_id = '.$page['image_id'].'
+;';
+ pwg_query($query);
- if ( isset($_COOKIE['pwg_anonymous_rater']) )
+ if ('favorites' == $page['section'])
+ {
+ redirect($url_up);
+ }
+ else
+ {
+ redirect($url_self);
+ }
+
+ break;
+ }
+ case 'set_as_representative' :
{
- if ($anonymous_id != $_COOKIE['pwg_anonymous_rater'] )
- { // client has changed his IP adress or he's trying to fool us
+ if (is_admin() and isset($page['category']))
+ {
$query = '
+UPDATE '.CATEGORIES_TABLE.'
+ SET representative_picture_id = '.$page['image_id'].'
+ WHERE id = '.$page['category'].'
+;';
+ pwg_query($query);
+ }
+
+ redirect($url_self);
+
+ break;
+ }
+ case 'toggle_metadata' :
+ {
+ break;
+ }
+ case 'add_to_caddie' :
+ {
+ fill_caddie(array($page['image_id']));
+ redirect($url_self);
+ break;
+ }
+ case 'rate' :
+ {
+ if (isset($_GET['rate'])
+ and $conf['rate']
+ and (!$user['is_the_guest'] or $conf['rate_anonymous'])
+ and in_array($_GET['rate'], $rate_items))
+ {
+ if ($user['is_the_guest'])
+ {
+ $ip_components = explode('.', $_SERVER["REMOTE_ADDR"]);
+ if (count($ip_components) > 3)
+ {
+ array_pop($ip_components);
+ }
+ $anonymous_id = implode ('.', $ip_components);
+
+ if (isset($_COOKIE['pwg_anonymous_rater']))
+ {
+ if ($anonymous_id != $_COOKIE['pwg_anonymous_rater'])
+ { // client has changed his IP adress or he's trying to fool us
+ $query = '
SELECT element_id FROM '. RATE_TABLE . '
WHERE user_id=' . $user['id'] . '
AND anonymous_id=\'' . $anonymous_id . '\'';
- $result = pwg_query($query);
- $already_there = array();
- while ( $row = mysql_fetch_array($result) )
- {
- array_push( $already_there, $row['element_id'] );
+ $result = pwg_query($query);
+ $already_there = array();
+ while ($row = mysql_fetch_array($result))
+ {
+ array_push($already_there, $row['element_id']);
+ }
+
+ if (count($already_there) > 0)
+ {
+ $query = '
+DELETE
+ FROM '.RATE_TABLE.'
+ WHERE user_id = '.$user['id'].'
+ AND anonymous_id = \''.$_COOKIE['pwg_anonymous_rater'].'\'
+ AND element_id NOT IN ('.implode(',', $already_there).')
+;';
+ pwg_query($query);
+ }
+
+ $query = '
+UPDATE
+ '.RATE_TABLE.'
+ SET anonymous_id = \'' .$anonymous_id.'\'
+ WHERE user_id = '.$user['id'].'
+ AND anonymous_id = \'' . $_COOKIE['pwg_anonymous_rater'].'\'
+;';
+ pwg_query($query);
+
+ setcookie(
+ 'pwg_anonymous_rater',
+ $anonymous_id,
+ strtotime('+10 years'),
+ cookie_path()
+ );
+ }
+ }
+ else
+ {
+ setcookie(
+ 'pwg_anonymous_rater',
+ $anonymous_id,
+ strtotime('+10 years'),
+ cookie_path()
+ );
+ }
}
-
- if ( count($already_there)>0 )
+
+ $query = '
+DELETE
+ FROM '.RATE_TABLE.'
+ WHERE element_id = '.$page['image_id'] . '
+ AND user_id = '.$user['id'].'
+';
+ if (isset($anonymous_id))
{
- $query = '
-DELETE FROM '. RATE_TABLE . '
- WHERE user_id=' . $user['id'] . '
- AND anonymous_id=\'' . $_COOKIE['pwg_anonymous_rater'] . '\'
- AND element_id NOT IN (' . implode(',',$already_there) . ')';
- pwg_query($query);
+ $query.= ' AND anonymous_id = \''.$anonymous_id.'\'';
}
-
- $query = '
-UPDATE '. RATE_TABLE . '
- SET anonymous_id=\'' . $anonymous_id . '\'
- WHERE user_id=' . $user['id'] . '
- AND anonymous_id=\'' . $_COOKIE['pwg_anonymous_rater'] . '\'';
pwg_query($query);
-
- setcookie('pwg_anonymous_rater', $anonymous_id,
- strtotime('+10 years'), cookie_path() );
- }
- }
- else
- {
- setcookie('pwg_anonymous_rater', $anonymous_id,
- strtotime('+10 years'), cookie_path() );
- }
- }
-
- $query = '
-DELETE FROM '.RATE_TABLE.'
- WHERE element_id = '.$_GET['image_id'] . '
- AND user_id = '.$user['id']
-;
- if (isset($anonymous_id))
- {
- $query.= ' AND anonymous_id=\'' . $anonymous_id .'\'';
- }
- pwg_query($query);
- $query = '
-INSERT INTO '.RATE_TABLE.'
+ $query = '
+INSERT
+ INTO '.RATE_TABLE.'
(user_id,anonymous_id,element_id,rate,date)
VALUES
- ('.$user['id'].','.(isset($anonymous_id)?'\''.$anonymous_id.'\'':"''").','.
- $_GET['image_id'].','.$_GET['rate'].',NOW())
+ ('
+ .$user['id'].','
+ .(isset($anonymous_id) ? '\''.$anonymous_id.'\'' : "''").','
+ .$page['image_id'].','
+ .$_GET['rate']
+ .',NOW())
;';
- pwg_query($query);
-
- // update of images.average_rate field
- $query = '
+ pwg_query($query);
+
+ // update of images.average_rate field
+ $query = '
SELECT ROUND(AVG(rate),2) AS average_rate
FROM '.RATE_TABLE.'
- WHERE element_id = '.$_GET['image_id'].'
+ WHERE element_id = '.$page['image_id'].'
;';
- $row = mysql_fetch_array(pwg_query($query));
- $query = '
+ $row = mysql_fetch_array(pwg_query($query));
+ $query = '
UPDATE '.IMAGES_TABLE.'
SET average_rate = '.$row['average_rate'].'
- WHERE id = '.$_GET['image_id'].'
+ WHERE id = '.$page['image_id'].'
+;';
+ pwg_query($query);
+ }
+
+ redirect($url_self);
+ }
+ case 'delete_comment' :
+ {
+ if (isset($_GET['comment_to_delete'])
+ and is_numeric($_GET['comment_to_delete'])
+ and is_admin())
+ {
+ $query = '
+DELETE FROM '.COMMENTS_TABLE.'
+ WHERE id = '.$_GET['comment_to_delete'].'
;';
- pwg_query($query);
- $url =
- PHPWG_ROOT_PATH
- .'picture.php'
- .get_query_string_diff(array('rate'));
- redirect($url);
+ pwg_query( $query );
+ }
+
+ redirect($url_self);
+ }
+ }
}
+// incrementation of the number of hits, we do this only if no action
+$query = '
+UPDATE
+ '.IMAGES_TABLE.'
+ SET hit = hit+1
+ WHERE id = '.$page['image_id'].'
+;';
+pwg_query($query);
//---------------------------------------------------------- related categories
$query = '
SELECT category_id,uppercats,commentable,global_rank
FROM '.IMAGE_CATEGORY_TABLE.'
INNER JOIN '.CATEGORIES_TABLE.' ON category_id = id
- WHERE image_id = '.$_GET['image_id'].'
+ WHERE image_id = '.$page['image_id'].'
AND category_id NOT IN ('.$user['forbidden_categories'].')
;';
$result = pwg_query($query);
@@ -265,7 +350,7 @@ usort($related_categories, 'global_rank_compare');
//------------------------------------- prev, current & next picture management
$picture = array();
-$ids = array($_GET['image_id']);
+$ids = array($page['image_id']);
if (isset($page['previous_item']))
{
array_push($ids, $page['previous_item']);
@@ -361,180 +446,26 @@ while ($row = mysql_fetch_array($result))
$picture[$i]['name'] = str_replace('_', ' ', $file_wo_ext);
}
- $picture[$i]['url'] =
- PHPWG_ROOT_PATH.'picture.php'
- .get_query_string_diff(array('image_id', 'add_fav', 'slideshow'))
- .'&amp;image_id='.$row['id'];
-}
-
-$url_up = PHPWG_ROOT_PATH.'category.php?';
-if ( isset($page['cat']) )
-{
- $url_up .= 'cat='.$page['cat'];
-}
-elseif ( isset($_GET['calendar']) )
-{
- $url_up .= 'calendar='.$_GET['calendar'];
-}
-
-$url_up_start = floor( $page['current_rank'] / $user['nb_image_page'] );
-$url_up_start *= $user['nb_image_page'];
-if ($url_up_start>0)
-{
- $url_up .= '&amp;start='.$url_up_start;
-}
-
-if ( isset($page['cat']) )
-{
- if ( $page['cat'] == 'search' )
- {
- $url_up.= '&amp;search='.$_GET['search'];
- }
- if ( $page['cat'] == 'list' )
- {
- $url_up.= '&amp;list='.$_GET['list'];
- }
+ $picture[$i]['url'] = duplicate_picture_URL(
+ array(
+ 'image_id' => $row['id'],
+ ),
+ array(
+ 'start',
+ )
+ );
}
$url_admin =
PHPWG_ROOT_PATH.'admin.php?page=picture_modify'
- .'&amp;cat_id='. ( isset($page['cat']) ? $page['cat'] : '' )
- .'&amp;image_id='.$_GET['image_id'];
+ .'&amp;cat_id='.(isset($page['category']) ? $page['category'] : '')
+ .'&amp;image_id='.$page['image_id']
+;
$url_slide =
- $picture['current']['url'].'&amp;slideshow='.$conf['slideshow_period'];
-
-//--------------------------------------------------------- favorite management
-if ( isset( $_GET['add_fav'] ) )
-{
- $query = 'DELETE FROM '.FAVORITES_TABLE;
- $query.= ' WHERE user_id = '.$user['id'];
- $query.= ' AND image_id = '.$picture['current']['id'];
- $query.= ';';
- $result = pwg_query( $query );
-
- if ( $_GET['add_fav'] == 1 )
- {
- $query = 'INSERT INTO '.FAVORITES_TABLE;
- $query.= ' (image_id,user_id) VALUES';
- $query.= ' ('.$picture['current']['id'].','.$user['id'].')';
- $query.= ';';
- $result = pwg_query( $query );
- }
- if ( !$_GET['add_fav'] and isset($page['cat']) and 'fav'==$page['cat'] )
- {
- if (!isset($page['previous_item']) and !isset($page['next_item']))
- {
- // there is no favorite picture anymore we redirect the user to the
- // category page
- redirect($url_up);
- }
- else if (!isset($page['previous_item']))
- {
- $url = str_replace( '&amp;', '&', $picture['next']['url'] );
- redirect( $url );
- }
- else
- {
- $url = str_replace('&amp;', '&', $picture['prev']['url'] );
- redirect( $url );
- }
- redirect( $url );
- }
-}
-
-//------------------------------------------------------ comment registeration
-if ( isset( $_POST['content'] ) && !empty($_POST['content']) )
-{
- $register_comment = true;
- $author = !empty($_POST['author'])?$_POST['author']:$lang['guest'];
- // if a guest try to use the name of an already existing user, he must be
- // rejected
- if ( $author != $user['username'] )
- {
- $query = 'SELECT COUNT(*) AS user_exists';
- $query.= ' FROM '.USERS_TABLE;
- $query.= ' WHERE '.$conf['user_fields']['username']." = '".$author."'";
- $query.= ';';
- $row = mysql_fetch_array( pwg_query( $query ) );
- if ( $row['user_exists'] == 1 )
- {
- $template->assign_block_vars(
- 'information',
- array('INFORMATION'=>$lang['comment_user_exists']));
- $register_comment = false;
- }
- }
-
- if ( $register_comment )
- {
- // anti-flood system
- $reference_date = time() - $conf['anti-flood_time'];
- $query = 'SELECT id FROM '.COMMENTS_TABLE;
- $query.= ' WHERE date > FROM_UNIXTIME('.$reference_date.')';
- $query.= " AND author = '".$author."'";
- $query.= ';';
- if ( mysql_num_rows( pwg_query( $query ) ) == 0
- or $conf['anti-flood_time'] == 0 )
- {
- list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();'));
-
- $data = array();
- $data{'author'} = $author;
- $data{'date'} = $dbnow;
- $data{'image_id'} = $_GET['image_id'];
- $data{'content'} = htmlspecialchars( $_POST['content'], ENT_QUOTES);
-
- if (!$conf['comments_validation'] or is_admin())
- {
- $data{'validated'} = 'true';
- $data{'validation_date'} = $dbnow;
- }
- else
- {
- $data{'validated'} = 'false';
- }
-
- include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
- $fields = array('author', 'date', 'image_id', 'content', 'validated',
- 'validation_date');
- mass_inserts(COMMENTS_TABLE, $fields, array($data));
-
- // information message
- $message = $lang['comment_added'];
-
- if (!$conf['comments_validation'] or is_admin())
-
- if ( $conf['comments_validation'] and !is_admin() )
- {
- $message.= '<br />'.$lang['comment_to_validate'];
- }
- $template->assign_block_vars('information',
- array('INFORMATION'=>$message));
- }
- else
- {
- // information message
- $template->assign_block_vars(
- 'information',
- array('INFORMATION'=>$lang['comment_anti-flood']));
- }
- }
-}
-// comment deletion
-if ( isset( $_GET['del'] )
- and is_numeric( $_GET['del'] )
- and is_admin() )
-{
- $query = 'DELETE FROM '.COMMENTS_TABLE;
- $query.= ' WHERE id = '.$_GET['del'];
- $query.= ';';
- pwg_query( $query );
-}
-
-//
-// Start output of page
-//
+ $picture['current']['url']
+ .'&amp;slideshow='.$conf['slideshow_period']
+;
$title = $picture['current']['name'];
$refresh = 0;
@@ -571,8 +502,12 @@ else
$original_height = $picture['current']['height'];
}
-$picture_size = get_picture_size($original_width, $original_height,
- @$user['maxwidth'], @$user['maxheight']);
+$picture_size = get_picture_size(
+ $original_width,
+ $original_height,
+ @$user['maxwidth'],
+ @$user['maxheight']
+ );
// metadata
if ($conf['show_exif'] or $conf['show_iptc'])
@@ -584,12 +519,15 @@ else
$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';
-}
+// $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';
//------------------------------------------------------- navigation management
@@ -622,45 +560,46 @@ if (isset($page['next_item']))
include(PHPWG_ROOT_PATH.'include/page_header.php');
$template->set_filenames(array('picture'=>'picture.tpl'));
-$template->assign_vars(array(
- 'CATEGORY' => $title_img,
- 'PHOTO' => $title_nb,
- 'TITLE' => $picture['current']['name'],
- 'SRC_IMG' => $picture['current']['src'],
- 'ALT_IMG' => $picture['current']['file'],
- 'WIDTH_IMG' => $picture_size[0],
- 'HEIGHT_IMG' => $picture_size[1],
-
- 'LEVEL_SEPARATOR' => $conf['level_separator'],
-
- 'L_HOME' => $lang['home'],
- 'L_SLIDESHOW' => $lang['slideshow'],
- 'L_STOP_SLIDESHOW' => $lang['slideshow_stop'],
- 'L_PREV_IMG' =>$lang['previous_page'].' : ',
- 'L_NEXT_IMG' =>$lang['next_page'].' : ',
- 'L_ADMIN' =>$lang['link_info_image'],
- 'L_COMMENT_TITLE' =>$lang['comments_title'],
- 'L_ADD_COMMENT' =>$lang['comments_add'],
- 'L_DELETE_COMMENT' =>$lang['comments_del'],
- 'L_DELETE' =>$lang['delete'],
- 'L_SUBMIT' =>$lang['submit'],
- 'L_AUTHOR' => $lang['upload_author'],
- 'L_COMMENT' =>$lang['comment'],
- 'L_DOWNLOAD' => $lang['download'],
- 'L_DOWNLOAD_HINT' => $lang['download_hint'],
- 'L_PICTURE_METADATA' => $lang['picture_show_metadata'],
- 'L_PICTURE_HIGH' => $lang['picture_high'],
- 'L_UP_HINT' => $lang['home_hint'],
- 'L_UP_ALT' => $lang['home'],
-
- 'U_HOME' => (PHPWG_ROOT_PATH.'category.php'),
- 'U_UP' => $url_up,
- 'U_METADATA' => $url_metadata,
- 'U_ADMIN' => $url_admin,
- 'U_SLIDESHOW'=> $url_slide,
- 'U_ADD_COMMENT' => str_replace( '&', '&amp;', $_SERVER['REQUEST_URI'] )
- )
-);
+$template->assign_vars(
+ array(
+ 'CATEGORY' => $title_img,
+ 'PHOTO' => $title_nb,
+ 'TITLE' => $picture['current']['name'],
+ 'SRC_IMG' => $picture['current']['src'],
+ 'ALT_IMG' => $picture['current']['file'],
+ 'WIDTH_IMG' => $picture_size[0],
+ 'HEIGHT_IMG' => $picture_size[1],
+
+ 'LEVEL_SEPARATOR' => $conf['level_separator'],
+
+ 'L_HOME' => $lang['home'],
+ 'L_SLIDESHOW' => $lang['slideshow'],
+ 'L_STOP_SLIDESHOW' => $lang['slideshow_stop'],
+ 'L_PREV_IMG' =>$lang['previous_page'].' : ',
+ 'L_NEXT_IMG' =>$lang['next_page'].' : ',
+ 'L_ADMIN' =>$lang['link_info_image'],
+ 'L_COMMENT_TITLE' =>$lang['comments_title'],
+ 'L_ADD_COMMENT' =>$lang['comments_add'],
+ 'L_DELETE_COMMENT' =>$lang['comments_del'],
+ 'L_DELETE' =>$lang['delete'],
+ 'L_SUBMIT' =>$lang['submit'],
+ 'L_AUTHOR' => $lang['upload_author'],
+ 'L_COMMENT' =>$lang['comment'],
+ 'L_DOWNLOAD' => $lang['download'],
+ 'L_DOWNLOAD_HINT' => $lang['download_hint'],
+ 'L_PICTURE_METADATA' => $lang['picture_show_metadata'],
+ 'L_PICTURE_HIGH' => $lang['picture_high'],
+ 'L_UP_HINT' => $lang['home_hint'],
+ 'L_UP_ALT' => $lang['home'],
+
+ 'U_HOME' => make_index_URL(),
+ 'U_UP' => $url_up,
+ 'U_METADATA' => $url_metadata,
+ 'U_ADMIN' => $url_admin,
+ 'U_SLIDESHOW'=> $url_slide,
+ 'U_ADD_COMMENT' => $url_self,
+ )
+ );
if ($conf['show_picture_name_on_title'])
{
@@ -668,92 +607,100 @@ if ($conf['show_picture_name_on_title'])
}
//------------------------------------------------------- upper menu management
+
// download link if file is not a picture
if (!$picture['current']['is_picture'])
{
$template->assign_block_vars(
'download',
- array('U_DOWNLOAD' => $picture['current']['download']));
+ array(
+ 'U_DOWNLOAD' => $picture['current']['download']
+ )
+ );
}
+
// display a high quality link if present
if (isset($picture['current']['high']))
{
$uuid = uniqid(rand());
- $template->assign_block_vars('high', array(
- 'U_HIGH' => $picture['current']['high'],
- 'UUID'=>$uuid
- ));
+
+ $template->assign_block_vars(
+ 'high',
+ array(
+ 'U_HIGH' => $picture['current']['high'],
+ 'UUID' => $uuid,
+ )
+ );
+
$template->assign_block_vars(
'download',
- array('U_DOWNLOAD' => PHPWG_ROOT_PATH.'action.php?dwn='
- .$picture['current']['high']
- )
- );
+ array(
+ 'U_DOWNLOAD' => PHPWG_ROOT_PATH.'action.php?dwn='
+ .$picture['current']['high']
+ )
+ );
}
+
// button to set the current picture as representative
-if (is_admin() and
- isset($page['cat']) and is_numeric($page['cat']))
+if (is_admin() and isset($page['category']))
{
$template->assign_block_vars(
'representative',
array(
- 'URL' =>
- PHPWG_ROOT_PATH.'picture.php'
- .get_query_string_diff(array('add_fav'))
- .'&amp;representative=1'
+ 'URL' => $url_self.'&amp;action=set_as_representative'
)
);
}
+// caddie button
if (is_admin())
{
$template->assign_block_vars(
'caddie',
array(
- 'URL' =>
- PHPWG_ROOT_PATH.'picture.php'
- .get_query_string_diff(array('add_fav')).'&amp;caddie=1')
+ 'URL' => $url_self.'&amp;action=add_to_caddie'
+ )
);
}
-//------------------------------------------------------- favorite manipulation
-if ( !$user['is_the_guest'] )
+// favorite manipulation
+if (!$user['is_the_guest'])
{
// verify if the picture is already in the favorite of the user
- $query = 'SELECT COUNT(*) AS nb_fav';
- $query.= ' FROM '.FAVORITES_TABLE.' WHERE image_id = '.$_GET['image_id'];
- $query.= ' AND user_id = '.$user['id'].';';
- $result = pwg_query( $query );
- $row = mysql_fetch_array( $result );
- if (!$row['nb_fav'])
+ $query = '
+SELECT COUNT(*) AS nb_fav
+ FROM '.FAVORITES_TABLE.'
+ WHERE image_id = '.$page['image_id'].'
+ AND user_id = '.$user['id'].'
+;';
+ $result = pwg_query($query);
+ $row = mysql_fetch_array($result);
+
+ if ($row['nb_fav'] == 0)
{
- $url = PHPWG_ROOT_PATH.'picture.php';
- $url.= get_query_string_diff(array('add_fav'));
- $url.= '&amp;add_fav=1';
+ $url = $url_self.'&amp;action=add_to_favorites';
$template->assign_block_vars(
'favorite',
array(
- 'FAVORITE_IMG' => get_themeconf('icon_dir').'/favorite.png',
- 'FAVORITE_HINT' =>$lang['add_favorites_hint'],
- 'FAVORITE_ALT' =>$lang['add_favorites_alt'],
- 'U_FAVORITE' => $url
- ));
+ 'FAVORITE_IMG' => get_themeconf('icon_dir').'/favorite.png',
+ 'FAVORITE_HINT' => $lang['add_favorites_hint'],
+ 'FAVORITE_ALT' => $lang['add_favorites_alt'],
+ 'U_FAVORITE' => $url_self.'&amp;action=add_to_favorites',
+ )
+ );
}
else
{
- $url = PHPWG_ROOT_PATH.'picture.php';
- $url.= get_query_string_diff(array('add_fav'));
- $url.= '&amp;add_fav=0';
-
$template->assign_block_vars(
'favorite',
array(
- 'FAVORITE_IMG' => get_themeconf('icon_dir').'/del_favorite.png',
- 'FAVORITE_HINT' =>$lang['del_favorites_hint'],
- 'FAVORITE_ALT' =>$lang['del_favorites_alt'],
- 'U_FAVORITE'=> $url
- ));
+ 'FAVORITE_IMG' => get_themeconf('icon_dir').'/del_favorite.png',
+ 'FAVORITE_HINT' => $lang['del_favorites_hint'],
+ 'FAVORITE_ALT' => $lang['del_favorites_alt'],
+ 'U_FAVORITE' => $url_self.'&amp;action=remove_from_favorites',
+ )
+ );
}
}
//------------------------------------ admin link for information modifications
@@ -887,306 +834,30 @@ foreach ($related_categories as $category)
);
}
-//------------------------------------------------------------------- metadata
-if ($metadata_showable and isset($_GET['show_metadata']))
-{
- include_once(PHPWG_ROOT_PATH.'/include/functions_metadata.inc.php');
- $template->assign_block_vars('metadata', array());
- if ($conf['show_exif'])
- {
- if (!function_exists('read_exif_data'))
- {
- die('Exif extension not available, admin should disable exif display');
- }
-
- if ($exif = @read_exif_data($picture['current']['src']))
- {
- $template->assign_block_vars(
- 'metadata.headline',
- array('TITLE' => 'EXIF Metadata')
- );
-
- foreach ($conf['show_exif_fields'] as $field)
- {
- if (strpos($field, ';') === false)
- {
- if (isset($exif[$field]))
- {
- $key = $field;
- if (isset($lang['exif_field_'.$field]))
- {
- $key = $lang['exif_field_'.$field];
- }
-
- $template->assign_block_vars(
- 'metadata.line',
- array(
- 'KEY' => $key,
- 'VALUE' => $exif[$field]
- )
- );
- }
- }
- else
- {
- $tokens = explode(';', $field);
- if (isset($exif[$tokens[0]][$tokens[1]]))
- {
- $key = $tokens[1];
- if (isset($lang['exif_field_'.$tokens[1]]))
- {
- $key = $lang['exif_field_'.$tokens[1]];
- }
-
- $template->assign_block_vars(
- 'metadata.line',
- array(
- 'KEY' => $key,
- 'VALUE' => $exif[$tokens[0]][$tokens[1]]
- )
- );
- }
- }
- }
- }
- }
- if ($conf['show_iptc'])
- {
- $iptc = get_iptc_data($picture['current']['src'],
- $conf['show_iptc_mapping']);
-
- if (count($iptc) > 0)
- {
- $template->assign_block_vars(
- 'metadata.headline',
- array('TITLE' => 'IPTC Metadata')
- );
- }
-
- foreach ($iptc as $field => $value)
- {
- $key = $field;
- if (isset($lang[$field]))
- {
- $key = $lang[$field];
- }
-
- $template->assign_block_vars(
- 'metadata.line',
- array(
- 'KEY' => $key,
- 'VALUE' => $value
- )
- );
- }
- }
-}
//slideshow end
-if ( isset( $_GET['slideshow'] ) )
+if (isset($_GET['slideshow']))
{
- if ( !is_numeric( $_GET['slideshow'] ) ) $_GET['slideshow'] = $conf['slideshow_period'];
-
- $template->assign_block_vars('stop_slideshow', array(
- 'U_SLIDESHOW'=>$picture['current']['url']
- ));
-}
-
-//------------------------------------------------------------------- rating
-if ($conf['rate'])
-{
- $query = '
-SELECT COUNT(rate) AS count
- , ROUND(AVG(rate),2) AS average
- , ROUND(STD(rate),2) AS STD
- FROM '.RATE_TABLE.'
- WHERE element_id = '.$picture['current']['id'].'
-;';
- $row = mysql_fetch_array(pwg_query($query));
- if ($row['count'] == 0)
- {
- $value = $lang['no_rate'];
- }
- else
- {
- $value = sprintf(
- l10n('%.2f (rated %d times, standard deviation = %.2f)'),
- $row['average'],
- $row['count'],
- $row['STD']
- );
- }
-
- if ($conf['rate_anonymous'] or !$user['is_the_guest'])
+ if (!is_numeric($_GET['slideshow']))
{
- if ($row['count']>0)
- {
- $query = 'SELECT rate
- FROM '.RATE_TABLE.'
- WHERE element_id = '.$_GET['image_id'] . '
- AND user_id = '.$user['id'] ;
-
- if ($user['is_the_guest'])
- {
- $ip_components = explode('.', $_SERVER['REMOTE_ADDR']);
- if ( count($ip_components)>3 )
- {
- array_pop($ip_components);
- }
- $anonymous_id = implode ('.', $ip_components);
- $query .= ' AND anonymous_id = \''.$anonymous_id . '\'';
- }
-
- $result = pwg_query($query);
- if (mysql_num_rows($result) > 0)
- {
- $row = mysql_fetch_array($result);
- $sentence = $lang['already_rated'];
- $sentence.= ' ('.$row['rate'].'). ';
- $sentence.= $lang['update_rate'];
- }
- else
- {
- $sentence = $lang['never_rated'].'. '.$lang['Rate'];
- }
- }
- else
- {
- $sentence = $lang['never_rated'].'. '.$lang['Rate'];
- }
- $template->assign_block_vars(
- 'rate',
- array(
- 'CONTENT' => $value,
- 'SENTENCE' => $sentence
- ));
-
- $template->assign_block_vars('info_rate', array('CONTENT' => $value));
-
- $template->assign_vars(
- array(
- 'INFO_RATE' => $value
- )
- );
-
- foreach ($rate_items as $num => $mark)
- {
- if ($num > 0)
- {
- $separator = '|';
- }
- else
- {
- $separator = '';
- }
-
- $url = PHPWG_ROOT_PATH.'picture.php';
- $url.= get_query_string_diff(array('add_fav'));
- $url.= '&amp;rate='.$mark;
-
- $template->assign_block_vars(
- 'rate.rate_option',
- array(
- 'OPTION' => $mark,
- 'URL' => $url,
- 'SEPARATOR' => $separator
- ));
- }
+ $_GET['slideshow'] = $conf['slideshow_period'];
}
-}
-//---------------------------------------------------- users's comments display
-
-// the picture is commentable if it belongs at least to one category which
-// is commentable
-$page['show_comments'] = false;
-foreach ($related_categories as $category)
-{
- if ($category['commentable'] == 'true')
- {
- $page['show_comments'] = true;
- }
+ $template->assign_block_vars(
+ 'stop_slideshow',
+ array(
+ 'U_SLIDESHOW' => $picture['current']['url'],
+ )
+ );
}
-if ($page['show_comments'])
-{
- // number of comment for this picture
- $query = 'SELECT COUNT(*) AS nb_comments';
- $query.= ' FROM '.COMMENTS_TABLE.' WHERE image_id = '.$_GET['image_id'];
- $query.= " AND validated = 'true'";
- $query.= ';';
- $row = mysql_fetch_array( pwg_query( $query ) );
-
- // navigation bar creation
- $url = PHPWG_ROOT_PATH.'picture.php';
- $url.= get_query_string_diff(array('add_fav','start'));
-
- if (!isset( $_GET['start'] )
- or !is_numeric( $_GET['start'] )
- or ( is_numeric( $_GET['start'] ) and $_GET['start'] < 0 ) )
- {
- $page['start'] = 0;
- }
- else
- {
- $page['start'] = $_GET['start'];
- }
- $page['navigation_bar'] = create_navigation_bar( $url, $row['nb_comments'],
- $page['start'],
- $conf['nb_comment_page'],
- '' );
- $template->assign_block_vars('comments', array(
- 'NB_COMMENT'=>$row['nb_comments'],
- 'NAV_BAR'=>$page['navigation_bar']));
-
- if ($row['nb_comments']>0)
- {
- $query = 'SELECT id,author,date,image_id,content';
- $query.= ' FROM '.COMMENTS_TABLE.' WHERE image_id = '.$_GET['image_id'];
- $query.= " AND validated = 'true'";
- $query.= ' ORDER BY date ASC';
- $query.= ' LIMIT '.$page['start'].', '.$conf['nb_comment_page'].';';
- $result = pwg_query( $query );
-
- while ( $row = mysql_fetch_array( $result ) )
- {
- $template->assign_block_vars(
- 'comments.comment',
- array(
- 'COMMENT_AUTHOR'=>empty($row['author'])?$lang['guest']:$row['author'],
- 'COMMENT_DATE'=>format_date($row['date'], 'mysql_datetime', true),
- 'COMMENT'=>parse_comment_content($row['content'])
- ));
+// +-----------------------------------------------------------------------+
+// | sub pages |
+// +-----------------------------------------------------------------------+
- if ( is_admin() )
- {
- $template->assign_block_vars(
- 'comments.comment.delete',
- array('U_COMMENT_DELETE'=> $url.'&amp;del='.$row['id']
- ));
- }
- }
- }
+include(PHPWG_ROOT_PATH.'include/picture_rate.inc.php');
+include(PHPWG_ROOT_PATH.'include/picture_comment.inc.php');
+include(PHPWG_ROOT_PATH.'include/picture_metadata.inc.php');
- if (!$user['is_the_guest']
- or ($user['is_the_guest'] and $conf['comments_forall']))
- {
- $template->assign_block_vars('comments.add_comment', array());
- // display author field if the user is not logged in
- if (!$user['is_the_guest'])
- {
- $template->assign_block_vars(
- 'comments.add_comment.author_known',
- array('KNOWN_AUTHOR'=>$user['username'])
- );
- }
- else
- {
- $template->assign_block_vars(
- 'comments.add_comment.author_field', array()
- );
- }
- }
-}
//------------------------------------------------------------ log informations
pwg_log( 'picture', $title_img, $picture['current']['file'] );
diff --git a/profile.php b/profile.php
index 805ab753e..26a4fc335 100644
--- a/profile.php
+++ b/profile.php
@@ -158,8 +158,7 @@ SELECT '.$conf['user_fields']['password'].' AS password
array($data));
// redirection
- $url = PHPWG_ROOT_PATH.'category.php?'.$_SERVER['QUERY_STRING'];
- redirect($url);
+ redirect(make_index_url());
}
}
// +-----------------------------------------------------------------------+
@@ -221,7 +220,7 @@ $template->assign_vars(
'L_RETURN' => $lang['home'],
'L_RETURN_HINT' => $lang['home_hint'],
- 'U_RETURN' => PHPWG_ROOT_PATH.'category.php',
+ 'U_RETURN' => make_index_url(),
'F_ACTION'=>$url_action,
));
diff --git a/random.php b/random.php
index 820eb00f0..c6d5dc33b 100644
--- a/random.php
+++ b/random.php
@@ -28,6 +28,7 @@
// +-----------------------------------------------------------------------+
// | define and include |
// +-----------------------------------------------------------------------+
+
define('PHPWG_ROOT_PATH','./');
include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
@@ -40,30 +41,22 @@ check_status(ACCESS_GUEST);
// | generate random element list |
// +-----------------------------------------------------------------------+
-// we must not show pictures of a forbidden category
-$where = '';
-if ( $user['forbidden_categories'] != '' )
-{
- $where = 'WHERE category_id NOT IN ('.$user['forbidden_categories'].')';
-}
-
$query = '
SELECT DISTINCT(id)
FROM '.IMAGES_TABLE.'
INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id
- '.$where.'
+ '.(
+ $user['forbidden_categories'] != ''
+ ? 'WHERE category_id NOT IN ('.$user['forbidden_categories'].')'
+ : ''
+ ).'
ORDER BY RAND(NOW())
LIMIT 0, '.$conf['top_number'].'
;';
-$result = pwg_query($query);
-$ids = array();
-while ($row = mysql_fetch_array($result))
-{
- array_push($ids, $row['id']);
-}
+
// +-----------------------------------------------------------------------+
// | redirect |
// +-----------------------------------------------------------------------+
-$url = PHPWG_ROOT_PATH.'category.php?cat=list&amp;list='.implode(',', $ids);
-redirect($url);
+
+redirect(make_index_URL(array('list' => array_from_query($query, 'id'))));
?> \ No newline at end of file
diff --git a/register.php b/register.php
index d622d9bc4..c69741671 100644
--- a/register.php
+++ b/register.php
@@ -49,7 +49,7 @@ if (isset($_POST['submit']))
{
$user_id = get_userid($_POST['login']);
log_user( $user_id, false);
- redirect('category.php');
+ redirect(make_index_url());
}
}
@@ -74,7 +74,7 @@ $template->assign_vars(array(
'L_CONFIRM_PASSWORD' => $lang['reg_confirm'],
'L_EMAIL' => $lang['mail_address'],
- 'U_HOME' => PHPWG_ROOT_PATH.'category.php',
+ 'U_HOME' => make_index_url(),
'F_ACTION' => 'register.php',
'F_LOGIN' => $login,
diff --git a/search.php b/search.php
index 5eaeef419..09131320e 100644
--- a/search.php
+++ b/search.php
@@ -142,8 +142,14 @@ INSERT INTO '.SEARCH_TABLE.'
//----------------------------------------------------------------- redirection
if (isset($_POST['submit']) and count($errors) == 0)
{
- $url = 'category.php?cat=search&search='.$search_id;
- redirect($url);
+ redirect(
+ make_index_url(
+ array(
+ 'section' => 'search',
+ 'search' => $search_id,
+ )
+ )
+ );
}
//----------------------------------------------------- template initialization
@@ -193,7 +199,7 @@ $template->assign_vars(array(
'TODAY_YEAR' => date('Y', time()),
'S_SEARCH_ACTION' => 'search.php',
'U_HELP' => PHPWG_ROOT_PATH.'/popuphelp.php?page=search',
- 'U_HOME' => 'category.php'
+ 'U_HOME' => make_index_url(),
)
);
diff --git a/upload.php b/upload.php
index ea06794bf..e01778dbb 100644
--- a/upload.php
+++ b/upload.php
@@ -125,12 +125,10 @@ if (isset($page['cat']))
$page['cat_site_id'] = $result['site_id'];
$page['cat_name'] = $result['name'];
$page['cat_uploadable'] = $result['uploadable'];
- if ( url_is_remote($page['cat_dir']) or !$page['cat_uploadable'])
+
+ if (url_is_remote($page['cat_dir']) or !$page['cat_uploadable'])
{
- echo '<div style="text-align:center;">'.$lang['upload_forbidden'].'<br />';
- echo '<a href="./category.php">';
- echo $lang['thumbnails'].'</a></div>';
- exit();
+ die('Fatal: you take a wrong way, bye bye');
}
}
@@ -280,32 +278,34 @@ $author = !empty($_POST['author'])?$_POST['author']:'';
$date_creation = !empty($_POST['date_creation'])?$_POST['date_creation']:'';
$comment = !empty($_POST['comment'])?$_POST['comment']:'';
-$template->assign_vars(array(
- 'ADVISE_TITLE' => $advise_title,
- 'NAME' => $username,
- 'EMAIL' => $mail_address,
- 'NAME_IMG' => $name,
- 'AUTHOR_IMG' => $author,
- 'DATE_IMG' => $date_creation,
- 'COMMENT_IMG' => $comment,
-
- 'L_TITLE' => $lang['upload_title'],
- 'L_USERNAME' => $lang['upload_username'],
- 'L_EMAIL' => $lang['mail_address'],
- 'L_NAME_IMG' => $lang['upload_name'],
- 'L_SUBMIT' => $lang['submit'],
- 'L_AUTHOR' => $lang['upload_author'],
- 'L_CREATION_DATE' => $lang['upload_creation_date'],
- 'L_COMMENT' => $lang['comment'],
- 'L_RETURN' => $lang['home'],
- 'L_RETURN_HINT' => $lang['home_hint'],
- 'L_UPLOAD_DONE' => $lang['upload_successful'],
- 'L_MANDATORY' => $lang['mandatory'],
-
- 'F_ACTION' => $u_form,
+$template->assign_vars(
+ array(
+ 'ADVISE_TITLE' => $advise_title,
+ 'NAME' => $username,
+ 'EMAIL' => $mail_address,
+ 'NAME_IMG' => $name,
+ 'AUTHOR_IMG' => $author,
+ 'DATE_IMG' => $date_creation,
+ 'COMMENT_IMG' => $comment,
+
+ 'L_TITLE' => $lang['upload_title'],
+ 'L_USERNAME' => $lang['upload_username'],
+ 'L_EMAIL' => $lang['mail_address'],
+ 'L_NAME_IMG' => $lang['upload_name'],
+ 'L_SUBMIT' => $lang['submit'],
+ 'L_AUTHOR' => $lang['upload_author'],
+ 'L_CREATION_DATE' => $lang['upload_creation_date'],
+ 'L_COMMENT' => $lang['comment'],
+ 'L_RETURN' => $lang['home'],
+ 'L_RETURN_HINT' => $lang['home_hint'],
+ 'L_UPLOAD_DONE' => $lang['upload_successful'],
+ 'L_MANDATORY' => $lang['mandatory'],
+
+ 'F_ACTION' => $u_form,
- 'U_RETURN' => PHPWG_ROOT_PATH.'category.php?'.$_SERVER['QUERY_STRING']
- ));
+ 'U_RETURN' => make_index_url(array('category' => $page['cat'])),
+ )
+ );
if ( !$page['upload_successful'] )
{