本文整理汇总了PHP中json_error函数的典型用法代码示例。如果您正苦于以下问题:PHP json_error函数的具体用法?PHP json_error怎么用?PHP json_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了json_error函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: login
public function login()
{
$username = jget('username', 'txt');
$password = jget('password');
$openid = jget('openid');
if ($username == "" || $password == "") {
json_error("无法登录,用户名或密码不能为空");
}
if ($this->Config['login_by_uid']) {
is_numeric($username) && json_error("禁止使用UID登录");
}
if ($GLOBALS['_J']['plugins']['func']['login']) {
hookscript('login', 'funcs', array('param' => $this->Post, 'step' => 'check'), 'login');
}
$rets = jsg_member_login($username, $password);
$uid = (int) $rets['uid'];
if ($uid < 1) {
json_error(array_iconv($this->Config['charset'], 'utf-8', $rets['error']));
}
$r = false;
if ($openid && $uid) {
$r = jlogic('wechat')->do_bind($openid, $uid);
}
if ($r) {
json_result("绑定成功!");
} else {
json_error("绑定失败!");
}
}
示例2: run
public function run()
{
header('Access-Control-Allow-Origin: *');
date_default_timezone_set('Asia/Seoul');
user()->login();
if ($model = http_input('model')) {
list($model_name, $class_name, $method_name) = explode('.', $model);
$uc_first_class_name = ucfirst($class_name);
$namespace = "of\\{$model_name}\\{$uc_first_class_name}";
$obj = new $namespace();
return $obj->{$method_name}();
}
switch ($doing = http_input('do')) {
default:
if (strpos($doing, '.')) {
$doing = str_replace('.', '\\', $doing);
} else {
$doing = ucfirst($doing);
}
$name = "of\\{$doing}";
$obj = new $name();
$obj->runAjax();
json_error(-40444, "Nothing to do");
return null;
}
}
示例3: executeImpl
protected function executeImpl(ArrayAdapter $params)
{
$action = $params->str('action');
$gallery = $params->str('gallery');
switch ($action) {
case 'creategall':
PsGallery::makeNew($gallery, $params->str('name'));
break;
case 'save':
PsGallery::inst($gallery)->saveGallery($params->str('name'), $params->arr('images'));
break;
case 'imgadd':
PsGallery::inst($gallery)->addWebImg($params->arr('img'));
break;
case 'imgdel':
if ($params->bool('web')) {
PsGallery::inst($gallery)->deleteWebImg($params->str('file'));
} else {
PsGallery::inst($gallery)->deleteLocalImg($params->str('file'));
}
break;
default:
json_error("Unknown action [{$action}].");
}
return new AjaxSuccess();
}
示例4: login
/**
* 로그인 과정을 진행한다.
*
* 입력 정보는 HTTP input 의 idx_member 와 session_id 로 들어오며,
* 회원 정보를 $sys->member 에 저장하고,
* 회원 번호를 리턴한다.
*
* 이것은 module/ajax/DataLayer.php 의 회원 로그인과 비슷하며,
*
* ajax 의 model=.... 와 같이 호출하는 경우, overframe/ajax/Ajax.php 의 run() 에 의해서 호출된다.
*
* @return mixed 회원번호 또는 ajax 에러 메세지.
*/
public function login()
{
global $sys;
$in = http_input();
$in['remember'] = 'Y';
sys()->log(" =========> UserLayer::login() in: ");
if (empty($in['idx_member'])) {
return FALSE;
}
if (isset($in['idx_member']) && $in['idx_member'] && isset($in['session_id'])) {
$member = $sys->member->get($in['idx_member']);
if (empty($member)) {
json_error(-508, "User not found. Wrong idx_member.");
}
if ($this->session_id($member) != $in['session_id']) {
json_error(-507, "Wrong user session id. Your IP and location information has been reported to admin.");
}
} else {
sys()->log(" =====> No. login. in[idx_member] and in[action] is not member_register_submit, in[id], in[password] is empty. ");
return FALSE;
}
$sys->member->idx = $member['idx'];
$sys->member->info = $member;
return $sys->member->idx;
}
示例5: checkAuth
/**
* Validate the provided API key.
*/
public function checkAuth()
{
$api = new API();
$api->key = $_GET['key'];
try {
$api->validate_key();
} catch (Exception $e) {
json_error($e->getMessage());
die;
}
}
示例6: check_object
/**
* Check that the object can be accessed.
*
* @param mixed $id Object ID
* @return boolean|WP_Error
*/
protected function check_object($id)
{
$id = (int) $id;
$post = get_post($id, ARRAY_A);
if (empty($id) || empty($post['ID'])) {
json_error(BigAppErr::$post['code'], BigAppErr::$post['msg'], "empty {$id}");
}
if (!json_check_post_permission($post, 'edit')) {
json_error(BigAppErr::$post['code'], BigAppErr::$post['msg'], "cant read:{$id}");
}
return true;
}
示例7: do_upload_avatar
function do_upload_avatar()
{
$cleaned = vB::getCleaner()->cleanArray($_REQUEST, array('upload' => vB_Cleaner::TYPE_FILE));
if (empty($cleaned['upload'])) {
return json_error(ERR_NO_PERMISSION);
}
$upload_result = vB_Api::instance('profile')->upload($cleaned['upload']);
if (!empty($upload_result['errors'])) {
return json_error(ERR_NO_PERMISSION);
}
return true;
}
示例8: execute_ajax_action
/**
* Выполнение ajax действия
*
* @param AjaxClassProvider $provider
*/
function execute_ajax_action(AbstractAjaxAction $action = null)
{
/* Для безопасности не будем писать детали обработки */
if (!$action) {
json_error('Действие не опеределено');
}
$result = $action->execute();
$result = $result ? $result : 'Ошибка выполнения действия';
if ($result instanceof AjaxSuccess) {
json_success($result->getJsParams());
}
json_error($result);
}
示例9: handle
function handle($args)
{
/*
* Make sure we have a search term.
*/
if (!isset($args['term']) || empty($args['term'])) {
json_error('Search term not provided.');
die;
}
/*
* Clean up the search term.
*/
$term = filter_var($args['term'], FILTER_SANITIZE_STRING);
/*
* Append an asterix to the search term, so that Solr can suggest autocomplete terms.
*/
$term .= '*';
/*
* Intialize Solarium.
*/
$client = new Solarium_Client($GLOBALS['solr_config']);
/*
* Set up our query.
*/
$query = $client->createSuggester();
$query->setHandler('suggest');
$query->setQuery($term);
$query->setOnlyMorePopular(TRUE);
$query->setCount(5);
$query->setCollate(TRUE);
/*
* Execute the query.
*/
$search_results = $client->suggester($query);
/*
* If there are no results.
*/
if (count($search_results) == 0) {
$response->terms = FALSE;
} else {
$response->terms = array();
foreach ($search_results as $term => $term_result) {
$i = 0;
foreach ($term_result as $suggestion) {
$response->terms[] = array('id' => $i, 'term' => $suggestion);
$i++;
}
}
}
$this->render($response, 'OK');
}
示例10: process_work
function process_work($pdo, $worker_id, $pool_id, $response, $json_id)
{
$q = $pdo->prepare('
INSERT IGNORE INTO work_data
(worker_id, pool_id, data, time_requested)
VALUES
(:worker_id, :pool_id, :data, UTC_TIMESTAMP())
');
$data = strtolower(substr($response->result->data, 0, 152));
if (!$q->execute(array(':worker_id' => $worker_id, ':pool_id' => $pool_id, ':data' => $data))) {
json_error('Database error on INSERT into work_data: ' . json_encode($q->errorInfo()), $json_id);
}
}
示例11: set_ak_sk
/**
* 设置AK SK
* @param ak,sk
*/
public function set_ak_sk($ak, $sk)
{
$ak = trim($ak);
$sk = trim($sk);
$st = false;
if (strlen($ak) == 32 && strlen($sk) == 32) {
$ak_sk = array('ak' => $ak, 'sk' => $sk);
$st = update_option("bigapp_ak_sk", json_encode($ak_sk));
$st = true;
} else {
json_error(BigAppErr::$server['code'], __lan("app key/app secret format is wrong"), "");
}
return $st;
}
示例12: do_subscribe_thread
function do_subscribe_thread()
{
$userinfo = vB_Api::instance('user')->fetchUserInfo();
if ($userinfo['userid'] < 1) {
return json_error(ERR_NO_PERMISSION);
}
$cleaned = vB::getCleaner()->cleanArray($_REQUEST, array('threadid' => vB_Cleaner::TYPE_UINT));
if (empty($cleaned['threadid'])) {
return json_error(ERR_INVALID_SUB);
}
$result = vB_Api::instance('follow')->add($cleaned['threadid'], vB_Api_Follow::FOLLOWTYPE_CONTENT);
if (empty($result) || !empty($result['errors'])) {
return json_error(ERR_INVALID_SUB);
}
return true;
}
示例13: do_get_announcement
function do_get_announcement()
{
$cleaned = vB::getCleaner()->cleanArray($_REQUEST, array('forumid' => vB_Cleaner::TYPE_UINT));
if (!isset($cleaned['forumid']) || $cleaned['forumid'] < 1) {
return json_error(ERR_NO_PERMISSION);
}
$result = vB_Api::instance('announcement')->fetch($cleaned['forumid']);
if ($result === null || isset($result['errors'])) {
return json_error(ERR_NO_PERMISSION);
}
$posts = array();
foreach ($result as $ann) {
$posts[] = fr_parse_post($ann);
}
return array('posts' => $posts, 'total_posts' => count($posts));
}
示例14: actionDeleteAttachment
public function actionDeleteAttachment()
{
$vals = $this->_input->filter(array('attachmentid' => XenForo_Input::UINT, 'poststarttime' => XenForo_Input::STRING));
try {
$attachment = $this->_getAttachmentOrError($vals['attachmentid']);
} catch (Exception $e) {
$error = new XenForo_Phrase('do_not_have_permission');
json_error($error->render());
}
if (!$this->_getAttachmentModel()->canDeleteAttachment($attachment, $vals['poststarttime'])) {
$error = new XenForo_Phrase('do_not_have_permission');
json_error($error->render());
}
$dw = XenForo_DataWriter::create('XenForo_DataWriter_Attachment');
$dw->setExistingData($attachment, true);
$dw->delete();
return array('success' => true);
}
示例15: executeImpl
protected function executeImpl(ArrayAdapter $params)
{
$action = $params->str('action');
$controller = PsLogger::controller();
switch ($action) {
case 'reset':
$controller->clearLogs();
break;
case 'on':
$controller->setLoggingEnabled(true);
break;
case 'off':
$controller->setLoggingEnabled(false);
break;
default:
json_error("Unknown action [{$action}].");
}
return new AjaxSuccess();
}