#!/usr/bin/perl #!/usr/local/bin/perl # ------------- # Links # ------------- # Links Manager # # File: verweis.cgi # Beschreibung: Increments the number of hits for the specified link, # and sends the user off to the appropriate page. # Author: Alex Krohn # Email: alex@gossamer-threads.com # Web: http://www.gossamer-threads.com/ # Version: 2.01 # # (c) 1998 Gossamer Threads Inc. # # This script is not freeware! Please read the README for full details # on registration and terms of use. # ===================================================================== # # Form Input: # '$db_key' = key number # Send as form input the key name and key value # # of the link you want to go to. # # Setup: # Make sure the require statement below points to the config file. # # # German Translation by Nicky # http://www.nicky.net # Deutsches Forum http://forum.nicky.net # Required Librariers # -------------------------------------------------------- eval { ($0 =~ m,(.*)/[^/]+,) && unshift (@INC, "$1"); # Get the script location: UNIX / ($0 =~ m,(.*)\\[^\\]+,) && unshift (@INC, "$1"); # Get the script location: Windows \ require "admin/links.cfg"; # Ändern Sie dieses zum vollen Pfad zu links.cfg, wenn Sie Probleme haben sollten. require "$db_lib_path/db_utils.pl"; require "$db_lib_path/links.def"; }; if ($@) { print "Content-type: text/plain\n\n"; print "Fehler beim einlesen von dazugehörigen Bibliothek Dateien: $@\n"; print "Überprüfen Sie ob diese existieren, Pfade richtig eingestellt sind, und ob die Dateien richtig CHMOD-ed sind."; } # ======================================================== eval { &main; }; if ($@) { &cgierr("Allgemeiner Fehler: $@"); } exit; sub main { # -------------------------------------------------------- my %in = &parse_form(); my ($goto, $id, $delim, $time); $id = $in{$db_key}; $delim = quotemeta($db_delim); $time = time(); if ($id eq "zufallsprinzip") { my ($count, $rand, $find); open (COUNT, "<$db_hits_path/index.count") or &error ("Fehler. Kann die Datei bzw. Verzeichnis nicht öffnen: $db_hits_path/index.count. Grund: $!"); $count = int ; close COUNT; srand; $find = 0; $rand = int (rand ($count + 0.5)); ($rand == $count) and ($rand--); open (URL, "<$db_url_name") or &error ("Fehler. Kann die Datei bzw. Verzeichnis nicht öffnen: $db_url_name. Grund: $!"); while () { $find++ == $rand or next; /\d+$delim(.+)/o or next; $goto = $1; last; } close URL; $goto or &error ("Allgemeiner Fehler: $rand."); } elsif (exists $in{$db_key}) { ($id =~ /^\d+$/) or &error ("ID - $id - exsitiert nicht."); open (URL, "<$db_url_name") or &error ("Fehler. Kann die Datei bzw. Verzeichnis nicht öffnen: $db_url_name. Grund: $!"); while () { (/^$id$delim(.+)/o) or next; chomp ($goto = $1); last; } close URL; $goto or &error ("Kann den Link mit der ID: $id nicht finden."); if (open (HIT, "<$db_hits_path/$id")) { my ($count, $old_time, @IP, $ip, $visited); chomp ($count = ); chomp ($old_time = ); chomp (@IP = ); (($time - $old_time) > 21600) and (@IP = ()); foreach $ip (@IP) { $ip eq $ENV{'REMOTE_ADDR'} and ($visited++ and last); } if (!$visited) { push (@IP, $ENV{'REMOTE_ADDR'}); $count = $count + 1; open (HIT, ">$db_hits_path/$id") or &error ("Fehler. Kann die Datei bzw. Verzeichnis nicht öffnen. Grund: $!"); if ($db_use_flock) { flock (HIT, 2) or &error ("Allgemeiner fehler. Grund: $!"); } local $" = "\n"; print HIT "$count\n$time\n@IP"; close HIT; } } else { open (HIT, ">$db_hits_path/$id") or &error ("Allgemeiner Fehler. Grund: $!"); print HIT "1\n$time\n$ENV{'REMOTE_ADDR'}"; close HIT; } } else { &error ("Kein Link ausgewählt!"); } $goto ? print "Location: $goto\n\n" : &error ("Links ID ($in{$db_key}) nicht gefunden."); } sub error { # ------------------------------------------ # print "Content-type: text/plain\n\n"; print "Fehler: $_[0]\n"; exit; }