From: paulr Date: Wed, 8 Jun 2011 19:02:36 +0000 (+1000) Subject: initial re-coding X-Git-Url: http://git.pjr.cc/?p=configmanager.git;a=commitdiff_plain;h=336d9ee4a2c84e3029a7f40b4ac759d592733c78 initial re-coding --- diff --git a/etc/config.php b/etc/config.php index e89f248..0620e15 100644 --- a/etc/config.php +++ b/etc/config.php @@ -1,3 +1,7 @@ \ No newline at end of file diff --git a/lib/cisco.plugin.php b/lib/cisco.plugin.php new file mode 100644 index 0000000..4b6490c --- /dev/null +++ b/lib/cisco.plugin.php @@ -0,0 +1,8 @@ + \ No newline at end of file diff --git a/lib/db.php b/lib/db.php new file mode 100644 index 0000000..f24917f --- /dev/null +++ b/lib/db.php @@ -0,0 +1,123 @@ +query($sql); +} + +function db_insertData($tablename) +{ + + $db = db_getDB(); + + $sql = "insert into \"$tablename\" values (NULL"; + for($i=1; $i < func_num_args(); $i++) { + $sql .= ",'".func_get_arg($i)."'"; + } + $sql .=")"; + + $db->query($sql); +} + +function db_selectData($tablename, $column="", $value="") +{ + $db = db_getDB(); + + if($column != "") $extra = " where $column like '%$value%'"; + else $extra = ""; + $sql = "select * from \"$tablename\"$extra"; + $res = $db->query($sql); + if(!$res) return false; + $data = $res->fetchAll(); + + return $data; +} + +function db_deleteData($tablename, $column, $value) +{ + $db = db_getDB(); + + $sql = "delete from \"$tablename\" where $column like '%$value%'"; + //echo "Sql is $sql\n"; + return $db->query($sql); + +} + +function db_updateData($tablename, $column, $newdata, $wherecol, $wheredata, $exact=true) +{ + $db = db_getDB(); + + if($exact) $sql = "update \"$tablename\" set $column='$newdata' where $wherecol='$wheredata'"; + else $sql = "update \"$tablename\" set $column='$newdata' where $wherecol like '$wheredata'"; + return $db->query($sql); +} + +function db_deleteTable($tablename) +{ + $db = db_getDB(); + + $sql = "drop table $tablename"; + + return $db->query($sql); +} + +function db_tableExists($tablename) +{ + $db = db_getDB(); + + $sql = "select count(*) from sqlite_master where type='table' and name='$tablename'"; + $res = $db->query($sql); + + $value = $res->fetchColumn(); + + if($value == 1) return true; + else return false; +} + +function db_getTables() +{ + $db = db_getDB(); + + $sql = "select name from sqlite_master where type='table' and name not like 'sqlite_%'"; + $res = $db->query($sql); + + return $res->fetchAll(); +} +?> \ No newline at end of file diff --git a/lib/lib.php b/lib/lib.php index 15c5adc..0fb5214 100644 --- a/lib/lib.php +++ b/lib/lib.php @@ -1,3 +1,36 @@ 0) { + require_once("$basedir/$file"); + //echo "required $basedir/$file\n"; + } + } + } +} else { + echo "No plugins dir ($basedir/plugins), continuing without\n"; +} + +$db = db_getDB(); ?> \ No newline at end of file diff --git a/lib/screenos.plugin.php b/lib/screenos.plugin.php new file mode 100644 index 0000000..7739cfe --- /dev/null +++ b/lib/screenos.plugin.php @@ -0,0 +1,27 @@ + +Name
+Password
+Method + "; + echo "
";
+	print_r($_REQUEST);
+	echo "
"; +} + +function nsos_getConfig($istest) +{ + +} +?> \ No newline at end of file diff --git a/lib/unix.plugin.php b/lib/unix.plugin.php new file mode 100644 index 0000000..26e18ba --- /dev/null +++ b/lib/unix.plugin.php @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/lib/www.php b/lib/www.php new file mode 100644 index 0000000..de4b337 --- /dev/null +++ b/lib/www.php @@ -0,0 +1,133 @@ + + +Network Config Manager + + + + + +

Network Config Manager

+ + +
Copyright 2003-2011, Paul J Robinson
+ + + $name
"; + } +} + +function www_body() +{ + global $FUNCTIONS; + + $called = false; + if(isset($_REQUEST["action"])) { + $req = $_REQUEST["action"]; + if(isset($FUNCTIONS["$req"])) { + $func = $FUNCTIONS["$req"]; + if(function_exists($func)) { + $func(); + return true; + } + } + } + + $db = db_getDB(); + + // here we do the normal body, whatever that + // we'll list the hosts, the size of the current config and + // the last time it was updated, plus the number of versions + +} + +function www_hostTypesDropDown() +{ + global $HOST_TYPE; + + foreach($HOST_TYPE as $tloop => $types) { + $typename = $types["name"]; + $typever = $tloop; + echo ""; + } +} + +function www_addhost() +{ + ?> +
+ + + + +
Name
Hostname/IP Address
Host Type
+ +
+ "; + $func(); + echo ""; + } else echo "would call $func for $htype but it doesnt exist\n"; + } +} + +function www_addHostStageThree() +{ + global $HOST_TYPE; + if(isset($_REQUEST["hosttype"])) { + $htype = $_REQUEST["htype"]; + $func = $HOST_TYPE["$htype"]["postfunction"]; + if(function_exists($func)) { + $func(); + } else echo "would call $func for $htype but it doesnt exist\n"; + } + +} +?> \ No newline at end of file diff --git a/lib/xmlrpc.php b/lib/xmlrpc.php new file mode 100644 index 0000000..5cbc582 --- /dev/null +++ b/lib/xmlrpc.php @@ -0,0 +1,8 @@ + \ No newline at end of file diff --git a/www/index.php b/www/index.php index e3417c9..a86ff2b 100644 --- a/www/index.php +++ b/www/index.php @@ -1,3 +1,11 @@ \ No newline at end of file