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