added some config jargon
[glcas.git] / libglcas / lib.php
1 <?php
2 /*
3  * 
4  * The Main lib.php file.
5  * 
6  */
7
8 //require_once();
9
10 // get the lib root, and set include path from it
11 $LIB_ROOT_FS = realpath(dirname(__FILE__));
12 global $LIB_ROOT_FS;
13
14 /*
15  * I shouldnt ever need to do this bit, but its here, just in case
16 $adpath = realpath($LIB_ROOT_FS."/../");
17 error_log("added libglcas path as $adpath");
18 set_include_path(get_include_path().PATH_SEPARATOR.$adpath);
19
20 */
21 require_once("libglcas/urlparser.php");
22 require_once("libglcas/web.php");
23 require_once("libglcas/config.php");
24
25 function glcas_pluginLoader($path="")
26 {
27         global $LIB_ROOT_FS;
28         if($path ==  "") {
29                 // try and find it
30                 $plpath = realpath($LIB_ROOT_FS."/../plugins/");
31                 if(file_exists($plpath."/glcas_plugin.php")) {
32                         // here it is, load away
33                         error_log("attempting to load plugins from $plpath");
34                         $dh = opendir("$plpath");
35                         if($dh) {
36                                 while(($file = readdir($dh))!==false) {
37                                         $mt = preg_match("/.*.php$/", $file);
38                                         if($mt > 0) {
39                                                 error_log("loading plugin $file");
40                                                 require_once("$plpath/$file");
41                                                 //echo "required $basedir/$file\n";
42                                         }
43                                 }
44                         }                       
45                 }
46         }
47 }
48
49 function glcas_getWebConfigPath()
50 {
51         global $WEB_ROOT_FS, $URL_HANDLERS, $BASE_URL;
52
53         // if you wish to add more places to find webconfig, add them here.
54         $configpath = false;
55         if(file_exists($WEB_ROOT_FS."/../var/glcas/webconfig")) return realpath($WEB_ROOT_FS."/../var/glcas/webconfig");
56         if(file_exists("/var/lib/glcas/webconfig")) return realpath("/var/lib/glcas/webconfig");
57         if(file_exists("/var/run/glcas/webconfig")) return realpath("/var/run/glcas/webconfig");
58         
59         return $configpath;
60         //return false; 
61 }
62
63 ?>