|
@@ -4,6 +4,55 @@
|
4
|
4
|
|
5
|
5
|
define('VERSION', 25);
|
6
|
6
|
|
|
7
|
+ function processExceptions($records = true) {
|
|
8
|
+ $sql = 'SELECT record_id, record_ip, record_headers, record_data FROM unprocessed';
|
|
9
|
+ $res = mysql_query($sql);
|
|
10
|
+ $count = 0;
|
|
11
|
+
|
|
12
|
+ while ($row = mysql_fetch_assoc($res)) {
|
|
13
|
+ $ip = $row['record_ip'];
|
|
14
|
+
|
|
15
|
+ $headers = array();
|
|
16
|
+
|
|
17
|
+ foreach (explode("\n", $row['record_headers']) as $line) {
|
|
18
|
+ if (preg_match('/(.*?): (.*)$/', $line, $m)) {
|
|
19
|
+ $headers[$m[1]] = $m[2];
|
|
20
|
+ }
|
|
21
|
+ }
|
|
22
|
+
|
|
23
|
+ if (!isset($headers['APPLICATION']) || substr($headers['APPLICATION'], -10) != '-exception') {
|
|
24
|
+ continue;
|
|
25
|
+ }
|
|
26
|
+
|
|
27
|
+ $application = substr($headers['APPLICATION'], 0, -10);
|
|
28
|
+ $imei = isset($headers['IMEI']) ? $headers['IMEI'] : '';
|
|
29
|
+
|
|
30
|
+ if (!ctype_digit($imei) && !empty($imei)) {
|
|
31
|
+ // It's probably an MEID not an IMEI number
|
|
32
|
+ $imei = bchexdec($headers['IMEI']);
|
|
33
|
+ }
|
|
34
|
+
|
|
35
|
+ $version = isset($headers['VERSION']) ? $headers['VERSION'] : '';
|
|
36
|
+ $headers = $row['record_headers'];
|
|
37
|
+ $data = $row['record_data'];
|
|
38
|
+
|
|
39
|
+ $sql = 'INSERT INTO exceptions (ex_ip, ex_imei, ex_application, ex_version, ';
|
|
40
|
+ $sql .= 'ex_headers, ex_trace) VALUES (';
|
|
41
|
+ $sql .= '\'' . m($ip) . '\', \'' . m($imei) . '\', \'' . m($application) . '\', \'';
|
|
42
|
+ $sql .= m($version) . '\', \'' . m($headers) . '\', \'' . m($data) . '\')';
|
|
43
|
+ mysql_query($sql) or die(mysql_error());
|
|
44
|
+
|
|
45
|
+ $sql = 'DELETE FROM unprocessed WHERE record_id = ' . $row['record_id'];
|
|
46
|
+ mysql_query($sql);
|
|
47
|
+
|
|
48
|
+ $count++;
|
|
49
|
+ }
|
|
50
|
+
|
|
51
|
+ if ($count > 1 || !$records && $count > 0) {
|
|
52
|
+ Oblong("\002[ANDROID]\002 Processed $count " . ($records ? "new" : "existing") . " exceptions");
|
|
53
|
+ }
|
|
54
|
+ }
|
|
55
|
+
|
7
|
56
|
function processSensorLogger($records = true) {
|
8
|
57
|
$sql = $records ? 'SELECT record_id, record_ip, record_headers, record_data FROM unprocessed'
|
9
|
58
|
: 'SELECT log_id, log_ip AS record_ip, log_headers AS record_headers, log_data '
|
|
@@ -133,5 +182,6 @@
|
133
|
182
|
}
|
134
|
183
|
|
135
|
184
|
processSensorLogger(!isset($argv[1]) || $argv[1] != '--update');
|
|
185
|
+ processExceptions(!isset($argv[1]) || $argv[1] != '--update');
|
136
|
186
|
|
137
|
187
|
?>
|