News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu

CPC Wiki is no more #1 CPC TopSite?

Started by TotO, 12:20, 25 January 13

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Devilmarkus

Well lets close this now.
The Topsites-Page is somewhat unimportant.
It should be a place where everybody should be able to share his CPC-website link.
Which page is on which place, really is not important.
But yes, the image should refresh every 24h.
I have no idea where this is designed in what header. I didnt code the topsites script. And I don't know PHP good enough to change that.
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Prodatron

Quote from: ralferoo on 16:10, 11 February 13
I got the impression that DevilMarkus was using it the other way, so the expiry time was set to 24 hours so that the browser would only request the image once every 24 hours.
If the pixel is only requested once every 24 hours, you will not be able to measure multiple page impressions of the same user at the same day. In this case the "Total PVs" column wouldn't make sense - it should always be the same like the daily (=24h) "Unique PVs".
Well, I have no idea, how the tracking methode of Topsites works in detail.

CU,
Prodatron

PS: Anyway that was quite an interesting (non CPC-related) discussion  :)

GRAPHICAL Z80 MULTITASKING OPERATING SYSTEM

Devilmarkus

Here's the button's code:
<?php
// Help prevent register_globals injection
define('ATSPHP'1);
$CONF = array();
$FORM = array();
$TMPL = array();

// Change the path to your full path if necessary
$CONF['path'] = '.';

// Connect to the database
require_once("{$CONF['path']}/settings_sql.php");
require_once(
"{$CONF['path']}/sources/sql/{$CONF['sql']}.php");
$DB "sql_{$CONF['sql']}";
$DB = new $DB;
$DB->connect($CONF['sql_host'], $CONF['sql_username'], $CONF['sql_password'], $CONF['sql_database']);

// Settings
$settings $DB->fetch("SELECT * FROM {$CONF['sql_prefix']}_settings"__FILE____LINE__);
$CONF array_merge($CONF$settings);


// Check id for backwards compatability with 4.x
if (isset($_GET['id']) && $_GET['id'] && !isset($_GET['u'])) {
  
$username $DB->escape($_GET['id']);
}
else {
  
$username $DB->escape($_GET['u']);
}

// Is this a valid member?  If not, exit to stop leechers
list($test) = $DB->fetch("SELECT active FROM {$CONF['sql_prefix']}_sites WHERE username = '{$username}'"__FILE____LINE__);
if (!
$test && (isset($_GET['u']) || isset($_GET['id']))) {
  exit;
}

// Is this a unique hit?
$ip $DB->escape($_SERVER['REMOTE_ADDR'], 1);
list(
$ip_sql$unq_pv) = $DB->fetch("SELECT ip_address, unq_pv FROM {$CONF['sql_prefix']}_ip_log WHERE ip_address = '$ip' AND username = '{$username}'"__FILE____LINE__);

$unique_sql ', unq_pv_overall = unq_pv_overall + 1, unq_pv_0_daily = unq_pv_0_daily + 1, unq_pv_0_weekly = unq_pv_0_weekly + 1, unq_pv_0_monthly = unq_pv_0_monthly + 1';
if (
$ip == $ip_sql && $unq_pv == 0) {
  
$DB->query("UPDATE {$CONF['sql_prefix']}_ip_log SET unq_pv = 1 WHERE ip_address = '{$ip}' AND username = '{$username}'"__FILE____LINE__);
}
elseif (
$ip != $ip_sql) {
  
$DB->query("INSERT INTO {$CONF['sql_prefix']}_ip_log (ip_address, username, unq_pv) VALUES ('{$ip}', '{$username}' ,1)"__FILE____LINE__);
}
else {
  
$unique_sql '';
}

// Update stats
$DB->query("UPDATE {$CONF['sql_prefix']}_stats SET tot_pv_overall = tot_pv_overall + 1, tot_pv_0_daily = tot_pv_0_daily + 1, tot_pv_0_weekly = tot_pv_0_weekly + 1, tot_pv_0_monthly = tot_pv_0_monthly + 1{$unique_sql} WHERE username = '{$username}'"__FILE____LINE__);

// What button to display?
$rank_on_button 0;
if (
$CONF['ranks_on_buttons']) {
  
// See if rank is freshly cached.  If so, use cached value.  If not, calculate rank.
  
list($rank_cache$rank_cache_time) = $DB->fetch("SELECT rank_cache, rank_cache_time FROM {$CONF['sql_prefix']}_stats WHERE username = '{$username}'"__FILE____LINE__);

  
$current_time time();
  if ((
$current_time 1800) < $rank_cache_time) { // Cache every 30 minutes.  1800 is the number of seconds to cache.  Change it if you want.
    
if ($rank_cache && $rank_cache <= $CONF['button_num']) {
      
$rank $rank_cache;
      
$location "{$CONF['button_dir']}/{$rank}.{$CONF['button_ext']}";
      
$rank_on_button 1;
    }
  }
  else {
    require_once 
"{$CONF['path']}/sources/misc/classes.php";
    
$rank_by base::rank_by();

    list(
$hits) = $DB->fetch("SELECT {$rank_by} FROM {$CONF['sql_prefix']}_sites sites, {$CONF['sql_prefix']}_stats stats WHERE sites.username = stats.username AND active = 1 AND sites.username = '{$username}'"__FILE____LINE__);
    if (
$hits) {
      list(
$rank) = $DB->fetch("SELECT count(*) FROM {$CONF['sql_prefix']}_sites sites, {$CONF['sql_prefix']}_stats stats WHERE sites.username = stats.username AND active = 1 AND ({$rank_by}) >= $hits"__FILE____LINE__);

      
$new_rank_cache 0;
      if (
$rank <= $CONF['button_num']) {
        
$location "{$CONF['button_dir']}/{$rank}.{$CONF['button_ext']}";
        
$rank_on_button 1;

        
$new_rank_cache $rank;
      }
    }
    if (
$new_rank_cache) {
      
$DB->query("UPDATE {$CONF['sql_prefix']}_stats SET rank_cache = {$new_rank_cache}, rank_cache_time = {$current_time} WHERE username = '{$username}'"__FILE____LINE__);
    }
  }

  
// Stat Buttons
  
if ($CONF['ranks_on_buttons'] == 2) {
    require_once 
"{$CONF['path']}/settings_buttons.php";
    exit;
  }
}

$DB->close();

if (!
$rank_on_button) {
  
$location $CONF['button_url'];
}

header("Location: {$location}");
?>


When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Devilmarkus

What I did was putting this code first:
// Avoid cheating
foreach($_GET as $k => $v){
    if ($k != "u" )    {
        header("Location: [url=http://cpc-live.com/topsites/images/cheater.png"]http://cpc-live.com/topsites/images/cheater.png"[/url];);
             die();
    }
}

When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

ralferoo

Looking at the code, it's clear that it does attempt to record unique visitors by checking for same IP and date, but it also increases the page view count each and every request. So, I'd say Podatron's randomisation is fair enough... the unique daily visitor count will be fine with or without the random value. And the random values ensure that each page view is counted, if it's not there the browser or a proxy server might not re-request the image so the total page views count will be too low.

Adding this to the start should ensure that browsers and proxies don't cache it, achieving the same as everyone adding the randomness:
<?php header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T'time())); ?>

Devilmarkus

There's no reason to modify the header.
The image is processed through PHP so it doesn't stay in cache.

I made something similar on another website I created.
There an image is puzzled together from several components.
So, each time you see the image, it contains different pieces.

(Because it can contain nudity, I put it into a spoiler)

Spoiler: ShowHide

When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Powered by SMFPacks Menu Editor Mod