Sorting
Posted: Sat Oct 22, 2005 7:29 am
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
#!/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