score-style index

This commit is contained in:
Shish 2009-01-04 08:24:06 -08:00
parent 7f90fdbf97
commit 0c628f2c10
2 changed files with 69 additions and 46 deletions

View file

@ -70,9 +70,9 @@ class GenericPage {
// ============================================== // ==============================================
public function display() { public function display($context) {
header("Content-type: {$this->type}"); header("Content-type: {$this->type}");
header("X-Powered-By: Shimmie-".VERSION); header("X-Powered-By: SCore-".SCORE_VERSION);
switch($this->mode) { switch($this->mode) {
case "page": case "page":

111
index.php
View file

@ -1,64 +1,87 @@
<?php <?php
// set up and purify the environment // set up and purify the environment
define("DEBUG", true); define("DEBUG", true);
define("SCORE_VERSION", 's2hack');
define("VERSION", 'trunk'); define("VERSION", 'trunk');
require_once "core/util.inc.php"; if(!file_exists("config.php")) {
header("Location: install.php");
exit;
}
require_once "core/util.inc.php";
version_check(); version_check();
sanitise_environment(); sanitise_environment();
// load base files try {
$files = array_merge(glob("core/*.php"), glob("ext/*/main.php")); // load base files
foreach($files as $filename) { $files = array_merge(glob("core/*.php"), glob("ext/*/main.php"));
require_once $filename; foreach($files as $filename) {
} require_once $filename;
}
// connect to database // connect to the database
$database = new Database(); $database = new Database();
$database->db->fnExecute = '_count_execs'; $database->db->fnExecute = '_count_execs';
$config = new DatabaseConfig($database); $config = new DatabaseConfig($database);
// load the theme parts // load the theme parts
$_theme = $config->get_string("theme", "default"); $_theme = $config->get_string("theme", "default");
if(!file_exists("themes/$_theme")) $_theme = "default"; if(!file_exists("themes/$_theme")) $_theme = "default";
require_once "themes/$_theme/page.class.php"; require_once "themes/$_theme/page.class.php";
require_once "themes/$_theme/layout.class.php"; require_once "themes/$_theme/layout.class.php";
require_once "themes/$_theme/themelet.class.php"; require_once "themes/$_theme/themelet.class.php";
$themelets = glob("ext/*/theme.php"); $themelets = glob("ext/*/theme.php");
foreach($themelets as $filename) { foreach($themelets as $filename) {
require_once $filename; require_once $filename;
} }
$custom_themelets = glob("themes/$_theme/*.theme.php"); $custom_themelets = glob("themes/$_theme/*.theme.php");
if($custom_themelets) { if($custom_themelets) {
$m = array(); $m = array();
foreach($custom_themelets as $filename) { foreach($custom_themelets as $filename) {
if(preg_match("/themes\/$_theme\/(.*)\.theme\.php/",$filename,$m) if(preg_match("/themes\/$_theme\/(.*)\.theme\.php/",$filename,$m)
&& array_contains($themelets, "ext/{$m[1]}/theme.php")) { && array_contains($themelets, "ext/{$m[1]}/theme.php")) {
require_once $filename; require_once $filename;
}
} }
} }
// start the page generation waterfall
$page = new Page();
$user = _get_user($config, $database);
$context = new RequestContext();
$context->page = $page;
$context->user = $user;
$context->database = $database;
$context->config = $config;
send_event(new InitExtEvent($context));
send_event(_get_page_request($context));
$context->page->display($context);
// for databases which support transactions
$database->db->CommitTrans(true);
}
catch(Exception $e) {
$version = VERSION;
$message = $e->getMessage();
header("HTTP/1.0 500 Internal Error");
print <<<EOD
<html>
<head>
<title>Internal error - SCore-$version</title>
</head>
<body>
<h1>Internal Error</h1>
<p>$message
</body>
</html>
EOD;
} }
// start the page generation waterfall
$page = new Page();
$user = _get_user($config, $database);
$context = new RequestContext();
$context->page = $page;
$context->user = $user;
$context->database = $database;
$context->config = $config;
send_event(new InitExtEvent($context));
send_event(_get_page_request($context));
$page->display();
// for databases which support transactions
$database->db->CommitTrans(true);
?> ?>