10 /************************************************************/
11 // show the opengatem usage log in the web page.
12 // the query condition is acquired from the html input from.
13 // default is as follows: any user, any device, last 3 days
14 // database connecttion parameters might be modified.
15 // As this script should be used only by the administrators,
16 // it should be protected by some access control method.
17 /************************************************************/
21 $now=date('Y-m-d H:i:s');
22 $fromTime=date('Y-m-d H:i:s', strtotime($now." -3 day"));
26 if(isset($_GET['userId']))$userId=$_GET['userId'];
27 if(isset($_GET['device']))$device=$_GET['device'];
28 if(isset($_GET['fromTime']))$fromTime=$_GET['fromTime'];
29 if(isset($_GET['toTime']))$toTime=$_GET['toTime'];
31 // show html table for query parameters
33 print("<form method=GET action=showlog.php");
34 print("<tr><td>UserId</td><td><input size=30 type=text name=userId value='".$userId."'></td></tr>");
35 print("<tr><td>Device</td><td><input size=30 type=text name=device value='".$device."'></td></tr>");
36 print("<tr><td>FromTime</td><td><input size=30 type=text name=fromTime value='".$fromTime."'></td></tr>");
37 print("<tr><td>ToTime</td><td><input size=30 type=text name=toTime value='".$toTime."'></td></tr>");
38 print("<tr><td></td><td><input type=submit value='send'></td></tr>");
39 print("</table></p>");
41 // connect and access to MySql db
42 $link = mysqli_connect('localhost', 'root', '');
43 if (!$link) die('Cannot connet to DB'.mysqli_error());
45 $db_selected = mysqli_select_db($link, 'opengatem');
46 if (!$db_selected) die('Cannot select DB'.mysqli_error());
48 mysqli_set_charset($link, 'utf8');
50 $result = mysqli_query($link, 'SELECT * FROM sessionview where userId like "'.$userId.'" and device like "'.$device.'" and "'.$fromTime.'"<openTime and openTime<"'.$toTime.'"');
52 if (!$result) die('Fail query'.mysqli_error());
55 print("<table border=1>");
58 while ($field = mysqli_fetch_field($result)) {
59 print('<td>'.$field->name.'</td>');
65 while ($row = mysqli_fetch_row($result)) {
67 for($i=0; $i<$count; $i++){
68 print('<td>'.$row[$i].'</td>');
74 $close_flag = mysqli_close($link);