예제 #1
0
 private function output($flag = TRUE, $msg = '', $data = array())
 {
     if ($flag) {
         $out = array('flag' => 'success', 'msg' => $msg, 'data' => $data);
     } else {
         $out = array('flag' => 'error', 'msg' => $msg, 'data' => $data);
         Ym_Logger::error($msg);
     }
     Ym_CommonTool::output($this, $out, 'json');
 }
예제 #2
0
파일: Common.php 프로젝트: kaka987/YoungYaf
 public static function output($flag = true, $msg = '', $data = array())
 {
     if ($flag) {
         $out = array('flag' => 'success', 'msg' => $msg, 'data' => $data);
     } else {
         $out = array('flag' => 'error', 'msg' => $msg, 'data' => $data);
         Ym_Logger::error($msg);
     }
     Ym_CommonTool::output(NULL, $out, 'json');
 }
예제 #3
0
 public static function outputJsonp($flag = TRUE, $msg = '', $data = array(), $obj = NULL)
 {
     // output json {"flag":"error","msg":"","data":[]}
     if ($flag) {
         $out = array('flag' => 'success', 'msg' => $msg, 'data' => $data);
     } else {
         $out = array('flag' => 'error', 'msg' => $msg, 'data' => $data);
         Ym_Logger::error($msg);
     }
     Ym_CommonTool::output($obj, $out, 'jsonp');
     exit;
 }
예제 #4
0
 public function modify()
 {
     $business = $this->_request->getPost('business');
     $status = $this->_request->getPost('status');
     $result = false;
     $result = setcookie("url_ids", $business, time() + 3600 * 24, '/');
     /*if ($status == 'close') {
           $result = $this->settingModel->closeBusiness($this->loginUser['id'], $business);
       } else if ($status == 'open') {
           $result = $this->settingModel->openBusiness($this->loginUser['id'], $business);
       }*/
     if ($result) {
         Ym_CommonTool::output($this, array('result' => 'success'), "json");
     } else {
         Ym_CommonTool::output($this, array('result' => 'failed'), "json");
     }
 }
예제 #5
0
파일: Signin.php 프로젝트: kaka987/YoungYaf
 public function execute()
 {
     $this->getView()->setLayout($this->layout);
     // 是否get请求
     if ($this->getRequest()->isPost()) {
         $result = array('result' => 'success', 'text' => '登陆成功!');
         // 获取登陆数据
         $account = $this->getRequest()->getPost();
         // 获取登陆数长度
         $email_lenth = strlen(trim($account['email']));
         $password_length = strlen(trim($account['password']));
         // 格式检查
         if ($email_lenth == 0) {
             $result['result'] = 'error';
             $result['text'] = '邮箱地址格式错误!';
             Ym_CommonTool::output($this, $result, 'json');
         }
         if ($password_length < 6) {
             $result['result'] = 'error';
             $result['text'] = '密码长度不能小于6位字符!';
             Ym_CommonTool::output($this, $result, 'json');
         }
         // 查询用户信息是否存在
         $accountModel = new Model_User_Account();
         $user = $accountModel->getUser($account);
         // 如果用户信息不为空
         if (!empty($user)) {
             // 序列化用户信息到字符串
             $user['loginTime'] = time();
             $accountModel->login($user);
         } else {
             $result['result'] = 'error';
             $result['text'] = '用户名或密码不正确!';
         }
         Ym_CommonTool::output($this, $result, 'json');
     }
 }