Read action inside router
[gitphp.git] / index.php
blob:a/index.php -> blob:b/index.php
<?php <?php
/** /**
* GitPHP * GitPHP
* *
* Index * Index
* *
* @author Christopher Han <xiphux@gmail.com> * @author Christopher Han <xiphux@gmail.com>
* @copyright Copyright (c) 2010 Christopher Han * @copyright Copyright (c) 2010 Christopher Han
* @package GitPHP * @package GitPHP
*/ */
   
/** /**
* Use utf-8 encoding * Use utf-8 encoding
*/ */
if (function_exists('mb_internal_encoding')) { if (function_exists('mb_internal_encoding')) {
mb_internal_encoding("UTF-8"); mb_internal_encoding("UTF-8");
} }
   
/** /**
* Define start time / memory for benchmarking * Define start time / memory for benchmarking
*/ */
define('GITPHP_START_TIME', microtime(true)); define('GITPHP_START_TIME', microtime(true));
define('GITPHP_START_MEM', memory_get_usage()); define('GITPHP_START_MEM', memory_get_usage());
   
/** /**
* Define some paths * Define some paths
*/ */
define('GITPHP_BASEDIR', dirname(__FILE__) . '/'); define('GITPHP_BASEDIR', dirname(__FILE__) . '/');
define('GITPHP_CONFIGDIR', GITPHP_BASEDIR . 'config/'); define('GITPHP_CONFIGDIR', GITPHP_BASEDIR . 'config/');
define('GITPHP_INCLUDEDIR', GITPHP_BASEDIR . 'include/'); define('GITPHP_INCLUDEDIR', GITPHP_BASEDIR . 'include/');
define('GITPHP_LOCALEDIR', GITPHP_BASEDIR . 'locale/'); define('GITPHP_LOCALEDIR', GITPHP_BASEDIR . 'locale/');
define('GITPHP_CACHEDIR', GITPHP_BASEDIR . 'cache/'); define('GITPHP_CACHEDIR', GITPHP_BASEDIR . 'cache/');
define('GITPHP_LIBDIR', GITPHP_BASEDIR . 'lib/'); define('GITPHP_LIBDIR', GITPHP_BASEDIR . 'lib/');
define('GITPHP_SMARTYDIR', GITPHP_LIBDIR . 'smarty/libs/'); define('GITPHP_SMARTYDIR', GITPHP_LIBDIR . 'smarty/libs/');
define('GITPHP_GESHIDIR', GITPHP_LIBDIR . 'geshi/'); define('GITPHP_GESHIDIR', GITPHP_LIBDIR . 'geshi/');
   
include(GITPHP_INCLUDEDIR . 'version.php'); include(GITPHP_INCLUDEDIR . 'version.php');
   
require(GITPHP_INCLUDEDIR . 'AutoLoader.class.php'); require(GITPHP_INCLUDEDIR . 'AutoLoader.class.php');
   
spl_autoload_register(array('GitPHP_AutoLoader', 'AutoLoad')); spl_autoload_register(array('GitPHP_AutoLoader', 'AutoLoad'));
   
date_default_timezone_set('UTC'); date_default_timezone_set('UTC');
   
try { try {
   
$controller = GitPHP_Router::GetController((isset($_GET['a']) ? $_GET['a'] : null)); $controller = GitPHP_Router::GetController();
if ($controller) { if ($controller) {
$controller->RenderHeaders(); $controller->RenderHeaders();
$controller->Render(); $controller->Render();
} }
   
} catch (Exception $e) { } catch (Exception $e) {
   
$messageController = new GitPHP_Controller_Message(); $messageController = new GitPHP_Controller_Message();
   
$config = $messageController->GetConfig(); $config = $messageController->GetConfig();
if ($config && $config->GetValue('debug') && !($e instanceof GitPHP_MessageException)) { if ($config && $config->GetValue('debug') && !($e instanceof GitPHP_MessageException)) {
throw $e; throw $e;
} }
   
$messageController->SetParam('exception', $e); $messageController->SetParam('exception', $e);
$messageController->RenderHeaders(); $messageController->RenderHeaders();
$messageController->Render(); $messageController->Render();
   
unset($messageController); unset($messageController);
   
} }
   
if (isset($controller)) { if (isset($controller)) {
$log = $controller->GetLog(); $log = $controller->GetLog();
if ($log && $log->GetEnabled()) { if ($log && $log->GetEnabled()) {
$entries = $log->GetEntries(); $entries = $log->GetEntries();
foreach ($entries as $logline) { foreach ($entries as $logline) {
echo "<br />\n" . htmlspecialchars($logline, ENT_QUOTES, 'UTF-8', true); echo "<br />\n" . htmlspecialchars($logline, ENT_QUOTES, 'UTF-8', true);
} }
unset($logline); unset($logline);
unset($entries); unset($entries);
} }
unset($controller); unset($controller);
} }
   
?> ?>
   
comments