Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Fax4Free

by Dark1 (Initiate)
on Mar 10, 2000 at 14:51 UTC ( #5160=sourcecode: print w/ replies, xml ) Need Help??

Category: internet
Author/Contact Info M. de Kok, mdekok@adicted.to
Description: Scipt uses the Net::SMTP module.. can be installed using PPM or VPM.
#!/usr/local/bin/perl

######################################################################
+#########
#                                                    #
#    FAX.PL (Fist release)                                     #
# Scripting and testing by M. de Kok                            #
# Code is free for personal use...                                #
#                                                    #
# For info and/or support mail: mdekok@adicted.to                    #
#                                                     #
# M.de kok                                                #
# Lingestraat 4                                            #
# 6826 AL, GLD.                                            #
# Arnhem, Netherlands                                        #
# +31620377240                                            #
# ICQ #9712917                                            #
#                                                    #
# Script @ work at: http://adicted.to/fax4free                        
+#
#                                                    #
######################################################################
+#########

# use the Net::SMTP module.. (can be installed using PPM or VPM)
use Net::SMTP;

# Meta tags
$tags = '<META NAME="Author" CONTENT="M. de Kok)"><meta name="keywords
+" content="JavaScript, JavaScripts, Java, Script, Scripts, SQL, datab
+ase, db, clickhere, Internet Services,'.
' Free, Repository, How-To, How, To, Guides, Documentation, Resources,
+ Marco de Kok, Sign Up!, Cool Notify, Hot List, DIRECTORIES, ASP, CGI
+, Databases, HTML/DHTML, Intranets, Java,'.
' JavaScript, Perl, What\'s Cool, What\'s New, REFERENCE, TRAINING CEN
+TER, JOURNAL, Users Choice, Profiles, Free Scripts, Online Events, AB
+OUT US, Who We Are, What We Do, News About Us,'.
' Advertising Info, email, developers, scripts, examples, free, refere
+nce, menu, help, editor, search, forwarding, forwarding service, emai
+l, email forwarding, library, database, samples,'.
' plan, directory, adicted, adicted.to, to, .to, adiction, adicts, pro
+gramming, journal, script, creating, web, pages, creating, commercial
+, web, site, design, learn, javascript, programming,'.
' languages, scripts"><meta name="description" content="Free URL and e
+mail forwardings, perlscript downloads and examples."><META NAME="dis
+tribution" CONTENT="global"><META NAME="resource-type"'.
' CONTENT="document"><META NAME="language" CONTENT="en"><META NAME="RO
+BOTS" CONTENT="ALL">';

# get data from form
&parse_form;

# organize data
$r_name=$TAG{r_name};
$r_adrs=$TAG{r_adrs};
$r_number=$TAG{r_number};
$f_mail=$TAG{f_mail};
$subject=$TAG{subject};
$body=$TAG{body};
$job_done=$TAG{job_done};

# Create Date Stamp
 my($date,$min,$hour,$day,$month,$year,$weekday,$ampm,$zero,@weekdays,
+@months);
 (undef, $min, $hour, $day, $month, $year, $weekday) = localtime(time)
+;
 @weekdays = ("Sunday","Monday","Tuesday","Wednesday",
             "Thursday","Friday","Saturday");
 @months = ("January","February","March","April","May","June","July",
           "August","September","October","November","December");
 # Dates correct through 2097 :)
 if ($year > 97) { $year += 1900; } else { $year += 2000; }
 # Fix Time
 if ($hour > 12) { $hour -= 12; $ampm = "PM"; } else { $ampm = "AM"; }
 if ($hour == 0) { $hour = 12; }
 if ($min < 10) { $zero = "0"; } else { $zero = ""; }
 $time = "$hour:$zero$min $ampm";
 $date = "$weekdays[$weekday], $months[$month] $day, $year";



if ($job_done eq "on") { &mail_entry }

$job_done="on";

# print HTML
print '<!doctype html public "-//w3c//dtd html 4.0 transitional//en"><
+html><head>';

   print <<"__HTML__"

 $tags
<title>fax4free</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2
+">
<script language="JavaScript">
<!--

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_popupMsg(theMsg) { //v2.0
  alert(theMsg);
}
//-->
</script>
</head>

<body bgcolor="#FFFFFF" background="bindertile.gif">
<form method="post" action="http://adicted.to/cgi-bin/fax.pl" name="fa
+x_form">
  <input type=hidden name=job_done value="$job_done">
  <table width="75%" border="0" align="center" name="main" background=
+"background.gif">
    <tr> 
      <td> 
        <div align="center">
          <p><font face="Verdana, Arial, Helvetica, sans-serif" size="
+5"><b>Cover 
            Page</b></font></p>
          <p><font face="Verdana, Arial, Helvetica, sans-serif" size="
+-1" color="#FF0000"><i>$message</i></font></p>
          <hr id="hr_1" size="2">
          <p align="right"><font face="Verdana, Arial, Helvetica, sans
+-serif" size="-2" color="#000000">Page 
            1 of 2</font></p>
          <p><font face="Verdana, Arial, Helvetica, sans-serif" size="
+-1" color="#000000"><i><b>FACSIMILE 
            TRANSMISSION</b></i></font></p>
          <p align="left"><font face="Verdana, Arial, Helvetica, sans-
+serif" size="-1" color="#000000"><i><b> 
            Please deliver this facsimile to:</b></i></font></p>
          <table width="73%" border="0">
            <tr> 
              <td width="34%"><b><font face="Verdana, Arial, Helvetica
+, sans-serif" color="#000000" size="-1"><strong><font color="#FF0000"
+>*</font></strong>Recipients 
                name:</font></b></td>
              <td width="66%" align="left" valign="bottom"><b><font fa
+ce="Verdana, Arial, Helvetica, sans-serif" color="#3333FF" size="-1">
+ 
                <input type="text" name="r_name" size="25" maxlength="
+60">
                </font></b></td>
            </tr>
            <tr> 
              <td width="34%"><b><font face="Verdana, Arial, Helvetica
+, sans-serif" color="#FF0000" size="-1"><strong>*</strong></font><fon
+t face="Verdana, Arial, Helvetica, sans-serif" size="-1" color="#0000
+00">Recipients 
                address:</font></b></td>
              <td width="66%" align="left" valign="bottom"><b><font fa
+ce="Verdana, Arial, Helvetica, sans-serif" size="-1" color="#3333FF">
+ 
                <input type="text" name="r_adrs" size="25" maxlength="
+60">
                </font></b></td>
            </tr>
            <tr>
              <td width="34%"><b><font face="Verdana, Arial, Helvetica
+, sans-serif" color="#FF0000" size="-1"><strong>*</strong></font><fon
+t face="Verdana, Arial, Helvetica, sans-serif" size="-1" color="#0000
+00">Recipients 
                number: </font></b> </td>
              <td width="66%" align="left" valign="bottom"> 
                <input type="text" name="r_number">
                <img src="help.gif" width="75" height="15" alt="Help" 
+name="helpred" onMouseDown="MM_openBrWindow('http://adicted.to/fax4fr
+ee/country_list.txt','list','scrollbars=yes,resizable=yes,width=250,h
+eight=500');
MM_popupMsg('example number: +310263445566 where +31 is the country co
+de (Netherlands) and 026 the area code. Enter +31 like: 31 and 026 li
+ke 26! The number to enter in this example should be: 31263445566')">
+</td>
            </tr>
          </table>
          <p align="left"><font size="-1" face="Verdana, Arial, Helvet
+ica, sans-serif" color="#000000"><i><b>From:</b></i></font></p>
          <table width="58%" border="0">
            <tr>
              <td width="34%"><b><font face="Verdana, Arial, Helvetica
+, sans-serif" color="#000000" size="-1"><strong><font color="#FF0000"
+>*</font></strong>Your 
                email address:</font></b><b><font face="Verdana, Arial
+, Helvetica, sans-serif" color="#3333FF" size="-1"> 
                </font></b></td>
              <td width="66%" align="left" valign="bottom"><b><font fa
+ce="Verdana, Arial, Helvetica, sans-serif" color="#3333FF"> 
                <input type="text" name="f_mail" maxlength="60">
                </font></b></td>
            </tr>
          </table>
          <p align="left"><b><i><font face="Verdana, Arial, Helvetica,
+ sans-serif" size="-1" color="#000000">Date:</font></i></b></p>
          <table width="57%" border="0">
            <tr>
              <td width="34%"><font face="Verdana, Arial, Helvetica, s
+ans-serif" size="-1" color="#000000"><b>$time</b></font></td>
              <td width="66%">
                <div align="right"><font face="Verdana, Arial, Helveti
+ca, sans-serif" size="-1" color="#000000"><b>$date</b></font></div>
              </td>
            </tr>
          </table>
          <p align="left"><b><i><font face="Verdana, Arial, Helvetica,
+ sans-serif" size="-1" color="#000000">Subject:</font></i></b></p>
          <table width="59%" border="0">
            <tr>
              <td width="32%"><b><font face="Verdana, Arial, Helvetica
+, sans-serif" color="#000000" size="-1">Subject 
                of this fax:</font></b></td>
              <td width="68%" align="left" valign="bottom"> 
                <input type="text" name="subject">
              </td>
            </tr>
          </table>
          <p>&nbsp;</p>
          <p><font face="Verdana, Arial, Helvetica, sans-serif" size="
+5"><b>Body</b></font></p>
          <p align="left"><b><font face="Verdana, Arial, Helvetica, sa
+ns-serif" color="#FF0000" size="-1"><strong>*<font size="-2">Requied 
            fields </font></strong></font></b> </p>
          <hr size="2">
          <p align="right"><font face="Verdana, Arial, Helvetica, sans
+-serif" size="-2" color="#000000">Page 
            2 of 2</font></p>
          <p align="right">&nbsp;</p>
          <p align="left"><b><i><font face="Verdana, Arial, Helvetica,
+ sans-serif" size="-1" color="#000000">Body:</font></i></b></p>
          <p align="center">
            <textarea name="body" cols="50" wrap="PHYSICAL" rows="15">














                 fax4free = a Adicted.to/service</textarea>
          </p>
          <p align="left">&nbsp;</p>
          <p align="center">&nbsp;</p>
          <p> 
            <input type="submit" name="Submit" value="Go Fax!">
            <input type="reset" name="Submit2" value="Reset">
          </p>
          <p>
          <p align="left"><b><font face="Verdana, Arial, Helvetica, sa
+ns-serif" size="-1" color="#3333FF"> 
            </font></b></p>
          <p>
        </div>
      </td>
    </tr>
  </table>
</form>
</body>
</html>


__HTML__
;



exit;

# SUBS

sub parse_form {

  if ($ENV{'QUERY_METHOD'} eq "GET") {
    &error("GET");
    }
 read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

# Split the name-value pairs
 @pairs = split(/&/, $buffer);

 foreach $pair (@pairs)
 {
     ($name, $value) = split(/=/, $pair);

     # Un-Webify plus signs and %-encoding
     $value =~ tr/+/ /;
     $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

     # Stop people from using subshells to execute commands
     # Not a big deal when using sendmail, but very important
     # when using UCB mail (aka mailx).
     # $value =~ s/~!/ ~!/g;

     # Uncomment for debugging purposes
     # print "Setting $name to $value<P>";
 
     $TAG{$name} = $value;
 }
  }



sub mail_entry {

# check address syntax
if ($f_mail =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/ || $f_mail !~ /^.+\@(
+\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/) {
 &error("mail_syntax");
}
if ($subject eq "") { $subject = "Fax4Free is a service from adicted.t
+o" }

# Mail data to counter and user
 $smtp = Net::SMTP->new('adicted.to', Hello => 'SpankzMail.Rulez', Tim
+eout => 30, Debug   => 0);
 $smtp->mail('postmaster@adicted.to');
  $smtp->to('counter@adicted.to');
    $smtp->recipient($f_mail);
    $smtp->data();
    $smtp->datasend("To: $f_mail\n");
    $smtp->datasend("From: auto\@adicted.to\n");
    $smtp->datasend("X-mailer: SpankZMailService v. 0.01t\n");
    $smtp->datasend("Mime-Version: 1.0\n");
    $smtp->datasend("Content-type: text/plain\n");
    $smtp->datasend("Subject: $subject\n\n");
    $smtp->datasend("__________________________\n\n");
    $smtp->datasend("Fax send to: $r_name, $r_adrs\n");
    $smtp->datasend("To fax number: $r_number\n");
    $smtp->datasend("______________________________\nBody:\n\n");
    $smtp->datasend("$body\n\n");
    $smtp->datasend("______________________________\n\n");
    $smtp->datasend("Your fax request has been accepted\n");
    $smtp->datasend("for delivery on $r_number... The logs for this\n"
+);
    $smtp->datasend("facsimile wil be send to you soon by tpcadmin\@in
+fo.tpc.in");
$smtp->quit;

# compose message for delivery on tcp...

$info1 = $r_name;
$info2 = $r_adrs;
$info1 =~ s/ /_/g;
$info2 =~ s/ /_/g;
$r_info1 = $info1;
$r_info2 = $info2;
$compose = "remote-printer." . $r_info1 . "/" . $r_info2 . "\@" . $r_n
+umber . ".iddd.tpc.int";


# deliver request @ tcp

$smtp = Net::SMTP->new('adicted.to', Hello => 'SpankzMail.Rulez', Time
+out => 30, Debug   => 0);
 $smtp->mail('postmaster@adicted.to');
  $smtp->to('counter@adicted.to');
    $smtp->recipient($compose);
    $smtp->data();
    $smtp->datasend("To: TCP\n");
    $smtp->datasend("From: $f_mail\n");
    $smtp->datasend("X-mailer: SpankZMailService v. 0.01t\n");
    $smtp->datasend("Mime-Version: 1.0\n");
    $smtp->datasend("Content-type: text/plain\n");
    $smtp->datasend("Subject: $subject\n\n");
    $smtp->datasend("$body\n\n");
$smtp->quit;


$message="Your facsimile has been added for delivery!";
$job_done="";
}

sub error {
  my %ERR;
  $ERR{"not_ready"} = "Sorry, but this part of the service is under co
+nstruction right now.
     your fax request however has been accepted for delivery on $numbe
+r...";
  $ERR{"mail_syntax"} = "[ $email ] is not an valide address!";
  $ERR{"GET"} = "The script must be called with the POST method.";
  $ERR{"debug"} = "compose = $compose";
  $ERR{"no_data"} = "All fields must by completed!";
  my $emsg = $ERR{$_[0]};
  if (!$emsg) {
    $emsg = "The script has suffered an unknown error.";
  }
  print "Content-type: text/html", "\n\n";
  print "<html><body>\n";
  print "<h1>Fax Error</h1>\n";
  print "$emsg";
  print "</body></html>";
  exit;
}

Comment on Fax4Free
Download Code
RE: Fax4Free
by Anonymous Monk on Sep 20, 2000 at 07:14 UTC
    LOL. I Sense Macromedia DreamWeaver 2.0 , hehehe
Re: Fax4Free
by Anonymous Monk on Feb 01, 2006 at 01:01 UTC
    6 year? this script is timeless.

Back to Code Catacombs

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: sourcecode [id://5160]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (17)
As of 2015-07-02 19:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (44 votes), past polls