#!/usr/bin/perl #!/usr/local/bin/perl # ------------- # Links # ------------- # Links Manager # # File: eintrag.cgi # Beschreibung: Adds a record marked unvalidated to the database and # optionally emails someone. # 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. # ===================================================================== # # Setup Notes: # 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"; $build_use_templates ? require "$db_lib_path/site_html_templates.pl" : require "$db_lib_path/site_html.pl"; }; 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."; exit; } # ======================================================== eval { &main; }; if ($@) { &cgierr("Allgemeiner Fehler: $@"); } exit; sub main { # -------------------------------------------------------- local (%in) = &parse_form; if (keys %in != 0) { &process_form; } else { if ($db_single_category) { my %is_valid = map { $_ => 1 } &category_list; $ENV{'HTTP_REFERER'} =~ s,/[^/]+\.[^/]+$,,; $ENV{'HTTP_REFERER'} =~ m,$build_root_url/(.+?)/?$,; $is_valid{$1} ? &site_html_add_form ($1) : &site_html_add_form (); } else { &site_html_add_form (); } } } sub process_form { # -------------------------------------------------------- my ($key, $status, $line, $output); # ----------------------------------------------- # Banner-MOD by Martin Bujara # www.linkdb.de # ----------------------------------------------- if ($in{'Width'} > "$bannerw") { &site_html_add_failure ("Bannerbreite zu gross, max. $bannerw Pix."); return; } if ($in{'Height'} > "$bannerh") { &site_html_add_failure ("Bannerhöhe zu gross, max. $bannerh Pix."); return; } # Check the referer. if (@db_referers and $ENV{'HTTP_REFERER'}) { $found = 0; foreach (@db_referers) { $ENV{'HTTP_REFERER'} =~ /$_/i and $found++ and last; } if (!$found) { &site_html_add_failure ("Automatische Eintragung akzeptiert dieses System nicht."); return; } } foreach $key (keys %add_system_fields) { $in{$key} = $add_system_fields{$key}; } $in{$db_cols[$db_modified]} = &get_date; open (ID, "<$db_links_id_file_name") or &cgierr("Fehler. Kann die Datei bzw. Verzeichnis nicht öffnen: $db_links_id_file_name. Grund: $!"); $in{$db_key} = + 1; close ID; $status = &validate_record(%in); if ($status eq "ok") { open (ID, ">$db_links_id_file_name") or &cgierr("Fehler. Kann die Datei bzw. Verzeichnis nicht öffnen: $db_links_id_file_name. Grund: $!"); flock(ID, 2) unless (!$db_use_flock); print ID $in{$db_key}; close ID; open (VAL, ">>$db_valid_name") or &cgierr("Fehler. Kann die Datei bzw. Verzeichnis nicht öffnen: $db_valid_name. Grund: $!"); flock(VAL, 2) unless (!$db_use_flock); print VAL &join_encode(%in); close VAL; &send_email; &site_html_add_success; } else { &site_html_add_failure($status); } } sub send_email { # -------------------------------------------------------- $db_admin_email or &cgierr("Admin Emailadresse in der links.cfg wurde nicht angegeben!"); my $to = $db_admin_email; my $from = $in{$db_cols[$db_contact_email]}; my $subject = "Link zugefügt: $in{'Titel'}\n"; my $msg = qq| Folgender Link erwartet Ihre Bearbeitung: Titel : $in{'Titel'} URL : $in{'URL'} Kategorie : $in{'Kategorie'} Beschreibung: $in{'Beschreibung'} Name : $in{'Name'} Email : $in{'Email'} Remote Host : $ENV{'REMOTE_HOST'} Referer : $ENV{'HTTP_REFERER'} Zum Adminbereich klicken Sie hier: $db_script_url Grüsse, Links Manager. |; require "$db_lib_path/Mailer.pm"; my $mailer = new Mailer ( { smtp => $db_smtp_server, sendmail => $db_mail_path, from => $from, subject => $subject, to => $to, msg => $msg, log => $db_mailer_log } ) or return; $mailer->send or return; }