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); } }
/** * Возвращает массив опций для построения постраничной навигации * Необходимо дергать сразу после выполнения SQL-запроса с SQL_CAL_FOUND_ROWS * * @param array $options - Массив опций * * @return object */ function getPaginator($options = array()) { $Paginator = new Zend_Paginator(new Zend_Paginator_Adapter_Null($this->_db->fetchOne('SELECT FOUND_ROWS()'))); $Paginator->setItemCountPerPage(isset($options['perpage']) ? $options['perpage'] : $this->getPerPage()); if (isset($options['widgetid'])) { $Paginator->setCurrentPageNumber($this->getCurrentPage($options['widgetid'])); } else { $Paginator->setCurrentPageNumber($this->getCurrentPage()); } $out = $Paginator->getPages(); $pageidentity = $this->getPageIdentity(); // Кроме стандартных параметров Zend_Paginator::getPages() возвращаем доп. параметры // Полный путь без GET-запроса $UrlInfo = parse_url($this->_request->getRequestUri()); $out->ClearUrl = $UrlInfo['path']; // Обрабатываем GET-запрос $query = $this->_request->getQuery(); if (isset($query[$pageidentity])) { unset($query[$pageidentity]); } if (isset($query['widget'])) { unset($query['widget']); } // Строим строку выражения if (!empty($query)) { $out->Query = http_build_query($query); } // Фактически, ссылку на первую страницу (без page и widget) $out->FullUrl = isset($out->Query) ? $out->ClearUrl . '?' . $out->Query : $out->ClearUrl; // Добавляем к выражению Id виджета $widget = isset($options['widgetid']) ? 'widget=' . (int) $options['widgetid'] . '&' : ''; // Полную ссылку к которой в конце надо только добавить номер страницы $out->PageUrl = isset($out->Query) ? $out->FullUrl . '&' . $widget . $pageidentity . '=' : $out->FullUrl . '?' . $widget . $pageidentity . '='; return $out; }
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 insertBadRequest(Zend_Controller_Request_Http $request) { $updateService = new FFR_Service_Update(); if ($updateService->currentSchemaVersion('tools') >= 5) { $this->_getRedirectLogGateway()->create(array('redirect_log_source' => $request->getRequestUri()))->save(); } }
public function testSetRequestUri() { $this->_request->setRequestUri('/archives/past/4?set=this&unset=that'); $this->assertEquals('/archives/past/4?set=this&unset=that', $this->_request->getRequestUri()); $this->assertEquals('this', $this->_request->getQuery('set')); $this->assertEquals('that', $this->_request->getQuery('unset')); }
public function match(Zend_Controller_Request_Http $request) { $sku = substr($request->getRequestUri(), 10); $productID = Mage::getModel('catalog/product')->getIdBySku($sku); // $product = Mage::getModel('catalog/product')->loadByAttribute('sku',$sku); // echo $product->getName()."<br>"; // echo "<img src='".$product->getImageUrl()."' />"; // die(); $request->setModuleName('catalog')->setControllerName('product')->setActionName('view')->setParam('id', $productID); return true; }
/** * 重載 繼承的 YUN_Controller_Action init 方法 * */ public function init() { parent::init(); $http = new Zend_Controller_Request_Http(); if (!$this->auth->isAllow('index.access')) { if ($this->auth->isLogined()) { $this->view->feedback(array('message' => '对不起,您没有权限执行该操作!', 'redirect' => $this->view->url(array('module' => 'default', 'controller' => 'user', 'action' => 'login')), 'linktext' => '点击继续')); } else { $this->view->Feedback(array('title' => '发生错误', 'message' => '对不起,您尚未登录', 'linktext' => '点击前往登录页面', 'redirect' => $this->view->url(array('module' => 'default', 'controller' => 'user', 'action' => 'login')) . '?u=' . urlencode('http://' . $http->getHttpHost() . $http->getRequestUri()))); } } $this->config = Zend_Registry::get('config'); }
public function languageswitcher($clslang = "") { $t = new Zend_Controller_Request_Http(); $url = $t->getRequestUri(); $url = explode("?", $url); if (count($url) > 0) { $uri = $url[0]; } else { $uri = $url; } $this->view->languages = Languages::getActiveLanguageList(); $this->view->clslang = $clslang; $this->view->uri = $uri; return $this->view->render('partials/languageswitcher.phtml'); }
/** * Canonicalizes the request URL based on the given link URL. Canonicalization will * only happen when requesting an HTML page, as it is primarily an SEO benefit. * * A response exception will be thrown is redirection is required. * * @param string $linkUrl */ public function canonicalizeRequestUrl($linkUrl) { if ($this->getResponseType() != 'html') { return; } if (!$this->_request->isGet()) { return; } $linkUrl = strval($linkUrl); if (strlen($linkUrl) == 0) { return; } if ($linkUrl[0] == '.') { $linkUrl = substr($linkUrl, 1); } $basePath = $this->_request->getBasePath(); $requestUri = $this->_request->getRequestUri(); if (substr($requestUri, 0, strlen($basePath)) != $basePath) { return; } $routeBase = substr($requestUri, strlen($basePath)); if (isset($routeBase[0]) && $routeBase[0] === '/') { $routeBase = substr($routeBase, 1); } if (preg_match('#^([^?]*\\?[^=&]*)(&(.*))?$#U', $routeBase, $match)) { $requestUrlPrefix = $match[1]; $requestParams = isset($match[3]) ? $match[3] : false; } else { $parts = explode('?', $routeBase); $requestUrlPrefix = $parts[0]; $requestParams = isset($parts[1]) ? $parts[1] : false; } if (preg_match('#^([^?]*\\?[^=&]*)(&(.*))?$#U', $linkUrl, $match)) { $linkUrlPrefix = $match[1]; //$linkParams = isset($match[3]) ? $match[3] : false; } else { $parts = explode('?', $linkUrl); $linkUrlPrefix = $parts[0]; //$linkParams = isset($parts[1]) ? $parts[1]: false; } if (urldecode($requestUrlPrefix) != urldecode($linkUrlPrefix)) { $redirectUrl = $linkUrlPrefix; if ($requestParams !== false) { $redirectUrl .= (strpos($redirectUrl, '?') === false ? '?' : '&') . $requestParams; } throw $this->responseException($this->responseRedirect(XenForo_ControllerResponse_Redirect::RESOURCE_CANONICAL_PERMANENT, $redirectUrl)); } }
public function languageswitcher() { $ns = new Zend_Session_Namespace('Admin'); $t = new Zend_Controller_Request_Http(); $url = $t->getRequestUri(); $url = explode("?", $url); if (count($url) > 0) { $uri = $url[0]; } else { $uri = $url; } $this->view->languages = Languages::getActiveLanguageList(); $this->view->uri = $uri; $this->view->langselected = $ns->lang; return $this->view->render('partials/switcher.phtml'); }
public function logAdminRequest(Zend_Controller_Request_Http $request, array $requestData = null, $ipAddress = null) { $baseUrl = $request->getBaseUrl(); $requestUri = $request->getRequestUri(); if (substr($requestUri, 0, strlen($baseUrl)) == $baseUrl) { $routeBase = substr($requestUri, strlen($baseUrl)); $routeBase = preg_replace('/^\\?/', '', $routeBase); } else { $routeBase = $requestUri; } if ($requestData === null) { $requestData = $this->_filterAdminLogRequestData($_POST); } $ipAddress = XenForo_Helper_Ip::getBinaryIp(null, $ipAddress, ''); $this->_getDb()->insert('xf_admin_log', array('request_date' => XenForo_Application::$time, 'user_id' => XenForo_Visitor::getUserId(), 'ip_address' => $ipAddress, 'request_url' => $routeBase, 'request_data' => json_encode($requestData))); }
/** * Gets the path the to be routed based on the URL of the request * * @param Zend_Controller_Request_Http Request object * * @return string Routing path */ public function getRoutePath(Zend_Controller_Request_Http $request) { $baseUrl = $request->getBaseUrl(); $requestUri = $request->getRequestUri(); $result = null; if (substr($requestUri, 0, strlen($baseUrl)) == $baseUrl) { $routeBase = substr($requestUri, strlen($baseUrl)); if (preg_match('#^/([^?]+)(\\?|$)#U', $routeBase, $match)) { // rewrite approach (starts with /). Must be non-empty rewrite up to query string. $result = urldecode($match[1]); } else { if (preg_match('#\\?([^=&]+)(&|$)#U', $routeBase, $match)) { // query string approach. Must start with non-empty, non-named param. $result = urldecode($match[1]); } } } if ($result === null) { $namedRouteVar = $request->getParam('_'); if ($namedRouteVar !== null && is_string($namedRouteVar)) { $result = $namedRouteVar; } } if ($result !== null) { return ltrim($result, '/'); } return ''; }
/** * @group ZF-3161 * @group ZFI-233 * @group ZF-5818 */ public function testStrippingHttpProtocolHostAndNonStandardPortFromRequestUriOnlyWhenPresentAtBeginningOfUri() { $_SERVER['REQUEST_URI'] = 'http://foo.example.com:8888/foo/bar?r=http://foo.example.com:8888/bar/baz'; $_SERVER['HTTP_HOST'] = ''; $_SERVER['SERVER_NAME'] = 'foo.example.com'; $_SERVER['SERVER_PORT'] = '8888'; $request = new Zend_Controller_Request_Http(); $test = $request->getRequestUri(); $this->assertEquals('/foo/bar?r=http://foo.example.com:8888/bar/baz', $test); $_SERVER['REQUEST_URI'] = '/foo/bar?r=https://foo.example.com:8888/bar/baz'; $_SERVER['HTTP_HOST'] = ''; $_SERVER['SERVER_NAME'] = 'foo.example.com'; $_SERVER['SERVER_PORT'] = '8888'; $request = new Zend_Controller_Request_Http(); $test = $request->getRequestUri(); $this->assertEquals('/foo/bar?r=https://foo.example.com:8888/bar/baz', $test); }
/** * Gets the request paths from the specified request object. * * @param Zend_Controller_Request_Http $request * * @return array Keys: basePath, host, protocol, fullBasePath, requestUri */ public static function getRequestPaths(Zend_Controller_Request_Http $request) { $basePath = $request->getBasePath(); if ($basePath === '' || substr($basePath, -1) != '/') { $basePath .= '/'; } $host = $request->getServer('HTTP_HOST'); if (!$host) { $host = $request->getServer('SERVER_NAME'); $serverPort = intval($request->getServer('SERVER_PORT')); if ($serverPort && $serverPort != 80 && $serverPort != 443) { $host .= ':' . $serverPort; } } $protocol = $request->isSecure() ? 'https' : 'http'; $requestUri = $request->getRequestUri(); return array('basePath' => $basePath, 'host' => $host, 'protocol' => $protocol, 'fullBasePath' => $protocol . '://' . $host . $basePath, 'requestUri' => $requestUri, 'fullUri' => $protocol . '://' . $host . $requestUri); }
/** * Log a message showing a reroute. * * @param Zend_Controller_Request_Http $request * @param Zend_Config|array $rerouteTo where to reroute the request to * @return void */ public static function logReroute(Zend_Controller_Request_Http $request, $rerouteTo, $reason) { if ($rerouteTo instanceof Zend_Config) { $reroute = $rerouteTo->toArray(); } else { $reroute = $rerouteTo; } self::log('Reroute from URI: ' . $request->getRequestUri() . ' (' . $request->getModuleName() . '/' . $request->getControllerName() . '/' . $request->getActionName() . '/' . ') to: ' . $reroute['moduleName'] . '/' . $reroute['controllerName'] . '/' . $reroute['actionName'] . " Reason: {$reason}"); }
/** * Do some checks before install. * * @throws Expeption If the server don't have the requirements. * * @return void */ private function _checkServer() { // Check the server $checkServer = Phprojekt::checkExtensionsAndSettings(); // Check the PHP version if (!$checkServer['requirements']['php']['checked']) { $missingRequirements[] = "You need the PHP Version " . $checkServer['requirements']['php']['required'] . " or newer. Follow this link for help: <a href=\"" . $checkServer['requirements']['php']['help'] . "\"" . " target=\"_new\">HELP</a>"; } // Check required extension foreach ($checkServer['requirements']['extension'] as $name => $values) { if (!$values['checked']) { $missingRequirements[] = "The '" . $name . "' extension must be enabled. Follow this link for help: " . "<a href=\"" . $values['help'] . "\" target=\"_new\">HELP</a>"; } } // Check required settings foreach ($checkServer['requirements']['settings'] as $name => $values) { if (!$values['checked']) { $missingRequirements[] = "The php.ini setting of '" . $name . "' has to be '" . $values['required'] . "'. Follow this link for help: <a href=\"" . $values['help'] . "\"" . " target=\"_new\">HELP</a>"; } } // Checking if configuration.php exists $baseDir = str_replace('htdocs/setup.php', '', $_SERVER['SCRIPT_FILENAME']); if (file_exists($baseDir . "configuration.php")) { throw new Exception("Configuration file found. Please, delete it before run setup again."); } if (!empty($missingRequirements)) { $message = implode("\n", $missingRequirements); throw new Exception($message); } if (strncmp($_SERVER['SCRIPT_NAME'], '/setup.php', 10) != 0) { $this->_message[] = "It is recommend install PHProjekt 6 using a virtual host.<br />" . "You should try to generate an extra virtual host (or a sub-domain) to phprojekt/htdocs."; // Works the .htaccess? $response = new Zend_Controller_Request_Http(); $webpath = $response->getHttpHost(); $str = ''; $sock = fsockopen($webpath, $response->getServer('SERVER_PORT')); $request = "GET " . str_replace('htdocs/setup.php', '', $response->getRequestUri()) . '/application/' . " HTTP/1.1\r\n" . "Host: " . $webpath . "\r\nConnection: close\r\n\r\n"; fwrite($sock, $request); while ($buff = fread($sock, 1024)) { $str .= $buff; } $response = Zend_Http_Response::fromString($str); if ($response->getStatus() != '403') { $this->_message[] = "Please note that your webserver needs to support .htaccess files " . "to deny access to the configuration files.<br />" . "Running PHProjekt 6 without using the provided .htaccess files to deny access to " . "certain files and folders, might not be secure and is not recommended."; } fclose($sock); } foreach ($checkServer['recommendations']['settings'] as $name => $values) { if (!$values['checked']) { $this->_message[] = "It is recommend to have '" . $name . "' set to '" . $values['required'] . "', but it is not required to run PHProjekt. Follow this link for help: <a href=\"" . $values['help'] . "\" target=\"_new\">HELP</a>"; } } }
/** * Validate signature * * @throws Mage_Oauth_Exception */ protected function _validateSignature() { $util = new Zend_Oauth_Http_Utility(); $calculatedSign = $util->sign(array_merge($this->_params, $this->_protocolParams), $this->_protocolParams['oauth_signature_method'], $this->_consumer->getSecret(), !is_null($this->_token) ? $this->_token->getSecret() : null, $this->_request->getMethod(), $this->_request->getScheme() . '://' . $this->_request->getHttpHost() . $this->_request->getRequestUri()); if ($calculatedSign != $this->_protocolParams['oauth_signature']) { $this->_throwException('Invalid signature.', self::ERR_SIGNATURE_INVALID); } }
/** * Auto-redirect to base url (without SID) if the requested url doesn't match it. * By default this feature is enabled in configuration. * * @param Zend_Controller_Request_Http $request */ protected function _checkBaseUrl($request) { if (!Mage::isInstalled() || $request->getPost()) { return; } if (!Mage::getStoreConfig('web/url/redirect_to_base')) { return; } $adminPath = (string) Mage::getConfig()->getNode(Mage_Adminhtml_Helper_Data::XML_PATH_CUSTOM_ADMIN_PATH); if (!$adminPath) { $adminPath = (string) Mage::getConfig()->getNode(Mage_Adminhtml_Helper_Data::XML_PATH_ADMINHTML_ROUTER_FRONTNAME); } if (preg_match('#^' . $adminPath . '(\\/.*)?$#', ltrim($request->getPathInfo(), '/')) && (string) Mage::getConfig()->getNode(Mage_Adminhtml_Helper_Data::XML_PATH_USE_CUSTOM_ADMIN_URL)) { return; } $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB, Mage::app()->getStore()->isCurrentlySecure()); if (!$baseUrl) { return; } $redirectCode = 302; if (Mage::getStoreConfig('web/url/redirect_to_base') == 301) { $redirectCode = 301; } $uri = @parse_url($baseUrl); $host = isset($uri['host']) ? $uri['host'] : ''; $path = isset($uri['path']) ? $uri['path'] : ''; $requestUri = $request->getRequestUri() ? $request->getRequestUri() : '/'; if ($host && $host != $request->getHttpHost() || $path && strpos($requestUri, $path) === false) { Mage::app()->getFrontController()->getResponse()->setRedirect($baseUrl, $redirectCode)->sendResponse(); exit; } }
/** * Auto-redirect to base url (without SID) if the requested url doesn't match it. * By default this feature is enabled in configuration. * * @param Zend_Controller_Request_Http $request */ protected function _checkBaseUrl($request) { if (!Mage::isInstalled() || $request->getPost()) { return; } if (!Mage::getStoreConfig('web/url/redirect_to_base')) { return; } $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB, Mage::app()->getStore()->isCurrentlySecure()); if (!$baseUrl) { return; } $redirectCode = 302; if (Mage::getStoreConfig('web/url/redirect_to_base') == 301) { $redirectCode = 301; } $uri = @parse_url($baseUrl); $host = isset($uri['host']) ? $uri['host'] : ''; $path = isset($uri['path']) ? $uri['path'] : ''; $requestUri = $request->getRequestUri() ? $request->getRequestUri() : '/'; if ($host && $host != $request->getHttpHost() || $path && strpos($requestUri, $path) === false) { Mage::app()->getFrontController()->getResponse()->setRedirect($baseUrl, $redirectCode)->sendResponse(); exit; } }
public function getRequestUri() { return $this->request->getScheme() . '://' . $this->request->getHttpHost() . rtrim($this->request->getRequestUri(), '?'); }
/** * @param \Zend_Controller_Request_Http $request * @return bool */ public static function isRequestToAdminBackend($request) { return preg_match("/^\\/admin/", $request->getRequestUri()) === 1; }
/** * Compute the request Url from the Http request * * @param \Zend_Controller_Request_Http $httpRequest * @return string */ public function getRequestUrl($httpRequest) { // TODO: Fix needed for $this->getRequest()->getHttpHost(). Hosts with port are not covered. return $httpRequest->getScheme() . '://' . $httpRequest->getHttpHost() . $httpRequest->getRequestUri(); }
/** * Do some checks before install. * * @throws Expeption If the server don't have the requirements. * * @return void */ private function _checkServer() { $missingRequirements = array(); // The following extensions are either needed by components of the Zend Framework that are used // or by P6 components itself. $extensionsNeeded = array('mbstring', 'iconv', 'ctype', 'gd', 'pcre', 'pdo', 'Reflection', 'session', 'SPL', 'zlib'); // These settings need to be properly configured by the admin $settingsNeeded = array('magic_quotes_gpc' => 0, 'magic_quotes_runtime' => 0, 'magic_quotes_sybase' => 0); // These settings should be properly configured by the admin $settingsRecommended = array('register_globals' => 0, 'safe_mode' => 0); // Check the PHP version $requiredPhpVersion = "5.2.4"; if (version_compare(phpversion(), $requiredPhpVersion, '<')) { // This is a requirement of the Zend Framework $missingRequirements[] = "PHP Version {$requiredPhpVersion} or newer"; } foreach ($extensionsNeeded as $extension) { if (!extension_loaded($extension)) { $missingRequirements[] = "The {$extension} extension must be enabled."; } } // Check pdo library $mysql = extension_loaded('pdo_mysql'); $sqlite = extension_loaded('pdo_sqlite2'); $pgsql = extension_loaded('pdo_pgsql'); if (!$mysql && !$sqlite && !$pgsql) { $missingRequirements[] = "You need one of these PDO extensions: pdo_mysql, pdo_pgsql or pdo_sqlite"; } foreach ($settingsNeeded as $conf => $value) { if (ini_get($conf) != $value) { $missingRequirements[] = "The php.ini setting of \"{$conf}\" has to be \"{$value}\"."; } } // Checking if configuration.php exists $baseDir = str_replace('htdocs/setup.php', '', $_SERVER['SCRIPT_FILENAME']); if (file_exists($baseDir . "configuration.php")) { throw new Exception("Configuration file found. Please, delete it before run setup again."); } if (!empty($missingRequirements)) { $message = implode("\n", $missingRequirements); throw new Exception($message); } if (strncmp($_SERVER['SCRIPT_NAME'], '/setup.php', 10) != 0) { $this->_message[] = "It is recommend install PHProjekt 6 using a virtual host.<br />" . "You should try to generate an extra virtual host (or a sub-domain) to phprojekt/htdocs."; // Works the .htaccess? $response = new Zend_Controller_Request_Http(); $webpath = $response->getHttpHost(); $str = ''; $sock = fsockopen($webpath, $response->getServer('SERVER_PORT')); $request = "GET " . str_replace('htdocs/setup.php', '', $response->getRequestUri()) . '/application/' . " HTTP/1.1\r\n" . "Host: " . $webpath . "\r\nConnection: close\r\n\r\n"; fwrite($sock, $request); while ($buff = fread($sock, 1024)) { $str .= $buff; } $response = Zend_Http_Response::fromString($str); if ($response->getStatus() != '403') { $this->_message[] = "Please note that your webserver needs to support .htaccess files " . "to deny access to the configuration files.<br />" . "Running PHProjekt 6 without using the provided .htaccess files to deny access to " . "certain files and folders, might not be secure and is not recommended."; } fclose($sock); } foreach ($settingsRecommended as $conf => $value) { if (ini_get($conf) != $value) { $this->_message[] = "It is recommend to have \"{$conf}\" set to \"{$value}\", but it is not required " . "to run PHProjekt."; } } }
/** * Loading the modules in front controller. */ public static function initFrontController() { $frontController = \Zend_Controller_Front::getInstance(); $frontController->setDefaultModule(self::$module); $directoryiterator = new \DirectoryIterator(self::$applicationPath); $request = new \Zend_Controller_Request_Http(); foreach ($directoryiterator as $directory) { $name = $directory->getBaseName(); if ($directory->isDir() and substr($name, 0, 1) != '.' and $name != 'configs') { //Adding the controllers directory. $controllers = sprintf('%s/%s/controllers', self::$applicationPath, $name); $frontController->addControllerDirectory($controllers, $name); //Setting the current module name. $route = new \Zend_Controller_Router_Route_Regex(sprintf('/%s/*', $name)); if (is_array($route->match($request->getRequestUri(), true))) { self::$module = $name; } } } }
private static function geraTagXml($columns, $metadata, $args) { $sistema = Core_Integration_Sica_User::getInfoSystem(Core_Integration_Sica_User::getUserSystem()); $schema = current($args->getEntityManager()->getConnection()->getSchemaManager()->getSchemaSearchPaths()); $request = new Zend_Controller_Request_Http(); $arrRequest = explode('/', $request->getRequestUri()); $rota = (string) $arrRequest[1] . '/' . $arrRequest[2]; $vCont = 0; $xml = new XMLWriter(); $xml->openMemory(); $xml->startDocument('1.0', 'UTF-8'); $xml->startElement("schema"); $xml->writeElement("nome", $schema); $xml->writeElement("rota", $rota); $xml->startElement("tabela"); $xml->writeElement("nome", $metadata->getTableName()); foreach ($columns as $key => $value) { $xml->startElement("coluna"); $xml->writeElement("nome", $key); $xml->writeElement("valor", $value); $xml->endElement(); $vCont++; } $xml->endElement(); $xml->endElement(); return $xml->outputMemory(true); }
public static function getDebugTemplateParams() { $params = array(); $request = new Zend_Controller_Request_Http(); $pageUrl = $request->getRequestUri(); $params['debug_url'] = $pageUrl . (strpos($pageUrl, '?') !== false ? '&' : '?') . '_debug=1'; if (XenForo_Application::isRegistered('page_start_time')) { $params['page_time'] = microtime(true) - XenForo_Application::get('page_start_time'); } $params['memory_usage'] = memory_get_usage(); if (XenForo_Application::isRegistered('db')) { $profiler = XenForo_Application::getDb()->getProfiler(); $params['db_queries'] = $profiler->getTotalNumQueries(); } return $params; }
public static function matchUrl(Zend_Controller_Request_Http $request) { if (AW_Kbase_Helper_Data::isModuleOutputDisabled() || !AW_Kbase_Helper_Data::getFrontendEnabled()) { return false; } $urlKey = self::getModuleUrlKey(); $pathInfo = $request->getPathInfo(); $requestUri = $request->getRequestUri(); if ($request->getParam('___from_store')) { $_fromStore = Mage::app()->getSafeStore($request->getParam('___from_store')); if ($_fromStore->getData()) { $_oldUrlKey = self::getModuleUrlKeyFromConfig($_fromStore); if (strpos($pathInfo, '/' . $_oldUrlKey) === 0 && $_oldUrlKey != $urlKey) { $_newUrl = self::secureUrl(Mage::getBaseUrl() . $urlKey . '/'); $response = Mage::app()->getResponse(); $response->setRedirect($_newUrl); $response->sendHeaders(); $request->setDispatched(true); return true; } } } if (0 !== strpos($pathInfo, '/' . $urlKey . '/')) { // if path does not begin with /kbase/ return false; } $pathInfo = substr($pathInfo, strlen($urlKey) + 2); $request->setModuleName('kbase')->setControllerName('article'); if (!strlen($pathInfo)) { $request->setActionName('index'); return AW_Kbase_Helper_Data::getFrontendEnabled() && self::cacheRewrite($request->getPathInfo(), 'kbase/article/index'); } $urlKeySuffix = self::getUrlKeySuffix(); $isArticle = false; if (!$urlKeySuffix) { $_path = explode('/', $pathInfo); $_aUrl = false; if (count($_path) == 1) { $_aUrl = $_path[0]; } if (count($_path) == 2) { $_aUrl = $_path[1]; } if ($_aUrl) { $_aUrl = urldecode($_aUrl); $_aId = Mage::getModel('kbase/article')->getResource()->getIdByUrlKey($_aUrl); if (!$_aId) { $_aId = Mage::getModel('kbase/article')->getResource()->getIdByUrlKey($_aUrl, true); } if ($_aId) { $isArticle = true; } } } /** * Checking is customer comes from other store view * having various article suffix id in comparison * with current */ if ($request->getParam('___from_store') && !$isArticle) { if (!isset($_fromStore)) { $_fromStore = Mage::app()->getSafeStore($request->getParam('___from_store')); } if ($_fromStore->getData()) { $_oldUrlSuffix = self::getUrlKeySuffixFromConfig($_fromStore); if ($urlKeySuffix != $_oldUrlSuffix) { $_path = explode('/', $pathInfo); $_aUrl = false; if (count($_path) == 1) { $_aUrl = $_path[0]; } if (count($_path) == 2) { $_aUrl = $_path[1]; } if ($_aUrl) { $_articleUrlKey = substr($_aUrl, 0, strpos($_aUrl, $_oldUrlSuffix)); $_aId = Mage::getModel('kbase/article')->getResource()->getIdByUrlKey($_articleUrlKey); if (!$_aId) { $_aId = Mage::getModel('kbase/article')->getResource()->getIdByUrlKey($_articleUrlKey, true); } if ($_aId) { $_storeIds = Mage::getModel('kbase/article')->getResource()->getArticleStoreIds($_aId); if (in_array(Mage::app()->getStore()->getId(), $_storeIds)) { $_newUrl = self::secureUrl(Mage::getBaseUrl() . $urlKey . '/' . $_articleUrlKey . $urlKeySuffix); $response = Mage::app()->getResponse(); $response->setRedirect($_newUrl); $response->sendHeaders(); $request->setDispatched(true); return true; } } } } } } if ($urlKeySuffix && '/' != $urlKeySuffix && $urlKeySuffix == substr($pathInfo, -strlen($urlKeySuffix)) || $isArticle) { $pathInfo = substr($pathInfo, 0, strlen($pathInfo) - strlen($urlKeySuffix)); $path = explode('/', $pathInfo); if (count($path) == 1) { $request->setActionName('article'); self::$_queryParams[self::URL_PARAM_NAME_ARTICLE] = $path[0]; return self::cacheRewrite($request->getPathInfo(), 'kbase/article/article/' . self::URL_PARAM_NAME_ARTICLE . '/' . $path[0]); } elseif (count($path) == 2) { $request->setActionName('article'); self::$_queryParams[self::URL_PARAM_NAME_CATEGORY] = $path[0]; self::$_queryParams[self::URL_PARAM_NAME_ARTICLE] = $path[1]; return self::cacheRewrite($request->getPathInfo(), 'kbase/article/article/' . self::URL_PARAM_NAME_CATEGORY . '/' . $path[0] . '/' . self::URL_PARAM_NAME_ARTICLE . '/' . $path[1]); } return false; } // since further there will be listing pages only, we should check the condition here if (!Mage::getStoreConfig('kbase/general/frontent_enabled')) { return false; } // init parameters with optional ones self::$_queryParams = array(self::URL_PARAM_NAME_LIMIT => false, self::URL_PARAM_NAME_PAGE => false, self::URL_PARAM_NAME_SORT => false, self::URL_PARAM_NAME_SORT_DIR => false, self::URL_PARAM_NAME_QUERY => false); $pathInfo = substr($pathInfo, 0, strlen($pathInfo) - 1); $path = explode('/', $pathInfo); for ($i = count($path) - 1; $i > 0; $i -= 2) { $paramName = $path[$i - 1]; if (array_key_exists($paramName, self::$_queryParams)) { // for(; $path[$i] != $decoded = urldecode($path[$i]); $path[$i] = $decoded); // self::$_queryParams[$paramName] = $path[$i]; self::$_queryParams[$paramName] = urldecode($path[$i]); unset($path[$i]); unset($path[$i - 1]); } } foreach (self::$_queryParams as $paramName => $value) { if ($value = self::getQueryParam($requestUri, $paramName)) { self::$_queryParams[$paramName] = urldecode($value); $requestUri = self::unsetQueryParam($requestUri, $paramName); } } if (1 == count($path)) { if ('search' == $path[0]) { // if there were known parameters passed as query params if ($requestUri != $request->getRequestUri()) { foreach (self::$_queryParams as $name => $value) { if ($value) { self::$_queryParams[$name] = self::encodeSpecialChars($value); } } Mage::app()->getFrontController()->getResponse()->setRedirect(self::getUrl(self::URL_TYPE_SEARCH, self::$_queryParams))->sendResponse(); exit; } $request->setActionName('search'); return true; } $request->setActionName('category'); self::$_queryParams[self::URL_PARAM_NAME_CATEGORY] = $path[0]; return true; } elseif (2 == count($path) && 'tag' == $path[0] && $path[1]) { $request->setActionName('tag'); self::$_queryParams[self::URL_PARAM_NAME_TAG] = $path[1]; return true; } return false; }
/** * Parse Digest Authorization header * * @param string $header Client's Authorization: HTTP header * @return array|false Data elements from header, or false if any part of * the header is invalid */ protected function _parseDigestAuth($header) { $temp = null; $data = array(); // See ZF-1052. Detect invalid usernames instead of just returning a // 400 code. $ret = preg_match('/username="******"]+)"/', $header, $temp); if (!$ret || empty($temp[1]) || !ctype_print($temp[1]) || strpos($temp[1], ':') !== false) { $data['username'] = '******'; } else { $data['username'] = $temp[1]; } $temp = null; $ret = preg_match('/realm="([^"]+)"/', $header, $temp); if (!$ret || empty($temp[1])) { return false; } if (!ctype_print($temp[1]) || strpos($temp[1], ':') !== false) { return false; } else { $data['realm'] = $temp[1]; } $temp = null; $ret = preg_match('/nonce="([^"]+)"/', $header, $temp); if (!$ret || empty($temp[1])) { return false; } if (!ctype_xdigit($temp[1])) { return false; } else { $data['nonce'] = $temp[1]; } $temp = null; $ret = preg_match('/uri="([^"]+)"/', $header, $temp); if (!$ret || empty($temp[1])) { return false; } // Section 3.2.2.5 in RFC 2617 says the authenticating server must // verify that the URI field in the Authorization header is for the // same resource requested in the Request Line. $rUri = @parse_url($this->_request->getRequestUri()); $cUri = @parse_url($temp[1]); if (false === $rUri || false === $cUri) { return false; } else { // Make sure the path portion of both URIs is the same if ($rUri['path'] != $cUri['path']) { return false; } // Section 3.2.2.5 seems to suggest that the value of the URI // Authorization field should be made into an absolute URI if the // Request URI is absolute, but it's vague, and that's a bunch of // code I don't want to write right now. $data['uri'] = $temp[1]; } $temp = null; $ret = preg_match('/response="([^"]+)"/', $header, $temp); if (!$ret || empty($temp[1])) { return false; } if (32 != strlen($temp[1]) || !ctype_xdigit($temp[1])) { return false; } else { $data['response'] = $temp[1]; } $temp = null; // The spec says this should default to MD5 if omitted. OK, so how does // that square with the algo we send out in the WWW-Authenticate header, // if it can easily be overridden by the client? $ret = preg_match('/algorithm="?(' . $this->_algo . ')"?/', $header, $temp); if ($ret && !empty($temp[1]) && in_array($temp[1], $this->_supportedAlgos)) { $data['algorithm'] = $temp[1]; } else { $data['algorithm'] = 'MD5'; // = $this->_algo; ? } $temp = null; // Not optional in this implementation $ret = preg_match('/cnonce="([^"]+)"/', $header, $temp); if (!$ret || empty($temp[1])) { return false; } if (!ctype_print($temp[1])) { return false; } else { $data['cnonce'] = $temp[1]; } $temp = null; // If the server sent an opaque value, the client must send it back if ($this->_useOpaque) { $ret = preg_match('/opaque="([^"]+)"/', $header, $temp); if (!$ret || empty($temp[1])) { // Big surprise: IE isn't RFC 2617-compliant. if (false !== strpos($this->_request->getHeader('User-Agent'), 'MSIE')) { $temp[1] = ''; $this->_ieNoOpaque = true; } else { return false; } } // This implementation only sends MD5 hex strings in the opaque value if (!$this->_ieNoOpaque && (32 != strlen($temp[1]) || !ctype_xdigit($temp[1]))) { return false; } else { $data['opaque'] = $temp[1]; } $temp = null; } // Not optional in this implementation, but must be one of the supported // qop types $ret = preg_match('/qop="?(' . implode('|', $this->_supportedQops) . ')"?/', $header, $temp); if (!$ret || empty($temp[1])) { return false; } if (!in_array($temp[1], $this->_supportedQops)) { return false; } else { $data['qop'] = $temp[1]; } $temp = null; // Not optional in this implementation. The spec says this value // shouldn't be a quoted string, but apparently some implementations // quote it anyway. See ZF-1544. $ret = preg_match('/nc="?([0-9A-Fa-f]{8})"?/', $header, $temp); if (!$ret || empty($temp[1])) { return false; } if (8 != strlen($temp[1]) || !ctype_xdigit($temp[1])) { return false; } else { $data['nc'] = $temp[1]; } $temp = null; return $data; }
public function init() { $this->_redirector = $this->_helper->getHelper('Redirector'); $this->_hostHttp = new Zend_Controller_Request_Http(); $this->_curUrl = $this->_hostHttp->getRequestUri(); }