Пример #1
0
 protected function _appendSid(array $urlOptions = array())
 {
     if (!array_key_exists('sid', $urlOptions)) {
         if ($sessionId = Showcase_Session::getSessionKey()) {
             $urlOptions['sid'] = $sessionId;
         }
     }
     return $urlOptions;
 }
Пример #2
0
 protected function _session()
 {
     if (!$this->_session instanceof Zend_Session_Namespace) {
         $this->_session = new Zend_Session_Namespace(__CLASS__);
         if (!isset($this->_session->initialized)) {
             Showcase_Session::regenerateId();
             $this->_session->initialized = true;
         }
         $this->_session->lock();
     }
     return $this->_session;
 }
Пример #3
0
function smarty_function_url($params, Smarty $smarty)
{
    $url = null;
    if (($urlHelper = Showcase_Controller_Action_HelperBroker::getStaticHelper('url')) && $urlHelper instanceof Showcase_Controller_Action_Helper_Url) {
        $assignVar = null;
        $uriParams = array();
        foreach ($params as $key => $val) {
            if ('assign' == $key) {
                $assignVar = $val;
            } elseif (!$val) {
            } else {
                $uriParams[$key] = strval($val);
            }
        }
        if (array_key_exists('route', $uriParams)) {
            // this is a route
            $routeName = $uriParams['route'];
            unset($uriParams['route']);
            try {
                $url = $urlHelper->url($uriParams, $routeName, true);
            } catch (Zend_Exception $e) {
                echo $e->getMessage();
            }
        } else {
            foreach (array('action', 'controller', 'module') as $key) {
                if (array_key_exists($key, $uriParams)) {
                    ${$key} = $uriParams[$key];
                    unset($uriParams[$key]);
                } else {
                    ${$key} = null;
                }
            }
            $url = $urlHelper->simple($action, $controller, $module, $uriParams, true);
        }
        if (0 !== strpos(strrev($url), '/')) {
            $url .= '/';
        }
        if ($sessionId = Showcase_Session::getSessionKey()) {
            $url .= "sid/{$sessionId}";
        }
        $url = $url ? 0 === strpos($url, '/') ? $url : '/' . $url : '#';
        if (!$assignVar) {
            echo $url;
        } else {
            $smarty->assign($assignVar, $url);
        }
    }
}
Пример #4
0
 /**
  * routeStartup() - check to see if a session exists versus a given parameter
  *
  * @param  (Zend_Controller_Request_Abstract $request
  * @return void
  */
 public function routeStartup(Zend_Controller_Request_Abstract $request)
 {
     //$request->setParam('ClientId','1');
     $regenerate = false;
     $uri = $request->getRequestUri();
     if (preg_match($this->_regex, $uri, $uriKey)) {
         $sessionKey = $uriKey[1];
         unset($uriKey);
         // OK we have a session ID passed to us by $_GET
         // Check to see if a cookie exists for this user
         if (Showcase_Session::sessionExists()) {
             // Cookie exists, remove the SID param from the request
             $request->setParam('sid', null);
         } else {
             if (false === strpos($_SERVER['HTTP_USER_AGENT'], 'Googlebot')) {
                 Showcase_Session::setSessionKey($sessionKey);
                 // no session for this user
                 // a get query and no session means either they are using an old link
                 // or that they have really high security settings
                 // let's go to the database and see if we can find them
                 $regenerate = true;
                 $sessionId = Showcase_Session::getSessionId($request);
                 // checks database to get the true PHPSESSID
                 if ($sessionId) {
                     // they have a session in the database, set their current session as the existing one
                     // and then regenerate it anyway as a security measure.
                     try {
                         Showcase_Session::setId($sessionId);
                     } catch (Zend_Exception $e) {
                         try {
                             Showcase_Session::destroy(true);
                         } catch (Zend_Exception $e) {
                         }
                     }
                 }
                 unset($sessionId);
                 // this is not a variable you want lying around.  Ever.  Unsetting just to be safe.
             }
         }
         $request->setRequestUri(preg_replace($this->_regex, '', $uri));
     }
     Showcase_Session::start();
     if ($regenerate) {
         Showcase_Session::regenerateId();
     }
 }
Пример #5
0
 protected function _load($showId = null, $method = null, $preview = 0, $offset = 0, $limit = null, array $portals = array(), array $channels = array(), $series = null, $start = null, $finish = null, $exclude = null, $searchTerm = null, $searchFilter = null, $transcript = null)
 {
     $user = $this->getRequest()->getParam('User');
     $args = array('type' => $method ? $method : $this->getRequest()->getParam('action', null), 'userId' => $user->id, 'ip' => Showcase_Session::getRemoteIp($this->getRequest()), 'cache' => $user->isCmsUser ? false : true, 'preview' => $user->isCmsUser ? $preview : 0, 'portals' => $user->isCmsUser ? count($portals) ? implode(', ', $portals) : null : $this->getRequest()->getParam('Portal')->id, 'channels' => count($channels) ? implode(', ', $channels) : ($this->getRequest()->getParam('Channel', null) ? $this->getRequest()->getParam('Channel')->id : null), 'series' => $series, 'offset' => $offset, 'limit' => $limit, 'start' => $start ? new Zend_Date($start, Zend_registry::get('locale')) : null, 'finish' => $finish ? new Zend_Date($finish, Zend_registry::get('locale')) : null, 'show' => $showId, 'exclude' => $exclude, 'search' => $searchTerm, 'filter' => $searchFilter, 'transcript' => $transcript);
     $return = null;
     if ($args['cache']) {
         $id = $this->_makeId($method, $args);
         if ($this->_cache()->test($id)) {
             $return = unserialize($this->_cache()->load($id));
         }
     }
     if (!$return) {
         $return = call_user_func_array(array($this, '_factory'), $args);
         if ($args['cache']) {
             $this->_cache()->save(serialize($return), $id);
         }
     }
     return $return;
 }
Пример #6
0
 protected function _update()
 {
     $userId = false;
     $sessionKey = $this->_getSessionKey();
     if ($sessionKey) {
         $stmt = Zend_Registry::get('dbh')->proc('session_load');
         $stmt->bindParam(':key', $sessionKey, PDO::PARAM_STR);
         try {
             $stmt->execute();
         } catch (Zend_Db_Statement_Exception $e) {
             die('session_load: ' . $e->getMessage());
         }
         $result = $stmt->fetchAll(Zend_Db::FETCH_OBJ);
         $stmt->closeCursor();
         $userDetails = false;
         if (is_array($result) && count($result)) {
             $userDetails = $result[0];
         }
         unset($stmt);
         if ($userDetails instanceof stdClass) {
             if (Showcase_Session::checkIpRange(Showcase_Session::encodeIp($this->_remoteIp), $userDetails->ip)) {
                 if ($userDetails->agent == $this->_sessionData->agent) {
                     $stmt = Zend_Registry::get('dbh')->proc('session_update');
                     $stmt->bindParam(':new_key', $sessionKey, PDO::PARAM_STR);
                     try {
                         $stmt->execute();
                     } catch (Zend_Db_Statement_Exception $e) {
                         die(__LINE__ . ':' . __FILE__ . ':' . $e->getMessage());
                     }
                     $stmt->closeCursor();
                     unset($stmt);
                     $this->_sessionData->key = $sessionKey;
                     $this->_sessionData->start = $userDetails->start;
                     $this->_sessionData->update = $userDetails->updated;
                     $this->_sessionData->agent = $userDetails->agent;
                     //$this->_sessionData->portal		= $userDetails->portal;
                     $this->_sessionData->setUserId($userDetails->user);
                     if (self::SESSION_GET == $this->_sessionMethod) {
                         Showcase_Session::setSessionKey($sessionKey);
                     }
                     //$this->_cleanUpExpiredSessions();
                     return true;
                 }
             }
         }
     }
     $this->_insert();
 }
Пример #7
0
 protected static function _ipValidate($ip)
 {
     if (!self::$_ipValidator instanceof Zend_Validate_Hostname) {
         self::$_ipValidator = new Zend_Validate_Hostname(Zend_Validate_Hostname::ALLOW_IP);
     }
     return self::$_ipValidator->isValid($ip);
 }