* @author Pablo Fischer * @author Helgi Žormar * @copyright 2005-2007 Jaws Development Group * @license http://www.gnu.org/copyleft/lesser.html */ define('JAWS_SCRIPT', 'index.php'); $current = dirname(__FILE__); // Redirect to the installer if JawsConfig can't be found. if (!file_exists($current . '/config/JawsConfig.php')) { header('Location: install.php'); } require_once $current . '/include/JawsInitApplication.php'; if ($GLOBALS['app']->Registry->Get('/version') != JAWS_VERSION) { header('Location: upgrade.php'); } if (DEBUG_ACTIVATED) { // Log start time (microseconds) $mtime = microtime(); $mtime = explode(' ', $mtime); $mtime = (double) $mtime[0] + $mtime[1]; $tstart = $mtime; } require_once JAWS_PATH . 'include/JawsGadgetHTML.php'; $GLOBALS['app']->SetApplicationType('web'); $GLOBALS['app']->Map->Parse(); // Manage user session stuff require_once 'include/SessionTypes/WebSession.php'; $GLOBALS['session'] =& new WebSession(true); // Init layout... $GLOBALS['app']->InstanceLayout(); $GLOBALS['app']->Layout->Load(); $request =& JawsRequest::getInstance(); $get_gadget = $request->get('gadget', 'get'); if ($get_gadget !== null) { $gadget = $get_gadget; } else { $post_gadget = $request->get('gadget', 'post'); $gadget = $post_gadget !== null ? $post_gadget : ''; } $get_action = $request->get('action', 'get'); if ($get_action !== null) { $action = $get_action; } else { $post_action = $request->get('action', 'post'); $action = $post_action !== null ? $post_action : ''; } // Check for requested gadget if (!empty($gadget)) { // Convert first letter to ucase to backwards compability $ReqGadget = ucfirst($gadget); if (!JawsGadget::IsValid($ReqGadget)) { JawsError::Fatal("Invalid requested gadget", __FILE__, __LINE__); } $ReqAction = !empty($action) ? $action : 'DefaultAction'; $am_i_index = false; } else { $ReqGadget = $GLOBALS['app']->Registry->Get('/config/main_gadget'); if ($ReqGadget) { $am_i_index = true; if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) { // We're requesting something weird... let's return a 404. $ReqAction = '_404'; } else { $ReqAction = 'DefaultAction'; } } else { JawsError::Fatal("No default gadget is set, please activate a gadget in the control panel.", __FILE__, __LINE__); } } if (empty($ReqGadget)) { JawsError::Fatal("Empty gadget, Registry or a missed table problem", __FILE__, __LINE__); } $goGadget = $GLOBALS['app']->LoadGadget($ReqGadget); if (JawsError::IsError($goGadget)) { JawsError::Fatal("Error loading gadget: $ReqGadget", __FILE__, __LINE__); } $anonCanRegister = $GLOBALS['app']->Registry->Get('/config/anon_register'); if ($ReqGadget == 'Users' && $anonCanRegister == 'false') { //Send user to a 404 page $ReqAction = '_404'; } $goGadget->SetAction($ReqAction); $action = $goGadget->GetAction(); $standAloneMode = $goGadget->isStandAlone($action); // If requested action is `stand alone' just print it if ($standAloneMode) { echo $goGadget->Execute(); } else { // If requested action if (!$goGadget->IsNormal($action)) { JawsError::Fatal("Invalid operation: You can't execute requested action. This action is part of admin or ". "can only be used in the layout (not via the URL)", __FILE__, __LINE__); } $GLOBALS['app']->Layout->Populate($goGadget, $am_i_index); $GLOBALS['app']->Layout->Show(); } // Sync session $GLOBALS['session']->Synchronize(); if (DEBUG_ACTIVATED) { // Log generation time $mtime = microtime(); $mtime = explode(' ', $mtime); $mtime = $mtime[1] + $mtime[0]; $tend = $mtime; $totaltime = ($tend - $tstart); // Log end time $GLOBALS['log']->Log(JAWS_LOG_INFO, "Page was generated in {$totaltime} seconds"); $GLOBALS['log']->Log(JAWS_LOG_INFO,'[Jaws End] ' . date('M/d/Y H:i:s') . ':' . __FILE__ . ':' . __LINE__); if (function_exists('memory_get_usage')) { $GLOBALS['log']->Log(JAWS_LOG_INFO, 'Memory Usage: ' . round(memory_get_usage() / 1024 / 1024, 2) . 'MB'); } $GLOBALS['log']->LogStackToScreen(); }