当前位置: 首页>>代码示例>>PHP>>正文


PHP Header::json方法代码示例

本文整理汇总了PHP中Header::json方法的典型用法代码示例。如果您正苦于以下问题:PHP Header::json方法的具体用法?PHP Header::json怎么用?PHP Header::json使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Header的用法示例。


在下文中一共展示了Header::json方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: post_signIn

 public function post_signIn()
 {
     Header::json();
     $email = $this->request->post('email', FILTER_VALIDATE_EMAIL);
     $password = $this->request->post('password');
     $rememberEmail = $this->request->post('remember_email', FILTER_VALIDATE_BOOLEAN);
     if (!$email || !$password) {
         die('{ "ok" : false, "msg" : "Invalid login" }');
     }
     try {
         $user = $this->orm->support_user();
         $user->select('id_support_user, name, sex');
         $user->where('email', $email);
         $user->and('password', md5($password));
         $user->and('active', 1);
         $row = $user->fetch();
         if ($row) {
             $row->update(array('online' => 0, 'last_activity' => new NotORM_Literal('NOW()')));
             unset($_SESSION['client_user']);
             $_SESSION['support_user'] = array('id_user' => $row['id_support_user'], 'name' => $row['name'], 'sex' => $row['sex']);
             if ($rememberEmail) {
                 $timeCookie = time() + 60 * 60 * 24 * 20;
                 # 20 days
                 setcookie('email', $email, $timeCookie, null, $_SERVER['HTTP_HOST']);
             } else {
                 $timeCookie = time() - 60 * 60 * 24;
                 # Delete
                 setcookie('email', $email, $timeCookie, null, $_SERVER['HTTP_HOST']);
             }
             print '{ "ok" : true }';
         } else {
             print '{ "ok" : false, "msg" : "Invalid login" }';
         }
     } catch (Exception $e) {
         print '{ "ok" : false, "msg" : "Error occurred" }';
     }
 }
开发者ID:sandroalvesperes,项目名称:chat,代码行数:37,代码来源:Login.php

示例2: post_editUser

 public function post_editUser()
 {
     Header::json();
     try {
         $idSupportUser = $this->request->post('id_support_user', FILTER_VALIDATE_INT);
         $name = $this->request->post('name');
         $email = $this->request->post('email', FILTER_VALIDATE_EMAIL);
         $sex = $this->request->post('sex');
         $password = $this->request->post('password');
         $active = $this->request->post('active', FILTER_VALIDATE_BOOLEAN);
         $accessMaintainUser = $this->request->post('access_maintain_user', FILTER_VALIDATE_BOOLEAN);
         $accessSupportStatus = $this->request->post('access_support_status', FILTER_VALIDATE_BOOLEAN);
         # Check whether the e-mail already exists
         # ------------------------------------------------------------------
         $supportUser = $this->orm->support_user();
         $supportUser->where('email', $email);
         $supportUser->and('id_support_user <> ?', $idSupportUser);
         if ($supportUser->count('*') > 0) {
             exit('{ "ok" : false, "msg" : "E-mail already exists" }');
         }
         $this->orm->transaction = 'begin';
         $this->orm->support_user[$idSupportUser]->update(array('name' => $name, 'email' => $email, 'sex' => $sex, 'password' => empty($password) ? new NotORM_Literal('password') : md5($password), 'active' => $active));
         $this->orm->support_user_access()->where('id_support_user', $idSupportUser)->update(array('maintain_user' => $accessMaintainUser, 'support_status' => $accessSupportStatus));
         $this->orm->transaction = 'commit';
         print '{ "ok" : true }';
     } catch (Exception $e) {
         print '{ "ok" : false, "msg" : "Error occurred" }';
     }
 }
开发者ID:sandroalvesperes,项目名称:chat,代码行数:29,代码来源:Users.php

示例3: post_evaluateSupport

 public function post_evaluateSupport()
 {
     Header::json();
     try {
         $rate = $this->request->post('rate', FILTER_VALIDATE_INT);
         $this->orm->chat[$_SESSION['chat_evaluate']['id_chat']]->update(array('rate' => $rate));
         unset($_SESSION['chat_evaluate']);
         print '{ "ok" : true }';
     } catch (Exception $e) {
         print '{ "ok" : false, "msg" : "Error occurred" }';
     }
 }
开发者ID:sandroalvesperes,项目名称:chat,代码行数:12,代码来源:Conversation.php

示例4: post_information

 public function post_information()
 {
     Header::json();
     try {
         $email = $this->request->post('email', FILTER_VALIDATE_EMAIL);
         $clientUser = $this->orm->client_user();
         $clientUser->select('name, sex');
         $clientUser->where('email', $email);
         $clientUser = $clientUser->fetch();
         if (!$clientUser) {
             exit('{ "ok" : false }');
         }
         print json_encode(array('ok' => true, 'name' => $clientUser['name'], 'sex' => $clientUser['sex']));
     } catch (Exception $e) {
         print '{ "ok" : false }';
     }
 }
开发者ID:sandroalvesperes,项目名称:chat,代码行数:17,代码来源:Client.php

示例5: post_checkSupportInactivity

 public function post_checkSupportInactivity()
 {
     Header::json();
     try {
         $timeLimit = $this->orm->param[array('name' => 'SET_OFFLINE_IN')]['value'];
         $supportUser = $this->orm->support_user();
         $supportUser->where('online', 1);
         $supportUser->and('TIMESTAMPDIFF(MINUTE, last_activity, NOW()) > ?', $timeLimit);
         $supportUser->update(array('typing' => 0, 'online' => 0));
         print '{ "ok" : true }';
     } catch (Exception $e) {
         print '{ "ok" : false }';
     }
 }
开发者ID:sandroalvesperes,项目名称:chat,代码行数:14,代码来源:Support.php


注:本文中的Header::json方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。