<?php /* * index.php * Main HTTP request handler * * Copyright Gottfried Haider, Danja Vasiliev 2010. * This source code is licensed under the GNU General Public License. * See the file COPYING for more details. */ @(require_once 'config.inc.php'); require_once 'log.inc.php'; log_msg('info', '--- request ---'); require_once 'controller.inc.php'; require_once 'modules.inc.php'; $args = parse_query_string(); log_msg('info', 'index: query arguments ' . var_dump_inl($args)); log_msg('debug', 'index: base url is ' . quot(base_url())); invoke_controller($args);
/** * this is the default (fallback) controller * * it mainly invokes other controllers or sends error messages */ function controller_default($args) { if (empty($args[0][0]) && empty($args[0][1])) { // take the default page $args[0][0] = startpage(); log_msg('debug', 'controller_default: using the default page'); } elseif ($args[0][0] == 'edit' && empty($args[0][1])) { // quirk: edit the default page $args[0][0] = startpage(); $args[0][1] = 'edit'; log_msg('debug', 'controller_default: using the default page'); invoke_controller($args); return; } page_canonical($args[0][0]); $obj = expl('.', $args[0][0]); if (count($obj) == 2) { // page requested if (page_exists($args[0][0])) { if (DEFAULT_TO_EDIT && is_auth()) { log_msg('debug', 'controller_default: invoking controller_edit'); controller_edit($args); } else { log_msg('debug', 'controller_default: invoking controller_show'); controller_show($args); } } elseif (ALWAYS_PROMPT_CREATE_PAGE || is_auth() || $args[0][0] == startpage()) { log_msg('debug', 'controller_default: invoking controller_create_page'); controller_create_page($args); } else { log_msg('info', 'controller_default: page ' . quot($args[0][0]) . ' not found, serving 404'); hotglue_error(404); } } else { // possibly object requested if (object_exists($args[0][0])) { // try to serve upload if (isset($args['download']) && $args['download']) { // prompt file save dialog on client $dl = true; } else { $dl = false; } log_msg('debug', 'controller_default: invoking serve_resource'); if (!serve_resource($args[0][0], $dl)) { log_msg('info', 'controller_default: object ' . quot($args[0][0]) . ' has no associated resource, serving 404'); hotglue_error(404); } } else { log_msg('info', 'controller_default: object ' . quot($args[0][0]) . ' not found, serving 404'); hotglue_error(404); } } }