Esempio n. 1
0
 private function getRequestedNetlet(\blaze\netlet\http\HttpNetletRequest $request, \blaze\netlet\NetletContext $context)
 {
     // Making sure that the Url ends with a '/'
     $uri = $request->getRequestURI()->getPath();
     if (!$uri->endsWith('/')) {
         $uri = $uri->concat('/');
     }
     foreach ($context->getNetletMapping() as $key => $name) {
         // Make a regex placeholders of the wildcards
         $regex = '/' . strtolower(str_replace(array('/', '*'), array('\\/', '.*'), $key)) . '/';
         // Check if the requested url fits a netlet mapping
         if ($uri->matches($regex)) {
             $netlets = $context->getNetlets();
             return $netlets->get($name);
         }
     }
     return null;
 }
 public function getCurrentSession(\blaze\netlet\http\HttpNetletRequest $request, $create = false)
 {
     if ($this->session == null) {
         $sessionId = null;
         foreach ($request->getCookies() as $cookie) {
             if ($cookie->getName()->compareTo(self::SESSION_NAME) == 0) {
                 $sessionId = $cookie->getValue();
                 break;
             }
         }
         if ($sessionId != null) {
             $this->readSession($sessionId);
         }
         if ($this->session == null && $create) {
             session_name(self::SESSION_NAME);
             session_id(hash('sha512', md5(uniqid()) . sha1(uniqid())));
             ini_set('session.use_cookies', '0');
             session_start();
             $this->session = new HttpSessionImpl($this, session_id(), $_SESSION);
         }
     }
     return $this->session;
 }
 public function setAttribute($name, $o)
 {
     $this->request->setAttribute($name, $o);
 }
 /**
  *
  * @param HttpNetletRequest $request
  * @return string
  */
 public static function getApplicationName(HttpNetletRequest $request)
 {
     $uri = $request->getRequestURI()->getPath();
     if (!$uri->endsWith('/')) {
         $uri = $uri->concat('/');
     }
     foreach (self::$serverConfig->get('applications') as $app) {
         $regex = '/' . str_replace(array('/', '*'), array('\\/', '.*'), $app->getUrlPrefix()) . '/';
         if ($uri->matches($regex)) {
             return $app->getPackage();
         }
     }
     return null;
 }
Esempio n. 5
0
 private function getRequestedFilters(\blaze\netlet\http\HttpNetletRequest $request, \blaze\netlet\NetletContext $context)
 {
     $uri = $request->getRequestURI()->getPath();
     if (!$uri->endsWith('/')) {
         $uri = $uri->concat('/');
     }
     $filterArr = new \blaze\collections\lists\ArrayList();
     // Looking in the filter mapping for a filter that fits the url
     foreach ($context->getFilterMapping() as $key => $name) {
         // Make a regex placeholders of the wildcards
         $regex = '/' . strtolower(str_replace(array('/', '*'), array('\\/', '.*'), $key)) . '/';
         // Check if the requested url fits a netlet mapping
         if ($uri->matches($regex)) {
             $filters = $context->getFilters();
             $filterArr->add($filters->get($name));
         }
     }
     return $filterArr;
 }