initial re-coding
[configmanager.git] / lib / lib.php
index 15c5adc..0fb5214 100644 (file)
@@ -1,3 +1,36 @@
 <?php
 
+$BASE_DIR = realpath(dirname(__FILE__)."/../");
+
+$DB_HANDLE = false;
+global $BASE_DIR, $HOST_TYPES, $DB_HANDLE;
+
+// require some files
+require_once("www.php");
+require_once("db.php");
+require_once("xmlrpc.php");
+
+// get the config
+if(file_exists("../etc/config.php")) require_once("../etc/config.php");
+
+// first and foremost, load the plugins
+$basedir = dirname(__FILE__);
+
+// we load this first
+if(is_dir("$basedir")) {
+       $dh = opendir("$basedir");
+       if($dh) {
+               while(($file = readdir($dh))!==false) {
+                       $mt = preg_match("/.*\.plugin\.php$/", $file);
+                       if($mt > 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