diff --git a/index.php b/index.php
index 32f6306..d05e8a8 100644
--- a/index.php
+++ b/index.php
@@ -1,4 +1,6 @@
-
+
Pamela
diff --git a/lib/db.php b/lib/db.php
index 0b3bc25..b094324 100644
--- a/lib/db.php
+++ b/lib/db.php
@@ -4,7 +4,7 @@ require_once("config.php");
function get_db() {
static $db = NULL;
if ($db == NULL) {
- $db = sqlite_open(SQLITE_DB);
+ $db = new SQLite3(SQLITE_DB);
}
return $db;
}
diff --git a/lib/macs.php b/lib/macs.php
index ef72247..26f9ad8 100644
--- a/lib/macs.php
+++ b/lib/macs.php
@@ -4,10 +4,9 @@ require_once("lib/db.php");
function macs_get() {
$results = array();
$db = get_db();
- $q = sqlite_query($db, "select mac from macs where committime > strftime('%s','now') - ".MACFILE_TTL);
+ $q = $db->query("select mac from macs where committime > strftime('%s','now') - ".MACFILE_TTL);
if (!$q) return $results;
- while(sqlite_has_more($q)) {
- $row = sqlite_fetch_array($q, SQLITE_ASSOC);
+ while($row = $q->fetch_array(SQLITE_ASSOC)) {
$results[] = $row['mac'];
}
return $results;
@@ -15,11 +14,11 @@ function macs_get() {
function macs_add($mac) {
$db = get_db();
- $mac = sqlite_escape_string($mac);
- return sqlite_exec($db, "insert or replace into macs values (\"$mac\", strftime('%s','now'))");
+ $mac = $db->escape_string($mac);
+ return $db->exec("insert or replace into macs values (\"$mac\", strftime('%s','now'))");
}
function macs_purge() {
$db = get_db();
- return sqlite_exec($db, "delete from macs where committime <= strftime('%s','now') - ".MACFILE_TTL);
+ return $db->exec("delete from macs where committime <= strftime('%s','now') - ".MACFILE_TTL);
}
diff --git a/lib/trans.php b/lib/trans.php
index 54d66f0..d9e7b10 100644
--- a/lib/trans.php
+++ b/lib/trans.php
@@ -4,10 +4,9 @@ require_once("lib/db.php");
function known_macs_get() {
$results = array();
$db = get_db();
- $q = sqlite_query($db, "select * from knownmacs");
+ $q = $db->query("select * from knownmacs");
if (!$q) return $results;
- while(sqlite_has_more($q)) {
- $row = sqlite_fetch_array($q, SQLITE_ASSOC);
+ while($row = $q->fetch_array(SQLITE_ASSOC)) {
$results[$row['mac']] = $row['name'];
}
return $results;
@@ -16,10 +15,9 @@ function known_macs_get() {
function known_macs_get_by_user($userid) {
$results = array();
$db = get_db();
- $q = sqlite_query($db, "select * from knownmacs where userid = \"userid\"");
+ $q = $db->query("select * from knownmacs where userid = \"userid\"");
if (!$q) return $results;
- while(sqlite_has_more($q)) {
- $row = sqlite_fetch_array($q, SQLITE_ASSOC);
+ while($row = $q->fetch_array(SQLITE_ASSOC)) {
$results[$row['mac']] = $row['name'];
}
return $results;
@@ -27,10 +25,10 @@ function known_macs_get_by_user($userid) {
function known_macs_upsert($mac, $name, $show) {
$db = get_db();
- $mac = sqlite_escape_string($mac);
- $name = sqlite_escape_string($name);
- $show = sqlite_escape_string($show);
- return sqlite_exec($db, "insert into knownmacs or replace (mac, name, show) values (\"$mac\", \"$name\", \"$show\")");
+ $mac = $db->escape_string($mac);
+ $name = $db->escape_string($name);
+ $show = $db->escape_string($show);
+ return $db->exec("insert into knownmacs or replace (mac, name, show) values (\"$mac\", \"$name\", \"$show\")");
}
function known_macs_translate($macs) {
diff --git a/macs.php b/macs.php
index 574145a..24ea293 100644
--- a/macs.php
+++ b/macs.php
@@ -37,7 +37,6 @@ function multiply() {
}
}
}
-
$macs = macs_get();
$macs = known_macs_translate($macs);
if (count($macs) > 0) {