Context-detection API for Android developed as a university project
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

portal.php 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?PHP
  2. if (!isset($_GET['imei']) || !ctype_digit($_GET['imei'])) {
  3. // TODO: Better error
  4. die('Invalid IMEI');
  5. }
  6. define('IMEI', $_GET['imei']);
  7. require_once('common.php');
  8. $sql = 'SELECT log_activity, log_id, log_statuscode FROM sensorlogger WHERE log_imei = \'' . m(IMEI) . '\'';
  9. $res = mysql_query($sql);
  10. echo '<?xml version="1.0"?>';
  11. ?>
  12. <html xmlns="http://www.w3.org/1999/xhtml">
  13. <head>
  14. <title>SensorLogger Results</title>
  15. <link rel="stylesheet" type="text/css" href="/style.css"/>
  16. <style type="text/css">
  17. .qr { float: left; clear: left; margin-right: 15px; }
  18. .qr img { width: 128px; }
  19. </style>
  20. </head>
  21. <body style="margin-top: 0; padding-top: 0;">
  22. <h1 style="background: url('android.png') no-repeat right; padding-top: 50px; margin-top: 0;">SensorLogger results for <span><?PHP echo IMEI; ?></span></h1>
  23. <div>
  24. <?PHP if (($num = mysql_num_rows($res)) == 0) { ?>
  25. <h2>Welcome</h2>
  26. <p>
  27. You do not appear to have submitted any data from the sensor logger application, yet.
  28. </p>
  29. <p>
  30. Why not <a href="/android/">download it</a> and give it a try, then check back soon!
  31. </p>
  32. <?PHP } else { ?>
  33. <h2>Thank you</h2>
  34. <p>
  35. You've submitted <strong><?PHP echo number_format($num); ?></strong>
  36. record<?PHP echo $num == 1 ? '' : 's'; ?> from the sensor logger application.
  37. </p>
  38. <?PHP
  39. $data = array();
  40. $codes = array();
  41. $rejects = 0;
  42. while ($row = mysql_fetch_assoc($res)) {
  43. if ($row['log_statuscode'] == '1') {
  44. $data[] = $row;
  45. } else {
  46. $codes[(int) $row['log_statuscode']]++;
  47. $rejects++;
  48. }
  49. }
  50. if ($rejects > 0) {
  51. ?>
  52. <p>
  53. Unfortunately, some of these traces have been rejected as they are not suitable for analysis:
  54. </p>
  55. <ul>
  56. <?PHP
  57. foreach ($codes as $code => $count) {
  58. echo '<li>', number_format($count), ' rejected because ' . getStatusCodeReason($code) . '</li>';
  59. }
  60. ?>
  61. </ul>
  62. <?PHP if ($num > $rejects) { ?>
  63. <p>The remaining <strong><?PHP echo $num - $rejects; ?></strong> record<?PHP echo $num > $rejects + 1 ? 's look' : ' looks'; ?>
  64. good, and <?PHP echo $num > $rejects + 1 ? 'are' : 'is'; ?> shown below:</p>
  65. <?PHP } else { ?>
  66. <p>Oh dear, that's all of your records. Make sure you're using the <a href="/android/">latest version</a>
  67. to ensure you get the best results. Record some more and check back soon!</p>
  68. <?PHP }
  69. } else {
  70. ?>
  71. <p>Our system didn't find any problems with your records, so all of them are shown below:</p>
  72. <?PHP
  73. }
  74. if ($rejects < $num) {
  75. ?>
  76. <h2>Your records</h2>
  77. <?PHP
  78. foreach ($data as $datum) {
  79. echo '<h3>', htmlentities($datum['log_activity']), '</h3>';
  80. echo '<div style="height: 700px; overflow: auto;">';
  81. echo '<img src="data.php?graph=' . $datum['log_id'] . '&amp;ds=1" height="330" alt="Graph of accelerometer data"/><br/>';
  82. echo '<img src="data.php?graph=' . $datum['log_id'] . '&amp;ds=2" height="330" alt="Graph of magnetic fielddata"/>';
  83. echo '</div>';
  84. }
  85. ?>
  86. <h2>Check back soon...</h2>
  87. <p>for information on how your records are being used, explanations of the data, and information on the application
  88. which will be created as a result</p>
  89. <?PHP } ?>
  90. <?PHP } ?>
  91. </div>
  92. <div id="footer"/>
  93. </body>
  94. </html>