function add_station($dirty) { if (is_read_only()) { return false; } global $db; $clean = sql_escape_hash($dirty); $station = db_get('select * from stations where callsign = "' . $clean['callsign'] . '"'); if(!$station) { $lhs = array_keys($dirty); $rhs = array_values($dirty); return $db->exec('insert into stations (' . implode(',', $lhs) . ') values ("' . implode('","', $rhs) . '")'); } else { $inj = sql_kv($dirty); return $db->exec('update stations set ' . implode(',', $inj) . ' where id = ' . $station['id']); } }
echo '<p>Now: ' . $now . '</p>'; echo '<table>'; $res = $db->query('select * from reminders'); $isFirst = true; while($row = prune($res)) { if($isFirst) { echo '<thead><tr>'; echo '<th>' . implode('</th><th>', array_keys($row)) . '</th>'; echo '</thead><tbody>'; $isFirst = False; } if (is_read_only()) { $row['email'] = '<em>(hidden)</em>'; } $intval = intval($row['end_time']); $row['end_time'] = "$intval<br><small>(" . ($now - $intval) . ')</small>'; echo '<tr><td>' . implode('</td><td>', array_values($row)) . '</td>'; echo '<td>'; echo '</tr>'; } ?> </tbody> </table> </body></html>