本文整理汇总了PHP中Zend_Controller_Request_Abstract::getHttpHost方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Controller_Request_Abstract::getHttpHost方法的具体用法?PHP Zend_Controller_Request_Abstract::getHttpHost怎么用?PHP Zend_Controller_Request_Abstract::getHttpHost使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Controller_Request_Abstract
的用法示例。
在下文中一共展示了Zend_Controller_Request_Abstract::getHttpHost方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postDispatch
public function postDispatch(Zend_Controller_Request_Abstract $request)
{
// if (Zend_Registry::isRegistered(Tomato_Core_GlobalKey::LOG_REQUEST)
// && Zend_Registry::get(Tomato_Core_GlobalKey::LOG_REQUEST) == false
// ) {
// return;
// }
$objRequestLog = new Model_RequestLog();
$uri = $request->getRequestUri();
$agent = $request->getServer('HTTP_USER_AGENT');
$browserInfo = self::_getBrowserInfo($agent);
$objRequestLog->insert(array('ip' => $request->getClientIp(), 'agent' => $agent, 'browser' => $browserInfo['browser'], 'version' => $browserInfo['version'], 'platform' => $browserInfo['platform'], 'bot' => self::_getBot($agent), 'uri' => $uri, 'full_url' => $request->getScheme() . '://' . $request->getHttpHost() . '/' . ltrim($uri, '/'), 'refer_url' => $request->getServer('HTTP_REFERER'), 'access_time' => date('Y-m-d H:i:s')));
// $log = new Tomato_Modules_Core_Model_RequestLog(
// array(
// 'ip' => $request->getClientIp(),
// 'agent' => $agent,
// 'browser' => $browserInfo['browser'],
// 'version' => $browserInfo['version'],
// 'platform' => $browserInfo['platform'],
// 'bot' => self::_getBot($agent),
// 'uri' => $uri,
// 'full_url' => $request->getScheme().'://'.$request->getHttpHost().'/'.ltrim($uri, '/'),
// 'refer_url' => $request->getServer('HTTP_REFERER'),
// 'access_time' => date('Y-m-d H:i:s'),
// )
// );
// $conn = Tomato_Core_Db_Connection::getMasterConnection();
// $gateway = new Tomato_Modules_Core_Model_RequestLogGateway();
// $gateway->setDbConnection($conn);
// $gateway->create($log);
}
示例2: preDispatch
public function preDispatch(AbstractRequest $request)
{
if ($request->module === 'default' && $request->controller === 'auth') {
return;
}
$frontController = FrontController::getInstance();
$bootstrap = $frontController->getParam('bootstrap');
$serviceManager = $bootstrap->getResource('ServiceManager');
$authService = $serviceManager->get('Zend\\Authentication\\AuthenticationService');
if (!$authService->hasIdentity()) {
$response = $this->getResponse();
$currentUri = sprintf('%s://%s%s%s', $request->getScheme(), $request->getHttpHost(), $request->getBaseUrl(), $request->getPathInfo());
$adapter = $authService->getAdapter();
$adapter->setLoginParameters(array('service' => $currentUri));
// Assume user is back here from a CAS authentication
if ($request->getQuery('ticket')) {
$adapter->setServiceValidateParameters(array('service' => $currentUri, 'ticket' => $request->getQuery('ticket')));
// Validate the ticket
$result = $authService->authenticate();
if (!$result->isValid()) {
$response->setRedirect($adapter->createLoginUri());
}
// Assume the user just got here
} else {
$response->setRedirect($adapter->createLoginUri());
}
}
}
示例3: routeStartup
/**
* routeStartup
* 在 路由器 完成请求的路由前被调用
*
* @param Zend_Controller_Request_Abstract $request
* @return void
*/
public function routeStartup(Zend_Controller_Request_Abstract $request)
{
// Do nothing...
return;
$hostname = $request->getHttpHost();
$pathinfo = $request->getPathInfo();
/**
* 根据二级域名检测请求的模块
*/
if (!empty($hostname)) {
$segments = explode('.', $hostname);
if (isset($segments[2])) {
$segmentNum = count($segments);
$rootDomain = $segments[$segmentNum - 2] . '.' . $segments[$segmentNum - 1];
if ($rootDomain === parse_url(URL_FTT, PHP_URL_HOST)) {
$subDomain2 = $segments[$segmentNum - 3];
if (array_key_exists($subDomain2, static::$_subDomain2ModuleMap)) {
$module = static::$_subDomain2ModuleMap[$subDomain2];
$hostel = explode('/', trim($pathinfo, '/'));
$hostel = trim(array_shift($hostel));
if ($hostel != '') {
$this->getResponse()->setRedirect(URL_FTT . '/' . $module . '/?' . static::KEY_INN . '=' . $hostel)->sendResponse();
exit;
}
}
}
}
}
}
示例4: routeStartup
public function routeStartup(\Zend_Controller_Request_Abstract $request)
{
/** @var $request \Zend_Controller_Request_Http */
if (!$request->isGet()) {
return;
}
$host = 'http://' . $request->getHttpHost();
$uri = \Zend_Uri_Http::fromString($host . $request->getRequestUri());
$query = $uri->getQueryAsArray();
if (!isset($query['_escaped_fragment_'])) {
return;
}
$path = $uri->getPath() . ltrim($query['_escaped_fragment_'], '/');
$uri->setPath($path);
unset($query['_escaped_fragment_']);
$uri->setQuery($query);
$request->setRequestUri(str_replace($host, '', $uri->getUri()));
$request->setPathInfo();
}
示例5: routeStartup
public function routeStartup(Zend_Controller_Request_Abstract $request)
{
// Initialize the variables
$front = Zend_Controller_Front::getInstance();
$bootstrap = $front->getParam('bootstrap');
$this->locale = $bootstrap->getResource('locale');
if (null === $this->locale) {
$this->locale = new Zend_Locale();
}
$this->resource = ZFE_Environment::getResource('Multilanguage');
$options = $this->resource->getOptions();
$language = $this->getBrowserLanguage();
// If a domain is given, perform subdomain-based language detection
if (isset($options['domain'])) {
$domain = $request->getHttpHost();
// If the main domain is accessed, use the browser language and
// redirect to that subdomain
if ($domain === $options['domain']) {
// Perform 302 redirect
header('HTTP/1.1 302');
header('Location: ' . $this->composeUrl($language));
exit;
}
// If it is not an IP address, extract the language from the domain, and store it
if (!ZFE_Core::isIpAddress($domain)) {
$subdomain = strtolower(str_replace('.' . $options['domain'], '', $domain));
$parts = explode('-', $subdomain);
$language = $parts[0];
if (isset($parts[1])) {
$language .= '_' . ucfirst($parts[1]);
}
}
}
// healthcheck: only use whitelisted languages
if (!in_array($language, $options["languages"])) {
$language = $options["languages"][0];
}
// Store the language in the resource
// This also initializes the translation resource
$this->resource->setLanguage($language);
}
示例6: routeStartup
/**
* @param \Zend_Controller_Request_Abstract $request
* @return bool|void
*/
public function routeStartup(\Zend_Controller_Request_Abstract $request)
{
$requestUri = $request->getRequestUri();
$excludePatterns = array();
// only enable GET method
if (!$request->isGet()) {
return $this->disable();
}
// disable the output-cache if browser wants the most recent version
// unfortunately only Chrome + Firefox if not using SSL
if (!$request->isSecure()) {
if (isset($_SERVER["HTTP_CACHE_CONTROL"]) && $_SERVER["HTTP_CACHE_CONTROL"] == "no-cache") {
return $this->disable("HTTP Header Cache-Control: no-cache was sent");
}
if (isset($_SERVER["HTTP_PRAGMA"]) && $_SERVER["HTTP_PRAGMA"] == "no-cache") {
return $this->disable("HTTP Header Pragma: no-cache was sent");
}
}
try {
$conf = \Pimcore\Config::getSystemConfig();
if ($conf->cache) {
$conf = $conf->cache;
if (!$conf->enabled) {
return $this->disable();
}
if (\Pimcore::inDebugMode()) {
return $this->disable("in debug mode");
}
if ($conf->lifetime) {
$this->setLifetime((int) $conf->lifetime);
}
if ($conf->excludePatterns) {
$confExcludePatterns = explode(",", $conf->excludePatterns);
if (!empty($confExcludePatterns)) {
$excludePatterns = $confExcludePatterns;
}
}
if ($conf->excludeCookie) {
$cookies = explode(",", strval($conf->excludeCookie));
foreach ($cookies as $cookie) {
if (!empty($cookie) && isset($_COOKIE[trim($cookie)])) {
return $this->disable("exclude cookie in system-settings matches");
}
}
}
// output-cache is always disabled when logged in at the admin ui
if (isset($_COOKIE["pimcore_admin_sid"])) {
return $this->disable("backend user is logged in");
}
} else {
return $this->disable();
}
} catch (\Exception $e) {
\Logger::error($e);
return $this->disable("ERROR: Exception (see debug.log)");
}
foreach ($excludePatterns as $pattern) {
if (@preg_match($pattern, $requestUri)) {
return $this->disable("exclude path pattern in system-settings matches");
}
}
$deviceDetector = Tool\DeviceDetector::getInstance();
$device = $deviceDetector->getDevice();
$deviceDetector->setWasUsed(false);
$this->defaultCacheKey = "output_" . md5($request->getHttpHost() . $requestUri);
$cacheKeys = [$this->defaultCacheKey . "_" . $device, $this->defaultCacheKey];
$cacheItem = null;
foreach ($cacheKeys as $cacheKey) {
$cacheItem = CacheManager::load($cacheKey, true);
if ($cacheItem) {
break;
}
}
if (is_array($cacheItem) && !empty($cacheItem)) {
header("X-Pimcore-Output-Cache-Tag: " . $cacheKey, true, 200);
header("X-Pimcore-Output-Cache-Date: " . $cacheItem["date"]);
foreach ($cacheItem["rawHeaders"] as $header) {
header($header);
}
foreach ($cacheItem["headers"] as $header) {
header($header['name'] . ': ' . $header['value'], $header['replace']);
}
echo $cacheItem["content"];
exit;
} else {
// set headers to tell the client to not cache the contents
// this can/will be overwritten in $this->dispatchLoopShutdown() if the cache is enabled
$date = new \Zend_Date(1);
$this->getResponse()->setHeader("Expires", $date->get(\Zend_Date::RFC_1123), true);
$this->getResponse()->setHeader("Cache-Control", "max-age=0, no-cache", true);
}
}
示例7: preDispatch
/**
* Predispatch
* Checks if the current user identified by roleName has rights to the requested url (module/controller/action)
* If not, it will call denyAccess to be redirected to errorPage
*
* @return void
**/
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
$controller = strtolower($request->getControllerName());
if (in_array($controller, array("api", "auth", "locale"))) {
$this->setRoleName("G");
} elseif (!Zend_Auth::getInstance()->hasIdentity()) {
if ($controller !== 'login') {
if ($request->isXmlHttpRequest()) {
$url = 'http://' . $request->getHttpHost() . '/login';
$json = Zend_Json::encode(array('auth' => false, 'url' => $url));
// Prepare response
$this->getResponse()->setHttpResponseCode(401)->setBody($json)->sendResponse();
//redirectAndExit() cleans up, sends the headers and stops the script
Zend_Controller_Action_HelperBroker::getStaticHelper('redirector')->redirectAndExit();
} else {
$r = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
$r->gotoSimpleAndExit('index', 'login', $request->getModuleName());
}
}
} else {
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$this->setRoleName($userInfo->type);
Zend_View_Helper_Navigation_HelperAbstract::setDefaultAcl($this->_acl);
Zend_View_Helper_Navigation_HelperAbstract::setDefaultRole($this->_roleName);
$resourceName = '';
if ($request->getModuleName() != 'default') {
$resourceName .= strtolower($request->getModuleName()) . ':';
}
$resourceName .= $controller;
/** Check if the controller/action can be accessed by the current user */
if (!$this->getAcl()->has($resourceName) || !$this->getAcl()->isAllowed($this->_roleName, $resourceName, $request->getActionName())) {
/** Redirect to access denied page */
$this->denyAccess();
}
}
}