Example #1
0
 private function start()
 {
     if (FALSE === self::$started) {
         session_start();
         self::$started = TRUE;
     }
 }
Example #2
0
 private function showUserPersonal()
 {
     $user = Bobr_Session::getInstance()->user;
     $output = '<p>Uzivatel: <b>' . $user->nick . '</b> je zalogovan.<p>';
     $output .= '<a href="' . Lib_Link::build('odhlaseni', TRUE) . '" title="Odhlasit se">Odhlasit se</a>';
     return $output;
 }
Example #3
0
 /**
  * Nastavi lang sybmol dle pravidel.
  *
  * @return Process
  */
 private function setLang()
 {
     $config = new Config();
     switch ($config->remoteLangFrom) {
         case 'config':
             $this->lang = $config->defaultLang;
             $this->webRoot = $config->webRoot;
             break;
         case 'browser':
             throw new Bobr_ProcessException('fycura prebrani jazyku z prohlizece neni jeste napsana.');
             break;
         case 'uri':
             // Nactem si lang z GETu
             $lang = Bobr_Request_HttpRequest::lang();
             if (empty($lang)) {
                 // Lang byl prazdny presmerujem ho na url s defaultnim langem
                 $this->webRoot = $config->webRoot . $config->defaultLang . '/';
                 Bobr_Request_HttpRequest::redirect($this->webRoot);
             } else {
                 $this->webRoot = $config->webRoot . $config->defaultLang . '/';
                 $this->lang = $lang;
             }
             break;
         default:
             $this->lang = $config->defaultLang;
             $this->webRoot = $config->webRoot;
             break;
     }
     // @todo mela by probehnout nejake validace langu.
     Bobr_Session::getInstance()->lang = $this->lang;
     return $this;
 }
Example #4
0
 public function __construct()
 {
     $user = Bobr_Session::getInstance()->user;
     if (empty($user->commands)) {
         throw new Exception('Zrejme neni nastaven uzivatel nebo nema zadna prava.');
     }
     $this->commandList = $user->commands;
 }
Example #5
0
 /**
  * Zvaliduje jestli v session je paltny objekt User.
  *
  * @return boolean
  */
 public function validate()
 {
     $session = Bobr_Session::getInstance();
     if (isset($session->user) && $session->user instanceof Bobr_User_User) {
         return TRUE;
     } else {
         return FALSE;
     }
 }
Example #6
0
 /**
  * Vygeneruje link na webRoot.
  * Pozor pouzivat az po tom co se provede Process, pouzivaji se z nej hodnoty.
  *
  * @return string
  */
 public static function getWebRoot()
 {
     $config = new Config();
     $webRoot = $config->webRoot;
     if ($config->remoteLangFrom === 'uri') {
         $webRoot .= Bobr_Session::lang() . '/';
     }
     return $webRoot;
 }
Example #7
0
 /**
  * Vraci instanci objektu Messanger, ktera je ulozena v session.
  *
  * @return Messanger
  */
 public static function getInstance()
 {
     if (Bobr_Session::getNamespace('Messanger') instanceof Lib_Messanger) {
         return Bobr_Session::getNamespace('Messanger');
     } else {
         Bobr_Session::setNamesapce('Messanger', new Lib_Messanger());
         self::$instance = Bobr_Session::getNamespace('Messanger');
         return self::$instance;
     }
 }
Example #8
0
 /**
  * Pokud je v session validni uzivatel a neni to anonymnous vraci true.
  *
  * @return boolean
  */
 public static function isLoged()
 {
     $userValidator = new Bobr_User_UserValidator();
     $user = Bobr_Session::getInstance()->user;
     if (TRUE === $userValidator->validate() && self::ANONYMOUS_USER_ID != $user->id) {
         return TRUE;
     } else {
         return FALSE;
     }
 }
Example #9
0
 /**
  * Odnastavi celou session a nastavi ji novy has
  *
  * @param mixed Bobr_Session
  * @return void
  */
 private function setSession(Bobr_Session $session)
 {
     $session->destroy();
     $session->hash = sha1(sha1($this->salt) . sha1(self::$remoteAddr . sha1($this->publicKey)));
 }
Example #10
0
 /**
  * Odnastavi usera v session.
  *
  * @return UserLogin
  */
 private function unsetUserFromSession()
 {
     unset(Bobr_Session::getInstance()->user);
     return $this;
 }
 public function __construct()
 {
     $user = Bobr_Session::getInstance()->user;
     $this->webInstanceList = $user->webInstance;
 }
Example #12
0
 /**
  * Zvaliduje session a nastavi uzivatele.
  *
  * @return Bobr
  */
 private function setUser()
 {
     // Zvalidujem platnost Session
     new Bobr_SessionValidator();
     $validator = new Bobr_User_UserValidator();
     // Zvalidujem uzivatele v session
     if (FALSE === $validator->validate()) {
         // Uzivatel nebyl validni nastavime anonymouse
         $user = Bobr_Session::getInstance()->user = new Bobr_User_User(2);
         echo '<p>Nastavil jsem <b>' . $user->nick . '</b>.</p>';
     } else {
         $user = Bobr_Session::getInstance()->user;
         echo '<p>Uzivatel <b>' . $user->nick . '</b> mel jiz vytvorenou session.</p>';
     }
     $user = Bobr_Session::getInstance()->user;
     $webInstanceValidatdor = new Bobr_WebInstanceValidator();
     if (TRUE === $webInstanceValidatdor->validate(Lib_Tools::getWebInstance())) {
         echo '<p>Uzivatel ma pristup na tuto web instanci</p>';
     } else {
         Lib_Messanger::addError('Nemate pristup na tuto stranku.');
         //@todo tato hlaska se pri presmerovani vymaze!!
         Bobr_Request_HttpRequest::redirect('/');
     }
     return $this;
 }