"Fossies" - the Fresh Open Source Software Archive

Member "smslink-0.56b-3/varia/web/smsgw.pl" (15 Nov 2005, 2271 Bytes) of package /linux/misc/old/smslink-0.56b-3.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "smsgw.pl" see the Fossies "Dox" file reference documentation.

    1 #!/usr/bin/perl -w
    2 #===========================================================
    3 # Program : smsgw.pl
    4 # Author  : Philippe Andersson
    5 # Date    : 24/03/99
    6 # Version : 1.1
    7 # Comment : (c) Les Ateliers du Heron, 1999 for Scitex Europe, S.A.
    8 # Version History :
    9 # * 1.0 (15/03/99) - Initial release.
   10 # * 1.1 (24/03/99) - Fixed a problem with multi-line input.
   11 #===========================================================
   12 
   13 use strict;
   14 use diagnostics;
   15 use CGI;
   16 
   17 #-----------------------------------------------------------
   18 # Name the global variables
   19 my $userid = "";
   20 my $dest = "";
   21 my $msgtxt = "";
   22 
   23 # Create en instance of CGI
   24 my $query = new CGI;
   25 
   26 # Send the MIME header
   27 print $query->header ("text/html");
   28 
   29 # Grab posted values
   30 $userid = $query->param ("userid");
   31 $dest = $query->param ("dest");
   32 $msgtxt = $query->param ("msgtxt");
   33 
   34 # Was at least one field filled-in ?
   35 if (($userid eq "") || ($dest eq "") || ($msgtxt eq "")) {
   36   print $query->start_html (-title => "Error !");
   37   print "<H1>Error !</H1>\n";
   38   print "<P>All fields are required - at least one of them is ";
   39   print "missing. Please go back and try again.</P>\n";
   40   print $query->end_html;
   41   exit;
   42 }
   43 
   44 # Check message length
   45 my $txtlen = length ($msgtxt);
   46 if ($txtlen > 160) {
   47   print $query->start_html (-title => "Error !");
   48   print "<H1>Error !</H1>\n";
   49   print "<P>Your message text is longer than 160 char. (now $txtlen). ";
   50   print "This 160 char. limit is built in the SMS protocol and can't ";
   51   print "be bypassed. ";
   52   print "Please go back and edit your message to make it shorter.</P>\n";
   53   print $query->end_html;
   54   exit;
   55 }
   56 
   57 # Remove newlines from msgtxt (replace them by space)
   58 $msgtxt =~ s/\n/ /g;
   59 
   60 #===========================================================
   61 print $query->start_html (-title => "SMS Sending Results");
   62 
   63 print "<H1>SMS Sending Results</H1>\n";
   64 
   65 #-----------------------------------------------------------
   66 # Submit the sendsms request
   67 my $retval = 0;
   68 
   69 $retval = system ("sendsms", "-d$dest", "-u$userid", "-m$msgtxt", "your-server");
   70 
   71 if ($retval == 0) {
   72   print "<P>Message was sent successfully !</P>\n";
   73 }
   74 else {
   75   print "<P>Failed to deliver message !</P>\n";
   76 }
   77 
   78 # End the HTML
   79 print $query->end_html;
   80 
   81 #-----------------------------------------------------------
   82 
   83 exit;
   84