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.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?PHP
  2. require_once('settings.php');
  3. mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS);
  4. mysql_select_db(MYSQL_DB);
  5. function m($sql) {
  6. return mysql_real_escape_string($sql);
  7. }
  8. function bchexdec($hex) {
  9. $len = strlen($hex);
  10. for ($i = 1; $i <= $len; $i++) {
  11. $dec = bcadd($dec, bcmul(strval(hexdec($hex[$i - 1])), bcpow('16', strval($len - $i))));
  12. }
  13. return $dec;
  14. }
  15. function Oblong($message) {
  16. $key = trim(file_get_contents('/home/chris/oblong.key'));
  17. $chan = '#MD87.highvol';
  18. $fp = @fsockopen("oblong.md87.co.uk", 3302, $errno, $errstr, 30);
  19. if ($fp) {
  20. $out = $key.' '.$chan.' '.substr($message, 0, 460)."\n";
  21. fwrite($fp, $out);
  22. fclose($fp);
  23. }
  24. }
  25. function getActivityArray() {
  26. $acs = array();
  27. $sql = 'SELECT activity_id, activity_name, activity_parent FROM activities ORDER BY activity_parent';
  28. $res = mysql_query($sql);
  29. while ($row = mysql_fetch_assoc($res)) {
  30. $name = $row['activity_name'];
  31. if (isset($acs[(int) $row['activity_parent']])) {
  32. $name = $acs[(int) $row['activity_parent']] . '/' . $name;
  33. }
  34. $acs[(int) $row['activity_id']] = $name;
  35. }
  36. return $acs;
  37. }
  38. function getStatusCodeReason($code) {
  39. switch ((int) $code) {
  40. case 2: return 'no IMEI code was specified';
  41. case 3: return 'no activity was specified';
  42. case 4: return 'no application version was specified';
  43. case 5: return 'no sensor data was included';
  44. case 6: return 'an invalid date was specified';
  45. case 7: return 'insufficient sensor data was included';
  46. case 8: return 'the sensor data was already submitted (duplicate)';
  47. case 9: return 'the sensor data contained long periods of identical values';
  48. }
  49. return 'unknown reason';
  50. }
  51. function decodeIMEI($input) {
  52. $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-=_';
  53. $tot = '0';
  54. for ($i = 0; $i < strlen($_GET['code']); $i++) {
  55. $n = strpos($chars, $_GET['code'][$i]);
  56. $tot = bcadd($tot, bcmul($n, bcpow(strlen($chars), strlen($_GET['code']) - $i - 1)));
  57. }
  58. return $tot;
  59. }
  60. ?>