diff options
author | rvelices <rv-github@modusoptimus.com> | 2007-09-20 01:00:16 +0000 |
---|---|---|
committer | rvelices <rv-github@modusoptimus.com> | 2007-09-20 01:00:16 +0000 |
commit | 94cd8b4fbb2ef8fc2b0a9d892afc2c03feee1b0a (patch) | |
tree | 746fad0dbf236b644a8c7c6c4b88bfaf5717ec07 /include | |
parent | fc19598a8e46f2d8ab5b3f37d65bf748263f6a2f (diff) |
- 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
Diffstat (limited to 'include')
-rw-r--r-- | include/functions_rate.inc.php | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/include/functions_rate.inc.php b/include/functions_rate.inc.php index 3fe1a668e..4d7f756b7 100644 --- a/include/functions_rate.inc.php +++ b/include/functions_rate.inc.php @@ -50,15 +50,15 @@ function rate_picture($image_id, $rate) return; } - if ($user_anonymous) + $ip_components = explode('.', $_SERVER["REMOTE_ADDR"]); + if (count($ip_components) > 3) { - $ip_components = explode('.', $_SERVER["REMOTE_ADDR"]); - if (count($ip_components) > 3) - { - array_pop($ip_components); - } - $anonymous_id = implode ('.', $ip_components); + array_pop($ip_components); + } + $anonymous_id = implode ('.', $ip_components); + if ($user_anonymous) + { 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()) |