本文整理匯總了PHP中jsonError函數的典型用法代碼示例。如果您正苦於以下問題:PHP jsonError函數的具體用法?PHP jsonError怎麽用?PHP jsonError使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了jsonError函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: login
public function login()
{
$params = request()->all();
$user = auth()->attempt($params);
if (auth()->check()) {
return jsonSuccess($user);
} else {
return jsonError('登錄失敗', '4011');
}
}
示例2: getInnerValue
function getInnerValue(&$obj, $innerVar)
{
if (substr($innerVar, 0, 1) != ".") {
jsonError("invalid variable name");
}
$nextIndex = strpos($innerVar, ".", 1);
if ($nextIndex !== FALSE) {
// recurse
$nextVarName = substr($innerVar, 1, $nextIndex - 1);
if (!is_array(@$obj[$nextVarName])) {
return NULL;
}
return getInnerValue($obj[$nextVarName], substr($innerVar, $nextIndex), $value);
} else {
return $obj[substr($innerVar, 1)];
}
}
示例3: validatePrivileges
function validatePrivileges($privileges = array(), $no_error = false)
{
return function () use($privileges, $no_error) {
try {
// Inicjalizacja modelu użytkownika
$user = new \Model\User();
// Pobranie instancji szkieletu Slim Framework
$app = \Slim\Slim::getInstance();
// Pobranie tokenu z pola Authorization nagłówka HTTP i jego walidacja
$token = validateToken($app->request->headers->get('Authorization'));
try {
// Pobranie danych uzytkownika o zadanym tokenie
$u = $user->getByToken($token, 'administrator');
} catch (Exception $e) {
throw new Exception('Użytkownik nie jest zalogowany.', 401);
}
// Sprawdzenie wymaganych uprawnień
if (!in_array($u['privileges'], $privileges)) {
throw new Exception('Brak uprawnień.', 401);
}
// Zapamiętanie danych potrzebnych do logowania jako zmienne globalne
$GLOBALS['user_id'] = $u['user_id'];
$GLOBALS['token'] = $token;
$GLOBALS['privileges'] = $u['privileges'];
try {
// Jeśli różnica pomiędzy ostatnią aktywnością, a bierzącym czasem
// wynosi 60 sekund, to odświeżamy autoryzację
$diff = abs(strtotime(date('Y-m-d H:i:s')) - strtotime($u['last_auth']));
if ($diff > 60) {
$res = $user->refreshAuth($token);
}
} catch (Exception $e) {
}
} catch (Exception $e) {
$GLOBALS['user_id'] = -1;
$GLOBALS['token'] = '';
$GLOBALS['privileges'] = 'guest';
if (!$no_error) {
jsonError($app, $e, true);
}
}
};
}
示例4: bootstrap
/**
* procore.json.php
* @author Adam Lee & Yaakov Albietz - ejectcore.com
* @copyright Copyright Eject Core 2009-2010. All rights reserved.
* @license GPLv3 License http://www.gnu.org/licenses/gpl-3.0.html
* @credit 3rd Party Development: Seth Benjamin
* @package Pro Core Manager API
* @version v1.0 Final
*
*/
function bootstrap()
{
if (isset($_GET['act'])) {
include realpath(dirname(__FILE__) . '/../../../') . '/config/config.inc.php';
include realpath(dirname(__FILE__) . '/../../../') . '/init.php';
if (file_exists('procore.api.php')) {
include_once 'procore.api.php';
$api = new ProCoreApi($smarty);
$action = isset($_GET['act']) ? $_GET['act'] : FALSE;
$reference = isset($_GET['reference']) ? $_GET['reference'] : FALSE;
$data = isset($_GET['data']) ? $_GET['data'] : FALSE;
if ($action !== FALSE) {
$output = $api->moduleAction($action, $reference, $data);
} else {
jsonError('Error: Action not defined.');
}
return $output;
} else {
return jsonError('Fatal Error: Core Manager API could not be located');
}
}
}
示例5: mysql_affected_rows
print mysql_affected_rows() . " DELETED\n \n";
} else {
if (preg_match("/^insert/i", $x)) {
print mysql_affected_rows() . " INSERTED\n \n";
}
}
}
}
return $res;
}
require_once dirname(__FILE__) . "/../../common/connect/applyCredentials.php";
require_once dirname(__FILE__) . "/../../common/php/dbMySqlWrappers.php";
require_once dirname(__FILE__) . "/../../records/edit/deleteRecordInfo.php";
if (!is_logged_in()) {
jsonError("no logged-in user");
}
$_REQUEST = json_decode(@$_POST["data"] ? $_POST["data"] : base64_decode(@$_GET["data"]), true);
mysql_connection_overwrite(DATABASE);
mysql_query("start transaction");
$out = deleteRecord(@$_REQUEST["id"]);
if (array_key_exists("error", $out)) {
jsonError($out["error"]);
}
mysql_query("commit");
print json_format($out);
function jsonError($message)
{
mysql_query("rollback");
print "{\"error\":\"" . addslashes($message) . "\"}";
exit(0);
}
示例6: mysql_affected_rows
if (preg_match("/^insert/i", $x)) {
print mysql_affected_rows() . " INSERTED\n \n";
}
}
}
}
return $res;
}
require_once dirname(__FILE__) . "/../../common/connect/applyCredentials.php";
require_once dirname(__FILE__) . "/../../common/php/dbMySqlWrappers.php";
require_once dirname(__FILE__) . "/../../common/php/saveRecord.php";
require_once dirname(__FILE__) . "/../../common/php/utilsTitleMask.php";
// 26/3/14 Functions to index record being saved using Elastic Search (Lucene)
require_once dirname(__FILE__) . "/../../records/index/elasticSearchFunctions.php";
if (!is_logged_in()) {
jsonError("no logged-in user");
}
$_REQUEST = json_decode(@$_POST["data"] ? $_POST["data"] : base64_decode(@$_GET["data"]), true);
mysql_connection_overwrite(DATABASE);
mysql_query("start transaction");
$out = saveRecord(@$_REQUEST["id"], @$_REQUEST["type"], @$_REQUEST["url"], @$_REQUEST["notes"], @$_REQUEST["group"], @$_REQUEST["vis"], @$_REQUEST["bookmark"], @$_REQUEST["pnotes"], @$_REQUEST["rating"], @$_REQUEST["tags"], @$_REQUEST["wgTags"], @$_REQUEST["detail"], @$_REQUEST["-notify"], @$_REQUEST["+notify"], @$_REQUEST["-comment"], @$_REQUEST["comment"], @$_REQUEST["+comment"]);
mysql_query("commit");
// 26/3/14 Add record to index in Elastic Search (Lucene)
updateRecordIndexEntry(HEURIST_DBNAME, @$_REQUEST["type"], @$_REQUEST["id"]);
print json_format($out);
function jsonError($message)
{
mysql_query("rollback");
print "{\"error\":\"" . addslashes($message) . "\"}";
exit(0);
}
示例7: ajaxController
function ajaxController($path, $request)
{
global $smarty, $dao, $error;
list($reqPath, $queryString) = explode('?', $path);
$pathParts = explode('/', substr($reqPath, 1));
list($action) = $pathParts;
session_start();
$authnStatus = checkAuthn();
if (!isLoggedIn()) {
echo "AUTHN_FAILED";
die;
}
switch ($action) {
case 'main':
echo "null";
break;
case 'submitForm':
$data = $request["formData"];
$userId = $_SESSION["loginId"];
$title = $data["title"];
$formData = $data["content"];
$xml = $request["xml"];
if (!validate_project_name($title)) {
jsonError(TITLE_INVALID, "Your form's name is invalid.");
}
if (count($data["content"]) > 10) {
jsonError(FORM_OVERFLOW, "Your form is too large. 10 controls may be present in a form. You have " . count($data["content"]) . ".");
}
if ($dao->checkFormName($title, $userId)) {
jsonError(FORM_NAME_EXISTS, "You already have a form with the same name. Please choose another name.");
}
$dao->newForm($title, $userId, $formData, $xml);
break;
case 'updateForm':
$data = $request["formData"];
$userId = $_SESSION["loginId"];
$title = $data["title"];
$formData = $data["content"];
$xml = $request["xml"];
if (count($data["content"]) > 10) {
jsonError(FORM_OVERFLOW, "Your form is too large. 10 controls may be present in a form. You have " . count($data["content"]) . ".");
}
$dao->updateForm($title, $userId, $formData, $xml);
break;
case 'listForms':
$formList = json_encode($dao->listForms($_SESSION["loginId"]));
echo $formList;
break;
case 'loadForm':
$data = $request["formData"];
$title = $data["title"];
$userId = $_SESSION["loginId"];
$formData = $dao->loadForm($userId, $title);
$responseObject = '{"title": "' . $title . '", "description" : "", "owner" : "foo", "controls" :' . $formData . ' , "id": "xwfsdfs"}';
echo $responseObject;
break;
case 'username':
echo $_SESSION["loginEmail"];
break;
case 'renameExpedition':
$data = $request["expData"];
$expId = $data["expId"];
$newName = $data["name"];
if (!validate_project_name($newName)) {
jsonError(TITLE_INVALID, "Your expedition's name is invalid.");
}
$dao->renameExpedition($expId, $newName);
break;
case 'getFindTimeStamps':
$data = $request["projectData"];
$projectId = $data["projId"];
$lastUpdate = $dao->getLastFindTime($projectId);
echo $lastUpdate;
break;
case 'updateFinds':
$data = $request["projectData"];
$projectId = $data["projId"];
$projectTime = $data["projTime"];
$newFinds = $dao->getFinds($projectId, $projectTime);
if (count($newFinds) >= 1) {
echo json_encode($newFinds);
}
break;
case 'getTimeStamps':
$data = $request["expData"];
$expId = $data["expId"];
if ($data["expId"] != "") {
$lastUpdate = $dao->getLastUpdate($expId);
echo $lastUpdate;
}
break;
case 'updateTracks':
$data = $request["expData"];
$expId = $data["expId"];
$expTime = $data["expTime"];
if ($expId != "") {
$newPoints = $dao->getNewPoints($expId, $expTime);
if (count($newPoints) >= 1) {
echo json_encode($newPoints);
}
//.........這裏部分代碼省略.........
示例8: dirname
* @package Heurist academic knowledge management system
* @todo
**/
require_once dirname(__FILE__) . "/../../common/connect/applyCredentials.php";
require_once dirname(__FILE__) . "/../../common/php/dbMySqlWrappers.php";
require_once dirname(__FILE__) . "/../../common/php/saveRecord.php";
require_once dirname(__FILE__) . "/../../common/php/utilsTitleMask.php";
if (!is_logged_in()) {
jsonError("no logged-in user");
}
$_REQUEST = json_decode(@$_POST["data"] ? $_POST["data"] : base64_decode(@$_GET["data"]), true);
mysql_connection_overwrite(DATABASE);
/* check if there are any records identified only by their hhash values */
if (!is_logged_in()) {
// must be logged into save
jsonError("invalid workgroup");
}
$nonces = array();
$retitleRecs = array();
$addRecDefaults = @$_SESSION[HEURIST_SESSION_DB_PREFIX . 'heurist']["display-preferences"]['addRecDefaults'];
if ($addRecDefaults) {
if ($addRecDefaults[0]) {
$userDefaultRectype = intval($addRecDefaults[0]);
}
if ($addRecDefaults[1]) {
$userDefaultOwnerGroupID = intval($addRecDefaults[1]);
}
if ($addRecDefaults[2]) {
$userDefaultVisibility = $addRecDefaults[2];
}
}
示例9: dirname
* @package Heurist academic knowledge management system
* @todo
**/
require_once dirname(__FILE__) . "/../../common/connect/applyCredentials.php";
require_once dirname(__FILE__) . "/../../common/php/dbMySqlWrappers.php";
function jsonError($message)
{
print "{\"error\":\"" . addslashes($message) . "\"}";
exit(0);
}
if (!is_logged_in()) {
jsonError("no logged-in user");
}
$label = @$_REQUEST["label"];
$wg = intval(@$_REQUEST["wg"]);
$ssid = intval(@$_REQUEST["ssid"]);
if ($label && $ssid) {
jsonError("missing argument (id or label) for saved search deletion");
}
mysql_connection_overwrite(DATABASE);
if ($ssid > 0) {
mysql_query("delete from usrSavedSearches where svs_ID={$ssid}");
} else {
if ($wg > 0) {
//OLD WAY
mysql_query("delete from usrSavedSearches where svs_Name='{$label}' and svs_UGrpID={$wg}");
} else {
mysql_query("delete from usrSavedSearches where svs_Name='{$label}' and svs_UGrpID=" . get_user_id());
}
}
print "{\"deleted\":" . (mysql_affected_rows() > 0 ? "true" : "false") . "}";
示例10: isset
}
}
if ($action == "doMod") {
$paramKey = isset($_REQUEST["paramKey"]) ? $_REQUEST["paramKey"] : "";
$paramValue = isset($_REQUEST["paramValue"]) ? $_REQUEST["paramValue"] : "";
if (trim($paramKey) == "") {
jsonError("fail", "paramKey is NULL");
}
$param = new param();
$result = $param->setParamValue($paramKey, $paramValue);
switch ($result) {
case "success":
jsonError("succ");
break;
case "error":
jsonError("fail", $param->getActionError());
break;
}
}
if ($action == "doAdd") {
$param = new param();
$result = $param->add();
switch ($result) {
case "success":
error("添加成功!", "alertGoTo", $_SERVER['HTTP_REFERER']);
break;
case "error":
error($news->getActionError(), "alertGoTo", $_SERVER['HTTP_REFERER']);
break;
}
}
示例11: user
<?php
/**
* 用戶密碼修改
*
*/
if ($action == "userPasswordModi") {
$user = new user();
$result = $user->ModiPassword();
switch ($result) {
case "success":
jsonError("success");
break;
case "error":
jsonError("error", $user->getActionError());
break;
}
}
示例12: Exception
throw new Exception('Niekompletne dane.', 400);
}
$notify_text = validateString('wiadomość', $postVars['notify_text'], 6, 2048);
$result = $thread->notify($id, $notify_text);
$email_to = implode(',', $result);
$subject = 'Powiadomienie';
$message = $notify_text . " \nJeśli nie chcesz otrzymywać wiadomości e-mail, zaloguj się na www.bariery.wroclaw.pl i wycofaj subskrypcję dla zgłoszeń.";
$headers = 'From: admin@bariery.wroclaw.pl' . "\r\n" . 'Reply-To: no-reply@bariery.wroclaw.pl' . "\r\n" . 'X-Mailer: PHP/' . phpversion();
@mail($email_to, $subject, $message, $headers);
jsonSuccess($app, $result);
} catch (Exception $e) {
jsonError($app, $e);
}
});
$app->delete('/id/:id', validatePrivileges(array('administrator')), function ($id) use($app, $thread) {
try {
$result = $thread->delete($id);
jsonSuccess($app, $result);
} catch (Exception $e) {
jsonError($app, $e);
}
});
$app->delete('/marker/id/:id', validatePrivileges(array('administrator')), function ($id) use($app, $thread) {
try {
$result = $thread->deleteMarker($id);
jsonSuccess($app, $result);
} catch (Exception $e) {
jsonError($app, $e);
}
});
});
示例13: settings
function settings($project_id = null)
{
// Edit Project Settings
$project_id = intval($project_id);
$this->Project =& ClassRegistry::init('Project');
$this->Project->contain(array('State.Step' => array('Condition', 'Action')));
$conditions = array('Project.id' => $project_id, 'Project.user_id' => $this->DarkAuth->id, 'Project.live' => 1);
$project = $this->Project->find('first', compact('conditions'));
if (empty($project)) {
$this->_Flash('Unable to find Project', 'mean', '/');
}
// Must be my project
if ($project['Project']['user_id'] != $this->DarkAuth->id) {
$this->_Flash('Invalid project chosen', 'mean', $this->referer('/'));
}
if ($this->RequestHandler->isGet()) {
$this->data = $project;
return;
}
// Parse input
// - type cannot be changed
App::import('Sanitize');
$data = array();
$data['id'] = $project['Project']['id'];
$data['enable_state'] = intval($this->data['Project']['enable_state']);
// Save
if (!$this->Project->save($data, false, array_keys($data))) {
echo jsonError(101, 'Failed saving Project Settings');
exit;
}
echo jsonSuccess('Settings Saved');
exit;
}
示例14: win1251
case 'zayav_spisok':
$_POST['find'] = win1251($_POST['find']);
$data = zayav_spisok($_POST);
if ($data['filter']['page'] == 1) {
$send['all'] = utf8($data['result']);
}
$send['spisok'] = utf8($data['spisok']);
jsonSuccess($send);
break;
case 'zayav_status':
if (!($zayav_id = _num($_POST['zayav_id']))) {
jsonError();
}
if (!($zayav_status = _num($_POST['status']))) {
jsonError();
}
$sql = "SELECT * FROM `zayav` WHERE `ws_id`=" . WS_ID . " AND !`deleted` AND `id`=" . $zayav_id;
if (!($z = query_assoc($sql))) {
jsonError();
}
if ($z['status'] == $zayav_status) {
jsonError();
}
$sql = "UPDATE `zayav`\n\t\t\t\tSET `status`=" . $zayav_status . ",\n\t\t\t\t\t`status_dtime`=CURRENT_TIMESTAMP\n\t\t\t\tWHERE `id`=" . $zayav_id;
query($sql);
_history(array('type_id' => 71, 'client_id' => $z['client_id'], 'zayav_id' => $zayav_id, 'v1' => $z['status'], 'v2' => $zayav_status));
jsonSuccess();
break;
}
jsonError();
示例15: switch
<?php
include_once '../lib/functions.php';
include_once 'config.php';
switch ($_GET['action']) {
case 'channel_thumbnail':
$feed = $_GET['feed'];
//XXX: Further feed validation is in order.
if (!preg_match("/\\/(r|domain)\\//", $feed)) {
jsonError('Invalid feed.');
}
if ($cacheAvailable) {
$thumbnail_url = $memcache->get("chthmb-{$feed}");
if (!empty($thumbnail_url)) {
$channel = new stdClass();
$channel->feed = $feed;
$channel->thumbnail_url = $thumbnail_url;
$channel->data_source = 'memcache';
jsonForAjax(array($channel));
}
}
//Reload the bean
$channel = R::findOne('channel', ' feed = ?', array($feed));
if (empty($channel) || empty($channel->thumbnail_url)) {
if (empty($channel)) {
$channel = R::dispense('channel');
}
$channel->feed = $feed;
$channel->thumbnail_url = getChannelThumbnail($feed);
//Store the bean
$id = R::store($channel);