#!/usr/bin/perl #################################################################### # # Update.pl # # Saves new advert to the selected category # Redirects to updated.html # # License and contact information can be found at www.danpromote.dk/int/ # # Copyright 2001 DanPromote # Last modified 01/17/2001 #################################################################### # Points $mailprogram to sendmail - used to send notificaiton $mailprogram = '/usr/sbin/sendmail'; # Where should notification be send ? $notify_email = 'thearma@thearma.org'; # Should notification be send (yes/no) ? $donotify="no"; # How many days should new postings "live" ? $livedays=999; # Changing anything below this line is not recommened # Calculates todays number ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); $today=$yday; # Gets the data from the form &parse_form; $headline = $FORM{'headline'}; $text = $FORM{'text'}; $category = lc($FORM{'category'}); $category =~ s/ /_/g; $name = $FORM{'name'}; $telephone = $FORM{'telephone'}; $email = $FORM{'email'}; $res1 = $FORM{'res1'}; $res2 = $FORM{'res2'}; $res3 = $FORM{'res3'}; $res4 = $FORM{'res4'}; $res5 = $FORM{'res5'}; # Calls subroutine to validate the input &validate; # Opens the counter-file and finds the last ID $countfile = "counter.txt"; open(COUNT,"$countfile") || die "Cant open $countfile !\n"; $ID = ; close(COUNT); # Gets the next ID and saves the counter $ID++; open(COUNT,">$countfile") || die "Cant open $countfile !\n"; print (COUNT "$ID\n"); close(COUNT); # Converts < to < to avoid abuse (\n"; print ""; exit; } } sub notify { if($email ne "") { $from = $email; } else { $from = $notify_email; } open(MAIL, "|$mailprogram -t") || die "Cant open $mailprogram\n"; print MAIL "From: $from\n"; print MAIL "To: $notify_email\n"; print MAIL "Subject: $header\n\n"; print MAIL "$text\n\n"; print MAIL "$category\n\n"; print MAIL "$name - $telephone - $email\n\n"; close(MAIL); } sub parse_form { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); if (length($buffer) < 5) { $buffer = $ENV{QUERY_STRING}; } @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $FORM{$name} = $value; } }