private function runModule()
 {
     switch ($this->sModule) {
         case "Home":
             $oController = new HomeController();
             $oController->run($this->sAction, $this->asArgs, $this->sView);
             break;
         case "ShowRoom":
             $oController = new ShowRoomController();
             $oController->run($this->sAction, $this->asArgs, $this->sView);
             break;
         case "Basic":
             $oController = new BasicController();
             $oController->run($this->sAction, $this->asArgs, $this->sView);
             break;
         case "Products":
             $oController = new ProdutosController();
             $oController->run($this->sAction, $this->asArgs, $this->sView);
             break;
         default:
             echo "Erro: Módulo não existe";
     }
     /* switch ( $this->sModule ) */
 }
 public function __call($name, $arguments)
 {
     if (preg_match("/^findby/i", $name)) {
         $name = BasicController::orm(lcfirst(substr($name, 6)));
         $value = $arguments[0];
         $where = '';
         foreach ($value as $key => $val) {
             if (preg_match('/$[0-9]^/', $val)) {
                 $where .= $key . "=" . $val;
             } else {
                 $where .= $key . "='" . $val . "'";
             }
             break;
         }
         $objs = $this->dao->findByWhere($where);
         return $objs;
     }
     return false;
 }
 public function __construct()
 {
     parent::__construct();
 }
Exemple #4
0
 function __construct()
 {
     parent::__construct();
     $this->assign('opciones', array('Inicio' => 'inicio', 'Equipos' => 'equipo', 'Miembros' => 'miembro', 'Inscripciones' => 'carreraConInscripciones', 'Clasificaciones' => 'carreraConLlegadas', 'Calendario' => 'calendario', 'Fotos' => 'foto', 'Galeria' => 'galeria', 'Videos' => 'video', 'Usuarios' => 'usuario', 'Login' => 'login', 'Logout' => 'logout'));
 }
 public function initialize()
 {
     parent::initialize();
     $this->beforeFilters->skip('ensureLogin');
     $this->afterFilters->skip('cleanUp');
 }
Exemple #6
0
    }
}
$controller_map = array('categories' => 'category', 'products' => 'product', 'qiniu' => 'qiniu');
try {
    $request_method = $_SERVER['REQUEST_METHOD'];
    $uri = $_SERVER['REQUEST_URI'];
    //比如 /users/1
    $pos = strpos($uri, '?');
    if ($pos !== false) {
        $uri = substr($uri, 0, $pos);
    }
    $uri_array = explode('/', $uri);
    //移除空
    array_shift($uri_array);
    //结果array('users', '1')
    //判断类是否存在
    if (!isset($controller_map[$uri_array[0]])) {
        throw new ControllerException(501);
    }
    $controller_prefix = $controller_map[$uri_array[0]];
    $class_name = StrLib::underlineToClassName($controller_map[$uri_array[0]]) . 'Controller';
    $controller = new $class_name();
    $data = $controller->router($uri);
    $result = array('result' => array('status' => array('code' => 200, 'msg' => ''), 'data' => $data));
    BasicController::output($result, $content_type);
} catch (ControllerException $e) {
    $error = $e->getMessage();
    $data = array('result' => array('status' => json_decode($error, true)));
    BasicController::output($data, $content_type);
}
exit;
 function __construct()
 {
     parent::__construct();
     $this->assign('opciones', array('Inicio' => 'inicio', 'Fotos' => 'foto', 'Pilotos' => 'piloto', 'Pruebas' => 'prueba', 'Inscripciones' => 'carreraConInscripciones', 'Clasificaciones' => 'carreraConLlegadas', 'Foro' => 'noticia', 'Usuarios' => 'usuario', 'Login' => 'login', 'Logout' => 'logout'));
 }
Exemple #8
0
 /**
  * 异步轮询消息
  */
 public function getMsgAction()
 {
     Yaf_Dispatcher::getInstance()->disableView();
     if (!$this->getRequest()->isXmlHttpRequest()) {
         parent::notify("页面不存在");
     }
     $uid = $this->getSession("uid");
     $redis = Yaf_Registry::get('redis');
     $msg = $redis->get("message_" . $uid);
     if ($msg) {
         $data = json_decode($msg, true);
         if (!$data["comment"]["status"]) {
             //$data["comment"]["status"]=0;//标记为已读
             $redis->set("message_" . $uid, json_encode($data));
             echo json_encode(array("status" => 1, "total" => $data["comment"]["total"], "type" => 1));
             exit;
         }
         if (!$data["reply"]["status"]) {
             //$data["reply"]["status"]=0;//标记为已读
             $redis->set("message_" . $uid, json_encode($data));
             echo json_encode(array("status" => 1, "total" => $data["reply"]["total"], "type" => 2));
             exit;
         }
     }
 }
 /**
  * 检查登录,如果未登录则输出status code 401,退出。
  */
 public function checkLogin()
 {
     $auth = self::$input['auth'];
     $is_auth_valid = AuthModel::isAuthValid($auth);
     if ($is_auth_valid === false) {
         throw new ExceptionLib('401');
     }
     self::$decoded_auth = AuthModel::decodeAuth($auth);
     return true;
 }
Exemple #10
0
 public function handleEditArticleAction()
 {
     if (!$this->getRequest()->isXmlHttpRequest()) {
         parent::notify("页面不存在");
         return false;
     }
     $uid = $this->getSession("uid");
     $email = $this->getSession("email");
     if (!isset($uid) || empty($uid) || !isset($email) || empty($email)) {
         $this->notify("请先登录", "http://" . $_SERVER["HTTP_HOST"] . "/login");
         return false;
     }
     Yaf_Dispatcher::getInstance()->disableView();
     $id = parent::getPost("id");
     $article = $this->m_study->Where("id=" . $id . " AND uid=" . $uid)->SelectOne();
     if (!$article) {
         die(json_encode(array("status" => 0, "msg" => "只能编辑自己的文章")));
     }
     if (!intval($article["status"])) {
         $this->notify("页面不存在");
         Yaf_Dispatcher::getInstance()->disableView();
         return false;
     }
     $title = parent::getPost("title");
     $category = (int) parent::getPost("category");
     $brief = parent::getPost("brief");
     $content = deep_htmlspecialchars(parent::getPost("content", false));
     $result = $this->m_study->UpdateByID(array("study_name" => $title, "sort_id" => $category, "content" => $content, "brief" => $brief), $id);
     if ($result) {
         die(json_encode(array("status" => 1, "msg" => "编辑文章成功", "url" => "http://" . $_SERVER["HTTP_HOST"] . "/study/detail?id=" . $id)));
     } else {
         die(json_encode(array("status" => 0, "msg" => "编辑文章失败")));
     }
 }
Exemple #11
0
 public function handleThreeAction()
 {
     Yaf_Dispatcher::getInstance()->disableView();
     $openid = parent::getPost("openid");
     $token = parent::getPost("token");
     $type = parent::getPost("type");
     $username = parent::getPost("username");
     if (!regex($username, "require")) {
         die(json_encode(array("status" => 0, "msg" => "昵称不能为空")));
     }
     $email = parent::getPost("email");
     if (!regex($email, "require")) {
         die(json_encode(array("status" => 0, "msg" => "邮箱不能为空")));
     }
     if (!regex($email, "email")) {
         die(json_encode(array("status" => 0, "msg" => "邮箱格式不正确")));
     }
     $exist_email = $this->m_user->Where("email='" . $email . "'")->Field("id")->SelectOne();
     if ($exist_email) {
         die(json_encode(array("status" => 0, "msg" => "邮箱已经注册过,请直接登录,如果忘记密码,请点击找回密码")));
     }
     $exist_username = $this->m_user->Where("username='******'")->Field("id")->SelectOne();
     if ($exist_username) {
         die(json_encode(array("status" => 0, "msg" => "昵称已经存在,请换一个")));
     }
     $result = $this->m_user->Insert(array("email" => $email, "avatar" => "/img/face.jpg", "brief" => "这家伙有点懒,还没有写个性签名! ", "username" => $username, "reg_time" => time(), "login_time" => time(), "login_ip" => getClientIP(), "reg_type" => 2));
     if ($result) {
         $model_user_three = $this->load('user_three');
         $model_user_three->Insert(array("user_id" => $result, "openid" => $openid, "type" => $type));
         //写入session
         parent::setSession('uid', $result);
         parent::setSession('email', $email);
         die(json_encode(array("status" => 1, "msg" => "绑定QQ成功。")));
     } else {
         die(json_encode(array("status" => 0, "msg" => "绑定QQ失败,请稍后再试...")));
     }
 }