當前位置: 首頁>>代碼示例>>PHP>>正文


PHP UserSession類代碼示例

本文整理匯總了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('/');
     }
 }
開發者ID:annacrea,項目名稱:ChezPaolo,代碼行數:33,代碼來源:BookingController.class.php

示例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];
     }
 }
開發者ID:paolocl,項目名稱:ChezPaolo,代碼行數:30,代碼來源:ModificationController.class.php

示例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();
}
開發者ID:h07r0d,項目名稱:leaguerunner,代碼行數:7,代碼來源:session.php

示例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];
     }
 }
開發者ID:paolocl,項目名稱:ChezPaolo,代碼行數:30,代碼來源:UserController.class.php

示例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');
     }
 }
開發者ID:annacrea,項目名稱:ChezPaolo,代碼行數:27,代碼來源:UserController.class.php

示例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');
     }
 }
開發者ID:paolocl,項目名稱:ChezPaolo,代碼行數:31,代碼來源:SupbookingController.class.php

示例7: getUser

 public function getUser()
 {
     require_once WEBAPPROOT . 'security/UserSession.php';
     $session = new UserSession();
     $session->start();
     return $session->getUser();
 }
開發者ID:fallouseven,項目名稱:projet_rpm,代碼行數:7,代碼來源:AuthentificationManager.php

示例8: httpGetMethod

 public function httpGetMethod(Http $http, array $queryFields)
 {
     if (isset($_GET['logout']) && $_GET['logout'] == 'out') {
         $userSession = new UserSession();
         $userSession->destroy();
         $http->redirectTo('/');
     }
 }
開發者ID:paolocl,項目名稱:ChezPaolo,代碼行數:8,代碼來源:LogoutController.class.php

示例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';
 }
開發者ID:berlianaputri,項目名稱:rps,代碼行數:9,代碼來源:AjaxController.php

示例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');
	}
開發者ID:nathansamson,項目名稱:CoOrg,代碼行數:10,代碼來源:admin.controller.Test.php

示例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;
 }
開發者ID:pvpalvk,項目名稱:kyberkoulutus2,代碼行數:17,代碼來源:UserSession.php

示例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('/');
     }
 }
開發者ID:paolocl,項目名稱:ChezPaolo,代碼行數:13,代碼來源:AddController.class.php

示例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');
 }
開發者ID:paolocl,項目名稱:ChezPaolo,代碼行數:15,代碼來源:PaymentController.class.php

示例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);
     }
 }
開發者ID:paolocl,項目名稱:ChezPaolo,代碼行數:15,代碼來源:BookingcheckController.class.php

示例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;
	}
開發者ID:nathansamson,項目名稱:CoOrg,代碼行數:28,代碼來源:admin.model.php


注:本文中的UserSession類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。