/** * Validate and Match Cms Page and modify request * * @param Zend_Controller_Request_Http $request * @return bool * * @SuppressWarnings(PHPMD.ExitExpression) */ public function match(Zend_Controller_Request_Http $request) { if (!Mage::isInstalled()) { Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('install'))->sendResponse(); exit; } $identifier = trim($request->getPathInfo(), '/'); $condition = new Varien_Object(array('identifier' => $identifier, 'continue' => true)); Mage::dispatchEvent('cms_controller_router_match_before', array('router' => $this, 'condition' => $condition)); $identifier = $condition->getIdentifier(); if ($condition->getRedirectUrl()) { Mage::app()->getFrontController()->getResponse()->setRedirect($condition->getRedirectUrl())->sendResponse(); $request->setDispatched(true); return Mage::getControllerInstance('Mage_Core_Controller_Varien_Action_Forward', $request, Mage::app()->getFrontController()->getResponse()); } if (!$condition->getContinue()) { return null; } $page = Mage::getModel('Mage_Cms_Model_Page'); $pageId = $page->checkIdentifier($identifier, Mage::app()->getStore()->getId()); if (!$pageId) { return null; } $request->setModuleName('cms')->setControllerName('page')->setActionName('view')->setParam('page_id', $pageId); $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $identifier); return Mage::getControllerInstance('Mage_Core_Controller_Varien_Action_Forward', $request, Mage::app()->getFrontController()->getResponse()); }
/** * Match a specific route for an already matched prefix. * * @see XenForo_Route_Interface::match() */ public function match($routePath, Zend_Controller_Request_Http $request, XenForo_Router $router) { $components = explode('/', $routePath); $action = strtolower(array_shift($components)); if (count($components) == 1) { // permission/<action>, etc $action .= reset($components); } else { switch ($action) { case 'permission': // permission/<group>/<permission>/<action> $request->setParam('permission_group_id', array_shift($components)); $request->setParam('permission_id', array_shift($components)); break; case 'permission-group': // permission-group/<group>/<action> $request->setParam('permission_group_id', array_shift($components)); break; case 'interface-group': // interface-group/<group>/<action> $request->setParam('interface_group_id', array_shift($components)); break; } $action .= implode('', $components); } return $router->getRouteMatch('XenForo_ControllerAdmin_Permission', $action, 'permissionsDevelopment'); }
public function match(Zend_Controller_Request_Http $request) { if (!Mage::isInstalled()) { Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('install'))->sendResponse(); exit; } $identifier = trim($request->getPathInfo(), '/'); $condition = new Varien_Object(array('identifier' => $identifier, 'continue' => true)); Mage::dispatchEvent('magicproduct_controller_router_match_before', array('router' => $this, 'condition' => $condition)); $identifier = $condition->getIdentifier(); if ($condition->getRedirectUrl()) { Mage::app()->getFrontController()->getResponse()->setRedirect($condition->getRedirectUrl())->sendResponse(); $request->setDispatched(true); return true; } if (!$condition->getContinue()) { return false; } if (!in_array($identifier, $this->router)) { return false; } $request->setModuleName('magicproduct')->setControllerName('index')->setActionName('product')->setParam('type', $identifier); $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $identifier); return true; }
private static function geraTagXml($type) { $request = new \Zend_Controller_Request_Http(); $arrRequest = explode('/', $request->getRequestUri()); if (!empty($arrRequest[3])) { $rota = (string) $arrRequest[1] . '/' . $arrRequest[2] . '/' . $arrRequest[3]; } else { $rota = (string) $arrRequest[1] . '/' . $arrRequest[2]; } $xml = "<schema>"; $xml .= "<nome>corporativo</nome>"; $xml .= "<rota>{$rota}</rota>"; $xml .= "<tabela>"; foreach ($type as $key => $value) { $nomeTabela = self::converteString($key); $xml .= "<nome>" . $nomeTabela . "</nome>"; foreach ($value as $k => $v) { if (!is_array($v) && !is_object($v)) { $xml .= "<coluna>"; $palavraConvertida = self::converteString($k); $v = self::procuraData($palavraConvertida) ? self::converteData($v) : $v; $xml .= "<nome>" . $palavraConvertida . "</nome>"; $xml .= "<valor>" . $v . "</valor>"; $xml .= "</coluna>"; } } } $xml .= "</tabela>"; $xml .= "</schema>"; return $xml; }
public function match(Zend_Controller_Request_Http $request) { //default route (404) $d = explode('/', Mage::getStoreConfig('web/default/no_route')); $request->setModuleName(isset($d[0]) ? $d[0] : 'core')->setControllerName(isset($d[1]) ? $d[1] : 'index')->setActionName(isset($d[2]) ? $d[2] : 'index'); return true; }
/** * 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)) { require_once 'Zend/Auth/Adapter/Exception.php'; throw new Zend_Auth_Adapter_Exception('Request and Response objects must be set before calling ' . 'authenticate()'); } $header = $this->_request->getHeader('Authorization'); if (empty($header)) { return $this->_challengeClient(); } $parts = array_filter(explode(' ', $header)); if ($parts < 2) { return $this->_challengeClient(); } $scheme = array_shift($parts); $creds = implode(' ', $parts); if (empty($this->_schemes[$scheme])) { throw new Zend_Auth_Adapter_Exception('Unsupported authentication scheme (' . $scheme . ')'); } $result = call_user_func($this->_schemes[$scheme], trim($creds), $this->_request); if (empty($result)) { \App::log()->debug("Authentication failed using scheme: " . @$this->_schemes[$scheme]); \App::log()->debug("Authentication failed using creds: " . @$creds); return $this->_challengeClient(); } else { if ($result instanceof Zend_Auth_Result) { return $result; } else { return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $result); } } }
/** * Validate and Match Cms Page and modify request * * @param Zend_Controller_Request_Http $request * @return bool */ public function match(Zend_Controller_Request_Http $request) { if (Mage::app()->getStore()->isAdmin()) { return false; } $pathInfo = $request->getPathInfo(); // remove suffix if any $suffix = Mage::helper('amlanding/url')->getSuffix(); if ($suffix && '/' != $suffix) { $pathInfo = str_replace($suffix, '', $pathInfo); } $pathInfo = explode('/', trim($pathInfo, '/ '), 2); $identifier = $pathInfo[0]; $params = isset($pathInfo[1]) ? $pathInfo[1] : ''; /* @var $page Amasty_Xlanding_Model_Page */ $page = Mage::getModel('amlanding/page'); $pageId = $page->checkIdentifier($identifier, Mage::app()->getStore()->getId()); if (!$pageId) { return false; } $params = trim($params, '/ '); if ($params) { $params = explode('/', $params); Mage::register('amshopby_current_params', $params); } $request->setModuleName('amlanding')->setControllerName('page')->setActionName('view')->setParam('page_id', $pageId)->setParam('am_landing', $identifier); return true; }
public function testDisplay() { $this->_response->expects($this->atLeastOnce())->method('sendHeaders'); $this->_request->expects($this->atLeastOnce())->method('getHeader'); $stat = (include __DIR__ . '/_files/timers.php'); $this->_output->display($stat); $actualHeaders = $this->_response->getHeaders(); $this->assertNotEmpty($actualHeaders); $actualProtocol = false; $actualProfilerData = false; foreach ($actualHeaders as $oneHeader) { $headerName = $oneHeader['name']; $headerValue = $oneHeader['value']; if (!$actualProtocol && $headerName == 'X-Wf-Protocol-1') { $actualProtocol = $headerValue; } if (!$actualProfilerData && $headerName == 'X-Wf-1-1-1-1') { $actualProfilerData = $headerValue; } } $this->assertNotEmpty($actualProtocol, 'Cannot get protocol header'); $this->assertNotEmpty($actualProfilerData, 'Cannot get profiler header'); $this->assertContains('Protocol/JsonStream', $actualProtocol); $this->assertRegExp('/"Type":"TABLE","Label":"Code Profiler \\(Memory usage: real - \\d+, emalloc - \\d+\\)"/', $actualProfilerData); $this->assertContains('[' . '["Timer Id","Time","Avg","Cnt","Emalloc","RealMem"],' . '["root","0.080000","0.080000","1","1,000","50,000"],' . '[". init","0.040000","0.040000","1","200","2,500"],' . '[". . init_store","0.020000","0.010000","2","100","2,000"],' . '["system","0.030000","0.015000","2","400","20,000"]' . ']', $actualProfilerData); }
/** * Test that Mage_Core_Controller_Varien_Action_Forward::dispatch() does not change dispatched flag */ public function testDispatch() { $this->_request->setDispatched(true); $this->assertTrue($this->_request->isDispatched()); $this->_object->dispatch('any action'); $this->assertFalse($this->_request->isDispatched()); }
/** * Called before an action is dispatched by Zend_Controller_Dispatcher. * * This callback allows for proxy or filter behavior. The * $action must be returned for the Zend_Controller_Dispatcher_Token to be dispatched. * To abort the dispatch, return FALSE. * * @param Zend_Controller_Request_Http $action * @return Zend_Controller_Dispatcher_Token|boolean */ public function preDispatch($action) { $module = $action->getModuleName(); $definition = null; if (isset($this->config[$module])) { $definition = $this->config[$module]; } else { if (isset($this->config['master_layout'])) { $definition = $this->config['master_layout']; } } if ($definition != null && !$action->getParam('__ignorelayout')) { $view = null; $layoutName = $this->getViewNameFrom($definition, strtolower($action->getControllerName()), strtolower($action->getActionName())); if ($layoutName) { $view = new MasterView($layoutName, $this->config['layout_path']); } if ($view != null) { Zend_Registry::set('MasterView', $view); $baseView = Zend_Registry::get(NovemberApplication::$ZEND_VIEW); $baseView->setMaster('MasterView'); } } return $action; }
/** * Adds the homepage route to the router (as specified by the navigation settings page) * The route will not be added if the user is currently on the admin theme. * * @param Zend_Controller_Router_Rewrite $router The router */ private function _addHomepageRoute($router) { // Don't add the route if the user is on the admin theme if (is_admin_theme()) { return; } $homepageUri = trim(get_option(Omeka_Form_Navigation::HOMEPAGE_URI_OPTION_NAME)); if (strpos($homepageUri, ADMIN_BASE_URL) === 0) { // homepage uri is an admin link $this->_addHomepageRedirect($homepageUri, $router); } else { if (strpos($homepageUri, '?') === false) { // left trim root directory off of the homepage uri $relativeUri = $this->_leftTrim($homepageUri, PUBLIC_BASE_URL); // make sure the new homepage is not the default homepage if ($relativeUri == '' || $relativeUri == '/') { return; } $homepageRequest = new Zend_Controller_Request_Http(); $homepageRequest->setRequestUri($homepageUri); $router->route($homepageRequest); $dispatcher = Zend_Controller_Front::getInstance()->getDispatcher(); if ($dispatcher->isDispatchable($homepageRequest)) { // homepage is an internal link $router->addRoute(self::HOMEPAGE_ROUTE_NAME, new Zend_Controller_Router_Route('/', $homepageRequest->getParams())); return; } } } // homepage is some external link, a broken internal link, or has a // query string $this->_addHomepageRedirect($homepageUri, $router); }
/** * match the route * @param Zend_Controller_Request_Http $request * @return bool */ public function match(Zend_Controller_Request_Http $request) { //if magento is not installed redirect to install if (!Mage::isInstalled()) { Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('install'))->sendResponse(); exit; } //get the url key $urlKey = trim($request->getPathInfo(), '/'); //explode by slash $parts = explode('/', $urlKey); //if there are not 2 parts (tag/something) in the url we don't care about it. //return false and let the rest of the application take care of the url. if (count($parts) != 2) { return false; } //if the first part of the url key is not 'tag' we don't care about it //return false and let the rest of the application take care of the url if ($parts[0] != 'tag') { return false; } $tagName = urldecode($parts[1]); //tag name //load the tag model $tag = Mage::getModel('tag/tag')->loadByName($tagName); //if there is no tag with this name available in the current store just do nothing if (!$tag->getId() || !$tag->isAvailableInStore()) { return false; } //but if the tag is valid //say to magento that the request should be mapped to `tag/product/list/tagId/ID_HERE` - the original url $request->setModuleName('tag')->setControllerName('product')->setActionName('list')->setParam('tagId', $tag->getId()); $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $urlKey); return true; }
/** * Return the URL * * @param string|array $urlOptions * @param string $name * @param bool $reset * @param bool $encode * @return string */ public function myUrl($urlOptions = array(), $name = null, $reset = false, $encode = true) { $front = Zend_Controller_Front::getInstance(); $router = $front->getRouter(); $extraUrlOptions = array(); $extraOptions = Zend_Controller_Front::getInstance()->getRequest()->getParams(); if (count($extraOptions)) { foreach ($extraOptions as $key => $value) { if ($key != 'module' && $key != 'controller' && $key != 'action') { $extraUrlOptions[] = $key . '=' . ($encode ? urlencode($value) : $value); } } } if (is_string($urlOptions)) { $urlOptions = '/' . ltrim($urlOptions, '/'); // Case the first character is ? $request = new Zend_Controller_Request_Http(); // Creates a cleaned instance of request http
public function nopageAction() { $http = new Zend_Controller_Request_Http(); if ($http->isXmlHttpRequest()) { $this->view->noLayout = true; } }
public function match(Zend_Controller_Request_Http $request) { if (!Mage::app()->isInstalled()) { Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('install'))->sendResponse(); exit; } $pathInfo = trim($request->getPathInfo(), '/'); //echo $pathInfo;die(); $pathInfoAr = explode('/', $pathInfo); if ($pathInfoAr[0] == Mage::getStoreConfig('vc_miniblog/blog/router')) { if (isset($pathInfoAr[1])) { switch ($pathInfoAr[1]) { case 'tag': $request->setModuleName('vc_miniblog')->setControllerName('index')->setActionName('index'); $request->setParams(array('tag' => $pathInfoAr[2])); $request->setParams(array('tag' => $pathInfoAr[2])); break; case 'cat': $request->setModuleName('vc_miniblog')->setControllerName('index')->setActionName('index'); $request->setParams(array('cat' => $pathInfoAr[2])); break; default: $request->setModuleName('vc_miniblog')->setControllerName('index')->setActionName('postDetail'); $request->setParams(array('identifier' => $pathInfoAr[1])); break; } } else { $request->setModuleName('vc_miniblog')->setControllerName('index')->setActionName('index'); } return true; } return false; }
public function match(Zend_Controller_Request_Http $request) { if (!Mage::app()->isInstalled()) { Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('install'))->sendResponse(); exit; } $route = "f"; $identifier = $request->getPathInfo(); if (substr(str_replace("/", "", $identifier), 0, strlen($route)) != $route) { return false; } $identifier = substr_replace($request->getPathInfo(), '', 0, strlen("/" . $route . "/")); $identifier = str_replace('.html', '', $identifier); $identifier = str_replace('.htm', '', $identifier); $identifier = str_replace('.php', '', $identifier); if ($identifier[strlen($identifier) - 1] == "/") { $identifier = substr($identifier, '', -1); } $identifier = explode('/', $identifier, 3); if (isset($identifier[1]) && isset($identifier[0]) && !isset($identifier[2])) { $request->setModuleName('f')->setControllerName('index')->setActionName('view')->setParam('id', $identifier[0])->setParam('v', $identifier[1]); return true; } else { return false; } }
public function __construct($args = false) { if ($args === false) { // Created with _getProcessor function $registryKey = '_singleton/amfpc/fpc_front'; Mage::register($registryKey, $this, true); } if (isset($_SESSION)) { $this->_sessionName = session_name(); } else { $sessionName = (string) Mage::app()->getConfig()->getNode('global/amfpc/session_name'); if ($sessionName) { $this->_sessionName = $sessionName; } } $request = new Zend_Controller_Request_Http(); $pathInfo = trim(strtok($request->getRequestUri(), '?'), '/'); if ($this->getDbConfig('web/url/use_store')) { $pathParts = explode('/', $pathInfo); $storeCode = array_shift($pathParts); $this->_urlInfo = array('store_code' => $storeCode, 'page' => implode('/', $pathParts)); } else { $this->_urlInfo = array('store_code' => false, 'page' => $pathInfo); } }
public function routeShutdown(Zend_Controller_Request_Abstract $request) { $front = Zend_Controller_Front::getInstance(); // Front controller has error handler plugin // if the request is an error request. // If the error handler plugin is not registered, // we will be unable which MCA to run, so do not continue. $errorHandlerClass = 'Zend_Controller_Plugin_ErrorHandler'; if (!$front->hasPlugin($errorHandlerClass)) { return false; } // Determine new error controller module_ErrorController_ErrorAction $plugin = $front->getPlugin($errorHandlerClass); $errorController = $plugin->getErrorHandlerController(); $errorAaction = $plugin->getErrorHandlerAction(); $module = $request->getModuleName(); // Create test request module_ErrorController_ErrorAction... $testRequest = new Zend_Controller_Request_Http(); $testRequest->setModuleName($module)->setControllerName($errorController)->setActionName($errorAaction); // Set new error controller if available if ($front->getDispatcher()->isDispatchable($testRequest)) { $plugin->setErrorHandlerModule($module); } else { return false; } return true; }
/** * See if any product matches * * @param Zend_Controller_Request_Http $request * @return bool */ public function match(Zend_Controller_Request_Http $request) { if (!Mage::isInstalled()) { Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('install'))->sendResponse(); exit; } // Clear session to make sure users can add products and the shopping cart clears properly if (isset($_GET['zipcode'])) { Mage::helper('urls')->clearSession($_GET['zipcode']); } // Get basic data $identifier = urldecode(strtolower(trim($request->getPathInfo(), '/'))); $vendorsCollection = Mage::helper('urls')->getVendors(); $vendorId = false; $productSlug = ''; // Get vendor id $vendorId = $this->_detectVendorId($identifier, $vendorsCollection); // Get product slug preg_match('/.*\\/(.*).html$/', $identifier, $matches); $productSlug = $matches[1]; if ($vendorId) { Mage::register('vendorId', $vendorId); $productId = Mage::helper('urls')->getProductIdBySlug($productSlug, $vendorId); if ('' == $productId || empty($productId)) { return false; } // Point to correct product $request->setModuleName('catalog')->setControllerName('product')->setActionName('view')->setParam('id', $productId); return true; } return false; }
public function match(Zend_Controller_Request_Http $request) { $active = Mage::getStoreConfig("dev/offline/mwdevtoolbar"); if ($active == 1) { $storeenabled = Mage::getStoreConfig('dev/offline/enable', $request->getStoreCodeFromPath()); if ($storeenabled) { Mage::getSingleton('core/session', array('name' => 'adminhtml')); $helper = Mage::helper('developertoolbar/data'); if ($helper->checkAllowsIps() == 0) { Mage::getSingleton('core/session', array('name' => 'front')); $front = $this->getFront(); $response = $front->getResponse(); $response->setHeader('HTTP/1.1', '503 Service Temporarily Unavailable'); $response->setHeader('Status', '503 Service Temporarily Unavailable'); $response->setHeader('Retry-After', '5000'); $response->setBody(html_entity_decode(Mage::getStoreConfig('dev/offline/message', $request->getStoreCodeFromPath()), ENT_QUOTES, "utf-8")); $response->sendHeaders(); $response->outputBody(); exit; } else { $showreminder = Mage::getStoreConfig('dev/offline/reminder', $request->getStoreCodeFromPath()); if ($showreminder) { $front = $this->getFront(); $response = $front->getResponse()->clearBody(); $response = $front->getResponse()->appendBody('<div style="height:12px; background:red; color: white; position:relative; width:100%;padding:3px; z-index:100000;text-trasform:capitalize;">Offline</div>'); } } } } return parent::match($request); }
public function setUp() { $savePath = ini_get('session.save_path'); if (strpos($savePath, ';')) { $savePath = explode(';', $savePath); $savePath = array_pop($savePath); } if (empty($savePath)) { $this->markTestSkipped('Cannot test FlashMessenger due to unavailable session save path'); } if (headers_sent()) { $this->markTestSkipped('Cannot test FlashMessenger: cannot start session because headers already sent'); } Zend_Session::start(); $this->front = Zend_Controller_Front::getInstance(); $this->front->resetInstance(); $this->front->setControllerDirectory(dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . '_files'); $this->front->returnResponse(true); $this->request = new Zend_Controller_Request_Http(); $this->request->setControllerName('helper-flash-messenger'); $this->response = new Zend_Controller_Response_Cli(); $this->controller = new HelperFlashMessengerController($this->request, $this->response, array()); $this->helper = new Zend_Controller_Action_Helper_FlashMessenger($this->controller); }
protected function _initStoreRoutes() { $request = new Zend_Controller_Request_Http(); $path = explode('/', trim($request->getPathInfo(), '/')); $requestedPath = array_shift($path); $requestedHost = $request->getHttpHost(); if ($store = Cosmos_Api::get()->cosmos->getStoreByHostPath($requestedHost, $requestedPath)) { $this->bootstrap('session'); Zend_Registry::set('csession', new Zend_Session_Namespace("cosmos_{$store['group_id']}")); Zend_Registry::get('log')->info($store); if ($store['path']) { $this->bootstrap('frontcontroller'); $front = Zend_Controller_Front::getInstance(); $request = $front->getRequest(); $dispatcher = $front->getDispatcher(); $defaultRoute = new Zend_Controller_Router_Route_Module(array(), $dispatcher, $request); $front->getRouter()->removeDefaultRoutes(); $defaults = array('path' => $store['path'], 'module' => $dispatcher->getDefaultModule()); $pathRoute = new Zend_Controller_Router_Route(':path', $defaults); Zend_Registry::set('cosmosRoute', $pathRoute); // This is to catch empty requests because for some reason 'default' doesn't. $front->getRouter()->addRoute('default-empty', $pathRoute); $front->getRouter()->addRoute('default', $pathRoute->chain($defaultRoute)); Zend_Registry::set('mode', 'path'); } else { Zend_Registry::set('mode', 'host'); } } else { die('fail'); // no matching store? } Cosmos_Addon::getInstance($store['addons']); }
public function match(Zend_Controller_Request_Http $request) { if (!Mage::isInstalled()) { Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('install'))->sendResponse(); exit; } $identifier = trim($request->getPathInfo(), '/'); $parts = explode('/', $identifier); if (isset($parts[1]) && $parts[1] == 'reviews') { $product = Mage::getModel('catalog/product')->loadByAttribute('url_key', $parts[0]); if (isset($parts[2])) { $p = explode('-', $parts[2]); $id = (int) end($p); $request->setRouteName('review')->setModuleName('review')->setControllerName('product')->setActionName('view')->setParam('id', $id)->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, 'reviews'); return true; } else { if ($product) { $request->setRouteName('review')->setModuleName('review')->setControllerName('product')->setActionName('list')->setParam('id', $product->getId())->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, 'reviews'); return true; } } } elseif ($parts[0] == 'tag' && isset($parts[1])) { $p = explode('-', $parts[1]); $id = (int) end($p); $request->setRouteName('tag')->setModuleName('tag')->setControllerName('product')->setActionName('list')->setParam('tagId', $id)->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, 'tags'); return true; } return false; }
function initialise() { // No config file, so this is a first run for install. Before creating the config file, check some // directory access $readonlyDirs = array(); if (!is_writable(dirname(__FILE__) . "/application/config/")) { $readonlyDirs[] = "/application/config/"; } if (!is_writable(dirname(__FILE__) . "/application/logs/")) { $readonlyDirs[] = "/application/logs/"; } if (!is_writable(dirname(__FILE__) . "/application/cache/")) { $readonlyDirs[] = "/application/cache/"; } if (count($readonlyDirs) > 0) { die('<div style="width:80%;margin:50px auto;text-align:center;">' . '<h3>Installation cannot proceed.</h3>' . '<p>The Warehouse installation needs write access priveleges to the following folders:</p>' . '<ul><li>' . implode('</li><li>', $readonlyDirs) . '</li></ul>' . '</div>'); } $source = dirname(__FILE__) . "/application/config/config.php.example"; $dest = dirname(__FILE__) . "/application/config/config.php"; if (false === ($_source_content = file_get_contents($source))) { die('<div style="width:80%;margin:50px auto;text-align:center;">' . '<h3>Config file not found.</h3>' . '<p>The <code>' . APPPATH . 'config/config' . EXT . '.example</code> file does not exist or could not be accessed.</p>' . '</div>'); } include dirname(__FILE__) . '/modules/indicia_setup/libraries/Zend_Controller_Request_Http.php'; $zend_http = new Zend_Controller_Request_Http(); $site_domain = preg_replace("/index\\.php.*\$/", "", $zend_http->getHttpHost() . $zend_http->getBaseUrl()); $_source_content = str_replace("*site_domain*", $site_domain, $_source_content); if (false === file_put_contents($dest, $_source_content)) { die('<div style="width:80%;margin:50px auto;text-align:center;">' . '<h1>Indicia Installation</h1>' . '<h2>Config file cannot be written.</h2>' . '<p>The <code>' . APPPATH . 'config/config' . EXT . '</code> file cannot be created..</p>' . '</div>'); } }
/** * Extract "login" and "password" credentials from HTTP-request * * Returns plain array with 2 items: login and password respectively * * @param Zend_Controller_Request_Http $request * @return array */ public function getHttpAuthCredentials(Zend_Controller_Request_Http $request) { $server = $request->getServer(); $user = ''; $pass = ''; if (empty($server['HTTP_AUTHORIZATION'])) { foreach ($server as $k => $v) { if (substr($k, -18) === 'HTTP_AUTHORIZATION' && !empty($v)) { $server['HTTP_AUTHORIZATION'] = $v; break; } } } if (isset($server['PHP_AUTH_USER']) && isset($server['PHP_AUTH_PW'])) { $user = $server['PHP_AUTH_USER']; $pass = $server['PHP_AUTH_PW']; } elseif (!empty($server['HTTP_AUTHORIZATION'])) { $auth = $server['HTTP_AUTHORIZATION']; list($user, $pass) = explode(':', base64_decode(substr($auth, strpos($auth, " ") + 1))); } elseif (!empty($server['Authorization'])) { $auth = $server['Authorization']; list($user, $pass) = explode(':', base64_decode(substr($auth, strpos($auth, " ") + 1))); } return array($user, $pass); }
/** * Validate and match entities and modify request * * @access public * @param Zend_Controller_Request_Http $request * @return bool * @author Ultimate Module Creator */ public function match(Zend_Controller_Request_Http $request) { if (!Mage::isInstalled()) { Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('install'))->sendResponse(); exit; } $urlKey = trim($request->getPathInfo(), '/'); $check = array(); $check['trainevent'] = new Varien_Object(array('prefix' => Mage::getStoreConfig('wage_trainevent/trainevent/url_prefix'), 'suffix' => Mage::getStoreConfig('wage_trainevent/trainevent/url_suffix'), 'list_key' => Mage::getStoreConfig('wage_trainevent/trainevent/url_rewrite_list'), 'list_action' => 'index', 'model' => 'wage_trainevent/trainevent', 'controller' => 'trainevent', 'action' => 'view', 'param' => 'id', 'check_path' => 0)); foreach ($check as $key => $settings) { if ($settings->getListKey()) { if ($urlKey == $settings->getListKey()) { $request->setModuleName('wage_trainevent')->setControllerName($settings->getController())->setActionName($settings->getListAction()); $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $urlKey); return true; } } if ($settings['prefix']) { $parts = explode('/', $urlKey); if ($parts[0] != $settings['prefix'] || count($parts) != 2) { continue; } $urlKey = $parts[1]; } if ($settings['suffix']) { $urlKey = substr($urlKey, 0, -strlen($settings['suffix']) - 1); } $model = Mage::getModel($settings->getModel()); } return false; }
/** * Validate and Match Manufacturer Page and modify request * * @param Zend_Controller_Request_Http $request * @return bool */ public function match(Zend_Controller_Request_Http $request) { if (!Mage::isInstalled()) { Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('install'))->sendResponse(); exit; } $router = 'manufacturers'; $identifier = trim(str_replace('/manufacturers/', '', $request->getPathInfo()), '/'); $condition = new Varien_Object(array('identifier' => $identifier, 'continue' => true)); Mage::dispatchEvent('manufacturer_controller_router_match_before', array('router' => $this, 'condition' => $condition)); $identifier = $condition->getIdentifier(); if ($condition->getRedirectUrl()) { Mage::app()->getFrontController()->getResponse()->setRedirect($condition->getRedirectUrl())->sendResponse(); $request->setDispatched(true); return true; } if (!$condition->getContinue()) { return false; } $manufacturer = Mage::getModel('zeon_manufacturer/manufacturer'); $manufacturerId = $manufacturer->checkIdentifier($identifier, Mage::app()->getStore()->getId()); if (trim($identifier) && $manufacturerId) { $request->setModuleName('manufacturers')->setControllerName('index')->setActionName('view')->setParam('manufacturer_id', $manufacturerId); $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $router . '/' . $identifier); return true; } return false; }
public function captcha() { $request = new Zend_Controller_Request_Http(); $cookie = (int) $request->getCookie('sicaeuser'); if ($cookie >= 3) { return '<div class="control-group"> <div class="controls captcha-img" style="text-align: center; border: 1px solid; width:285px;"> <img id="captcha" src="/usuario/captcha" alt="CAPTCHA Image" /> </div> <div class="controls captcha-button"> <button title="Atualizar Imagem" class="btn btn-small" type="button" onclick="document.getElementById(\'captcha\').src = \'/usuario/captcha/id/\' + Math.random(); return false;"> <i class="icon-refresh"></i> </button> <object title="Ouvir" align="top" width="33" height="26" id="SecurImage_as3" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"> <param title="Ouvir" value="sameDomain" name="allowScriptAccess" /> <param title="Ouvir" value="false" name="allowFullScreen" /> <param title="Ouvir" value="/captcha/swf/securimage_play.swf?audio=/usuario/captcha-audio/&bgColor1=#f4f4f4&bgColor2=#f4f4f4&iconColor=#000&roundedCorner=4&borderWidth=1&borderColor=#d2d2d2" name="movie" /> <param title="Ouvir" value="high" name="quality" /> <param title="Ouvir" value="#f4f4f4" name="bgcolor" /> <embed title="Ouvir" align="" width="33" height="26" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" allowfullscreen="false" allowscriptaccess="sameDomain" name="SecurImage_as3" bgcolor="#ffffff" quality="high" src="/captcha/swf/securimage_play.swf?audio=/usuario/captcha-audio/&bgColor1=#f4f4f4&bgColor2=#f4f4f4&iconColor=#000&roundedCorner=4&borderWidth=1&borderColor=#d2d2d2" /> </object> </div> </div> <div class="control-group"> <label class="control-label" for=captcha_code>* Código de segurança</label> <div class="controls"> <input type="text" id="captcha_code" name="captcha_code" class="input-xlarge required" maxlength="7" /> </div> </div> '; } }
public function match(Zend_Controller_Request_Http $request) { if (!Mage::isInstalled()) { Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('install'))->sendResponse(); exit; } $identifier = trim($request->getPathInfo(), '/'); /* @var $parser Hackathon_Layeredlanding_Model_Layeredlanding */ $landingPage = Mage::getModel('layeredlanding/layeredlanding')->loadByUrl($identifier); if (!$landingPage->getId()) { return false; } Mage::register('current_landingpage', $landingPage); Mage::app()->getStore()->setConfig(Mage_Catalog_Helper_Category::XML_PATH_USE_CATEGORY_CANONICAL_TAG, 0); // disable canonical tag // if successfully gained url parameters, use them and dispatch ActionController action $categoryIdsValue = $landingPage->getCategoryIds(); $categoryIds = explode(',', $categoryIdsValue); $firstCategoryId = $categoryIds[0]; $request->setRouteName('catalog')->setModuleName('catalog')->setControllerName('category')->setActionName('view')->setParam('id', $firstCategoryId); /** @var $attribute Hackathon_Layeredlanding_Model_Attributes */ foreach ($landingPage->getAttributes() as $attribute) { $attr = Mage::getModel('eav/entity_attribute')->load($attribute->getAttributeId()); $request->setParam($attr->getAttributeCode(), $attribute->getValue()); } $controllerClassName = $this->_validateControllerClassName('Mage_Catalog', 'category'); $controllerInstance = Mage::getControllerInstance($controllerClassName, $request, $this->getFront()->getResponse()); $request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $identifier); // dispatch action $request->setDispatched(true); $controllerInstance->dispatch('view'); return true; }
/** * Adds the homepage route to the router (as specified by the navigation settings page) * The route will not be added if the user is currently on the admin theme. * * @param Zend_Controller_Router_Rewrite $router The router */ private function _addHomepageRoute($router) { // Don't add the route if the user is on the admin theme if (!is_admin_theme()) { $homepageUri = get_option(Omeka_Form_Navigation::HOMEPAGE_URI_OPTION_NAME); $homepageUri = trim($homepageUri); $withoutAdminUri = $this->_leftTrim($this->_leftTrim($homepageUri, ADMIN_BASE_URL), '/' . ADMIN_WEB_DIR); if ($withoutAdminUri != $homepageUri) { // homepage uri is an admin link $homepageUri = WEB_ROOT . '/' . ADMIN_WEB_DIR . $withoutAdminUri; $this->addRedirectRouteForDefaultRoute(self::HOMEPAGE_ROUTE_NAME, $homepageUri, array(), $router); } else { // homepage uri is not an admin link // left trim root directory off of the homepage uri $homepageUri = $this->_leftTrim($homepageUri, PUBLIC_BASE_URL); // make sure the new homepage is not the default homepage if ($homepageUri == '' || $homepageUri == self::DEFAULT_ROUTE_NAME || $homepageUri == PUBLIC_BASE_URL) { return; } $homepageRequest = new Zend_Controller_Request_Http(); $homepageRequest->setBaseUrl(WEB_ROOT); // web root includes server and root directory $homepageRequest->setRequestUri($homepageUri); $router->route($homepageRequest); $dispatcher = Zend_Controller_Front::getInstance()->getDispatcher(); if ($dispatcher->isDispatchable($homepageRequest)) { // homepage is an internal link $router->addRoute(self::HOMEPAGE_ROUTE_NAME, new Zend_Controller_Router_Route(self::DEFAULT_ROUTE_NAME, $homepageRequest->getParams())); } else { // homepage is some external link or a broken internal link $this->addRedirectRouteForDefaultRoute(self::HOMEPAGE_ROUTE_NAME, $homepageUri, array(), $router); } } } }