4657e529f43a926bbfc3eb6981108ebb8a4f0d16
[glcas.git] / www / index.php
1 <?php
2
3 $WEB_ROOT_FS = realpath(dirname(__FILE__));
4
5 global $WEB_ROOT_FS, $URL_HANDLERS;
6
7 // add libglcas as if it were a path in ../libglcas
8 if(file_exists("../libglcas")) {
9         $path = realpath($WEB_ROOT_FS."/../");
10         error_log("added glcas path as $path");
11         set_include_path(get_include_path().PATH_SEPARATOR.$path);
12 }
13
14 // include the based library
15 require_once("libglcas/lib.php");
16
17 // load plugins
18 glcas_pluginLoader();
19
20 // find our config
21 $configpath = "";
22
23 // TODO: do this better
24 if(file_exists($WEB_ROOT_FS."/../var")) {
25         
26         // is it there?
27         if(file_exists($WEB_ROOT_FS."/../var/glcas/webconfig")) {
28                 $configpath = realpath("$WEB_ROOT_FS/../var/glcas/webconfig");
29         } else {        
30                 // if not, attempt to create
31                 if(!file_exists($WEB_ROOT_FS."/../var/glcas")) {
32                         mkdir($WEB_ROOT_FS."/../var/glcas");
33                 }
34                 // success!
35                 touch("$WEB_ROOT_FS/../var/glcas/webconfig");
36                 $configpath = realpath("$WEB_ROOT_FS/../var/glcas/webconfig");
37         }
38 }
39
40
41 $glconfig = new GLCASConfig();
42 $glconfig->loadConfig($configpath);
43 $webResponder = new GLCASWeb($glconfig);
44 $webResponder->go($URL_HANDLERS);
45 /*
46
47 echo "<pre>";
48 $vars = get_defined_vars();
49 foreach($vars as $var => $vkey) {
50         echo "VAR $var is:\n";
51         var_dump($$var);
52         echo "\n\n";
53 }
54
55 echo "</pre>";
56 /**/
57
58 ?>