2010-02-22 00:38:28 +00:00
|
|
|
<?php
|
|
|
|
require_once("lib/db.php");
|
|
|
|
|
|
|
|
function macs_get() {
|
|
|
|
$results = array();
|
|
|
|
$db = get_db();
|
2010-11-13 23:15:26 +00:00
|
|
|
$q = $db->query("select mac from macs where committime > strftime('%s','now') - ".MACFILE_TTL);
|
2010-02-22 00:38:28 +00:00
|
|
|
if (!$q) return $results;
|
2010-11-13 23:15:26 +00:00
|
|
|
while($row = $q->fetch_array(SQLITE_ASSOC)) {
|
2010-02-22 00:38:28 +00:00
|
|
|
$results[] = $row['mac'];
|
|
|
|
}
|
|
|
|
return $results;
|
|
|
|
}
|
|
|
|
|
|
|
|
function macs_add($mac) {
|
|
|
|
$db = get_db();
|
2010-11-13 23:15:26 +00:00
|
|
|
$mac = $db->escape_string($mac);
|
|
|
|
return $db->exec("insert or replace into macs values (\"$mac\", strftime('%s','now'))");
|
2010-02-22 00:38:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function macs_purge() {
|
|
|
|
$db = get_db();
|
2010-11-13 23:15:26 +00:00
|
|
|
return $db->exec("delete from macs where committime <= strftime('%s','now') - ".MACFILE_TTL);
|
2010-02-22 00:38:28 +00:00
|
|
|
}
|