Code:
<?php
# PHP click counter (CCount) - display number of clicks on a link
# Version: 1.1
# File name: display.php
# Written 22nd January 2005 by Klemen Stirn (info@phpjunkyard.com)
# http://www.PHPJunkYard.com



#############################
#     DO NOT EDIT BELOW     #
#############################

require_once "settings.php";



if($settings['system'] == 2) {$settings['newline']="\r\n";}
elseif($settings['system'] == 3) {$settings['newline']="\r";}
else {$settings['newline']="\n";}

echo "var ccount_link = new Array();\n";

$lines = file($settings['logfile']);

foreach ($lines as $thisline) {
   trim($thisline);
   list($id,$added,$url,$count,$linkname)=explode("%%",$thisline);
    echo "ccount_link[$id]=$count;\n";
}

$totaldls = array_sum($ccount_display);
$lastelement = count($ccount_display);
$ccount_display[$lastelement] = $totaldls;

echo "
function ccount_display(id)
{
document.write(ccount_link[id]);
}
";

exit();
?>


Code:
<?php
# PHP click counter (CCount) - display number of clicks on a link
# Version: 1.1
# File name: display.php
# Written 22nd January 2005 by Klemen Stirn (info@phpjunkyard.com)
# http://www.PHPJunkYard.com



#############################
#     DO NOT EDIT BELOW     #
#############################

require_once "settings.php";



if($settings['system'] == 2) {$settings['newline']="\r\n";}
elseif($settings['system'] == 3) {$settings['newline']="\r";}
else {$settings['newline']="\n";}

echo "var ccount_link = new Array();\n";

$lines = file($settings['logfile']);

$cumsum = 0;
foreach ($lines as $thisline) {
   trim($thisline);
   list($id,$added,$url,$count,$linkname)=explode("%%",$thisline);
   $cumsum = $cumsum + $count;
    echo "ccount_link[$id]=$count;\n";
}

$lastelement = count($lines);
$ccount_link[$lastelement] = $cumsum;
echo "ccount_link[$lastelement] = $cumsum;\n";

echo "
function ccount_display(id)
{
document.write(ccount_link[id]);
}
";

exit();
?>

hmmm, that is strange. I tried to post a reply, but I got an error 500...

Anyways, I will try that. What variable should I use?
I fixed that. I was messing with the .htaccess file that controls the site.
Ok. And about the variable?

Edit: I have been reading through that php book, so far everything seems easy...
Did you try what I posted? It should work now. Just use <<elements+1>> as the number to call for the total.
Confused I hope I start to understand this soon...

Ok, it added them up and placed them in another slot...

http://tifreakware.calcgames.org/stats.htm
Did you enter this manually?


Code:
<tr><td>Total Downloads</td><td><script language="Javascript">$count</script></td></tr>
Yup. You should probably look at the page to see what it is doing...
ok, don't have it be $count. Have it be ccount[21] or whatever instead.
Ok, will it be messed up if I add more to it later?

I just realized, that isn't going to work, for the simple fact that it will be undefined. I am going to try something, see if it works...
It will in fact be messed up later.
Yeah, I tried playing with it, but I made it so where it wouldn't display anything. I have placed everything back as it once was. I guess I will have to worry about adding that later...
Cool. I think it's confusing because of the way they set it up to run. Oh well. Smile
Yup, now to just get the last bug out of the links page... Neutral
Wait, I just looked at it Shock and I think I might know what's wrong... Very Happy
Ok, I shall refrain from touching it for now... Very Happy
(I meant the links page, BTW) Smile
If I get a chance soon, I'll fix it. Could you post the CGI source code here?

Code:
#!/usr/bin/perl
#
# Author name:   Kerm Martian
# Creation date: January 26, 2004

print("Content-type: text/html\n\n");
$referrer = $ENV{'HTTP_REFERER'};
$referrer =~ s/^.*\?(.*)$/$1/i;
if ($referrer eq "") {$start = 0;} else { $start = $referrer + 0;}
open(LOGFILE,"linkdata.txt");
@lines = <LOGFILE>;
close(LOGFILE);
$totallength = scalar(@lines);
$end = $start+20;
if ($end > $totallength-1) {
$end = $totallength-1;
}
#print("document.write(\'\');");
print("document.write(\'<table border=\"0\">\');");
print("document.write(\'<tr><td colspan=\"2\">Go to: \');");
for($curprint=0;$curprint<=$totallength;$curprint=$curprint+20){
$nextprint = $curprint+19;
if ($nextprint > $totallength-1) {
$nextprint = $totallength-1;
}
if ($curprint != $start) {
$curprint++;
$nextprint++;
print("document.write(\'<a href=\"links.htm?$curprint\">$curprint - $nextprint<\\\/A>   \');");
} else {
$curprint++;
$nextprint++;
print("document.write(\'$curprint - $nextprint   \');");
}
$curprint = $curprint - 1;
}
print("document.write(\'<\\\/td><\\\/tr>\');");
for($curlinenum=$start;$curlinenum<=$end;$curlinenum++){
$printline = $lines[$curlinenum];
$printline =~ s/\'/\\\'/ig;
@curlinkdata = split(/\|/,$printline);
$imgsrc = $curlinkdata[0];
$url = $curlinkdata[1];
$description = $curlinkdata[2];
$description = substr($description, 0, length ($description)-2);
print("document.write(\'<TR><TD>\');");
print("document.write(\'<a target=\"_blank\" href=\"$url\"><img src=\"/images/banners$imgsrc\" border=\"0\" width=\"256\" height=\"70\"><\\\/A><\\\/TD><TD>$description<\\\/TD><\\\/TR>\');");
}
print("document.write(\'<tr><td>Go to: \');");
for($curprint=0;$curprint<=$totallength;$curprint=$curprint+20){
$nextprint = $curprint+19;
if ($nextprint > $totallength-1) {
$nextprint = $totallength-1;
}
if ($curprint != $start) {
$curprint++;
$nextprint++;
print("document.write(\'<a href=\"links.htm?$curprint\">$curprint - $nextprint<\\\/A>   \');");
} else {
$curprint++;
$nextprint++;
print("document.write(\'$curprint - $nextprint   \');");
}
$curprint = $curprint - 1;
}
print("document.write(\'<\\\/td><\\\/tr>\');");
print("document.write(\'<\\\/table>\');");
exit;
already click resolved

[Please note that this post has been rebuilt from a corrupted database.]
  
Page 4 of 4
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement