\n"; } if ($class == "0" || $class == "1" || $class == "2" || $class == "3") { echo "Class: $class
\n"; } if ($coding == "8bit") { echo "BINARY
\n"; } else { if (!$text == "") echo ""; if ($coding == "Unicode_No_Compression" || $coding == "Unicode_Compression") { echo "Unicode t"; } else { echo "T"; } if ($textdecoded == "") { echo "ext
\n"; } else { echo "ext: $textdecoded
\n"; } if ($text == "") echo ""; echo "
\n"; } } function dispvalidity($validity) { if ($validity == -1) { echo "default"; } else if ($validity == 0) { echo "5 minutes"; } else if ($validity == 255) { echo "max. time"; } else { echo "$validity"; } } $arg=""; if (!isset($db_serv) && isset($_GET['serv'])) { $db_serv = $_GET['serv']; if ($arg == "") {$arg="?";} else {$arg=$arg."&";}; $arg = $arg . "serv=$db_serv"; $dbservorig=false; } if (!isset($db_user) && isset($_GET['user'])) { $db_user = $_GET['user']; if ($arg == "") {$arg="?";} else {$arg=$arg."&";}; $arg = $arg . "user=$db_user"; $dbuserorig=false; } if (!isset($db_pass) && isset($_GET['pass'])) { $db_pass = $_GET['pass']; if ($arg == "") {$arg="?";} else {$arg=$arg."&";}; $arg = $arg . "pass=$db_pass"; $dbpassorig=false; } if ($arg == "") {$arg="?";} else {$arg=$arg."&";}; if (!isset($db_name) && isset($_GET['db'])) { $db_name = $_GET['db']; } if (isset($db_pass) && isset($db_user) && isset($db_serv)) { $dbpass = @mysql_connect("$db_serv","$db_user","$db_pass"); if ($dbpass) { mysql_query("SET NAMES UTF8;"); if (isset($db_name)) { $dbconnect = mysql_select_db("$db_name"); } } } if (isset($dbpass) && isset($dbconnect) && isset($_GET['op']) && isset($_GET['year']) && isset($_GET['month']) && isset($_GET['day']) && isset($_GET['hour']) && isset($_GET['minute']) && isset($_GET['second']) && isset($_GET['number']) && isset($_GET['tresc']) && isset($_GET['validity']) && isset($_GET['report']) && isset($_GET['phone'])) { if ($_GET['op']=="addsms") { $year = $_GET['year']; $month = $_GET['month']; $day = $_GET['day']; $hour = $_GET['hour']; $minute = $_GET['minute']; $second = $_GET['second']; $datoom="$year$month$day$hour$minute$second"; $number=$_GET['number']; $tresc=$_GET['tresc']; $validity=$_GET['validity']; if (isset($_GET['class'])) { $class = $_GET['class']; } else { $class = "-1"; } $phone = $_GET['phone']; $report = $_GET['report']; if (strlen($tresc) > 160) { // $result2 = mysql_db_query("$db_name","select ID from outbox order by ID desc limit 1"); // $rekord2 = mysql_fetch_row($result2); // if ($rekord == null) { // $newid = 0; // } else { // $newid = $rekord2[0]; // } // mysql_free_result($result2); // $pos = 0; // $text = ""; } else { if ($report == "yes") { mysql_query ("insert into outbox(UpdatedInDB,InsertIntoDB,Class,DestinationNumber,TextDecoded,SendingDateTime,RelativeValidity,SenderID,DeliveryReport,Coding) VALUES(now(),now(),'$class','$number','$tresc','$datoom','$validity','$phone','yes','Default_No_Compression')"); } if ($report == "no") { mysql_query ("insert into outbox(UpdatedInDB,InsertIntoDB,Class,DestinationNumber,TextDecoded,SendingDateTime,RelativeValidity,SenderID,DeliveryReport,Coding) VALUES(now(),now(),'$class','$number','$tresc','$datoom','$validity','$phone','no','Default_No_Compression')"); } if ($report == "default") { mysql_query ("insert into outbox(UpdatedInDB,InsertIntoDB,Class,DestinationNumber,TextDecoded,SendingDateTime,RelativeValidity,SenderID,Coding) VALUES(now(),now(),'$class','$number','$tresc','$datoom','$validity','$phone','Default_No_Compression')"); } } } } if (isset($dbpass) && isset($dbconnect) && isset($_GET['op']) && isset($_GET['dzial'])) { if ($_GET['op']=="del") { if (isset($_GET['id'])) { $dzial = $_GET['dzial']; $id = $_GET['id']; mysql_query ("delete from $dzial where id='$id'"); if ($dzial == "outbox") { mysql_query ("delete from outbox_multipart where id='$id'"); } } else if ($delall) { $dzial = $_GET['dzial']; mysql_query ("delete from $dzial"); if ($dzial == "outbox") { mysql_query ("delete from outbox_multipart"); } } } $_GET['op']=$dzial; } echo "\n\n"; echo " "; echo "\n"; echo "SMS SERVER based on GAMMU\n\n"; if (isset($dbpass) && isset($dbconnect) && isset($_GET['op']) && isset($_GET['action'])) { if ($_GET['op']=="daemons") { $action = urldecode($_GET['action']); popen ($action, "r"); } } if (isset($dbpass) && isset($dbconnect) && isset($_GET['op']) && isset($_GET['year']) && isset($_GET['month']) && isset($_GET['day']) && isset($_GET['hour']) && isset($_GET['minute']) && isset($_GET['second']) && isset($_GET['number']) && isset($_GET['tresc']) && isset($_GET['validity'])) { if ($_GET['op']=="addsms") { echo ""; } } if (!isset($dbpass)) { echo "LOGIN

\n"; echo "

\n\n"; echo "\n"; echo "\n"; echo "\n"; echo "
Server address:port :
Name :
Password :
\n"; exit; } if (!$dbpass) { echo " 

Authorization error with MySQL server\n"; if (isset($dbservorig) || isset($dbuserorig) || isset($dbpassorig)) { echo "

Back to login form"; } echo "

\n"; exit; } if (isset($dbconnect) && !$dbconnect) { echo " 

No database in MySQL server
\n\n"; exit; } echo "\n"; echo "\n"; echo "\n\n\n\n\n\n\n\n\n
\n"; echo "SMS Gateway example, user $db_user"; echo "
"; #MENU if (isset($dbservorig) || isset($dbuserorig) || isset($dbpassorig)) { echo "OTHER USER
\n"; } $result0 = mysql_list_dbs($dbpass); while ($row0 = mysql_fetch_object($result0)) { $result = mysql_db_query("$row0->Database","select Version from gammu"); $rekord = @mysql_fetch_row($result); if (!$rekord) continue; mysql_free_result($result); if ($rekord[0]!='7') continue; $result2 = @mysql_list_tables($row0->Database); if (!$result2) continue; $found = false; while ($row2 = mysql_fetch_row($result2)) { if ($row2[0] == "inbox") $found = true; if ($row2[0] == "outbox") $found = true; if ($row2[0] == "outbox_multipart") $found = true; if ($row2[0] == "sentitems") $found = true; } mysql_free_result($result2); if (!$found) continue; if (!isset($_GET['db']) || $_GET['db']!=$row0->Database) { echo "Database>[>>] $row0->Database
\n"; continue; } echo "[<<] $row0->Database
\n"; echo "  Database&op=daemons>DAEMONS
\n"; echo "  Database&op=phones>PHONES

\n"; echo "  Database&op=newsms>NEW OUTBOX SMS

\n"; echo "  Database&op=inbox>INBOX
\n"; if (isset($_GET['op']) && $_GET['op']=="inbox") { $result = mysql_db_query("$db_name","select substring(ReceivingDateTime,1,10) from inbox group by substring(ReceivingDateTime,1,10) order by substring(ReceivingDateTime,1,10) desc"); while($rekord = mysql_fetch_row($result)) { $d = dispdate($rekord[0]); echo "     · Database&op=inbox&date=$rekord[0]>$d
"; } mysql_free_result($result); } echo "  Database&op=outbox>OUTBOX
\n"; if (isset($_GET['op']) && $_GET['op']=="outbox") { $result = mysql_db_query("$db_name","select substring(SendingDateTime,1,10) from outbox group by substring(SendingDateTime,1,10) order by substring(SendingDateTime,1,10) desc"); while($rekord = mysql_fetch_row($result)) { $d = dispdate($rekord[0]); echo "     · Database&op=outbox&date=$rekord[0]>$d
"; } mysql_free_result($result); } echo "  Database&op=sentitems>SENT ITEMS
\n"; if (isset($_GET['op']) && $_GET['op']=="sentitems") { $result = mysql_db_query("$db_name","select $sentitems,substring(SendingDateTime,1,10) from sentitems group by substring(SendingDateTime,1,10) order by substring(SendingDateTime,1,10) desc"); while($rekord = mysql_fetch_row($result)) { $d = dispdate($rekord[18]); echo "     · Database&op=sentitems&date=$rekord[18]>$d
"; } mysql_free_result($result); } } mysql_free_result($result0); # /MENU echo "

\n"; #TRESC if (isset($_GET['op'])) { if ($_GET['op']=="inbox") { $innum = 0; echo "DATABASE $db_name, INBOX"; if (isset($_GET['date']) && $_GET['date']!="") { $d = $_GET['date']; $d2 = dispdate($d); echo " $d2"; } echo "

\n"; echo ""; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; if ($delall) { echo "\n"; } else { echo "\n"; } if (!isset($_GET['date']) || $_GET['date']=="") { $result = mysql_db_query("$db_name","select $inbox from inbox order by ReceivingDateTime desc"); } else { $d = $_GET['date']; $result = mysql_db_query("$db_name","select $inbox from inbox where ReceivingDateTime like '$d%' order by ReceivingDateTime desc"); } while($rekord = mysql_fetch_row($result)) { $innum++; if (!isset($_GET['date']) || $_GET['date']=="") { if (isset($_GET['id']) && $_GET['id']!="" && $_GET['id'] == $rekord[9]) { echo ""; } else { echo ""; } } else { if (isset($_GET['id']) && $_GET['id']!="" && $_GET['id'] == $rekord[9]) { echo ""; } else { echo ""; } } echo ""; if ($rekord[7] == "-1") { echo ""; } else { echo ""; } $d2 = dispdatetime($rekord[1]); echo ""; echo ""; if (!isset($_GET['date']) || $_GET['date']=="") { echo ""; } else { echo ""; } if (isset($_GET['id']) && $_GET['id']!="" && $_GET['id'] == $rekord[9]) { $op = $_GET['op']; $id = $_GET['id']; echo "\n"; } } mysql_free_result($result); echo "
IDFROMSMSCCLASSRECEIVE TIMEPHONE[X]
$rekord[9] [<<]
$rekord[9] [>>]
$rekord[9] [<<]
$rekord[9] [>>]$rekord[3]$rekord[6]not set$rekord[7]$d2$rekord[10][X]
[X]
"; $d2 = dispdatetime($rekord[0]); echo "Last changed in DB: $d2
"; $d2 = dispdatetime($rekord[1]); echo "Insert into DB: $d2
"; dispsmsinfo($rekord[7],$rekord[5],$rekord[2],$rekord[8],$rekord[4]); echo "
"; echo "
$innum SMS received"; } if ($_GET['op']=="outbox") { $outduring = 0; $outfuture = 0; echo "DATABASE $db_name, OUTBOX"; if (isset($_GET['date']) && $_GET['date']!="") { $d = $_GET['date']; $d2 = dispdate($d); echo " $d2"; } echo "

\n"; echo ""; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; if ($delall) { echo "\n"; } else { echo "\n"; } if (!isset($_GET['date']) || $_GET['date']=="") { $result = mysql_db_query("$db_name","select $outbox from outbox order by SendingDateTime desc"); } else { $d = $_GET['date']; $result = mysql_db_query("$db_name","select $outbox from outbox where SendingDateTime like '$d%' order by SendingDateTime desc"); } while($rekord = mysql_fetch_row($result)) { if (!isset($_GET['date']) || $_GET['date']=="") { if (isset($_GET['id']) && $_GET['id']!="" && $_GET['id'] == $rekord[8]) { echo ""; } else { echo ""; } } else { if (isset($_GET['id']) && $_GET['id']!="" && $_GET['id'] == $rekord[8]) { echo ""; } else { echo ""; } } echo ""; $d2 = dispdatetime($rekord[11]); echo ""; $counter = 1; if ($rekord[9] == "true") { $result2 = mysql_db_query("$db_name","select $outbox_multipart from outbox_multipart where id='$rekord[8]'"); while($rekord2 = mysql_fetch_row($result2)) $counter++; mysql_free_result($result2); } echo ""; } else { echo "[X]"; } if (isset($_GET['id']) && $_GET['id']!="" && $_GET['id'] == $rekord[8]) { $op = $_GET['op']; $id = $_GET['id']; echo "\n"; } } mysql_free_result($result); echo "
IDTOTIME 2BE SENTPARTSVALIDITYSENDINGPHONEREPORT[X]
$rekord[8] [<<]
$rekord[8] [>>]
$rekord[8] [<<]
$rekord[8] [>>]$rekord[3]$d2$counter"; dispvalidity($rekord[10]); if ($rekord[13] != "00000000000000") { $result2 = mysql_db_query("$db_name","select now()+0;"); $rekord2 = mysql_fetch_row($result2); if ($rekord[13]<$rekord2[0]) { echo "no (earlier failed)"; $outfuture++; } else { echo "yes (now)"; $outduring++; } mysql_free_result($result2); } else { echo "no (earlier not tried)"; $outfuture++; } if ($rekord[12] == "") { echo "<< any >>"; } else { echo "$rekord[12]"; } echo "$rekord[14]"; if (!isset($_GET['date']) || $_GET['date']=="") { echo "[X]
"; $result2 = mysql_db_query("$db_name","select $outbox from outbox where ID='$id'"); while($rekord2 = mysql_fetch_row($result2)) { $d2 = dispdatetime($rekord2[0]); echo "Last changed in DB: $d2
"; $d2 = dispdatetime($rekord2[1]); echo "Insert into DB: $d2
"; if ($rekord2[9] == "true") { echo "
"; } dispsmsinfo($rekord2[6],$rekord2[5],$rekord2[2],$rekord2[7],$rekord2[4]); if ($rekord[9] == "true") { $result3 = mysql_db_query("$db_name","select $outbox_multipart from outbox_multipart where id='$rekord[8]'"); while($rekord3 = mysql_fetch_row($result3)) { echo "
"; dispsmsinfo($rekord3[3],$rekord3[2],$rekord3[0],$rekord3[4],$rekord3[1]); } mysql_free_result($result3); } } mysql_free_result($result2); echo "
"; echo "
$outduring SMS sequences during sending, $outfuture SMS sequences waiting for sending"; } if ($_GET['op']=="sentitems") { $sentnum = 0; echo "DATABASE $db_name, SENT ITEMS"; if (isset($_GET['date']) && $_GET['date']!="") { $d = $_GET['date']; $d2 = dispdate($d); echo " $d2"; } echo "

\n"; echo ""; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; if ($delall) { echo "\n"; } else { echo "\n"; } if (!isset($_GET['date']) || $_GET['date']=="") { $result = mysql_db_query("$db_name","select $sentitems from sentitems order by SendingDateTime"); } else { $d = $_GET['date']; $result = mysql_db_query("$db_name","select $sentitems from sentitems where SendingDateTime like '$d%' group by ID order by ID"); } while($rekord = mysql_fetch_row($result)) { if (!isset($_GET['date']) || $_GET['date']=="") { if (isset($_GET['id']) && $_GET['id']!="" && $_GET['id'] == $rekord[11]) { echo "\n"; } else { echo "\n"; } } else { if (isset($_GET['id']) && $_GET['id']!="" && $_GET['id'] == $rekord[11]) { echo "\n"; } else { echo "\n"; } } echo "\n"; echo "\n"; $d2 = dispdatetime($rekord[0]); echo "\n"; echo "\n"; if (!isset($_GET['date']) || $_GET['date']=="") { echo ""; } else { echo ""; } echo "\n"; $sentnum++; if (isset($_GET['id']) && $_GET['id']!="" && $_GET['id'] == $rekord[11]) { $op = $_GET['op']; $id = $_GET['id']; echo "
IDTOSMSCUPDATEDPHONE[X]
$rekord[11] [<<]
$rekord[11] [>>]
$rekord[11] [<<]
$rekord[11] [>>]$rekord[5]$rekord[8]$d2$rekord[12][X]
[X]
"; for ($i = 1; $i <= 10; $i++) { $result2 = mysql_db_query("$db_name","select $sentitems from sentitems where ID='$id' and SequencePosition='$i' limit 1"); if ($result2 == null) break; while($rekord2 = mysql_fetch_row($result2)) { if (!$i == 1) echo "
"; echo "Validity: "; dispvalidity($rekord2[17]); echo "
\n"; dispsmsinfo($rekord2[9],$rekord2[7],$rekord2[4],$rekord2[10],$rekord2[6]); } mysql_free_result($result2); } echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; $result2 = mysql_db_query("$db_name","select $sentitems from sentitems where ID='$id'"); while($rekord2 = mysql_fetch_row($result2)) { echo "\n"; echo "\n"; echo ""; $d2 = dispdatetime($rekord2[2]); echo "\n"; if ($rekord2[3] != "00000000000000") { $d2 = dispdatetime($rekord2[3]); echo "\n"; } else { echo "\n"; } } mysql_free_result($result2); echo "
PARTERROR CODESTATUSSENDING TIMEDELIVERY TIME
$rekord2[13]$rekord2[15]$rekord2[14]$d2$d2
not set
\n"; } } mysql_free_result($result); echo "
"; echo "
$sentnum SMS sequences sent"; } if ($_GET['op']=="newsms") { $result2 = mysql_db_query("$db_name","select now()+0;"); $rekord2 = mysql_fetch_row($result2); $fulldt = $rekord2[0]; mysql_free_result($result2); $rok="$fulldt[0]$fulldt[1]$fulldt[2]$fulldt[3]"; $miesiac="$fulldt[4]$fulldt[5]"; $dzionek="$fulldt[6]$fulldt[7]"; $godzina="$fulldt[8]$fulldt[9]"; $minuta="$fulldt[10]$fulldt[11]"; $sekunda="$fulldt[12]$fulldt[13]"; echo "DATABASE $db_name, NEW OUTBOX SMS

\n"; echo "

\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo ""; echo "\n"; echo ""; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
Recipient (eg. +48xxxxxxxxx)
Sending date (year-month-day)\n"; echo " - \n"; echo " -
Sending time (hour:minute:second)\n"; echo " : \n"; echo " :
Validity
Delivery Report
Sending phone
Send class 0 SMS
\n"; echo "
Chars left in current SMS
SMS number / $max_limit
\n"; echo ""; echo "
 
\n"; } if ($_GET['op']=="daemons") { echo "DATABASE $db_name, DAEMONS

\n"; echo ""; echo "\n"; echo "\n"; $result = mysql_db_query("$db_name","select $daemons from daemons"); while($rekord = mysql_fetch_row($result)) { echo "\n"; $x = urlencode($rekord[0]); echo ""; } mysql_free_result($result); echo "
INFO
$rekord[1][X]
"; echo ""; echo "
 
\n"; } if ($_GET['op']=="phones") { $counter = 0; echo "DATABASE $db_name, PHONES

\n"; echo ""; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; $result = mysql_db_query("$db_name","select $phones from phones where TimeOut>NOW()"); while($rekord = mysql_fetch_row($result)) { $counter++; echo "\n"; echo "\n"; echo "\n"; echo "\n"; $d2 = dispdatetime($rekord[1]); echo "\n"; echo "\n"; } mysql_free_result($result); echo "
IMEIIDSEND SMSRECEIVE SMSLOGGEDCLIENT
$rekord[5]$rekord[0]$rekord[3]$rekord[4]$d2$rekord[6]
"; echo "
$counter phones

"; echo ""; echo "
 
\n"; } } else { echo ""; echo "
 
\n"; } echo "

\n"; echo "\n"; echo "SMS Gateway example version 0.0.3 (c) 2004 by Michal Kruger & Marcin Wiacek. Part of Gammu project

\n"; echo "This PC - IP ".$HTTP_SERVER_VARS['REMOTE_ADDR'].":".$HTTP_SERVER_VARS['REMOTE_PORT']; //." (".gethostbyaddr($HTTP_SERVER_VARS['REMOTE_ADDR']). echo ", ".$HTTP_SERVER_VARS['HTTP_USER_AGENT']."
\n"; echo "WWW server - IP ".$HTTP_SERVER_VARS['HTTP_HOST'].":".$HTTP_SERVER_VARS['SERVER_PORT']; //echo " (".gethostbyaddr($HTTP_SERVER_VARS['HTTP_HOST'])."), \n"; echo ", ".$HTTP_SERVER_VARS['SERVER_SOFTWARE'].", MySQL client ",mysql_get_client_info(),"
\n"; echo "MySQL server - IP $db_serv, ",mysql_get_server_info(),"
\n"; echo "
\n"; echo "
"; ?>