Comment out global exception catch temporarily to make development easier
[gitphp.git] / index.php
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
/**
 * GitPHP
 *
 * Index
 *
 * @author Christopher Han <xiphux@gmail.com>
 * @copyright Copyright (c) 2010 Christopher Han
 * @package GitPHP
 */
 
define('GITPHP_START_TIME', microtime(true));
define('GITPHP_START_MEM', memory_get_usage());
 
/**
 * Define some paths
 */
define('GITPHP_BASEDIR', dirname(__FILE__) . '/');
define('GITPHP_CONFIGDIR', GITPHP_BASEDIR . 'config/');
define('GITPHP_INCLUDEDIR', GITPHP_BASEDIR . 'include/');
define('GITPHP_GITOBJECTDIR', GITPHP_INCLUDEDIR . 'git/');
define('GITPHP_CONTROLLERDIR', GITPHP_INCLUDEDIR . 'controller/');
 
/*
 * Version
 */
include_once(GITPHP_INCLUDEDIR . 'version.php');
 
/*
 * Constants
 */
require_once(GITPHP_INCLUDEDIR . 'defs.constants.php');
 
require_once(GITPHP_INCLUDEDIR . 'Config.class.php');
 
require_once(GITPHP_INCLUDEDIR . 'Log.class.php');
 
require_once(GITPHP_GITOBJECTDIR . 'ProjectList.class.php');
 
require_once(GITPHP_INCLUDEDIR . 'MessageException.class.php');
require_once(GITPHP_CONTROLLERDIR . 'Controller.class.php');
 
date_default_timezone_set('UTC');
 
//try {
 
        /*
         * Configuration
         */
        try {
                GitPHP_Config::GetInstance()->LoadConfig(GITPHP_CONFIGDIR . 'gitphp.conf.php.example');
        } catch (Exception $e) {
        }
        GitPHP_Config::GetInstance()->LoadConfig(GITPHP_CONFIGDIR . 'gitphp.conf.php');
 
        /*
         * Debug
         */
        if (GitPHP_Log::GetInstance()->GetEnabled()) {
                GitPHP_Log::GetInstance()->SetStartTime(GITPHP_START_TIME);
                GitPHP_Log::GetInstance()->SetStartMemory(GITPHP_START_MEM);
        }
 
        /*
         * Project list
         */
        GitPHP_ProjectList::Instantiate(GITPHP_CONFIGDIR . 'gitphp.conf.php');
 
        if (!GitPHP_Config::GetInstance()->GetValue('projectroot', null)) {
                throw new GitPHP_MessageException('A projectroot must be set in the config', true);
        }
 
        $gitphp_current_project = null;
 
        if (isset($_GET['p'])) {
                $gitphp_current_project = GitPHP_ProjectList::GetInstance()->GetProject(str_replace(chr(0), '', $_GET['p']));
        }
 
        $controller = GitPHP_Controller::GetController((isset($_GET['a']) ? $_GET['a'] : null));
        if ($controller) {
                $controller->RenderHeaders();
                $controller->Render();
        }
 
//} catch (Exception $e) {
//
//      require_once(GITPHP_CONTROLLERDIR . 'Controller_Message.class.php');
//      $controller = new GitPHP_Controller_Message();
//      $controller->SetParam('message', $e->getMessage());
//      if ($e instanceof GitPHP_MessageException) {
//              $controller->SetParam('error', $e->Error);
//      } else {
//              $controller->SetParam('error', true);
//      }
//      $controller->Render();
//
//}
 
if (GitPHP_Log::GetInstance()->GetEnabled()) {
        $entries = GitPHP_Log::GetInstance()->GetEntries();
        foreach ($entries as $logline) {
                echo "\n" . $logline;
        }
}
 
?>
 
comments