From b6cadf03d1dcbe1d0c22a7dde09d516a2ed3e8f4 Mon Sep 17 00:00:00 2001 From: paulr Date: Sat, 13 Nov 2010 02:28:11 +1100 Subject: [PATCH] various bits a pieces --- doc/README | 6 ++++- php/authd/authd.php | 6 ++++ php/config/config.php | 5 ++++ php/lib/db.php | 62 +++++++++++++++++++++++++++++++++++++++++++++++++ php/lib/lib.php | 6 ++++ 5 files changed, 84 insertions(+), 1 deletions(-) create mode 100644 php/authd/authd.php create mode 100644 php/lib/db.php diff --git a/doc/README b/doc/README index 91c61a6..20e0ece 100644 --- a/doc/README +++ b/doc/README @@ -16,4 +16,8 @@ Primary, this website will only do three things: 2) admin users - i.e. assign tokens to users - it would be nice if the backend were something else (i.e. ldap/AD) 3) allow users to manage their tokens i.e. synchronize them - assign them to themselves, etc. \ No newline at end of file + assign them to themselves, etc. + +This system will also include a auth daemon called authd. +Authd is primarily a data broker, spoken to via shared memory +from the website. \ No newline at end of file diff --git a/php/authd/authd.php b/php/authd/authd.php new file mode 100644 index 0000000..bf3b1fd --- /dev/null +++ b/php/authd/authd.php @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/php/config/config.php b/php/config/config.php index 15c5adc..1d8a6f4 100644 --- a/php/config/config.php +++ b/php/config/config.php @@ -1,3 +1,8 @@ \ No newline at end of file diff --git a/php/lib/db.php b/php/lib/db.php new file mode 100644 index 0000000..027ce53 --- /dev/null +++ b/php/lib/db.php @@ -0,0 +1,62 @@ +dbobject->query($sql); + + $sql = 'CREATE TABLE "hosts" ("ho_id" INTEGER PRIMARY KEY AUTOINCREMENT,"ho_sn_id" INTEGER,"ho_ip" TEXT,"ho_name" TEXT,"ho_desc" TEXT);'; + $this->dbobject->query($sql); + + $sql = 'CREATE TABLE subnet ("sn_id" INTEGER PRIMARY KEY AUTOINCREMENT,"snid_id" INTEGER,"sn_ip" TEXT,"sn_mask" TEXT,"sn_name" TEXT, "sn_desc" TEXT);'; + $this->dbobject->query($sql); + + $sql = 'CREATE TABLE supernet ("sn_id" INTEGER PRIMARY KEY AUTOINCREMENT,"sn_name" TEXT,"sn_ip" TEXT,"sn_mask" TEXT,"sn_desc" TEXT);'; + $this->dbobject->query($sql); + } + + function connect() { + global $DB_URI; + + try { + $this->dbobject = new PDO("$DB_URI"); + } catch(PDOException $exep) { + error_log("execpt on db open"); + } + + if(!$this->dbobject->query("select * from hosts")) { + error_log("db open for init"); + $this->init(); + } + + } + + public $dbobject = ""; + + function dump() { + $sql = "select * from supernet"; + $res = $this->dbobject->query($sql); + + foreach($res as $row) { + echo "sn:".$row["sn_id"].":".$row["sn_name"].":".$row["sn_ip"].":".$row["sn_mask"].":".$row["sn_desc"]."\n"; + } + $sql = "select * from subnet"; + $res = $this->dbobject->query($sql); + + foreach($res as $row) { + echo "sbn:".$row["sn_id"].":".$row["snid_id"].":".$row["sn_name"].":".$row["sn_ip"].":".$row["sn_mask"].":".$row["sn_desc"]."\n"; + } + $sql = "select * from hosts"; + $res = $this->dbobject->query($sql); + + foreach($res as $row) { + echo "hst:".$row["ho_id"].":".$row["ho_sn_id"].":".$row["ho_ip"].":".$row["ho_name"].":".$row["ho_desc"]."\n"; + } + } + + function restore($restorefile) { + + } +} + +?> \ No newline at end of file diff --git a/php/lib/lib.php b/php/lib/lib.php index dc10d56..59e1f60 100644 --- a/php/lib/lib.php +++ b/php/lib/lib.php @@ -1,4 +1,10 @@ \ No newline at end of file -- 1.7.0.4