1<?php 2# CONFIGURATION 3//they can be defined or not. if not, interface will give login form 4//$db_serv="127.0.0.1"; 5//$db_user="root"; 6//$db_pass=""; 7//$db_name="smsd" 8 9//these must be defined 10$dokument="admin.php"; //name of current document 11$delall = true; //should be Delete All available for folders ? 12$max_limit=1; //maximum number of sms for outgoing sms editor 13 14############################# 15## DO NOT CHANGE BELOW !!! ## 16############################# 17 18$inbox="UpdatedInDB,ReceivingDateTime,Text,SenderNumber,Coding,UDH,SMSCNumber,Class,TextDecoded,ID,RecipientID"; 19$outbox="UpdatedInDB,InsertIntoDB,Text,DestinationNumber,Coding,UDH,Class,TextDecoded,ID,MultiPart,RelativeValidity,SendingDateTime,SenderID,SendingTimeOut,DeliveryReport"; 20$outbox_multipart="Text,Coding,UDH,Class,TextDecoded,ID,SequencePosition"; 21$sentitems="UpdatedInDB,InsertIntoDB,SendingDateTime,DeliveryDateTime,Text,DestinationNumber,Coding,UDH,SMSCNumber,Class,TextDecoded,ID,SenderID,SequencePosition,Status,StatusError,TPMR,RelativeValidity"; 22$phones="ID,InsertIntoDB,TimeOut,Send,Receive,IMEI,Client,Battery,Signal"; 23$daemons="Start,Info"; 24 25function dispdatetime($dt) 26{ 27 return "$dt[0]$dt[1]$dt[2]$dt[3]-$dt[5]$dt[6]-$dt[8]$dt[9] $dt[11]$dt[12]:$dt[14]$dt[15]:$dt[17]$dt[18]"; 28} 29function dispdate($dt) 30{ 31 return "$dt[0]$dt[1]$dt[2]$dt[3]-$dt[5]$dt[6]-$dt[8]$dt[9]"; 32} 33function dispsmsinfo($class,$udh,$text,$textdecoded,$coding) 34{ 35 if (!$udh == "") { 36 echo "UDH AVAILABLE<br>\n"; 37 } 38 if ($class == "0" || $class == "1" || $class == "2" || $class == "3") { 39 echo "Class: $class<br>\n"; 40 } 41 if ($coding == "8bit") { 42 echo "BINARY<br>\n"; 43 } else { 44 if (!$text == "") echo "<b>"; 45 if ($coding == "Unicode_No_Compression" || $coding == "Unicode_Compression") { 46 echo "Unicode t"; 47 } else { 48 echo "T"; 49 } 50 if ($textdecoded == "") { 51 echo "ext</b><br>\n"; 52 } else { 53 echo "ext</b>: $textdecoded<br>\n"; 54 } 55 if ($text == "") echo "</b>"; 56 echo "<br>\n"; 57 } 58} 59function dispvalidity($validity) { 60 if ($validity == -1) { 61 echo "default"; 62 } else if ($validity == 0) { 63 echo "5 minutes"; 64 } else if ($validity == 255) { 65 echo "max. time"; 66 } else { 67 echo "$validity"; 68 } 69} 70 71$arg=""; 72if (!isset($db_serv) && isset($_GET['serv'])) { 73 $db_serv = $_GET['serv']; 74 if ($arg == "") {$arg="?";} else {$arg=$arg."&";}; 75 $arg = $arg . "serv=$db_serv"; 76 $dbservorig=false; 77} 78if (!isset($db_user) && isset($_GET['user'])) { 79 $db_user = $_GET['user']; 80 if ($arg == "") {$arg="?";} else {$arg=$arg."&";}; 81 $arg = $arg . "user=$db_user"; 82 $dbuserorig=false; 83} 84if (!isset($db_pass) && isset($_GET['pass'])) { 85 $db_pass = $_GET['pass']; 86 if ($arg == "") {$arg="?";} else {$arg=$arg."&";}; 87 $arg = $arg . "pass=$db_pass"; 88 $dbpassorig=false; 89} 90if ($arg == "") {$arg="?";} else {$arg=$arg."&";}; 91 92if (!isset($db_name) && isset($_GET['db'])) { 93 $db_name = $_GET['db']; 94} 95 96if (isset($db_pass) && isset($db_user) && isset($db_serv)) { 97 $dbpass = @mysql_connect("$db_serv","$db_user","$db_pass"); 98 if ($dbpass) { 99 mysql_query("SET NAMES UTF8;"); 100 if (isset($db_name)) { 101 $dbconnect = mysql_select_db("$db_name"); 102 } 103 } 104} 105 106if (isset($dbpass) && isset($dbconnect) && isset($_GET['op']) && 107 isset($_GET['year']) && isset($_GET['month']) && isset($_GET['day']) && 108 isset($_GET['hour']) && isset($_GET['minute']) && isset($_GET['second']) && 109 isset($_GET['number']) && isset($_GET['tresc']) && isset($_GET['validity']) && 110 isset($_GET['report']) && isset($_GET['phone'])) 111{ 112 if ($_GET['op']=="addsms") { 113 $year = $_GET['year']; 114 $month = $_GET['month']; 115 $day = $_GET['day']; 116 $hour = $_GET['hour']; 117 $minute = $_GET['minute']; 118 $second = $_GET['second']; 119 $datoom="$year$month$day$hour$minute$second"; 120 $number=$_GET['number']; 121 $tresc=$_GET['tresc']; 122 $validity=$_GET['validity']; 123 if (isset($_GET['class'])) { 124 $class = $_GET['class']; 125 } else { 126 $class = "-1"; 127 } 128 $phone = $_GET['phone']; 129 $report = $_GET['report']; 130 if (strlen($tresc) > 160) { 131// $result2 = mysql_db_query("$db_name","select ID from outbox order by ID desc limit 1"); 132// $rekord2 = mysql_fetch_row($result2); 133// if ($rekord == null) { 134// $newid = 0; 135// } else { 136// $newid = $rekord2[0]; 137// } 138// mysql_free_result($result2); 139// $pos = 0; 140// $text = ""; 141 } else { 142 if ($report == "yes") { 143 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')"); 144 } 145 if ($report == "no") { 146 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')"); 147 } 148 if ($report == "default") { 149 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')"); 150 } 151 } 152 } 153} 154 155if (isset($dbpass) && isset($dbconnect) && isset($_GET['op']) && isset($_GET['dzial'])) { 156 if ($_GET['op']=="del") { 157 if (isset($_GET['id'])) { 158 $dzial = $_GET['dzial']; 159 $id = $_GET['id']; 160 mysql_query ("delete from $dzial where id='$id'"); 161 if ($dzial == "outbox") { 162 mysql_query ("delete from outbox_multipart where id='$id'"); 163 } 164 } else if ($delall) { 165 $dzial = $_GET['dzial']; 166 mysql_query ("delete from $dzial"); 167 if ($dzial == "outbox") { 168 mysql_query ("delete from outbox_multipart"); 169 } 170 } 171 } 172 $_GET['op']=$dzial; 173} 174 175echo "<HTML>\n<HEAD>\n"; 176echo " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />"; 177 178echo "<STYLE TYPE=text/css>\n"; 179echo "<!--\n"; 180echo "BODY {text-decoration: none; color: #404040; font-family: verdana, arial; font-weight: normal; font-size: 10px; margin-left: 0pt; margin-right: 0pt; margin-top: 0pt; margin-bottom: 0pt}\n"; 181echo "input,select,option {text-decoration: none; color: #404040; font-family: verdana, arial; font-weight: normal; font-size: 10px;}\n"; 182echo "TD,P,BR {text-decoration: none; color: #404040; font-family: verdana, arial; font-weight: normal; font-size: 10px;}\n"; 183echo "B {text-decoration: none; font-family: verdana, arial; font-weight: bold; font-size: 10px;}\n"; 184echo "LI {text-decoration: none; color: #404040; font-family: verdana, arial; font-weight: normal; font-size: 10px;}\n"; 185echo "A:link {text-decoration: none; color: navy; font-family: verdana, arial; font-weight: normal; font-variant: small-caps; font-size: 10px;}\n"; 186echo "A:visited {text-decoration: none; color: navy; font-family: verdana, arial; font-weight: normal; font-variant: small-caps; font-size: 10px;}\n"; 187echo "A:active {text-decoration: none; color: navy; font-family: verdana, arial; font-weight: normal; font-variant: small-caps; font-size: 10px;}\n"; 188echo "A:hover {text-decoration: none; color: red; font-family: verdana, arial; font-weight: normal; font-variant: small-caps; font-size: 10px;}\n"; 189echo "-->\n"; 190echo "</STYLE>\n"; 191echo "<TITLE>SMS SERVER based on GAMMU</TITLE>\n<body bgcolor=#ededed>\n"; 192 193if (isset($dbpass) && isset($dbconnect) && isset($_GET['op']) && isset($_GET['action'])) { 194 if ($_GET['op']=="daemons") { 195 $action = urldecode($_GET['action']); 196 popen ($action, "r"); 197 } 198} 199 200if (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'])) { 201 if ($_GET['op']=="addsms") { 202 echo "<script>"; 203 echo "document.location.href='$dokument$arg"."db=$db_name&op=outbox';"; 204 echo "</script>"; 205 } 206} 207 208if (!isset($dbpass)) { 209 echo "<b>LOGIN</b><p>\n"; 210 echo "<form method=\"GET\" action=$dokument name=login>\n<table>\n"; 211 echo "<tr><td>Server address:port :</td><td><input name=serv maxlength=20></td></tr>\n"; 212 echo "<tr><td>Name :</td><td><input name=user maxlength=20></td></tr>\n"; 213 echo "<tr><td>Password :</td><td><input name=pass maxlength=20></td></tr>\n"; 214 echo "<tr><td colspan=2><input type=submit name=send value=SEND OnClick=\"if (login.db_serv.value=='') {alert('Sender number not filled'); return false;} else return true;\"></td></tr></table></form>\n"; 215 exit; 216} 217if (!$dbpass) { 218 echo " <p><center>Authorization error with MySQL server\n"; 219 220 if (isset($dbservorig) || isset($dbuserorig) || isset($dbpassorig)) { 221 echo "<p><a href=ala OnClick=\"history.back(); return false;\">Back to login form</a>"; 222 } 223 224 echo "</center></body>\n</html>"; 225 exit; 226} 227if (isset($dbconnect) && !$dbconnect) { 228 echo " <p><center>No database in MySQL server</center>\n</body>\n</html>"; 229 exit; 230} 231 232echo "<script language=JavaScript>\n"; 233echo "function Del(ID) {\n"; 234echo " return confirm(\"Do you want to delete SMS with ID \"+ID+\" ?\");\n"; 235echo "}\n"; 236if ($delall) { 237 echo "function DelAll(ID) {\n"; 238 echo " if (confirm(\"Do you want to delete all SMS from \"+ID+\" ?\")) {\n"; 239 echo " if (confirm(\"REALLY ?\")) {\n"; 240 echo " return true;\n"; 241 echo " }\n"; 242 echo " }\n"; 243 echo " return false;\n"; 244 echo "}\n"; 245 echo "function update() {\n"; 246 if ($max_limit == 1) { 247 echo " if (document.newsms.tresc.value.length > 160) {\n"; 248 echo " document.newsms.tresc.value = document.newsms.tresc.value.substring(0, 160);"; 249 } else { 250 echo " if (document.newsms.tresc.value.length > ". 153*$max_limit .") {\n"; 251 echo " document.newsms.tresc.value = document.newsms.tresc.value.substring(0, ". 153*$max_limit .");"; 252 } 253 echo " \n }\nif (document.newsms.tresc.value.length > 160) {\n"; 254 echo " document.newsms.smsnum.value = Math.ceil(document.newsms.tresc.value.length/153);\n"; 255 echo " document.newsms.left.value = document.newsms.smsnum.value*153 - document.newsms.tresc.value.length;\n"; 256 echo " } else {\n"; 257 echo " document.newsms.smsnum.value = 1;\n"; 258 echo " document.newsms.left.value = 160 - document.newsms.tresc.value.length;\n"; 259 echo " }\n"; 260 echo "}\n"; 261} 262echo "</script>\n"; 263echo "<table width = 100% cellspacing=1 cellpadding=5 border=0 bgcolor=silver>\n"; 264echo "<tr>\n<td colspan=2 bgcolor=red>\n"; 265echo "<b><font color=white size=2 face=verdana>SMS Gateway example, user $db_user</font></b>"; 266echo "</td>\n</tr>\n<tr>\n<td bgcolor=whitesmoke valign=top>"; 267 268#MENU 269 270if (isset($dbservorig) || isset($dbuserorig) || isset($dbpassorig)) { 271 echo "<nobr><a href=$dokument>OTHER USER</a></nobr><br>\n"; 272} 273 274$result0 = mysql_list_dbs($dbpass); 275while ($row0 = mysql_fetch_object($result0)) { 276 $result = mysql_db_query("$row0->Database","select Version from gammu"); 277 $rekord = @mysql_fetch_row($result); 278 if (!$rekord) continue; 279 mysql_free_result($result); 280 if ($rekord[0]!='7') continue; 281 282 $result2 = @mysql_list_tables($row0->Database); 283 if (!$result2) continue; 284 $found = false; 285 while ($row2 = mysql_fetch_row($result2)) { 286 if ($row2[0] == "inbox") $found = true; 287 if ($row2[0] == "outbox") $found = true; 288 if ($row2[0] == "outbox_multipart") $found = true; 289 if ($row2[0] == "sentitems") $found = true; 290 } 291 mysql_free_result($result2); 292 if (!$found) continue; 293 if (!isset($_GET['db']) || $_GET['db']!=$row0->Database) { 294 echo "<a href=$dokument$arg"."db=$row0->Database>[>>] $row0->Database</a><br>\n"; 295 continue; 296 } 297 echo "<a href=$dokument$arg"."x=x>[<<] $row0->Database</a><br>\n"; 298 299 echo "  <a href=$dokument$arg"."db=$row0->Database&op=daemons>DAEMONS</a><br>\n"; 300 echo "  <a href=$dokument$arg"."db=$row0->Database&op=phones>PHONES</a><p>\n"; 301 302 echo "<nobr>  <a href=$dokument$arg"."db=$row0->Database&op=newsms>NEW OUTBOX SMS</a></nobr><br><br>\n"; 303 304 echo "  <a href=$dokument$arg"."db=$row0->Database&op=inbox>INBOX</a><br>\n"; 305 if (isset($_GET['op']) && $_GET['op']=="inbox") { 306 $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"); 307 while($rekord = mysql_fetch_row($result)) { 308 $d = dispdate($rekord[0]); 309 echo "     · <a href=$dokument$arg"."db=$row0->Database&op=inbox&date=$rekord[0]>$d</a><br>"; 310 } 311 mysql_free_result($result); 312 } 313 314 echo "  <a href=$dokument$arg"."db=$row0->Database&op=outbox>OUTBOX</a><br>\n"; 315 if (isset($_GET['op']) && $_GET['op']=="outbox") { 316 $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"); 317 while($rekord = mysql_fetch_row($result)) { 318 $d = dispdate($rekord[0]); 319 echo "     · <a href=$dokument$arg"."db=$row0->Database&op=outbox&date=$rekord[0]>$d</a><br>"; 320 } 321 mysql_free_result($result); 322 } 323 324 echo "  <a href=$dokument$arg"."db=$row0->Database&op=sentitems>SENT ITEMS</a><br>\n"; 325 if (isset($_GET['op']) && $_GET['op']=="sentitems") { 326 $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"); 327 while($rekord = mysql_fetch_row($result)) { 328 $d = dispdate($rekord[18]); 329 echo "     · <a href=$dokument$arg"."db=$row0->Database&op=sentitems&date=$rekord[18]>$d</a><br>"; 330 } 331 mysql_free_result($result); 332 } 333} 334mysql_free_result($result0); 335 336# /MENU 337 338echo "</td>\n<td bgcolor=whitesmoke valign=top>\n"; 339 340#TRESC 341 342if (isset($_GET['op'])) { 343 if ($_GET['op']=="inbox") { 344 $innum = 0; 345 echo "<b>DATABASE $db_name, INBOX"; 346 if (isset($_GET['date']) && $_GET['date']!="") { 347 $d = $_GET['date']; 348 $d2 = dispdate($d); 349 echo " $d2"; 350 } 351 echo "</b><br><br>\n"; 352 echo "<table width=620 cellspacing=1 border=1>"; 353 echo "<tr bgcolor=gold><td>ID</td>\n"; 354 echo "<td>FROM</td>\n"; 355 echo "<td>SMSC</td>\n"; 356 echo "<td>CLASS</td>\n"; 357 echo "<td>RECEIVE TIME</td>\n"; 358 echo "<td>PHONE</td>\n"; 359 if ($delall) { 360 echo "<td><a href=$dokument$arg"."db=$db_name&op=del&dzial=inbox Title='Click to delete all SMS' OnClick=\"return DelAll('Inbox');\">[X]</td></tr>\n"; 361 } else { 362 echo "<td></td></tr>\n"; 363 } 364 if (!isset($_GET['date']) || $_GET['date']=="") { 365 $result = mysql_db_query("$db_name","select $inbox from inbox order by ReceivingDateTime desc"); 366 } else { 367 $d = $_GET['date']; 368 $result = mysql_db_query("$db_name","select $inbox from inbox where ReceivingDateTime like '$d%' order by ReceivingDateTime desc"); 369 } 370 while($rekord = mysql_fetch_row($result)) { 371 $innum++; 372 if (!isset($_GET['date']) || $_GET['date']=="") { 373 if (isset($_GET['id']) && $_GET['id']!="" && $_GET['id'] == $rekord[9]) { 374 echo "<tr><td>$rekord[9] <a href=$dokument$arg"."db=$db_name&op=inbox title='Click to hide details'>[<<]</a></td>"; 375 } else { 376 echo "<tr><td>$rekord[9] <a href=$dokument$arg"."db=$db_name&op=inbox&id=$rekord[9] title='Click to display details'>[>>]</a></td>"; 377 } 378 } else { 379 if (isset($_GET['id']) && $_GET['id']!="" && $_GET['id'] == $rekord[9]) { 380 echo "<tr><td>$rekord[9] <a href=$dokument$arg"."db=$db_name&op=inbox&date=$d title='Click to hide details'>[<<]</a></td>"; 381 } else { 382 echo "<tr><td>$rekord[9] <a href=$dokument$arg"."db=$db_name&op=inbox&date=$d&id=$rekord[9] title='Click to display details'>[>>]</a></td>"; 383 } 384 } 385 echo "<td>$rekord[3]</td><td>$rekord[6]</td>"; 386 if ($rekord[7] == "-1") { 387 echo "<td>not set</td>"; 388 } else { 389 echo "<td>$rekord[7]</td>"; 390 } 391 $d2 = dispdatetime($rekord[1]); 392 echo "<td>$d2</td>"; 393 echo "<td>$rekord[10]</td>"; 394 if (!isset($_GET['date']) || $_GET['date']=="") { 395 echo "<td><a href=$dokument$arg"."db=$db_name&op=del&dzial=inbox&id=$rekord[9] OnClick=\"return Del($rekord[9]);\" Title='Click to delete'>[X]</a></td></tr>"; 396 } else { 397 echo "<td><a href=$dokument$arg"."db=$db_name&op=del&dzial=inbox&date=$d&id=$rekord[9] OnClick=\"return Del($rekord[9]);\" Title='Click to delete'>[X]</a></td></tr>"; 398 } 399 if (isset($_GET['id']) && $_GET['id']!="" && $_GET['id'] == $rekord[9]) { 400 $op = $_GET['op']; 401 $id = $_GET['id']; 402 echo "</tr><tr><td colspan=7 bgcolor=white>"; 403 $d2 = dispdatetime($rekord[0]); 404 echo "Last changed in DB: $d2<br>"; 405 $d2 = dispdatetime($rekord[1]); 406 echo "Insert into DB: $d2<br>"; 407 dispsmsinfo($rekord[7],$rekord[5],$rekord[2],$rekord[8],$rekord[4]); 408 echo "</td></tr>\n"; 409 } 410 } 411 mysql_free_result($result); 412 echo "</table>"; 413 echo "<br>$innum SMS received"; 414 } 415 if ($_GET['op']=="outbox") { 416 $outduring = 0; 417 $outfuture = 0; 418 echo "<b>DATABASE $db_name, OUTBOX"; 419 if (isset($_GET['date']) && $_GET['date']!="") { 420 $d = $_GET['date']; 421 $d2 = dispdate($d); 422 echo " $d2"; 423 } 424 echo "</b><br><br>\n"; 425 echo "<table width=620 cellspacing=1 border=1>"; 426 echo "<tr bgcolor=gold><td>ID</td>\n"; 427 echo "<td>TO</td>\n"; 428 echo "<td>TIME 2BE SENT</td>\n"; 429 echo "<td>PARTS</td>\n"; 430 echo "<td>VALIDITY</td>\n"; 431 echo "<td>SENDING</td>\n"; 432 echo "<td>PHONE</td>\n"; 433 echo "<td>REPORT</td>\n"; 434 if ($delall) { 435 echo "<td><a href=$dokument$arg"."db=$db_name&op=del&dzial=outbox Title='Click to delete all SMS' OnClick=\"return DelAll('Outbox');\">[X]</td></tr>\n"; 436 } else { 437 echo "<td></td></tr>\n"; 438 } 439 if (!isset($_GET['date']) || $_GET['date']=="") { 440 $result = mysql_db_query("$db_name","select $outbox from outbox order by SendingDateTime desc"); 441 } else { 442 $d = $_GET['date']; 443 $result = mysql_db_query("$db_name","select $outbox from outbox where SendingDateTime like '$d%' order by SendingDateTime desc"); 444 } 445 while($rekord = mysql_fetch_row($result)) { 446 if (!isset($_GET['date']) || $_GET['date']=="") { 447 if (isset($_GET['id']) && $_GET['id']!="" && $_GET['id'] == $rekord[8]) { 448 echo "<tr><td>$rekord[8] <a href=$dokument$arg"."db=$db_name&op=outbox title='Click to hide details'>[<<]</a></td>"; 449 } else { 450 echo "<tr><td>$rekord[8] <a href=$dokument$arg"."db=$db_name&op=outbox&id=$rekord[8] title='Click to display details'>[>>]</a></td>"; 451 } 452 } else { 453 if (isset($_GET['id']) && $_GET['id']!="" && $_GET['id'] == $rekord[8]) { 454 echo "<tr><td>$rekord[8] <a href=$dokument$arg"."db=$db_name&op=outbox&date=$d title='Click to hide details'>[<<]</a></td>"; 455 } else { 456 echo "<tr><td>$rekord[8] <a href=$dokument$arg"."db=$db_name&op=outbox&date=$d&id=$rekord[8] title='Click to display details'>[>>]</a></td>"; 457 } 458 } 459 echo "<td>$rekord[3]</td>"; 460 $d2 = dispdatetime($rekord[11]); 461 echo "<td>$d2</td>"; 462 $counter = 1; 463 if ($rekord[9] == "true") { 464 $result2 = mysql_db_query("$db_name","select $outbox_multipart from outbox_multipart where id='$rekord[8]'"); 465 while($rekord2 = mysql_fetch_row($result2)) $counter++; 466 mysql_free_result($result2); 467 } 468 echo "<td>$counter</td><td>"; 469 dispvalidity($rekord[10]); 470 if ($rekord[13] != "00000000000000") { 471 $result2 = mysql_db_query("$db_name","select now()+0;"); 472 $rekord2 = mysql_fetch_row($result2); 473 if ($rekord[13]<$rekord2[0]) { 474 echo "</td><td>no (earlier failed)</td><td>"; 475 $outfuture++; 476 } else { 477 echo "</td><td>yes (now)</td><td>"; 478 $outduring++; 479 } 480 mysql_free_result($result2); 481 } else { 482 echo "</td><td>no (earlier not tried)</td><td>"; 483 $outfuture++; 484 } 485 if ($rekord[12] == "") { 486 echo "<< any >>"; 487 } else { 488 echo "$rekord[12]"; 489 } 490 echo "</td><td>$rekord[14]</td><td>"; 491 if (!isset($_GET['date']) || $_GET['date']=="") { 492 echo "<a href=$dokument$arg"."db=$db_name&op=del&dzial=outbox&id=$rekord[8] Title='Click to delete' OnClick=\"return Del($rekord[8]);\" >[X]</a></td></tr>"; 493 } else { 494 echo "<a href=$dokument$arg"."db=$db_name&op=del&dzial=outbox&date=$d&id=$rekord[8] Title='Click to delete' OnClick=\"return Del($rekord[8]);\" >[X]</a></td></tr>"; 495 } 496 497 if (isset($_GET['id']) && $_GET['id']!="" && $_GET['id'] == $rekord[8]) { 498 $op = $_GET['op']; 499 $id = $_GET['id']; 500 echo "</tr><tr><td colspan=9 bgcolor=white>"; 501 $result2 = mysql_db_query("$db_name","select $outbox from outbox where ID='$id'"); 502 while($rekord2 = mysql_fetch_row($result2)) { 503 $d2 = dispdatetime($rekord2[0]); 504 echo "Last changed in DB: $d2<br>"; 505 $d2 = dispdatetime($rekord2[1]); 506 echo "Insert into DB: $d2<br>"; 507 if ($rekord2[9] == "true") { 508 echo "<hr size=1 color=silver>"; 509 } 510 dispsmsinfo($rekord2[6],$rekord2[5],$rekord2[2],$rekord2[7],$rekord2[4]); 511 if ($rekord[9] == "true") { 512 $result3 = mysql_db_query("$db_name","select $outbox_multipart from outbox_multipart where id='$rekord[8]'"); 513 while($rekord3 = mysql_fetch_row($result3)) { 514 echo "<hr size=1 color=silver>"; 515 dispsmsinfo($rekord3[3],$rekord3[2],$rekord3[0],$rekord3[4],$rekord3[1]); 516 } 517 mysql_free_result($result3); 518 } 519 } 520 mysql_free_result($result2); 521 echo "</td></tr>\n"; 522 } 523 } 524 mysql_free_result($result); 525 echo "</table>"; 526 echo "<br>$outduring SMS sequences during sending, $outfuture SMS sequences waiting for sending"; 527 } 528 if ($_GET['op']=="sentitems") { 529 $sentnum = 0; 530 echo "<b>DATABASE $db_name, SENT ITEMS"; 531 if (isset($_GET['date']) && $_GET['date']!="") { 532 $d = $_GET['date']; 533 $d2 = dispdate($d); 534 echo " $d2"; 535 } 536 echo "</b><br><br>\n"; 537 echo "<table width=620 cellspacing=1 border=1>"; 538 echo "<tr bgcolor=gold><td>ID</td>\n"; 539 echo "<td>TO</td>\n"; 540 echo "<td>SMSC</td>\n"; 541 echo "<td>UPDATED</td>\n"; 542 echo "<td>PHONE</td>\n"; 543 if ($delall) { 544 echo "<td><a href=$dokument$arg"."db=$db_name&op=del&dzial=sentitems Title='Click to delete all SMS' OnClick=\"return DelAll('Sent Items');\">[X]</td></tr>\n"; 545 } else { 546 echo "<td></td></tr>\n"; 547 } 548 if (!isset($_GET['date']) || $_GET['date']=="") { 549 $result = mysql_db_query("$db_name","select $sentitems from sentitems order by SendingDateTime"); 550 } else { 551 $d = $_GET['date']; 552 $result = mysql_db_query("$db_name","select $sentitems from sentitems where SendingDateTime like '$d%' group by ID order by ID"); 553 } 554 while($rekord = mysql_fetch_row($result)) { 555 if (!isset($_GET['date']) || $_GET['date']=="") { 556 if (isset($_GET['id']) && $_GET['id']!="" && $_GET['id'] == $rekord[11]) { 557 echo "<tr><td>$rekord[11] <a href=$dokument$arg"."db=$db_name&op=sentitems title='Click to hide details'>[<<]</a></td>\n"; 558 } else { 559 echo "<tr><td>$rekord[11] <a href=$dokument$arg"."db=$db_name&op=sentitems&id=$rekord[11] title='Click to display details'>[>>]</a></td>\n"; 560 } 561 } else { 562 if (isset($_GET['id']) && $_GET['id']!="" && $_GET['id'] == $rekord[11]) { 563 echo "<tr><td>$rekord[11] <a href=$dokument$arg"."db=$db_name&op=sentitems&date=$d title='Click to hide details'>[<<]</a></td>\n"; 564 } else { 565 echo "<tr><td>$rekord[11] <a href=$dokument$arg"."db=$db_name&op=sentitems&date=$d&id=$rekord[11] title='Click to display details'>[>>]</a></td>\n"; 566 } 567 } 568 echo "<td>$rekord[5]</td>\n"; 569 echo "<td>$rekord[8]</td>\n"; 570 $d2 = dispdatetime($rekord[0]); 571 echo "<td>$d2</td>\n"; 572 echo "<td>$rekord[12]</td>\n"; 573 if (!isset($_GET['date']) || $_GET['date']=="") { 574 echo "<td><a href=$dokument$arg"."db=$db_name&op=del&dzial=sentitems&id=$rekord[11] Title='Click to delete' OnClick=\"return Del($rekord[11]);\" >[X]</a></td></tr>"; 575 } else { 576 echo "<td><a href=$dokument$arg"."db=$db_name&op=del&dzial=sentitems&date=$d&id=$rekord[11] Title='Click to delete' OnClick=\"return Del($rekord[11]);\" >[X]</a></td></tr>"; 577 } 578 echo "</tr>\n"; 579 $sentnum++; 580 if (isset($_GET['id']) && $_GET['id']!="" && $_GET['id'] == $rekord[11]) { 581 $op = $_GET['op']; 582 $id = $_GET['id']; 583 echo "</tr><tr><td colspan=6 bgcolor=white>"; 584 585 for ($i = 1; $i <= 10; $i++) { 586 $result2 = mysql_db_query("$db_name","select $sentitems from sentitems where ID='$id' and SequencePosition='$i' limit 1"); 587 if ($result2 == null) break; 588 while($rekord2 = mysql_fetch_row($result2)) { 589 if (!$i == 1) echo "<hr size=1 color=silver>"; 590 echo "Validity: "; 591 dispvalidity($rekord2[17]); 592 echo "<br>\n"; 593 dispsmsinfo($rekord2[9],$rekord2[7],$rekord2[4],$rekord2[10],$rekord2[6]); 594 } 595 mysql_free_result($result2); 596 } 597 598 echo "<table width=100%><tr bgcolor=silver>\n"; 599 echo "<td>PART</td>\n"; 600 echo "<td>ERROR CODE</td>\n"; 601 echo "<td>STATUS</td>\n"; 602 echo "<td>SENDING TIME</td>\n"; 603 echo "<td>DELIVERY TIME</td></tr>\n"; 604 605 $result2 = mysql_db_query("$db_name","select $sentitems from sentitems where ID='$id'"); 606 while($rekord2 = mysql_fetch_row($result2)) { 607 echo "<tr><td>$rekord2[13]</td>\n"; 608 echo "<td>$rekord2[15]</td>\n"; 609 echo "<td>$rekord2[14]</td>"; 610 $d2 = dispdatetime($rekord2[2]); 611 echo "<td>$d2</td>\n"; 612 if ($rekord2[3] != "00000000000000") { 613 $d2 = dispdatetime($rekord2[3]); 614 echo "<td>$d2</td></tr>\n"; 615 } else { 616 echo "<td>not set</td></tr>\n"; 617 } 618 } 619 mysql_free_result($result2); 620 621 echo "</td></tr></table>\n"; 622 } 623 } 624 mysql_free_result($result); 625 echo "</table>"; 626 echo "<br>$sentnum SMS sequences sent"; 627 } 628 if ($_GET['op']=="newsms") { 629 $result2 = mysql_db_query("$db_name","select now()+0;"); 630 $rekord2 = mysql_fetch_row($result2); 631 $fulldt = $rekord2[0]; 632 mysql_free_result($result2); 633 634 $rok="$fulldt[0]$fulldt[1]$fulldt[2]$fulldt[3]"; 635 $miesiac="$fulldt[4]$fulldt[5]"; 636 $dzionek="$fulldt[6]$fulldt[7]"; 637 $godzina="$fulldt[8]$fulldt[9]"; 638 $minuta="$fulldt[10]$fulldt[11]"; 639 $sekunda="$fulldt[12]$fulldt[13]"; 640 641 echo "<b>DATABASE $db_name, NEW OUTBOX SMS</b><p>\n"; 642 echo "<form method=\"GET\" action=$dokument name=newsms>\n"; 643 echo "<input type=hidden name=op value=addsms>\n"; 644 echo "<input type=hidden name=serv value=$db_serv>\n"; 645 echo "<input type=hidden name=user value=$db_user>\n"; 646 echo "<input type=hidden name=pass value=$db_pass>\n"; 647 echo "<input type=hidden name=db value=$db_name>\n"; 648 649 echo "<table><tr><td>Recipient (eg. +48xxxxxxxxx)</td>"; 650 echo "<td><input name=number maxlength=20></td></tr>\n"; 651 652 echo "<tr><td>Sending date (year-month-day)</td>"; 653 echo "<td><input name=year maxlength=4 value=\"$rok\" size=4>\n"; 654 echo " - <input name=month maxlength=2 value=\"$miesiac\" size=2>\n"; 655 echo " - <input name=day maxlength=2 value=\"$dzionek\" size=2></td></tr>\n"; 656 657 echo "<tr><td>Sending time (hour:minute:second)</td><td><input name=hour maxlength=2 value=\"$godzina\" size=2>\n"; 658 echo " : <input name=minute maxlength=2 value=\"$minuta\" size=2>\n"; 659 echo " : <input name=second maxlength=2 value=\"$sekunda\" size=2></td></tr>\n"; 660 661 echo "<tr><td>Validity</td><td><select name=validity>\n"; 662 echo "<option value=-1 select>Default (taken from sending phone)\n"; 663 echo "<option value=0>5 minutes\n"; 664 echo "<option value=1>10 minutes\n"; 665 echo "<option value=255>max. time (depends on SMSC)\n"; 666 echo "</select></td></tr><tr>\n"; 667 668 echo "<tr><td>Delivery Report</td><td><select name=report>\n"; 669 echo "<option value=default select>Default (depends on sending daemon)\n"; 670 echo "<option value=yes>yes\n"; 671 echo "<option value=no>no\n"; 672 echo "</select></td></tr><tr>\n"; 673 674 echo "<tr><td>Sending phone</td><td><select name=phone>\n"; 675 echo "<option value=\"\" select>any\n"; 676// echo "<option value=bzzz>ala\n"; 677 $result = mysql_db_query("$db_name","select $phones from phones where TimeOut>NOW() AND ID<>\"\""); 678 while($rekord = mysql_fetch_row($result)) { 679 echo "<option value=$rekord[0]>$rekord[5] / $rekord[0]\n"; 680 } 681 echo "</select></td></tr><tr>\n"; 682 683 echo "<td colspan=2><input type=checkbox name=class value=0>Send class 0 SMS</input><br>\n"; 684 685 echo "<textarea name=tresc cols=70 rows=5 onChange=\"update();\" onFocus=\"update();\" onKeyUp=\"update();\" onKeyDown=\"update();\" onclick=\"update();\"></textarea></td></tr>\n"; 686 687 echo "<tr><td colspan=2><input type=submit value=SEND OnClick=\"if (newsms.number.value=='') {alert('Sender number not filled'); return false;} else return true;\"></td></tr>\n"; 688 689 echo "<tr><td><b>Chars left in current SMS</b></td><td><input name=left maxlength=3 value=\"160\" size=3 readonly></td></tr>\n"; 690 691 echo "<tr><td><b>SMS number</b></td><td><input name=smsnum maxlength=3 value=\"1\" size=3 readonly> / $max_limit</td></tr>\n"; 692 693 echo "</table></form>\n"; 694 echo "<table width=620 cellspacing=1 border=0>"; 695 echo "<tr><td> </td></tr></table>\n"; 696 } 697 if ($_GET['op']=="daemons") { 698 echo "<b>DATABASE $db_name, DAEMONS</b><p>\n"; 699 700 echo "<table width=620 cellspacing=1 border=1>"; 701 echo "<tr bgcolor=gold><td>INFO</td>\n"; 702 echo "<td></td></tr>\n"; 703 $result = mysql_db_query("$db_name","select $daemons from daemons"); 704 while($rekord = mysql_fetch_row($result)) { 705 echo "<td>$rekord[1]</td>\n"; 706 $x = urlencode($rekord[0]); 707 echo "<td><a href=$dokument$arg"."db=$db_name&action=$x&op=daemons Title='Click to start' OnClick=\"return Del('ala');\" >[X]</a></td></tr>"; 708 } 709 mysql_free_result($result); 710 echo "</table>"; 711 712 echo "<table width=620 cellspacing=1 border=0>"; 713 echo "<tr><td> </td></tr></table>\n"; 714 } 715 if ($_GET['op']=="phones") { 716 $counter = 0; 717 echo "<b>DATABASE $db_name, PHONES</b><p>\n"; 718 echo "<table width=1024 cellspacing=1 border=1>"; 719 echo "<tr bgcolor=gold><td>IMEI</td>\n"; 720 echo "<td>ID</td>\n"; 721 echo "<td>SEND SMS</td>\n"; 722 echo "<td>RECEIVE SMS</td>\n"; 723 echo "<td>LOGGED</td>\n"; 724 echo "<td>CLIENT</td>\n"; 725 echo "<td>BATTERY</td>\n"; 726 echo "<td>SIGNAL</td></tr>\n"; 727 $result = mysql_db_query("$db_name","select $phones from phones where TimeOut>NOW()"); 728 while($rekord = mysql_fetch_row($result)) { 729 $counter++; 730 echo "<td>$rekord[5]</td>\n"; 731 echo "<td>$rekord[0]</td>\n"; 732 echo "<td>$rekord[3]</td>\n"; 733 echo "<td>$rekord[4]</td>\n"; 734 $d2 = dispdatetime($rekord[1]); 735 echo "<td>$d2</td>\n"; 736 echo "<td>$rekord[6]</td>\n"; 737 echo "<td>$rekord[7]</td>\n"; 738 echo "<td>$rekord[8]</td></tr>\n"; 739 } 740 mysql_free_result($result); 741 echo "</table>"; 742 echo "<br>$counter phones<p>"; 743 echo "<table width=620 cellspacing=1 border=0>"; 744 echo "<tr><td> </td></tr></table>\n"; 745 } 746} else { 747 echo "<table width=620 cellspacing=1 border=0>"; 748 echo "<tr><td> </td></tr></table>\n"; 749} 750 751echo "</td></tr>\n<tr>\n<td colspan=2 height=15 bgcolor=red align=center>\n"; 752echo "<b><font color=white size=2 face=verdana>\n"; 753echo "SMS Gateway example version 0.0.3 (c) 2004 by Michal Kruger & <a href=mailto:marcin@mwiacek.com>Marcin Wiacek</a>. Part of <a href=http://www.mwiacek.com>Gammu</a> project<br><hr width=100>\n"; 754echo "This PC - IP ".$HTTP_SERVER_VARS['REMOTE_ADDR'].":".$HTTP_SERVER_VARS['REMOTE_PORT']; 755//." (".gethostbyaddr($HTTP_SERVER_VARS['REMOTE_ADDR']). 756echo ", ".$HTTP_SERVER_VARS['HTTP_USER_AGENT']."<br>\n"; 757echo "WWW server - IP ".$HTTP_SERVER_VARS['HTTP_HOST'].":".$HTTP_SERVER_VARS['SERVER_PORT']; 758//echo " (".gethostbyaddr($HTTP_SERVER_VARS['HTTP_HOST'])."), \n"; 759echo ", ".$HTTP_SERVER_VARS['SERVER_SOFTWARE'].", MySQL client ",mysql_get_client_info(),"<br>\n"; 760echo "MySQL server - IP $db_serv, ",mysql_get_server_info(),"<br>\n"; 761echo "</font></b>\n"; 762echo "</td>\n</tr>\n</table>"; 763 764 765?> 766 767<br /> 768<?php 769#MENU 02 770 771$link = mysql_connect ($db_serv, $db_user, $db_pass); 772$result0 = mysql_list_dbs($link); 773$arg = '?'; 774 775 if (!isset($_GET['db']) || $_GET['db']!=$row0->Database) { 776 echo "<a href=$dokument$arg"."db=$row0->Database>[>>] $row0->Database</a><br>\n"; 777 778 } 779 echo "<a href=$dokument$arg"."x=x>[<<] $row0->Database</a><br>\n"; 780 781 echo "  <a href=$dokument$arg"."db=$row0->Database&op=daemons>DAEMONS</a><br>\n"; 782 echo "  <a href=$dokument$arg"."db=$row0->Database&op=phones>PHONES</a><p>\n"; 783 784 echo "<nobr>  <a href=$dokument$arg"."db=$row0->Database&op=newsms>NEW OUTBOX SMS</a></nobr><br><br>\n"; 785 786 echo "  <a href=$dokument$arg"."db=$row0->Database&op=inbox>INBOX</a><br>\n"; 787 if (isset($_GET['op']) && $_GET['op']=="inbox") { 788 $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"); 789 while($rekord = mysql_fetch_row($result)) { 790 $d = dispdate($rekord[0]); 791 echo "     · <a href=$dokument$arg"."db=$row0->Database&op=inbox&date=$rekord[0]>$d</a><br>"; 792 } 793 mysql_free_result($result); 794 } 795 796 echo "  <a href=$dokument$arg"."db=$row0->Database&op=outbox>OUTBOX</a><br>\n"; 797 if (isset($_GET['op']) && $_GET['op']=="outbox") { 798 $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"); 799 while($rekord = mysql_fetch_row($result)) { 800 $d = dispdate($rekord[0]); 801 echo "     · <a href=$dokument$arg"."db=$row0->Database&op=outbox&date=$rekord[0]>$d</a><br>"; 802 } 803 mysql_free_result($result); 804 } 805 806 echo "  <a href=$dokument$arg"."db=$row0->Database&op=sentitems>SENT ITEMS</a><br>\n"; 807 if (isset($_GET['op']) && $_GET['op']=="sentitems") { 808 $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"); 809 while($rekord = mysql_fetch_row($result)) { 810 $d = dispdate($rekord[18]); 811 echo "     · <a href=$dokument$arg"."db=$row0->Database&op=sentitems&date=$rekord[18]>$d</a><br>"; 812 } 813 mysql_free_result($result); 814 } 815 816mysql_free_result($result0); 817 818# /MENU 819 820 821?> 822