#!/usr/bin/perl ########################################################################## ## ## ## IntelliLink Pro v5.0 ## ## ---------------------- ## ## By Smarter Scripts ## ## (http://www.smarterscripts.com) ## ## ## ## IntelliLink Pro is not a free script. If you got this from some ## ## place other than SmarterScripts.com, please contact us, we do offer ## ## rewards for that type of information. Visit our site for up to date ## ## versions. Most CGIs are over $200, sometimes more than $500, ## ## this script is much less. We can keep this script cheap, ## ## as well as free scripts on our site, if people don't steal it. ## ## Also, no return links are required, but we appreciate it if you ## ## do find a spot for us. ## ## Thanks! ## ## ## ## (c) copyright 2003 SmarterScripts.com and R3N3 Internet Services ## ########################################################################## if ($ENV{'SERVER_SOFTWARE'} =~ /microsoft/i) { $path = $ENV{'PATH_TRANSLATED'}; $path =~ /^(.*)\\[^\\]*$/; $path = $1; chdir $path; } require 'include/functions.cgi'; %in = getvars(); $id = $in{'id'}; $gid = $in{'gid'}; if($id eq '') { gotosite(); exit } $timenow = time(); if(($anticheat == 0)||($anticheat == 1)) { # cheating is bad, let's do what we can to prevent it... if($timenow - $gid > 600) # Give the code a ten-minute range { $url = "$cgiurl/in.cgi?id=$id&gid=$timenow"; if($reflog) { logref($id, 'ref') } if($banref[0] ne '') { banref() } if($anticheat == 0) { print "Content-type: text/html\n\n"; print < $body You are being redirected to... $sitename


Continue to $sitename EOF exit; } else { print "Content-type: text/html\n\n"; open(DATA, '< html/gateway.html'); flock(DATA, $LOCK_SH); $html = ''; while () { $html .= $_ } flock(DATA, $LOCK_UN); close(DATA); $site = $siteurl[(int rand(@siteurl))]; $html =~ s/\[siteurl\]/$site/g; $html =~ s/\[url\]/$url/g; $html =~ s/\[sitename\]/$sitename/g; print $html; &info; } exit; } } else { if($reflog) { logref($id, 'ref') } if($banref[0] ne '') { &banref } } unless($resetdays == 0) { if($timenow > resettime()+($resetdays*86400)) { require 'include/reset.cgi'; &resetfiles } } unless($updatetime == 0) { if($timenow > updatetime()+($updatetime*60)) { require 'include/update.cgi'; &update } } if (! iplog() ) { updatecount($id, 1, 0) } if($cookielink) { my($sec,$min,$hour,$mday,$mon,$year,$wday) = gmtime($timenow+(365*86400)); # Cookie should expire in one year my @months = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); my @days = ('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'); print sprintf("Set-Cookie: intellilinkid=$id; path=/; expires=$days[$wday], %02d-$months[$mon]-%d 00:00:00 GMT\n", $mday, $year+1900); } gotosite($id); sub gotosite { my ($id) = @_; my ($url, %data); if ($id ne '') { %data = getdatabyid($id) } # Check if hits for this account should be forwarded to a special URL if ($data{'forward'} ne '') { $url = $data{'forward'} } else { $url = $siteurl[(int rand(@siteurl))] } print "Location: $url\n\n"; } sub iplog { my $ipfound = 0; my $logip = $ENV{'REMOTE_ADDR'}; if((!$count_noip) && ($logip eq '')) { gotosite(); exit; } if ($sql) { if (!$dbh) { dbconnect() } $logip = $dbh->quote($logip); my $ref = $dbh->selectrow_arrayref("SELECT COUNT(*) FROM iplog WHERE ip=$logip AND id=$id"); $ipfound = $ref->[0]; if (!$ipfound) { $dbh->do("INSERT INTO iplog (ip, id) VALUES($logip, $id)") } } else { open(LOG,'< iplog.txt'); flock(LOG, $LOCK_SH); while ($log = ) { if ($log eq "$logip|$id\n") { $ipfound = 1; last; } } flock(LOG, $LOCK_UN); close(LOG); if (!$ipfound) { open (PFILE, '>>iplog.txt'); flock(PFILE, $LOCK_EX); print PFILE "$logip|$id\n"; flock(PFILE, $LOCK_UN); close PFILE; } } return $ipfound; } sub banref { $referrer = $ENV{'HTTP_REFERER'}; if($referrer ne '') { foreach $banref (@banref) { $banref = regescape($banref); if($referrer =~ /$banref/i) { gotosite(); exit } } } }