Author Topic: How users cheat view on his photos???  (Read 3468 times)

0 Members and 1 Guest are viewing this topic.

Offline MrAndrew

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
    • Aviation PhotoBase
How users cheat view on his photos???
« on: January 21, 2011, 08:06:17 PM »
Very very important question... How users cheat view on his photos on my gallery??? Is there any protection???

Many thanks

Offline tutton

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: How users cheat view on his photos???
« Reply #1 on: January 23, 2011, 02:56:00 AM »
You can disable the viewing of galleries for guests because if you view the gallery as a guest and keep refreshing it will keep upping the view count so to solve that problem just disable guests from viewing galleries.

Offline MrAndrew

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
    • Aviation PhotoBase
Re: How users cheat view on his photos???
« Reply #2 on: January 31, 2011, 10:09:57 AM »
I`ve operated this, but this not resolved my problem:

In includes/functions.php file before ?>

if (!function_exists('get_image_hits_table')) {
    function 
get_image_hits_table($image_id$session_ip$user_id) {    
        global 
$site_db;

        if ((int)
$user_id GUEST) {
            
$sql "SELECT h.user_id
                       FROM " 
IMAGES_HITS_TABLE " h
                       INNER JOIN " 
IMAGES_TABLE " i ON (i.image_id = h.image_id)
                       INNER JOIN " 
CATEGORIES_TABLE " c ON (c.cat_id = i.cat_id)
                       WHERE i.image_active = 1 AND i.image_id = " 
. (int)$image_id " AND h.user_id = " . (int)$user_id " AND i.cat_id NOT IN (".get_auth_cat_sql("auth_viewcat""NOTIN").")";

            
$hits_info $site_db->query_firstrow($sql);
            if (!empty(
$hits_info['user_id'])) {
                return 
true;
            }

        } elseif (
$user_id == GUEST) {
            
$sql "SELECT h.session_ip
                       FROM " 
IMAGES_HITS_TABLE " h
                       INNER JOIN " 
IMAGES_TABLE " i ON (i.image_id = h.image_id)
                       INNER JOIN " 
CATEGORIES_TABLE " c ON (c.cat_id = i.cat_id)
                       WHERE i.image_active = 1 AND i.image_id = " 
. (int)$image_id " AND i.cat_id NOT IN (".get_auth_cat_sql("auth_viewcat""NOTIN").")";

            
$result $site_db->query($sql);
            if (
$num_rows 0) {
                
$ip_check false;
                while (
$hits_row $site_db->fetch_array($result)) {
                    if (
$hits_row['session_ip'] == $session_ip) {
                        
$ip_check true;
                    }
                }
                if (
$ip_check == true) {
                    return 
true;
                }
            }
        }
    }
}


In details.php file replaced previews code with
// Update Hits
if (function_exists('get_image_hits_table') && get_image_hits_table($image_id$session_info['session_ip'], $session_info['session_user_id']) !== true) {
  
$sql "UPDATE ".IMAGES_TABLE."
          SET image_hits = image_hits + 1
          WHERE image_id = 
$image_id";
  
$site_db->query($sql);

  
$sql "INSERT INTO " IMAGES_HITS_TABLE "
             (field_id, image_id, session_ip, user_id)
             VALUES(NULL, " 
. (int)$image_id ", '" addslashes($session_info['session_ip']) . "', '" addslashes($session_info['session_user_id']) . "')";

  
$result $site_db->query($sql);
}


In includes/constants.php file added after:
define('IMAGES_TABLE'$table_prefix.'images');
This:
define('IMAGES_HITS_TABLE'$table_prefix.'images_hits');

In phpmyadmin console, in SQL window, pasted and executed this:
CREATE TABLE 4images_images_hits (
field_id INT(11unsigned NOT NULL AUTO_INCREMENT,
image_id INT(11NOT NULL DEFAULT '0',
session_ip VARCHAR(15NOT NULL DEFAULT '',
user_id INT(11NOT NULL DEFAULT '0',
PRIMARY KEY(field_id)
TYPE=MyISAM;


HOW TO BLOCK CHEATERS! Please help me... Thanks to Thunderstrike for big help me with this!