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.

common.php 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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 Oblong($message) {
  9. $key = trim(file_get_contents('/home/chris/oblong.key'));
  10. $chan = '#MD87.highvol';
  11. $fp = @fsockopen("oblong.md87.co.uk", 3302, $errno, $errstr, 30);
  12. if ($fp) {
  13. $out = $key.' '.$chan.' '.substr($message, 0, 460)."\n";
  14. fwrite($fp, $out);
  15. fclose($fp);
  16. }
  17. }
  18. function getStatusCodeReason($code) {
  19. switch ((int) $code) {
  20. case 2: return 'no IMEI code was specified';
  21. case 3: return 'no activity was specified';
  22. case 4: return 'no application version was specified';
  23. case 5: return 'no sensor data was included';
  24. case 6: return 'an invalid date was specified';
  25. case 7: return 'insufficient sensor data was included';
  26. case 8: return 'the sensor data was already submitted (duplicate)';
  27. case 9: return 'the sensor data contained long periods of identical values';
  28. }
  29. return 'unknown reason';
  30. }
  31. function decodeIMEI($input) {
  32. $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-=_';
  33. $tot = '0';
  34. for ($i = 0; $i < strlen($_GET['code']); $i++) {
  35. $n = strpos($chars, $_GET['code'][$i]);
  36. $tot = bcadd($tot, bcmul($n, bcpow(strlen($chars), strlen($_GET['code']) - $i - 1)));
  37. }
  38. return $tot;
  39. }
  40. ?>