Author Topic: CPC Wiki is no more #1 CPC TopSite?  (Read 5086 times)

0 Members and 1 Guest are viewing this topic.

Offline Devilmarkus

  • Vivid source of indefiniteness
  • 6128 Plus
  • ******
  • Posts: 4.039
  • Country: de
  • WebCPC / JavaCPC developer
    • index.php?action=treasury
    • CPC-Live website
  • Liked: 1007
Re: CPC Wiki is no more #1 CPC TopSite?
« Reply #75 on: 17:14, 11 February 13 »
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

Offline Prodatron

  • 6128 Plus
  • ******
  • Posts: 810
  • Country: de
  • Back on the Z80
    • index.php?action=treasury
    • SymbOS SYmbiosis Multitasking Based Operating System
  • Liked: 1030
Re: CPC Wiki is no more #1 CPC TopSite?
« Reply #76 on: 17:55, 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

Offline Devilmarkus

  • Vivid source of indefiniteness
  • 6128 Plus
  • ******
  • Posts: 4.039
  • Country: de
  • WebCPC / JavaCPC developer
    • index.php?action=treasury
    • CPC-Live website
  • Liked: 1007
Re: CPC Wiki is no more #1 CPC TopSite?
« Reply #77 on: 18:20, 11 February 13 »
Here's the button's code:
Code: [Select]
<?php
// Help prevent register_globals injection
define(&#39;ATSPHP&#39;, 1);
$CONF = array();
$FORM = array();
$TMPL = array();

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

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

// Settings
$settings $DB->fetch("SELECT * FROM {$CONF[&#39;sql_prefix&#39;]}_settings", __FILE__, __LINE__);
$CONF array_merge($CONF$settings);


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

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

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

$unique_sql = &#39;, 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&#39;;
if ($ip == $ip_sql && $unq_pv == 0) {
  
$DB->query("UPDATE {$CONF[&#39;sql_prefix&#39;]}_ip_log SET unq_pv = 1 WHERE ip_address = &#39;{$ip}&#39; AND username = &#39;{$username}&#39;", __FILE__, __LINE__);
}
elseif (
$ip != $ip_sql) {
  
$DB->query("INSERT INTO {$CONF[&#39;sql_prefix&#39;]}_ip_log (ip_address, username, unq_pv) VALUES (&#39;{$ip}&#39;, &#39;{$username}&#39; ,1)", __FILE__, __LINE__);
}
else {
  
$unique_sql = &#39;&#39;;
}

// Update stats
$DB->query("UPDATE {$CONF[&#39;sql_prefix&#39;]}_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 = &#39;{$username}&#39;", __FILE__, __LINE__);

// What button to display?
$rank_on_button 0;
if (
$CONF[&#39;ranks_on_buttons&#39;]) {
  // 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[&#39;sql_prefix&#39;]}_stats WHERE username = &#39;{$username}&#39;", __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[&#39;button_num&#39;]) {
      
$rank $rank_cache;
      
$location "{$CONF[&#39;button_dir&#39;]}/{$rank}.{$CONF[&#39;button_ext&#39;]}";
      
$rank_on_button 1;
    }

  }
  else {
    require_once "
{$CONF[&#39;path&#39;]}/sources/misc/classes.php";
    
$rank_by base::rank_by();

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

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

        
$new_rank_cache $rank;
      }

    }
    if (
$new_rank_cache) {
      
$DB->query("UPDATE {$CONF[&#39;sql_prefix&#39;]}_stats SET rank_cache = {$new_rank_cache}, rank_cache_time = {$current_time} WHERE username = &#39;{$username}&#39;", __FILE__, __LINE__);
    
}
  }


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

$DB->close();

if (!
$rank_on_button) {
  
$location $CONF[&#39;button_url&#39;];
}

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

Offline Devilmarkus

  • Vivid source of indefiniteness
  • 6128 Plus
  • ******
  • Posts: 4.039
  • Country: de
  • WebCPC / JavaCPC developer
    • index.php?action=treasury
    • CPC-Live website
  • Liked: 1007
Re: CPC Wiki is no more #1 CPC TopSite?
« Reply #78 on: 18:25, 11 February 13 »
What I did was putting this code first:
Code: [Select]
// 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

Offline ralferoo

  • Supporter
  • 6128 Plus
  • *
  • Posts: 966
  • Country: gb
  • Liked: 579
Re: CPC Wiki is no more #1 CPC TopSite?
« Reply #79 on: 18:41, 11 February 13 »
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:
Code: [Select]
<?php header(&#39;Expires: &#39;.gmdate(&#39;D, d M Y H:i:s \G\M\T&#39;, time())); ?>

Offline Devilmarkus

  • Vivid source of indefiniteness
  • 6128 Plus
  • ******
  • Posts: 4.039
  • Country: de
  • WebCPC / JavaCPC developer
    • index.php?action=treasury
    • CPC-Live website
  • Liked: 1007
Re: CPC Wiki is no more #1 CPC TopSite?
« Reply #80 on: 13:19, 12 February 13 »
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: show

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