summaryrefslogtreecommitdiff
path: root/portal/system/handler.php
blob: dec5c959350e81e2a55568bae30ad259ba793306 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
// Main file for dispatching pages
//
// $Id: handler.php,v 1.21 2007-08-14 12:03:45 mha Exp $
//
function __autoload($class) {
   if ($class == 'HTML_Template_Sigma') {
       require_once 'HTML/Template/Sigma.php';
       return;
   }
   $lcclass = strtolower($class);
   if (substr($lcclass,0,5) == 'page_') {
      require_once './page/' . substr($lcclass,5) . '.php';
   }
   elseif (substr($lcclass,0,5) == 'form_') {
      require_once './form/' . substr($lcclass,5) . '.php';
   }
   elseif (substr($lcclass,0,6) == 'admin_') {
       require_once '../admin/' . substr($lcclass,6) . '.php';
   }
   else {
      require_once "./global/$lcclass.php";
   }
}

require_once './global/settings.php';

// Override config that really must be set
ini_set('session.use_cookies','1');
ini_set('session.use_only_cookies','1');


try {
    if (isset($_GET['page']) && $_GET['page'] == 'submitthanks') {
        // Special case. Ugly, but backwards compatible ;-)
        $pgpage = Dispatcher::Dispatch($_GET['action']);
        $pgpage->thanks = true;
    }
    else
        $pgpage = Dispatcher::Dispatch(isset($_GET['page'])?$_GET['page']:'index');

    $pgpage->setLanguage(isset($_GET['lang'])?$_GET['lang']:null);

    if ($pgpage->requirelogin)
        $pgpage->ValidateLogin();

    $pgpage->PreRender();
    $pgpage->DoRender();
}
catch (NotFoundException $nfe) {
    $errp = new ErrorPage(404, 'File Not Found', $nfe->getMessage(), isset($_GET['page'])?$_GET['page']:'index');
    $errp->ShowError();
}
catch (Exception $ex) {
    $errp = new ErrorPage(500, 'Internal Server Error', $ex->getMessage(), isset($_GET['page'])?$_GET['page']:'index');
    $errp->ShowError();
}

$pgpage->Show();

?>