diff --git a/core/page.class.php b/core/page.class.php index 0cf91da3..d18c5f6d 100644 --- a/core/page.class.php +++ b/core/page.class.php @@ -70,9 +70,9 @@ class GenericPage { // ============================================== - public function display() { + public function display($context) { header("Content-type: {$this->type}"); - header("X-Powered-By: Shimmie-".VERSION); + header("X-Powered-By: SCore-".SCORE_VERSION); switch($this->mode) { case "page": diff --git a/index.php b/index.php index 839230ed..bb1fef13 100644 --- a/index.php +++ b/index.php @@ -1,64 +1,87 @@ db->fnExecute = '_count_execs'; -$config = new DatabaseConfig($database); + // connect to the database + $database = new Database(); + $database->db->fnExecute = '_count_execs'; + $config = new DatabaseConfig($database); -// load the theme parts -$_theme = $config->get_string("theme", "default"); -if(!file_exists("themes/$_theme")) $_theme = "default"; -require_once "themes/$_theme/page.class.php"; -require_once "themes/$_theme/layout.class.php"; -require_once "themes/$_theme/themelet.class.php"; + // load the theme parts + $_theme = $config->get_string("theme", "default"); + if(!file_exists("themes/$_theme")) $_theme = "default"; + require_once "themes/$_theme/page.class.php"; + require_once "themes/$_theme/layout.class.php"; + require_once "themes/$_theme/themelet.class.php"; -$themelets = glob("ext/*/theme.php"); -foreach($themelets as $filename) { - require_once $filename; -} + $themelets = glob("ext/*/theme.php"); + foreach($themelets as $filename) { + require_once $filename; + } -$custom_themelets = glob("themes/$_theme/*.theme.php"); -if($custom_themelets) { - $m = array(); - foreach($custom_themelets as $filename) { - if(preg_match("/themes\/$_theme\/(.*)\.theme\.php/",$filename,$m) - && array_contains($themelets, "ext/{$m[1]}/theme.php")) { - require_once $filename; + $custom_themelets = glob("themes/$_theme/*.theme.php"); + if($custom_themelets) { + $m = array(); + foreach($custom_themelets as $filename) { + if(preg_match("/themes\/$_theme\/(.*)\.theme\.php/",$filename,$m) + && array_contains($themelets, "ext/{$m[1]}/theme.php")) { + 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 << + + Internal error - SCore-$version + + +

Internal Error

+

$message + + +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); ?>