本文整理汇总了PHP中UserSession类的典型用法代码示例。如果您正苦于以下问题:PHP UserSession类的具体用法?PHP UserSession怎么用?PHP UserSession使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UserSession类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: httpPostMethod
public function httpPostMethod(Http $http, array $formFields)
{
/*
* Méthode appelée en cas de requête HTTP POST
*
* L'argument $http est un objet permettant de faire des redirections etc.
* L'argument $formFields contient l'équivalent de $_POST en PHP natif.
*/
/*$date = new DateModel();
var_dump($date->testDate($formFields['dateResa'])); //0 FAUX - 1 VRAI REJEX */
$userSession = new UserSession();
if ($userSession->isAuthenticated()) {
$dateTime = date_create($formFields['dateResa'] . ' ' . $formFields['timeResa']);
$now = new DateTime("now");
$resaDate = date_format($dateTime, 'Y-m-d');
$resaTime = date_format($dateTime, 'H:i:s');
//var_dump($formFields);
if (!empty($formFields['dateResa']) && !empty($formFields['timeResa']) && !empty($formFields['NumberOfSeats']) && $dateTime > $now && ctype_digit($formFields['NumberOfSeats'])) {
$userId = $userSession->getId();
$Booking = new BookingModel();
$resultat = $Booking->register($userId, $resaDate, $resaTime, $formFields['NumberOfSeats']);
return ['resultat' => $resultat];
} elseif ($dateTime < $now) {
return ['Error' => 'Nous ne pouvons vous réserver une table pour une date antérieur à aujourd\'hui'];
} else {
return ['Error' => 'Un champ n\'a pas était remplie correctement'];
}
} else {
echo 'lu';
die;
$http->redirectTo('/');
}
}
示例2: httpPostMethod
public function httpPostMethod(Http $http, array $formFields)
{
/*
* Méthode appelée en cas de requête HTTP POST
*
* L'argument $http est un objet permettant de faire des redirections etc.
* L'argument $formFields contient l'équivalent de $_POST en PHP natif.
*/
$userSession = new UserSession();
if ($userSession->isAdminAuthenticated() == false) {
$http->redirectTo('/');
}
//var_dump($formFields);
//var_dump($_FILES);
if (array_key_exists('Modification', $formFields)) {
if ($http->hasUploadedFile('Photo')) {
$pathinfo = $http->moveUploadedFile('Photo', '/images/meals');
var_dump($pathinfo);
$mealModel = new MealModel();
$mealModel->modifyPicture($pathinfo, $formFields['Id']);
}
$mealModel = new MealModel();
$result = $mealModel->modifyMeal($formFields['Name'], $formFields['Description'], $formFields['QuantityInStock'], $formFields['BuyPrice'], $formFields['SalePrice'], $formFields['Id']);
$http->redirectTo('/Admin/List');
} elseif (ctype_digit($formFields['meal_Id'])) {
$mealModel = new MealModel();
$meal = $mealModel->find($formFields['meal_Id']);
return ['meal' => $meal];
}
}
示例3: sess_read
function sess_read($key)
{
global $lr_session;
$lr_session = new UserSession();
$lr_session->create_from_cookie($key, $_SERVER['REMOTE_ADDR']);
return $lr_session->is_valid();
}
示例4: httpPostMethod
public function httpPostMethod(Http $http, array $formFields)
{
/*
* Méthode appelée en cas de requête HTTP POST
*
* L'argument $http est un objet permettant de faire des redirections etc.
* L'argument $formFields contient l'équivalent de $_POST en PHP natif.
*/
try {
$Customer = new CustomerModel();
$verifEmail = $Customer->sameMail($formFields['Email']);
if ($verifEmail && ctype_digit($formFields['Year']) && ctype_digit($formFields['Month']) && ctype_digit($formFields['Day']) && ctype_digit($formFields['Phone']) && strlen($formFields['Phone']) === 10 && ctype_digit($formFields['ZipCode']) && strlen($formFields['ZipCode']) === 5 && isset($formFields['password']) && $formFields['password2'] == $formFields['password'] && isset($formFields['Email']) && filter_var($formFields['Email'], FILTER_VALIDATE_EMAIL) != false) {
$Birthdate = $formFields['Year'] . '-' . $formFields['Month'] . '-' . $formFields['Day'];
//var_dump($Birthdate);
$Customer_id = $Customer->registerCustomer($formFields['FirstName'], $formFields['LastName'], $Birthdate, $formFields['Phone'], $formFields['Address'], $formFields['Address2'], $formFields['City'], $formFields['ZipCode'], $formFields['Email'], $formFields['password']);
//var_dump($Customer_id);
$user = $Customer->findCustomer($Customer_id);
$UserSession = new UserSession();
$UserSession->create($user);
$http->redirectTo('');
} else {
$http->redirectTo('Exception?Error=3');
}
} catch (DomainException $event) {
$form = new RegisterForm();
$form->bind($formFields);
$form->setErrorMessage($event->getMessage());
return ['_form' => $form];
}
}
示例5: httpPostMethod
public function httpPostMethod(Http $http, array $formFields)
{
/*
* Méthode appelée en cas de requête HTTP POST
*
* L'argument $http est un objet permettant de faire des redirections etc.
* L'argument $formFields contient l'équivalent de $_POST en PHP natif.
*/
$Customer = new CustomerModel();
$verifEmail = $Customer->sameMail($formFields['Email']);
//var_dump(strlen($_POST['Phone']));
//var_dump(strlen($_POST['ZipCode']));
if ($verifEmail['result'] === '0' && ctype_digit($formFields['Year']) && ctype_digit($formFields['Month']) && ctype_digit($formFields['Day']) && ctype_digit($formFields['Phone']) && strlen($formFields['Phone']) === 10 && ctype_digit($formFields['ZipCode']) && strlen($formFields['ZipCode']) === 5 && isset($formFields['password']) && isset($formFields['Email']) && filter_var($formFields['Email'], FILTER_VALIDATE_EMAIL) != false) {
$password = password_hash($formFields['password'], PASSWORD_DEFAULT);
//var_dump($password);
$Birthdate = $formFields['Year'] . '-' . $formFields['Month'] . '-' . $formFields['Day'];
//var_dump($Birthdate);
$Customer_id = $Customer->registerCustomer($formFields['FirstName'], $formFields['LastName'], $Birthdate, $formFields['Phone'], $formFields['Address'], $formFields['Address2'], $formFields['City'], $formFields['ZipCode'], $formFields['Email'], $formFields['password']);
//var_dump($Customer_id);
$user = $Customer->findCustomer($Customer_id);
$UserSession = new UserSession();
$UserSession->create($user);
$http->redirectTo('');
} elseif ($verifEmail != '0') {
$http->redirectTo('Exception?Error=3');
}
}
示例6: httpPostMethod
public function httpPostMethod(Http $http, array $formFields)
{
/*
* Méthode appelée en cas de requête HTTP POST
*
* L'argument $http est un objet permettant de faire des redirections etc.
* L'argument $formFields contient l'équivalent de $_POST en PHP natif.
*/
/*var_dump($formFields['bookingDate']);
var_dump($date);
var_dump($date > $formFields['bookingDate']);
die();*/
$date = new DateTime();
$userSession = new UserSession();
$bookingModel = new BookingModel();
$customerId = intval($userSession->getId());
if ($userSession->isAuthenticated()) {
$customerId = intval($userSession->getId());
$checkBookingById = $bookingModel->checkBookingById($customerId, intval($formFields['bookingId']), $formFields['bookingDate']);
if (ctype_digit($formFields['bookingId']) && $date < new DateTime($formFields['bookingDate']) && $checkBookingById) {
$bookingModel->DeletBooking($formFields['bookingId']);
$flashBag = new FlashBag();
$flashBag->add('Réservation ' . $formFields["bookingId"] . ' bien supprimée');
$http->redirectTo('/');
}
$flashBag = new FlashBag();
$flashBag->add('Problème lors de la suppression de la réservation (Vous ne pouvez supprimer des réservations posterieur à aujourd\'hui)');
$http->redirectTo('/Booking');
}
}
示例7: getUser
public function getUser()
{
require_once WEBAPPROOT . 'security/UserSession.php';
$session = new UserSession();
$session->start();
return $session->getUser();
}
示例8: httpGetMethod
public function httpGetMethod(Http $http, array $queryFields)
{
if (isset($_GET['logout']) && $_GET['logout'] == 'out') {
$userSession = new UserSession();
$userSession->destroy();
$http->redirectTo('/');
}
}
示例9: __construct
public function __construct()
{
//parent::__construct();
Doo::loadClass('UserSession');
$usession = new UserSession();
$this->username = $usession->uget('username');
$this->ppv_cat_code = 'C_TokoVideo_PPV';
$this->svod_cat_code = 'C_TokoVideo_International';
}
示例10: testIndexNoAdmin
public function testIndexNoAdmin()
{
$s = new UserSession('azerty', 'azerty');
$s->save();
$this->request('admin');
$this->assertRedirected('');
$this->assertFlashError('You don\'t have the rights to view this page');
}
示例11: createForUser
/**
* @param $user User
* @param $sessionOnly boolean
* @param null $expireDate int
* @return UserSession
*/
public static function createForUser($user, $expireDate)
{
$session = new UserSession();
$session->user = $user->id;
$session->token = Auth::generateSessionToken($user->salt);
$session->createDate = Database::now();
$session->expireDate = CommonUtil::sqlTimeStamp($expireDate);
$session->expired = 0;
$session->save();
return $session;
}
示例12: httpGetMethod
public function httpGetMethod(Http $http, array $queryFields)
{
/*
* Méthode appelée en cas de requête HTTP GET
*
* L'argument $http est un objet permettant de faire des redirections etc.
* L'argument $queryFields contient l'équivalent de $_GET en PHP natif.
*/
$userSession = new UserSession();
if ($userSession->isAdminAuthenticated() == false) {
$http->redirectTo('/');
}
}
示例13: httpPostMethod
public function httpPostMethod(Http $http, array $formFields)
{
/*
* Méthode appelée en cas de requête HTTP POST
*
* L'argument $http est un objet permettant de faire des redirections etc.
* L'argument $formFields contient l'équivalent de $_POST en PHP natif.
*/
$userSession = new UserSession();
if ($userSession->isAuthenticated() == false) {
$http->redirectTo('/User/Login');
}
//TODO : API BANCAIRE
$http->redirectTo('/Order/Payment/Success');
}
示例14: httpPostMethod
public function httpPostMethod(Http $http, array $formFields)
{
$dateTime = date_create($formFields['resaDate']);
$resaDate = date_format($dateTime, 'Y-m-d');
//var_dump($_POST, $resaDate);
$booking = new Database();
$userSession = new UserSession();
$userId = $userSession->getId();
//var_dump($userId);
if (ctype_digit($userId)) {
$bookingList = $booking->queryOne('SELECT COUNT(Id) AS count FROM Booking WHERE Customer_Id = ? AND BookingDate = ?', [$userId, $resaDate]);
/*var_dump(json_encode($bookingList['count']));*/
$http->sendJsonResponse($bookingList);
}
}
示例15: modules
public static function modules()
{
$session = UserSession::get();
if ($session)
{
$user = $session->user();
if (!Acl::isAllowed($user->username, 'admin'))
{
return null;
}
}
else
{
return null;
}
CoOrg::loadPluginInfo('admin');
$modules = array();
foreach (self::$_modules as $m)
{
if ($m->isAllowed($user))
{
$modules[] = $m;
}
}
usort($modules, array('Admin', 'cmpModule'));
return $modules;
}