1<html>
2<head>
3</head>
4<body>
5<FORM ACTION=sms.php method="post">
6Search SMS-es by first entered chars:
7<INPUT NAME=Char SIZE=20>
8<INPUT TYPE=SUBMIT VALUE="Search"><br/><br/>
9</FORM>
10
11<?//this script was created by Michal Holes (michal@holes.sk)
12//under GNU GPL for showing of the received SMS-es by
13//great sms daemon GAMMU saved to standard MySQL database and table
14//created by script GAMMU
15
16function mysql_timestamp_to_human($dt) //mysql timestamp to human readable
17{
18	$yr=strval(substr($dt,0,4)); //year
19	$mo=strval(substr($dt,4,2)); //month
20	$da=strval(substr($dt,6,2)); //day
21	$hr=strval(substr($dt,8,2)); //hour
22	$mi=strval(substr($dt,10,2)); //minute
23	//$se=strval(substr($dt,12,2)); //sec
24
25        return date("d M Y H:i", mktime ($hr,$mi,0,$mo,$da,$yr)).""; //format of displayed date and time
26}
27
28mysql_connect("localhost", "sms", "sms") or die(mysql_error()); //connect to mysql
29mysql_select_db("sms") or die(mysql_error()); //select database
30if ($Char!="") //check if char was inserted
31    $If = "WHERE TextDecoded LIKE '".AddSlashes($Char)."%'"; //if yes, change variable
32else
33    $If = ""; //or do nothing
34
35$result = mysql_query("SELECT * FROM inbox $If ORDER BY ReceivingDateTime"); //select data with variable and order it by time and date of the reception
36
37echo "<table border=1>"; //begin creation of table
38echo "<tr> <th>Datum a cas </th><th>Tel. cislo</th> <th>Sprava</th> </tr>"; //header of the table
39while($row = mysql_fetch_array( $result )) { //create variable row
40	// Print out the contents of each row into a table
41
42	echo "<tr><td>"; //begin of row and cell
43	$d= $row['ReceivingDateTime']; //create variable for function at begin
44	echo mysql_timestamp_to_human($d); //paste normal date
45	echo "</td><td>";// end and begin of cell
46	echo $row['SenderNumber']; //show sender number
47	echo "</td><td>"; //end and begin of cell
48	echo $row['TextDecoded']; //show text of the message
49	echo "</td></tr>"; //end of the cell and row
50}
51echo "</table>"; //end of table
52
53?>
54<br><br><br>
55</body>
56</html>
57