예제 #1
0
 public function handlePacket()
 {
     global $sUser, $sDB, $sQuery, $sTemplate, $sLog, $sRequest, $sPage;
     $this->pageTitle = $sRequest->getString("pageTitle");
     if (!$this->pageTitle) {
         $this->pageTitle = "default";
     }
     $res = $sDB->exec("SELECT * FROM `pages` WHERE `pageTitle` = '" . mysql_real_escape_string($this->pageTitle) . "' LIMIT 1;");
     if (mysql_num_rows($res)) {
         $row = mysql_fetch_object($res);
         $className = $row->className;
         $sPage = new $className($row);
         if (!$sPage->canView()) {
             $sPage = new PageError($sPage->error());
         }
     } else {
         $sPage = new PageError($sTemplate->getString("PAGE_ERROR_INVALID_PAGE"));
     }
 }
예제 #2
0
 function exam()
 {
     if (!$_SESSION['valid']) {
         header("Location:/login");
     }
     $req_uri = explode('/', $_SERVER['REQUEST_URI']);
     $examid = is_numeric($req_uri[3]) ? $req_uri[3] : -1;
     if ($examid > 0) {
         $exinfo = $this->db->query("SELECT * FROM `exam` WHERE `id` = {$examid};");
         if ($exinfo->num_rows) {
             //Load Test Page
             $ex_info = mysqli_fetch_assoc($exinfo);
             require 'views/~testroom_exam.php';
         } else {
             PageError::HttpError(410);
         }
     } else {
         PageError::HttpError(410);
     }
 }
예제 #3
0
// register the Twig Autoloader
Twig_Autoloader::register();
// Create a new instance of Router
$router = new Router();
// Get an instance of Dispatcher
$dispatcher = new Dispatcher();
$dispatcher->setSuffix('Controller');
$dispatcher->setClassPath(CONTROLLER_DIR);
// Set up your default route:
$default_route = new Route('/');
$default_route->setMapClass('default')->setMapMethod('index');
$router->addRoute('default', $default_route);
$url = urldecode($_SERVER['REQUEST_URI']);
try {
    $found_route = $router->findRoute($url);
    $dispatcher->dispatch($found_route);
} catch (RouteNotFoundException $e) {
    PageError::show('404', $url);
} catch (badClassNameException $e) {
    PageError::show('400', $url);
} catch (classFileNotFoundException $e) {
    PageError::show('500', $url);
} catch (classNameNotFoundException $e) {
    PageError::show('500', $url);
} catch (classMethodNotFoundException $e) {
    PageError::show('500', $url);
} catch (classNotSpecifiedException $e) {
    PageError::show('500', $url);
} catch (methodNotSpecifiedException $e) {
    PageError::show('500', $url);
}
예제 #4
0
 function p404()
 {
     PageError::p404();
 }
 /** 
  * If a fatal error occurs generate PageError or redirect to LoginPanel
  */
 function checkFatalError($type)
 {
     if (in_array($type, $this->fatalErrors)) {
         if ($type == 'noLogin' && strpos($_SERVER['QUERY_STRING'], 'redirect') === FALSE) {
             global $CONFIG_TAB_ROOT;
             header('Location: ' . $CONFIG_TAB_ROOT . 'user/login.php?redirect=' . urlencode($_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING']));
             exit;
         }
         $errorPage = new PageError($this);
         echo $errorPage->create();
         /* echo '<pre>';
            var_dump(debug_backtrace());
            echo '</pre>'; */
         exit;
     }
 }
예제 #6
0
//URL Parser
//Define $req_uri
//
//REQUEST_URI
$req_uri_clearq = explode('?', $_SERVER['REQUEST_URI']);
$req_uri_clearm = explode(':', $req_uri_clearq[0]);
$req_uri = array_slice(explode('/', $req_uri_clearm[0]), 1);
//
$_GET['_controller'] = @$req_uri[0];
$_GET['_action'] = @$req_uri[1];
if (empty($_GET['_controller'])) {
    $_GET['_controller'] = DEFAULT_CONTROLLER;
    require dirname(__FILE__) . '/../controller/' . $_GET['_controller'] . '.php';
    $page = new $_GET['_controller']();
    $_pHandle = $page->_default(@$req_uri_clearm[1]);
} else {
    $fp_file = dirname(__FILE__) . '/../controller/' . $_GET['_controller'] . '.php';
    $fp = @fopen($fp_file, 'r');
    if ($fp) {
        require dirname(__FILE__) . '/../controller/' . $_GET['_controller'] . '.php';
        if (empty($_GET['_action'])) {
            $page = new $_GET['_controller']();
            $_pHandle = $page->_default(@$req_uri_clearm[1]);
        } else {
            $page = new $_GET['_controller']();
            $_pHandle = $page->{$_GET}['_action'](@$req_uri_clearm[1]);
        }
    } else {
        PageError::HttpError(404);
    }
}