本文整理汇总了PHP中SessionUtils类的典型用法代码示例。如果您正苦于以下问题:PHP SessionUtils类的具体用法?PHP SessionUtils怎么用?PHP SessionUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SessionUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkLogin
public function checkLogin($usr = '', $pass = '')
{
/*inicialmente validaremos contra datos preestablecidos que podrían venir por ejemplo, de una base de datos*/
if ($usr == self::$user && $pass == self::$password) {
self::$loggedin = true;
self::$arrUsuario['user'] = self::$user;
$_SESSION['auth_user'] = self::$user;
$_SESSION['auth_pass'] = self::$password;
parent::set("auth_user", self::$user);
parent::set("auth_pass", self::$password);
return true;
} else {
self::$arrUsuario = array();
self::$loggedin = false;
return false;
}
$auth = new SessionUtils();
if ($auth->checkLogin('test', 'test')) {
echo "ok";
print_r($_SESSION);
print_r($_COOKIE);
} else {
echo "fail";
}
}
示例2: setUp
protected function setUp()
{
parent::setUp();
$this->deleteAllUsers();
$this->createNewUsers();
SessionUtils::saveSessionObject('user', $this->usersArray['admin']);
}
示例3: insertNewUserAddressVisited
public function insertNewUserAddressVisited(\AddressDTO $addressDTO)
{
try {
$this->userAutentication();
$userLogged = SessionUtils::getUserLogged();
$newAddress = array(":" . USERID => $userLogged->getUserId(), ":" . LONGITUDE => $addressDTO->getLongitude(), ":" . LATITUDE => $addressDTO->getLatitude(), ":" . TIMESTAMP => date(DATE_FORMAT));
$newAddressId = $this->getDB()->insert(USER_ADDRESS_VISITED_TABLE, $newAddress);
return $newAddressId;
} catch (PDOException $pdoe) {
throw $pdoe;
} catch (Exception $e) {
throw $e;
}
}
示例4: testSession
public function testSession()
{
try {
$userLogged = SessionUtils::getUserLogged();
$username = $userLogged->getUserName();
$sessionToken = SessionUtils::getSessionToken();
$query = "select * from sat_user where USERNAME = {$username} and SESSION_TOKEN = {$sessionToken}";
return $this->execQuery($query);
} catch (PDOException $pdoe) {
throw $pdoe;
} catch (Exception $e) {
throw $e;
}
}
示例5: deleteFriendModel
function deleteFriendModel($friendId)
{
try {
$responseDTO = new ResponseDTO(DELETE_FRIEND_FORM);
$friendsDAO = new FriendsDAO();
$oldFriend = $friendsDAO->deleteFriend($friendId);
SessionUtils::deleteFriendInUserLoggedFriendList($friendId);
$responseDTO->setResponseSucc("friend" . $friendId);
return $responseDTO;
} catch (PDOException $pdoe) {
throw $pdoe;
} catch (UserNotAuthenticatedExceptionDTO $authExp) {
throw $authExp;
} catch (Exception $e) {
throw $e;
}
}
示例6: updateProfilePhoto
public function updateProfilePhoto(\PhotoDTO $userProfilePhotoDTO)
{
$userLogged = SessionUtils::getUserLogged();
$set = array(PROFILEPHOTO => $userProfilePhotoDTO->getPhotoId());
$where = array(USERID => $userLogged->getUserId());
try {
$this->userAutentication();
$userPhoto = $this->getDB()->update(USER_TABLE, $set, $where);
DataModelUtils::notifyAction($userProfilePhotoDTO->getPhotoId() . SEPARATOR . $userProfilePhotoDTO->getPhotoUrl(), PROFILE_SETTINGS_PHOTO_FORM);
return $userProfilePhotoDTO;
} catch (PDOException $pdoe) {
throw $pdoe;
} catch (UserNotAuthenticatedExceptionDTO $authExp) {
throw $authExp;
} catch (Exception $e) {
throw $e;
}
}
示例7: deleteAlbum
public function deleteAlbum($albumId)
{
try {
$model = $this->getModel();
$deletedAlbum = $model->deleteAlbumModel($albumId);
if (isset($_POST[JAVASCRIPT_ON]) && $_POST[JAVASCRIPT_ON] === "Y") {
echo json_encode($deletedAlbum->jsonSerialize());
} else {
SessionUtils::setError($deletedAlbum);
header("Location: " . URL . ALBUM_CONTROLLER);
exit;
}
} catch (PDOException $pdoe) {
throw $pdoe;
} catch (UserNotAuthenticatedExceptionDTO $authExp) {
parent::userNotLogged($authExp);
} catch (Exception $e) {
throw $e;
}
}
示例8: uploadPhotoModel
public static function uploadPhotoModel($uploadedPhoto, $albumId, $formType, $latitude = NULL, $longitude = NULL)
{
$responseDTO = new ResponseDTO($formType);
try {
$userLogged = SessionUtils::getUserLogged();
$fileName = $uploadedPhoto["name"];
$fileType = $uploadedPhoto["type"];
$tmpFileName = $uploadedPhoto["tmp_name"];
$rawImage = FileUtils::getRawImage($fileType, $tmpFileName);
$fileName = FileUtils::getFileName($fileName, $userLogged->getUserId(), $albumId);
$redimImage = FileUtils::getRedimensionedImage($tmpFileName, $rawImage);
if (imagejpeg($redimImage, $fileName, 100)) {
$photoDAO = new PhotoDAO();
$newPhotoDTO = new PhotoDTO(NULL, $fileName, $latitude, $longitude);
$newPhotoDTO = $photoDAO->insertNewPhoto($newPhotoDTO);
if ($newPhotoDTO->getPhotoId() == 0) {
$responseDTO->setErrField(ERROR_RESPONSE, "Errore durante l'inserimento della foto [" . $newPhotoDTO->getPhotoUrl() . "]");
} else {
$albumDAO = new AlbumDAO();
if (is_null($albumId)) {
$albumId = $albumDAO->getDefaultAlbumId($userLogged->getUserId());
}
if ($formType !== ADD_ALBUM_FORM) {
$photoInAlbumId = $albumDAO->insertNewUserPhotoAlbum($userLogged->getUserId(), $albumId, $newPhotoDTO->getPhotoId());
}
if (!is_null($latitude) && !is_null($longitude)) {
$uploadedAddress = FileUtils::saveAddressModel($latitude, $longitude, $formType);
}
return $newPhotoDTO;
}
} else {
$responseDTO->setErrField(ERROR_RESPONSE, "Errore durante la copia del file sul server PHP");
}
} catch (PDOException $pdoe) {
throw $pdoe;
} catch (UserNotAuthenticatedExceptionDTO $userAuth) {
throw $userAuth;
} catch (Exception $e) {
throw $e;
}
}
示例9: userAutentication
function userAutentication()
{
try {
$userLogged = SessionUtils::getUserLogged();
$sessionToken = SessionUtils::getSessionToken();
if (!is_null($userLogged)) {
$query = "select * from sat_user where userid = " . $userLogged->getUserId() . " and SESSION_TOKEN = '" . $sessionToken . "'";
$objectArray = $this->getDB()->execQuery($query);
if (is_null($objectArray)) {
$myException = new UserNotAuthenticatedExceptionDTO(URL . LOGIN_CONTROLLER);
throw $myException;
}
}
} catch (PDOException $pdoe) {
throw $pdoe;
} catch (UserNotAuthenticatedExceptionDTO $userAuth) {
throw $userAuth;
} catch (Exception $e) {
throw $e;
}
}
示例10: forgotPassword
public function forgotPassword()
{
try {
$model = $this->getModel();
$forgotPwdjax = NULL;
if (isset($_GET["forgotPasswordForm"])) {
$forgotPwdjax = json_decode($_GET["forgotPasswordForm"], true);
$forgottenPwd = $model->forgotPasswordModel($forgotPwdjax);
echo json_encode($forgottenPwd->jsonSerialize());
} else {
$forgottenPwd = $model->forgotPasswordModel($forgotPwdjax);
SessionUtils::setError($forgottenPwd);
header("Location:" . URL . FORGOT_PWD_CONTROLLER);
exit;
}
} catch (PDOException $pdoe) {
throw $pdoe;
} catch (Exception $e) {
throw $e;
}
}
示例11: forgotPasswordModel
public function forgotPasswordModel($forgotPasswordForm)
{
$formObjRaw = new FormDTO(FORGOT_PWD_FORM, $forgotPasswordForm);
$responseDTO = new ResponseDTO(FORGOT_PWD_FORM);
try {
$formDataObj = $formObjRaw->getFormData();
$validator = new FormValidator(FORGOT_PWD_FORM, $formDataObj);
$validationError = $validator->checkAll();
if (sizeof($validationError) == 0) {
$userDAO = new UserDAO();
$userDTO = $userDAO->getUserByEmail($formDataObj[FORGOT_PWD_FORM . EMAIL]);
if (is_null($userDTO)) {
$responseDTO->setErrField(ERROR_RESPONSE, "Nessun user presente con questa mail");
} else {
$newPassword = PasswordUtils::createRandomicPassword();
$userDTO->setPassword($newPassword);
$resultMail = DataModelUtils::sendMail($userDTO, FORGOT_PWD_FORM);
$hashedPwd = PasswordUtils::getPassword($newPassword);
$userDTO->setPassword($hashedPwd);
$result = $userDAO->updateUserPassword($userDTO);
if ($result != 1) {
$responseDTO->setErrField(ERROR_RESPONSE, "Problema nel cambio della password");
} else {
$responseDTO->setResponseSucc("Verra mandata una mail con una nuova password all'indirizzo " . $userDTO->getEmail());
}
}
} else {
if (array_key_exists(EMAIL, $validationError)) {
$responseDTO->setErrField(EMAIL, $validationError[EMAIL]);
}
SessionUtils::setFormValue($formDataObj);
}
return $responseDTO;
} catch (PDOException $pdoe) {
throw $pdoe;
} catch (Exception $e) {
throw $e;
}
}
示例12: getUnreadNotificationList
public function getUnreadNotificationList($limit = NULL)
{
$userLogged = SessionUtils::getUserLogged();
if (is_null($limit)) {
$query = "select * from sat_notify where SUBJECT_ID = " . $userLogged->getUserId() . " and IS_READ = 0 order by sent_at desc ";
} else {
$query = "select * from sat_notify where SUBJECT_ID = " . $userLogged->getUserId() . " and IS_READ = 0 order by sent_at desc ";
}
try {
$objectArray = $this->getDB()->execQuery($query);
if (is_null($objectArray)) {
return NULL;
} else {
$objectListDTO = DataModelUtils::getObjectList(NOTIFICATIONDTO, $objectArray);
return $objectListDTO;
}
} catch (PDOException $pdoe) {
throw $pdoe;
} catch (Exception $e) {
throw $e;
}
}
示例13: confirmFriendshipModel
public function confirmFriendshipModel($notificationId, $userForm)
{
$formObjRaw = new FormDTO(CONFIRM_FRIENDSHIP_FORM, $userForm);
$formObjRaw->setSubElementId($notificationId);
try {
$formDataObj = $formObjRaw->getFormData();
$friendDAO = new FriendsDAO();
$result = $friendDAO->confirmFriendship($formDataObj[CONFIRM_FRIENDSHIP_FORM . FRIENDID]);
$userDAO = new UserDAO();
$friendDTO = $userDAO->getUserByUserId($formDataObj[CONFIRM_FRIENDSHIP_FORM . FRIENDID]);
$friendDTO->setPassword(NULL);
$notificationDAO = new NotificationDAO();
$result = $notificationDAO->setNotificationAsRead($formDataObj[CONFIRM_FRIENDSHIP_FORM . NOTIFICATIONID]);
SessionUtils::addFriendInUserLoggedFriendList($friendDTO, date(DATE_FORMAT));
DataModelUtils::notifyAction($friendDTO->getUserId() . SEPARATOR . $friendDTO->getUserName(), CONFIRM_FRIENDSHIP_FORM);
return $friendDTO;
} catch (PDOException $pdoe) {
throw $pdoe;
} catch (Exception $e) {
throw $e;
}
}
示例14: getFriendsList
public function getFriendsList($userProfile)
{
if (!SessionUtils::isAdmin()) {
$query = "select ut.*, pt.*, tmp.FRIENDSSINCE \n from sat_user ut, sat_photo pt, ( \n select FRIENDID as USERID,FRIENDSSINCE \n from sat_user_friends \n where USERID = {$userProfile} \n UNION \n select USERID, FRIENDSSINCE \n from sat_user_friends \n where FRIENDID = {$userProfile} \n ) tmp \n where ut.profilephoto = pt.photoid and tmp.USERID = ut.USERID";
} else {
$query = "select distinct ut.*, pt.*, NULL AS FRIENDSSINCE from sat_user ut, sat_photo pt where ut.role <> 'ADMIN' and ut.profilephoto = pt.photoid ";
}
try {
$this->userAutentication();
$objectArray = $this->getDB()->execQuery($query);
if (is_null($objectArray)) {
return NULL;
} else {
$objectListDTO = DataModelUtils::getObjectList(FRIENDSDTO, $objectArray);
return $objectListDTO;
}
} catch (PDOException $pdoe) {
throw $pdoe;
} catch (Exception $e) {
throw $e;
}
}
示例15: deleteUser
public function deleteUser($userId)
{
try {
$model = $this->getModel();
$deletedUser = $model->deleteUserModel($userId);
FileUtils::deleteAlbumDirOnServer($userId, NULL);
if (isset($_POST[JAVASCRIPT_ON]) && $_POST[JAVASCRIPT_ON] === "Y") {
echo json_encode($deletedUser->jsonSerialize());
} else {
$responseDTO = new ResponseDTO(DELETE_USER_FORM);
$responseDTO->setResponseSucc("Utente eliminato con successo");
SessionUtils::setError($responseDTO);
header("Location: " . URL . USERLIST_CONTROLLER);
exit;
}
} catch (PDOException $pdoe) {
throw $pdoe;
} catch (UserNotAuthenticatedExceptionDTO $authExp) {
parent::userNotLogged($authExp);
} catch (Exception $e) {
throw $e;
}
}