Explorar el Código

Functionality to export classified windows

Closes #39
tags/SensorLogger/0.2.0
Chris Smith hace 14 años
padre
commit
0a49b0c5aa
Se han modificado 1 ficheros con 32 adiciones y 0 borrados
  1. 32
    0
      website/admin.php

+ 32
- 0
website/admin.php Ver fichero

83
   }
83
   }
84
  }
84
  }
85
 
85
 
86
+ function process_export($args) {
87
+  $acs = getActivityArray();
88
+  $sql = 'SELECT wc_offset, activity_id, log_data FROM activities NATURAL JOIN windowclassifications NATURAL JOIN sensorlogger WHERE log_statuscode = 1 AND (0';
89
+
90
+  foreach ($acs as $id => $name) {
91
+   if (substr($name, 0, 10) == 'CLASSIFIED') {
92
+    $sql .= ' OR activity_id = ' . $id;
93
+   }
94
+  }
95
+
96
+  $sql .= ')';
97
+  $res  = mysql_query($sql);
98
+
99
+  header('Content-type: text/plain');
100
+
101
+  while ($row = mysql_fetch_assoc($res)) {
102
+   echo 'Activity: ', $acs[$row['activity_id']], "\n";
103
+   $data = array_slice(explode("\n", $row['log_data']), $row['wc_offset'], 128);
104
+   echo implode("\n", $data);
105
+   echo "\n";
106
+  }
107
+
108
+  exit;
109
+ }
110
+
86
  if (isset($_POST['action'])) {
111
  if (isset($_POST['action'])) {
87
   $args = array();
112
   $args = array();
88
   $action = str_replace('.', '_', $_POST['action']) . '_';
113
   $action = str_replace('.', '_', $_POST['action']) . '_';
136
  <input type="submit" value="Delete">
161
  <input type="submit" value="Delete">
137
 </form>
162
 </form>
138
 
163
 
164
+<h1>Export</h1>
165
+
166
+<form action="admin.php" method="post">
167
+ <input type="hidden" name="action" value="export">
168
+ <input type="submit" value="Export classified windows">
169
+</form>
170
+
139
 <h1>Sample management</h1>
171
 <h1>Sample management</h1>
140
 <?PHP
172
 <?PHP
141
 
173
 

Loading…
Cancelar
Guardar