#!/usr/bin/perl use Socket; ################################################################## # (C)1998-9 Bignosebird.com bnbform v3.0 # This software is FREEWARE! Do with it as you wish. It is yours # to share and enjoy. Modify it, improve it, and have fun with it! # It is distributed strictly as a learning aid and bignosebird.com # disclaims all warranties- including but not limited to: # fitness for a particular purpose, merchantability, loss of # business, harm to your system, etc... ALWAYS BACK UP YOUR # SYSTEM BEFORE INSTALLING ANY SCRIPT OR PROGRAM FROM ANY # SOURCE! # # Socket based e-mail for cross platform capability! # ############## SPECIAL FORM VARIABLES ############################ #required: comma delimited list of required entry fields #data_order: comma delimited list indicating what fields to actually # print and in what order. #outputfile: the name of the file to save the data in if using a file #emailfile: the name of the file to hold only the sender e-mail address #ok_url: URL to go to if successful #not_ok_url URL to go to if unsuccessful #submit_to: email address of person to input receive data by mail #cc_to: email address of Cc Recipient #submit_by: email address of person completing form #autorespond: if yes, then send confirmation to submitter #automessage: text to print for autoconfirmation e-mail #form_id: name of form for e-mail subject #countfile: name of file for serial number counter #okaydomains: prevents calling the script from other sites, # without restricting e-mail addresses. # replaces $SECURE_NAME from earlier versions. # use only lower case letters. #SMTP_SERVER: the full host name of the server providing e-mail # gateway service ################################################################## ## MAIN ########################################################## # uncomment the line below, and change bignosebird to your domain # name if you wish to make is so the script can only be called # from your site. @okaydomains=("http://support.cohf.net", "http://www.cumonherface.com", "http://members.cohf.net"); #SMTP_SERVER: indicates the name of the host acting as the e-mail # gateway. "localhost" should work on most systems. #$SMTP_SERVER="localhost"; #OR IF SMTP IS UNAVAILABLE TO YOU, USE SEND_MAIL- # BUT NOT BOTH! $SEND_MAIL="/usr/sbin/sendmail -t"; $lockfile="/tmp/bnbform.lck"; &decode_vars; &valid_page; if ($fields{'countfile'} ne "") { &get_number; } &valid_data; &write_data; if ($fields{'autorespond'} eq "yes") { &answer_back; } if ($fields{'ok_url'} ne "") { print "Location: $fields{'ok_url'}\n\n"; exit;} else { &thank_you; } ################################################################## sub write_data { if ($fields{'submit_by'} ne "") { if (&valid_address == 0) { &bad_email; exit; } } if ($fields{'submit_by'} ne "" && $fields{'emailfile'} ne "") { open (EMF,">>$fields{'emailfile'}"); print EMF "$fields{'submit_by'}\n"; close (EMF); } $the_date=localtime(); if ($fields{'submit_to'} ne "") { $msgtext=""; $msgtext .= "On $the_date,\n"; $msgtext .= "The following information was submitted:\n"; $msgtext .= "Host: $ENV{'REMOTE_ADDR'}\n"; $nslookup=`host $ENV{'REMOTE_ADDR'}`; $msgtext .= "NsLookup: $nslookup\n"; } if ($fields{'outputfile'} ne "") { &get_the_lock; open(OUT_FILE,">>$fields{'outputfile'}"); } foreach $to_print (@sortlist) { if ($fields{'outputfile'} ne "") { print OUT_FILE "$fields{$to_print}\|"; } if ($fields{'submit_to'} ne "") { $msgtext .= "$to_print = $fields{$to_print}\n"; } } $msgtext .= "\nSupport Function:\n"; $msgtext .= "Login test: http://$fields{'username'}:$fields{'password'}\@members.cohf.net/cohf/cohfmembers/cohf/index.shtml\n"; $msgtext .= "Username: http://members.cohf.net/cohf/cgi-bin/controlpanelcohf/supportcohf/support_admin.cgi?username=$fields{'username'}&action=userreport&email=$fields{'submit_by'}\n"; $msgtext .= "Subscription: http://members.cohf.net/cohf/cgi-bin/controlpanelcohf/supportcohf/support_admin.cgi?subscription=$fields{'subscription'}&action=subsreport&email=$fields{'submit_by'}\n"; $msgtext .= "Email: http://members.cohf.net/cohf/cgi-bin/controlpanelcohf/supportcohf/support_admin.cgi?email=$fields{'submit_by'}&action=emailreport\n"; if ($fields{'outputfile'} ne "") { print OUT_FILE "$the_date\|\n"; close(OUT_FILE); &drop_the_lock; } if ($fields{'submit_to'} ne "") { $mailresult=&sendmail($fields{submit_by}, $fields{submit_by}, $fields{submit_to}, $SMTP_SERVER, $fields{form_id}, $msgtext); if ($mailresult ne "1") {print "Content-type: text/html\n\n"; print "MAIL NOT SENT. SMTP ERROR: $mailcodes{'$mailresult'}\n"; exit } } if ($fields{'cc_to'} ne "") { $mailresult=&sendmail($fields{submit_by}, $fields{submit_by}, $fields{cc_to}, $SMTP_SERVER, $fields{form_id}, $msgtext); } } ################################################################## sub decode_vars { $i=0; read(STDIN,$temp,$ENV{'CONTENT_LENGTH'}); @pairs=split(/&/,$temp); foreach $item(@pairs) { ($key,$content)=split(/=/,$item,2); $content=~tr/+/ /; $content=~s/%(..)/pack("c",hex($1))/ge; $content=~s/\t/ /g; $fields{$key}=$content; if ($key eq "data_order") { $content=~s/ //g; @sortlist=split(/,/,$content); } if ($key eq "required") { $content=~s/ //g; @mandatory=split(/,/,$content); } } } ################################################################## sub valid_data { if ($fields{'data_order'} eq "") #make sure we have work to do! { print "Content-type: text/html\n\n"; print <<__W1__;
__W3__
exit;
}
##################################################################
sub answer_back
{
$subject = "COHF Support Confirmation";
$msgtext="";
if ($fields{'automessage'} ne "")
{
open (AM,"< $fields{'automessage'}");
while (