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('/');
     }
 }
 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];
     }
 }
Example #3
0
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();
}
 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];
     }
 }
 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');
     }
 }
 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');
     }
 }
 public function getUser()
 {
     require_once WEBAPPROOT . 'security/UserSession.php';
     $session = new UserSession();
     $session->start();
     return $session->getUser();
 }
 public function httpGetMethod(Http $http, array $queryFields)
 {
     if (isset($_GET['logout']) && $_GET['logout'] == 'out') {
         $userSession = new UserSession();
         $userSession->destroy();
         $http->redirectTo('/');
     }
 }
Example #9
0
 protected function GetFullName(ReservationItemView $reservation)
 {
     $shouldHide = Configuration::Instance()->GetSectionKey(ConfigSection::PRIVACY, ConfigKeys::PRIVACY_HIDE_USER_DETAILS, new BooleanConverter());
     if ($shouldHide && (is_null($this->user) || $this->user->UserId != $reservation->UserId && !$this->user->IsAdminForGroup($reservation->OwnerGroupIds()))) {
         return Resources::GetInstance()->GetString('Private');
     }
     $name = new FullName($reservation->FirstName, $reservation->LastName);
     return $name->__toString();
 }
Example #10
0
 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';
 }
	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');
	}
Example #12
0
 /**
  * @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;
 }
Example #13
0
 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('/');
     }
 }
 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');
 }
 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);
     }
 }
Example #16
0
	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;
	}
Example #17
0
 public static function getInstance()
 {
     if (self::$Instance === null) {
         self::$Instance = new UserSession();
     }
     return self::$Instance;
 }
Example #18
0
 public static function getInstance()
 {
     if (!isset(UserSession::$instance)) {
         UserSession::$instance = new UserSession();
     }
     return UserSession::$instance;
 }
Example #19
0
 public static function getMenuShortCuts()
 {
     $user_info = UserSession::getSessionInfo();
     //功能菜单
     $data = array();
     $data = Module::getAllModule();
     $user_info = UserSession::getSessionInfo();
     //用户的权限
     $access = MenuUrl::getMenuByRole($user_info['user_role']);
     foreach ($data as $k => $module) {
         $list = MenuUrl::getlistByModuleId('shortcut', $module['module_id']);
         if (!$list) {
             unset($data[$k]);
             continue;
         }
         //去除无权限访问的
         foreach ($list as $key => $value) {
             if (!in_array($value['menu_url'], $access)) {
                 unset($list[$key]);
             }
         }
         $data[$k]['menu_list'] = $list;
     }
     return $data;
 }
Example #20
0
 /**
  * @return UserSession The single shared instance
  */
 public static function getInstance()
 {
     if (!self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Example #21
0
 public function getUser()
 {
     if (empty($this->_user)) {
         return $this->_user = UserSession::getUser();
     } else {
         return $this->_user;
     }
 }
Example #22
0
 public function __construct()
 {
     parent::__construct();
     $this->_user = UserSession::getUser();
     $this->load->vars('login_user', $this->_user);
     $this->_is_login = UserSession::isLogin();
     $this->load->vars('is_login', $this->_is_login);
     $this->_controller = get_class($this);
 }
 public function httpPostMethod(Http $http, array $formFields)
 {
     if (filter_var($formFields['Login'], FILTER_VALIDATE_EMAIL) != false) {
         $CustomerModel = new CustomerModel();
         $user_id = $CustomerModel->findWithCredentials($formFields['Login'], $formFields['Password']);
         //var_dump($user_id);
         if (ctype_digit($user_id)) {
             $user = $CustomerModel->findCustomer($user_id);
             $UserSession = new UserSession();
             $UserSession->create($user);
             $http->redirectTo('/');
         } else {
             $http->redirectTo('Exception?' . $user_id);
         }
     } else {
         $http->redirectTo('Exception?Error=4');
     }
 }
Example #24
0
 /**
  * @see UserSession::__construct()
  */
 public function __construct($userID = null, $row = null, $username = null)
 {
     // user data
     $this->sqlSelects .= " lw_user.*, ";
     $this->sqlJoins .= " LEFT JOIN ugml" . LW_N . "_users\r\n\t\t\t\t\t\t\t\tAS lw_user\r\n\t\t\t\t\t\t\t\tON lw_user.id = user.userID ";
     // other selects
     $this->sqlSelects .= " lw_user.id AS lwUserID, ";
     parent::__construct($userID, $row, $username);
 }
 /**
  * @see Action::execute()
  */
 public function execute()
 {
     // call execute event
     parent::execute();
     // save status
     UserSession::saveStatus($this->name, $this->status);
     // call executed event
     $this->executed();
 }
 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 */
     try {
         $userSession = new UserSession();
         if ($userSession->isAuthenticated()) {
             $dateTime = date_create($formFields['dateResa'] . ' ' . $formFields['timeResa']);
             if ($dateTime == false) {
                 throw new InvalidArgumentException(BookingModel::$dateException);
             }
             $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']);
                 $flashBag = new FlashBag();
                 $flashBag->add("Votre réservation numero {$resultat} du {$resaDate} à {$resaTime} pour " . $formFields['NumberOfSeats'] . " est bien pris en compte");
                 $http->redirectTo('/');
             } elseif ($dateTime < $now) {
                 throw new InvalidArgumentException(BookingModel::$PasseDateException);
             } else {
                 throw new InvalidArgumentException(BookingModel::$FieldsException);
             }
         } else {
             $http->redirectTo('/');
         }
     } catch (InvalidArgumentException $event) {
         //var_dump($event);
         $form = new BookingForm();
         $form->bind($formFields);
         $form->setErrorMessage($event->getMessage());
         return ['_form' => $form];
     }
 }
	public function save($subject, $body, $commentOn,
	                     $name = null, $email = null, $website = null)
	{
		$commentClass = $this->_commentClass;
		$comment = new $commentClass;
		$comment->title = $subject;
		$comment->comment = $body;
		
		if (UserSession::get())
		{
			$comment->author = UserSession::get()->user();
			$comment->spamStatus = PropertySpamStatus::OK;
		}
		else
		{
			$publicProfile = new AnonProfile;
			$publicProfile->name = $name;
			$publicProfile->email = $email;
			$publicProfile->website = $website;
			$publicProfile->IP = Session::IP();
			$comment->anonAuthor = $publicProfile;
			
			if ($this->checkSpamStatus($comment, $publicProfile) === false)
			{
				$this->newComment = $comment;
				$this->commentRequests = $this->_commentRequests;
				$this->renderErrorSave($commentOn);
				return;
			}
		}
		if ($comment->spamStatus != PropertySpamStatus::SPAM)
		{
			try
			{
				$commentOn->comments[] = $comment;
				if ($comment->spamStatus == PropertySpamStatus::OK)
				{
					$this->notice(t('Your comment has been posted'));
				}
				$this->beforeSuccess($commentOn, $comment);
				$this->redirectOnSuccess($commentOn);
			}
			catch (ValidationException $e)
			{
				$this->error(t('Your comment was not posted'));
				$this->newComment = $comment;
				$this->commentRequests = $this->_commentRequests;
				$this->renderErrorSave($commentOn);
			}
		}
		else
		{
			$this->notice(t('Your comment has been marked as spam, and will not appear'));
			$this->redirectOnSuccess($commentOn);
		}
	}
 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');
     }
     $orderModel = new OrderModel();
     $order_Id = $orderModel->validation($formFields['order'], $userSession->getId());
     //$order = $orderModel->getOrderById($order_Id);
     //return ['order', $order];
     $http->redirectTo('/Order/Payment?order_Id=' . $order_Id);
     // TODO : PAGE DE VALIDATION DU PANIER ET BOUTON PAYMENT
 }
Example #29
0
 public static function logout()
 {
     if (!Session::getUser()) {
         Session::deleteSessionCookie();
         return;
     }
     $token = Session::getSessionCookie();
     $session = UserSession::findByToken($token);
     $session->expired = 1;
     $session->save();
     Session::deleteSessionCookie();
 }
Example #30
0
 /**
  * @see UserProfile::__construct()
  */
 public function __construct($userID = null, $row = null, $username = null, $email = null)
 {
     $this->sqlSelects .= ' lw_user.*, lw_stat.*, lw_user.password AS gamePassword, ';
     $this->sqlJoins .= ' LEFT JOIN ugml_users lw_user ON (lw_user.id = user.userID) ';
     $this->sqlJoins .= ' LEFT JOIN ugml_stat lw_stat ON (lw_stat.userID = user.userID) ';
     // new stats
     $this->sqlSelects .= " wot_stat.rank AS wotRank,\n\t\t\t\t\t\t\t\twot_stat.points AS wotPoints, ";
     $this->sqlJoins .= " LEFT JOIN ugml_stat_entry \n\t\t\t\t\t\t\t\tAS wot_stat\n\t\t\t\t\t\t\t\tON wot_stat.statTypeID = " . self::STAT_TYPE_ID . "\n\t\t\t\t\t\t\t\t\tAND wot_stat.relationalID = user.userID ";
     parent::__construct($userID, $row, $username, $email);
     $this->points = $this->wotPoints;
     $this->rank = $this->wotRank;
 }