CGI:
#!/usr/bin/perl
use CGI;
use strict;
my $file = "/home/v/e/ text file location"; // inside txt file: Hits number|Site name|URL|
my $top = "top.cgi";
my $in = new CGI;
my $action = $in->param('action') || undef;
my $title = $in->param('title');
my $page = $in->param('page');
print $in->header();
print <<EOHTML;
<html>
<head>
<title>TOP TEN</title>
</head>
<body background="XXX.jpg">
<base target="_self">
<br>
<table border="1" cellpadding="2" cellspacing="0" width="600" align="center">
<tr>
<td align=center width="25%">Rank</tr>
<td align=center>TOP TEN</tr>
<td align=center width="25%">Hits</td>
</tr>
EOHTML
my @record;
my $count;
open (DATA , "<$file") || die "Could not open $file.";
my (@lines) = <DATA>;
foreach my $line (sort {$b <=> $a} @lines) {
@record=split(/\|/ , $line);
$count++;
print qq~
<tr>
<td align=center>$count</td>
<td align=center><a href=$record[2] >$record[1]</a></td>
<td align=center >$record[0]</td>
</tr>
~;
}
close (DATA);
print <<EOHTML;
</table>
</body>
</html>
EOHTML
exit();
In php please. CCount - click counter v. 1.2
Sorting
Top
Sort by hits/counts
Change in:
------------
click.php
$lines[$i]=$id."%%".$url."%%".$count."%%".$name.$newline;
to
$lines[$i]=$count."%%".$id."%%".$url."%%".$name.$newline;
------------
display.php
list($id,$added,$url,$count,$linkname)=explode("%%",$thisline);
to
list($count,$id,$added,$url,$linkname)=explode("%%",$thisline);
------------
index.php
list($id,$added,$url,$count,$name)=explode("%%",$thisline);
to
list($count,$id,$added,$url,$name)=explode("%%",$thisline);
---
list($id,$added,$url,$count,$linkname)=explode("%%",$thisline);
to
list($count,$id,$added,$url,$linkname)=explode("%%",$thisline);
---
foreach ($lines as $thisline) {
trim($thisline);
to
sort($lines);
foreach ($lines as $key => $thisline) {
trim($thisline);
---
new td for rank number:
// location in code
if ($noyet == 0) {
echo "<table border=\"0\" cellpadding=\"3\" cellspacing=\"0\"><tr>
//
<td algin=\"center\" valgin=\"center\" class=\"second\"> <b>rank</b> </td>
---
// location in code
$linkname=$url;
}
}
echo "<tr>
//
<td algin=\"center\" valgin=\"center\" class=\"first\"> <b>$key</b> </td>
More info:
http://www.php.net/manual/en/function.sort.php
Change in:
------------
click.php
$lines[$i]=$id."%%".$url."%%".$count."%%".$name.$newline;
to
$lines[$i]=$count."%%".$id."%%".$url."%%".$name.$newline;
------------
display.php
list($id,$added,$url,$count,$linkname)=explode("%%",$thisline);
to
list($count,$id,$added,$url,$linkname)=explode("%%",$thisline);
------------
index.php
list($id,$added,$url,$count,$name)=explode("%%",$thisline);
to
list($count,$id,$added,$url,$name)=explode("%%",$thisline);
---
list($id,$added,$url,$count,$linkname)=explode("%%",$thisline);
to
list($count,$id,$added,$url,$linkname)=explode("%%",$thisline);
---
foreach ($lines as $thisline) {
trim($thisline);
to
sort($lines);
foreach ($lines as $key => $thisline) {
trim($thisline);
---
new td for rank number:
// location in code
if ($noyet == 0) {
echo "<table border=\"0\" cellpadding=\"3\" cellspacing=\"0\"><tr>
//
<td algin=\"center\" valgin=\"center\" class=\"second\"> <b>rank</b> </td>
---
// location in code
$linkname=$url;
}
}
echo "<tr>
//
<td algin=\"center\" valgin=\"center\" class=\"first\"> <b>$key</b> </td>
More info:
http://www.php.net/manual/en/function.sort.php