40) { error('Your link name is too long! Please limit your name to maximum 40 chars!'); } $new_count = input($_POST['count']); if (preg_match("/\D/",$new_count)) { $new_count = 0; } $found=0; $i=0; $lines = file($settings['logfile']); foreach ($lines as $thisline) { if (strpos($thisline, $id.'%%') === 0) { $thisline = trim($thisline); list($id,$added,$url,$count,$name) = explode('%%',$thisline); $lines[$i]=$id.'%%'.$added.'%%'.$new_url.'%%'.$new_count.'%%'.$new_name."\r\n"; $found=1; break; } $i++; } if ($found != 1) {error('This ID doesn\'t exist!');} $content = implode('', $lines); $fp = @fopen($settings['logfile'],'w') or error('Can\'t write to log file! Please Change the file permissions (CHMOD to 666 on UNIX machines!)'); flock($fp, LOCK_EX); fputs($fp,$content); flock($fp, LOCK_UN); fclose($fp); mainpage('Changes to link ID '.$id.' have been saved!'); } // END savelink function editlink() { global $settings; $id=checkid(); $found=0; $i=0; $lines = file($settings['logfile']); foreach ($lines as $thisline) { if (strpos($thisline, $id.'%%') === 0) { $thisline = trim($thisline); list($id,$added,$url,$count,$name) = explode('%%',$thisline); $found=1; break; } $i++; } if ($found != 1) {error('This ID doesn\'t exist!');} printHeader(); ?>

Cancel / Go back | LOGOUT


Editing link ID

Required fields are marked bold.

Clicks:1
Link name:2
Link URL:3
   
1 Set click count to a number of your choice. CCount will continue counting clicks on this link from the new number.
2 Link name is a unique name for this link (max 40 chars including spaces). This name will be displayed as "Web page" in the statistics. If you don't choose a name the link URL will be displayed.
3 This is the URL to which your visitors will be redirected after clicking the click tracking link (click.php?id=).

| Cancel / Go back


 

 

 

'.$settings['logfile'].'!'); } if (!move_uploaded_file($_FILES['backup']['tmp_name'], $settings['logfile'])) { error('There has been an error uploading the backup file! Please make sure your log file ('.$settings['logfile'].') is writable by PHP scripts. On UNIX machines CHMOD it to 666 (rw-rw-rw-)!'); } printHeader(); ?>

 

Backup restored:

 

Backup successfully restored!

Your backup has been successfully restored. If this was a valid CCount backup file your counter should work OK now!

 

Click to continue

 

 

 

 

40) { error('Your link name is too long! Please limit your name to maximum 40 chars!'); } $start_from = input($_POST['count']); if (preg_match("/\D/",$start_from)) { $start_from = 0; } $previd = file_get_contents($settings['idfile']); $previd = trim($previd); $previd++; $fp = @fopen($settings['idfile'],'w') or error('Can\'t write to the IDs file ('.$settings['idfile'].')! Make sure PHP scripts have permission to write to this file (CHMOD it to 666 on LINUX machines!)'); flock($fp, LOCK_EX); fputs($fp,$previd); flock($fp, LOCK_UN); fclose($fp); $addline = $previd . '%%' . date('Y/m/d') . '%%' . $url . '%%'. $start_from . '%%' . $name . "\r\n"; $fp = @fopen($settings['logfile'],'a') or error('Can\'t write to the log file ('.$settings['logfile'].')! Make sure PHP scripts have permission to write to this file (CHMOD it to 666 on LINUX machines!)'); flock($fp, LOCK_EX); fputs($fp,$addline); flock($fp, LOCK_UN); fclose($fp); printHeader(); ?>

 

Link added

 

New link successfully added!

A new link with ID has been successfully added.

To count clicks on this link use this URL:



instead of the old one:

 

Click to continue

 

 

 

 

0 clicks!'); } // END resetlink function removelink() { global $settings; $id=checkid(); $found=0; $i=0; $lines = file($settings['logfile']); foreach ($lines as $thisline) { if (strpos($thisline, $id.'%%') === 0) { unset($lines[$i]); $found=1; break; } $i++; } if ($found != 1) {error('This ID doesn\'t exist!');} $content = implode('', $lines); $fp = @fopen($settings['logfile'],'w') or error('Can\'t write to log file! Please Change the file permissions (CHMOD to 666 on UNIX machines!)'); flock($fp, LOCK_EX); fputs($fp,$content); flock($fp, LOCK_UN); fclose($fp); if ($found != 1) { error('This ID doesn\'t exist!'); } mainpage('Link with ID '.$id.' was successfully removed!'); } // END removelink function mainpage($notice='') { global $settings; printHeader(); ?>

Add a new link | Refresh stats | LOGOUT


'.$notice.'

'; } ?>

Link statistics

Not counting any links. Use the form below to add new links to be counted.

'; } else { $i=0; foreach ($lines as $thisline) { $thisline = trim($thisline); list($id,$added,$url,$count,$linkname)=explode('%%',$thisline); $totalclicks += $count; if($count > $maxclicks) { $maxclicks = $count; $maxid=$id; } $i++; } $average = $totalclicks/$i; $average = number_format($average, 1); echo ' '; if ($maxclicks != 0) { echo ' '; } echo '
Total links: '.$i.'
Total clicks: '.$totalclicks.'
Average clicks: '.$average.'
Maximum clicks: '.$maxclicks.' (link ID '.$maxid.')
   
'; } $maxlinewidth = 200; if ($noyet == 0) { echo ' '; foreach ($lines as $thisline) { $thisline = trim($thisline); if (strlen($thisline) < 4) { continue; } list($id,$added,$url,$count,$linkname) = explode('%%',$thisline); if ($count == 0 || $maxclicks == 0) { $linewidth = 1; } else { $linewidth = round(($count * $maxlinewidth) / $maxclicks); if ($linewidth == 0) { $linewidth = 1; } } if (empty($linkname)) { if (strlen($url) > 40) { $linkname = substr($url, 0, 20); $linkname .= '...'; $linkname .= substr($url, -17); } else { $linkname=$url; } } echo ' '; } echo '
  ID Clicks Added Web page Graph
Remove this link Reset number of clicks to 0 Edit this link '.$id.' '.$count.' '.$added.' '.$linkname.'

TIP: For best performance you should remove links you don\'t use anymore. Button functions are explained below:

- delete link
- reset number of clicks to 0
- edit link

'; } ?>

Add a link

Use this form to add a new link to track clicks on. Required fields are marked bold.
Start counting from:1
Link name:2
Link URL:3
   
1 CCount will start counting clicks from the number you choose (default: start counting from 0).
2 Link name is a unique name for this link (max 40 chars including spaces). This name will be displayed as "Web page" in the statistics. If you don't choose a name the link URL will be displayed.
3 URL of the link you want to count clicks on.


Download backup

You may download a backup of the link database and restore it in the future should your link file be corrupted for any reason.
Click to download backup

Restore backup

Use this form to restore a previously downloaded backup file. This action cannot be undone! Select your backup file:


Usage

To track clicks on a link, use this URL instead of the link original URL:
?id=ID

Replace ID with the ID number of the URL, for example:
?id=13


Rate this script

If you like this script please rate it or even write a review at:

Rate this Script @ Hot Scripts

Rate this Script @ The PHP Resource Index


Stay updated

Join my FREE newsletter and you will be notified about new scripts, new versions of the existing scripts and other important news from PHPJunkYard.
Click here for more info

 

 

LOGGED OUT

 

You have been successfully logged out.

Click here to login again

 

 

 

 

 

 

Enter admin panel

 
Please type in your admin password

 

 

 

 

ERROR

 

An error occured:

 

Back to the previous page

 

 

 

 

PHP Click Counter admin panel
=")) { session_regenerate_id(); } else { $randlen = 32; $randval = '0123456789abcdefghijklmnopqrstuvwxyz'; $random = ''; $randval_len = 35; for ($i = 1; $i <= $randlen; $i++) { $random .= substr($randval, rand(0,$randval_len), 1); } if (session_id($random)) { setcookie( session_name('CCOUNT'), $random, ini_get("session.cookie_lifetime"), "/" ); return true; } else { return false; } } } ?>
PHP Click Counter
-- Admin panel --