Skip to content

Commit

Permalink
allow ratings from different logged in users regardless of IP address
Browse files Browse the repository at this point in the history
  • Loading branch information
ron4mac committed Nov 22, 2021
1 parent e1ef517 commit bbd2ed8
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 30 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @license GNU General Public License version 3 or later; see LICENSE
*
* CHANGELOG.txt
* @since 1.6.16
* @since 1.6.17
*/
Changelog
=========
Expand All @@ -20,6 +20,7 @@ Changelog
[S] = Security fix (issues that are related to security)
*********************************************

2021-11-22 [B] Allow ratings from different logged in users regardless of IP address {ron4mac}
2021-11-20 [M] Update third party (ZenPhoto maintained) exif reader {ron4mac}
2021-11-15 [M] Change bridge file for SMF 2.1 to function with latest SMF version {ron4mac}
2021-11-09 [B] Correct install failure when single quote (') is used in db config {ron4mac}
Expand Down
4 changes: 2 additions & 2 deletions include/cpg16x.files.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5581,7 +5581,7 @@
</element>
<element>
<fullpath>include/themes.inc.php</fullpath>
<version>1.6.10</version>
<version>1.6.17</version>
<status>mandatory</status>
<permission>read</permission>
<hash>f7a3b825d8ad2a0e26a0aec5e9e6d355</hash>
Expand Down Expand Up @@ -7894,7 +7894,7 @@
</element>
<element>
<fullpath>ratepic.php</fullpath>
<version>1.6.03</version>
<version>1.6.17</version>
<status>mandatory</status>
<permission>read</permission>
<hash>ef2b10b0ba399e6316884c877ef35187</hash>
Expand Down
4 changes: 2 additions & 2 deletions include/themes.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @license GNU General Public License version 3 or later; see LICENSE
*
* include/themes.inc.php
* @since 1.6.10
* @since 1.6.17
*/

/////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -3628,7 +3628,7 @@ function theme_html_rating_box()
if ($CURRENT_PIC_DATA['owner_id'] == $USER_DATA['user_id'] && $USER_DATA['user_id'] != 0 && ($CONFIG['rate_own_files'] == 0 || $CONFIG['rate_own_files'] == 2 && !USER_IS_ADMIN)) {
// user is owner
$rate_title = $lang_rate_pic['forbidden'];
} elseif (!$result_votes->numRows() && !$result_vote_stats->numRows()) {
} elseif ((USER_ID && !$result_votes->numRows()) || !$result_vote_stats->numRows()) {
// user hasn't voted yet, show voting things
$rate_title = $lang_rate_pic['rate_this_pic'];
$user_can_vote = 'true';
Expand Down
49 changes: 24 additions & 25 deletions ratepic.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
<?php
/*************************
Coppermine Photo Gallery
************************
Copyright (c) 2003-2016 Coppermine Dev Team
v1.0 originally written by Gregory Demar
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 3
as published by the Free Software Foundation.
********************************************
Coppermine version: 1.6.03
$HeadURL$
**********************************************/
/**
* Coppermine Photo Gallery
*
* v1.0 originally written by Gregory Demar
*
* @copyright Copyright (c) 2003-2021 Coppermine Dev Team
* @license GNU General Public License version 3 or later; see LICENSE
*
* ratepic.php
* @since 1.6.17
*/

define('IN_COPPERMINE', true);
define('RATEPIC_PHP', true);
Expand Down Expand Up @@ -106,17 +103,19 @@
exit;
}

// Check if user already rated this picture - vote stats table
$sql = "SELECT null FROM {$CONFIG['TABLE_VOTE_STATS']} WHERE pid = $pic AND ip = '$raw_ip'";
$result = cpg_db_query($sql);
if ($result->numRows(true)) {
$send_back = array(
'status' => 'error',
'msg' => $lang_rate_pic_php['already_rated'],
'a' => $USER,
);
echo json_encode($send_back);
exit;
// If no logged in user, check if IP already rated this picture - vote stats table
if (!USER_ID) {
$sql = "SELECT null FROM {$CONFIG['TABLE_VOTE_STATS']} WHERE pid = $pic AND ip = '$raw_ip'";
$result = cpg_db_query($sql);
if ($result->numRows(true)) {
$send_back = array(
'status' => 'error',
'msg' => $lang_rate_pic_php['already_rated'],
'a' => $USER,
);
echo json_encode($send_back);
exit;
}
}

//Test for Self-Rating
Expand Down

0 comments on commit bbd2ed8

Please sign in to comment.