#!/usr/bin/perl ############################################################################## # The Real Topsites Version 3.4.2 # # Copyright 2001-2004 G5-Scripts.de webmaster@G5-Scripts.de # # Last Modified 11.05.2004 # # G5-Scripts.de http://www.G5-Scripts.de # ############################################################################## # COPYRIGHT Bestimmungen # # Copyright 2001-2004 G5-Scripts.de All Rights Reserved. # # # # Dieser Script darf sollange benutzt werden, solange # # dieser Copyright Hinweis und all die anderen innerhalb des Scripts # # bestehen bleiben. Wenn Sie diesen Script benutzen, erklären Sie sich # # damit einverstanden, die Copyrights Bestimmungen gelesen zu haben und # # das Sie mit diesen einverstanden sind. # # # # !!! Das Verkaufen des Scripts ohne meiner Einverständnis ist verbotten !!! # # !!!Änderungen am Script ohne meiner Einverständnis sind nicht erlaubt !!! # # # ############################################################################## $variables_file= "admin.cnf"; require "protected/$variables_file"; $remote = $ENV{'REMOTE_ADDR'}; $|=1; use CGI; $CGI::POST_MAX=1024*1024; # Maximale Zeichenkette via method=POST = ca. 1 MB $req = new CGI; @daten=$req->param; for(@daten) { my $value = $req->param($_); $value =~ s/\\'/'/gi; $value =~ s/\'/\\'/gi; $in{$_} = $value; } if ($in{'hitin'} ne "") {if($ref_log eq "ja"){&referer_log;}&hitin;exit;} elsif($in{'out'} ne "") {&out_hit;exit;} elsif($in{'show'} ne "") {&show_banner;exit;} elsif($in{'klick'} ne "") {if($ref_log eq "ja"){&referer_log;}&hitin_klick;exit;} elsif($in{'id'} ne "") {&check_gate;exit;} elsif($in{'button'} eq "show") {&button;exit;} elsif($in{'refresh'} eq "1") {&refresh;exit;} elsif($in{'toplist'} eq "regeln") {®eln;exit;} else {print "Location: $toplist_url/$toplist_dateiname\n\n";}; sub read_split_daten { opendir (MEMBER_DIR, "protected/members"); @members = readdir(MEMBER_DIR); closedir (MEMBER_DIR); $a=0;$v=0; foreach (@members) { if ($members[$a] =~ ".mbr") { open (MEMBER, "; if ($flock eq "ja") {flock(MEMBER, 8);} close (MEMBER); @daten[$v] = join("", $m_daten);$v++;}$a++;} @daten = sort {$b <=> $a} @daten; $a=0;$eintraege=0; foreach (@daten) { @split_daten =split(/\|/, $daten[$a]); if ((($split_daten[0] >= $hits_to_list) && ($split_daten[0] ne "")) && ($split_daten[3] eq "0")){ push(@daten_n, join("\|", @split_daten)); $uebereins++; $heute_hits_in=$heute_hits_in+$split_daten[0]; $heute_hits_out=$heute_hits_out+$split_daten[11]; }$eintraege++;$a++;}} ############################################################################################## ############################################################################################## sub vor_var { ($sp1_br,$sp2_br,$sp3_br,$sp4_br) = split(/\,/, $sp_breiten); $breite=$sp1_br+$sp2_br+$sp3_br+$sp4_br+($tab_rahmenbreite*5)+($tab_zellraum*5); ($sp1_cl,$sp2_cl,$sp3_cl,$sp4_cl) = split(/\,/, $sp_farben); if(length $sp1_cl == 6){$sp1col = "bgcolor=$sp1_cl";} if(length $sp2_cl == 6){$sp2col = "bgcolor=$sp2_cl";} if(length $sp3_cl == 6){$sp3col = "bgcolor=$sp3_cl";} if(length $sp4_cl == 6){$sp4col = "bgcolor=$sp4_cl";} if(($target1 =~ /\W/)||($target1 eq "")){$target="target=_blank";} else {$target="target=$target1";} if(($target2 =~ /\W/)||($target1 eq "")){$target_l="";} else {$target_l="target=$target2";} if(($ausrichtung eq "center") or ($ausrichtung =~ /[^a-zA-Z]/)) {$align="";} else {$align="align=$ausrichtung";} if($banner_fest eq "ja"){$banner_groesse="width=$max_banner_breite height=$max_banner_hoehe"} else {$banner_groesse="";} } sub listenanfang { &vor_var; $HTML = "$toplist_name"; $HTML .= "\n"; $HTML .= "\n\n"; $HTML .= "\n"; if(($iframe eq "1") && ($iframe_gr eq "fest")) {$HTML .= "";} if(($popup eq "1") && ($popup_gr eq "fest")) {$HTML .= "";} $HTML .= "

"; if ($siteofmom eq "ja") {&siteofthemoment;} if ($menu eq "ja") {&menue;} open (HEADER, "); close (HEADER); &tabkopf;&liste; } #**************************site of the moment*************************** sub siteofthemoment { $seiteneintr = $uebereins-1; open (SITEOFMOM, ";close (SITEOFMOM); @siteofmom = split(/\|/, $daten_n[$sofm]); unless (($siteofmom[9] =~ /[.]+[jJ]+[pP]+[gG]/) || ($siteofmom[9] =~ /[.]+[gG]+[iI]+[fF]/)) {$banner_f = "fehler"} $HTML .= "

"; $HTML .= ""; $HTML .= "
$siteofmom_caption
"; if($banner_f ne "fehler"){$HTML .= "\"$siteofmom[5]\"";} if($banner_f eq "fehler"){$HTML .= "$siteofmom[5]
$siteofmom[7]";} if($banner_f eq "fehler") {$banner_f="";} $HTML .= "
"; if ($sofm >= $seiteneintr) {open (SITEOFMOM, ">protected/siteofmom.txt");print SITEOFMOM "0";close (SITEOFMOM);} if ($sofm < $seiteneintr) {$sofm++; open (SITEOFMOM, ">protected/siteofmom.txt");print SITEOFMOM $sofm;close (SITEOFMOM);} } #*********************************menue********************************* sub menue { $HTML .= "

"; $HTML .= ""; $HTML .= ""; $HTML .= ""; $HTML .= ""; $HTML .= ""; $HTML .= "
SEITE EINTRAGENMEMBER LOGINREGELNBOOKMARKKONTAKT
"; } #*********************************TabKopf********************************* sub tabkopf { $HTML .= "
"; $HTML .= ""; $HTML .= ""; } #*********************************liste********************************* sub liste { @umbrch = split(/\,/, $umbruch); $a=$rang-1;$site=1;$aktiveS=$rang-1; for ($i = 0; $i < $sites; $i++) { @split_daten = split(/\|/, $daten_n[$a]); unless (($split_daten[9] =~ /[.]+[jJ]+[pP]+[gG]/) || ($split_daten[9] =~ /[.]+[gG]+[iI]+[fF]/)) {$banner_f = "fehler"} $outurl = "$cgi_url/topsites.cgi?out=$split_daten[4]"; $HTML .= ""; if ($umbrch[$u]==$rang) {$zz++;&umbruch;$u++;} $site++;$rang++;$a++;} if(($umbruch <= 0) || $umbruch eq "") {&liste_close;&tabfuss;} if($umbruch >= 0) {&liste_close;&tabfuss;} } #*********************************umbruch********************************* sub liste_close {$HTML .= "
$sp1_txt$tabkopftext$sp3_txt$sp4_txt
$rang"; if ($split_daten[5] ne "") {$HTML .= "$split_daten[5]
";} if($split_daten[0] >= $hits_to_list) {$aktiveS++;} if(($site <= $banners_to_show) && ($banner_f ne "fehler") && ($nobann ne "ja")) {$HTML .= "
";} if($banner_f eq "fehler") {$banner_f="";} if ((($hits_to_list ne "0") && ($a >= $aktiveS)) || (($hits_to_list eq "0") && ($a >= $eintraege))){$HTML .= "SEITE EINTRAGEN";} if($split_daten[7] ne "") {$HTML .= "$split_daten[7]";} if($split_daten[0] eq "") {$split_daten[0]= " ";} if($split_daten[11] eq "") {$split_daten[11]= " ";} $HTML .= "
$split_daten[0]"; if($ges_hits eq "ja"){$HTML .= "
($split_daten[2])";} $HTML .= "
$split_daten[11]"; if($ges_hits eq "ja"){$HTML .= "
($split_daten[13])";} $HTML .= "
";} sub umbruch { &liste_close; $HTML .= "
"; open (DATA, ");close (DATA); &tabkopf($tabkopftext=$sp2_2_txt); } #*********************************TabFuss********************************* sub tabfuss { $HTML .= "
$eintraege Seiten in der Datenbankdavon $uebereins Seiten aktivinsgesamt $heute_hits_in Hits INinsgesamt $heute_hits_out Hits Out
"; if ($menu eq "ja") {&parts_links;} &schluss; } #*********************************TabAbschluss********************************* sub parts_links { if($split_list eq "1") { ($filename,$ext) = split(/\./, $toplist_dateiname); $rangab = 1;$rangbis = $siteperlistpart;$listpartslinks=0;$l=""; $HTML .= "

"; for($listpartslinks; $listpartslinks<$max_members_to_show; $listpartslinks=$listpartslinks+$siteperlistpart) { $HTML .= ""; $rangab=$rangab+$siteperlistpart;$rangbis=$rangbis+$siteperlistpart;$l++; }$HTML .= "
$rangab - $rangbis
";}} sub schluss { if ($menu eq "ja") {&menue;}$f=0; open (FOOTER, "); close (FOOTER); $HTML .= "
\x3C\x73\x70\x61\x6E \x63\x6C\x61\x73\x73\x3D\"\x74\x65\x78\x74\">\x50\x6F\x77\x65\x72\x65\x64 \x62\x79 \x3C\x61 \x68ref=\"\x68\x74\x74\x70\x3A\x2F\x2F\x77\x77"; #! Der Copyrights Hinweis darf nicht entfernt werden. Wenn Sie diesen Script benutzen und den Copyrights Hinweis entfernen, # dann verstoßen Sie gegen unsere Copyrights Bestimmungen ! $HTML .= "\x77\x2E\x47\x35\x2D\x53\x63\x72\x69\x70\x74\x73\x2E\x64\x65\" \x74\x61\x72\x67\x65\x74\x3D\"_blank\">\x54\x68\x65 \x52\x65\x61\x6C \x54\x6F\x70\x73\x69\x74\x65\x73\x3C/a>
"; } sub toplist_schreiben { &update_list; print "Location: $toplist_url/$toplist_dateiname\n\n";exit; } ############################################################################################## ############################################################################################## sub refresh {&toplist_schreiben;} sub ip_sperre { my $account =$in{'show'} ||=$in{'hitin'} ||=$in{'klick'} ||=$in{'out'} ||=$in{'id'}; $newtime=time; $checktime=time - $IP_sperre_zeit*60; if (-e "protected/members/$account.mbr") { if(-e "protected/ips/$account.txt") { open(LOG, "+; foreach $line (@daten_all) {@element = split(/\|/, $line); if($element[2] > $checktime) {push(@daten, join("", $line));}} seek(LOG, 0,0); foreach $line (@daten) { @element = split(/\|/, $line); if($element[1] eq $remote) { if ($element[2] > $checktime) {$found="1";} elsif($element[2] < $checktime) {$zeit_in_log=$newtime; $erneuert="1";} } print LOG "0|$element[1]|$element[2]|0\n"; } if(($found ne "1") && ($erneuert ne "1")) { print LOG "0|$remote|$newtime|0\n";} close(LOG); } else { if((-e "protected/ips") == false){ mkdir('protected/ips',0777)} open(LOG, ">protected/ips/$account.txt"); print LOG "0|$remote|$newtime|0\n"; close(LOG); } if ($found eq "1") {$ip_sperre = "aktiv";} }} sub referer_log { my $referer=$ENV{'HTTP_REFERER'}; my $account =$in{'show'} ||=$in{'hitin'} ||=$in{'klick'} ||=$in{'out'}; my $zeit = localtime(time); my @split_zeit = split(/ +/,$zeit); if(open(LOGFILE, ">>protected/logs/$account.txt") == false){ mkdir('protected/logs',0777)} print LOGFILE "0|$remote|$split_zeit[3]|$referer|0\n"; close (LOGFILE); } sub regeln { print "Content-type: text/html\n\n"; print "\n"; print "Regeln\n"; print ""; print "
"; print "
"; open (REGELN, ";close (REGELN); print "
"; print "
Powered by The Real Topsites
"; exit; } sub hitin { $member_id =$in{'show'} ||=$in{'hitin'} ||=$in{'klick'}; if($member_id =~ /[^0-9]/) {&fehler($login_fehler="Account mit der ID: $member_id nicht vorhanden!");} if($gateway eq "1") {&show_gate;exit;} if ($IP_sperre eq "1") {&ip_sperre;} if($ip_sperre eq "aktiv") {print "Location: $toplist_url/$toplist_dateiname\n\n";exit;} &hit_in; &timecheck; print "Location: $toplist_url/$toplist_dateiname\n\n"; exit; } sub hitin_klick { $member_id =$in{'show'} ||=$in{'hitin'} ||=$in{'klick'}; if($member_id =~ /[^0-9]/) {&fehler($login_fehler="Account mit der ID: $member_id nicht vorhanden!");} if($gateway eq "1") {&show_gate;exit;} if ($IP_sperre eq "1") {&ip_sperre;} if($ip_sperre eq "aktiv") { if($on_klick_go eq "0") {print "Location: $toplist_url/$toplist_dateiname\n\n";} if($on_klick_go ne "0") {print "Location: $on_klick_go\n\n";} exit;} &hit_in;&timecheck; if($on_klick_go eq "0") {print "Location: $toplist_url/$toplist_dateiname\n\n";} if($on_klick_go ne "0") {print "Location: $on_klick_go\n\n";} exit; } sub show_banner { if($ref_log eq "ja"){&referer_log;} if ($IP_sperre eq "1") {&ip_sperre;} if($ip_sperre ne "aktiv") {&hit_in;} &button; } sub button { &timecheck; print "Location: $button_url\n\n"; exit;; } sub hit_in { $mbr = $in{'show'} ||=$in{'hitin'} ||=$in{'klick'} ||=$in{'id'}; if (-e "protected/members/$mbr.mbr") { open(COUNT, "+); if($count[4] eq "") {&read_back;} if(($mbr eq $count[4]) && ($count[3] eq "0")) { $count[0]++; $count[2]++; } seek (COUNT, 0, 0); print COUNT join('|', @count); if ($flock eq "ja") {flock(COUNT, 8);} close(COUNT); &write_back; } #if($in{'show'} eq '') { #print "Location: $toplist_url/$toplist_dateiname\n\n"; #exit; #} } sub out_hit { if ($IP_sperre2 eq "1") {&ip_sperre;} $mbr = $in{'out'}; if(($IP_sperre2 eq "1") && ($ip_sperre eq "aktiv")) { &read_mbr; print "Location: $split_daten[6]\n\n";exit; } if (-e "protected/members/$mbr.mbr") { open(COUNT, "+); if($count[4] eq "") {&read_back;} $count[11]++; $count[13]++; seek (COUNT, 0, 0); print COUNT join('|', @count); if ($flock eq "ja") {flock(COUNT, 8);} close(COUNT); &write_back; } &timecheck; print "Location: $count[6]\n\n"; exit; } sub read_mbr { open (USER_DATA, "); if ($flock eq "ja") {flock(USER_DATA, 8);} close (USER_DATA); } sub read_back { open (USER_DATA, "); if ($flock eq "ja") {flock(USER_DATA, 8);} close (USER_DATA); } sub write_back { open (DATEN, ">protected/members/$mbr.bak"); if ($flock eq "ja") {flock(DATEN, 1);} print DATEN join('|', @count); if ($flock eq "ja") {flock(DATEN, 8);} close (DATEN); } sub show_gate { $ID = $in{'show'} ||=$in{'hitin'} ||=$in{'klick'}; open(GATE, "); if ($flock eq "ja") {flock(GATE, 8);} close(GATE); &read_gate; $gate_code =~ s/\<--FORMANF-->/
/g; $gate_code =~ s/\<--FORMEND-->/<\/form>/g; $gate_code =~ s/\<--CGIURL-->/$cgi_url\/topsites.cgi/g; $gate_code =~ s/\<--MEMBER-->/$ID/g; $gate_code =~ s/\<--GATE-->/$gate_nr/g; $gate_code =~ s/\<--VOTEBTN-->//g; print "Content-Type: text/html\n\n"; print $gate_code; exit; } sub check_gate { $ID=$in{'id'}; $gate=$in{'gate'}; &read_gate; &write_new_gate; if ($IP_sperre eq "1") {&ip_sperre;} if($gate_nr eq $gate) { if ($ip_sperre ne "aktiv") {&hit_in;} &timecheck; if($on_klick_go eq "0") {print "Location: $toplist_url/$toplist_dateiname\n\n";} if($on_klick_go ne "0") {print "Location: $on_klick_go\n\n";} exit; } elsif (($gate_nr ne $gate) || ($ip_sperre eq "aktiv")) { &timecheck; if($on_klick_go eq "0") {print "Location: $toplist_url/$toplist_dateiname\n\n";} if($on_klick_go ne "0") {print "Location: $on_klick_go\n\n";} exit; } } sub read_gate { open(GATE, "; if ($flock eq "ja") {flock(GATE, 8);} close(GATE); } sub write_new_gate { my @alphab = ('a'..'z', 'A'..'Z', '0'..'9'); for(1..10) {$a=int(rand(62));$new_gate_nr=join("", $new_gate_nr,$alphab[$a]);} if(open(GATE, ">protected/gate/$ID.txt") == false){ mkdir('protected/gate',0777)} if ($flock eq "ja") {flock(GATE, 1);} print GATE $new_gate_nr; if ($flock eq "ja") {flock(GATE, 8);} close(GATE); } sub timecheck { my $jetztwert = time(); open (reset_time, ";close (reset_time); open (update_time, ";close (update_time); if ($jetztwert > $reset_time+($toplist_reset*86400)){ open (reset_time, ">protected/reset_time.txt");print reset_time $jetztwert; close (reset_time); &reset_list;} elsif ($jetztwert > $update_time+($toplist_update_zeit*60)) { open (update_time, ">protected/update_time.txt");print update_time $jetztwert; close (update_time); &update_list; }} sub reset_list { opendir (MEMBER_DIR, "protected/members"); @members = readdir(MEMBER_DIR); closedir (MEMBER_DIR); $a=0; foreach (@members) { if ($members[$a] =~ ".mbr") { open (MEMBER, "; if ($flock eq "ja") {flock(MEMBER, 8);} close (MEMBER); @split_daten = split(/\|/, $m_daten); $split_daten[1] = $split_daten[0]; $split_daten[12] = $split_daten[11]; $split_daten[0] = 0; $split_daten[11] = 0; $daten_n = join('|', @split_daten); if ($daten_n ne "") { open (MEMBER, ">protected/members/$members[$a]"); if ($flock eq "ja") {flock(MEMBER, 1);} print MEMBER $daten_n; if ($flock eq "ja") {flock(MEMBER, 8);} close (MEMBER); }}$a++;} open (SITEOFMOM, ">protected/siteofmom.txt");print SITEOFMOM "0";close (SITEOFMOM); if ($IP_sperre eq "1") {&ipfiles_delete;&log_delete;}} sub ipfiles_delete { $ips_dir ="$cgi_path\protected/ips/"; opendir (IP_DIR, $ips_dir); @files = readdir(IP_DIR); closedir (IP_DIR); chdir $ips_dir; foreach $file (@files) {unlink $file;} } sub log_delete { $log_dir ="$cgi_path\protected/logs/"; opendir (IP_DIR, $log_dir); @files = readdir(IP_DIR); closedir (IP_DIR); chdir $log_dir; foreach $file (@files) {unlink $file;} } sub update_list { if($split_list ne "1") { $sites = $max_members_to_show; $tabkopftext=$sp2_txt; $rang=1;$u=0; $toplist = "$toplist_path$toplist_dateiname"; &read_split_daten; &listenanfang; open (TOPSITES, ">$toplist");print TOPSITES $HTML;close (TOPSITES); } if($split_list eq "1") { $sites = $siteperlistpart; $tabkopftext=$sp2_txt; ($filename,$ext) = split(/\./, $toplist_dateiname); &read_split_daten; $rang=1;$u=0; for($listparts; $listparts<$max_members_to_show; $listparts=$listparts+$siteperlistpart) { $dateiname = "$filename$p"; $toplist = "$toplist_path$dateiname.$ext"; &listenanfang; open (TOPSITES, ">$toplist");print TOPSITES $HTML;close (TOPSITES); $rang=$rang;$sites = $siteperlistpart; if($bann4allparts eq "ja") {$nobann="nein";} else {$nobann="ja";} $p++; }}} sub mbr_repair{ open (MEMBER, "; if ($flock eq "ja") {flock(MEMBER, 8);} close (MEMBER); open (MEMBER, ">protected/members/$mbr.mbr"); if ($flock eq "ja") {flock(MEMBER, 1);} print MEMBER $m_daten; if ($flock eq "ja") {flock(MEMBER, 8);} close (MEMBER); @split_daten = split(/\|/, $m_daten); } sub fehler { print "Content-type: text/html\n\n"; print "Error!

"; print ""; print "
!! ERROR !!
$login_fehler

"; print "
"; exit;} ###########################################################################################