GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   is there a basic page counter script out there? (https://gfy.com/showthread.php?t=417396)

clickhappy 01-16-2005 06:11 AM

is there a basic page counter script out there?
 
just a basic counter that tells me how many times a page is loaded?

I dont want a sex counter, just a basic barebones counter.
Theres got to be an easy way to do it with php, but when i look at counter scripts out there they have features and all these includes that i cant figure out how to install.

Kapitan Ivanov II 01-16-2005 06:15 AM

php.net

LEARN IT, or you'll never make it in the biz.

celebx 01-16-2005 09:28 AM

PHP Code:

<?php

// SNT's Array2Txt Functions :)
function Array2Txt($array,$fill='',$tab=1,$compress=0) { 
    if (!
$fill) { 
        
$txt_return='array('
    } 
    
$n=rand(); 
    
$run[$n]=0
    for(
$i=0;$i<$tab;$i++) {$t.="\t";} 
    foreach (
$array as $key => $value) { 
        if (!
$run[$n]) { 
            
$c=''
        } else { 
            
$c=', '
        }
$run[$n]++; 
        if (
is_array($value)) { 
            
$txt_return.=$c."\n".$t.'''.$key.'' => array('.Array2Txt($value,'',1,$tab+1); 
            continue 
1
        } 
        
$txt_return.=$c."\n".$t.'''.$key.'' => ''.$value.'''
    } 
    if (!
$fill) { 
        
$txt_return.=');'
    } else { 
        
$txt_return.=')'
    }     
    if (
$compress) { 
        return 
gzcompress($txt_return9); 
    } else { 
        return 
$txt_return
    } 


function 
Txt2Array($arraytxt,$decompress=0) { 
    if (
$decompress) { 
        eval(
'$return_array = '.gzuncompress($arraytxt)); 
        return 
$return_array
    } else { 
        eval(
'$return_array = '.$arraytxt); 
        return 
$return_array
    } 
}

//register user and count pageviews per page
session_start();
if (!isset(
$_SESSION['count'])) {
   
$new_visitor=1;
   
$_SESSION['visitor'] = array();
   
$_SESSION['visitor'][$_SERVER["PHP_SELF"]]=1;
} else {
   
$_SESSION['visitor'][$_SERVER["PHP_SELF"]]++;
}

//create counter data array from counter data file
if (file_exists($counter_data_file)) {
$counter_data Txt2Array(file_get_contents($counter_data_file));
} else { 
// create counter data file (if not exist)
   
if (!$handle fopen($counter_data_file'a')) {
         print 
"Can not create counter data file.";
         exit;
   }
   print 
"<!--- New Counter Data File created on ".date("r").". ---/>";
   
fclose($handle);


$counter_data[$_SERVER["PHP_SELF"]]["views"]++;
if (
$new_visitor) {
$counter_data[$_SERVER["PHP_SELF"]]["visitors"]++;
}

if (
is_writable($counter_data_file)) {
   if (!
$handle fopen($counter_data_file'a')) {
         print 
"Can not open counter data file.";
         exit;
   }
   
$counter_data_txt Array2Txt($counter_data);
   if (!
fwrite($handle$counter_data_txt)) {
       print 
"Can not write to counter data file.";
       exit;
   }

   print 
"<!--- Successfully updated counter data file, this page has been visited ".$counter_data[$_SERVER["PHP_SELF"]]["views"]." times. ---/>"
   
fclose($handle);
} else {
   print 
"The counter data file is not writeable.";
}

/*
The Array2Txt using the compression functions and a MySQL DB for data storage enables storage of detailed per visitor traffic information for 1m+/day trafficed sites! It will enable you to create the easyest and fastest accessable, processless and optimum source of traffic information.
*/

?>

p.s. this code has not been tested

celebx 01-16-2005 10:16 AM

the tested code:

http://www.phpbuilder.com/board/show...3#post10584993

If you run TheHun.com and would like to know every detail about your visitors over an unlimited period, use this counter for maximum possibilities and performance.

clickhappy 01-16-2005 02:37 PM

Quote:

Originally Posted by celebx
the tested code:

http://www.phpbuilder.com/board/show...3#post10584993

If you run TheHun.com and would like to know every detail about your visitors over an unlimited period, use this counter for maximum possibilities and performance.


can it be done without a database?

TheMob 01-16-2005 02:45 PM

I love statcounter.

Really.

www.statcounter.com


All times are GMT -7. The time now is 11:18 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123