mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-03-28 17:42:57 +01:00
- fix very rare sql error (duplicate key) for rating
git-svn-id: http://piwigo.org/svn/branches/branch-1_7@2099 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
@@ -50,15 +50,15 @@ function rate_picture($image_id, $rate)
|
||||
return;
|
||||
}
|
||||
|
||||
$ip_components = explode('.', $_SERVER["REMOTE_ADDR"]);
|
||||
if (count($ip_components) > 3)
|
||||
{
|
||||
array_pop($ip_components);
|
||||
}
|
||||
$anonymous_id = implode ('.', $ip_components);
|
||||
|
||||
if ($user_anonymous)
|
||||
{
|
||||
$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'])
|
||||
@@ -78,7 +78,7 @@ DELETE
|
||||
FROM '.RATE_TABLE.'
|
||||
WHERE user_id = '.$user['id'].'
|
||||
AND anonymous_id = \''.$_COOKIE['pwg_anonymous_rater'].'\'
|
||||
AND element_id NOT IN ('.implode(',', $already_there).')
|
||||
AND element_id IN ('.implode(',', $already_there).')
|
||||
;';
|
||||
pwg_query($query);
|
||||
}
|
||||
@@ -116,7 +116,7 @@ DELETE
|
||||
WHERE element_id = '.$image_id.'
|
||||
AND user_id = '.$user['id'].'
|
||||
';
|
||||
if (isset($anonymous_id))
|
||||
if (isset($user_anonymous))
|
||||
{
|
||||
$query.= ' AND anonymous_id = \''.$anonymous_id.'\'';
|
||||
}
|
||||
@@ -128,7 +128,7 @@ INSERT
|
||||
VALUES
|
||||
('
|
||||
.$user['id'].','
|
||||
.(isset($anonymous_id) ? '\''.$anonymous_id.'\'' : "''").','
|
||||
.'\''.$anonymous_id.'\','
|
||||
.$image_id.','
|
||||
.$rate
|
||||
.',NOW())
|
||||
|
||||
Reference in New Issue
Block a user