#!/usr/bin/perl
use CGI::Carp qw(fatalsToBrowser);
$version="3.0A Premium";
require "config/premiumtopliste.cfg";
###################################################
#### makme-topliste - Toplisten-Script         ####
#### Version 3.0A Premium Date: 28.06.2008     ####
#### Option Ueber18.de Alterskontrolle(update) ####
#### copyright by makme, media & entertainment ####
###################################################

# mitglieds.dat umschreiben, neu einlesen und umbenennen in user.dat und mitglieds.dat sichern 28.02.2006
# Datei meta.dat umschreiben, neu einlesen und umbenennen in metatag.dat 28.02.2006
# Update vom 02.05.2009

### Programmablauf der Premiumtopliste

if ($ENV{'REQUEST_METHOD'} eq 'POST') {
  read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
} else {
  $buffer = $ENV{'QUERY_STRING'};
}
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
  ($name, $value) = split(/=/, $pair);
  $name =~ tr/+/ /;
  $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
  $value =~ tr/+/ /;
  $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
  $value =~ s/\|//eg;
  $FORM{$name} = $value;
}
if    ($FORM{action} eq "neues_mitglied")   { &confirm_rules;}
elsif ($FORM{action} eq "rules_accept")     { &neues_mitglied_form;}
elsif ($FORM{action} eq "hit_out")          { &checkip;        }
elsif ($FORM{action} eq "hit_in")           { &check_torlauf_option;  }
elsif ($FORM{action} eq "hit_in_torlauf")   { &check_torlauf;  }
elsif ($FORM{action} eq "edit_mitglied")    { &edit_form;      }
elsif ($FORM{action} eq "vote")             { &vote_form;      }
elsif ($FORM{action} eq "vote_final")       { &checkip;        }
elsif ($FORM{action} eq "show_vote")        { &show_vote;      }
elsif ($FORM{action} eq "lostpassform")     { &lost_pass_form; }
elsif ($FORM{action} eq "regeln")           { &regeln;         }
elsif ($FORM{lost_password} eq "ja")        { &search_pass;    }
elsif ($FORM{ID})                           { &awm_hit_out     }
else {
      &check_update;
      print "Location: $no_cgi_url/$dateiname.$mak_dat\n\n";
      exit;
      }

sub check_torlauf {
### Loesche alte Torläufe
$maxtorzeit = ($torlauf_maxtime*60);
$zeit = time;
open (IP,"<config/log/session/session.log")||die("Konnte die Datei session.log nicht einlesen");
if ($use_flock eq "1") {flock (IP,1);}
@OLDGW =<IP>;
foreach $line (@OLDGW) {
    @TEMP_GW = split(/\|/,$line);
    if ((($TEMP_GW[1]+$maxtorzeit)>$zeit)&&($TEMP_GW[0] ne $FORM{session}))
       {push @NEWGW,"$line";}
    if ($TEMP_GW[0] eq $FORM{session})
       {$usersession="$line"; }
    }
if ($use_flock eq "1") {flock (IP,8);}
close (IP);
open (NEWIP,">config/log/session/session.log")||die("Konnte die Datei session.log nicht schreiben");
if ($use_flock eq "1") {flock (NEWIP,1);}
print NEWIP @NEWGW;
if ($use_flock eq "1") {flock (NEWIP,8);}
close (NEWIP);
### Aktuellen Torlauf (torlauf) pruefen
if ($usersession ne"")
{
 @SESSIONDAT = split(/\|/,$usersession);
 $FORM{account}="$SESSIONDAT[2]";
 $FORM{action}="hit_in";
 &checkip;
 }
else {
      print "Location: $no_cgi_url/$dateiname.$mak_dat\n\n";
      exit;
     }
}

sub check_torlauf_option {
if   ($torlauf eq "on") {&create_torlauf_session;}
else {&checkip;}
}

sub create_torlauf_session {
### neue Sitzung ID
  @BITS = ('a'..'Z', '0'..'9');
  $session_id="";
   for(0..9) {
    my $BITS = $BITS[ int(rand($#BITS + 1)) ];
    $session_id .="$BITS";
  }
### Torlaufsitzung in session.log schreiben
  $sessionzeit = time();
  open (SESSIONLOG,">>config/log/session/session.log")||die("Konnte die Datei session.log nicht beschreiben");
  if ($use_flock eq "1") {flock (SESSIONLOG,1);}
  print SESSIONLOG "$session_id|$sessionzeit|$FORM{account}|\n";
  if ($use_flock eq "1") {flock (SESSIONLOG,8);}
  close(SESSIONLOG);
### Torlauf (torlauf) erzeugen und Besucher umleiten
  print "Content-type: text/html\n\n";
            open (DATEI,"<$cgi_root_path/config/insert/torlauf.dat")||die("Konnte die Datei torlauf.log nicht einlesen");
            if ($use_flock eq "1") {flock (DATEI,1);}
            @DATEN =<DATEI>;
            if ($use_flock eq "1") {flock (DATEI,8);}
            close (DATEI);
            foreach $line (@DATEN)
            { $line =~ s/\<URL\>/$cgi_root_url\/topliste.cgi/gio;
              $line =~ s/\<SESSION\>/$session_id/gio;
            print $line;
            }
exit;
}

sub checkip {

$userip = $ENV{REMOTE_ADDR};
if($ENV{'HTTP_VIA'} || $ENV{'HTTP_X_FORWARDED_FOR'})
   {
   $found_proxy_server="on";
### Adminupdate check
   open (UPDATE, "<$cgi_root_path/config/adminproxy.txt");
   if ($use_flock eq "1") {flock (UPDATE,1);}
   $line =<UPDATE>;
   if ($use_flock eq "1") {flock (UPDATE,8);}
   close (UPDATE);
          if ($line eq "adminproxy_on"){
               $found_proxy_server="no";
               open (UPDATE, ">$cgi_root_path/config/adminproxy.txt");
               if ($use_flock eq "1") {flock (UPDATE,1);}
              print UPDATE "";
               if ($use_flock eq "1") {flock (UPDATE,8);}
               close (UPDATE);
               chmod 0777, "$cgi_root_path/config/adminproxy.txt";
               }
    }
else {$found_proxy_server="no";}
$zeit = time;
### Zeiten fuer IP-Adressen
$minvotetime=($minzeit_vote*60);
$hitintime=($minzeit_hitin*60);
$hitouttime=($minzeit_hitout*60);
$maxiptime=($max_log_alter*3600);

### alte IP-Eintraege loeschen
open (IP,"<config/log/ip.log")||die("Konnte die Datei ip.log nicht einlesen");
if ($use_flock eq "1") {flock (IP,1);}
@OLDIP =<IP>;
foreach $line (@OLDIP) {
    @ZEIT = split(/\|/,$line);
    if (($ZEIT[1]+$maxiptime)>$zeit){push @NEWIP,"$line";}
    }
if ($use_flock eq "1") {flock (IP,8);}
close (IP);
open (NEWIP,">config/log/ip.log")||die("Konnte die Datei session.log nicht beschreiben");
if ($use_flock eq "1") {flock (NEWIP,1);}
print NEWIP @NEWIP;
if ($use_flock eq "1") {flock (NEWIP,8);}
close (NEWIP);
### IP fuer Hit_IN pruefen
if  ($FORM{action} eq  "hit_in"){
### log proxyserver hit in (only redirect to toplist.html without update toplist to prevent serveroverload!)
        if (($found_proxy_server eq "on")&&($proxyfilter eq "on"))
        {
### proxylogbuch ein/aus
    if ($do_log_proxy ne "no"){
    open (PROXY_LOG,">>config/log/proxy.log")||die("Konnte die Datei proxy.log nicht einlesen");
    if ($use_flock eq "1") {flock (PROXY_LOG,1);}
    print PROXY_LOG "$userip|$zeit|$FORM{action}|$FORM{account}|$ENV{'HTTP_VIA'}|$ENV{'HTTP_X_FORWARDED_FOR'}\n";
    if ($use_flock eq "1") {flock (PROXY_LOG,8);}
    close(PROXY_LOG);
    }
    if ($hit_option eq alternative_URL)
    {
    if ($hit_in_url_alternative eq ""){print "Location: $no_cgi_url/$dateiname.$mak_dat\n\n";}
    else{print "Location: $hit_in_url_alternative\n\n";}
    }
    else{print "Location: $no_cgi_url/$dateiname.$mak_dat\n\n";};
    exit;
    }
### Hit in ueber Proxyserver pruefen
else {
     $last_hit_in_time=0;
     $hit_in_gefunden=0;
     foreach $line (@NEWIP)
            {
             chomp ($line) if ($line =~ /\n/);
             @hit_in_IP = split(/\|/,$line);
             if (($hit_in_IP[0] eq $userip)&&($hit_in_IP[2] eq $FORM{action})&&($hit_in_IP[3] eq $FORM{account}))
            {$hit_in_gefunden="1";
             $last_hit_in_time=$hit_in_IP[1];
            }
            }
### mehrfache hit-in in Logbuch schreiben
          if (($hit_in_gefunden eq "1")&&($zeit<($last_hit_in_time+$hitintime))){
### Hitin/out logbuch an aus
               if ($do_log_hit ne "no"){
               open (hit_LOG,">>config/log/hit.log")||die("Konnte die Datei hit.log nicht beschreiben");
               if ($use_flock eq "1") {flock (hit_LOG,1);}
               print hit_LOG "$userip|$zeit|$FORM{action}|$FORM{account}|\n";
               if ($use_flock eq "1") {flock (hit_LOG,8);}
               close(hit_LOG);
               }
               &check_update;
               if ($hit_option eq alternative_URL)
                  {
                    if ($hit_in_url_alternative eq ""){print "Location: $no_cgi_url/$dateiname.$mak_dat\n\n";}
                    else{print "Location: $hit_in_url_alternative\n\n";}
                   }
                else{print "Location: $no_cgi_url/$dateiname.$mak_dat\n\n";}
              }
##
          else {
                open (hit_in_LOG,">>config/log/ip.log")||die("Konnte die Datei ip.log nicht beschreiben");
                if ($use_flock eq "1") {flock (hit_in_LOG,1);}
                print hit_in_LOG "$userip|$zeit|$FORM{action}|$FORM{account}\n";
                if ($use_flock eq "1") {flock (hit_in_LOG,8);}
                close(hit_in_LOG);
                &check_update;
                &log_hit_in;
                if ($hit_option eq alternative_URL)
                      {
                        if ($hit_in_url_alternative eq ""){print "Location: $no_cgi_url/$dateiname.$mak_dat\n\n";}
                        else{print "Location: $hit_in_url_alternative\n\n";}
                      }
                else{print "Location: $no_cgi_url/$dateiname.$mak_dat\n\n";}
                exit;
               }
        }
 }
### IP fuer Hit_out pruefen
if  ($FORM{action} eq  "hit_out"){
### hit out ueber Proxyserver
     if (($found_proxy_server eq "on")&&($proxyfilter eq "on"))
        {
### Hit in/out Logbuch an/aus
         if($do_log_hit ne "no"){
         open (PROXY_LOG,">>config/log/proxy.log")||die("Konnte die Datei proxy.log nicht beschreiben");
         if ($use_flock eq "1") {flock (PROXY_LOG,1);}
         print PROXY_LOG "$userip|$zeit|$FORM{action}|$FORM{account}|$ENV{'HTTP_VIA'}|$ENV{'HTTP_X_FORWARDED_FOR'}\n";
         if ($use_flock eq "1") {flock (PROXY_LOG,8);}
         close(PROXY_LOG);
         }
                $datensatz=0;
                open (ALLEACCOUNTS, "<$userdatapath/user.dat")||die("Konnte die Datei user.dat nicht einlesen");
                if ($use_flock eq "1") {flock (ALLEACCOUNTS,1);}
                @ALLEACCOUNTS = <ALLEACCOUNTS>;
                foreach (@ALLEACCOUNTS){
                                         @USER = split(/\|/, $ALLEACCOUNTS[$datensatz]);
                                         if ($USER[4] eq  $FORM{account})
                                               {
                                                $redirect   = "$USER[11]";
                                                $awm_status = "$USER[32]";
                                                $awm_system = "$USER[33]";
                                                $awm_id     = "$USER[34]";
                                               }
                                          $datensatz++;
                                        }
                if ($use_flock eq "1") {flock (ALLEACCOUNTS,8);}
                close (ALLEACCOUNTS);


                 if ($awm_status eq "awm_check_on")
                    {
                     &awm_check;exit;
                    }
                   else {print "Location: $redirect \n\n";exit;}
         }
### Hit out ueber Proxyserver
   else {
             $last_hit_out_time=0;
             $hit_out_gefunden=0;
        foreach $line (@NEWIP) {
             chomp ($line) if ($line =~ /\n/);
             @hit_out_IP = split(/\|/,$line);
             if (($hit_out_IP[0] eq $userip)&&($hit_out_IP[2] eq $FORM{action})&&($hit_out_IP[3] eq $FORM{account}))
                {
                 $last_hit_out_time=$hit_out_IP[1];
                 $hit_out_gefunden=1;
                }
             }
### Logbuch mehrfache hit-out
          if (($hit_out_gefunden eq "1")&&($zeit<($last_hit_out_time+$hitouttime))){
               &check_update;
               $datensatz=0;
                open (ALLEACCOUNTS, "<$userdatapath/user.dat")||die("Konnte die Datei user.dat nicht einlesen");
                if ($use_flock eq "1") {flock (ALLEACCOUNTS,1);}
                @ALLEACCOUNTS = <ALLEACCOUNTS>;
                foreach (@ALLEACCOUNTS){
                                         @USER = split(/\|/, $ALLEACCOUNTS[$datensatz]);
                                         if ($USER[4] eq  $FORM{account})
                                               {
                                                $redirect   = "$USER[11]";
                                                $awm_status = "$USER[32]";
                                                $awm_system = "$USER[33]";
                                                $awm_id     = "$USER[34]";
                                               }
                                          $datensatz++;
                                        }
                if ($use_flock eq "1") {flock (ALLEACCOUNTS,8);}
              close (ALLEACCOUNTS);
### Hit in/out Logbuch an/aus
              if ($do_log_hit ne "no"){
              open (hit_LOG,">>config/log/hit.log")||die("Konnte die Datei hit.log nicht beschreiben");
              if ($use_flock eq "1") {flock (hit_LOG,1);}
              print hit_LOG "$userip|$zeit|$FORM{action}|$FORM{account}|\n";
              if ($use_flock eq "1") {flock (hit_LOG,8);}
              close(hit_LOG);
              }
                if ($awm_status eq "awm_check_on")
                     {
                      &awm_check;exit;
                     }
                else {print "Location: $redirect \n\n";exit;}
              }

          else {
                open (hit_out_LOG,">>config/log/ip.log")||die("Konnte die Datei ip.log nicht beschreiben");
                if ($use_flock eq "1") {flock (hit_out_LOG,1);}
                print hit_out_LOG "$userip|$zeit|$FORM{action}|$FORM{account}\n";
                if ($use_flock eq "1") {flock (hit_out_LOG,8);}
                close(hit_out_LOG);
                &check_update;
                &log_hit_out;
                exit;
               }
        }
}

### IP fuer Bewertung pruefen
if  ($FORM{action} eq  "vote_final"){
    if (($found_proxy_server eq "on")&&($proxyfilter eq "on"))
        {
### log proxyserver vote
    if ($found_proxy_server eq "on")
             { ### Proxylogbuch an/aus
               if ($do_log_proxy ne "no"){
                open (PROXY_LOG,">>config/log/proxy.log")||die("Konnte die Datei proxy.log nicht beschreiben");
                if ($use_flock eq "1") {flock (PROXY_LOG,1);}
                print PROXY_LOG "$userip|$zeit|$FORM{action}|$FORM{account}|$ENV{'HTTP_VIA'}|$ENV{'HTTP_X_FORWARDED_FOR'}\n";
                if ($use_flock eq "1") {flock (PROXY_LOG,8);}
                close(PROXY_LOG);
               }
               push @FEHLER , "<p align=\"center\"><font face\=\"$font\" size\=\"$error_font_size\" color\=$error_font_color>\n";
               push @FEHLER , "FAIRPLAY!!! Bewertungen &uuml;ber Proxyserver werden in dieser Premiumtopliste nicht akzeptiert!<br><br>Proxy-Server: $ENV{'HTTP_VIA'} $ENV{'HTTP_X_FORWARDED_FOR'}</font></p>\n";
               &error;
             }
         }
### Bewertung ueber Proxyserver pruefen
      else {
            $lastvote_time = "0";
            $votegefunden = "0";

             foreach $line (@NEWIP) {
             chomp ($line) if ($line =~ /\n/);
             @VOTEIP = split(/\|/,$line);
             if (($VOTEIP[0] eq $userip)&&($VOTEIP[2] eq $FORM{action})&&($VOTEIP[3] eq $FORM{account}))
                {$votegefunden++;
                 $lastvote_time=$VOTEIP[1];
                }
             }
     if (($votegefunden <=($maxvote_pro_account-1))&&( $zeit > ($lastvote_time+$minvotetime))){
          open (VOTELOG,">>config/log/ip.log")||die("Konnte die Datei ip.log nicht beschreiben");
          if ($use_flock eq "1") {flock (VOTELOG,1);}
          print VOTELOG "$userip|$zeit|$FORM{action}|$FORM{account}\n";
          if ($use_flock eq "1") {flock (VOTELOG,8);}
          close(VOTELOG);
          &vote_final;&check_update;
          }
### Logbuch fuer mehrfache Bewertung
      if (($votegefunden <=($maxvote_pro_account-1))&&( $zeit < ($lastvote_time+$minvotetime))){
          ### Votelogbuch an/aus
          if ($do_log_vote ne "no"){
          open (VOTELOG,">>config/log/vote.log")||die("Konnte die Datei vote.log nicht beschreiben");
          if ($use_flock eq "1") {flock (VOTELOG,1);}
          print VOTELOG "$userip|$zeit|$FORM{action}|$FORM{account}\n";
          if ($use_flock eq "1") {flock (VOTELOG,8);}
          close(VOTELOG);
          }
          push @FEHLER , "<p align=\"center\"><font face\=\"$font\" size\=\"$error_font_size\" color\=\"$error_font_color\">\n";
          push @FEHLER , "FAIRPLAY!!! Sie k&ouml;nnen dieses Mitglied nur alle $minzeit_vote Minuten bewerten!</font></p>\n";
          &error;
          }
### mehrfache Bewertungen in Logbuch schreiben
      if ($votegefunden > ($maxvote_pro_account-1)) {
          ### Votelogbuch an/aus
          if ($do_log_vote ne "no"){
          open (VOTELOG,">>config/log/vote.log")||die("Konnte die Datei vote.log nicht beschreiben");
          if ($use_flock eq "1") {flock (VOTELOG,1);}
          print VOTELOG "$userip|$zeit|$FORM{action}|$FORM{account}\n";
          if ($use_flock eq "1") {flock (VOTELOG,8);}
          close(VOTELOG);
          }
          push @FEHLER , "<p align=\"center\"><font face\=$font size\=\"$error_font_size\" color\=\"$error_font_color\">\n";
          push @FEHLER , "FAIRPLAY!!! Sie k&ouml;nnen  dieses  \"$FORM{account}\" Mitglied maximal $maxvote_pro_account mal je Sitzung bewerten!</font></p>\n";
          &error;
          }
       }
    }
 }

sub check_update {
         $zeit = time();
     if (!-e "$no_cgi_path/$dateiname.$mak_dat")
        { &create_new_toplist; }
     if (!-e "$cgi_root_path/config/reset.txt")
        { open (RESET, ">$cgi_root_path/config/reset.txt")||die("Konnte die Datei reset.txt nicht erzeugen");
          if ($use_flock eq "1") {flock (RESET,1);}
          print RESET $zeit;
          if ($use_flock eq "1") {flock (RESET,8);}
          close (RESET);
        }
     if (!-e "$cgi_root_path/config/reset_alle.txt")
        { open (RESETALL, ">$cgi_root_path/config/reset_alle.txt")||die("Konnte die Datei reset_alle.txt nicht erzeugen");
          if ($use_flock eq "1") {flock (RESETALL,1);}
          print RESETALL $zeit;
          if ($use_flock eq "1") {flock (RESETALL,8);}
          close (RESETALL);
        }
     if (!-e "$cgi_root_path/config/update.txt")
        { open (UPDATE, ">$cgi_root_path/config/update.txt")||die("Konnte die Datei update.txt nicht erzeugen");
          if ($use_flock eq "1") {flock (UPDATE,1);}
          print UPDATE $zeit;
          if ($use_flock eq "1") {flock (UPDATE,8);}
          close (UPDATE);
        }
     if (!-e "$cgi_root_path/config/backup.txt")
        { open (BACKUP, ">$cgi_root_path/config/backup.txt")||die("Konnte die Datei backup.txt nicht erzeugen");
          if ($use_flock eq "1") {flock (BACKUP,1);}
          print BACKUP $zeit;
          if ($use_flock eq "1") {flock (BACKUP,8);}
          close (BACKUP);
        }
      open (RESET, "<$cgi_root_path/config/reset.txt")||die("Konnte die Datei reset.txt nicht einlesen");
      if ($use_flock eq "1") {flock (RESET,1);}
      $last_reset = <RESET>;
      if ($use_flock eq "1") {flock (RESET,8);}
      close (RESET);
      open (RESETALL,"<$cgi_root_path/config/reset_alle.txt"||die("Konnte die Datei reset_alle.txt nicht einlesen"));
      if ($use_flock eq "1") {flock (RESETALL,1);}
      $last_reset_alle = <RESETALL>;
      if ($use_flock eq "1") {flock (RESETALL,8);}
      close (RESETALL);
      open (UPDATE,"<$cgi_root_path/config/update.txt")||die("Konnte die Datei update.txt nicht einlesen");
      if ($use_flock eq "1") {flock (UPDATE,1);}
      $last_update =<UPDATE>;
      if ($use_flock eq "1") {flock (UPDATE,8);}
      close (UPDATE);
      open (BACKUP,"<$cgi_root_path/config/backup.txt")||die("Konnte die Datei backup.txt nicht einlesen");
      if ($use_flock eq "1") {flock (BACKUP,1);}
      $last_backup =<BACKUP>;
      if ($use_flock eq "1") {flock (BACKUP,8);}
      close (BACKUP);

 if ($zeit > $last_backup+($backup_day*86400))
    { open (BACKUP,">$cgi_root_path/config/backup.txt")||die("Konnte die Datei backup.txt nicht beschreiben");
      if ($use_flock eq "1") {flock (BACKUP,1);}
      print BACKUP $zeit;
      if ($use_flock eq "1") {flock (BACKUP,8);}
      close (BACKUP);
      &backup;
    }
 if ($zeit > $last_reset+($reset_time*86400))
     { open (RESET, ">$cgi_root_path/config/reset.txt")||die("Konnte die Datei reset.txt nicht beschreiben");
      if ($use_flock eq "1") {flock (RESET,1);}
      print RESET $zeit;
      if ($use_flock eq "1") {flock (RESET,8);}
      close (RESET);
      &reset_account;
      &create_new_toplist;
     }
     elsif ($zeit > $last_reset_alle+($reset_alle_time*86400))
     { open (RESETALL, ">$cgi_root_path/config/reset_alle.txt")||die("Konnte die Datei reset_alle.txt nicht beschreiben");
       if ($use_flock eq "1") {flock (RESETALL,1);}
       print RESETALL $zeit;
       if ($use_flock eq "1") {flock (RESETALL,8);}
       close (RESETALL);
       &reset_alle_accounts;
       &create_new_toplist;
     }
     elsif ($zeit > $last_update+($update_time*60))
     { open (UPDATE, ">$cgi_root_path/config/update.txt")||die("Konnte die Datei update.txt nicht beschreiben");
       if ($use_flock eq "1") {flock (UPDATE,1);}
       print UPDATE $zeit;
       if ($use_flock eq "1") {flock (UPDATE,8);}
       close (UPDATE);
       &update_account;
       &create_new_toplist;
     }
}

sub create_new_toplist {
### Mitgliedsdaten auslesen/sortieren

open (ACCOUNT, "<$userdatapath/user.dat")||die("Konnte die Datei user.dat nicht einlesen");
            if ($use_flock eq "1") {flock (ACCOUNT,1);}
            @ALLEDATEN = <ACCOUNT>;
            if ($use_flock eq "1") {flock (ACCOUNT,8);}
close (ACCOUNT);
@ALLEDATEN = sort {$b <=> $a} @ALLEDATEN;
### Mitgliedsdaten pruefen
    $datensatz = "0";
    $user_found= "0";

foreach (@ALLEDATEN)
    {
     @TEMPARRY = split (/\|/,$ALLEDATEN[$datensatz] );
### Toplistenerstellung
      if (($TEMPARRY[0] >=$min_hit) && ($TEMPARRY[18] ne "0") && ($user_found < $max_in_list))
          {
             push (@TOPUSER, join ("\|", @TEMPARRY));
             $user_found++;
          }
### aktive Mitglieder
       if (($TEMPARRY[0] >=$min_hit) && ($TEMPARRY[18] ne "0"))
          {
             push (@AKTIV,$TEMPARRY[4]);
          }

     $datensatz++;
    }
$eingetragene_mitglieder=$datensatz++;
$active_mitglieder=@AKTIV;
### Seitenanzahl berechnen
$temp_page = ($user_found/$user_je_page);
if ($temp_page <= "1")
    {
     $lastpage = "1";
    }
else {
      if ($temp_page =~ /\./)
      {
       $temp_page++;$lastpage =int($temp_page);

      }
      else
      {
       $lastpage=$temp_page;
      }
     }
### Seiten erstellen
if ($show_vorherige_position eq "on")
    {
    open (OLDPOSITION, "<$cgi_root_path/config/position.txt")||die("Konnte die Datei position.txt nicht einlesen");
    if ($use_flock eq "1") {flock (OLDPOSITION,1);}
    @OLDPOSITION =<OLDPOSITION>;
    if ($use_flock eq "1") {flock (OLDPOSITION,8);}
    close (OLDPOSITION);
    }
### Zur Berechnung der Durschnittshits
$zeit = time();
$topliste="";
$aktueller_user_in_tabelle="1";
$aktueller_user_auf_seite ="1";
$aktuelle_seite ="1";
$rang="1";
$tabelle_offen="0";
$datensatztopliste="0";
$oldposition="0";
&werbung_auslesen;
### Fehlermeldung falls kein User in der Datenbank nach Reset
#if ((!@TOPUSER)||(@TOPUSER eq "")){
if ($user_found eq "0"){
               $user_found="1";
               $no_user_in_database_fix="on";
               $maximale_banneranzahl="0";
               $fehlermeldung_user="0|0|0|0|TOPLISTENZENTRALE|geheimespasswort|keiner|keiner|123456\@blablabla.de|Keine Topliste Verfügbar|<br>Diese Premiumtopliste wurde kürzlich auf >0< zurückgesetzt.<br>Zur Zeit befindet sich leider kein Mitglied in unserer Datenbank, welches die Kriterien erfüllt, um in dieser Liste zu erscheinen.<br>Bitte besuchen Sie und später noch einmal.<br>Vielen Dank.<br> |http://www.toplistenzentrale.com|http://www.toplistenzentrale.com/no-cgi/banner/userbanner/makme-banner-468x60.jpg|60|468|1012496530|0|0|1|10|10|0|0|0|0|0|0|0|0|0|10|show_normal_banner|awm_check_off|alterskontrolle|1027782003|1|1|1|1|info\@aaabbccddd.de|1|mak|http://www.toplistenzentrale.com|http://www.toplistenzentrale.com/no-cgi/banner/userbanner/makme-banner-468x60.jpg|1|1|1009547414|0|0|1|0|0|0|0|0|0|0|0|0|0|0|0|show_normal_banner|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|";
               push @TOPUSER,$fehlermeldung_user;
               }

foreach (@TOPUSER)
    { @USER = split (/\|/, $TOPUSER[$datensatztopliste]);
### Textdatei position.txt erzeugen
              $pushposition = "$USER[4]|$rang|\n";
              push @NEWPOSITION ,$pushposition;
### letzte Position suchen
      foreach $line (@OLDPOSITION){
                                   @TEMP = split (/\|/,$line);
                                   if ($TEMP[0] eq $USER[4]) {$oldposition=$TEMP[1]};
                                  }
      if (($aktuelle_seite eq "1")&&($aktueller_user_auf_seite eq 1)){&open_page;}
      if ($aktueller_user_in_tabelle eq 1){&open_table;}


$topliste .="<tr><td width=\"$toplist_cell_width1\" bgcolor=\"$table_body_color\">\n";
$topliste .="<p align=\"center\"><font face=\"$font_face_toplistenrang\" size=\"$font_size_toplistenrang\" color=\"$font_color_toplistenrang\">$rang</font>\n";
if ($show_vorherige_position eq "on")
    {
    $topliste .="<font face=\"$font_face_toplistenrang\" size=\"$font_size_toplistevorherigerrang\" color=\"$font_color_toplistenrang\" align=\"center\"><br>($oldposition)</font>\n";
    }
$topliste .="</p></td><td width=\"$toplist_cell_width2\" bgcolor=\"$table_body_color\">\n";

if ($rang <= $maximale_banneranzahl)
    { $topliste .="<a href=\"$cgi_root_url/topliste.cgi?action=hit_out&account=$USER[4]\" target=\"$target\">\n";
### show the userbanner (7 ways :-D)
      if ($USER[31] eq "show_normal_banner")
          {$topliste .="<center><img target=\"$target\" style=\"border: $borderwidth_userbanner_toplist solid $bodercolor_userbanner_toplist\" src=\"$USER[12]\" width=\"$USER[14]\" height=\"$USER[13]\" alt=\"$USER[9]\"></center></a> \n";}
      if ($USER[31] eq "show_banner_nicht_frei")
          {
           if ($alternative_banner_admincheck eq "standard_banner")
              {
              $topliste .="<center><img target=\"$target\" style=\"border: $borderwidth_userbanner_toplist solid $bodercolor_userbanner_toplist\" src=\"$no_cgi_url/ersatzbanner/nicht_frei.gif\" width=\"468\" height=\"60\" alt=\"Das Mitgliedsbanner wurde noch nicht freigeschaltet\"></center></a> \n";
              }
           if ($alternative_banner_admincheck eq "user_defined_banner")
              {
              $topliste .="<center><img target=\"$target\" style=\"border: $borderwidth_userbanner_toplist solid $bodercolor_userbanner_toplist\" src=\"$alternative_banner_admincheck_url\" width=\"$alternative_banner_admincheck_width\" height=\"$alternative_banner_admincheck_height\" alt=\"Das Mitgliedsbanner wurde noch nicht freigeschaltet\"></center></a> \n";
              }
          }
      if ($USER[31] eq "show_kein_banner")
          {
           if ($alternative_banner_no_userbanner eq "standard_banner")
              {
              $topliste .="<center><img target=\"$target\" style=\"border: $borderwidth_userbanner_toplist solid $bodercolor_userbanner_toplist\" src=\"$no_cgi_url/ersatzbanner/kein_banner.gif\" width=\"468\" height=\"60\" alt=\"Dieses Mitglied hat leider kein Banner angegeben\"></center></a> \n";
              }
           if ($alternative_banner_no_userbanner eq "user_defined_banner")
              {
              $topliste .="<center><img target=\"$target\" style=\"border: $borderwidth_userbanner_toplist solid $bodercolor_userbanner_toplist\" src=\"$alternative_banner_no_userbanner_url\" width=\"$alternative_banner_no_userbanner_width\" height=\"$alternative_banner_no_userbanner_heigth\" alt=\"Dieses Mitglied hat leider kein Banner angegeben\"></center></a> \n";
              }
          }
      if ($USER[31] eq "show_not_allowed")
          {
           if ($alternative_banner_rules eq "standard_banner")
              {
              $topliste .="<center><img target=\"$target\" style=\"border: $borderwidth_userbanner_toplist solid $bodercolor_userbanner_toplist\" src=\"$no_cgi_url/ersatzbanner/regelverstoss.gif\" width=\"468\" height=\"60\" alt=\"Das Mitgliedsbanner verst&ouml;ßt gegen die Regeln\"></center></a> \n";
              }
           if ($alternative_banner_rules eq "user_defined_banner")
              {
              $topliste .="<center><img target=\"$target\" style=\"border: $borderwidth_userbanner_toplist solid $bodercolor_userbanner_toplist\" src=\"$alternative_banner_rules_url\" width=\"$alternative_banner_rules_width\" height=\"$alternative_banner_rules_height\" alt=\"Das Mitgliedsbanner verst&ouml;ßt gegen die Regeln\"></center></a> \n";
              }
           }
    }
$topliste .="<center>";
if ($show_user_sitename_link eq "on")
    {
### Wenn kein Mitglied in der Datenbank erscheint....
    if ($no_user_in_database_fix eq "on")
       { $topliste .="<font face=\"$font\" size=\"$fontsize_user_sitename_link\">";
         $topliste .="<a target=\"$target\" href=\"$cgi_root_url/topliste.cgi\" target=\"_self\" title=\"Topliste neu laden\"><b>$USER[9]</b></a><br>";
       }
    else
        {
         $topliste .="<font face=\"$font\" size=\"$fontsize_user_sitename_link\">";
         $topliste .="<a target=\"$target\" href=\"$cgi_root_url/topliste.cgi?action=hit_out&account=$USER[4]\" target=\"$target_userbanner_toplist\"><b>$USER[9]</b></a><br>";
        }

    }
if ($show_user_beschreibung eq "on")
    {
    $topliste .="<font face=\"$font\" size=\"$fontsize_user_beschreibung\" $font_color>$USER[10]</font>";
    }

$topliste .="</center></td><td width=\"$toplist_cell_width3\" bgcolor=\"$table_body_color\">\n";
$topliste .="<p align=\"center\"><font face=\"$font\" size=\"$fontsize_user_hitin\" $font_color>$USER[0]</font>\n";
if ($show_hitin_geamt eq "on")
    {
    $topliste .="<br><br><font face=\"$font\" size=\"$fontsize_user_hitin_gesamt\" $font_color>($USER[16])</font></p>\n";
    }
$topliste .="</td><td width=\"$toplist_cell_width4\" bgcolor=\"$table_body_color\">\n";
$topliste .="<p align=\"center\"><font face=\"$font\" size=\"$fontsize_user_hitin\" $font_color>$USER[1]</font>\n";
if ($show_hitin_geamt eq "on")
    {
    $topliste .="<br><br><font face=\"$font\" size=\"$fontsize_user_hitin_gesamt\" $font_color>($USER[17])</font></p>\n";
    }
$topliste .="</td></tr>\n";
if ($show_second_userline eq "on")
    {

						#########################################


$topliste .=" <tr><td width=\"$toplist_cell_width1\" bgcolor=\"$table_body_color\">\n";
if ($show_user_bewertung_grafik eq "on")
    {
     if ($votegrafik eq "dunkle_sterne")
        {
       $star_dir="$no_cgi_url/sterne/dunkler_hintergrund";$votegrafik_width="51";$votegrafik_height="10";
        }
     if ($votegrafik eq "helle_sterne")
        {
        $star_dir="$no_cgi_url/sterne/heller_hintergrund";$votegrafik_width="51";$votegrafik_height="10";
        }
     if ($votegrafik eq "sonstige")
        {
        $star_dir="$no_cgi_url/sterne/sonstige";
        $votegrafik_width="$votegrafik_width_sonstige";
        $votegrafik_height="$votegrafik_height_sonstige";
        }
         if ($USER[19]<= 10)
            {$bild='5star.gif';
         if ($USER[19]<= 9)
            {$bild='4star.gif';}
         if ($USER[19]<= 8)
            {$bild='3star.gif';}
         if ($USER[19]<= 7)
            {$bild='2star.gif';}
         if ($USER[19]<= 6)
            {$bild='1star.gif';}
         if ($USER[19]<= 5)
            {$bild='0star.gif';}
              }
$topliste .=" <a href=\"$cgi_root_url/topliste.cgi?action=show_vote\&account=$USER[4]\" target=\"_blank\">\n";
$topliste .=" <center><img border=\"0\" src=\"$star_dir/$bild\" alt=\"Bewertungsergebnisse $USER[9]\" width=\"$votegrafik_width\" height=\"$votegrafik_height\"></center></font>\n";
    }
$topliste .=" </td>\n";
$topliste .=" <td width=\"$toplist_cell_width2\" bgcolor=\"$table_body_color\"><font face=\"$font\" size=\"$fontsize_user_beschreibung\" $font_color>\n";
if ($show_vote_link eq "on")
    {
    $topliste .="<a title=\"Diese Seite bewerten\" href=\"$cgi_root_url/topliste.cgi?action=vote&account=$USER[4]&bannerurl=$USER[12]&bannerbreite=$USER[14]&bannerhoehe=$USER[13]\" target=\"_blank\">Bewerten:</a> $USER[20]</font>\n";
    }
$topliste .=" </td>\n";
$topliste .=" <td width=\"$toplist_cell_width3\" bgcolor=\"$table_body_color\">\n";
if ($show_average eq "on")
    {
            $tage = ($zeit - $USER[15]) / 86400;
             if ($tage < "1") {$tage = 1;}
             $dschnitt_in = int ( $USER[16] / $tage);
             $dschnitt_out = int ( $USER[17] / $tage);
$topliste .=" <p align=\"center\"><font face=\"$font\" size=\"$fontsize_average\" $font_color>&Oslash; $dschnitt_in</font></p>\n";
    }
$topliste .=" </td>\n";
$topliste .=" <td width=\"$toplist_cell_width4\" bgcolor=\"$table_body_color\">\n";
$topliste .="<p align=\"center\"><font face=\"$font\" size=\"$fontsize_average\" $font_color>";
if ($show_average eq "on")
    {
$topliste .=" &Oslash; $dschnitt_out\n";
    }
$topliste .="</font></p></td>\n";
$topliste .=" </tr>\n";



    }

    if (($show_vorherige_position eq "on")&&($user_found eq $rang)){&save_new_position;}
    $aktueller_user_in_tabelle++;
    $aktueller_user_auf_seite++;
    $rang++;
    $datensatztopliste++;
    if ($aktueller_user_in_tabelle eq ($user_je_table+1))
          {&close_table; $aktueller_user_in_tabelle="1";}
    if ($aktueller_user_auf_seite eq ($user_je_page+1))
          {&close_table('seiten_menue_einfuegen');&close_page; }
    if ($rang eq $user_found+1)
          {&close_table('seiten_menue_einfuegen');&close_page;}
    }
}

sub open_page {
if ( $aktuelle_seite eq "1")
    {
         open (NEW,">$no_cgi_path/$dateiname\.$mak_dat")||die("Konnte die Datei $dateiname\.$mak_dat nicht erzeugen / beschreiben");
         if ($use_flock eq "1") {flock (NEW,1);}
    }
if ( $aktuelle_seite > "1")
    {
         open (NEW,">$no_cgi_path/$dateiname$aktuelle_seite\.$mak_dat")||die("Konnte die Datei $dateiname$aktuelle_seite\.$mak_dat nicht erzeugen / beschreiben");
         if ($use_flock eq "1") {flock (NEW,1);}

          }
$topliste .="<html><head><title>$title</title>\n";
#### HTML Header oeffnen
    if ($laufleiste) {
                 $topliste .= "<style>body \{scrollbar-arrow-color : $scrollbar_arrow_color\; ";### Farbige Scrollleiste
                 $topliste .= "scrollbar-base-color: $scrollbar_base_color \;  \}</style>";
                 }
#### Metatags einfuegen
                 open (DATEI,"<$cgi_root_path/config/insert/metatag.dat")||die("Konnte die Datei metatag.dat nicht einlesen");
                 if ($use_flock eq "1") {flock (DATEI,1);}
                 @DATEN =<DATEI>;
                 if ($use_flock eq "1") {flock (DATEI,8);}
                 close (DATEI);
                 foreach $line (@DATEN)
                   {
                    $topliste .=$line;
                   }
### HTML-Header schliessen
### Hintergrund ein/aus
                   if ($background_show eq "on") {$background_code ="background=\"$background\"";}

$topliste .="</head>\n<body $background_code bgcolor\=\"$backcolor\" text\=\"$text_link_text\" link\=\"$text_link_link\" vlink\=\"$text_link_vlink\" alink\=\"$text_link_alink\">\n\n";
                ### Header einfuegen
                open (DATEI,"<$cgi_root_path/config/insert/header.dat")||die("Konnte die Datei header.dat nicht einlesen");
                if ($use_flock eq "1") {flock (DATEI,1);}
                @DATEN =<DATEI>;
                if ($use_flock eq "1") {flock (DATEI,1);}
                close (DATEI);
                foreach $line (@DATEN)
                    {
                     $topliste .=$line;
                    }

#### Aktueller Toptipp  (show only the userbanner not the alternative banner)
if (($aktuelle_empfehlung eq on)&&($aktuelle_seite eq "1")){
      $datensatz_akem  = "0";
      $user_found_akem = "0";
      foreach (@TOPUSER)
              {
               @AKEMTEMPARRY = split (/\|/,$TOPUSER[$datensatz_akem] );
                if ($AKEMTEMPARRY[31] eq "show_normal_banner")
                    {push (@AKEMUSER, join ("\|", @AKEMTEMPARRY));
                     $user_found_akem++;
                    }
                 $datensatz_akem++;
              }
        srand;
        $akem_user= int ((rand $user_found_akem));
        @AKEM = split (/\|/,$AKEMUSER[$akem_user]);
### Mitglied Kriterium -0- makme_toplistenzentrale
if ($no_user_in_database_fix eq "on"){$akem_user_link="http://www.toplistenzentrale.com";}
else {$akem_user_link="$cgi_root_url/topliste.cgi?action=hit_out&account=$AKEM[4]";}
$akem_cell_height=($AKEM[13]+10);
$topliste .="<div align=\"center\"><center>\n";
$topliste .="<table border=\"$tableborder_akem\" ";
$topliste .="bordercolor=\"$toplist_border_color\" width=\"$tablewidth_akem\" bgColor=\"$table_bg_color_akem\" ";
$topliste .="cellPadding=\"$tablecellpadding_akem\" cellSpacing=\"$tablecellspacing_akem\">";
$topliste .="<tr><td bgcolor=\"$table_head_color_akem\"><p align=center>\n";
$topliste .="<font align=\"center\" face=\"$font\" size=\"$font_size_table\" color=\"$font_color_akem\">";
$topliste .="<b>$akem_text</b></font></td></tr>";
$topliste .="<tr><td bgcolor=\"$table_body_color_akem\" align=center height=\"$akem_cell_height\">\n";
$topliste .="<p align=center><a href=\"$akem_user_link\" target=\"_blank\">\n";
$topliste .="<img style=\"border: $borderwidth_userbanner_toplist solid $bodercolor_userbanner_toplist\" src=\"$AKEM[12]\" width=$AKEM[14] height=$AKEM[13] alt=\"$AKEM[9]\"></a></p>\n";
$topliste .="</td></tr></table><br></center></div>\n";
}

### Mitgliedermenue einfuegen
if ($show_usermenue eq "on"){
$topliste .="<center><font face\=\"$font\" size\=\"$font_size\" color=\"$text_link_text\" >

<a href=\"$webmasterhomepage\" target=\"_blank\"><font face\=\"$font\" size\=\"$font_size\" color=\"$text_link_text\">[$button_home_text]</font></a>

<a href=\"$cgi_root_url/topliste.cgi?action=neues_mitglied\" target=\"_self\"><font face\=\"$font\" size\=\"$font_size\" color=\"$text_link_text\">[$button_anmelden_text]</font></a>

<a href=\"$cgi_root_url/topliste.cgi?action=edit_mitglied\" target=\"_self\"><font face\=\"$font\" size\=\"$font_size\" color=\"$text_link_text\">[$button_userlogin_text]</font></a>


<br></font></center>";
}
### Update und Reset-Informationen einfuegen
&get_time;
if ($show_update_periode eq "on"){
    if ($update_time > 1){$topliste .="<center><font face\=\"$font\" size\=\"$font_size\" color=\"$text_link_text\">Diese Liste wird alle $update_time Minuten aktualisiert.</font></center>";}
    else {$topliste .="<center><font face\=\"$font\" size\=\"$font_size\" color=\"$text_link_text\">Diese Liste wird alle 60 Sekunden aktualisiert.</font></center>";}
    }
if ($show_reset_periode eq "on"){
    if ($reset_time > 1){$topliste .="<center><font face\=\"$font\" size\=\"$font_size\" color=\"$text_link_text\">Ein Reset erfolgt alle $reset_time Tage.</center></font>";}
    else {$topliste .="<center><font face\=\"$font\" size\=\"$font_size\" color=\"$text_link_text\">Ein Reset erfolgt alle 7 Tage. </font></center>";}
    }
if ($show_last_update eq "on"){
    $topliste .="<center><font face\=\"$font\" size\=\"$font_size\" color=\"$text_link_text\"> Letztes Update: $aktdate um $aktzeit.</font></center>\n";
    }
if ($show_next_update eq "on"){
    $topliste .="<center><font face\=\"$font\" size\=\"$font_size\" color=\"$text_link_text\"> N&auml;chstes Update: $nextupdatedate um $nextupdatetime.</font></center>\n";
    }
if ($show_next_reset eq "on"){
    $topliste .="<center><font face\=\"$font\" size\=\"$font_size\" color=\"$text_link_text\"> N&auml;chstes Reset: $nextresetdate um $nextresettime.</font></center>\n";
    }
### Eingetragene Mitglieder anzeigen
if ($show_eingetragene_mitglieder eq "on"){
    $topliste .="<center><font face\=\"$font\" size\=\"$font_size\" color=\"$text_link_text\"> Anzahl aller eingetragenen Mitglieder:<b> $eingetragene_mitglieder</b> </font></center>\n";
    }
### Aktive Mitglieder anzeigen
if ($show_active_mitglieder eq "on"){
    $topliste .="<center><font face\=\"$font\" size\=\"$font_size\" color=\"$text_link_text\"> Anzahl aller aktiven Mitglieder:<b> $active_mitglieder</b> </font></center>\n";
    }
### Menue einfuegen
&menue;
}

sub close_page {
### Das Seitenmenue einfuegen
           if (($aktueller_user_auf_seite eq ($user_je_page+1))||($rang eq $user_found+1))
                 {&menue;}



### Mitgliedermenue einfuegen
if ($show_usermenue_down eq "on"){
$topliste .="<center><font face\=\"$font\" size\=\"$font_size\" color=\"$text_link_text\" >
             <a href=\"$webmasterhomepage\" target=\"_blank\"><font face\=\"$font\" size\=\"$font_size\" color=\"$text_link_text\">[$button_home_text]</font></a>
             <a href=\"$cgi_root_url/topliste.cgi?action=neues_mitglied\" target=\"_self\"><font face\=\"$font\" size\=\"$font_size\" color=\"$text_link_text\">[$button_anmelden_text]</font></a>
             <a href=\"$cgi_root_url/topliste.cgi?action=edit_mitglied\" target=\"_self\"><font face\=\"$font\" size\=\"$font_size\" color=\"$text_link_text\">[$button_userlogin_text]</font></a>
<font face=\"Arial, Helvetica, sans-serif\" size=\"1\"><br>&nbsp;</font></center></font>";
}
if ($show_update_periode_down eq "on"){
    if ($update_time > 1){$topliste .="<center><font face\=\"$font\" size\=\"$font_size\" color=\"$text_link_text\">Diese Liste wird alle $update_time Minuten aktualisiert. </font></center> ";}
    else {$topliste .="<center><font face\=\"$font\" size\=\"$font_size\" color=\"$text_link_text\">Diese Liste wird alle 60 Sekunden aktualisiert. </font></center>";}
    }
if ($show_reset_periode_down eq "on"){
    if ($reset_time > 1){$topliste .="<center><font face\=\"$font\" size\=\"$font_size\" color=\"$text_link_text\">Ein Reset erfolgt alle $reset_time Tage.</center></font>";}
    else {$topliste .="<center><font face\=\"$font\" size\=\"$font_size\" color=\"$text_link_text\">Ein Reset erfolgt wöchentlich. </font></center>";}
    }
if ($show_last_update_down eq "on"){
    $topliste .="<center><font face\=\"$font\" size\=\"$font_size\" color=\"$text_link_text\"> Letztes Update: $aktdate um $aktzeit.</font></center>\n";
    }
if ($show_next_update_down eq "on"){
    $topliste .="<center><font face\=\"$font\" size\=\"$font_size\" color=\"$text_link_text\"> N&auml;chstes Update: $nextupdatedate um $nextupdatetime.</font></center>\n";
    }
if ($show_next_reset_down eq "on"){
    $topliste .="<center><font face\=\"$font\" size\=\"$font_size\" color=\"$text_link_text\"> N&auml;chstes Reset: $nextresetdate um $nextresettime.</font></center>\n";
    }
### Eingetrage User werden angezeigt
if ($show_eingetragene_mitglieder_down eq "on"){
    $topliste .="<center><font face\=\"$font\" size\=\"$font_size\" color=\"$text_link_text\"> Anzahl aller eingetragener Mitglieder:<b> $eingetragene_mitglieder</b> </font></center>\n";
    }
### Aktive User werden angezeigt
if ($show_active_mitglieder_down eq "on"){
    $topliste .="<center><font face\=\"$font\" size\=\"$font_size\" color=\"$text_link_text\"> Anzahl der aktiven Mitglieder:<b> $active_mitglieder</b> </font></center>\n";
    }
$topliste .="<font face=\"Arial, Helvetica, sans-serif\" size=\"1\"><br>&nbsp;</font>";

### Footer einfuegen
 open (DATEI,"<$cgi_root_path/config/insert/footer.dat")||die("Konnte die Datei footer.dat nicht einlesen");
            if ($use_flock eq "1") {flock (DATEI,1);}
            @DATEN =<DATEI>;
            if ($use_flock eq "1") {flock (DATEI,8);}
            close (DATEI);
            foreach $line (@DATEN)
            {
            $topliste .="$line";
            }
### Html-Seite schliessen
$topliste .="<font face=\"Arial, Helvetica, sans-serif\" size=\"1\"><br></font><center><font face=\"Arial\" size=\"2\" color=\"$text_link_text\">\n<b>makme-Topliste $version</b> &#169; by<a target=\"_blank\" href=\"http://www.toplistenzentrale.com\"><font face=\"Arial\" size=\"2\" color=\"$text_link_text\">Toplistenzentrale.com</font></a></font></center>";
$topliste .="</body></html>\n";
### aktuelle Seite wird geschrieben
 print NEW $topliste;
            if ($use_flock eq "1") {flock (NEW,8);}
         close (NEW);
        if ( $aktuelle_seite eq "1")
            {chmod 0777, "$no_cgi_path/$dateiname\.$mak_dat";}
        if ( $aktuelle_seite > "1")
            { $chmod_path = "$no_cgi_path/$dateiname"."$aktuelle_seite\.$mak_dat";
            chmod 0777, "$chmod_path";
            }

$aktuelle_seite++;
$aktueller_user_auf_seite ="1";
$aktueller_user_in_tabelle="1";
$topliste="";
    if ($rang < $user_found+1)
        {&open_page;}
}


sub menue {

if ($lastpage > 1){
    $topliste .="<font face=\"Arial, Helvetica, sans-serif\" size=\"1\">&nbsp;</font><center>\n";
        if  (($lastpage > 1)&&($aktuelle_seite ne 1))
            { $vorheriger_page=($aktuelle_seite-1);
        if ($vorheriger_page eq 1){$vorheriger_page="";}
              $topliste .="<a title=\"vorherige Seite\" href=\"$no_cgi_url/$dateiname$vorheriger_page.$mak_dat\"><--</a>\n";
            }
for ($menue_link = 1;$menue_link<$lastpage+1;$menue_link++)
     {
       if ($menue_link eq 1)
            {
             $topliste .="<a title=\"TOP $user_je_page\" href=\"$no_cgi_url/$dateiname.$mak_dat\">$menue_link</a> \n";
            }
      else {
            $top1= ((($menue_link-1)*$user_je_page)+1);
            $top2= (($top1+$user_je_page)-1);
            $topliste .="<a title=\"TOP $top1-$top2\" href=\"$no_cgi_url/$dateiname$menue_link.$mak_dat\">$menue_link</a> \n";
            }
     }
if  (($lastpage > 1)&&($aktuelle_seite ne $lastpage))
     { $next_page=($aktuelle_seite+1);
      $topliste .="<a title=\"n&auml;chste Seite\" href=\"$no_cgi_url/$dateiname$next_page.$mak_dat\">--></a>\n";
     }
$topliste .="</center><font face=\"Arial, Helvetica, sans-serif\" size=\"1\">&nbsp;</font>\n";
    }
### Zwischenraum zwischen Benutzermenue und Topliste bestimmen falls kein Seitenmenue benoetigt wird.
else {$topliste .="<font face=\"Arial, Helvetica, sans-serif\" size=\"1\">&nbsp;</font>";}
}

sub open_table {
if ($tabelle_offen eq 0){
$topliste .="<div align=\"center\"><center>\n";
$topliste .= "<table width=\"$toplist_table_width\" border=\"$toplist_border_width\" bordercolor=\"$toplist_border_color\" cellspacing=\"$toplist_cellspacing\" cellpadding=\"$toplist_cellpadding\" bgColor=\"$table_bg_color\">\n";
$topliste .= "<tr>\n";
$topliste .= "<td width=\"$toplist_cell_width1\" bgcolor=\"$table_head_color\">\n";
$topliste .= "<p align=\"center\"><font face\=\"$font\" size\=\"$font_size_table\" color=\"$font_color_table_header\"><b>$rang_text</b></font></p>\n";
$topliste .= "</td>\n";
$topliste .= "<td width=\"$toplist_cell_width2\" bgcolor=\"$table_head_color\">\n";
$topliste .= "<p align=\"center\"><font face\=\"$font\" size\=\"$font_size_table\" color=\"$font_color_table_header\"><b>$beschreibung_text</b></font></p></font>\n";
$topliste .= "</td>\n";
$topliste .= "<td width=\"$toplist_cell_width3\" bgcolor=\"$table_head_color\">\n";
$topliste .= "<p align=\"center\"><font face\=\"$font\" size\=\"$font_size_table\" color=\"$font_color_table_header\"><b>$hit_in_text</b><br></font>\n";
if ($show_hitin_geamt eq "on")
    {
    $topliste .="<font face\=\"$font\" size\=\"1\" color=\"$font_color_table_header\">($hit_in_gesamt_text)</font></p>\n";
    }
$topliste .= "</td>\n";
$topliste .= "<td width=\"$toplist_cell_width4\" bgcolor=\"$table_head_color\">\n";
$topliste .= "<p align=\"center\"><font face\=\"$font\" size\=\"$font_size_table\" color=\"$font_color_table_header\"><b>$hit_out_text<br></b></font>\n";
if ($show_hitin_geamt eq "on")
    {
    $topliste .="<font face\=\"$font\" size\=\"1\" color=\"$font_color_table_header\">($hit_out_gesamt_text)</font></p>\n";
    }
$topliste .= "</td>\n";
$topliste .= "</tr>\n";
$tabelle_offen = "1";
}
}

sub close_table {
 if ($tabelle_offen eq 1)
  {
  $topliste .="</tr></table></center></div>\n";
  &insert_werbung;
  $tabelle_offen="0";
  }
}

sub werbung_auslesen{

$werbung="0";
open (META,"<$userdatapath/insert/werbung/werbung.dat");
    if ($use_flock eq "1") {flock (META,1);}
    @WERBUNG = <META>;
    if ($use_flock eq "1") {flock (META,8);}
    close (META);
    foreach $line (@WERBUNG)
    {
    chomp ($line) if ($line =~ /\n/);
    }
open (META,"<$userdatapath/insert/werbung/standardwerbung.dat");
    if ($use_flock eq "1") {flock (META,1);}
    @STANDARDWERBUNG = <META>;
    if ($use_flock eq "1") {flock (META,8);}
    close (META);

}

sub insert_werbung {

if (-e "$userdatapath/insert/werbung/werbung_id_$WERBUNG[$werbung].dat")
    {
    open (META,"<$userdatapath/insert/werbung/werbung_id_$WERBUNG[$werbung].dat");
    if ($use_flock eq "1") {flock (META,1);}
    @AKTUELLE_WERBUNG = <META>;
    if ($use_flock eq "1") {flock (META,8);}
    close (META);
        foreach $line (@AKTUELLE_WERBUNG)
        {
        $topliste .="$line";
        }
    }
else { $topliste .= "@STANDARDWERBUNG";}
$werbung++;
}

sub get_time {
### Uhrzeit des letzten Updates berechnen
if (($show_last_update eq "on")||($show_last_update_down eq "on")){
      $offsetzeit = time() + ($serveroffset * 3600);
      ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime ($offsetzeit);
      @months = ("space" , "Januar", "Februar", "M&auml;rz", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember");
      $mon++;$year = $year + 1900;$monformat = sprintf ("%2d", $mon);$monformat =~tr/ /0/;
      $mdayformat = sprintf ("%2d", $mday);$mdayformat =~tr/ /0/;$USDate = "$monformat-$mdayformat-$year";
      $EuroDate = "$mdayformat-$monformat-$year";$USDateerweitert = "$months[$mon] $mday, $year";
      $EuroDateerweitert = "$mday $months[$mon] $year";$min = sprintf ("%2d", $min);$min =~tr/ /0/;
      $hour = sprintf ("%2d", $hour);$hour =~tr/ /0/;$EuroTime = "$hour:$min Uhr";
      if ($hour < 12) {$ext = "AM";$USHour = "$hour";}if ($hour > 12) {$USHour = $hour - 12;$ext = "PM";}
      if ($hour == 12){$ext = "PM";$USHour = "12";}if ($hour == 0) {$USHour = "12";}
      $USHour = sprintf ("%2d", $USHour);$USHour =~tr/ /0/;$USTime = "$USHour:$min $ext";
      if ($timeformat eq "12") {$aktzeit = $USTime;} else {$aktzeit = $EuroTime;}
      if ($dateformat eq "US") {$aktdate = "$USDate";}elsif ($dateformat eq "USXL") {$aktdate = "$USDateerweitert";}
      elsif ($dateformat eq "EU") {$aktdate = "$EuroDate";}else {$aktdate = "$EuroDateerweitert";}
  }
### Uhrzeit des naechsten Updates berechnen
if (($show_next_update eq "on")||($show_next_update_down eq "on")){
      $updatezeit = time() + ($serveroffset * 3600) +($update_time * 60);
      ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime ($updatezeit);
      @months = ("space" , "Januar", "Februar", "M&auml;rz", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember");
      $mon++;$year = $year + 1900;$monformat = sprintf ("%2d", $mon);$monformat =~tr/ /0/;
      $mdayformat = sprintf ("%2d", $mday);$mdayformat =~tr/ /0/;
      $USDate = "$monformat-$mdayformat-$year";$EuroDate = "$mdayformat-$monformat-$year";
      $USDateerweitert = "$months[$mon] $mday, $year";$EuroDateerweitert = "$mday $months[$mon] $year";
      $min = sprintf ("%2d", $min);$min =~tr/ /0/;$hour = sprintf ("%2d", $hour);$hour =~tr/ /0/;
      $EuroTime = "$hour:$min Uhr";if ($hour < 12) {$ext = "AM";$USHour = "$hour";}if ($hour > 12) {$USHour = $hour - 12;$ext = "PM";}
      if ($hour == 12){$ext = "PM";$USHour = "12";}          if ($hour == 0) {$USHour = "12";}
      $USHour = sprintf ("%2d", $USHour);$USHour =~tr/ /0/;$USTime = "$USHour:$min $ext";
      if ($timeformat eq "12") {$nextupdatetime = $USTime;}else {$nextupdatetime = $EuroTime;}
      if ($dateformat eq "US") {$nextupdatedate = "$USDate";}elsif ($dateformat eq "USXL") {$nextupdatedate = "$USDateerweitert";}
      elsif ($dateformat eq "EU") {$nextupdatedate = "$EuroDate";}else {$nextupdatedate = "$EuroDateerweitert";}
    }
### Uhrzeit des naechsten Reset berechnen
if (($show_next_reset eq "on")||($show_next_reset_down eq "on")){
      $resetzeit = $last_reset + ($serveroffset * 3600) + ($reset_time*86400);
      ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime ($resetzeit);
      @months = ("space" , "Januar", "Februar", "M&auml;rz", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember");
      $mon++;$year = $year + 1900;$monformat = sprintf ("%2d", $mon);$monformat =~tr/ /0/;
      $mdayformat = sprintf ("%2d", $mday);$mdayformat =~tr/ /0/;
      $USDate = "$monformat-$mdayformat-$year";$EuroDate = "$mdayformat-$monformat-$year";
      $USDateerweitert = "$months[$mon] $mday, $year";$EuroDateerweitert = "$mday $months[$mon] $year";
      $min = sprintf ("%2d", $min);$min =~tr/ /0/;$hour = sprintf ("%2d", $hour);$hour =~tr/ /0/;
      $EuroTime = "$hour:$min Uhr";if ($hour < 12) {$ext = "AM";$USHour = "$hour";}if ($hour > 12) {$USHour = $hour - 12;$ext = "PM";}
      if ($hour == 12){$ext = "PM";$USHour = "12";}          if ($hour == 0) {$USHour = "12";}
      $USHour = sprintf ("%2d", $USHour);$USHour =~tr/ /0/;$USTime = "$USHour:$min $ext";
      if ($timeformat eq "12") {$nextresettime = $USTime;}else {$nextresettime = $EuroTime;}
      if ($dateformat eq "US") {$nextresetdate = "$USDate";}elsif ($dateformat eq "USXL") {$nextresetdate = "$USDateerweitert";}
      elsif ($dateformat eq "EU") {$nextresetdate = "$EuroDate";}else {$nextresetdate = "$EuroDateerweitert";}
    }
}

sub save_new_position {

    open (NEWPOSITION, ">$cgi_root_path/config/position.txt")||die("Konnte die Datei position.txt nicht beschreiben");
    if ($use_flock eq "1") {flock (NEWPOSITION,1);}
    foreach $line (@NEWPOSITION)
    {
    print NEWPOSITION "$line";
    }
    if ($use_flock eq "1") {flock (NEWPOSITION,8);}
    close (NEWPOSITION);
    }



sub log_hit_out {
                     $datensatz=0;

        open (ALLEACCOUNTS, "+<$userdatapath/user.dat")||die("Konnte die Datei user.dat nicht einlesen");
              if ($use_flock eq "1") {flock (ALLEACCOUNTS,1);}
                @ALLEACCOUNTS = <ALLEACCOUNTS>;

        foreach (@ALLEACCOUNTS)
           {
             @USER = split(/\|/, $ALLEACCOUNTS[$datensatz]);
             if ($USER[4] eq  $FORM{account})
               {
                 $USER[3]++;  $USER[17]++;
                 $redirect   = "$USER[11]";
                 $awm_status = "$USER[32]";
                 $awm_system = "$USER[33]";
                 $awm_id     = "$USER[34]";
                 $ALLEACCOUNTS[$datensatz] = join ("\|",@USER);
               }
               $datensatz++;
            }
        seek (ALLEACCOUNTS, 0, 0);
        print ALLEACCOUNTS @ALLEACCOUNTS;
        if ($use_flock eq "1") {flock (ALLEACCOUNTS,8);}
        close (ALLEACCOUNTS);

    if ($awm_status eq "awm_check_on")
       {
       &awm_check;
       }
    else {print "Location: $redirect \n\n";}

}

sub awm_check {
if ($awm_system eq "alterskontrolle")
   {


   &header;
print "<div align=\"center\">\n";
print "<center>\n";
print "<table width=\"600\" border=\"$toplist_border_width\" bordercolor=\"$toplist_border_color\" cellspacing=\"$toplist_cellspacing\" cellpadding=\"$toplist_cellpadding\" bgColor=\"$table_bg_color\">\n";
print "<tr>\n";
print "<td width=\"600\" bgcolor=\"$table_head_color\" colspan=\"2\">\n";
print "<center><font face\=\"$font\" size\=\"$font_size_table\" color=\"$font_color_table_header\"><b>Die Seite wird durch ein Jugendschutzsystem gesch&uuml;tzt!</b></font></td>\n";
print "</tr>\n";
print "<tr>\n";
print "<td width=\"600\" bgcolor=\"$table_body_color\"  height=\"25\" colspan=\"2\">\n";
print<<"TOR";
<!-- Start ueber18.de -->

<table border="0" width="100%" cellpadding="2">

  <table border="0" width="100%" cellpadding="2">
    <tr>
     <td width="100%">
     <p align="center"><font size="2" face="Arial"><br>
     Damit Ihr Alter überprüft werden kann, geben Sie bitte jetzt Ihre ueber18.de - Zugangsdaten ein! </font></p>
    <p><font face="Arial" size="2">Wenn Sie noch keine Zugangsdaten haben, können Sie sich
    <a href="http://www.ueber18.de?wid=$webmasterID&sid=$siteID" target="_blank">hier registrieren!</a></font><br>
&nbsp;</td>
</table>
<form method="POST" action="http://www.ueber18.de/cgi-mod/tor2.cgi">
<input type="hidden" name="pname" value="ID">
<input type="hidden" name="pvalue" value="$awm_id">
<input type="hidden" name="id" value="$siteID">
<input type="hidden" name="wid" value="$webmasterID">
  <div align="center">
    <table cellspacing="0" cellpadding="0" bgcolor="#e5e5e9" border="0" ?>
      <tbody>
        <tr>
          <td><a
href="http://www.ueber18.de/?wid=$webmasterID&sid=$siteID"
target="_blank"><img border="0"
src="http://www.ueber18.de/images/tor.gif" width="348"
height="93"></a></td>
        </tr>
        <tr>
          <td valign="bottom" bgcolor="#E5E5E9">
            <table border="0" width="100%" cellspacing="4" cellpadding="0">
              <tr>
                <td><b><font face="Arial,Helvetica,sans-serif" size="2"
color="#000080">User-ID:</font></b></td>
                <td><input size="14" name="userid"></td>
                <td>
                  <p align="center"><img border="0"
src="http://www.ueber18.de/images/infos.gif" width="80"
height="24"></td>
              </tr>
              <tr>
                <td><b><font face="Arial,Helvetica,sans-serif" size="2"
color="#000080">Passwort:</font></b></td>
                <td><input size="14" name="pw" type="password"></td>
                <td>
                  <p align="center"><input type="submit" value="START"
style="font-weight: bold; color: #000066"></td>
              </tr>
            </table>
          </td>
        </tr>
        <tr>
          <td align="middle" bgcolor="#000066">
            <table border="0" width="100%" cellspacing="0" cellpadding="4">
              <tr>
                <td width="100%" class="foot"><font
face="Arial,Helvetica,sans-serif" size="2"><font color="#E5E5E9">Diese
                  Seite wird durch</font> <a
href="http://www.ueber18.de?wid=$webmasterID&sid=$siteID"
target="_blank" class="whitelink"><font
color="#E5E5E9">ueber18.de</font></a>
                  <font color="#E5E5E9">geschützt !</font></font></td>
              </tr>
            </table>
          </td>
        </tr>
      </tbody>
    </table>
  </div>
</form>

<!-- Ende ueber18.de -->
TOR
print "</td>\n";
print "</tr>\n";
print "</table>\n";
print "</center>\n";
print "</div>\n";
&footer;
   }

}

sub awm_hit_out {


        open (ALLEACCOUNTS, "<$userdatapath/user.dat")||die("Konnte die Datei user.dat nicht einlesen");
              if ($use_flock eq "1") {flock (ALLEACCOUNTS,1);}
                @ALLEACCOUNTS = <ALLEACCOUNTS>;

        foreach (@ALLEACCOUNTS)
           {
             @USER = split(/\|/, $ALLEACCOUNTS[$datensatz]);
             if ($USER[34] eq  $FORM{ID})
               {
                 $redirect   = "$USER[11]";
               }
               $datensatz++;
            }

        if ($use_flock eq "1") {flock (ALLEACCOUNTS,8);}
        close (ALLEACCOUNTS);
print "Location: $redirect \n\n";
}

sub log_hit_in {

        $datensatz=0;
              open (ALLEACCOUNTS, "+<$userdatapath/user.dat")||die("Konnte die Datei user.dat nicht einlesen");
              if ($use_flock eq "1") {flock (ALLEACCOUNTS,1);}
                   @ALLEACCOUNTS = <ALLEACCOUNTS>;

        foreach (@ALLEACCOUNTS)
           {
             @USER = split(/\|/, $ALLEACCOUNTS[$datensatz]);
             if ($USER[4] eq  $FORM{account})
               {
                 $USER[2]++; $USER[16]++;
                 $ALLEACCOUNTS[$datensatz] = join ("\|",@USER);
               }
               $datensatz++;
            }
        seek (ALLEACCOUNTS, 0, 0);
        print ALLEACCOUNTS @ALLEACCOUNTS;
        if ($use_flock eq "1") {flock (ALLEACCOUNTS,8);}
        close (ALLEACCOUNTS);



}

sub update_account {
             #  $datensatz=0;
#
#
#               open (ALLEACCOUNTS, "<$userdatapath/user.dat")||die("Konnte die Datei user.dat nicht einlesen");
#               if ($use_flock eq "1") {flock (ALLEACCOUNTS,1);}
#               @ALLEACCOUNTS = <ALLEACCOUNTS>;
#               if ($use_flock eq "1") {flock (ALLEACCOUNTS,8);}
#               close (ALLEACCOUNTS);
#         foreach (@ALLEACCOUNTS)
#            {
#              @USER = split(/\|/, $ALLEACCOUNTS[$datensatz]);
#              $USER[0] = $USER[0] + $USER[2];
#              $USER[1] = $USER[1] + $USER[3];
#              $USER[2] = 0;
#              $USER[3] = 0;
#              $v1 = $USER[21]* 10;
#              $v2 = $USER[22]* 20;
#              $v3 = $USER[23]* 30;
#              $v4 = $USER[24]* 40;
#              $v5 = $USER[25]* 50;
#              $v6 = $USER[26]* 60;
#              $v7 = $USER[27]* 70;
#              $v8 = $USER[28]* 80;
#              $v9 = $USER[29]* 90;
#              $v10 =$USER[30]* 100;
# if (($USER[20] eq "0")||($USER[20] eq "")||($USER[20] eq "\n"))
#    {$stimmen = "1";}
# else {$stimmen = $USER[20];}
#  $vote = (($v1+$v2+$v3+$v4+$v5+$v6+$v7+$v8+$v9+$v10) / $stimmen)/10;
#  $USER[19] = $vote;
#
#             $ALLEACCOUNTS[$datensatz] = join ("\|",@USER);
#             $datensatz++;
#             }
#
#
#         open (ALLEACCOUNTS, ">$userdatapath/user.dat")||die("Konnte die Datei user.dat nicht beschreiben");
#           if ($use_flock eq "1") {flock (ALLEACCOUNTS,1);}
#           print ALLEACCOUNTS @ALLEACCOUNTS;
#           if ($use_flock eq "1") {flock (ALLEACCOUNTS,8);}
#         close (ALLEACCOUNTS);
### Updateroutine entfernt \n
open (ALLEACCOUNTS, "<$userdatapath/user.dat")||die("Konnte die Datei user.dat nicht einlesen");
if ($use_flock eq "1") {flock (ALLEACCOUNTS,1);}
@ALLEACCOUNTS = <ALLEACCOUNTS>;
if ($use_flock eq "1") {flock (ALLEACCOUNTS,8);}
close (ALLEACCOUNTS);
        foreach (@ALLEACCOUNTS)
           { if (($_ ne "")&&($_ ne "\n"))
             {
              @USER = split(/\|/, $_);
              $USER[0] = $USER[0] + $USER[2];
              $USER[1] = $USER[1] + $USER[3];
              $USER[2] = 0;
              $USER[3] = 0;
              $v1 = $USER[21]* 10;
              $v2 = $USER[22]* 20;
              $v3 = $USER[23]* 30;
              $v4 = $USER[24]* 40;
              $v5 = $USER[25]* 50;
              $v6 = $USER[26]* 60;
              $v7 = $USER[27]* 70;
              $v8 = $USER[28]* 80;
              $v9 = $USER[29]* 90;
              $v10 =$USER[30]* 100;
               if (($USER[20] eq "0")||($USER[20] eq "")||($USER[20] eq "\n"))
                   {$stimmen = "1";}
                   else {$stimmen = $USER[20];}
              $vote = (($v1+$v2+$v3+$v4+$v5+$v6+$v7+$v8+$v9+$v10) / $stimmen)/10;
              $USER[19] = $vote;
             push @UPDATE_ACCOUNT ,join ("\|",@USER);
              }
}
open (ALLEACCOUNTS, ">$userdatapath/user.dat")||die("Konnte die Datei user.dat nicht beschreiben");
if ($use_flock eq "1") {flock (ALLEACCOUNTS,1);}
print ALLEACCOUNTS @UPDATE_ACCOUNT;
if ($use_flock eq "1") {flock (ALLEACCOUNTS,8);}
close (ALLEACCOUNTS);
}

sub reset_account {
### Resetroutine entfernt \n

              open (ALLEACCOUNTS, "<$userdatapath/user.dat")||die("Konnte die Datei user.dat nicht einlesen");
              if ($use_flock eq "1") {flock (ALLEACCOUNTS,1);}
              @ALLEACCOUNTS = <ALLEACCOUNTS>;
              if ($use_flock eq "1") {flock (ALLEACCOUNTS,8);}
              close (ALLEACCOUNTS);
   foreach (@ALLEACCOUNTS)
           {if (($_ ne "")&&($_ ne "\n"))
             {
              @USER = split(/\|/,$_);
              $USER[0] = 0;
              $USER[1] = 0;
              $USER[2] = 0;
              $USER[3] = 0;
              push @RESET_USER, join ("\|",@USER);
              }
          }
        open (ALLEACCOUNTS, ">$userdatapath/user.dat")||die("Konnte die Datei user.dat nicht beschreiben");
        if ($use_flock eq "1") {flock (ALLEACCOUNTS,1);}
        print ALLEACCOUNTS @RESET_USER;
        if ($use_flock eq "1") {flock (ALLEACCOUNTS,8);}
        close (ALLEACCOUNTS);
}

sub reset_alle_accounts {
### reset_alle Routine entfernt \n

              open (ALLEACCOUNTS, "<$userdatapath/user.dat")||die("Konnte die Datei user.dat nicht einlesen");
              if ($use_flock eq "1") {flock (ALLEACCOUNTS,1);}
              @ALLEACCOUNTS = <ALLEACCOUNTS>;
              if ($use_flock eq "1") {flock (ALLEACCOUNTS,8);}
              close (ALLEACCOUNTS);
   foreach (@ALLEACCOUNTS)
           {if (($_ ne "")&&($_ ne "\n"))
             {
              @USER = split(/\|/, $_);
### Reset Hit in/out
              if ($reset_alle_option_hit eq "on")
              {
               $USER[0]  = 0;
               $USER[1]  = 0;
               $USER[2]  = 0;
               $USER[3]  = 0;
              }
### Reset Hit in/out alle
              if ($reset_alle_option_hit_all eq "on")
              {
               $USER[15] = time();
               $USER[16] = 0;
               $USER[17] = 0;
              }
### Reset der Votedatei
             if ($reset_alle_option_vote eq "on")
             {
              $USER[19] = 0;
              $USER[20] = 0;
              $USER[21] = 0;
              $USER[22] = 0;
              $USER[23] = 0;
              $USER[24] = 0;
              $USER[25] = 0;
              $USER[26] = 0;
              $USER[27] = 0;
              $USER[28] = 0;
              $USER[29] = 0;
              $USER[30] = 0;
              }
            push @RESET_ALLE_USER , join ("\|",@USER);
             }
            }
        open (ALLEACCOUNTS, ">$userdatapath/user.dat")||die("Konnte die Datei user.dat nicht beschreiben");
        if ($use_flock eq "1") {flock (ALLEACCOUNTS,1);}
        print ALLEACCOUNTS @RESET_ALLE_USER;
        if ($use_flock eq "1") {flock (ALLEACCOUNTS,8);}
        close (ALLEACCOUNTS);


}

sub show_vote {

&header;
                $datensatz = "0";
                    open (ACCOUNT, "<$userdatapath/user.dat")||die("Konnte die Datei user.dat nicht einlesen");
                    if ($use_flock eq "1") {flock (ACCOUNT,1);}
                    @ALLEDATEN = <ACCOUNT>;
                    if ($use_flock eq "1") {flock (ACCOUNT,8);}
                    close (ACCOUNT);
                    foreach (@ALLEDATEN)
                    {
                    @ACCOUNTDATEN = split (/\|/, $ALLEDATEN[$datensatz]);
                    if ($ACCOUNTDATEN[4] eq $FORM{account})
                    {@ACCOUNT =@ACCOUNTDATEN;
 $voteanzahl = $ACCOUNT[20];
 $v1 = $ACCOUNT[21]* 10;
 $v2 = $ACCOUNT[22]* 20;
 $v3 = $ACCOUNT[23]* 30;
 $v4 = $ACCOUNT[24]* 40;
 $v5 = $ACCOUNT[25]* 50;
 $v6 = $ACCOUNT[26]* 60;
 $v7 = $ACCOUNT[27]* 70;
 $v8 = $ACCOUNT[28]* 80;
 $v9 = $ACCOUNT[29]* 90;
 $v10 = $ACCOUNT[30]* 100;
$stimmen = $voteanzahl;
if ($voteanzahl eq 0)
   {$voteanzahl = 1;$stimmen=0;}
 $vote_percent = ($v1+$v2+$v3+$v4+$v5+$v6+$v7+$v8+$v9+$v10) / $voteanzahl;
 $vote_percent = int $vote_percent;



}

                    $datensatz++;
                    }

print "<div align=\"center\">\n";
print "  <center>\n";
print "  <table width=\"451\" border=\"$toplist_border_width\" bordercolor=\"$toplist_border_color\" cellspacing=\"$toplist_cellspacing\" cellpadding=\"$toplist_cellpadding\" bgColor=\"$table_bg_color\">\n";
print "    <tr>\n";
print "      <td width=439 bgcolor=$table_head_color >\n";
print "        <p align=\"center\"><b><font face\=$font size\=$font_size_table color=\"$font_color_table_header\" size=3>Bewertung des &quot; $FORM{account} &quot;\n";
print "        Mitglied-Accounts</font></b></td>\n";
print "    </tr>\n";
print "    <tr>\n";
print "      <td width=\"431\" bgcolor=\"$table_body_color\" align=\"right\" height=\"25\">\n";
print "        <p align=\"center\">&nbsp;\n";
print "        </p>\n";
print "        \n";
print "        <div align=\"center\">\n";
print "          <center>\n";
print "          <table border=\"0\" cellspacing=\"0\" width=\"200\">\n";
print "            <tr>\n";
print "              <td width=\"100\" align=\"right\"><font face\=\"$font\" size\=\"$font_size_table\" $font_color >&nbsp;10 Sterne</font></td>\n";
print "              <td width=\"100\"><font face\=\"$font\" size\=\"$font_size_table\" $font_color >&nbsp;\= $ACCOUNT[30] mal</font></td>\n";
print "            </tr>\n";
print "            <tr>\n";
print "              <td width=\"100\" align=\"right\"><font face\=\"$font\" size\=\"$font_size_table\" $font_color >&nbsp;9 Sterne</font></td>\n";
print "              <td width=\"100\"><font face\=\"$font\" size\=\"$font_size_table\" $font_color >&nbsp;\= $ACCOUNT[29] mal</font></td>\n";
print "            </tr>\n";
print "            <tr>\n";
print "              <td width=\"100\" align=\"right\"><font face\=\"$font\" size\=\"$font_size_table\" $font_color >&nbsp;8 Sterne</font></td>\n";
print "              <td width=\"100\"><font face\=\"$font\" size\=\"$font_size_table\" $font_color >&nbsp;\= $ACCOUNT[28] mal</font></td>\n";
print "            </tr>\n";
print "            <tr>\n";
print "              <td width=\"100\" align=\"right\"><font face\=\"$font\" size\=\"$font_size_table\" $font_color >&nbsp;7 Sterne</font></td>\n";
print "              <td width=\"100\"><font face\=\"$font\" size\=\"$font_size_table\" $font_color >&nbsp;\= $ACCOUNT[27] mal</font></td>\n";
print "            </tr>\n";
print "            <tr>\n";
print "              <td width=\"100\" align=\"right\"><font face\=\"$font\" size\=\"$font_size_table\" $font_color >&nbsp;6 Sterne</font></td>\n";
print "              <td width=\"100\"><font face\=\"$font\" size\=\"$font_size_table\" $font_color >&nbsp;\= $ACCOUNT[26] mal</font></td>\n";
print "            </tr>\n";
print "            <tr>\n";
print "              <td width=\"100\" align=\"right\"><font face\=\"$font\" size\=\"$font_size_table\" $font_color >&nbsp;5 Sterne</font></td>\n";
print "              <td width=\"100\"><font face\=\"$font\" size\=\"$font_size_table\" $font_color >&nbsp;\= $ACCOUNT[25] mal</font></td>\n";
print "            </tr>\n";
print "            <tr>\n";
print "              <td width=\"100\" align=\"right\"><font face\=\"$font\" size\=\"$font_size_table\" $font_color >&nbsp;4 Sterne</font></td>\n";
print "              <td width=\"100\"><font face\=\"$font\" size\=\"$font_size_table\" $font_color >&nbsp;\= $ACCOUNT[24] mal</font></td>\n";
print "            </tr>\n";
print "            <tr>\n";
print "              <td width=\"100\" align=\"right\"><font face\=\"$font\" size\=\"$font_size_table\" $font_color >&nbsp;3 Sterne</font></td>\n";
print "              <td width=\"100\"><font face\=\"$font\" size\=\"$font_size_table\" $font_color >&nbsp;\= $ACCOUNT[23] mal</font></td>\n";
print "            </tr>\n";
print "            <tr>\n";
print "              <td width=\"100\" align=\"right\"><font face\=\"$font\" size\=\"$font_size_table\" $font_color >&nbsp;2 Sterne</font></td>\n";
print "              <td width=\"100\"><font face\=\"$font\" size\=\"$font_size_table\" $font_color >&nbsp;\= $ACCOUNT[22] mal</font></td>\n";
print "            </tr>\n";
print "            <tr>\n";
print "              <td width=\"100\" align=\"right\"><font face\=\"$font\" size\=\"$font_size_table\" $font_color >&nbsp;1 Stern</font></td>\n";
print "              <td width=\"100\"><font face\=\"$font\" size\=\"$font_size_table\" $font_color >&nbsp;\= $ACCOUNT[21] mal</font></td>\n";
print "            </tr>\n";
print "          </table>\n";
print "          </center>\n";
print "        </div>\n";
print "        \n";
print "        <p align=\"center\"><font face\=\"$font\" size\=\"$font_size_table\" $font_color >Anzahl der abgegebenen Stimmen \= <b>$stimmen</b> </font>";
print "        \n";
print "        <p align=\"center\"><font face\=\"$font\" size\=\"$font_size_table\" $font_color >&nbsp;Gesamtergebnis \ = \<b>$vote_percent</b>%</font>";
print "        \n";
print "        <p align=\"center\">&nbsp;</td>\n";
print "    </tr>\n";
print "    <tr>      <td width=\"431\" bgcolor=\"$table_body_color\" align=\"right\" height=\"50\">\n";
print "        <p align=\"center\"><input TYPE=\"BUTTON\" VALUE=\"Fenster schliessen\" onhit=window.close()></td>\n";
print "    </tr>\n";
print "  </table>\n";
print "  </center>\n";
print "</div>\n";
&footer;


}

sub header {

            print "Content-type: text/html\n\n";
            print "<html><head><title>$title</title>\n";
            if ($laufleiste) {
                print "<style>body \{scrollbar-arrow-color : $scrollbar_arrow_color\; ";
                print "scrollbar-base-color: $scrollbar_base_color \;  \}</style>";
                }
            open (DATEI,"<$cgi_root_path/config/insert/metatag.dat")||die("Konnte die Datei metatag.dat nicht einlesen");
            if ($use_flock eq "1") {flock (DATEI,1);}
            @DATEN =<DATEI>;
            if ($use_flock eq "1") {flock (DATEI,8);}
            close (DATEI);
            foreach $line (@DATEN)
            {
            print $line;
            }
            print "</head>\n";
            print "<body background\=\"$background\" bgcolor\=$backcolor text\=\"$text_link_text\" link\=\"$text_link_link\" vlink\=\"$text_link_vlink\" alink\=\"$text_link_alink\">\n";
            open (DATEI,"<$cgi_root_path/config/insert/header.dat")||die("Konnte die Datei header.dat nicht einlesen");
            if ($use_flock eq "1") {flock (DATEI,1);}
            @DATEN =<DATEI>;
            if ($use_flock eq "1") {flock (DATEI,8);}
            close (DATEI);
            foreach $line (@DATEN)
            {
            print $line;
            }
           }

sub footer {

            open (DATEI,"<$cgi_root_path/config/insert/footer.dat")||die("Konnte die Datei footer.dat nicht einlesen");
            if ($use_flock eq "1") {flock (DATEI,1);}
            @DATEN =<DATEI>;
            if ($use_flock eq "1") {flock (DATEI,8);}
            close (DATEI);
            foreach $line (@DATEN)
            {
            print $line;
            }
            print "<br><br><center><font face=\"Arial\" size=\"2\" color=\"$text_link_text\"><b>makme-Topliste $version</b> &#169; by <a <font target=\"_blank\" href=\"http://www.toplistenzentrale.com\"><font face=\"Arial\" size=\"2\" color=\"$text_link_text\">Toplistenzentrale.com</font></a></font></center>\n";
            print "</body></html>\n";
            }

sub backup {

  open (BACKUP,"<$cgi_root_path/config/backup/backup.log")||die("Konnte die Datei backup.log nicht einlesen");
      if ($use_flock eq "1") {flock (BACKUP,1);}
      @BACKUPLOG =<BACKUP>;
      if ($use_flock eq "1") {flock (BACKUP,8);}
      close (BACKUP);

### Freie Backup-Nummer suchen / Backup erzeugen und in Datenbank schreiben
      $backupnumberneu="1001";
      while (-e "$cgi_root_path/config/backup/backup$backupnumberneu.dat")
            {
            $backupnumberneu++;
            }
    open (BACKUPLOG, ">>$cgi_root_path/config/backup/backup.log")||die("Konnte die Datei backup.log nicht beschreiben");
    if ($use_flock eq "1") {flock (BACKUPLOG,1);}
    print BACKUPLOG "$zeit|$cgi_root_path/config/backup/backup$backupnumberneu.dat|\n";
    if ($use_flock eq "1") {flock (BACKUPLOG,8);}
    close (BACKUPLOG);
    open (ACCOUNT, "<$userdatapath/user.dat")||die("Konnte die Datei user.dat nicht einlesen");
    if ($use_flock eq "1") {flock (ACCOUNT,1);}
    @ALLEDATEN = <ACCOUNT>;
    if ($use_flock eq "1") {flock (ACCOUNT,8);}
    close (ACCOUNT);

    open (NEWBACKUP, ">$cgi_root_path/config/backup/backup$backupnumberneu.dat")||die("Konnte die Datei backup$backupnumberneu.dat nicht beschreiben");
    if ($use_flock eq "1") {flock (NEWBACKUP,1);}
    foreach $line (@ALLEDATEN){
    print NEWBACKUP "$line";
    }
    if ($use_flock eq "1") {flock (NEWBACKUP,8);}
    close (NEWBACKUP);
    chmod 0777, "$cgi_root_path/config/backup/backup$backupnumberneu.dat";

    if ($backup_mail eq on){
    @MAIL = split(/\@/, $backup_mail_adress);
    open (MAIL,"|$mailpath -t");
    print MAIL "To: $MAIL[0]\@$MAIL[1]\n";
    print MAIL "From: $your_mail\n";
    print MAIL "Subject: Backup der $title erstellt \n";
    print MAIL "Content-type: text/plain\n\n";
    print MAIL "Hallo Admin\n\n";
    print MAIL "Ihre Topliste: $title wurde gesichert.\n\n";
    print MAIL "Sie finden Ihr Backup im Administrationsbereich Ihres PTS unter:\n\n";
    print MAIL "$cgi_root_url/config/admin.cgi\n\n";
    close (MAIL);
    }
}

sub neues_mitglied_form {
&header;
print "<div align=\"center\">\n";
print "  <center>\n";
print "  <table width=\"600\" border=\"$toplist_border_width\" bordercolor=\"$toplist_border_color\" cellspacing=\"$toplist_cellspacing\" cellpadding=\"$toplist_cellpadding\" bgColor=\"$table_bg_color\">\n";
print "    <tr>\n";
print "      <td width=\"600\" bgcolor=\"$table_head_color\" colspan=\"2\">\n";
print "        <p align=\"center\"><font face\=\"$font\" size\=\"$font_size_table\" color=\"$font_color_table_header\"><b><big>Neuen Account erstellen</big></b></font></td>\n";
print "    </tr>\n";
print "    <tr><form method=\"POST\" action=\"$neues_mitglied_url\">\n";
print "      <td width=\"220\" bgcolor=\"$table_body_color\" align=\"right\" height=\"25\"><font face\=\"$font\" size\=\"$font_size_table\" $font_color >Account Name</font></td>\n";
print "      <td width=\"380\" bgcolor=\"$table_body_color\" height=\"25\"><input type=\"text\" name=\"account\" size=\"33\"></td>\n";
print "    </tr>\n";
print "    <tr>\n";
print "      <td width=\"220\" bgcolor=\"$table_body_color\" align=\"right\" height=\"25\"><font face\=\"$font\" size\=\"$font_size_table\" $font_color >Passwort</font></td>\n";
print "      <td width=\"380\" bgcolor=\"$table_body_color\" height=\"25\"><input type=\"password\" name=\"passwort\" size=\"33\"></td>\n";
print "    </tr>\n";
print "    <tr>\n";
print "      <td width=\"220\" bgcolor=\"$table_body_color\" align=\"right\" height=\"25\"><font face\=\"$font\" size\=\"$font_size_table\" $font_color >Wiederholung Passwort</font></td>\n";
print "      <td width=\"380\" bgcolor=\"$table_body_color\" height=\"25\"><input type=\"password\" name=\"confirm_passwort\" size=\"33\"></td>\n";
print "    </tr>\n";
print "    <tr>\n";
print "      <td width=\"220\" bgcolor=\"$table_body_color\" align=\"right\" height=\"25\"><font  face\=\"$font\" size\=\"$font_size_table\" $font_color >Vorname</font></td>\n";
print "      <td width=\"380\" bgcolor=\"$table_body_color\" height=\"25\"><input type=\"text\" name=\"vorname\" size=\"33\"></td>\n";
print "    </tr>\n";
print "    <tr>\n";
print "      <td width=\"220\" bgcolor=\"$table_body_color\" align=\"right\" height=\"25\"><font face\=\"$font\" size\=\"$font_size_table\" $font_color >Nachname</font></td>\n";
print "      <td width=\"380\" bgcolor=\"$table_body_color\" height=\"25\"><input type=\"text\" name=\"nachname\" size=\"33\"></td>\n";
print "    </tr>\n";
print "    <tr>\n";
print "      <td width=\"220\" bgcolor=\"$table_body_color\" align=\"right\" height=\"25\"><font face\=\"$font\" size\=\"$font_size_table\" $font_color >Email</font></td>\n";
print "      <td width=\"380\" bgcolor=\"$table_body_color\" height=\"25\"><input type=\"text\" name=\"email\" size=\"33\"></td>\n";
print "    </tr>\n";
print "    <tr>\n";
print "      <td width=\"220\" bgcolor=\"$table_body_color\" align=\"right\" height=\"25\"><font face\=\"$font\" size\=\"$font_size_table\" $font_color >Seitenname</font></td>\n";
print "      <td width=\"380\" bgcolor=\"$table_body_color\" height=\"25\"><input type=\"text\" name=\"seitenname\" size=\"33\"></td>\n";
print "    </tr>\n";
print "    <tr>\n";
print "      <td width=\"220\" bgcolor=\"$table_body_color\" align=\"right\" height=\"62\"><font face\=\"$font\" size\=\"$font_size_table\" $font_color >Beschreibung</font></td>\n";
print "      <td width=\"380\" bgcolor=\"$table_body_color\" height=\"62\">\n";
print "                          <textarea rows=\"3\" name=\"beschreibung\" cols=\"28\"></textarea></td>\n";
print "    </tr>\n";
print "    <tr>\n";
print "      <td width=\"220\" bgcolor=\"$table_body_color\" align=\"right\" height=\"25\"><font face\=\"$font\" size\=$font_size_table\" $font_color >Seiten-Url</font></td>\n";
print "      <td width=\"380\" bgcolor=\"$table_body_color\" height=\"25\"><input type=\"text\" name=\"seitenurl\" size=\"33\" ></td>\n";
print "    </tr>\n";
print "    <tr>\n";
print "      <td width=\"220\" bgcolor=\"$table_body_color\" align=\"right\" height=\"25\"><font face\=\"$font\" size\=\"$font_size_table\" $font_color  >Banner-Url</font></td>\n";
print "      <td width=\"380\" bgcolor=\"$table_body_color\" height=\"25\"><input type=\"text\" name=\"bannerurl\" size=\"33\" ></td>\n";
print "    </tr>\n";
print "    <tr>\n";
print "      <td width=\"220\" bgcolor=\"$table_body_color\" align=\"right\" height=\"25\"><font face\=\"$font\" size\=\"$font_size_table\" $font_color  >Bannerbreite</font></td>\n";
print "      <td width=\"380\" bgcolor=\"$table_body_color\" height=\"25\"><input type=\"text\" name=\"bannerbreite\" size=\"33\"><font face\=\"$font\" size\=\"$font_size_table\" $font_color > (max. $user_banner_width Pixel)</td> \n";
print "    </tr>\n";
print "    <tr>\n";
print "      <td width=\"220\" bgcolor=\"$table_body_color\" align=\"right\" height=\"25\"><font face\=\"$font\" size\=\"$font_size_table\" $font_color >Bannerh&ouml;he</font></td>\n";
print "      <td width=\"380\" bgcolor=\"$table_body_color\" height=\"25\"><input type=\"text\" name=\"bannerhoehe\" size=\"33\"><font face\=\"$font\" size\=\"$font_size_table\" $font_color > (max. $user_banner_height Pixel) </td>\n";
print "    </tr>\n";
print "    <tr>\n";
print "      <td width=\"220\" bgcolor=\"$table_body_color\" align=\"right\" height=\"25\"><input type=\"hidden\" name=\"regeln\" value=\"ja\"></td>\n";
print "      <td width=\"380\" bgcolor=\"$table_body_color\" height=\"25\"><font face\=\"$font\" size\=\"$font_size_table\" $font_color  >&nbsp;</td>\n";
print "    </tr>\n";
print "    <tr>\n";
print "      <td width=\"220\" bgcolor=\"$table_body_color\" height=\"27\">&nbsp;</td>\n";
print "      <td width=\"380\" bgcolor=\"$table_body_color\" height=\"27\"><input type=\"hidden\" name=\"newuser\" value=\"ja\"><input type=\"submit\" value=\"Abschicken\">\&nbsp;\&nbsp;&nbsp;\n";
print "        <input type=\"reset\" value=\"&Auml;nderungen verwerfen\"></td>\n";
print "    </tr></form>\n";
print "  </table>\n";
print "  </center>\n";
print "</div>\n";
&footer;
    }
sub edit_form {
&header;
print "<div align=\"center\">\n";
print "<center>\n";
print "<table width=\"600\" border=\"$toplist_border_width\" bordercolor=\"$toplist_border_color\" cellspacing=\"$toplist_cellspacing\" cellpadding=\"$toplist_cellpadding\" bgColor=\"$table_bg_color\">\n";
print "<tr>\n";
### Mitgliedsaccount bearbeiten
print "<td width=\"600\" bgcolor=\"$table_head_color\" colspan=\"2 \">\n";
print "<p align=\"center\"><font face\=\"$font\" size\=\"$font_size_table\" color=\"$font_color_table_header\"><b><big>Login\: Mitglieds-Account bearbeiten</big></b></font></td>\n";
print "</tr>\n";
print "<tr>\n";
print "<td width=\"600\" bgcolor=\"$table_body_color\" align=\"right\" height=\"25\" colspan=\"2\">&nbsp;</td>\n";
print "</tr>\n";
print "<tr><form method=\"POST\" action=\"$edit_mitglied_url\">\n";
print "<td width=\"220\" bgcolor=\"$table_body_color\" align=\"right\" height=\"25\"><font face\=\"$font\" size\=\"$font_size_table\" $font_color  >Ihr Mitgliedsname</font></td>\n";
print "<td width=\"380\" bgcolor=\"$table_body_color\" height=\"25\"><input type=\"text\" name=\"editaccount\" size=\"33\"></td>\n";
print "</tr>\n";
print "<tr>\n";
print "<td width=\"220\" bgcolor=\"$table_body_color\" align=\"right\" height=\"25\"><font face\=\"$font\" size\=\"$font_size_table\" $font_color  >Ihr Passwort</font></td>\n";
print "<td width=\"380\" bgcolor=\"$table_body_color\" height=\"25\"><input type=\"password\" name=\"editpass\" size=\"33\"></td>\n";
print "</tr>\n";
print "<tr>\n";
print "<td width=\"600\" bgcolor=\"$table_body_color\" height=\"27\" colspan=\"2\">\n";
print "<p align=\"center\">\n";
print "<input type=\"hidden\" name=\"edit_mitglied\" value=\"ja\">\n";
print "<center><input type=\"submit\" value=' login ' ></center>\n";
if ($email_on eq 1){
print "<br><br><center><font face\=\"$font\" size\=\"$font_size_table\" $font_color >Wenn Sie Ihr Passwort vergessen haben, kann unser System versuchen es Ihnen zuzusenden.<br>In diesem Fall klicken Sie bitte</font>
<a href=\"$cgi_root_url/topliste.cgi\?action\=lostpassform\"><font face\=\"$font\" size\=\"$font_size_table\" $font_color >hier</font></a><center>\n";
}
print "</p></form>\n";
print "</td>\n";
print "</tr>\n";
print "</table>\n";
print "</center>\n";
print "</div>\n";
&footer;
}

sub vote_form {
&header;
print "<p>&nbsp;</p>\n";
print "<div align=\"center\">\n";
print "<center>\n";
print "<table width=\"560\" border=\"$toplist_border_width\" bordercolor=\"$toplist_border_color\" cellspacing=\"$toplist_cellspacing\" cellpadding=\"$toplist_cellpadding\" bgColor=\"$table_bg_color\">\n";
print "<tr>\n";
print "<td width=\"560\" bgcolor=\"$table_head_color\" >\n";
print "<p align=\"center\"><font face\=\"$font\" size\=\"$font_size_table\" color=\"$font_color_table_header\" ><b><big>\"$FORM{account}\" -&nbsp; Mitglied bewerten<big></b></font></big></big></td>\n";
print "</tr>\n";
print "<tr>\n";
print "<td width=\"560\" bgcolor=\"$table_body_color\" align=\"right\">\n";
print "<p align=\"center\">&nbsp;</p>\n";
print "<p align=\"center\">\n";
print "<img border=\"0\" src=\"$FORM{bannerurl}\" alt=\"Userbanner des $FORM{account} Accounts\" width=\"$FORM{bannerbreite}\" height=\"$FORM{bannerhoehe}\"></p>\n";
print "<p align=\"center\">&nbsp;</td>\n";
print "</tr>\n";
print "<tr>\n";
print "<td width=\"560\" bgcolor=\"$table_body_color\" align=\"right\">\n";
print "<p align=\"center\">&nbsp;</p>\n";
print "<form method=\"GET\" action=\"$cgi_root_url/topliste.cgi\">\n";
print "<input type=\"hidden\" name=\"action\" value=\"vote_final\">\n";
print "<input type=\"hidden\" name=\"account\" value=\"$FORM{account}\">\n";
print "<p align=\"center\"><select size=\"1\" name=\"bewertung\">\n";
print "<option selected value=\"30\">10 - sehr gut</option>\n";
print "<option value=\"29\">9</option>\n";
print "<option value=\"28\">8</option>\n";
print "<option value=\"27\">7</option>\n";
print "<option value=\"26\">6</option>\n";
print "<option value=\"25\">5 - durchschnittlich</option>\n";
print "<option value=\"24\">4</option>\n";
print "<option value=\"23\">3</option>\n";
print "<option value=\"22\">2</option>\n";
print "<option value=\"21\">1 - schlecht</option>\n";
print "</select>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type=\"submit\" value=\"Mitglied bewerten\" ></p>\n";
print "</form>\n";
print "<p align=\"center\">&nbsp;</td>\n";
print "</tr>\n";
print "</table>\n";
print "</center>\n";
print "</div>\n";
&footer;
}

sub vote_final {
                $datensatz = "0";
                   open (ACCOUNT, "<$userdatapath/user.dat")||die("Konnte die Datei user.dat nicht einlesen");
                   if ($use_flock eq "1") {flock (ACCOUNT,1);}
                   @ALLEDATEN = <ACCOUNT>;
                   if ($use_flock eq "1") {flock (ACCOUNT,8);}
                   close (ACCOUNT);
                   foreach (@ALLEDATEN)
                   {
                   @ACCOUNTDATEN = split (/\|/, $ALLEDATEN[$datensatz]);
                   if ($ACCOUNTDATEN[4] eq $FORM{account})
                   {$ACCOUNTDATEN[$FORM{bewertung}]++ ;
                    $ACCOUNTDATEN[20]++ ;
                    $vote_erfolgreich=1;}
                   $ALLEDATEN[$datensatz] = join ("\|",@ACCOUNTDATEN);
                   $datensatz++;
                   }
                        open (ACCOUNT, ">$userdatapath/user.dat")||die("Konnte die Datei user.dat nicht beschreiben");
                        if ($use_flock eq "1") {flock (ACCOUNT,1);}
                        print ACCOUNT @ALLEDATEN;
                        if ($use_flock eq "1") {flock (ACCOUNT,8);}
                        close (ACCOUNT);
 &show_vote;
}

sub lost_pass_form {
&header;
### Passwort vergessen Formular
print "<div align=\"center\">\n";
print "<center>\n";
print "<table width=\"650\" border=\"$toplist_border_width\" bordercolor=\"$toplist_border_color\" cellspacing=\"$toplist_cellspacing\" cellpadding=\"$toplist_cellpadding\" bgColor=\"$table_bg_color\">\n";
print "<tr>\n";
print "<td width=\"650\" bgcolor=\"$table_head_color\" colspan=\"2\">\n";
print "<p align=\"center\"><font face\=\"$font\" size\=\"$font_size_table\" color=\"$font_color_table_header\"><b><big>Passwort vergessen \?</big></b></font></td>\n";
print "</tr>\n";
print "<tr>\n";
print "<td width=\"650\" bgcolor=\"$table_body_color\" align=\"right\" height=\"25\" colspan=\"2\">\n";
print "<center><font face\=\"$font\" size\=\"$font_size_table\" $font_color >Bitte geben Sie Ihren Mitgiedsnamen ein.<br>Das Toplistensystem versucht Ihnen Ihr Passwort an die im Account angegebene<br>e-Mailadresse zu senden.</font></center>";
print "</td></tr>\n";
print "<tr><form method=\"GET\" action=\"$cgi_root_url/topliste.cgi\">\n";
print "<input type=\"hidden\" name=\"lost_password\" value=\"ja\">\n";
print "<td width=\"250\" bgcolor=\"$table_body_color\" align=\"right\" height=\"25\"><font face\=\"$font\" size\=\"$font_size_table\" $font_color >Account Name</font></td>\n";
print "<td width=\"400\" bgcolor=\"$table_body_color\" height=\"25\"><input type=\"text\" name=\"account\" size=\"33\"></td>\n";
print "</tr>\n";
print "<tr>\n";
print "<td width=\"650\" bgcolor=\"$table_body_color\" height=\"27\" colspan=\"2\">\n";
print "<p align=\"center\">\n";
print "<input type=\"submit\" value=' login ' >\n";
print "</p></form>\n";
print "</td>\n";
print "</tr>\n";
print "</table>\n";
print "</center>\n";
print "</div>\n";
&footer;
}

sub search_pass {
$datensatz = "0";
                   open (ACCOUNT, "<$userdatapath/user.dat")||die("Konnte die Datei user.dat nicht einlesen");
                   if ($use_flock eq "1") {flock (ACCOUNT,1);}
                   @ALLEDATEN = <ACCOUNT>;
                   if ($use_flock eq "1") {flock (ACCOUNT,8);}
                   close (ACCOUNT);
                   foreach (@ALLEDATEN)
                   {
                   @ACCOUNTDATEN = split (/\|/, $ALLEDATEN[$datensatz]);
                   if ($ACCOUNTDATEN[4] eq $FORM{account})
                   {$ACCOUNTDATEN[$FORM{bewertung}]++ ;
                    $pass=$ACCOUNTDATEN[5];
                    $email=$ACCOUNTDATEN[8] ;
                    $suche_erfolgreich=1;}

                   $datensatz++;
                   }
if ($suche_erfolgreich eq 1){
@MAIL = split(/\@/, $email);
open (MAIL,"|$mailpath -t");
print MAIL "To: $MAIL[0]\@$MAIL[1]\n";
print MAIL "From: $your_mail\n";
print MAIL "Subject: Ihr Passwort fuer die Premiumtopliste $title \n";
print MAIL "Content-type: text/plain\n\n";
print MAIL "Sie haben Ihr Passwort für unser Tolistensystem angefordert.\n\n";
print MAIL "Unser Premium-Tolistensystem hat die folgenden Zugangsdaten gefunden:\n\n";
print MAIL "Mitgliedsname: $FORM{account} \n";
print MAIL "Passwort: $pass\n\n";
print MAIL "Sie finden Ihren Eintrag unter:\n\n";
print MAIL "$cgi_root_url/topliste.cgi\n\n";
print MAIL "Sollten Ihre Daten fehlerhaft sein koennen Sie diese hier auch bearbeiten:\n\n";
print MAIL "$cgi_root_url/topliste.cgi?action=edit_mitglied\n\n";
close (MAIL);

&header;
print "<div align=\"center\">\n";
print "<center>\n";
print "<table width=\"600\" border=\"$toplist_border_width\" bordercolor=\"$toplist_border_color\" cellspacing=\"$toplist_cellspacing\" cellpadding=\"$toplist_cellpadding\" bgColor=\"$table_bg_color\">\n";
print "<tr>\n";
print "<td width=\"600\" bgcolor=\"$table_head_color\" colspan=\"2\">\n";
print "<center><font face\=\"$font\" size\=\"$font_size_table\" color=\"$font_color_table_header\"><b><big>Passwort wurde versandt</big></b></font></td>\n";
print "</tr>\n";
print "<tr>\n";
print "<td width=\"600\" bgcolor=\"$table_body_color\" align=\"right\" height=\"25\" colspan=\"2\">\n";
print "<center><br><br><font face\=\"$font\" size\=\"$font_size_table\" $font_color ><b>Ihr Passwort wurde soeben vom System an folgende e-Mail-Adresse geschickt:</b></font><br><br>";
print "<font face\=\"$font\" size\=\"$font_size_table\" $font_color ><b><big>$email</big></b></font><br><br><br><br></td>\n";
print "</tr>\n";
print "</table>\n";
print "<br><br><p align=\"center\"><font face\=\"$font\" size\=\"$font_size_table\" $font_color><a href=\"$cgi_root_url/topliste.cgi\">Zur&uuml;ck zur $title </a></font></p>\n";
print "</center>\n";
print "</div>\n";
&footer;
}
else {
&header;
print "<div align=\"center\">\n";
print "<center>\n";
print "<table width=\"600\" border=\"$toplist_border_width\" bordercolor=\"$toplist_border_color\" cellspacing=\"$toplist_cellspacing\" cellpadding=\"$toplist_cellpadding\" bgColor=\"$table_bg_color\">\n";
print "<tr>\n";
print "<td width=\"600\" bgcolor=\"$table_head_color\" colspan=\"2\">\n";
print "<center><font face\=\"$font\" size\=\"$font_size_table\" color=\"$font_color_table_header\"><b>Mitgliedsdaten nicht gefunden\!</b></font></td>\n";
print "</tr>\n";
print "<tr>\n";
print "<td width=\"600\" bgcolor=\"$table_body_color\" align=\"right\" height=\"25\" colspan=\"2\">\n";
print "<center><br><br><font $font size\=\"$error_font_size\" color\=\"$error_font_color\"><b>Das Toplistensystem konnte Ihre Mitgliedsdaten leider nicht finden!</b></font><br>";
print "<font $font size\=\"$error_font_size\" color\=\"$error_font_color\"><b>Bitte &uuml;berpr&uuml;fen Sie Ihre Eingabe\!</b></font><br><br><br><br></td>\n";
print "</tr>\n";
print "</table>\n";
print "<br><br><p align=\"center\"><font size=\"4\" face=\"Arial\" ><a href=javascript:history.go(-1);><font face=\"Arial\" size=\"2\" color=\"$text_link_text\">Zur&uuml;ck</font></a></font></p>\n";
print "</center>\n";
print "</div>\n";
&footer;
}
}

sub confirm_rules {
&header;
print "<div align=\"center\">\n";
print "<center>\n";
print "<table width=\"600\" border=\"$toplist_border_width\" bordercolor=\"$toplist_border_color\" cellspacing=\"$toplist_cellspacing\" cellpadding=\"$toplist_cellpadding\" bgColor=\"$table_bg_color\">\n";
print "<tr>\n";
print "<td width=\"600\" bgcolor=\"$table_head_color\" colspan=\"2\" >\n";
print "<center><font face\=\"$font\" size\=\"$font_size_table\" color=\"$font_color_table_header\"><b>Regeln f&uuml;r den Beitritt in die Premiumtopliste $title</b></font></td>\n";
print "</tr>\n";
print "<tr>\n";
print "<td width=\"600\" bgcolor=\"$table_body_color\"  height=\"25\" colspan=\"2\">\n";
print "<font face\=\"$font\" size\=\"$font_size_table\" $font_color>\n";
open (DATEI,"<$cgi_root_path/config/insert/regeln.txt")||die("Konnte die Datei regeln.txt nicht einlesen");
            if ($use_flock eq "1") {flock (DATEI,1);}
            @DATEN =<DATEI>;
            if ($use_flock eq "1") {flock (DATEI,8);}
            close (DATEI);
            foreach $line (@DATEN)
            {
            print "$line" ;
            }
print "</font>\n";
##########################################################


print "<center>\n";
print "<table border=\"0\" cellpadding=\"3\" cellspacing=\"1\">\n";
print "<td>\n";
print "<form action=\"$cgi_root_url/topliste.cgi\" method=\"POST\" name=\"yes\">";
print "<input type=\"hidden\" name=\"action\" value=\"rules_accept\"><input type=\"submit\" name=\"Submit\" value=\"Regeln akzeptieren\"></form>\n";
print "</td>\n";
print "<td>\&nbsp;\&nbsp;\&nbsp;</td>\n";
print "<td>\n";
print "<form action=\"$cgi_root_url/topliste.cgi\" method=\"POST\"><input type=\"submit\" value=\"Regeln ablehnen\"></form>\n";
print "</td>\n";
print "</table>\n";
print "</center>\n";
##########################################################
if (!$wait_rules_accept){$wait_rules_accept = 10;}
print "<script language=\"javascript\">\n";
print "<!--\n";
print "var secs = $wait_rules_accept;\n";
print "var wait = secs * 1000;\n";
print "document.yes.Submit.disabled=true;\n";
print "        \n";
print "for(i=1;i<=secs;i++) {\n";
print " window.setTimeout(\"update(\" + i + \")\", i * 1000);\n";
print "}\n";
print "\n";
print "window.setTimeout(\"zeitr()\", wait);\n";
print "\n";
print "function update(num) {\n";
print " if(num == (wait/1000)) {\n";
print "  document.yes.Submit.value = \"Regeln akzeptieren\";\n";
print " }\n";
print " else {\n";
print "  printnr = (wait/1000)-num;\n";
print "  document.yes.Submit.value = \"Regeln akzeptieren ( \" + printnr + \" Sek. )\";\n";
print " }\n";
print "}\n";

print "function zeitr() {\n";
print " document.yes.Submit.disabled=false;\n";
print "}\n";
print "//-->\n";
print "</script>\n";
print "</td>\n";
print "</tr>\n";
print "</table>\n";
print "</center>\n";
print "</div>\n";
&footer;
}


sub regeln {

}

sub error {
    &header;
    print "<div align=\"center\">\n";
    print "<center>\n";
    print "<table width=\"600\" border=\"$toplist_border_width\" bordercolor=\"$toplist_border_color\" cellspacing=\"$toplist_cellspacing\" cellpadding=\"$toplist_cellpadding\" bgColor=\"$table_bg_color\">\n";
    print "<tr>\n";
    print "<td width=\"600\" bgcolor=\"$table_head_color\" colspan=\"2\" height=\"40\">\n";
    print "<p align=\"center\"><font face\=\"$font\" size\=\"$font_size_table\" color=\"$font_color_table_header\"><b><big>Folgende Fehler wurden gefunden</big></b></font></td>\n";
    print "</tr>\n";
    print "<tr><td width=\"600\" bgcolor=\"$table_body_color\"><p>&nbsp;</p>\n";
    print "@FEHLER";
    print "<p>&nbsp;</p></td></tr>";
    print "</table>\n";
    print "</center>\n";
    print "<p>\&nbsp;</p><center><input TYPE=BUTTON VALUE=Schliessen onhit=window.close()> <center>\n";
    print "</div>\n";
    &footer;

}
1;