Example #1
0
 public function execute($args = null)
 {
     if (!ServiceAuth::getInstance()->isAuth()) {
         header('Location: /login');
     } else {
         if (empty($_POST)) {
             return ServiceRenderHtml::newInstance()->load('search')->render();
         }
         $res = array();
         if (isset($_POST['search1'])) {
             $res = CollectionProfile::newInstance()->findByWithUser('prog', $_POST['prog']);
         } elseif (isset($_POST['search2'])) {
             $res = CollectionProfile::newInstance()->findByWithUser(array('prog', 'semester'), array($_POST['prog'], $_POST['semester']));
         } elseif (isset($_POST['search3'])) {
             $res = CollectionProfile::newInstance()->findByWithUser('sex', $_POST['sex']);
         } elseif (isset($_POST['search4'])) {
             $resx = CollectionUser_has_user::newInstance()->findByWithUserLoose('user_id1', ServiceAuth::getInstance()->getUser()->getId());
             foreach ($resx as $v) {
                 $res[] = $v->getUser2();
             }
         } elseif (isset($_POST['search5'])) {
             $res = CollectionProfile::newInstance()->findAllWithUser();
         } else {
             return ControllerError::newInstance()->execute($args);
         }
         $_SESSION['search'] = $res;
         header('Location: /search/result');
     }
 }
Example #2
0
 public function execute($args = null)
 {
     $v = $this->getQueryNext();
     if (in_array($v, array('add', 'del'))) {
         $this->{$v}($args);
     } else {
         ControllerError::newInstance()->execute();
     }
 }
Example #3
0
<?php

require_once 'inc.php';
$_POST = @array_map_recursive('trim', $_POST);
$_GET = @array_map_recursive('trim', $_GET);
$query = isset($_GET['q']) ? $_GET['q'] : 'home';
$query = rtrim($query, '/');
$query = mb_strtolower($query);
$query = explode('/', $query);
try {
    $a = Controller::main($query);
    session_start();
    ob_start();
    $a->execute();
    ob_end_flush();
} catch (UnknownClass $e) {
    ob_end_clean();
    ControllerLost::newInstance()->execute($e);
} catch (Exception $e) {
    ob_end_clean();
    ControllerError::newInstance()->execute($e);
}