Esempio n. 1
0
	public function testSetPath() {
		$this->object->setPath('/this/is/a/path/to/a/file.htm');

		$this->assertThat(
			$this->object->getPath(),
			$this->equalTo('/this/is/a/path/to/a/file.htm')
		);
	}
Esempio n. 2
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();
 }
Esempio n. 3
0
 /**
  * Method to parse the router
  *
  * @param   JRouter  $router  JRouter instance
  * @param   JURI     $uri     Current JURI instance
  *
  * @return array
  */
 public function parseRoute($router, $uri)
 {
     $path = $uri->getPath();
     $segments = explode('/', $path);
     $alias = end($segments);
     if (preg_match('/^([0-9])\\-/', $alias) == false) {
         $alias = preg_replace('/\\-$/', '', $alias);
         $slug = $this->getSlugByAlias($alias);
         if (!empty($slug)) {
             $path = str_replace($alias, $slug, $path);
             $uri->setPath($path);
         }
     }
     return array();
 }
Esempio n. 4
0
 function parse(&$uri)
 {
     $mainframe =& JFactory::getApplication();
     // test for the backlink plugin to work correctly
     if (JPluginHelper::isEnabled('system', 'backlink')) {
         // && $uri->getQuery() ) {    // commented out - causing problems
         $joomlaRequest = urldecode($_SERVER['REQUEST_URI']);
         $realRequest = $uri->toString(array('path', 'query'));
         if ($realRequest != $joomlaRequest) {
             $uri = new JURI($joomlaRequest);
         }
     }
     // store the old URI before we change it in case we will need it
     // for default Joomla SEF
     $oldUri = new JURI($uri->toString());
     if (!SEFTools::JoomFishInstalled()) {
         $url_query = $uri->getQuery();
         $host = explode(".", $uri->getHost());
         $subdomain = array_shift($host);
         $db = JFactory::getDBO();
         // Subdomain titlepage
         if ($uri->getPath() == '/' && empty($url_query) && empty($_POST)) {
             $query = "SELECT Itemid_titlepage FROM #__sef_subdomains WHERE subdomain = " . $db->quote($subdomain) . " LIMIT 1";
             $db->setQuery($query);
             $Itemid = $db->loadResult();
             if ($Itemid > 0) {
                 $uri->setVar('Itemid', $Itemid);
                 JoomSEF::set('real_domain', JFactory::getUri()->getHost());
                 JFactory::getUri()->setHost(implode(".", $host));
             }
         } else {
             $query = "SELECT COUNT(*) FROM #__sef_subdomains WHERE subdomain = " . $db->quote($subdomain);
             $db->setQuery($query);
             $cnt = $db->loadResult();
             if ($cnt) {
                 JoomSEF::set('real_domain', JFactory::getUri()->getHost());
                 JFactory::getUri()->setHost(implode(".", $host));
             }
         }
     }
     $sefConfig =& SEFConfig::getConfig();
     // load patches
     JPluginHelper::importPlugin('sefpatch');
     // trigger onSefLoad patches
     $mainframe->triggerEvent('onSefLoad');
     // get path
     $path = $uri->getPath();
     // remove basepath
     $path = substr_replace($path, '', 0, strlen(JURI::base(true)));
     // remove slashes
     $path = ltrim($path, '/');
     // Redirect URL with / on the end to URL without / on the end
     if ($sefConfig->redirectSlash) {
         $request = $_SERVER["REQUEST_URI"];
         $noBase = substr_replace($request, '', 0, strlen(JURI::base(true)));
         if ($request != "/" && $noBase != "/" && substr($request, -1) == '/') {
             $mainframe->redirect(rtrim($request, "/"), '', 'message');
             JFactory::getApplication()->close();
         }
     }
     // Redirect the index.php (need to check this before index.php removal)
     if ($sefConfig->fixIndexPhp && $path == 'index.php' && count($_POST) == 0) {
         $q = $uri->getQuery(true);
         if (count($q) == 0) {
             $newUrl = JURI::root();
             if (substr($newUrl, -1) != '/') {
                 $newUrl .= '/';
             }
             $mainframe->redirect($newUrl, '', 'message', true);
             exit;
         }
     }
     // Try the 301 Alias redirect
     if (count($_POST) == 0) {
         JoomSEF::_parseAlias($path, $uri->getQuery(true));
     }
     // Disable non-SEF redirect for index2.php links
     // EDIT: don't even parse index2.php links!
     if (substr($path, 0, 10) == 'index2.php') {
         //$sefConfig->nonSefRedirect = false;
         return $uri->getQuery(true);
     }
     // Redirect old /index.php/ links if set to
     if ($sefConfig->fixIndexPhp && substr($path, 0, 10) == 'index.php/' && count($_POST) == 0) {
         $newUrl = JURI::root();
         if (substr($newUrl, -1) != '/') {
             $newUrl .= '/';
         }
         $newUrl .= substr($path, 10);
         $mainframe->redirect($newUrl, '', 'message', true);
         exit;
     }
     // remove prefix (both index.php and index2.php)
     $path = preg_replace('/^index2?.php/i', '', $path);
     // remove slashes again to be sure there aren't any left
     $path = ltrim($path, '/');
     // replace spaces with our replacement character
     // (mainly for '+' handling, but may be useful in some other situations too)
     $path = str_replace(' ', $sefConfig->replacement, $path);
     // set the route
     $uri->setPath($path);
     // host name handling
     if (SEFTools::JoomFishInstalled() && $sefConfig->langPlacement == _COM_SEF_LANG_DOMAIN && !JPluginHelper::isEnabled('system', 'jfrouter')) {
         // different domains for languages handling
         $host = $uri->toString(array('host'));
         $host = trim($host, '/');
         $code = null;
         foreach ($sefConfig->jfSubDomains as $langCode => $domain) {
             if ($host == $domain) {
                 // if main language is not selected, use the first corresponding domain
                 if ($sefConfig->mainLanguage == '0') {
                     $code = $langCode;
                     break;
                 } else {
                     if ($langCode == $sefConfig->mainLanguage) {
                         $code = $langCode;
                         break;
                     } else {
                         if (is_null($code)) {
                             $code = $langCode;
                         }
                     }
                 }
             }
         }
         // we found a matching domain
         if (!is_null($code)) {
             JRequest::setVar('lang', $code);
             $config =& JFactory::getConfig();
             $config->set('joomsef.domain_lang', $code);
         }
     }
     // parse the url
     $vars = JoomSEF::_parseSefUrl($uri, $oldUri);
     // handle custom site name for extensions
     if (isset($vars['option'])) {
         $params =& SEFTools::getExtParams($vars['option']);
         $useSitename = $params->get('useSitename', '1');
         $customSitename = trim($params->get('customSitename', ''));
         $config =& JFactory::getConfig();
         if ($useSitename == '0') {
             // don't use site name
             $config->setValue('sitename', '');
         } elseif (!empty($customSitename)) {
             // use custom site name
             $config->setValue('sitename', $customSitename);
         }
     }
     // trigger onSefUnload patches
     $mainframe->triggerEvent('onSefUnload');
     return $vars;
 }
 function isImage($link)
 {
     $uri = new JURI($link);
     $path = $uri->getPath();
     return preg_match('/\\.(jpg|jpeg|png|bmp|gif)$/i', $path) > 0;
 }
Esempio n. 6
0
 /**
  * Method to get the OAuth message string for signing.
  *
  * Note: As of PHP 5.3 the $this->encode() function is RFC 3986 compliant therefore this requires PHP 5.3+
  *
  * @param   string  $requestUrl     The message's request URL.
  * @param   string  $requestMethod  The message's request method.
  *
  * @return  string  The unsigned OAuth message string.
  *
  * @link    http://www.faqs.org/rfcs/rfc3986
  * @see     $this->encode()
  * @since   1.0
  */
 public function _fetchStringForSigning($requestUrl, $requestMethod)
 {
     // Get a JURI instance for the request URL.
     $uri = new JURI($requestUrl);
     // Initialise base array.
     $base = array();
     // Get the found parameters.
     $params = $this->getParameters();
     // Add the variables from the URI query string.
     foreach ($uri->getQuery(true) as $k => $v) {
         if (strpos($k, 'oauth_') !== 0) {
             $params[$k] = $v;
         }
     }
     // Make sure that any found oauth_signature is not included.
     unset($params['oauth_signature']);
     // Ensure the parameters are in order by key.
     ksort($params);
     // Iterate over the keys to add properties to the base.
     foreach ($params as $key => $value) {
         // If we have multiples for the parameter let's loop over them.
         if (is_array($value)) {
             // Don't want to do this more than once in the inner loop.
             $key = $this->encode($key);
             // Sort the value array and add each one.
             sort($value, SORT_STRING);
             foreach ($value as $v) {
                 $base[] = $key . '=' . $this->encode($v);
             }
         } else {
             $base[] = $this->encode($key) . '=' . $this->encode($value);
         }
     }
     // Start off building the base string by adding the request method and URI.
     $base = array($this->encode(strtoupper($requestMethod)), $this->encode(strtolower($uri->toString(array('scheme', 'user', 'pass', 'host', 'port'))) . $uri->getPath()), $this->encode(implode('&', $base)));
     return implode('&', $base);
 }
Esempio n. 7
0
 protected function _do404(&$uri)
 {
     if (self::$requestParsed) {
         return array();
     }
     // get config objects
     $pageInfo =& Sh404sefFactory::getPageInfo();
     $sefConfig = Sh404sefFactory::getConfig();
     // store the status
     $pageInfo->httpStatus = 404;
     // request path
     $reqPath = $uri->getPath();
     // optionnally log the 404 details
     if ($sefConfig->shLog404Errors && !empty($reqPath)) {
         try {
             $record = Sh404sefHelperDb::selectObject('#__sh404sef_urls', '*', array('oldurl' => $reqPath));
             if (!empty($record)) {
                 // we have, so update counter
                 Sh404sefHelperDb::queryQuote('update ?? set cpt=(cpt+1) where ?? = ?', array('#__sh404sef_urls', 'oldurl'), array($reqPath));
             } else {
                 // record the 404
                 Sh404sefHelperDb::insert('#__sh404sef_urls', array('cpt' => 1, 'rank' => 0, 'oldurl' => $reqPath, 'newurl' => '', 'dateadd' => Sh404sefHelperDate::getUTCNow('Y-m-d')));
             }
             // add more details about 404 into security log file
             if ($sefConfig->shSecEnableSecurity && $sefConfig->shSecLogAttacks) {
                 $sep = "\t";
                 $logData = date('Y-m-d') . $sep . date('H:i:s') . $sep . 'Page not found (404)' . $sep . $_SERVER['REMOTE_ADDR'] . $sep;
                 $logData .= getHostByAddr($_SERVER['REMOTE_ADDR']) . $sep;
                 $userAgent = empty($_SERVER['HTTP_USER_AGENT']) ? 'No user agent' : $_SERVER['HTTP_USER_AGENT'];
                 $logData .= $userAgent . $sep . $_SERVER['REQUEST_METHOD'] . $sep . $_SERVER['REQUEST_URI'];
                 $logData .= empty($_SERVER['HTTP_REFERER']) ? "\n" : $sep . $_SERVER['HTTP_REFERER'] . "\n";
                 shLogToSecFile($logData);
             }
         } catch (Sh404sefExceptionDefault $e) {
             _log(__METHOD__ . '/' . __LINE__ . '/' . __CLASS__ . ': Database error: ' . $e->getMessage());
         }
     }
     // display the error page
     $vars['option'] = 'com_content';
     $vars['view'] = 'article';
     // use provided Itemid
     if (empty($sefConfig->shPageNotFoundItemid)) {
         $shHomePage = JFactory::getApplication()->getMenu()->getDefault();
         $vars['Itemid'] = empty($shHomePage) ? null : $shHomePage->id;
     } else {
         $vars['Itemid'] = $sefConfig->shPageNotFoundItemid;
     }
     // user picked our default 404 error page, read its id from DB
     if ($sefConfig->page404 == '0') {
         try {
             $requestedlanguageTag = JFactory::getLanguage()->getTag();
             $languageTag = JRequest::getString(JUtility::getHash('language'), null, 'cookie');
             if (!empty($languageTag)) {
                 $vars['lang'] = $languageTag;
             }
             $ids = Sh404sefHelperDb::queryQuoteOnly('select ?? from ?? where ?? = ? and ?? in ( ?, ?) order by ?? desc', array('id', '#__content', 'title', 'language', 'language'), array('__404__', $languageTag, '*'))->eLoadResultArray();
             $id = empty($ids[0]) ? null : $ids[0];
         } catch (Sh404sefExceptionDefault $e) {
             _log(__METHOD__ . '/' . __LINE__ . '/' . __CLASS__ . ': Database error: ' . $e->getMessage());
         }
         if (empty($id)) {
             JError::raiseError(404, JText::_('Component Not Found') . ' (' . $pageInfo->getDefaultLiveSite() . '/' . $uri->getPath() . ')');
         }
     } else {
         $id = $sefConfig->page404;
     }
     $vars['id'] = $id;
     $uri = new JURI($pageInfo->getDefaultLiveSite() . '/index.php?' . 'option=com_content&view=article&id=' . $id . (empty($vars['Itemid']) ? '' : '&Itemid=' . $vars['Itemid']) . (empty($vars['lang']) ? '' : '&lang=' . shGetIsoCodeFromName($vars['lang'])));
     $tmpl = str_replace('.php', '', $sefConfig->error404SubTemplate);
     if (!empty($tmpl)) {
         $vars['tmpl'] = $tmpl;
     }
     // and prepare the item for display
     $menus =& JFactory::getApplication()->getMenu();
     $menuItem = $menus->getItem($vars['Itemid']);
     if (!empty($menuItem)) {
         $menus->setActive($vars['Itemid']);
     } else {
         $menuItem = $menus->getDefault();
     }
     if (!empty($menuItem->params)) {
         $disableParams = array('show_title', 'show_category', 'show_author', 'show_create_date', 'show_modify_date', 'show_publish_date', 'show_vote', 'show_readmore', 'show_icons', 'show_hits', 'show_feed_link', 'show_page_heading');
         foreach ($disableParams as $p) {
             $menuItem->params->set($p, 0);
         }
         //set a custom page title
         $menuItem->params->set('page_title', htmlspecialchars($uri->get('_uri')));
     }
     // set the menu query array, J! will use that for breadcrumb
     $menuItem->query = $vars;
     // throw 404 http return code, and prepare for page display
     if (!headers_sent()) {
         JResponse::setHeader('status', '404 NOT FOUND');
         // custom error page, faster than loading Joomla 404 page. Not recommended though, why not show
         // your site ?
         if (is_readable(sh404SEF_FRONT_ABS_PATH . '404-Not-Found.tpl.html')) {
             $errorPage = file_get_contents(sh404SEF_FRONT_ABS_PATH . '404-Not-Found.tpl.html');
             if ($errorPage !== false) {
                 $errorPage = str_replace('%sh404SEF_404_URL%', ' (' . $pageInfo->getDefaultLiveSite() . '/' . $uri->getPath() . ')', $errorPage);
                 $errorPage = str_replace('%sh404SEF_404_SITE_URL%', $pageInfo->getDefaultLiveSite(), $errorPage);
                 $errorPage = str_replace('%sh404SEF_404_SITE_NAME%', JFactory::getApplication()->getCfg('sitename'), $errorPage);
                 echo $errorPage;
                 die;
             }
         }
     } else {
         _log('Headers already sent before getting control on 404 page - message displayed');
         $shUri = new JUri();
         $shOriginalUri = new JURI();
         $url = shSefRelToAbs($pageInfo->getDefaultLiveSite() . "/index.php?" . $_SERVER['QUERY_STRING'], '', $shUri, $shOriginalUri);
         JError::RaiseError(500, "<br />SH404SEF : headers were already sent when I got control!<br />This is not necessarily a sh404sef error. It may have been caused by any of your extensions or even Joomla itself. If there is no error message above this one, providing more details, then you may look inside the error log file of your web server for an indication of what may be breaking things up.<br />URL=" . $url . '<br />');
     }
     return $vars;
 }
Esempio n. 8
0
 /**
  * setHost
  *
  * @param $host
  *
  * @return void
  */
 public function setHost($host)
 {
     $uri = new JURI($host);
     $this->host = $host = $uri->getHost() . $uri->getPath();
     $this->uri->setHost($host);
 }
Esempio n. 9
0
 /**
  * Function to build a sef route
  *
  * @param   JURI  $uri  The uri
  *
  * @return  void
  */
 protected function _buildSefRoute($uri)
 {
     // Get the route
     $route = $uri->getPath();
     // Get the query data
     $query = $uri->getQuery(true);
     if (!isset($query['option'])) {
         return;
     }
     $app = JApplication::getInstance('site');
     $menu = $app->getMenu();
     /*
      * Build the component route
      */
     $component = preg_replace('/[^A-Z0-9_\\.-]/i', '', $query['option']);
     $tmp = '';
     // Use the component routing handler if it exists
     $path = JPATH_SITE . '/components/' . $component . '/router.php';
     // Use the custom routing handler if it exists
     if (file_exists($path) && !empty($query)) {
         require_once $path;
         $function = substr($component, 4) . 'BuildRoute';
         $function = str_replace(array("-", "."), "", $function);
         $parts = $function($query);
         // Encode the route segments
         if ($component != 'com_search') {
             // Cheep fix on searches
             $parts = $this->_encodeSegments($parts);
         } else {
             // Fix up search for URL
             $total = count($parts);
             for ($i = 0; $i < $total; $i++) {
                 // Urlencode twice because it is decoded once after redirect
                 $parts[$i] = urlencode(urlencode(stripcslashes($parts[$i])));
             }
         }
         $result = implode('/', $parts);
         $tmp = $result != "" ? $result : '';
     }
     /*
      * Build the application route
      */
     $built = false;
     if (isset($query['Itemid']) && !empty($query['Itemid'])) {
         $item = $menu->getItem($query['Itemid']);
         if (is_object($item) && $query['option'] == $item->component) {
             if (!$item->home || $item->language != '*') {
                 $tmp = !empty($tmp) ? $item->route . '/' . $tmp : $item->route;
             }
             $built = true;
         }
     }
     if (!$built) {
         $tmp = 'component/' . substr($query['option'], 4) . '/' . $tmp;
     }
     if ($tmp) {
         $route .= '/' . $tmp;
     } elseif ($route == 'index.php') {
         $route = '';
     }
     // Unset unneeded query information
     if (isset($item) && $query['option'] == $item->component) {
         unset($query['Itemid']);
     }
     unset($query['option']);
     // Set query again in the URI
     $uri->setQuery($query);
     $uri->setPath($route);
 }
Esempio n. 10
0
 /**
  * Replaces the matched tags
  *
  * @param array An array of matches (see preg_match_all)
  * @return string
  */
 function route(&$matches)
 {
     $url = str_replace('&amp;', '&', $matches[3]);
     $uri = new JURI(JURI::base(true) . '/' . $url);
     //Remove basepath
     $path = substr_replace($uri->getPath(), '', 0, strlen(JURI::base(true)));
     //Remove prefix
     $path = trim(str_replace('index.php', '', $path), '/');
     if (empty($path)) {
         $route = JRoute::_($url);
         $result = $matches[1] . $matches[2] . $route;
     } else {
         $result = $matches[0];
     }
     return $result;
 }
Esempio n. 11
0
 static function append_sid($hook, $url, $params = false, $is_amp = true, $session_id = false)
 {
     global $_SID, $_EXTRA_URL;
     $arrParams = array();
     $arrExtra = array();
     $anchor = '';
     JForumHook::fixPage();
     $config =& JFactory::getConfig();
     if ($url == '.php') {
         $url = '/' . $config->getValue('config.phpbb_path') . '/index.php';
     }
     // Assign sid if session id is not specified
     if ($session_id === false) {
         $session_id = $_SID;
     }
     //Clean the url and the params first
     if ($is_amp) {
         $url = str_replace('&amp;', '&', $url);
         if (!is_array($params)) {
             $params = str_replace('&amp;', '&', $params);
         }
     }
     $amp_delim = $is_amp ? '&amp;' : '&';
     $url_delim = strpos($url, '?') === false ? '?' : $amp_delim;
     // Process the parameters array
     if (is_array($params)) {
         foreach ($params as $key => $item) {
             if ($item === NULL) {
                 continue;
             }
             if ($key == '#') {
                 $anchor = '#' . $item;
                 continue;
             }
             $arrParams[$key] = $item;
         }
     } else {
         if (strpos($params, '#') !== false) {
             list($params, $anchor) = explode('#', $params, 2);
             $anchor = '#' . $anchor;
         }
         parse_str($params, $arrParams);
     }
     //Process the extra array
     if (!empty($_EXTRA_URL)) {
         $extra = implode('&', $_EXTRA_URL);
         parse_str($extra, $arrExtra);
     }
     //Create the URL
     $uri = new JURI($url);
     $query = $uri->getQuery(true);
     $query = $query + $arrParams + $arrExtra;
     $uri->setQuery($query);
     //Set session id variable
     if ($session_id) {
         $uri->setVar('sid', $session_id);
     }
     //Set fragment
     if ($anchor) {
         $uri->setFragment($anchor);
     }
     $view = basename($uri->getPath(), '.php');
     if (!$uri->getVar('rb_v') && $view != "style") {
         if (JRequest::getVar('rb_v') == 'adm') {
             if (strpos($url, $config->getValue('config.phpbb_path')) === false) {
                 $view = 'adm';
             }
         }
         if (stripos($url, $config->getValue('config.phpbb_path') . '/adm') !== false) {
             $view = 'adm';
         }
         if ($view != 'index') {
             $uri->setVar('rb_v', $view);
         }
     }
     if ($view != 'style') {
         $url = 'index.php' . $uri->toString(array('query', 'fragment'));
         // {} getting lost in encoding
         $url = str_replace(array('%7B', '%7D'), array('{', '}'), $url);
         return urldecode(JURI::base() . JRoute::_($url, $is_amp));
     } else {
         $url = 'style.php' . $uri->toString(array('query', 'fragment'));
         $url = str_replace(array('%7B', '%7D'), array('{', '}'), $url);
         return urldecode(JPATH_ROOT . '/' . $config->getValue('config.phpbb_path') . '/' . $url);
     }
 }
Esempio n. 12
0
 function parse(&$siteRouter, &$uri)
 {
     if ($this->parsing) {
         return array();
     }
     $this->parsing = true;
     $uri->setPath(JURI::base(true) . '/' . $uri->getPath());
     $mainframe = JFactory::getApplication();
     $router = $mainframe->get('mijosef.global.jrouter');
     $router->setMode(JROUTER_MODE_DONT_PARSE);
     // Fix the missing question mark
     if (count($_POST) == 0) {
         $url = $uri->toString();
         $new_url = preg_replace('/^([^?&]*)&([^?]+=[^?]*)$/', '$1?$2', $url);
         // Redirect if question mark fixed
         if ($new_url != $url) {
             $mainframe->redirect($new_url, '', 'message', true);
         }
     }
     // Check if URI is string
     if (is_string($uri)) {
         $uri = JURI::getInstance($uri);
     }
     // Backlink plugin compatibility
     if (JPluginHelper::isEnabled('system', 'backlink')) {
         $joomla_request = $_SERVER['REQUEST_URI'];
         $real_request = $uri->toString(array('path', 'query'));
         if ($real_request != $joomla_request) {
             $uri = new JURI($joomla_request);
         }
     }
     // We'll use it for Joomla! SEF to MijoSEF redirection
     $old_uri = clone $uri;
     // get path
     $path = $uri->getPath();
     // remove basepath
     $path = substr_replace($path, '', 0, strlen(JURI::base(true)));
     // remove slashes
     $path = ltrim($path, '/');
     // Check if the URL starts with index2.php
     if (substr($path, 0, 10) == 'index2.php') {
         return $uri->getQuery(true);
     }
     // remove prefix (both index.php and index2.php)
     $path = preg_replace('/^index2?.php/i', '', $path);
     // remove slashes again to be sure there aren't any left
     $path = ltrim($path, '/');
     // replace spaces with our replacement character
     $path = str_replace(' ', $this->MijosefConfig->replacement_character, $path);
     // set the route
     $uri->setPath($path);
     $vars = Mijosef::get('uri')->parseURI($uri, $old_uri);
     // Parsing done
     $this->parsing = false;
     // Fix the start variable
     if ($start = $uri->getVar('start')) {
         $uri->delVar('start');
         $vars['limitstart'] = $start;
     }
     $menu = Mijosef::get('utility')->getMenu();
     // Handle an empty URL (special case)
     if (empty($vars['Itemid']) && empty($vars['option'])) {
         $item = Mijosef::get('uri')->getDefaultMenuItem();
         if (!is_object($item)) {
             return $vars;
         }
         // set the information in the request
         $vars = $item->query;
         // get the itemid
         $vars['Itemid'] = $item->id;
         // set the active menu item
         $menu->setActive($vars['Itemid']);
         // set vars
         $this->setRequestVars($vars);
         return $vars;
     }
     // Get the item id, if it hasn't been set force it to null
     if (empty($vars['Itemid'])) {
         $vars['Itemid'] = JRequest::getInt('Itemid', null);
     }
     // Get the variables from the uri
     $this->setVars($vars);
     // No option? Get the full information from the itemid
     if (empty($vars['option'])) {
         $item = $menu->getItem($this->getVar('Itemid'));
         if (!is_object($item)) {
             return $vars;
         }
         // No default item set
         $vars = $vars + $item->query;
     }
     // Set the active menu item
     $menu->setActive($this->getVar('Itemid'));
     Mijosef::get('language')->parseLang($vars);
     // Set vars
     $this->setRequestVars($vars);
     return $vars;
 }
Esempio n. 13
0
 /**
  * Replace Joomla! M_images standard Icons from main images folder to design image folder
  * @param body HTML body content
  * @return replaced image path for M_images
  **/
 function replaceM_images($body)
 {
     // find M_images (joomla default icons) in input and img elements
     preg_match_all('/(<img|<input).*?src="(.+?)"(.*?)>/is', $body, $matches);
     /* with input preg_match_all('/<img|<input.*?src="(.+?)"(.*?)>/is', $body, $matches); */
     // reduce dublicates
     $images = array_unique($matches[2]);
     $old_img_path = 'images/M_images/';
     $new_img_path = JYAML_PATH_REL . '/images/' . $this->config->design . '/M_images/';
     foreach ($images as $image) {
         if (strpos($image, $old_img_path) === false) {
             continue;
         }
         // Get Path withourt URL if in path
         $uri = new JURI($image);
         $image = $uri->getPath();
         // absolute path to check if file exists
         if (strpos($image, JURI::base(true) . '/' . $old_img_path) !== false) {
             $check_file = $new_img_path . str_replace(JURI::base(true) . '/' . $old_img_path, '', $image);
         } else {
             $check_file = $new_img_path . str_replace($old_img_path, '', $image);
         }
         $check_file = JPATH_SITE . DS . str_replace('/', DS, $check_file);
         // check image replacement exists in design/image/M_images/ folder
         if (JFile::exists($check_file)) {
             $this->_logs[] = 'M_Image Replaced: ' . $old_img_path . basename($image) . " \n\t\t\t\t\\ - To: " . $new_img_path . basename($image);
             $body = str_replace($old_img_path . basename($image), $new_img_path . basename($image), $body);
         }
     }
     return $body;
 }
Esempio n. 14
0
 function _finalizeURI($uri, $route)
 {
     // Prepare non-SEF part
     if ($this->attributes->non_sef_part != '' && strstr($route, '?')) {
         $this->attributes->non_sef_part = str_replace('?', '&amp;', $this->attributes->non_sef_part);
     }
     // Get domain
     $url = self::getDomain();
     // Add non-SEF vars
     if ($this->MijosefConfig->append_non_sef == 1) {
         $url .= $route . $this->attributes->non_sef_part;
     } else {
         $url .= $route;
     }
     // Add fragment
     $fragment = $uri->getFragment();
     if (!empty($fragment)) {
         $url .= '#' . $fragment;
     }
     // Finally return new URI
     $uri = new JURI($url);
     $uri->setPath(JString::substr($uri->getPath(), JString::strlen(JURI::base(true))));
     return $uri;
 }
Esempio n. 15
0
 /**
  * TuiyoTableResources::createAvatarThumb()
  * Creates and saves a thumb for the avatar image.
  * @param mixed $width
  * @return
  */
 private function createAvatarThumb($width)
 {
     $filePath = TUIYO_FILES . DS . "avatars" . DS . $this->userID . DS;
     $userAvatar = array();
     $imageMani = TuiyoAPI::get("imagemanipulation");
     $thumbX = clone $this;
     $thumbXDir = $filePath . "thumb" . $width . DS;
     $thumbXtarget = $thumbXDir . $this->fileName;
     $thumbSource = $this->filePath . $this->fileName;
     if (!JFolder::exists($thumbXDir)) {
         JFolder::create($thumbXDir);
         JPath::setPermissions($thumbXDir);
     }
     if ($imageMani->resizeImage($thumbSource, $thumbXtarget, $width, $width, true)) {
         $thumbX->resourceID = null;
         $thumbX->filePath = JPath::clean($thumbXDir);
         $thumbX->url = JURI::getPath(true) . str_replace(array(JPATH_ROOT, DS), array("", "/"), $thumbXtarget);
         $thumbX->fileTitle = $thumbX->fileTitle . "_" . $width . "x" . $width;
         //3. Save the Object in the Database
         if (!$thumbX->store()) {
             //echo $thumbX->getError(); die;
             trigger_error($thumbX->getError(), E_USER_ERROR);
             return false;
         }
     }
     $URL = $thumbX->url;
     $thumbX = null;
     return $URL;
 }