implemented a plugin loader so i can add things like
[gwvp.git] / gwvplib / gwvppluginloader.php
diff --git a/gwvplib/gwvppluginloader.php b/gwvplib/gwvppluginloader.php
new file mode 100644 (file)
index 0000000..dcc7e0e
--- /dev/null
@@ -0,0 +1,32 @@
+<?php
+
+function gwvp_PluginLoader($path="")
+{
+       if($path !=  "") {
+               // try and find it
+               error_log("attempting to load plugins from $path");
+               $dh = opendir("$path");
+               if($dh) {
+                       while(($file = readdir($dh))!==false) {
+                               $mt = preg_match("/.*.php$/", $file);
+                               if($mt > 0) {
+                                       error_log("loading plugin $file");
+                                       require_once("$path/$file");
+                                       //echo "required $basedir/$file\n";
+                               }
+                       }
+               }                       
+       }
+}
+
+// we assume the config is loaded, but this is where it works:
+error_log("begin plugin load");
+if(isset($plugin_path)) {
+       error_log("path set");
+       if(is_dir($plugin_path)) {
+               error_log("is dir, beginning load");
+               gwvp_PluginLoader($plugin_path);
+       }
+}
+
+?>
\ No newline at end of file