- 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:
parent
fc19598a8e
commit
94cd8b4fbb
1 changed files with 10 additions and 10 deletions
|
@ -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())
|
||||
|
|
Loading…
Add table
Reference in a new issue