Context-detection API for Android developed as a university project
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

portal.php 3.8KB

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