#!/usr/local/bin/perl # # # ####################################################### # Top Sites version 2.01 # # Created by: Solution Scripts # Email: solutions@solutionscripts.com # Web: http://solutionscripts.com # ####################################################### # # # COPYRIGHT NOTICE: # # Copyright 1999 Solution Scripts All Rights Reserved. # # This program is being distributed as freeware. It may be used and # modified free of charge, so long as this copyright notice, the header # above and all the footers in the program that give me credit remain # intact. Please also send me an email, and let me know # where you are using this script. # # By using this program you agree to indemnify Solution Scripts from any liability. # # Selling the code for this program without prior written consent is # expressly forbidden. Obtain permission before redistributing this # program over the Internet or in any other medium. In all cases # copyright and header must remain intact. # ###################################################### # # # NOTHING NEEDS TO BE ALTERED IN THIS SCRIPT FOR IT TO RUN # UNLESS YOU FEEL THE NEED TO EDIT IT # # ###################################################### &set_defaults; eval { require "variables.pl"; }; if ($@) { print "Content-type: text/html\n\n"; &header; print <
Something is wrong with your variables.pl file. Please look carefully at the error listed below and double check the settings in the variables.pl file.

The error is:
$@

EOF &error_footer("error_variables.shtml"); exit; } unless ($topsite_location =~ /http:\/\//) { &error(5); } unless ($topsite_location_cgi =~ /http:\/\//) { &error(6); } if ($path_to_topsites =~ /http:\/\//) { &error(7); } $topsite_location =~ s/\/$//; $topsite_location_cgi =~ s/\/$//; $path_to_topsites =~ s/\/$//; $current_time = time(); $member=$ENV{'QUERY_STRING'}; $cgiurl = $ENV{'SCRIPT_NAME'}; $all_right = "
Top Sites v$version, created by Solution Scripts
\"Enhancing the web with cgi\"
"; if ($member) { @pairs=split(/&/,$member); foreach $item(@pairs) { ($name,$content)=split (/=/,$item,2); $content=~tr/+/ /; $content=~ s/%(..)/pack("c",hex($1))/ge; if ($INPUT{$name}) { $INPUT{$name} = $INPUT{$name}.",".$content; } else { $INPUT{$name} = $content; } } } else { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; if ($INPUT{$name}) { $INPUT{$name} = $INPUT{$name}.",".$value; } else { $INPUT{$name} = $value; } } } if ($INPUT{'action'} eq "stats") { &stats; } elsif ($INPUT{'action'} eq "variables") { &show_vari; } elsif ($INPUT{'editfinal'}) { &editfinal; } elsif ($INPUT{'edit'}) { &edit; } elsif ($INPUT{'new_pass'}) { &new_pass; } elsif ($INPUT{'html_dis'}) { &html_dis; } elsif ($INPUT{'locate'}) { &locate; } elsif ($INPUT{'newaccount'}) {&newaccount; } else { &hit_in; } exit; sub stats { print "Content-type: text/html\n\n"; &header; open (DAT,"; close (DAT); $total=0; $num = push(@database_array); foreach $line(@database_array) { @member_array = split(/\|/,$line); $total += $member_array[1]; } print <$num
Total click thrus to your Top Sites: $total

With Top Sites Professional detailed stats are taken for each member and the Top Sites program. For example each member can view their daily stats which contain the number of hits they sent on each day, the number of people your Top Sites sent them ech day, and the rank their site was on that day. It is set up in table format so they may see if they are falling or increasing their rank. Through the admininstrative screen in Top Sites Professional you can also see daily, weekly, and monthly stats for the total system. You can also view how many sites are active (sent hits) today, this week, and this month.

More information on Top Sites Professional

EOF &footer; exit; } ## INCOMING ## sub hit_in { $member =~ s/ID\=//gi; unless ($member) { &thehtml; print "Location: $topsite_location/topsites.html\n\n"; exit; } open (DAT,"+; $found=0; $a=0; foreach $line(@database_array) { @member_array = split(/\|/,$line); if ($member_array[9] == $member) { $member_array[1]++; $member_array[0] = $member_array[1]; unless ($member_array[7]) { $member_array[7] = $current_time; } $line = join("\|",@member_array); } } seek (DAT, 0, 0); print DAT @database_array; close (DAT); open (LASTTIME,"; close (LASTTIME); $doit = $current_time - $last; if ($doit > $update_time) { open (NEWTIME,">time.txt") || &error(3); if ($use_flock) { flock NEWTIME, 2; } print NEWTIME "$current_time"; close (NEWTIME); &thehtml } print "Location: $topsite_location/topsites.html\n\n"; exit; } ##### CREATES THE HTML RANKING sub thehtml { open (DAT,"; close (DAT); unless ($rank) { $rank = "Hits/Day"; } unless ($all_right) { &error(4); } foreach $line(@database_array) { @member_array = split(/\|/,$line); unless ($member_array[5]) { next; } if ($rank eq "Hits/Day") { if ($member_array[7]) { $total_time = $current_time - $member_array[7]; $total_time = $total_time /86400; if ($total_time > 1) { $member_array[0] = $member_array[1] / $total_time; $line = join("\|",@member_array); } else { $member_array[0] = "0"; $line = join("\|",@member_array); $member_array[0] = $member_array[1]; $nline[$nn] = join("\|",@member_array); $nn++; } } else { $member_array[0] = 0; $line = join("\|",@member_array); $member_array[0] = $member_array[1]; $nline[$nn] = join("\|",@member_array); $nn++; } } else { $member_array[0] = $member_array[1]; $line = join("\|",@member_array); } } @sorted = sort { $a <=> $b }@database_array; @sort = reverse(@sorted); @nsorted = sort { $a <=> $b }@nline; @nsort = reverse(@nsorted); $html .= "\n\n$topsite_name\n\n"; $html .= "\n"; open (HEAD, "header.txt"); @head = ; close (HEAD); foreach $line (@head) { $html .= "$line"; } $html .= "


\n"; $html .= "\n"; $html .= "\n"; $html .= "\n"; $html .= "\n"; if ($rank eq "Hits/Day") { $html .= "\n"; } $html .= "\n"; $ranks = 0; $nn=0; while ($ranks < $num_to_show) { @members_array = split(/\|/,$sort[$ranks]); if (($members_array[0] == 0) && ($rank eq "Hits/Day")) { @members_array = split(/\|/,$nsort[$nn]); $nn++; $members_array[0] = 0; } $s_rank = $ranks + 1; $x++; $z++; $html .= "\n"; if ($members_array[9]) { $html .= "\n"; if ($members_array[0] && ($rank eq "Hits/Day")) { # $hpd = int($members_array[0]); $hpd = $members_array[0]; $hpd = sprintf ("%.".$round_int."f",$hpd); unless ($hpd) { $hpd =1; } } else { $total_time = $current_time - $members_array[7]; $total_time = $total_time /86400; if ($total_time < 1) { $hpd = "NEW"; } else { $hpd = 0; } } if ($rank eq "Hits/Day") { $html .= "\n"; } $html .= "\n"; } else { $html .= "\n"; if ($rank eq "Hits/Day") { $html .= "\n"; } $html .= "\n"; } $ranks++; } $html .="
RankSite NameHits/DayHits in
$s_rank$members_array[5]
\n"; if (($ranks < $num_banners) && $members_array[4]){ $html .= ""; $html .= ""; $html .= ""; } $html .= "
$hpd$members_array[1]
- Your Site Here ---

Click Here to add your site

\n"; open (HEAD, "footer.txt"); @foot = ; close (HEAD); foreach $line (@foot) { $html .= "$line"; } $html .= $all_right; open (HTML,">$path_to_topsites/topsites.html") || &error(2); print HTML "$html"; close (HTML); } sub set_defaults { # SET DEFAULTS # $version = "2.01"; $over_bg = "white"; $text_color = "black"; $link_color = "blue"; $font_size = "1"; $font_face = "verdana"; $table_border = 1; $table_padding = 5; $table_spacing = 0; $table_width = 575; $table_bg = $over_bg; $table_head_bg = $over_bg; $text_table_head = $text_color; $round_int = 1; } sub error{ print "Content-type: text/html\n\n"; $errors = $_[0] ; &header; if ($errors == 1) { print <An error has occured reading and writing to members.db

More information on the problem:
$!

EOF &error_footer("rw_members.shtml"); } elsif ($errors == 2) { print <An error has occured trying to write/create the file topsites.html

topsites.html is set to be created in the dir:
$path_to_topsites

More information on the problem:
$!

EOF &error_footer("wc_topsites.shtml"); } elsif ($errors == 3) { print <An error has occured trying to write/create the file time.txt

More information on the problem:
$!

EOF &error_footer("wc_time.shtml"); } elsif ($errors == 4) { print <
Thank you

EOF &footer; } elsif ($errors == 5) { print <You have your variables.pl configured wrong

The value you have entered for \$topsite_location does not contain http://

EOF &error_footer("variables.shtml"); } elsif ($errors == 6) { print <You have your variables.pl configured wrong

The value you have entered for \$topsite_location_cgi does not contain http://

EOF &error_footer("variables.shtml"); } elsif ($errors == 7) { print <You have your variables.pl configured wrong

The value you have entered for \$path_to_topsites contains http:// which is for urls, not paths

EOF &error_footer("variables.shtml"); } exit; } sub header { print < Top Sites -- From Solution Scripts
EOF } sub error_footer { $error_url = $_[0]; print < http://solutionscripts.com/man/top_sites

or you can jump straight to the page containing more information on your error at: http://solutionscripts.com/man/top_sites/$error_url

We also host a Help Forum where people can come and ask questions about Solution Scripts' scripts and questions they are having about them. The url for the Help Forum is:
http://solutionscripts.com/forum

Who knows, someone might have the posted the same question you have and the answer might already be there.


Top Sites, created by Solution Scripts
"Enhancing the web with cgi"
EOF } sub footer { $error_url = $_[0]; print <
Top Sites, created by Solution Scripts
"Enhancing the web with cgi"
EOF }