Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: [Add-on] create fake hits  (Read 13296 times)

0 Members and 1 Guest are viewing this topic.

jaspervd

  • Coppermine newbie
  • Offline Offline
  • Posts: 7
[Add-on] create fake hits
« on: April 13, 2008, 08:09:38 pm »

I just started my own gallery but hated how all of my pictures had 0 views, so I decided to create a little script that will update all pictures in the database with a random amount of views, looks much better in my opinion :)

How to install:
1) Open activity.php and edit line 20:
Code: [Select]
$views = mt_rand(300,1000);the first number(300) is the minimum amount of views you want, the last number (1000) is the max amount of views you want. The script will then randomly pick a number between these values.
2) Upload this script to the root of your gallery
3) point your browser to the file to run it once and your done :)
4) delete the file or chmod/rename it so other people cant use it

Source code:
Code: [Select]
<?php
//needed to acces the database
define('IN_COPPERMINE'true);
define('ADMIN_PHP'true);
define('CONFIG_PHP'true);
require(
'include/init.inc.php');
require(
'include/sql_parse.php');

$query="select * from cpg14x_pictures";
$result=mysql_query($query);

$i=1;

//repeat for all pictures
while ($email=mysql_fetch_row($result)) {

//generate random ammount of views between 300 and 1000 (you can edit these values)
$views mt_rand(300,1000);
//do not edit below

//update the database
$email_mysql_query = ("UPDATE cpg14x_pictures SET hits = $views WHERE pid = $i"); 
$email_mysql_query_result mysql_query($email_mysql_query); 
echo 
$i
$i $i+1;
}
?>

I have also attached my file :)
Logged

tfischer

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 75
    • Fischersplace Photo Gallery
Re: [Add-on] create fake hits
« Reply #1 on: April 13, 2008, 09:04:46 pm »

For what it's worth (for anyone reading this who may not realize), the view count stats can simply be disabled in the admin config panel.  Not sure what the real point of having a 'fake' count is.  Probably better to disable the display of the view count, and renable it some time later when you have some gallery usage stats built up.

Thanks for sharing the contribution though.

-Tim
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: [Add-on] create fake hits
« Reply #2 on: April 14, 2008, 09:38:47 am »

@jaspervd: thanks for sharing your solution, although I agree with tfischer: I can't see a reason why you want to fake the number of views. That's cheating imo that will cause a misproportion/disbalance of your actual stats, nothing else.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: [Add-on] create fake hits
« Reply #3 on: January 22, 2016, 02:19:32 pm »

Here's an improved version that works for all galleries:

Code: [Select]
<?php

define
('IN_COPPERMINE'true);
require(
'include/init.inc.php');

if (!
GALLERY_ADMIN_MODE) {
    
cpg_die(ERROR$lang_errors['access_denied'], __FILE____LINE__);
}

$min 300;
$max 1000;

cpg_db_query("UPDATE {$CONFIG['TABLE_PICTURES']} SET hits = FLOOR(RAND() * ".($max $min 1).") + ".$min);

pageheader();
echo 
$lang_common['done'];
pagefooter();

?>
Logged
Pages: [1]   Go Up
 

Page created in 0.019 seconds with 19 queries.