bug fixed: create_navigation_bar take into account clean URL if requested.

deletion: argument link_class (HTML class of links) in function
create_navigation_bar was removed, useless since branch 1.5.

bug fixed: rate_items are now a configuration parameter (set in config file)

modification: new functions library functions_rate.inc.php to reduce
picture.php length.

bug fixed: categories were never expanded in the menu since clean URLs.

bug fixed: changing pictures sorting order in main page was always
rederecting to root category.


git-svn-id: http://piwigo.org/svn/trunk@1084 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
plegall
2006-03-16 22:34:45 +00:00
parent 853bf2a0a5
commit 5980db248a
14 changed files with 249 additions and 192 deletions
+2 -109
View File
@@ -27,6 +27,7 @@
define('PHPWG_ROOT_PATH','./');
include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
include_once(PHPWG_ROOT_PATH.'include/functions_rate.inc.php');
include(PHPWG_ROOT_PATH.'include/section_init.inc.php');
// Check Access and exit when user status is not ok
@@ -194,115 +195,7 @@ UPDATE '.CATEGORIES_TABLE.'
}
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']);
}
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()
);
}
}
$query = '
DELETE
FROM '.RATE_TABLE.'
WHERE element_id = '.$page['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.'
(user_id,anonymous_id,element_id,rate,date)
VALUES
('
.$user['id'].','
.(isset($anonymous_id) ? '\''.$anonymous_id.'\'' : "''").','
.$page['image_id'].','
.$_GET['rate']
.',NOW())
;';
pwg_query($query);
// update of images.average_rate field
$query = '
SELECT ROUND(AVG(rate),2) AS average_rate
FROM '.RATE_TABLE.'
WHERE element_id = '.$page['image_id'].'
;';
$row = mysql_fetch_array(pwg_query($query));
$query = '
UPDATE '.IMAGES_TABLE.'
SET average_rate = '.$row['average_rate'].'
WHERE id = '.$page['image_id'].'
;';
pwg_query($query);
}
rate_picture($user['id'], $page['image_id'], $_GET['rate']);
redirect($url_self);
}
case 'delete_comment' :