Exemplo n.º 1
0
 /**
  * Set URL for get front-end content. Correct URL
  *
  * @param   string  $url  Link
  *
  * @return  void
  */
 public static function setRenderUrl($url = '')
 {
     $uri = new JURI($url);
     if ($uri->getScheme() == '') {
         $scheme = 'http';
         if (@$_SERVER['HTTPS']) {
             $scheme = 'https';
         }
         $uri->setScheme($scheme);
     }
     @(list($host, $port) = explode(':', $_SERVER['HTTP_HOST']));
     if ($uri->getHost() == '') {
         $uri->setHost($host);
     }
     if ($uri->getPort() == '') {
         $uri->setPort($port);
     }
     if (strtolower($uri->getHost()) != strtolower($host)) {
         self::$_isExternal = true;
     } else {
         if (!$uri->hasVar('jsntpl_position')) {
             $uri->setVar('jsntpl_position', '1');
         }
         if (!$uri->hasVar('secret_key')) {
             $config = JFactory::getConfig();
             $secret = $config->get('secret');
             $uri->setVar('secret_key', md5($secret));
         }
         if ($uri->hasVar('Itemid') and $uri->getVar('Itemid') == '') {
             $uri->delVar('Itemid');
         }
         self::$_renderUrl = $uri->toString();
     }
 }
Exemplo n.º 2
0
 /**
  * useSSL
  *
  * @param $ssl
  *
  * @return void
  */
 public function useSSL($ssl)
 {
     if ($ssl) {
         $this->uri->setScheme('https');
     } else {
         $this->uri->setScheme('http');
     }
 }
Exemplo n.º 3
0
	public function testSetScheme() {
		$this->object->setScheme('ftp');

		$this->assertThat(
			$this->object->getScheme(),
			$this->equalTo('ftp')
		);
	}
Exemplo n.º 4
0
 /**
  * Give a relative path, return path with host.
  *
  * @param   string $path A system path.
  *
  * @return  string  Path with host added.
  */
 public static function pathAddHost($path)
 {
     if (!$path) {
         return;
     }
     // build path
     $uri = new JURI($path);
     if ($uri->getHost()) {
         return $path;
     }
     $uri->parse(JURI::root());
     $root_path = $uri->getPath();
     if (strpos($path, $root_path) === 0) {
         $num = JString::strlen($root_path);
         $path = JString::substr($path, $num);
     }
     $uri->setPath($uri->getPath() . $path);
     $uri->setScheme('http');
     $uri->setQuery(null);
     return $uri->toString();
 }
Exemplo n.º 5
0
 /**
  * Function to convert a route to an internal URI
  *
  * @param   JURI  $uri  The uri.
  *
  * @return  array
  */
 public function parse($uri)
 {
     $vars = array();
     // Get the application
     $app = JApplication::getInstance('site');
     if ($app->getCfg('force_ssl') == 2 && strtolower($uri->getScheme()) != 'https') {
         // Forward to https
         $uri->setScheme('https');
         $app->redirect((string) $uri);
     }
     // Get the path
     // Decode URL to convert punycode to unicode so that strings match when routing.
     $path = urldecode($uri->getPath());
     // Remove the base URI path.
     $path = substr_replace($path, '', 0, strlen(JURI::base(true)));
     // Check to see if a request to a specific entry point has been made.
     if (preg_match("#.*?\\.php#u", $path, $matches)) {
         // Get the current entry point path relative to the site path.
         $scriptPath = realpath($_SERVER['SCRIPT_FILENAME'] ? $_SERVER['SCRIPT_FILENAME'] : str_replace('\\\\', '\\', $_SERVER['PATH_TRANSLATED']));
         $relativeScriptPath = str_replace('\\', '/', str_replace(JPATH_SITE, '', $scriptPath));
         // If a php file has been found in the request path, check to see if it is a valid file.
         // Also verify that it represents the same file from the server variable for entry script.
         if (file_exists(JPATH_SITE . $matches[0]) && $matches[0] == $relativeScriptPath) {
             // Remove the entry point segments from the request path for proper routing.
             $path = str_replace($matches[0], '', $path);
         }
     }
     // Identify format
     if ($this->_mode == JROUTER_MODE_SEF) {
         if ($app->getCfg('sef_suffix') && !(substr($path, -9) == 'index.php' || substr($path, -1) == '/')) {
             if ($suffix = pathinfo($path, PATHINFO_EXTENSION)) {
                 $vars['format'] = $suffix;
             }
         }
     }
     // Set the route
     $uri->setPath(trim($path, '/'));
     $vars += parent::parse($uri);
     return $vars;
 }
Exemplo n.º 6
0
 /**
  * Преобразует img-тег в html-код иконки
  * @param array $matches
  * @return string
  */
 function imageReplacer(&$matches)
 {
     // Создать объект тега изображения
     $newImgStr = $imgStr = $matches[0];
     $this->img->parse($imgStr);
     // Если указаны классы для которых (не)надо создавать иконки, проверить класс изображения.
     // И если для данного не надо создавать - выйти из функции.
     if ($this->thumbnailsFor && $this->class) {
         $imgClasses = explode(' ', $this->img->getAttribute('class'));
         $myClasses = preg_split('/\\W+/', $this->class);
         $classFind = array_intersect($imgClasses, $myClasses);
         if ($this->thumbnailsFor == 1 && !$classFind || $this->thumbnailsFor == 2 && $classFind) {
             return $imgStr;
         }
     }
     // Если изображение удаленное - проверить наличие локальной копии, при отсутствии создать
     $juri =& JFactory::getURI();
     $src = $this->img->getAttribute('src');
     if (!$juri->isInternal($src)) {
         $this->copyRemote($src);
     }
     // Проверить необходимость замены - нужна ли иконка?
     // Прежде чем обращатья к функциям GD, проверяются атрибуты тега.
     if ($this->img->getHeight() || $this->img->getWidth() || $this->defaultWidth || $this->defaultHeight) {
         $this->origImgName = $this->img->getAttribute('src');
         $this->origImgName = $this->urlToFile($this->origImgName);
         $this->origImgSize = @getimagesize($this->origImgName);
         // Если размер файла определить не удалось, вероятно это скрипт
         // Копируем как файл с удаленного сервера и пробуем еще раз
         if ($this->origImgSize === false) {
             $src = new JURI($src);
             $src->setHost($_SERVER['SERVER_NAME']);
             $src->setScheme('http');
             $this->copyRemote($src->toString());
             $this->origImgName = $this->img->getAttribute('src');
             $this->origImgName = $this->urlToFile($this->origImgName);
             $this->origImgSize = @getimagesize($this->origImgName);
         }
         $origImgW = $this->origImgSize[0];
         $this->origImgSize[1] = $this->origImgSize[1];
         /* Размеры по-умолчанию */
         // Если это блог или главная, взять настройки для блогов
         if ($this->blogHelper && $this->blogHelper->isBlog()) {
             $this->defaultSize = $this->blogDefaultSize;
             $this->defaultWidth = $this->blogDefaultWidth;
             $this->defaultHeight = $this->blogDefaultHeight;
         }
         $this->proportionsStrategy->setDefaultSize();
         if ($this->img->getWidth() && $this->img->getWidth() < $this->origImgSize[0] || $this->img->getHeight() && $this->img->getHeight() < $this->origImgSize[1]) {
             // Заменить изображение на иконку
             $newImgStr = $this->createThumb();
             $this->img->isThumb = true;
         }
     }
     if ($this->img->isThumb || $this->popupType == 'bloglink') {
         if (!$this->has_header) {
             $this->decorator->addHeader();
         }
         $this->has_header = true;
         $result = $this->decorator->decorate();
     } else {
         $result = $this->img->toString();
     }
     return $result;
 }
Exemplo n.º 7
0
if (DEFAULT_QUOTATION_MODE) {
    $checkout = '';
} else {
    $checkout = '';
    JPluginHelper::importPlugin('redshop_payment');
    $dispatcher = JDispatcher::getInstance();
    $pluginButton = $dispatcher->trigger('onPaymentCheckoutButton', array($cart));
    $pluginButton = implode("<br>", $pluginButton);
    // Google checkout start Div
    if ($pluginButton) {
        $checkout .= '<div class="googlecheckout-button" style="float:left;">' . $pluginButton . '</div>';
    }
    if (SSL_ENABLE_IN_CHECKOUT) {
        $uri = JURI::getInstance();
        $c_link = new JURI();
        $c_link->setScheme('https');
        $c_link->setHost($uri->getHost());
        $c_link->setPath(JRoute::_('index.php?option=com_redshop&view=checkout&Itemid=' . $Itemid));
        $link = $c_link->toString();
    } else {
        $link = JRoute::_('index.php?option=com_redshop&view=checkout&Itemid=' . $Itemid);
    }
    $checkout .= '<div class="checkout_button"  style="float:right;">';
    $checkout .= '<input type=button class="greenbutton" value="' . JText::_('COM_REDSHOP_CART_CHECKOUT') . '" ';
    if (MINIMUM_ORDER_TOTAL > 0 && $cart['total'] < MINIMUM_ORDER_TOTAL) {
        $checkout .= ' onclick="alert(\'' . JText::_('COM_REDSHOP_MINIMUM_ORDER_TOTAL_HAS_TO_BE_MORE_THAN') . ' ' . MINIMUM_ORDER_TOTAL . '\');">';
    } else {
        $checkout .= ' onclick="javascript:document.location=\'' . $link . '\'">';
    }
    $checkout .= '</div>';
}
Exemplo n.º 8
0
 /**
  * Set URL for get front-end content. Correct URL
  *
  * @param   string  $url  Link
  *
  * @return  void
  */
 public function setRenderUrl($url = '')
 {
     $uri = new JURI($url);
     if ($uri->getScheme() == '') {
         $scheme = 'http';
         if (@$_SERVER['HTTPS']) {
             $scheme = 'https';
         }
         $uri->setScheme($scheme);
     }
     @(list($host, $port) = explode(':', $_SERVER['HTTP_HOST']));
     if ($uri->getHost() == '') {
         $uri->setHost($host);
     }
     if ($uri->getPort() == '') {
         $uri->setPort($port);
     }
     if (JString::strtolower($uri->getHost()) != JString::strtolower($host)) {
         $this->_isExternal = true;
     } else {
         if (!$uri->hasVar('poweradmin')) {
             $uri->setVar('poweradmin', '1');
         }
         if ($uri->hasVar('Itemid') and $uri->getVar('Itemid') == '') {
             $uri->delVar('Itemid');
         }
         $this->_renderUrl = $uri->toString();
     }
 }