本文整理汇总了PHP中JsonResponse::set方法的典型用法代码示例。如果您正苦于以下问题:PHP JsonResponse::set方法的具体用法?PHP JsonResponse::set怎么用?PHP JsonResponse::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonResponse
的用法示例。
在下文中一共展示了JsonResponse::set方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: insertNewUser
/**
* Insert new user into database
*
* @param array $info containing 'username','name','password','email'
* @param bool $ldap TRUE for LDAP user
* @return JsonResponse {"msg","msgType","errorCode"}
* @throws Exception
*/
function insertNewUser($info, $ldap = false)
{
$this->info['msg'] = "user::false";
$response = new JsonResponse();
$response->set("msgType", "error");
$response->set("error", "true");
$db = new RecordSet($this->dbConnectionInfo);
$username = $db->sanitize($info['username']);
$name = $db->sanitize($info['name']);
$email = $db->sanitize($info['email']);
if ($this->isUqFieldViolated('userName', $username)) {
$response->set("msg", "User name is already taken!");
$response->set("errorCode", "4");
} else {
if ($this->isUqFieldViolated('email', $email) && trim($email) != '') {
$response->set("msg", "Email is already in the database!");
$response->set("errorCode", "5");
} else {
if (!$this->checkEmail($email) && !$ldap) {
$response->set("msg", "Invalid e-mail address!");
$response->set("errorCode", "3");
} else {
if (strlen(trim($info['password'])) < 5 && !$ldap) {
$response->set("msg", "Password is too short!");
$response->set("errorCode", "1");
} else {
if ($db->sanitize($info['password']) != $info['password']) {
$response->set("msg", "Invalid password!");
$response->set("errorCode", "2");
} else {
if (!$ldap) {
$password = MD5($db->sanitize($info['password']));
$status = 'created';
} else {
$password = '';
$status = 'validated';
}
$date = date("Y-m-d H:i:s");
$sql = "INSERT INTO users (userId ,userName ,email ,name ,company ,password ,date ,level ,status,notifyAll,notifyReply,notifyPage) VALUES (NULL,'" . $username . "','" . $email . "','" . $name . "','noCompany','" . $password . "','" . $date . "','user','" . $status . "','no','yes','yes');";
$rows = $db->Run($sql);
$this->info['msg'] = "user::rows::" . $rows;
// $toReturn=$sql;
if ($rows <= 0) {
$response->set("msg", $db->m_DBErrorNumber . $db->m_DBErrorMessage . $sql);
$response->set("errorCode", "10");
} else {
$response->set("error", "false");
$response->set("errorCode", "0");
$this->validate($username, $info['password'], $status);
}
$db->Close();
}
}
}
}
}
return $response;
}
示例2: JsonResponse
*/
require_once 'init.php';
//$ses=Session::getInstance();
$toReturn = new JsonResponse();
if (isset($_POST['email']) && trim($_POST['email']) != '') {
// send email to support
$info['product'] = $_POST['product'];
$info['version'] = $_POST['version'];
$info['username'] = $_POST['userName'];
$info['email'] = $_POST['email'];
$user = new User($dbConnectionInfo);
$generateInfo = $user->generatePasswd($info);
$productTranslate = defined("__PRODUCT_NAME__") ? __PRODUCT_NAME__ : $info['product'];
if ($generateInfo['generated'] == "") {
// nu are email valid
$toReturn->set("success", "false");
$toReturn->set("message", Utils::translate('noEmailFound'));
//echo "No ";
} else {
if ($generateInfo['match']) {
// generated password
$template = new Template("./templates/" . __LANGUAGE__ . "/recover.html");
$confirmationMsg = $template->replace(array("username" => $info['username'], "password" => $generateInfo['generated'], "productName" => $productTranslate));
// $confirmationMsg = "Your new generated password for user name = ".$info['username']." is ".$generateInfo['generated'];
$mail = new Mail();
$mail->Subject("[" . $productTranslate . "] " . Utils::translate('RecoveredEmailSubject'));
$mail->To($info['email']);
$mail->From(__EMAIL__);
$mail->Body($confirmationMsg);
$mail->Send();
$user->changePassword($info['email'], $generateInfo['generated']);
示例3: elseif
$toReturn->set("userName", $ses->{$fullUser}->userName);
$toReturn->set("level", $ses->{$fullUser}->level);
} else {
if (strlen(trim($user->msg)) > 0) {
$toReturn->set("error", $user->msg);
}
}
echo $toReturn;
} elseif (isset($_POST['logOff']) && trim($_POST['logOff']) != '') {
$ses->errBag = null;
unset($ses->errBag);
unset($ses->{$fullUser});
// echo print_r($_POST,true);
} elseif (isset($_POST['check']) && trim($_POST['check']) != '') {
$toReturn = new JsonResponse();
$toReturn->set("isAnonymous", "false");
$toReturn->set("loggedIn", "false");
if (defined('__GUEST_POST__') && !__GUEST_POST__ && (isset($ses->{$fullUser}) && $ses->{$fullUser}->isAnonymous == 'true')) {
unset($ses->{$fullUser});
}
if (defined('__GUEST_POST__') && __GUEST_POST__ && !isset($ses->{$fullUser})) {
$user = new User($dbConnectionInfo);
// user not logged in and guest is allowed to post
if (!$user->initAnonymous()) {
$toReturn->set("isAnonymous", "false");
$toReturn->set("loggedIn", "false");
$toReturn->set("msg", "1");
$toReturn->set("msgType", "error");
} else {
// anonymous must be logged in
$ses->{$fullUser} = $user;
示例4: JsonResponse
<?php
/*
Oxygen Webhelp plugin
Copyright (c) 1998-2014 Syncro Soft SRL, Romania. All rights reserved.
Licensed under the terms stated in the license file EULA_Webhelp.txt
available in the base directory of this Oxygen Webhelp plugin.
*/
require_once "init.php";
$cfgFile = './config/config.php';
$cfgInstall = '../../install/';
$toReturn = new JsonResponse();
if (file_exists($cfgInstall)) {
$toReturn->set("installPresent", "true");
} else {
$toReturn->set("installPresent", "false");
}
if (file_exists($cfgFile) && filesize($cfgFile) > 0) {
$toReturn->set("configPresent", "true");
} else {
$toReturn->set("configPresent", "false");
}
echo $toReturn;
示例5: explode
//list($id,$date,$action,$newPassword) = explode("|", $realId);
$args = explode("|", $realId);
$id = $args[0];
$date = $args[1];
$action = "new";
$newPassword = "";
if (count($args) > 2) {
$action = $args[2];
$newPassword = $args[3];
}
$user = new User($dbConnectionInfo);
//echo "id=".$id." date=".$date;
$currentDate = date("Y-m-d G:i:s");
$days = Utils::getTimeDifference($currentDate, $date, 3);
if ($days > 7) {
$toReturn->set("error", true);
$toReturn->set("msg", "Confirmation code expired!");
} else {
$productTranslate = defined("__PRODUCT_NAME__") ? __PRODUCT_NAME__ : $_POST['productName'];
if ($action == "recover") {
$email = $id;
$userName = $user->changePassword($email, $newPassword);
if ($userName != "") {
$template = new Template("./templates/" . __LANGUAGE__ . "/recover.html");
$confirmationMsg = $template->replace(array("username" => $userName, "password" => $newPassword, "productName" => $productTranslate));
//
// $confirmationMsg = "Your generated password form username '".$userName."' is '".$newPassword."'";
// $confirmationMsg.="<br/>Thank you !";
$mail = new Mail();
$mail->Subject("[" . $productTranslate . "] " . $translate['RecoveredEmailSubject']);
$mail->To($email);
示例6: User
$user = new User($dbConnectionInfo);
$return = $user->insertNewUser($info);
if ($return->error == "true") {
echo $return;
} else {
$id = base64_encode($user->userId . "|" . $user->date);
$link = "<a href='" . __BASE_URL__ . "oxygen-webhelp/resources/confirm.html?id={$id}'>" . __BASE_URL__ . "oxygen-webhelp/resources/confirm.html?id={$id}</a>";
$template = new Template("./templates/signUp.html");
$productTranslate = defined("__PRODUCT_NAME__") ? __PRODUCT_NAME__ : $_POST['product'];
$arrayProducts = $user->getSharedProducts();
$products = "";
foreach ($arrayProducts as $productId => $productName) {
$products .= "\"" . $productName . "\" ";
}
$confirmationMsg = $template->replace(array("name" => $info['name'], "username" => $info['username'], "confirmationLink" => $link, "productName" => $productTranslate, "products" => $products));
$mail = new Mail();
$mail->Subject("[" . $productTranslate . "] " . Utils::translate('signUpEmailSubject'));
$mail->To($info['email']);
$mail->From(__EMAIL__);
$mail->Body($confirmationMsg);
$mail->Send();
$json->set("error", "false");
$json->set("msg", "SignUp Success");
echo $json;
}
} else {
$json->set("error", "true");
$json->set("errorCode", "6");
$json->set("msg", "Invalid username!");
echo $json;
}
示例7: JsonResponse
echo $toReturn;
}
} else {
$toReturn->set("msgClass", "error");
$toReturn->set("msg", Utils::translate("err.notLoggedIn"));
echo $toReturn;
}
} else {
if (isset($_POST['select']) && trim($_POST['select']) != '') {
$toReturn = new JsonResponse();
$pName = isset($_POST['product']) ? $_POST['product'] : "";
$pVersion = isset($_POST['version']) ? $_POST['version'] : "";
$fullUser = base64_encode($pName . "_" . $pVersion . "_user");
$ses = Session::getInstance();
if (isset($ses->{$fullUser})) {
$delim = $_POST['delimiter'];
$user = $ses->{$fullUser};
$toReturn->set("isLogged", "true");
$toReturn->set("name", $user->name);
$toReturn->set("email", $user->email);
$toReturn->set("notifyPage", $user->notifyPage);
$toReturn->set("notifyReply", $user->notifyReply);
$toReturn->set("notifyAll", $user->notifyAll);
} else {
$toReturn->set("isLogged", "false");
}
echo $toReturn;
} else {
echo "Invalid data!";
}
}
示例8: JsonResponse
} else {
echo "Success";
}
} else {
if (isset($_POST["qVersion"]) && trim($_POST["qVersion"]) != "" && $_POST["qVersion"] == "true") {
$response = new JsonResponse();
$pName = isset($_POST['productName']) ? $_POST['productName'] : "";
$pVersion = isset($_POST['productVersion']) ? $_POST['productVersion'] : "";
$fullUser = base64_encode($pName . "_" . $pVersion . "_user");
$comment = new Comment($dbConnectionInfo, "", $fullUser);
$vList = $comment->queryVersions($pName);
$toPrint = "";
$minVersion = "";
$idx = 0;
foreach ($vList as $version => $visible) {
$toPrint .= "<div class='versionTimeLine'>";
$toPrint .= "<div class='v_{$visible}' id='ver_" . $idx . "' onclick=setVersion('{$version}');>" . $version . "</div>";
$toPrint .= "</div>";
if ($minVersion == "" && $visible == 'true') {
$minVersion = $version;
}
$idx++;
}
$response->set("versions", $toPrint);
$response->set("minVersion", $minVersion);
echo $response;
} else {
echo "No data to insert as comment!";
}
}
}
示例9: JsonResponse
<?php
/*
Oxygen Webhelp plugin
Copyright (c) 1998-2015 Syncro Soft SRL, Romania. All rights reserved.
Licensed under the terms stated in the license file EULA_Webhelp.txt
available in the base directory of this Oxygen Webhelp plugin.
*/
include_once "config.php";
include_once "../localization/strings.php";
global $localization;
$toReturn = new JsonResponse();
foreach ($localization as $key => $translation) {
$toReturn->set($key, $translation);
}
echo $toReturn;