Esempio n. 1
0
 protected function setBase()
 {
     $head = $this->getElementByTagName('head', 0);
     if (!$head instanceof DOMNode) {
         return;
     }
     $script = substr($_SERVER['SCRIPT_NAME'], 0, strrpos($_SERVER['SCRIPT_NAME'], "/"));
     $site_url = I2CE::getProtocol() . '://' . $_SERVER['HTTP_HOST'] . $script . '/';
     $base = $this->createElement('base', array('href' => $site_url));
     $head->insertBefore($base, $head->firstChild);
 }
Esempio n. 2
0
 /**
  * Send the redirect header with the given URL.
  *
  * @param string $url
  */
 public function redirect($url)
 {
     if (!array_key_exists('HTTP_HOST', $_SERVER)) {
         return;
     }
     if ($this->isGet() && !preg_match('/login/', $_SERVER['REQUEST_URI'])) {
         $_SESSION['referal'] = I2CE::getProtocol() . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     }
     if (preg_match('/^[a-zA-Z]+:\\/\\//', $url) || $url[0] == '/') {
         //an absolute url
         //do nothing;
     } else {
         $url = $this->getAccessedBaseURL() . $url;
     }
     header("Location: " . $url);
 }
Esempio n. 3
0
 /**
  * Returns the base url from which the site was accessed.  If no
  * .htaccess is used, ths will include the index.php.  If rewrites
  * are used (via .htacces) this will no include the
  * index.php. Point is... this is the base url from which the site
  * was accessed, no questions asked.  This of course assumes that
  * you are now accessing the site via the command line
  *
  *@return string
  */
 public static function getAccessedBaseURL($include_http = true)
 {
     $script = substr($_SERVER['SCRIPT_NAME'], 0, strrpos($_SERVER['SCRIPT_NAME'], "/"));
     if ($include_http) {
         if (array_key_exists('HTTP_HOST', $_SERVER)) {
             $site_url = I2CE::getProtocol() . '://' . $_SERVER['HTTP_HOST'] . $script . '/';
         } else {
             $site_url = 'http://localhost/';
         }
     } else {
         $site_url = $script . '/';
     }
     if (!self::rewrittenURLs()) {
         $site_url = $site_url . 'index.php/';
     } else {
         if ($_SERVER['SCRIPT_NAME'] . '/update.php' == $_SERVER['PHP_SELF']) {
             $site_url = $site_url . 'index.php/';
         }
     }
     return $site_url;
 }