Gossamer Forum
Home : Products : Links 2.0 : Customization :

Top 100 Variation

Quote Reply
Top 100 Variation
Hi,

just a variation of the Top 100 Theme. The Script produces a static "Top 100", or what ever you want Page, where the Links are sortet per "hits". A static page is better, than a dynamic page, because kidies with a fast finger can crash your server if they hit fast enaugh the button or link, which produces the dynamic page.

Sample Output:

http://www.kostnixx.de/pages/topsites.html

If you have added extra fields, you maybe must change the field numbers.

Have fun,

Karl




------ Script ------

Code:

#!/usr/bin/perl

use strict;

# Default Outputfile
my $outputFile = "/home/www/yourdomain/pages/topsites.html";

my $number_to_rank = 100;

my $htmlHeader=<<EOT;
<html>
<head>
<meta http-equiv="pragma" content="no-cache">
</head>
<body>
<center>
<table cellpadding=2 cellspacing=2 width=90%>
<tr>
<td bgcolor=#000000 align=center><font face="Verdana,Helvetica" color=#ffffff size=-1><b>Rang</b></font></td>
<td bgcolor=#000000 align=center><font face="Verdana, Helvetica" color=#ffffff size=-1><b>Hits</b></font></td>
<td bgcolor=#000000><font face="Verdana, Helvetica" color=#ffffff size=-1><b>Link</b></font></td>
<td bgcolor=#000000 align=center><font face="Verdana, Helvetica" color=#ffffff size=-1><b>Votes</b></font></td>
</tr>
EOT
;

my $htmlFooter=<<EOT;
</table></center>
</body>
</html>
EOT
;

sub tableLine {
my $lineCnt = sprintf("%04d",shift);
my $p = shift;
my ($p0,$p1,$p2,$p3)=split(/\|/,$p);
print F <<EOT;
<tr>
<td bgcolor=#c0c0c0 align=center><font face="Verdana, Helvetica" size=-1><b>$lineCnt</b></font></td>
<td bgcolor=#dfdfdf align=center><font face="Verdana, Helvetica" size=-1><b>$p0</b></font></td>
<td bgcolor=#efefef><font face="Verdana, Helvetica" size=-1><a href="http://www.yourdomain.de/cgi-bin/links/jump.cgi?ID=$p2">$p1</a></font></td>
<td bgcolor=#dfdfdf align=center><font face="Verdana, Helvetica" size=-1><b>$p3</b></font></td>
</tr>
EOT
}

open (F, ">$outputFile");

print F $htmlHeader;
open (LINKS,"/home/www/yourdomain/cgi-bin/links/admin/data/links.db")
&#0124; &#0124; die "links.db not fount: $!\n";
flock(LINKS, 2)
&#0124; &#0124; die "cannot lock links.db : $!\n";

my @rearranged;
while (<LINKS> ) {
my @fields = split(/\|/);
push @rearranged, "$fields[8]|$fields[1]|$fields[0]|$fields[11]";
}
close LINKS;

my @sorted = sort { $b <=> $a } @rearranged;
for (my $z = 0; $z < $number_to_rank; tableLine( $z,$sorted[$z++] )){};

print F $htmlFooter;
close F;

# Just for checking
print "Content-type: text/html\n\n";
print `cat $outputFile`;


[This message has been edited by Karl (edited December 01, 1999).]
Quote Reply
Re: Top 100 Variation In reply to
hi karl,

your mod is really good but:
i'll get always http 500 internal server error Frown

i have set the correct path's but it's not working.
maybe u can help

thx



------------------
ciao
Nicky
mse.nicky.net
www.nicky.net/forum german forum for GT Links

Quote Reply
Re: Top 100 Variation In reply to
Hi,

i have a problem with cut and paste in this forum

Take a look at this two lines:

&#0124; &#0124; die "links.db not fount: $!\n";
flock(LINKS, 2)
&#0124; &#0124; die "cannot lock links.db : $!\n";

and kill the space between the &#0124; &#0124;

Karl

Quote Reply
Re: Top 100 Variation In reply to
hi again,

still not working, after i kill the spaces
between both "| |"

------------------
ciao
Nicky
mse.nicky.net
www.nicky.net/forum german forum for GT Links

Quote Reply
Re: Top 100 Variation In reply to
Did you check to make sure that you changed the script's permission to 755?

BTW: Using or rather than &#0124; &#0124; is better.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------


Quote Reply
Re: Top 100 Variation In reply to
eliot Wink (LOL),

yes i did.



------------------
ciao
Nicky
mse.nicky.net
www.nicky.net/forum german forum for GT Links

Quote Reply
Re: Top 100 Variation In reply to
HEllo Karl,

I've seen your post about the ranking of sites.. is that the only script included in your post? or I still need to embed it to links 20?
Quote Reply
Re: Top 100 Variation In reply to
Hi alwell,

you need only this script.

Karl
Quote Reply
Re: Top 100 Variation In reply to
hi karl,

i found it out how to run this script on my server without the errors Smile

look at:

Quote:
open (LINKS,"data/links.db");
## &#0124; &#0124; die "links.db not fount: $!\n";
flock(LINKS, 2);
## &#0124; &#0124; die "cannot lock links.db : $!\n";

------------------
ciao
Nicky
mse.nicky.net
www.nicky.net/forum german forum for GT Links

Quote Reply
Re: Top 100 Variation In reply to
using "||" is actually better than using "or"..

"or" doesn't work in some of the things.. i prefer || while inside of code like

Code:
if ($blah eq "blah" || $hehe eq "hehe") {

and then i like to use "or" for things outside of code.. (well.. it LOOKS outside..)

Code:
($blah eq "blah") or
die ("\$blah is not equal to 'blah'");

just my little || or or talk..

jerry
Quote Reply
Re: Top 100 Variation In reply to
how to use run this script using Biuld all, and to have site's URL to get to, and not a href="http://www.yourdomain.de/cgi-bin/links/jump.cgi?ID=$p2"
Quote Reply
Re: Top 100 Variation In reply to
Hi Karl.

Your MOD is really cool.

I dunno if you know Perl that well, but what would be cool is a feature "Hits In". Like Top Sites.

P-A
Quote Reply
Re: Top 100 Variation In reply to
Hi!

I did a small variation on Karl's script.
Now you get also the categorie and when you click on a link, the link is loaded in the main window and in a popup-window you are 'forced' to vote for the link!
It's just a small variation on Karl's script, on rate.cgi and small changes on site-html-templates.pl. You need another two templates for the 'voting popup' and a 'thank-you popup'!
You can see it live (no demo!) at http://www.juhukatzen.de/topsites1999.html !
If you are interested mail me, I'll send you the ziped files!

Best wishes
Stefan

------------------
visit Juhu!Katzen!
http://www.juhukatzen.de/
Quote Reply
Re: Top 100 Variation In reply to
Hi,

How can you have the topsites page generated, display each link using the link.html template?

Thanks! Smile

------------------
BeatBox Entertainment
Ron Newbigging



[This message has been edited by ron4315 (edited January 03, 2000).]