various bits a pieces master
authorpaulr <me@pjr.cc>
Fri, 12 Nov 2010 15:28:11 +0000 (02:28 +1100)
committerpaulr <me@pjr.cc>
Fri, 12 Nov 2010 15:28:11 +0000 (02:28 +1100)
doc/README
php/authd/authd.php [new file with mode: 0644]
php/config/config.php
php/lib/db.php [new file with mode: 0644]
php/lib/lib.php

index 91c61a6..20e0ece 100644 (file)
@@ -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 (file)
index 0000000..bf3b1fd
--- /dev/null
@@ -0,0 +1,6 @@
+<?php
+// this components is the part that does the actual auth. It'll run as a user and secure all its data.
+require_once("../lib/lib.php")
+
+
+?>
\ No newline at end of file
index 15c5adc..1d8a6f4 100644 (file)
@@ -1,3 +1,8 @@
 <?php
 
+$DB_URI = "sqlite:/tmp/otpcentral.db";
+
+
+global $DB_URI;
+
 ?>
\ No newline at end of file
diff --git a/php/lib/db.php b/php/lib/db.php
new file mode 100644 (file)
index 0000000..027ce53
--- /dev/null
@@ -0,0 +1,62 @@
+<?php
+class db {
+       function init() {
+
+               $sql = 'CREATE TABLE sqlite_sequence(name,seq);';
+               $this->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
index dc10d56..59e1f60 100644 (file)
@@ -1,4 +1,10 @@
 <?php
 
+require_once("../config/config.php");
+
+require_once("db.php");
+require_once("soap.php");
+require_once("token.php");
+require_once("user.php");
 
 ?>
\ No newline at end of file