本文整理汇总了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" }';
}
}
示例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" }';
}
}
示例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" }';
}
}
示例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 }';
}
}
示例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 }';
}
}