/**
  * 判断是否有访问某个游戏的条件
  * 
  * @see Zend_Acl_Assert_Interface::assert()
  */
 public function assert(Zend_Acl $acl, Zend_Acl_Role_Interface $role = null, Zend_Acl_Resource_Interface $resource = null, $privilege = null)
 {
     if ($this->_request->has('gametype')) {
         $roleData = ZtChart_Model_Acl_Loader::getInstance()->getRole($role->getRoleId());
         return in_array($this->_request->getParam('gametype'), $roleData['role_gametype']);
     }
     return true;
 }
Beispiel #2
0
 public function test_marshall_PUT_body_as_params()
 {
     $this->request->setMethod('PUT');
     $this->request->setRawBody('param1=value1&param2=value2');
     $this->plugin->preDispatch($this->request);
     $this->assertEquals('value1', $this->request->getParam('param1'));
     $this->assertEquals('value2', $this->request->getParam('param2'));
 }
 /**
  * Performs an authentication attempt
  *
  * @throws Zend_Auth_Adapter_Exception If authentication cannot be performed
  * @return Zend_Auth_Result
  */
 public function authenticate()
 {
     if (empty($this->_request) || empty($this->_response)) {
         throw new Zend_Auth_Adapter_Exception('Request and Response objects must be set before calling authenticate method');
     }
     if ($this->_request->getParam('module') != 'download') {
         throw new Zend_Auth_Adapter_Exception('Wrong endpoint');
     }
     try {
         $token = $this->_request->getParam('downloadToken');
         if (!$token instanceof Download\Model\DownloadTokenModel) {
             throw new Zend_Auth_Adapter_Exception("Download token data is missing", 401);
         }
         if ($token->authType == \App_Controller_Plugin_Auth::AUTH_TYPE_EXTERNAL) {
             $apiId = $token->apiId;
             $apiIdMapper = Application\Model\Mapper\APIIdMapper::getInstance();
             $res = $apiIdMapper->findOneByApiId($apiId);
             if (empty($res)) {
                 throw new \Application\Exceptions\NotFoundException("Api id '{$apiId}' not found (at Mongo)");
             }
             $orgId = $res->getOrgId();
             $apiUserId = 'API_' . $apiId;
             if (empty($orgId)) {
                 throw new Zend_Auth_Adapter_Exception("Organization id not defined in Api id '{$apiId}' ");
             }
             $result = array('id' => $apiUserId, 'apiId' => $apiId, 'username' => 'api_' . $orgId, 'monetaryDataAccess' => $res->getMonetaryDataAccess(), 'orgId' => $orgId, 'role' => 'admin', 'authType' => App_Controller_Plugin_Auth::AUTH_TYPE_DOWNLOAD_TOKEN);
         } else {
             if ($username = $token->username) {
                 $userMapper = Application\Model\Mapper\UserMapper::getInstance();
                 $res = $userMapper->findOneByUserName($username);
                 if (empty($res)) {
                     throw new \Application\Exceptions\NotFoundException("User name '{$username}' not found");
                 }
                 $orgId = $res->getOrganizationId();
                 if (empty($orgId)) {
                     throw new Zend_Auth_Adapter_Exception("User '{$username}' has no orgId");
                 }
                 $result = array('id' => $res->id, 'username' => $username, 'monetaryDataAccess' => $res->getMonetaryDataAccess(), 'role' => $res->getRole(), 'orgId' => $orgId, 'authType' => App_Controller_Plugin_Auth::AUTH_TYPE_DOWNLOAD_TOKEN, 'language' => $res->language);
             }
         }
         //             App_Controller_Plugin_TrackingToken::generateToken($username, $orgId);
         //             $orgSrv = \Application\Service\OrgService::getInstance();
         //             $organization = $orgSrv->load($orgId);
         //             if (empty($organization)) {
         //                 throw new \Application\Exceptions\NotFoundException("Org '$orgId' not found");
         //             }
         if ($token->impersonation) {
             $result['impersonation'] = $token->impersonation;
         }
         $result['downloadToken'] = $token;
         return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $result);
     } catch (Exception $e) {
         \App::log()->err($e->getMessage());
     }
     \App::log()->warn("Download authentication failed: Token => " . @$token->id ?: null);
     return new Zend_Auth_Result(Zend_Auth_Result::FAILURE, null);
 }
Beispiel #4
0
 /**
  * Constructor to setup the strategy
  */
 public function __construct(Zend_Controller_Request_Http $request, Zend_Controller_Response_Http $response)
 {
     $this->strategies = new Zend_Loader_PluginLoader(array('App_Auth_Strategy' => 'App/Auth/Strategy'));
     $auth = Zend_Auth::getInstance();
     $this->user = $auth->getIdentity();
     $this->request = $request;
     $this->response = $response;
     $this->setStrategy($this->request->getParam('strategy', 'db'));
 }
Beispiel #5
0
 public static function noControllerResponse(XenForo_RouteMatch $routeMatch, Zend_Controller_Request_Http $request)
 {
     self::sendErrorPageHeaders();
     if (XenForo_Application::debugMode()) {
         echo 'Failed to get controller response and reroute to error handler (' . $routeMatch->getControllerName() . '::action' . $routeMatch->getAction() . ')';
         if ($request->getParam('_exception')) {
             echo self::getExceptionTrace($request->getParam('_exception'));
         }
     } else {
         echo self::_getPhrasedTextIfPossible('An unexpected error occurred. Please try again later.', 'unexpected_error_occurred');
     }
 }
Beispiel #6
0
 /**
  * Init method.
  * Call during construction of the controller to perform some default initialization.
  */
 public function init()
 {
     parent::init();
     $this->getResponse()->setHeader('Content-Type', $this->_mimetype);
     $this->_request->setParam('view', $this->_helper->viewRenderer);
     $this->_helper->viewRenderer->setViewScriptPathSpec(":action.phtml");
     $this->view->addHelperPath(USVN_HELPERS_DIR, 'USVN_View_Helper');
     $this->_helper->layout->setLayout('default');
     $this->_request->setParam('project', $this->_request->getParam('project', '__NONE__'));
     $this->_request->setParam('area', $this->_request->getParam('area', '__NONE__'));
     if ($this->_mimetype != 'text/html') {
         $this->_helper->viewRenderer->setNoRender();
     }
 }
Beispiel #7
0
 public function linkDoctorAccount(Doctor $doctor)
 {
     $token = AccessToken::getByDoctor($doctor);
     if (!$token instanceof AccessToken) {
         $token = AccessToken::create();
         $token->setDoctor($doctor);
     }
     $client = MedOptima_Service_Google_Config::getCalendarClient();
     if ($this->_request->getParam('code')) {
         $client->authenticate($this->_request->getParam('code'));
         (new MedOptima_Service_Google_AccessToken_Initializer())->updateFromEncodedData($token, $client->getAccessToken());
     }
     $token->save();
     return true;
 }
 /**
  * @param Zend_Controller_Request_Http $request
  */
 public function preDispatch($request)
 {
     // dont filter anything if a resident is logged in
     $session = new Zend_Session_Namespace();
     if ($session->currentResidentId) {
         $session->currentResident = Table_Residents::getInstance()->find($session->currentResidentId)->current();
         return;
     }
     // allow index and session controller to all
     if ($request->getControllerName() == 'index' || $request->getControllerName() == 'session') {
         return;
     }
     // Authenticate direct requests for non-html stuff
     if ($request->getParam('format') !== "html") {
         // The requestor provided a username
         if (isset($_SERVER['PHP_AUTH_USER'])) {
             $resident = Table_Residents::getInstance()->findResidentByEmailAndPasswordhash($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
             if ($resident) {
                 $session->currentResidentId = $resident->getId();
                 $session->currentResident = $resident;
                 return;
             }
         }
         header('WWW-Authenticate: Basic realm="WG-Organizer"');
         header('HTTP/1.0 401 Unauthorized');
         die;
     }
     // else redirect to frontpage
     $request->setControllerName('index');
     $request->setActionName('index');
 }
Beispiel #9
0
 public function testGetAliasedParamZF2455()
 {
     $this->_request->setParam('controller', 'value');
     $this->_request->setAlias('var1', 'controller');
     $this->assertEquals('value', $this->_request->getParam('controller'));
     $this->assertEquals('value', $this->_request->getParam('var1'));
 }
Beispiel #10
0
 /**
  * @group ZF-1798
  */
 public function testParamSourcesHonoredByGetParam()
 {
     $_GET = array('foo' => 'bar');
     $_POST = array('foo' => 'baz');
     $this->_request->setParamSources(array('_POST'));
     $this->assertEquals('baz', $this->_request->getParam('foo'));
 }
Beispiel #11
0
 /**
  * Retrieve a parameter.
  *
  * Retrieves a parameter from the instance. Priority is in the order of
  * userland parameters (see {@link setParam()}), $_GET, $_POST. If a
  * parameter matching the $key is not found, null is returned.
  *
  * If the $key is an alias, the actual key aliased will be used.
  *
  * @param mixed $key
  * @param mixed $default Default value to use if key not found
  * @return mixed
  */
 public function getParam($key, $default = null)
 {
     $param = parent::getParam($key, $default);
     if (is_string($param)) {
         return trim($param);
     }
     return $param;
 }
 /**
  * 通过工厂方法快速获取 YUN_Paginator 对象
  *
  * @param  array  $data
  * @param  integer        $perPage
  * @param  string         $uriSegment
  * @return YUN_Paginator
  */
 public static function factory($data, Zend_Controller_Request_Http $request, $perPage = 20, $uriSegment = 'page')
 {
     $paginator = Zend_Paginator::factory($data);
     $paginator->setItemCountPerPage($perPage);
     // 每页显示数
     $paginator->setCurrentPageNumber($request->getParam($uriSegment));
     // 设置当前页
     return $paginator;
 }
Beispiel #13
0
 /**
  * Redirect to startup page after logging in if request contains any params (except security key)
  *
  * @param Mage_Admin_Model_User $user
  * @param Zend_Controller_Request_Http $request
  * @param string|null $alternativeUrl
  * @return null|string
  */
 public function getRedirectUrl(Mage_Admin_Model_User $user, Zend_Controller_Request_Http $request = null, $alternativeUrl = null)
 {
     if (empty($request)) {
         return;
     }
     $countRequiredParams = $this->_urlModel->useSecretKey() && $request->getParam(Mage_Adminhtml_Model_Url::SECRET_KEY_PARAM_NAME) ? 1 : 0;
     $countGetParams = count($request->getUserParams()) + count($request->getQuery());
     return $countGetParams > $countRequiredParams ? $this->_urlModel->getUrl($user->getStartupPageUrl()) : $alternativeUrl;
 }
Beispiel #14
0
 public function testPostDispatchQuitsWithFalseUserErrorHandlerParam()
 {
     $front = Zend_Controller_Front::getInstance();
     $front->resetInstance();
     $front->setParam('noErrorHandler', true);
     $this->response->setException(new Zend_Controller_Dispatcher_Exception('Testing controller exception'));
     $this->request->setModuleName('foo')->setControllerName('bar')->setActionName('baz');
     $this->plugin->postDispatch($this->request);
     $this->assertNull($this->request->getParam('error_handler'));
 }
Beispiel #15
0
 public function testSetNullParamsUnsetsKeys()
 {
     $this->_request->setParams(array('foo' => 'bar', 'bar' => 'baz'));
     $this->assertEquals('bar', $this->_request->getParam('foo'));
     $this->assertEquals('baz', $this->_request->getParam('bar'));
     $this->_request->setParams(array('foo' => null));
     $params = $this->_request->getParams();
     $this->assertFalse(isset($params['foo']));
     $this->assertTrue(isset($params['bar']));
 }
 /**
  * @param Zend_Controller_Request_Http $request
  */
 public function preDispatch($request)
 {
     // dont filter anything if a resident is logged in
     $session = new Zend_Session_Namespace();
     // Sets the resident id so the next if loads the user ;)
     if ($request->getParam('appauth_key')) {
         $session->currentResidentId = Table_Residents::getInstance()->findByAppAuthKey($request->getParam('appauth_key'));
     }
     if ($session->currentResidentId) {
         $session->currentResident = Table_Residents::getInstance()->find($session->currentResidentId)->current();
         return;
     }
     // allow index and session controller to all
     if ($request->getControllerName() == 'index' || $request->getControllerName() == 'session') {
         return;
     }
     // else redirect to frontpage
     $request->setControllerName('index');
     $request->setActionName('index');
 }
Beispiel #17
0
 public function dispatch()
 {
     $method = strtoupper($this->_request->getMethod());
     if ($method === 'POST' && null !== ($extraMethod = $this->_request->getParam('_method', null))) {
         $extraMethod = strtoupper(filter_var($extraMethod, FILTER_SANITIZE_STRING));
         if (in_array($extraMethod, array('PUT', 'DELETE'))) {
             $method = $extraMethod;
         }
     }
     $action = strtolower($method) . 'Action';
     $aclResource = strtolower(get_called_class() . '_' . $method);
     if (method_exists($this, $action)) {
         if (Tools_Security_Acl::isAllowed($aclResource)) {
             return $this->_jsonHelper->direct($this->{$action}());
         } else {
             $this->_error(null, self::REST_STATUS_FORBIDDEN);
         }
     } else {
         throw new Exceptions_SeotoasterPluginException(get_called_class() . ' doesn\'t have ' . $method . ' implemented');
     }
 }
Beispiel #18
0
 /**
  * Filter an individual item
  *
  * @param string $variableName Name of the input variable
  * @param mixed $filterData Filter information, can be a single constant or an array containing a filter and options
  * @param array $options Filtering options
  *
  * @return mixed Value after being cleaned
  */
 public function filterSingle($variableName, $filterData, array $options = array())
 {
     $filters = array();
     if (is_string($filterData)) {
         $filters = array($filterData);
     } else {
         if (is_array($filterData) && isset($filterData[0])) {
             $filters = is_array($filterData[0]) ? $filterData[0] : array($filterData[0]);
             if (isset($filterData[1]) && is_array($filterData[1])) {
                 $options = array_merge($options, $filterData[1]);
             } else {
                 unset($filterData[0]);
                 $options = array_merge($options, $filterData);
             }
         } else {
             throw new XenForo_Exception("Invalid data passed to " . __CLASS__ . "::" . __METHOD__);
         }
     }
     $firstFilter = reset($filters);
     if (isset($options['default'])) {
         $defaultData = $options['default'];
     } else {
         if (array_key_exists($firstFilter, self::$_DEFAULTS)) {
             $defaultData = self::$_DEFAULTS[$firstFilter];
         } else {
             $defaultData = null;
         }
     }
     if ($this->_request) {
         $data = $this->_request->getParam($variableName);
     } else {
         $data = isset($this->_sourceData[$variableName]) ? $this->_sourceData[$variableName] : null;
     }
     if ($data === null) {
         $data = $defaultData;
     }
     foreach ($filters as $filterName) {
         if (isset($options['array'])) {
             if (is_array($data)) {
                 foreach (array_keys($data) as $key) {
                     $data[$key] = self::_doClean($filterName, $options, $data[$key], $defaultData);
                 }
             } else {
                 $data = array();
                 break;
             }
         } else {
             $data = self::_doClean($filterName, $options, $data, $defaultData);
         }
     }
     $this->_cleanedVariables[$variableName] = $data;
     return $data;
 }
Beispiel #19
0
 /**
  * Check if request can be cached
  *
  * @param Zend_Controller_Request_Http $request
  * @return bool
  */
 public function allowCache(Zend_Controller_Request_Http $request)
 {
     foreach ($this->_noCacheGetParams as $param) {
         if (!is_null($request->getParam($param, null))) {
             return false;
         }
     }
     if (Mage::getSingleton('core/session')->getNoCacheFlag()) {
         return false;
     }
     return true;
 }
Beispiel #20
0
 /**
  * @param string $cat
  * @return bool True for success
  */
 protected function forwardCategory($cat)
 {
     // if somebody has old urls in the cache.
     if (!Mage::getStoreConfig('amshopby/seo/urls')) {
         return false;
     }
     $cat = trim($cat, '/');
     // we do not use Mage::getVersion() here as it is not defined in the old versions.
     $isVersionEE13 = 'true' == (string) Mage::getConfig()->getNode('modules/Enterprise_UrlRewrite/active');
     $suffix = $this->getUrlHelper()->getUrlSuffix();
     if ($isVersionEE13) {
         $urlRewrite = Mage::getModel('enterprise_urlrewrite/url_rewrite');
         /* @var $urlRewrite Enterprise_UrlRewrite_Model_Url_Rewrite */
         if (version_compare(Mage::getVersion(), '1.13.0.2', '>=')) {
             $catReqPath = array('request' => $cat . $suffix, 'whole' => $cat);
         } else {
             $catReqPath = array($cat);
         }
         $urlRewrite->setStoreId(Mage::app()->getStore()->getId())->loadByRequestPath($catReqPath);
     } else {
         $urlRewrite = Mage::getModel('core/url_rewrite');
         /* @var $urlRewrite Mage_Core_Model_Url_Rewrite */
         $cat = $cat . $suffix;
         $catReqPath = $cat;
         $urlRewrite->setStoreId(Mage::app()->getStore()->getId())->loadByRequestPath($catReqPath);
     }
     if (!$urlRewrite->getId()) {
         $store = $this->request->getParam('___from_store');
         $store = Mage::app()->getStore($store)->getId();
         if (!$store) {
             return false;
         }
         $urlRewrite->setData(array())->setStoreId($store)->loadByRequestPath($catReqPath);
         if (!$urlRewrite->getId()) {
             return false;
         }
     }
     $this->request->setPathInfo($cat);
     $this->request->setModuleName('catalog');
     $this->request->setControllerName('category');
     $this->request->setActionName('view');
     if ($isVersionEE13) {
         $categoryId = str_replace('catalog/category/view/id/', '', $urlRewrite->getTargetPath());
         $this->request->setParam('id', $categoryId);
     } else {
         $categoryId = $urlRewrite->getCategoryId();
         $this->request->setParam('id', $categoryId);
         $urlRewrite->rewrite($this->request);
     }
     Mage::register('amshopby_forwarded_category_id', $categoryId);
     return true;
 }
Beispiel #21
0
 public function getResults(Zend_Controller_Request_Http $request)
 {
     $this->setTemplate('searchlucene/result.phtml');
     $query = $request->getParam('q', false);
     $queryEscaped = htmlspecialchars($query);
     Mage::app()->getFrontController()->getAction()->getLayout()->getBlock('head.meta')->setTitle(Mage::helper('searchlucene')->__('Search results for: %s', $queryEscaped));
     $var = Mage::getBaseDir('var');
     $index_dir = $var . DS . 'search' . DS . 'index';
     $index = Zend_Search_Lucene::open($index_dir);
     $hits = $index->find($query);
     $this->assign('hits', $hits);
     $this->assign('query', $queryEscaped);
 }
Beispiel #22
0
 /**
  * Retrieve the User record associated with the authenticated user.
  *
  * @return User|null
  */
 public function init()
 {
     $this->getBootstrap()->bootstrap('Auth');
     $auth = $this->getBootstrap()->getResource('Auth');
     $this->getBootstrap()->bootstrap('Db');
     $db = $this->getBootstrap()->getResource('Db');
     $front = Zend_Controller_Front::getInstance();
     $request = new Zend_Controller_Request_Http();
     // REST API requests require a slightly different authentication
     // strategy. They use non-persistant, key-based authentication
     if ($front->getParam('api')) {
         // Authenticate against the API key in a non-persistent way.
         $auth->setStorage(new Zend_Auth_Storage_NonPersistent());
         $authAdapter = new Omeka_Auth_Adapter_KeyTable($request->getParam('key'));
         $auth->authenticate($authAdapter);
     }
     if (!$auth->hasIdentity()) {
         // There is no user if there is no identity.
         return null;
     }
     try {
         // Get the user ID for REST API or standard requests.
         if ($front->getParam('api')) {
             // Update the key row.
             $key = $auth->getIdentity();
             $key->ip = inet_pton($request->getClientIp());
             $key->accessed = date('Y-m-d H:i:s');
             $key->save();
             $userId = $key->user_id;
         } else {
             $userId = $auth->getIdentity();
         }
         $user = $db->getTable('User')->findActiveById($userId);
     } catch (Zend_Db_Statement_Exception $e) {
         // Exceptions may be thrown because the database is out of sync with
         // the code.  Suppress errors and skip authentication, but only
         // until the database is properly upgraded.
         if (Omeka_Db_Migration_Manager::getDefault()->dbNeedsUpgrade()) {
             $user = null;
         } else {
             throw $e;
         }
     }
     if (!$user) {
         // If we can't retrieve the User from the database, it likely means
         // that this user has been deleted.  In this case, do not allow the
         // user to stay logged in.
         $auth->clearIdentity();
     }
     return $user;
 }
Beispiel #23
0
 /**
  * Checks a request for CSRF issues. This is only checked for POST requests
  * (with session info) that aren't Ajax requests (relies on browser-level
  * cross-domain policies).
  *
  * The token is retrieved from the "_xfToken" request param.
  *
  * @param string $action
  */
 protected function _checkCsrf($action)
 {
     if (isset(self::$_executed['csrf'])) {
         return;
     }
     self::$_executed['csrf'] = true;
     if (!XenForo_Application::isRegistered('session')) {
         return;
     }
     if ($this->_request->isPost() || substr($this->getResponseType(), 0, 2) == 'js') {
         // post and all json requests require a token
         $this->_checkCsrfFromToken($this->_request->getParam('_xfToken'));
     }
 }
Beispiel #24
0
 /**
  * @param string $cat
  * @throws Mage_Core_Controller_Varien_Exception
  */
 protected function forwardCategory($cat)
 {
     $cat = trim($cat, '/');
     // we do not use Mage::getVersion() here as it is not defined in the old versions.
     $isVersionEE13 = Mage::helper('amshopby')->isModuleEnabled('Enterprise_UrlRewrite');
     $suffix = $this->getUrlHelper()->getUrlSuffix();
     if ($isVersionEE13) {
         $urlRewrite = Mage::getModel('enterprise_urlrewrite/url_rewrite');
         /* @var $urlRewrite Enterprise_UrlRewrite_Model_Url_Rewrite */
         if (version_compare(Mage::getVersion(), '1.13.0.2', '>=')) {
             $catReqPath = array('request' => $cat . $suffix, 'whole' => $cat);
         } else {
             $catReqPath = array($cat);
         }
         $urlRewrite->setStoreId(Mage::app()->getStore()->getId())->loadByRequestPath($catReqPath);
     } else {
         /* @var Mage_Core_Model_Url_Rewrite $urlRewrite */
         $urlRewrite = Mage::getModel('core/url_rewrite');
         $cat = $cat . $suffix;
         $catReqPath = $cat;
         $urlRewrite->setStoreId(Mage::app()->getStore()->getId())->loadByRequestPath($catReqPath);
     }
     if (!$urlRewrite->getId()) {
         $store = $this->request->getParam('___from_store');
         $store = Mage::app()->getStore($store)->getId();
         if ($store) {
             $urlRewrite->setData(array())->setStoreId($store)->loadByRequestPath($catReqPath);
         }
         if (!$urlRewrite->getId()) {
             if (is_array($catReqPath)) {
                 $catReqPath = current($catReqPath);
             }
             throw new Mage_Core_Controller_Varien_Exception("Routing: Cannot forward to category view page: " . $catReqPath);
         }
     }
     $this->request->setPathInfo($cat);
     $this->request->setModuleName('catalog');
     $this->request->setControllerName('category');
     $this->request->setActionName('view');
     if ($isVersionEE13) {
         $categoryId = str_replace('catalog/category/view/id/', '', $urlRewrite->getTargetPath());
         $this->request->setParam('id', $categoryId);
     } else {
         $categoryId = $urlRewrite->getCategoryId();
         $this->request->setParam('id', $categoryId);
         $urlRewrite->rewrite($this->request);
     }
     Mage::register('amshopby_forwarded_category_id', $categoryId);
 }
 /**
  * @param Zend_Controller_Request_Http $request
  * @return null|string
  */
 public function adCampaignBanner(Zend_Controller_Request_Http $request)
 {
     // Get module name from request
     $module = $request->getModuleName();
     // Set or get campaign and content details in session, if any
     $session = new Zend_Session_Namespace('homelet_global');
     if ($request->getParam('utm_campaign') != '') {
         $session->campaign = $request->getParam('utm_campaign');
     }
     if ($request->getParam('utm_content') != '') {
         $session->content = $request->getParam('utm_content');
     }
     $this->campaign = $session->campaign;
     $this->content = $session->content;
     // Look up to see if there's a match between module, campaign and content.
     if (isset($this->bannerMappings[$module][$this->campaign][$this->content])) {
         // Pass the matching parameters to the partial view to display
         $params = $this->bannerMappings[$module][$this->campaign][$this->content];
         return $this->view->partial('partials/ad-campaign-banner.phtml', $params);
     } else {
         // No match, no banner
         return null;
     }
 }
Beispiel #26
0
 public function getNotFoundResponse()
 {
     if (XenForo_Application::debugMode()) {
         $controllerName = $this->_request->getParam('_controllerName');
         if (!$controllerName) {
             return $this->responseError(new XenForo_Phrase('route_x_not_found', array('route' => $this->_request->getParam('_origRoutePath'))), 404);
         } else {
             if (!class_exists($controllerName, false)) {
                 return $this->responseError(new XenForo_Phrase('controller_x_for_route_y_not_found', array('controller' => $controllerName, 'route' => $this->_request->getParam('_origRoutePath'))), 404);
             } else {
                 return $this->responseError(new XenForo_Phrase('controller_x_does_not_define_action_y', array('controller' => $controllerName, 'action' => $this->_request->getParam('_action'))), 404);
             }
         }
     } else {
         return $this->responseError(new XenForo_Phrase('requested_page_not_found'), 404);
     }
 }
Beispiel #27
0
 /**
  * Returns a parameter from the current request and expands its URI
  * using the local namespace table. It also strips slashes if
  * magic_quotes_gpc is turned on in PHP.
  *
  * @param string  $name            the name of the parameter
  * @param boolean $expandNamespace Whether to expand the namespace or not
  *
  * @return mixed the parameter or null if not found
  */
 public function getParam($key, $default = null, $expandNamespace = false)
 {
     // get parameter value from Zend_Request
     $value = parent::getParam($key, $default);
     if ($expandNamespace) {
         // expandable parameters cannot be arrays
         if (is_array($value)) {
             $value = current($value);
         }
         // expand namespace
         $value = OntoWiki_Utils::expandNamespace($value);
     }
     // strip slash quotes if necessary
     if (get_magic_quotes_gpc() && is_string($value)) {
         $value = stripslashes($value);
     }
     return $value;
 }
 public function match(Zend_Controller_Request_Http $request)
 {
     if (!Mage::isInstalled()) {
         Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('install'))->sendResponse();
         exit;
     }
     $route = Mage::helper('prodfaqs')->getListIdentifier();
     $identifier = trim($request->getPathInfo(), '/');
     $identifier = str_replace(Mage::helper('prodfaqs')->getSeoUrlSuffix(), '', $identifier);
     if ($identifier == $route) {
         $request->setModuleName('prodfaqs')->setControllerName('index')->setActionName('index');
         return true;
     } elseif (strpos($identifier, $route . '/search') === 0) {
         $request->setModuleName('prodfaqs')->setControllerName('index')->setActionName('search')->setParam('id', (int) $request->getParam('id'));
         return true;
     } elseif (strpos($identifier, $route) === 0 && strlen($identifier) > strlen($route) && strpos($identifier, '-questions') === false) {
         $identifier = trim(substr($identifier, strlen($route)), '/');
         $topicId = Mage::getModel('prodfaqs/topic')->checkIdentifier($identifier, Mage::app()->getStore()->getId());
         if (!$topicId) {
             return false;
         }
         $request->setModuleName('prodfaqs')->setControllerName('index')->setActionName('view')->setParam('id', $topicId);
         $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $identifier);
         return true;
     } elseif (strpos($identifier, $route) === 0 && strpos($identifier, '-questions') >= 0) {
         $product_identifier = trim(substr($identifier, strlen($route)), '/');
         $product_identifier = str_replace('-questions', '', $product_identifier);
         //Now get the product id from this identifier
         $store_id = Mage::app()->getStore()->getId();
         $collection = Mage::getResourceModel('catalog/product_collection')->setStoreId($store_id);
         Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);
         Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
         $collection->addAttributeToFilter(array(array('attribute' => 'url_key', 'eq' => $product_identifier)));
         $data = $collection->getData();
         if ($data) {
             $prod_id = $data[0]['entity_id'];
             $request->setModuleName('prodfaqs')->setControllerName('index')->setActionName('productfaqs')->setParam('id', $prod_id);
             return true;
         } else {
             return false;
         }
     }
     return false;
 }
 protected function _getLayoutByHandles(Zend_Controller_Request_Http $request, $handles)
 {
     /* @var $core Mana_Core_Helper_Data */
     $core = Mage::helper('mana_core');
     if (count($handles) < 1 || count($handles) > 2) {
         return null;
     } elseif (count($handles) == 1) {
         $handle = $handles[0];
     } else {
         if ($request->getParam('id')) {
             if ($core->endsWith($handles[0]['handle'], '_edit')) {
                 $handle = $core->endsWith($handles[1]['handle'], '_new') ? $handles[0] : null;
             } elseif ($core->endsWith($handles[1]['handle'], '_edit')) {
                 $handle = $core->endsWith($handles[0]['handle'], '_new') ? $handles[1] : null;
             } else {
                 return null;
             }
         } else {
             if ($core->endsWith($handles[0], '_new')) {
                 $handle = $core->endsWith($handles[1], '_edit') ? $handles[0] : null;
             } elseif ($core->endsWith($handles[1], '_new')) {
                 $handle = $core->endsWith($handles[0], '_edit') ? $handles[1] : null;
             } else {
                 return null;
             }
         }
         if (!$handle) {
             return null;
         }
     }
     $block = $handle['block'];
     $controller = explode('_', $handle['handle']);
     $module = array_shift($controller);
     if ($module == 'adminhtml') {
         $module = (string) Mage::getConfig()->getNode('admin/routers/adminhtml/args/frontName');
     }
     $action = array_pop($controller);
     $controller = implode('_', $controller);
     $route = compact('module', 'controller', 'action');
     return compact('route', 'block');
 }
 public function match(Zend_Controller_Request_Http $request)
 {
     if (Mage::app()->getStore()->isAdmin()) {
         return false;
     }
     $pageId = $request->getPathInfo();
     // remove suffix if any
     $suffix = Mage::helper('amshopby/url')->getUrlSuffix();
     if ($suffix && '/' != $suffix) {
         $pageId = str_replace($suffix, '', $pageId);
     }
     //add trailing slash
     $pageId = trim($pageId, '/') . '/';
     $reservedKey = Mage::getStoreConfig('amshopby/seo/key') . '/';
     //  canon/
     //  electronics - false
     //  electronics/shopby/canon/
     //  electronics/shopby/red/
     //  electronics/shopby/
     //  shopby/
     //  shopby/red/
     //  shopby/canon/ - false
     //  shopby/manufacturer-canon/ - false
     //  manufacturer-canon/ - true
     // starts from shopby
     $isAllProductsPage = substr($pageId, 0, strlen($reservedKey)) == $reservedKey;
     // has shopby in the middle
     $isCategoryPage = false !== strpos($pageId, '/' . $reservedKey);
     if (!Mage::getStoreConfig('amshopby/seo/urls')) {
         // If path info have something after reserved key
         if (($isAllProductsPage || $isCategoryPage) && substr($pageId, -strlen($reservedKey), strlen($reservedKey)) != $reservedKey) {
             return false;
         }
     }
     if ($isAllProductsPage) {
         // no support for old style urls
         if ($this->hasBrandIn(self::MIDDLE, $pageId)) {
             return false;
         }
     }
     if (!$isAllProductsPage && !$isCategoryPage) {
         if (!$this->hasBrandIn(self::BEGINNING, $pageId)) {
             return false;
         }
         //it is brand page and we modify the url to be in the old style
         $pageId = $reservedKey . $pageId;
     }
     // get layered navigation params as string
     list($cat, $params) = explode($reservedKey, $pageId, 2);
     $params = trim($params, '/');
     if ($params) {
         $params = explode('/', $params);
     }
     // remember for futire use in the helper
     if ($params) {
         Mage::register('amshopby_current_params', $params);
     }
     $cat = trim($cat, '/');
     if ($cat) {
         // normal category
         // if somebody has old urls in the cache.
         if (!Mage::getStoreConfig('amshopby/seo/urls')) {
             return false;
         }
         // we do not use Mage::getVersion() here as it is not defined in the old versions.
         $isVersionEE13 = 'true' == (string) Mage::getConfig()->getNode('modules/Enterprise_UrlRewrite/active');
         if ($isVersionEE13) {
             $urlRewrite = Mage::getModel('enterprise_urlrewrite/url_rewrite');
             /* @var $urlRewrite Enterprise_UrlRewrite_Model_Url_Rewrite */
             if (version_compare(Mage::getVersion(), '1.13.0.2', '>=')) {
                 $catReqPath = array('request' => $cat . $suffix, 'whole' => $cat);
             } else {
                 $catReqPath = array($cat);
             }
             $urlRewrite->setStoreId(Mage::app()->getStore()->getId())->loadByRequestPath($catReqPath);
         } else {
             $urlRewrite = Mage::getModel('core/url_rewrite');
             /* @var $urlRewrite Mage_Core_Model_Url_Rewrite */
             $cat = $cat . $suffix;
             $catReqPath = $cat;
             $urlRewrite->setStoreId(Mage::app()->getStore()->getId())->loadByRequestPath($catReqPath);
         }
         // todo check in ee13
         if (!$urlRewrite->getId()) {
             $store = $request->getParam('___from_store');
             $store = Mage::app()->getStore($store)->getId();
             if (!$store) {
                 return false;
             }
             $urlRewrite->setData(array())->setStoreId($store)->loadByRequestPath($catReqPath);
             if (!$urlRewrite->getId()) {
                 return false;
             }
         }
         $request->setPathInfo($cat);
         $request->setModuleName('catalog');
         $request->setControllerName('category');
         $request->setActionName('view');
         if ($isVersionEE13) {
             $categoryId = str_replace('catalog/category/view/id/', '', $urlRewrite->getTargetPath());
             $request->setParam('id', $categoryId);
         } else {
             $request->setParam('id', $urlRewrite->getCategoryId());
             $urlRewrite->rewrite($request);
         }
     } else {
         // root category
         $realModule = 'Amasty_Shopby';
         $request->setPathInfo(trim($reservedKey, '/'));
         $request->setModuleName('amshopby');
         $request->setRouteName('amshopby');
         $request->setControllerName('index');
         $request->setActionName('index');
         $request->setControllerModule($realModule);
         $file = Mage::getModuleDir('controllers', $realModule) . DS . 'IndexController.php';
         include $file;
         //compatibility with 1.3
         $class = $realModule . '_IndexController';
         $controllerInstance = new $class($request, $this->getFront()->getResponse());
         $request->setDispatched(true);
         $controllerInstance->dispatch('index');
     }
     return true;
 }