#!/usr/bin/perl
#########################################################################################
# #
# Test implementation of Smash protocol in perl for CGI use. #
# Based on a textbook TCP/IP client example. (Yess! Cut'nPaste really works!) #
# This comes without any warranties. Use at own risk. #
# There is no real number validator in here. #
# JavaScript is just doing concatenation & length check.. #
# #
# You can envoke the script with query line parameters "number=46701234567" #
# and "message=Testing%20writing%20to%20the%20form" which is useful in links. #
# These override any defaults in config section... #
# #
# SMS #
# #
# Göran Ekeberg 2001-09-04 #
# #
#########################################################################################
#Small script config part...
$port = 7077; #Server port
$them = '10.42.17.2'; #Server IP adress or name
$scriptURL = "/cgi-bin/sms"; #Where am I?
@operators = ("comviq",
"telia", #Operators hash.
"europolitan"); #See server config for the ones 2 chose.
#"other"); #The first one is default...
$number = "4670"; #Consider NOT setting this value...
$defaultmessage = ""; #Hmmm...
######################################################################################
#Config page appearence
$pageheader = "
Smash CGI Client
";
#End of page header stuff.
###########################################################################################
#End of config! Wear gloves below this line!
#Variables
$htmlheader = "content-type: text/html\n\n";
###########################################################################################
#Decode form data
$i=0;
if ($ENV{'QUERY_STRING'}) {
$temp = $ENV{'QUERY_STRING'};
} else {
read(STDIN,$temp,$ENV{'CONTENT_LENGTH'});
}
@pairs=split(/&/,$temp);
foreach $item(@pairs)
{
($key,$content)=split(/=/,$item); # (/=/,$item,2);
$content=~tr/+/ /;
$content=~s/%(..)/pack("c",hex($1))/ge;
$content =~ s///g;
$fields{$key}=$content;
$i++;
}
#End decode
###########################################################################################
#Control script action
if ($fields{sendit}) {
&resultpage($fields{number},$fields{message},$fields{operator});
} else {
&formpage($fields{number},$fields{message});
}
#End control
######################################################################################
# Make some form html from operators hash
sub makeselect {
my $select = "";
$select = "
EOM
}
#End formpage
###########################################################################################
#Send and print result page
sub resultpage {
my ($num, $mess, $op) = @_;
$response = &sendIt($num, $mess, $op);
$mess =~ s/\n/ /g;
print $htmlheader;
print <Have queued:
\"$mess\"