My first project in months
It was a small project that just involved adding a click counter to a flash nav bar i had made for my clans site awhile back. when i first started this i figured i could have it done in about an hour. in reality it took me three days.
the whole thing includes 16 txt files (1 per link) and 2 php files (one to send clicks to the text files and one to retrive the clicks and send it to the flash file.)
It works like this:
Link Clicked ===> Goto counter/redirect page ===> redirect and send data to text file
View flash nav bar ===> PHP file grabs links from text files and sends them as variables to the flash nav bar
THE CODE!!!:
clickcounter.php
PHP Code:
<?php
$redirect = $_GET['page'];
if ($redirect == "home"){
$filename = "clickcounter/cc-home.txt";
$redirecting = "index.php";
} elseif ($redirect == "forums"){
$filename = "clickcounter/cc-forums.txt";
$redirecting = "modules.php?name=Forums";
} elseif ($redirect == "ya"){
$filename = "clickcounter/cc-ya.txt";
$redirecting = "modules.php?name=Your_Account";
} elseif ($redirect == "pvtm"){
$filename = "clickcounter/cc-pvtm.txt";
$redirecting = "modules.php?name=Private_Messages";
} elseif ($redirect == "c2dcs"){
$filename = "clickcounter/cc-c2dcs.txt";
$redirecting = "http://www.goc2dclan.com/modules.php?name=store";
} elseif ($redirect == "jsg"){
$filename = "clickcounter/cc-jsg.txt";
$redirecting = "http://www.jandsgifts.goc2dclan.com/";
} elseif ($redirect == "fb"){
$filename = "clickcounter/cc-fb.txt";
$redirecting = "modules.php?name=Feedback";
} elseif ($redirect == "rec"){
$filename = "clickcounter/cc-rec.txt";
$redirecting = "modules.php?name=Recommend_Us";
} elseif ($redirect == "ml"){
$filename = "clickcounter/cc-ml.txt";
$redirecting = "modules.php?name=Members_List";
} elseif ($redirect == "wl"){
$filename = "clickcounter/cc-wl.txt";
$redirecting = "modules.php?name=Web_Links";
} elseif ($redirect == "down"){
$filename = "clickcounter/cc-down.txt";
$redirecting = "modules.php?name=Downloads";
} elseif ($redirect == "cp"){
$filename = "clickcounter/cc-cp.txt";
$redirecting = "http://clanpics.goc2dclan.com/";
} elseif ($redirect == "servers"){
$filename = "clickcounter/cc-servers.txt";
$redirecting = "modules.php?name=servers";
} elseif ($redirect == "stats"){
$filename = "clickcounter/cc-stats.txt";
$redirecting = "modules.php?name=Statistics";
} elseif ($redirect == "surveys"){
$filename = "clickcounter/cc-surveys.txt";
$redirecting = "modules.php?name=Surveys";
} elseif ($redirect == "frappr"){
$filename = "clickcounter/cc-frappr.txt";
$redirecting = "modules.php?name=Frappr";
} else {
$filename = "clickcounter/cc-home.txt";
$redirecting = "index.php";
}
@$fptr = fopen($filename, "r+");
if ($fptr == NULL) {
@$fptr = fopen($filename, "w+");
fwrite($fptr, "1");
fclose($fptr);
} else {
$data = fread($fptr, filesize($filename));
$dataInt = (int) $data;
$dataInt++;
rewind($fptr);
fwrite($fptr, $dataInt);
fclose($fptr);
}
?>
<html>
<head>
<title>Redirecting........</title>
<meta http-equiv="refresh" content="0;URL=<?=$redirecting?>">
</head>
<body>
</body>
</html>
block-Navigation.php (for PHP-Nuke)
PHP Code:
<?php
if (eregi("block-Navigation.php", $_SERVER['PHP_SELF'])) {
Header("Location: index.php");
die();
}
$filename1 = "clickcounter/cc-home.txt";
$filename2 = "clickcounter/cc-forums.txt";
$filename3 = "clickcounter/cc-ya.txt";
$filename4 = "clickcounter/cc-pvtm.txt";
$filename5 = "clickcounter/cc-c2dcs.txt";
$filename6 = "clickcounter/cc-jsg.txt";
$filename7 = "clickcounter/cc-fb.txt";
$filename8 = "clickcounter/cc-rec.txt";
$filename9 = "clickcounter/cc-ml.txt";
$filename10 = "clickcounter/cc-wl.txt";
$filename11 = "clickcounter/cc-down.txt";
$filename12 = "clickcounter/cc-cp.txt";
$filename13 = "clickcounter/cc-servers.txt";
$filename14 = "clickcounter/cc-stats.txt";
$filename15 = "clickcounter/cc-surveys.txt";
$filename16 = "clickcounter/cc-frappr.txt";
@$fptr1 = fopen($filename1, "r+");
$cchome = fread($fptr1, filesize($filename1));
fclose($fptr1);
@$fptr2 = fopen($filename2, "r+");
$ccforums = fread($fptr2, filesize($filename2));
fclose($fptr2);
@$fptr3 = fopen($filename3, "r+");
$ccya = fread($fptr3, filesize($filename3));
fclose($fptr3);
@$fptr4 = fopen($filename4, "r+");
$ccpvtm = fread($fptr4, filesize($filename4));
fclose($fptr4);
@$fptr5 = fopen($filename5, "r+");
$ccc2dcs = fread($fptr5, filesize($filename5));
fclose($fptr5);
@$fptr6 = fopen($filename6, "r+");
$ccjsg = fread($fptr6, filesize($filename6));
fclose($fptr6);
@$fptr7 = fopen($filename7, "r+");
$ccfb = fread($fptr7, filesize($filename7));
fclose($fptr7);
@$fptr8 = fopen($filename8, "r+");
$ccrec = fread($fptr8, filesize($filename8));
fclose($fptr8);
@$fptr9 = fopen($filename9, "r+");
$ccml = fread($fptr9, filesize($filename9));
fclose($fptr9);
@$fptr10 = fopen($filename10, "r+");
$ccwl = fread($fptr10, filesize($filename10));
fclose($fptr10);
@$fptr11 = fopen($filename11, "r+");
$ccdown = fread($fptr11, filesize($filename11));
fclose($fptr11);
@$fptr12 = fopen($filename12, "r+");
$cccp = fread($fptr12, filesize($filename12));
fclose($fptr12);
@$fptr13 = fopen($filename13, "r+");
$ccservers = fread($fptr13, filesize($filename13));
fclose($fptr13);
@$fptr14 = fopen($filename14, "r+");
$ccstats = fread($fptr14, filesize($filename14));
fclose($fptr14);
@$fptr15 = fopen($filename15, "r+");
$ccsurveys = fread($fptr15, filesize($filename15));
fclose($fptr15);
@$fptr16 = fopen($filename16, "r+");
$ccfrappr = fread($fptr16, filesize($filename16));
fclose($fptr16);
$content = '<embed src="/includes/nav.swf" height="511" width="145" flashvars="home='.$cchome.'&forums='.$ccforums.'&ya='.$ccya.'&pvtm='.$ccpvtm.'&c2dcs='.$ccc2dcs.'&jsg='.$ccjsg.'&fb='.$ccfb.'&rec='.$ccrec.'&ml='.$ccml.'&wl='.$ccwl.'&down='.$ccdown.'&cp='.$cccp.'&servers='.$ccservers.'&stats='.$ccstats.'&surveys='.$ccsurveys.'&frappr='.$ccfrappr.'"type="application/x-shockwave-flash"></embed>';
?>
If you guys wanna see it it's Here.