Bladeren bron

Functionality to export classified windows

Closes #39
tags/SensorLogger/0.2.0
Chris Smith 14 jaren geleden
bovenliggende
commit
0a49b0c5aa
1 gewijzigde bestanden met toevoegingen van 32 en 0 verwijderingen
  1. 32
    0
      website/admin.php

+ 32
- 0
website/admin.php Bestand weergeven

@@ -83,6 +83,31 @@
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 111
  if (isset($_POST['action'])) {
87 112
   $args = array();
88 113
   $action = str_replace('.', '_', $_POST['action']) . '_';
@@ -136,6 +161,13 @@
136 161
  <input type="submit" value="Delete">
137 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 171
 <h1>Sample management</h1>
140 172
 <?PHP
141 173
 

Laden…
Annuleren
Opslaan