mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-07-21 00:53:04 +02: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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$ip_components = explode('.', $_SERVER["REMOTE_ADDR"]);
|
||||||
|
if (count($ip_components) > 3)
|
||||||
|
{
|
||||||
|
array_pop($ip_components);
|
||||||
|
}
|
||||||
|
$anonymous_id = implode ('.', $ip_components);
|
||||||
|
|
||||||
if ($user_anonymous)
|
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 (isset($_COOKIE['pwg_anonymous_rater']))
|
||||||
{
|
{
|
||||||
if ($anonymous_id != $_COOKIE['pwg_anonymous_rater'])
|
if ($anonymous_id != $_COOKIE['pwg_anonymous_rater'])
|
||||||
@@ -78,7 +78,7 @@ DELETE
|
|||||||
FROM '.RATE_TABLE.'
|
FROM '.RATE_TABLE.'
|
||||||
WHERE user_id = '.$user['id'].'
|
WHERE user_id = '.$user['id'].'
|
||||||
AND anonymous_id = \''.$_COOKIE['pwg_anonymous_rater'].'\'
|
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);
|
pwg_query($query);
|
||||||
}
|
}
|
||||||
@@ -116,7 +116,7 @@ DELETE
|
|||||||
WHERE element_id = '.$image_id.'
|
WHERE element_id = '.$image_id.'
|
||||||
AND user_id = '.$user['id'].'
|
AND user_id = '.$user['id'].'
|
||||||
';
|
';
|
||||||
if (isset($anonymous_id))
|
if (isset($user_anonymous))
|
||||||
{
|
{
|
||||||
$query.= ' AND anonymous_id = \''.$anonymous_id.'\'';
|
$query.= ' AND anonymous_id = \''.$anonymous_id.'\'';
|
||||||
}
|
}
|
||||||
@@ -128,7 +128,7 @@ INSERT
|
|||||||
VALUES
|
VALUES
|
||||||
('
|
('
|
||||||
.$user['id'].','
|
.$user['id'].','
|
||||||
.(isset($anonymous_id) ? '\''.$anonymous_id.'\'' : "''").','
|
.'\''.$anonymous_id.'\','
|
||||||
.$image_id.','
|
.$image_id.','
|
||||||
.$rate
|
.$rate
|
||||||
.',NOW())
|
.',NOW())
|
||||||
|
|||||||
Reference in New Issue
Block a user