Esempio n. 1
0
 public function __construct(Request $request)
 {
     if (strpos($request->getURI(), 'index.php') || strpos($request->getURI(), 'index.html')) {
         header('HTTP/1.0 301 Moved Permanently');
         $replaced_url = str_replace(['index.php/', 'index.php', 'index.html'], ['', '', ''], str_replace('?', '', $request->getURI()));
         header('Location: http://' . $request->getHttpHost() . $replaced_url);
         exit(0);
     }
 }
Esempio n. 2
0
 public function getUrl($url_raw)
 {
     // Ignore preformed URLs.
     if (stristr($url_raw, '://')) {
         return $url_raw;
     }
     // Retrieve domain from either MVC controller or config file.
     if ($this->_include_domain) {
         $url_domain = null;
         $url_domain = $this->_config->application->base_url;
         if (!$url_domain) {
             $http_host = trim($this->_request->getHttpHost(), ':');
             if (!empty($http_host)) {
                 $url_domain = (FA_IS_SECURE ? 'https://' : 'http://') . $http_host;
             }
         }
         $url_raw = $url_domain . $url_raw;
     }
     return $url_raw;
 }
Esempio n. 3
0
 /**
  * Generate cache key pair (for response header / body) by Host + Uri + Allowed Queries
  * @param Request $request
  * @param array $ignores
  * @return array
  */
 public function generateCacheKeys(Request $request, array $ignores = array())
 {
     list($urlPath) = explode('?', $request->getURI());
     $urlQuery = $request->getQuery();
     //NOTE: remove Phalcon default url rewrite param here
     unset($urlQuery['_url']);
     if ($ignores) {
         foreach ($ignores as $ignoreKey) {
             unset($urlQuery[$ignoreKey]);
         }
     }
     $cacheKeyPrefix = $request->getHttpHost() . $urlPath . json_encode($urlQuery);
     $cacheKeyPrefix = md5($cacheKeyPrefix);
     $bodyKey = $cacheKeyPrefix . '_b';
     $headersKey = $cacheKeyPrefix . '_h';
     $this->cacheHeadersKey = $headersKey;
     $this->cacheBodyKey = $bodyKey;
     return array($headersKey, $bodyKey);
 }
Esempio n. 4
0
 /**
  * Lets you specify the callback url to redirect to when authorizing the page is reloaded.
  * If the url is not specified and is used to redirect the authorization,
  * the authorization after the current page just updated
  *
  * @param string $url page that will be implemented to redirect after login (accept QUERY_STRING)
  * @return $this
  */
 public function setUrl($url = '')
 {
     if (is_array($url) === true) {
         $url = $url[key($url)];
     }
     $request = new Request();
     if (empty($url) === true) {
         $this->url = $request->getScheme() . '://' . $request->getHttpHost() . (new Router())->getRewriteUri();
     } else {
         $this->url = $request->getScheme() . '://' . $request->getHttpHost() . $url;
     }
     return $this;
 }
Esempio n. 5
0
 public function getHttpHost()
 {
     return parent::getHttpHost();
 }