#!/usr/bin/perl ########## - Ver 2.4 - [CougaLinks] ----- ###################################################### # # Created by Paul Williams # E-Mail: paul@rainbow.nwnet.co.uk # http://scripts.marschall.net/ # Created: 21 Nov 1996 # Last Updated: 06 Apr 1998 [My birthday] # ########## - © Copyright 1998 Cougasoft - ###################################################### # # About: The redistribution or reselling of this code is strictly # prohibited, I don't mind if you alter the code but please # give credit where credit is due ;) # # Basically, all I ask is you don't try and make a profit from # this script. If you are in the webhosting business, please # visit my website for a serverpack. # # Source [IS NOT] to be redistributed in any form of medium. # ########## ------------------------------ ##################################################### # # ########## ------------------------------ ##################################################### # # M A I N P R O G R A M # ########## ------------------------------ ##################################################### # unless (do "data/cl-pref.pref" || do "cl-pref.pref") { printf("Content-type: text/plain\n\n" . "_________________________________________________________\n\n" . "- Preferences file [cl-pref.pref] can not be found !! -\n" . "- You must upload the preference file to the same dir -\n" . "- as this .cgi (.pl) script or to a directory called -\n" . "- data which is a subdirectory of the directory which -\n" . "- this script currently lies.\t\t\t\t-\n\n" . "- If I've lost you, just upload the pref file to the -\n" . "- same dir which this script is in :)\t\t\t-\n\n" . "- Paul\t\t\t\t\t\t\t-\n" . "_________________________________________________________\n\n"); exit(0); } # ########## ------------------------------ ##################################################### # ########## - SORT_INFORMATION [] -------- ##################################################### # read(STDIN, $input, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $input); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ tr/;/:/; $value =~ s/<([^>]|\n)*>//g if ($html); $INPUT{$name} = $value; } # ########## ------------------------------ ##################################################### # ########## - ACTION:REDIRECT [] --------- ##################################################### # if ($ENV{'QUERY_STRING'} =~ /direct=(.*)/i) { open(WHITWORTH, "$link_file") || ¬ify("500 Data Server Error", "I was not able to find the \$data file
upload it to and try again

If this is not admin, please let him/her
know about this problem.", 0); flock WHITWORTH, 1; @jaqueline = ; close(WHITWORTH); open(JANUARY, ">$link_file") || ¬ify("500 Data Server Error", "I was not able to write to the \$data file
chmod it to 666 and try again

If this is not admin, please let him/her
know about this problem.", 0); flock JANUARY, 2; foreach (@jaqueline) { ($name, $url, $date, $description, $click) = split('\|DI\|'); if ($url eq "$1") { $click++; printf(JANUARY "%s|DI|%s|DI|%s|DI|%s|DI|%d|DI|\n", $name, $url, $date, $description, $click); } else { printf(JANUARY "%s", $_); } } close(JANUARY); printf("Content-type: text/html\n"); printf("Location: %s\n\n", $1); } # ########## ------------------------------ ##################################################### # ########## - ACTION:REDIRECT [] --------- ##################################################### # elsif ($ENV{'QUERY_STRING'} =~ /action=random/i) { open(WILLIAMS, "$link_file") || ¬ify("500 Data Server Error", "I was not able to find the \$data file
upload it to and try again

If this is not admin, please let him/her
know about this problem.", 0); flock WILLIAMS, 1; @andrew = ; close(WILLIAMS); srand(time ^ $$); $l = sprintf("%s", $andrew[rand($#andrew)]); ($name, $url, $date, $description, $click) = split('\|DI\|', $l); printf("Content-type: text/html\n"); printf("Location: %s\n\n", $url); } # ########## ------------------------------ ##################################################### # ########## - ACTION:SUBMIT_URL [] ------- ##################################################### # elsif ($ENV{'QUERY_STRING'} eq "action=submit-url") { ¬ify("500 Internal Server Error", "[BAD HTTP_REFERER !]", 2) if ($ENV{'HTTP_REFERER'} !~ /^http:\/\/$ENV{'HTTP_HOST'}$ENV{'SCRIPT_NAME'}/); &missing("SITE NAME") unless $INPUT{'name'}; &missing("URL") unless $INPUT{'url'}; &missing("DESCRIPTION") unless $INPUT{'description'}; ¬ify("501 Data Server Error", "There is a problem with the URL.", 1) if ($INPUT{'url'} !~ /^\w.*:\/\/[\w\W]+\.[\w\W]+$/); open (CAR_DOOR, "$link_file") || ¬ify("500 Internal Server Error", "I was not able to find the \$data file
upload it to and try again

If this is not admin, please let him/her
know about this problem.", 0); flock CAR_DOOR, 1; while () { if (/$INPUT{'url'}/) { ¬ify("Link added.", "That URL has already been added.", 1); } } close(CAR_DOOR); &add(); &top_html("Success !"); &nframe("[Thank you for adding a link]

Please click " . "h e r e to view the link."); &bottom(1); } # ########## ------------------------------ ##################################################### # ########## - ACTION:ADD-URL [] ---------- ##################################################### # elsif ($ENV{'QUERY_STRING'} eq "action=add-url") { $browser = sprintf("%s", $BGCOLORPG); $browser = sprintf("%s", $TBCOLOR) if ($ENV{'HTTP_USER_AGENT'} !~ /MSIE/); &top_html("Submit a URL"); printf("
\n". "\n", $TBCOLOR, $ENV{'SCRIPT_NAME'}); printf("\n" . "\n\n", $browser); printf("\n" . "\n\n" . "\n" . "\n\n", $BGCOLORPG); printf("\n" . "\n\n" . "\n" . "\n\n", $BGCOLORPG); printf("\n" . "\n\n" . "\n" . "\n\n", $BGCOLORPG); printf("\n" . "\n\n" . "\n" . "\n\n", $BGCOLORPG); printf("
Please fill out all fields. \n" . "
 Site Name \n" . "
 \n" . "
 Site url - [http://www.yourdomain.com/] \n" . "
 \n" . "
 Description - [35 words or less] \n" . "
 \n" . "
 \n" . "
 
\n" . "
\n"); &bottom(1); } # ########## ------------------------------ ##################################################### # ########## - ACTION:MAIN [] ------------ ##################################################### # else { &status(); open(BRAVO, "$link_file"); flock BRAVO, 1; if ($display == 1) { @johnny = sort(); } elsif ($display == 2) { @johnny = ; } else { @johnny = reverse(); } close(BRAVO); $n = 1; $data = @johnny; if ($data == 1) { $title = sprintf("%d link", $data); } else { $title = sprintf("%d links", $data); } &top_html("$title", 1); printf("
\n" . "\n" . "\n\n" . "\n" . "\n" . "\n", $RESHADE, $CATEGORY,$TBCOLOR, $TBCOLOR, $TBCOLOR ); printf("\n\n"); foreach (@johnny) { ($name, $url, $date, $description, $click) = split('\|DI\|'); printf("\n", $n); printf("\n", $description); printf("\n\n", $click); $n++; } printf("\n", $RESHADE); printf("
%s
NumberLINK Clicks
%d.%s - [%s] ", $ENV{'SCRIPT_NAME'}, $url, $name, $date); printf("
%s
%d
 
\n"); printf("


Script written by Paul Williams " . "CougaSoft

"); &bottom(1); } # ########## ---------------------- ############################################################# # # S U B R O U T I N E S # ########## - ADDITIONAL STUFF [] ############################################################# # sub top_html { printf("Content-type: text/html\n\n" . "\n" . "\n" . "\n" . " Cougalinks - %s\n" . "\n" . "\n\n", $_[0], $BODYTEXT, $BGCOLORPG, $LINK, $VLINK, $ALINK, $BGGIF); printf("
\n\n", $gif) if ($my_link); printf("
\n\n", $gif) if (!$my_link); printf("
[Add-A-Link] - [H o m e] - " . "[Random Link]

", $ENV{'SCRIPT_NAME'}, $HOME, $ENV{'SCRIPT_NAME'}) if ($_[1]); } # ########## ---------------------- ############################################################# # # S U B A D D # ########## - ADD [] ------------- ############################################################# # sub add { $INPUT{'name'} =~ s/<([^>]|\n)*>//g; $INPUT{'name'} =~ s/\&/\&\;/g; $INPUT{'name'} =~ s/"/\"\;/g; $INPUT{'name'} =~ s/(.)/sprintf("%s", &uppercase($1))/e; $INPUT{'description'} =~ s/\s/ /g; &date(); $init = 0; $mlog = $mlog - 1; open(LINK, "$link_file"); flock LINK, 1; @link = ; close(LINK); open(FILE, ">$link_file") || ¬ify("500 Internal Server Error", "I was not able to write to the \$data file
chmod it to 666 and try again

If this is not admin, please let him/her
know about this problem.", 0); flock FILE, 2; printf(FILE "%s|DI|%s|DI|%s|DI|%s|DI|0|DI|\n", $INPUT{'name'}, $INPUT{'url'}, $date, $INPUT{'description'}); while ($init !=$mlog) { printf(FILE "%s", $link[$init]); $init++; } close(FILE); } # ########## ---------------------- ############################################################# # # S U B U P P E R C A S E # ########## - UPPERCASE [] ------- ############################################################# # sub uppercase { $tmp = $_[0]; $tmp =~ tr/a-z/A-Z/; return ($tmp); } # ########## ---------------------- ############################################################# # # S U B D A T E # ########## - DATE [] ------------ ############################################################# # sub date { @days = ('Sun','Mon','Tues','Wed','Thur','Fri','Sat'); @months = ('Jan','Feb','Mar','Apr','May','Jun','Jul', 'Aug','Sept','Oct','Nov','Dec'); ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); $hour = "0$hour" if ($hour < 10); $min = "0$min" if ($min < 10); $sec = "0$sec" if ($sec < 10); $year = $year + 1900; $date = "$months[$mon] $mday $year"; } # ########## ---------------------- ############################################################# # # S U B S T A T U S # ########## - STATUS [] ---------- ############################################################# # sub status { if (!-e "$link_file") { &top_html("Problema !", 0); printf("
" . "" . "", $TBCOLOR); printf("
" . "
Currently -
Link Data File
" . "
Can not be found.
Please update location(s) in Administration.
\n" . "
\n\n"); &bottom(1); } } # ########## ---------------------- ############################################################# # # S U B N F R A M E # ########## - NFRAME [] ---------- ############################################################# # sub nframe { printf("
\n" . " \n\n \n", $_[0]); printf("
\n" . " %s
\n\n"); } # ########## ---------------------- ############################################################# # # S U B M I S S I N G # ########## - MISSING [] --------- ############################################################# # sub missing { &top_html("Missing Field"); &nframe("Missing Field [$_[0]]
Return to the " . " F O R M and try again."); &bottom(1); } # ########## ---------------------- ############################################################# # # S U B N O T I F Y # ########## - NOTIFY [] ---------- ############################################################# # sub notify { $xtra = sprintf("
Return to the F O R M and try again.", $ENV{'HTTP_REFERER'}) if ($_[2] ==1); $xtra = sprintf("
Return to my S I T E and surf on.", $HOME) if ($_[2] == 2); &top_html("$_[0]"); &nframe("$_[1] $xtra"); &bottom(1); } # ########## ---------------------- ############################################################# # # S U B B O T T O M # ########## - BOTTOM [] ---------- ############################################################# # sub bottom { printf("\n"); printf("\n"); exit(0) if ($_[0]); } # ########## ---------------------- ############################################################# # ########## - EXIT(0) ------------ ############################################################# #