file datastore work
[glcas.git] / lib / lib.php
1 <?php
2
3 require_once("config.php");
4 require_once("wsdl.php");
5
6
7 // first and foremost, load the plugins
8 $basedir = dirname(__FILE__);
9
10 // we load this first
11 if(file_exists("$basedir/plugins/www.php")) require_once("$basedir/plugins/www.php");
12
13 if(is_dir("$basedir/plugins")) {
14         $dh = opendir("$basedir/plugins");
15         if($dh) {
16                 while(($file = readdir($dh))!==false) {
17                         $mt = preg_match("/.*\.php$/", $file);
18                         if($mt > 0) {
19                                 require_once("$basedir/plugins/$file");
20                                 //echo "required $basedir/plugins/$file\n";
21                         }
22                 }
23         }
24 } else {
25         echo "No plugins dir ($basedir/plugins), continuing without\n";
26 }
27
28 function urlInterpretter()
29 {
30         global $BASE_URLS;
31         global $URL_COMPONENTS;
32         
33         if(isset($_REQUEST["q"])) $qry = $_REQUEST["q"];
34         else $qry = "";
35         
36         $urlcomps = preg_split("/[,\/]/", $qry);
37         $URL_COMPONENTS = $urlcomps;
38         
39         foreach($BASE_URLS as $bases_cd => $bases) {
40                 //echo "<br>checking $bases_cd for ".$bases["base"]." against \"".$urlcomps[0]."\"<br>";
41                 if(strtolower($urlcomps[0]) == strtolower($bases["base"])) {
42                         //echo "match<br>";
43                         $func = $bases["function"];
44                         return $func();
45                 }
46         }
47 }
48 ?>