-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathindex.php
124 lines (106 loc) · 2.92 KB
/
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?php
/**
* GitPHP
*
* Index
*
* @author Christopher Han <[email protected]>
* @copyright Copyright (c) 2010 Christopher Han
* @package GitPHP
*/
/**
* Use utf-8 encoding
*/
if (function_exists('mb_internal_encoding')) {
mb_internal_encoding("UTF-8");
}
/**
* Define start time / memory for benchmarking
*/
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_LOCALEDIR', GITPHP_BASEDIR . 'locale/');
define('GITPHP_CACHEDIR', GITPHP_BASEDIR . 'cache/');
define('GITPHP_LIBDIR', GITPHP_BASEDIR . 'lib/');
define('GITPHP_SMARTYDIR', GITPHP_LIBDIR . 'smarty/libs/');
define('GITPHP_GESHIDIR', GITPHP_LIBDIR . 'geshi/');
/**
* Low level setup
*/
if (function_exists('mb_internal_encoding')) {
mb_internal_encoding("UTF-8");
}
date_default_timezone_set('UTC');
/**
* Version header
*/
include(GITPHP_INCLUDEDIR . 'version.php');
/**
* Autoload setup
*/
require(GITPHP_INCLUDEDIR . 'AutoLoader.class.php');
spl_autoload_register('GitPHP_AutoLoader::AutoLoad');
/**
* Compatibility global functions / defines
*/
include(GITPHP_INCLUDEDIR . 'helpers.php');
$router = new GitPHP_Router();
try {
$controller = $router->GetController();
if ($controller) {
$controller->Initialize();
$controller->RenderHeaders();
$controller->Render();
unset($controller);
}
} catch (Exception $e) {
$messageController = $router->GetMessageController();
$messageController->Initialize();
$messageController->SetParam('message', $e->getMessage());
if ($e instanceof GitPHP_MessageException) {
$messageController->SetParam('error', $e->Error);
$messageController->SetParam('statuscode', $e->StatusCode);
} else {
$config = $messageController->GetConfig();
if ($config && $config->GetValue('debug')) {
throw $e;
}
}
$messageController->SetParam('exception', $e);
try {
$messageController->RenderHeaders();
$messageController->Render();
} catch (Exception $e) {
echo('<b>Fatal error</b> : '.$e->getMessage().'<pre style="font-size: 8pt;">');
if (GitPHP_Config::GetInstance()->GetValue('debug')) {
$stack = $e->getTrace();
$error = @ error_get_last(); // PHP 5.2
if (!empty($error))
echo 'Last error at '.str_replace(GITPHP_BASEDIR,'',$error['file']).':'.
$error['line'].': '.$error['message'];
else
foreach ($stack as $t) print_r($t);
}
die;
}
unset($messageController);
}
$log = GitPHP_DebugLog::GetInstance();
if ($log->GetEnabled() && $log->GetCount()) {
echo '<div class="debug_footer"><pre>';
echo implode("\n", $log->GetEntries());
echo '</pre></div>';
}
unset($router);
GitPHP_ProjectList::DestroyInstance();
GitPHP_MemoryCache::DestroyInstance();
GitPHP_Config::DestroyInstance();
GitPHP_GitExe::DestroyInstance();
GitPHP_DebugLog::DestroyInstance();
?>