/** * Save a list of aliases as entered by user in backend to the database * * @param string $aliasList data from an html textarea field * @param string $nonSefUrl the non sef url to which aliases are attached * * @return boolean true on success */ public function saveFromInput($aliasList, $nonSefUrl) { // split aliases from raw input data into an array $aliasList = explode("\n", $aliasList); // delete them all. We should do a transaction, but not worth it $query = 'DELETE from #__sh404sef_aliases where newurl = ' . $this->_db->Quote($nonSefUrl); $this->_db->setQuery($query); $this->_db->query(); // Write new aliases. We use a raw db query instead of table // so as to write them all in one pass. Could be done by the table if (!empty($aliasList[0])) { $query = 'INSERT INTO #__sh404sef_aliases (newurl, alias, type) VALUES __shValues__;'; $values = ''; $endOfLine = array("\r\n", "\n", "\r"); foreach ($aliasList as $alias) { $alias = str_replace($endOfLine, '', $alias); if (!empty($alias)) { $values .= '(' . $this->_db->Quote($nonSefUrl) . ', ' . $this->_db->Quote(htmlspecialchars_decode($alias)) . ', ' . $this->_db->Quote(Sh404sefHelperGeneral::COM_SH404SEF_URLTYPE_ALIAS) . '),'; } } $query = str_replace('__shValues__', JString::rtrim($values, ','), $query); $this->_db->setQuery($query); $this->_db->query(); // check errors $error = $this->_db->getErrorNum(); if (!empty($error)) { $this->setError('Internal database error # ' . $error); } } // return true if no error $error = $this->getError(); return empty($error); }
function vm_sef_get_category_title(&$db, &$catDesc, $category_id, $option, $shLangName) { global $shMosConfig_locale; $sefConfig =& shRouter::shGetConfig(); if (empty($category_id)) { return ''; } $q = "SELECT c.category_name, c.category_id, c.category_description, x.category_parent_id FROM #__vm_category AS c"; $q .= "\n LEFT JOIN #__vm_category_xref AS x ON c.category_id = x.category_child_id;"; $db->setQuery($q); if (!shTranslateUrl($option, $shLangName)) { // V 1.2.4.m $tree = $db->loadObjectList('category_id', false); } else { $tree = $db->loadObjectList('category_id'); } $catDesc = $tree[$category_id]->category_description; $title = ''; $securityCounter = 0; do { // all categories and subcategories $securityCounter++; $title .= ($sefConfig->shInsertCategoryId ? $tree[$category_id]->category_id . $sefConfig->replacement : '') . $tree[$category_id]->category_name . ' | '; $category_id = $tree[$category_id]->category_parent_id; } while ($category_id != 0 && $securityCounter < 10); if ($securityCounter >= 10) { JError::raiseError(500, 'Unable to create SEF url for Virtuemart: could not find category with id : ' . $category_id); } return JString::rtrim($title, ' | '); }
/** * Internally render the plugin, and add required script declarations * to the document * * @return void */ public function render() { $params = $this->getParams(); $document = JFactory::getDocument(); $document->addScript("http://api.simile-widgets.org/runway/1.0/runway-api.js"); $c = 0; $images = (array) $params->get('coverflow_image'); $titles = (array) $params->get('coverflow_title'); $subtitles = (array) $params->get('coverflow_subtitle'); $listIds = (array) $params->get('coverflow_table'); $eventData = array(); foreach ($listIds as $listId) { $listModel = JModelLegacy::getInstance('List', 'FabrikFEModel'); $listModel->setId($listId); $list = $listModel->getTable(); $listModel->getPagination(0, 0, 0); $image = $images[$c]; $title = $titles[$c]; $subtitle = $subtitles[$c]; $data = $listModel->getData(); if ($listModel->canView() || $listModel->canEdit()) { $elements = $listModel->getElements(); $imageElement = FArrayHelper::getValue($elements, FabrikString::safeColName($image)); foreach ($data as $group) { if (is_array($group)) { foreach ($group as $row) { $event = new stdClass(); if (!method_exists($imageElement, 'getStorage')) { switch (get_class($imageElement)) { case 'FabrikModelFabrikImage': $rootFolder = $imageElement->getParams()->get('selectImage_root_folder'); $rootFolder = JString::ltrim($rootFolder, '/'); $rootFolder = JString::rtrim($rootFolder, '/'); $event->image = COM_FABRIK_LIVESITE . 'images/stories/' . $rootFolder . '/' . $row->{$image . '_raw'}; break; default: $event->image = isset($row->{$image . '_raw'}) ? $row->{$image . '_raw'} : ''; break; } } else { $event->image = $imageElement->getStorage()->pathToURL($row->{$image . '_raw'}); } $event->title = $title === '' ? '' : (string) strip_tags($row->{$title}); $event->subtitle = $subtitle === '' ? '' : (string) strip_tags($row->{$subtitle}); $eventData[] = $event; } } } } $c++; } $json = json_encode($eventData); $str = "var coverflow = new FbVisCoverflow({$json});"; $srcs = FabrikHelperHTML::framework(); $srcs['Coverflow'] = $this->srcBase . 'coverflow/coverflow.js'; FabrikHelperHTML::script($srcs, $str); }
public function init() { static $_initialized = false; if (!$_initialized) { $this->originalUri = $this->getURI(); $uri = JURI::getInstance(); $this->currentSefUrl = $uri->toString(); $site = $uri->toString(array('scheme', 'host', 'port')); $this->basePath = JString::rtrim(str_replace($site, '', $uri->base()), '/'); $this->loadHomepages(); } }
function su_char_limit($str, $limit = 150, $end_char = '...') { if (JString::trim($str) == '') { return $str; } // always strip tags for text $str = strip_tags(JString::trim($str)); $find = array("/\r|\n/u", "/\t/u", "/\\s\\s+/u"); $replace = array(" ", " ", " "); $str = preg_replace($find, $replace, $str); if (JString::strlen($str) > $limit) { $str = JString::substr($str, 0, $limit); return JString::rtrim($str) . $end_char; } else { return $str; } }
public static function getPath($type = 'site') { jimport('joomla.filesystem.file'); $application = JFactory::getApplication(); if ($type == 'k2') { $path = JPATH_SITE . '/media/k2/galleries'; } else { if ($type == 'site') { $user = JFactory::getUser(); if (version_compare(JVERSION, '2.5', 'ge')) { $isAdmin = $user->authorise('core.admin', 'com_sigpro'); } else { $isAdmin = $user->gid == 25; } if ($application->isAdmin() || $isAdmin) { if (version_compare(JVERSION, '1.6.0', 'ge')) { $defaultImagePath = 'images'; } else { $defaultImagePath = 'images/stories'; } $params = JComponentHelper::getParams('com_sigpro'); $path = JPATH_SITE . '/' . $params->get('galleries_rootfolder', $defaultImagePath); } else { $folder = self::getUserFolder(); $path = JPATH_SITE . '/media/jw_sigpro/users/' . $folder; if (!JFolder::exists($path)) { JFolder::create($path); } } } else { if ($type == 'users') { $path = JPATH_SITE . '/media/jw_sigpro/users'; } } } $path = JPath::clean($path); JPath::check($path); if (JString::substr($path, -1, 1) == DIRECTORY_SEPARATOR) { $path = JString::rtrim($path, DIRECTORY_SEPARATOR); } return $path; }
/** * Draws the html form element * * @param array $data to pre-populate element with * @param int $repeatCounter repeat group counter * * @return string elements html */ public function render($data, $repeatCounter = 0) { $params = $this->getParams(); $name = $this->getHTMLName($repeatCounter); $value = $this->getValue($data, $repeatCounter); $id = $this->getHTMLId($repeatCounter); $rootFolder = $this->rootFolder($value); if ($rootFolder != '/') { $value = str_replace($rootFolder, '', $value); } // $$$ rob - 30/06/2011 can only select an image if its not a remote image $canSelect = $params->get('image_front_end_select', '0') && JString::substr($value, 0, 4) !== 'http'; // $$$ hugh - tidy up a bit so we don't have so many ///'s in the URL's $rootFolder = JString::ltrim($rootFolder, '/'); $rootFolder = JString::rtrim($rootFolder, '/'); $rootFolder = $rootFolder === '' ? '' : $rootFolder . '/'; // $$$ rob - 30/062011 allow for full urls in the image. (e.g from csv import) $defaultImage = JString::substr($value, 0, 4) == 'http' ? $value : COM_FABRIK_LIVESITE . $rootFolder . $value; $float = $params->get('image_float'); $float = $float != '' ? "style='float:{$float};'" : ''; $str = array(); $str[] = '<div class="fabrikSubElementContainer" id="' . $id . '">'; $rootFolder = str_replace('/', DS, $rootFolder); if ($canSelect && $this->isEditable()) { $str[] = '<img src="' . $defaultImage . '" alt="' . $value . '" ' . $float . ' class="imagedisplayor"/>'; if (array_key_exists($name, $data)) { if (trim($value) == '' && $rootFolder === '') { $path = "/"; } else { $bits = explode("/", $value); if (count($bits) > 1) { $path = '/' . array_shift($bits) . '/'; $path = $rootFolder . $path; $val = array_shift($bits); } else { $path = $rootFolder; } } } else { $path = $rootFolder; } $images = array(); $imagenames = (array) JFolder::files(JPATH_SITE . '/' . $path); foreach ($imagenames as $n) { $images[] = JHTML::_('select.option', $n, $n); } // $$$rob not sure about his name since we are adding $repeatCounter to getHTMLName(); $imageName = $this->getGroupModel()->canRepeat() ? FabrikString::rtrimWord($name, "][{$repeatCounter}]") . "_image][{$repeatCounter}]" : $id . '_image'; $bits = explode('/', $value); $image = array_pop($bits); // $$$ hugh - append $rootFolder to JPATH_SITE, otherwise we're showing folders // they aren't supposed to be able to see. $folders = JFolder::folders(JPATH_SITE . DS . $rootFolder); // @TODO - if $folders is empty, hide the button/widget? All they can do is select // from the initial image dropdown list, so no point having the widget for changing folder? $str[] = '<br/>' . JHTML::_('select.genericlist', $images, $imageName, 'class="inputbox imageselector" ', 'value', 'text', $image); $str[] = FabrikHelperHTML::folderAjaxSelect($folders); $str[] = '<input type="hidden" name="' . $name . '" value="' . $value . '" class="fabrikinput hiddenimagepath folderpath" />'; } else { $w = new FabrikWorker(); $value = $w->parseMessageForPlaceHolder($value, $data); $linkURL = $params->get('link_url', ''); $imgstr = '<img src="' . $defaultImage . '" alt="' . $value . '" ' . $float . ' class="imagedisplayor"/>' . "\n"; if ($linkURL) { $imgstr = '<a href="' . $linkURL . '" target="_blank">' . $imgstr . '</a>'; } $str[] = $imgstr; $str[] = '<input type="hidden" name="' . $name . '" value="' . $value . '" class="fabrikinput hiddenimagepath folderpath" />'; } $str[] = '</div>'; return implode("\n", $str); }
/** * Insert appropriate script links into document */ public function onSh404sefInsertSocialButtons(&$page, $sefConfig) { $app = JFactory::getApplication(); // are we in the backend - that would be a mistake if (!defined('SH404SEF_IS_RUNNING') || $app->isAdmin()) { return; } // don't display on errors $pageInfo = Sh404sefFactory::getPageInfo(); if (!empty($pageInfo->httpStatus) && $pageInfo->httpStatus == 404) { return; } // regexp to catch plugin requests $regExp = '#{sh404sef_social_buttons(.*)}#Us'; // search for our marker} if (preg_match_all($regExp, $page, $matches, PREG_SET_ORDER) > 0) { // process matches foreach ($matches as $id => $match) { $url = ''; $imageSrc = ''; $imageDesc = ''; // extract target URL if (!empty($match[1])) { //normally, there is no quotes around attributes // but a description will probably have spaces, so we // now try to get attributes from both syntax jimport('joomla.utilities.utility'); $attributes = JUtility::parseAttributes($match[1]); $url = empty($attributes['url']) ? '' : $attributes['url']; $imageSrc = empty($attributes['img']) ? '' : $attributes['img']; $imageDesc = empty($attributes['desc']) ? '' : $attributes['desc']; $type = empty($attributes['type']) ? '' : $attributes['type']; // now process usual tags $raw = explode(' ', $match[1]); $attributes = array(); $enabledButtons = array(); foreach ($raw as $attribute) { $attribute = JString::trim($attribute); if (strpos($attribute, '=') === false) { continue; } $bits = explode('=', $attribute); if (empty($bits[1])) { continue; } switch ($bits[0]) { case 'url': if (empty($url)) { $base = JURI::base(true); if (substr($bits[1], 0, 10) == 'index.php?') { $url = JURI::getInstance()->toString(array('scheme', 'host', 'port')) . JRoute::_($bits[1]); } else { if (substr($bits[1], 0, JString::strlen($base)) == $base) { $url = JURI::getInstance()->toString(array('scheme', 'host', 'port')) . $bits[1]; } else { if (substr($bits[1], 0, 1) == '/') { $url = JString::rtrim(JURI::base(), '/') . $bits[1]; } else { $url = $bits[1]; } } } } break; case 'type': $newType = trim(strtolower($bits[1])); if (!in_array($newType, $enabledButtons)) { $enabledButtons[] = $newType; } break; case 'img': $imageSrc = empty($imageSrc) ? strtolower($bits[1]) : $imageSrc; break; } } if (!empty($enabledButtons)) { $this->_enabledButtons = $enabledButtons; } } // get buttons html $buttons = $this->_sh404sefGetSocialButtons($sefConfig, $url, $context = '', $content = null, $imageSrc, $imageDesc); $buttons = str_replace('\'', '\\\'', $buttons); // replace in document $page = str_replace($match[0], $buttons, $page); } } // insert head links as needed $this->_insertSocialLinks($page, $sefConfig); }
function shIsAnyHomepage( $string) { static $pages = array(); static $home = ''; static $cleanedHomeLinks = array(); if( !isset( $pages[$string])) { $pageInfo = & Sh404sefFactory::getPageInfo(); if(empty( $cleanedHomeLinks)) { foreach( $pageInfo->homeLinks as $link) { $cleanedHomeLinks[] = shCleanUpPag( $link); } } $shTempString = JString::rtrim(str_replace($pageInfo->getDefaultLiveSite(), '', $string), '/'); $shTempString = shSortUrl(shCleanUpPag($shTempString)); // check all homepages $pages[$string] = false; foreach( $cleanedHomeLinks as $link) { if( $link == $shTempString) { $pages[$string] = true; } } } return $pages[$string]; }
/** * @group String * @covers JString::rtrim * @dataProvider rtrimData */ public function testRtrim($string, $charlist, $expect) { if ($charlist === null) { $actual = JString::rtrim($string); } else { $actual = JString::rtrim($string, $charlist); } $this->assertEquals($expect, $actual); }
} } } //Make sure host name matches our config, we need this later. if (strpos($GLOBALS['shConfigLiveSite'], $shPageInfo->URI->host) === false && strpos($sefConfig->shConfig_live_secure_site, $shPageInfo->URI->host) === false) { _log('Redirecting to home : host don\'t match our config : ' . $GLOBALS['shConfigLiveSite'] . ' | ' . $shPageInfo->URI->host . ' | ' . $sefConfig->shConfig_live_secure_site); shRedirect($GLOBALS['shConfigLiveSite']); } else { $shPageInfo->shCurrentPageURL = $shPageInfo->URI->protocol . '://' . $shPageInfo->URI->host . (!sh404SEF_USE_NON_STANDARD_PORT || empty($shPageInfo->URI->port) ? '' : ':' . $shPageInfo->URI->port) . $shPageInfo->URI->path; _log('Current page URL : ' . $shPageInfo->shCurrentPageURL); $shPageInfo->shCurrentPagePath = str_replace($GLOBALS['shConfigLiveSite'], '', $shPageInfo->shCurrentPageURL); _log('Current page path : ' . $shPageInfo->shCurrentPagePath); if (empty($sefConfig->shRewriteMode)) { $shPageInfo->baseUrl = $shPageInfo->shCurrentPageURL; } else { $shPageInfo->baseUrl = $GLOBALS['shConfigLiveSite'] . JString::rtrim($sefConfig->shRewriteStrings[$sefConfig->shRewriteMode], '/') . $shPageInfo->shCurrentPagePath; } // V 1.2.4.s PR2 : workaround for Virtuemart cookie check issue // see second part in shSef404.php if (shIsSearchEngine()) { // simulate doing successfull cookie check _log('Setting VMCHECK cookie for search engine'); $_COOKIE['VMCHECK'] = 'OK'; $_REQUEST['vmcchk'] = 1; // from VM 1.1.2 onward, result is stored in session, not cookie $_SESSION['VMCHECK'] = 'OK'; } } } else { JError::RaiseError(COM_SH404SEF_NOREAD . "( {$sef404} )<br />" . COM_SH404SEF_CHK_PERMS); }
/** * Insert appropriate script links into document */ public function onSh404sefInsertSocialButtons(&$page, $sefConfig) { $app = JFactory::getApplication(); // are we in the backend - that would be a mistake if (!defined('SH404SEF_IS_RUNNING') || $app->isAdmin()) { return; } // don't display on errors $pageInfo = Sh404sefFactory::getPageInfo(); if (!empty($pageInfo->httpStatus) && $pageInfo->httpStatus == 404) { return; } // regexp to catch plugin requests $regExp = '#{sh404sef_social_buttons(.*)}#Us'; // search for our marker} if (preg_match_all($regExp, $page, $matches, PREG_SET_ORDER) > 0) { // process matches foreach ($matches as $id => $match) { $url = ''; // extract target URL if (!empty($match[1])) { $raw = explode(' ', $match[1]); $attributes = array(); $enabledButtons = array(); foreach ($raw as $attribute) { $attribute = JString::trim($attribute); if (strpos($attribute, '=') === false) { continue; } $bits = explode('=', $attribute); if (empty($bits[1])) { continue; } switch ($bits[0]) { case 'url': $base = JURI::base(true); if (substr($bits[1], 0, 10) == 'index.php?') { $url = JURI::getInstance()->toString(array('scheme', 'host', 'port')) . JRoute::_($bits[1]); } else { if (substr($bits[1], 0, JString::strlen($base)) == $base) { $url = JURI::getInstance()->toString(array('scheme', 'host', 'port')) . $bits[1]; } else { if (substr($bits[1], 0, 1) == '/') { $url = JString::rtrim(JURI::base(), '/') . $bits[1]; } else { $url = $bits[1]; } } } break; case 'type': $enabledButtons[] = strtolower($bits[1]); break; } } if (!empty($enabledButtons)) { $this->_enabledButtons = $enabledButtons; } } // get buttons html $buttons = $this->_sh404sefGetSocialButtons($sefConfig, $url); $buttons = str_replace('\'', '\\\'', $buttons); // replace in document $page = str_replace($match[0], $buttons, $page); } } // insert head links as needed $this->_insertSocialLinks($page, $sefConfig); }
function shIsHomepage($string) { static $pages = array(); static $home = ''; global $shHomeLink; if (!isset($pages[$string])) { if (empty($home) && !empty($shHomeLink)) { $home = shSortUrl(shCleanUpLangAndPag($shHomeLink)); } $shTempString = JString::rtrim(str_replace($GLOBALS['shConfigLiveSite'], '', $string), '/'); $pages[$string] = shSortUrl(shCleanUpLangAndPag($shTempString)) == $home; // version t added sorting } return $pages[$string]; }
/** * Return the absolute URI path to the resource */ public function getURI($storageId) { $root = JString::rtrim(JURI::root(), '/'); $storageId = JString::ltrim($storageId, '/'); return $root . '/' . $storageId; }
/** * Get the path (relative to site root?) to the smaller file * * @param string $file large file path * @param string $type type (thumb or crop) * * @return string */ protected function _getSmallerFile($file, $type) { $params = $this->getParams(); $w = new FabrikWorker(); // $$$ rob wasn't working when getting thumb path on upload $ulDir = JPath::clean($params->get('ul_directory')); $ulDir = str_replace("\\", "/", $ulDir); // If we're deleting a file, See http://fabrikar.com/forums/showthread.php?t=31715 $file = str_replace("\\", "/", $file); // Replace things like $my->id may barf on other stuff $afile = str_replace(JURI::root(), '', $file); $afile = JString::ltrim($afile, "/"); $ulDir = JString::ltrim($ulDir, "/"); $ulDir = JString::rtrim($ulDir, "/"); $ulDirbits = explode('/', $ulDir); $filebits = explode('/', $afile); $match = array(); $replace = array(); for ($i = 0; $i < count($filebits); $i++) { if (array_key_exists($i, $ulDirbits) && $filebits[$i] != $ulDirbits[$i]) { $match[] = $ulDirbits[$i]; $replace[] = $filebits[$i]; } } $ulDir = str_replace($match, $replace, $ulDir); // $$$ rob wasn't working when getting thumb path on upload $typeDir = $type == 'thumb' ? $params->get('thumb_dir') : $params->get('fileupload_crop_dir'); $thumbdir = str_replace($match, $replace, $typeDir); $ulDir = $w->parseMessageForPlaceHolder($ulDir); $thumbdir = $w->parseMessageForPlaceHolder($thumbdir); $file = str_replace($ulDir, $thumbdir, $file); $file = $w->parseMessageForPlaceHolder($file); $f = basename($file); $dir = dirname($file); $ext = JFile::getExt($f); // Remove extension $fclean = str_replace('.' . $ext, '', $f); if ($type == 'thumb') { // $f replaced by $fclean, $ext $file = $dir . '/' . $params->get('thumb_prefix') . $fclean . $params->get('thumb_suffix') . '.' . $ext; } else { $file = $dir . '/' . $f; } return $file; }
/** * internally render the plugin, and add required script declarations * to the document */ function render() { require_once COM_FABRIK_FRONTEND . '/helpers/html.php'; $app = JFactory::getApplication(); $params = $this->getParams(); $config = JFactory::getConfig(); $document = JFactory::getDocument(); $w = new FabrikWorker(); $document->addScript("http://api.simile-widgets.org/runway/1.0/runway-api.js"); $c = 0; $images = (array) $params->get('coverflow_image'); $titles = (array) $params->get('coverflow_title'); $subtitles = (array) $params->get('coverflow_subtitle'); $config = JFactory::getConfig(); $listids = (array) $params->get('coverflow_table'); $eventdata = array(); foreach ($listids as $listid) { $listModel = JModel::getInstance('List', 'FabrikFEModel'); $listModel->setId($listid); $list = $listModel->getTable(); $nav = $listModel->getPagination(0, 0, 0); $image = $images[$c]; $title = $titles[$c]; $subtitle = $subtitles[$c]; $data = $listModel->getData(); if ($listModel->canView() || $listModel->canEdit()) { $elements = $listModel->getElements(); $imageElement = JArrayHelper::getValue($elements, FabrikString::safeColName($image)); $action = $app->isAdmin() ? "task" : "view"; $nextview = $listModel->canEdit() ? "form" : "details"; foreach ($data as $group) { if (is_array($group)) { foreach ($group as $row) { $event = new stdClass(); if (!method_exists($imageElement, 'getStorage')) { //JError::raiseError(500, 'Looks like you selected a element other than a fileupload element for the coverflows image element'); switch (get_class($imageElement)) { case 'FabrikModelFabrikImage': $rootFolder = $imageElement->getParams()->get('selectImage_root_folder'); $rootFolder = JString::ltrim($rootFolder, '/'); $rootFolder = JString::rtrim($rootFolder, '/'); $event->image = COM_FABRIK_LIVESITE . 'images/stories/' . $rootFolder . '/' . $row->{$image . '_raw'}; break; default: $event->image = isset($row->{$image . '_raw'}) ? $row->{$image . '_raw'} : ''; break; } } else { $event->image = $imageElement->getStorage()->pathToURL($row->{$image . '_raw'}); } $event->title = (string) strip_tags($row->{$title}); $event->subtitle = (string) strip_tags($row->{$subtitle}); $eventdata[] = $event; } } } } $c++; } $json = json_encode($eventdata); $str = "var coverflow = new FbVisCoverflow({$json});"; $srcs = FabrikHelperHTML::framework(); $srcs[] = $this->srcBase . 'coverflow/coverflow.js'; FabrikHelperHTML::script($srcs, $str); }
/** * Parse the url into parts * * @param &string &$raw_url the raw url to parse * @param bool $relative_url allow relative URLs * * @return an object (if successful) with the parts as attributes (or a error string in case of error) */ private static function parse_url(&$raw_url, $relative_url) { // Set up the return object $result = new JObject(); $result->error = false; $result->relative = $relative_url; // Handle relative URLs $url = $raw_url; if ($relative_url) { $uri = JFactory::getURI(); $url = $uri->base(true) . "/" . $raw_url; } // Thanks to http://www.roscripts.com/PHP_regular_expressions_examples-136.html // For parts of the URL regular expression here if (preg_match('^(?P<protocol>\\b[A-Z]+\\b://)?' . '(?P<domain>[-A-Z0-9\\.]+)?' . ':?(?P<port>[0-9]*)' . '(?P<path>/[-A-Z0-9+&@#/%=~_|!:,.;]*)' . '?(?P<parameters>\\?[-A-Z0-9+&@#/%=~_|!:,.;]*)?^i', $url, $match)) { // Get the protocol (if any) $protocol = ''; if (isset($match['protocol']) && $match['protocol']) { $protocol = JString::rtrim($match['protocol'], '/:'); } // Get the domain (if any) $domain = ''; if (isset($match['domain']) && $match['domain']) { $domain = $match['domain']; } // Figure out the port $port = null; if ($protocol == 'http') { $port = 80; } elseif ($protocol == 'https') { $ports = 443; } elseif ($protocol == 'ftp') { $ports = 21; } elseif ($protocol == '') { $port = 80; } else { // Unrecognized protocol $result->error = true; $result->error_code = 'url_unknown_protocol'; $result->error_msg = JText::sprintf('ATTACH_ERROR_UNKNOWN_PROTCOL_S_IN_URL_S', $protocol, $raw_url); return $result; } // Override the port if specified if (isset($match['port']) && $match['port']) { $port = (int) $match['port']; } // Default to HTTP if protocol/port is missing if (!$port) { $port = 80; } // Get the path and reconstruct the full path if (isset($match['path']) && $match['path']) { $path = $match['path']; } else { $path = '/'; } // Get the parameters (if any) if (isset($match['parameters']) && $match['parameters']) { $parameters = $match['parameters']; } else { $parameters = ''; } // Handle relative URLs (or missing info) if ($relative_url) { // Do nothing } else { // If it is not a relative URL, make sure we have a protocl and domain if ($protocol == '') { $protocol = 'http'; } if ($domain == '') { // Reject bad url syntax $result->error = true; $result->error_code = 'url_no_domain'; $result->error_msg = JText::sprintf('ATTACH_ERROR_IN_URL_SYNTAX_S', $raw_url); } } // Save the information $result->protocol = $protocol; $result->domain = $domain; $result->port = $port; $result->path = str_replace('//', '/', $path); $result->params = $parameters; $result->url = str_replace('//', '/', $path . $result->params); } else { // Reject bad url syntax $result->error = true; $result->error_code = 'url_bad_syntax'; $result->error_msg = JText::sprintf('ATTACH_ERROR_IN_URL_SYNTAX_S', $raw_url); } return $result; }
shRedirect($shPageInfo->URI->protocol . '://' . str_replace('www.', '', $_SERVER['HTTP_HOST'] . (!sh404SEF_USE_NON_STANDARD_PORT || empty($shPageInfo->URI->port) ? '' : ':' . $shPageInfo->URI->port)) . $shPageInfo->shSaveRequestURI); } } } //Make sure host name matches our config, we need this later. if (!empty($shPageInfo->URI->host) && strpos($GLOBALS['shConfigLiveSite'], $shPageInfo->URI->host) === false && strpos($sefConfig->shConfig_live_secure_site, $shPageInfo->URI->host) === false) { _log('Redirecting to home : host don\'t match our config : ' . $GLOBALS['shConfigLiveSite'] . ' | ' . $shPageInfo->URI->host . ' | ' . $sefConfig->shConfig_live_secure_site); shRedirect($GLOBALS['shConfigLiveSite']); } else { $shPageInfo->shCurrentPagePath = $shPageInfo->URI->protocol . '://' . $shPageInfo->URI->host . (!sh404SEF_USE_NON_STANDARD_PORT || empty($shPageInfo->URI->port) ? '' : ':' . $shPageInfo->URI->port) . $shPageInfo->URI->path; $shPageInfo->shCurrentPagePath = shUrlDecode($shPageInfo->shCurrentPagePath); $shPageInfo->shCurrentPagePath = str_replace($GLOBALS['shConfigLiveSite'], '', $shPageInfo->shCurrentPagePath); _log('Current page path : ' . $shPageInfo->shCurrentPagePath); $qString = $shPageInfo->URI->getQueryString(); $shPageInfo->shCurrentPageURL = empty($qString) ? $shPageInfo->shCurrentPagePath : $shPageInfo->shCurrentPagePath . '?' . JString::ltrim($qString, '&'); $rewriteBit = empty($sefConfig->shRewriteMode) ? '' : JString::rtrim($sefConfig->shRewriteStrings[$sefConfig->shRewriteMode], '/'); $shPageInfo->baseUrl = $GLOBALS['shConfigLiveSite'] . $rewriteBit . $shPageInfo->shCurrentPagePath; _log('Current base url : ' . $shPageInfo->baseUrl); // V 1.2.4.s PR2 : workaround for Virtuemart cookie check issue // see second part in shSef404.php if (shIsSearchEngine()) { // simulate doing successfull cookie check _log('Setting VMCHECK cookie for search engine'); $_COOKIE['VMCHECK'] = 'OK'; $_REQUEST['vmcchk'] = 1; // from VM 1.1.2 onward, result is stored in session, not cookie $_SESSION['VMCHECK'] = 'OK'; } } } else { JError::RaiseError(COM_SH404SEF_NOREAD . "( {$sef404} )<br />" . COM_SH404SEF_CHK_PERMS);
function _parseSefRoute(&$uri) { $vars = array(); _log('_parseSefRoute, parsing _uri ' . $uri->_uri); _log('_parseSefRoute, parsing _host ' . $uri->_host); _log('_parseSefRoute, parsing _path ' . $uri->_path); include JPATH_ROOT . DS . 'components' . DS . 'com_sh404sef' . DS . 'sh404sef.inc.php'; if (shIsMultilingual() == 'joomfish') { $currentLangShortCode = $GLOBALS['shMosConfig_shortcode']; $conf =& JFactory::getConfig(); $configDefaultLanguage = $conf->getValue('config.language'); $tmp = explode('-', str_replace('_', '-', $configDefaultLanguage)); $defaultLangShortCode = $tmp[0]; } else { $currentLang = ''; } $jMenu = null; $shMenu = null; // set active menu if changed if (!empty($vars['Itemid'])) { $newItemid = intval($vars['Itemid']); if (!empty($newItemid)) { $jMenu =& JSite::getMenu(); $jMenu->setActive($newItemid); $shMenu =& shRouter::shGetMenu(); $shMenu->setActive($newItemid); } } //Set the variables $this->setVars($vars); // set language again, as Joomfish may have set it according to user cookie if (shIsMultilingual() == 'joomfish' && !empty($vars['lang']) && $vars['lang'] != $currentLangShortCode) { JRequest::setVar('lang', $vars['lang']); // we also need to fix the main menu, as joomfish has set it to the wrong language if (empty($shMenu) || empty($shMenu)) { $jMenu =& JSite::getMenu(); $shMenu =& shRouter::shGetMenu(); } $sefLang = TableJFLanguage::createByShortcode($vars['lang'], false); $jMenu->_items = shGetJFMenu($sefLang->code, false, $jMenu->_items); $shMenu->_items = shGetJFMenu($sefLang->code, false, $shMenu->_items); // and finally we can set new joomfish language shSetJfLanguage($vars['lang']); } // last fix is to remove the home flag if other than default language if (shIsMultilingual() == 'joomfish' && !empty($vars['lang']) && $vars['lang'] != $defaultLangShortCode) { if (empty($shMenu) || empty($shMenu)) { $jMenu =& JSite::getMenu(); $shMenu =& shRouter::shGetMenu(); } $jDefaultItem =& $jMenu->getDefault(); $jDefaultItem->home = 0; $shDefaultItem =& $shMenu->getDefault(); $shDefaultItem->home = 0; } // and finally we can set new joomfish language if (shIsMultilingual() == 'joomfish' && !empty($vars['lang']) && $vars['lang'] != $currentLangShortCode) { shSetJfLanguage($vars['lang']); } // real last fix is to fix the $uri object, which Joomfish broke as it intended the path to be // parsed by Joomla router, not ours if (shIsMultilingual() == 'joomfish') { $myUri =& JURI::getInstance(); // fix the path if (!empty($sefConfig->shRewriteMode)) { $rewriteBit = JString::rtrim($sefConfig->shRewriteStrings[$sefConfig->shRewriteMode], '/'); } else { $rewriteBit = ''; } $path = rtrim($shPageInfo->base, '/') . $rewriteBit . $shPageInfo->shCurrentPagePath; $myUri->setPath($path); // remove the lang query that JF added to $uri $myUri->delVar('lang'); } return $vars; }
<?php /** * SEF extension for Joomla! * Originally written for Mambo as 404SEF by W. H. Welch. * * @author $Author: shumisha $ * @copyright Yannick Gaultier - 2009-2010 * @package sh404SEF-15 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL * @version $Id: uninstall.sh404sef.php 1842 2011-03-02 19:51:18Z silianacom-svn $ */ defined('_JEXEC') or die('Direct Access to this location is not allowed.'); global $mainframe; jimport('joomla.filesystem.file'); $front_live_site = JString::rtrim(str_replace('/administrator', '', JURI::base()), '/'); // V 1.2.4.t improved upgrading function shDeletetable($tableName) { $database =& JFactory::getDBO(); $sql = 'DROP TABLE #__' . $tableName; $database->setQuery($sql); $database->query(); } function shDeleteAllSEFUrl($kind) { $database =& JFactory::getDBO(); $sql = 'DELETE FROM #__redirection WHERE '; if ($kind == 'Custom') { $where = '`dateadd` > \'0000-00-00\' and `newurl` != \'\';'; } else {
protected function _setPageInfo($uri) { if (self::$requestParsed) { return; } // get pageInfo object and set some of its properties $pageInfo = Sh404sefFactory::getPageInfo(); $pageInfo->shCurrentPageNonSef = 'index.php' . $uri->toString(array('query', 'fragment')); $pageInfo->shCurrentPageURL = $uri->get('_uri'); $site = $uri->toString(array('scheme', 'host', 'port')); $pageInfo->basePath = JString::rtrim(str_replace($site, '', $uri->base()), '/'); }
function shIsHomepage($string) { static $pages = array(); global $shHomeLink; $md5 = md5($string); if (!isset($pages[$md5])) { $shTempString = JString::rtrim(str_replace($GLOBALS['shConfigLiveSite'], '', $string), '/'); $pages[$md5] = shSortUrl(shCleanUpLangAndPag($shTempString)) == shSortUrl(shCleanUpLangAndPag($shHomeLink)); // version t added sorting } return $pages[$md5]; }
function shSEFConfig() { $sef_config_file = sh404SEF_ADMIN_ABS_PATH . 'config/config.sef.php'; $app = JFactory::getApplication(); if ($app->isAdmin()) { $this->shCheckFilesAccess(); } if (shFileExists($sef_config_file)) { include $sef_config_file; } // shumisha : 2007-04-01 new parameters ! if (isset($shUseURLCache)) { $this->shUseURLCache = $shUseURLCache; } // shumisha : 2007-04-01 new parameters ! if (isset($shMaxURLInCache)) { $this->shMaxURLInCache = $shMaxURLInCache; } // shumisha : 2007-04-01 new parameters ! if (isset($shTranslateURL)) { $this->shTranslateURL = $shTranslateURL; } //V 1.2.4.m if (isset($shInsertLanguageCode)) { $this->shInsertLanguageCode = $shInsertLanguageCode; } if (isset($notTranslateURLList)) { $this->notTranslateURLList = $notTranslateURLList; } if (isset($notInsertIsoCodeList)) { $this->notInsertIsoCodeList = $notInsertIsoCodeList; } // shumisha : 2007-04-03 new parameters ! if (isset($shInsertGlobalItemidIfNone)) { $this->shInsertGlobalItemidIfNone = $shInsertGlobalItemidIfNone; } if (isset($shInsertTitleIfNoItemid)) { $this->shInsertTitleIfNoItemid = $shInsertTitleIfNoItemid; } if (isset($shAlwaysInsertMenuTitle)) { $this->shAlwaysInsertMenuTitle = $shAlwaysInsertMenuTitle; } if (isset($shAlwaysInsertItemid)) { $this->shAlwaysInsertItemid = $shAlwaysInsertItemid; } if (isset($shDefaultMenuItemName)) { $this->shDefaultMenuItemName = $shDefaultMenuItemName; } if (isset($shAppendRemainingGETVars)) { $this->shAppendRemainingGETVars = $shAppendRemainingGETVars; } if (isset($shVmInsertShopName)) { $this->shVmInsertShopName = $shVmInsertShopName; } if (isset($shInsertProductId)) { $this->shInsertProductId = $shInsertProductId; } if (isset($shVmUseProductSKU)) { $this->shVmUseProductSKU = $shVmUseProductSKU; } if (isset($shVmInsertManufacturerName)) { $this->shVmInsertManufacturerName = $shVmInsertManufacturerName; } if (isset($shInsertManufacturerId)) { $this->shInsertManufacturerId = $shInsertManufacturerId; } if (isset($shVMInsertCategories)) { $this->shVMInsertCategories = $shVMInsertCategories; } if (isset($shVmAdditionalText)) { $this->shVmAdditionalText = $shVmAdditionalText; } if (isset($shVmInsertFlypage)) { $this->shVmInsertFlypage = $shVmInsertFlypage; } if (isset($shInsertCategoryId)) { $this->shInsertCategoryId = $shInsertCategoryId; } if (isset($shReplacements)) { $this->shReplacements = $shReplacements; } if (isset($shInsertNumericalId)) { $this->shInsertNumericalId = $shInsertNumericalId; } if (isset($shInsertNumericalIdCatList)) { $this->shInsertNumericalIdCatList = $shInsertNumericalIdCatList; } if (isset($shRedirectNonSefToSef)) { $this->shRedirectNonSefToSef = $shRedirectNonSefToSef; } // disabled, can't be implemented safely //if (isset($shRedirectJoomlaSefToSef)) $this->shRedirectJoomlaSefToSef = $shRedirectJoomlaSefToSef; if (isset($shConfig_live_secure_site)) { $this->shConfig_live_secure_site = JString::rtrim($shConfig_live_secure_site, '/'); } if (isset($shActivateIJoomlaMagInContent)) { $this->shActivateIJoomlaMagInContent = $shActivateIJoomlaMagInContent; } if (isset($shInsertIJoomlaMagIssueId)) { $this->shInsertIJoomlaMagIssueId = $shInsertIJoomlaMagIssueId; } if (isset($shInsertIJoomlaMagName)) { $this->shInsertIJoomlaMagName = $shInsertIJoomlaMagName; } if (isset($shInsertIJoomlaMagMagazineId)) { $this->shInsertIJoomlaMagMagazineId = $shInsertIJoomlaMagMagazineId; } if (isset($shInsertIJoomlaMagArticleId)) { $this->shInsertIJoomlaMagArticleId = $shInsertIJoomlaMagArticleId; } if (isset($shInsertCBName)) { $this->shInsertCBName = $shInsertCBName; } if (isset($shCBInsertUserName)) { $this->shCBInsertUserName = $shCBInsertUserName; } if (isset($shCBInsertUserId)) { $this->shCBInsertUserId = $shCBInsertUserId; } if (isset($shCBUseUserPseudo)) { $this->shCBUseUserPseudo = $shCBUseUserPseudo; } if (isset($shInsertMyBlogName)) { $this->shInsertMyBlogName = $shInsertMyBlogName; } if (isset($shMyBlogInsertPostId)) { $this->shMyBlogInsertPostId = $shMyBlogInsertPostId; } if (isset($shMyBlogInsertTagId)) { $this->shMyBlogInsertTagId = $shMyBlogInsertTagId; } if (isset($shMyBlogInsertBloggerId)) { $this->shMyBlogInsertBloggerId = $shMyBlogInsertBloggerId; } if (isset($shInsertDocmanName)) { $this->shInsertDocmanName = $shInsertDocmanName; } if (isset($shDocmanInsertDocId)) { $this->shDocmanInsertDocId = $shDocmanInsertDocId; } if (isset($shDocmanInsertDocName)) { $this->shDocmanInsertDocName = $shDocmanInsertDocName; } if (isset($shLog404Errors)) { $this->shLog404Errors = $shLog404Errors; } if (isset($shLMDefaultItemid)) { $this->shLMDefaultItemid = $shLMDefaultItemid; } if (isset($shInsertFireboardName)) { $this->shInsertFireboardName = $shInsertFireboardName; } if (isset($shFbInsertCategoryName)) { $this->shFbInsertCategoryName = $shFbInsertCategoryName; } if (isset($shFbInsertCategoryId)) { $this->shFbInsertCategoryId = $shFbInsertCategoryId; } if (isset($shFbInsertMessageSubject)) { $this->shFbInsertMessageSubject = $shFbInsertMessageSubject; } if (isset($shFbInsertMessageId)) { $this->shFbInsertMessageId = $shFbInsertMessageId; } if (isset($shDoNotOverrideOwnSef)) { // V 1.2.4.m $this->shDoNotOverrideOwnSef = $shDoNotOverrideOwnSef; } if (isset($shEncodeUrl)) { // V 1.2.4.m $this->shEncodeUrl = $shEncodeUrl; } if (isset($guessItemidOnHomepage)) { // V 1.2.4.q $this->guessItemidOnHomepage = $guessItemidOnHomepage; } if (isset($shForceNonSefIfHttps)) { // V 1.2.4.q $this->shForceNonSefIfHttps = $shForceNonSefIfHttps; } if (isset($shRewriteMode)) { // V 1.2.4.s $this->shRewriteMode = $shRewriteMode; } if (isset($shRewriteStrings)) { // V 1.2.4.s $this->shRewriteStrings = $shRewriteStrings; } if (isset($shMetaManagementActivated)) { // V 1.2.4.s $this->shMetaManagementActivated = $shMetaManagementActivated; } if (isset($shRemoveGeneratorTag)) { // V 1.2.4.s $this->shRemoveGeneratorTag = $shRemoveGeneratorTag; } if (isset($shPutH1Tags)) { // V 1.2.4.s $this->shPutH1Tags = $shPutH1Tags; } if (isset($shInsertContentTableName)) { // V 1.2.4.s $this->shInsertContentTableName = $shInsertContentTableName; } if (isset($shContentTableName)) { // V 1.2.4.s $this->shContentTableName = $shContentTableName; } if (isset($shAutoRedirectWww)) { // V 1.2.4.s $this->shAutoRedirectWww = $shAutoRedirectWww; } if (isset($shVmInsertProductName)) { // V 1.2.4.s $this->shVmInsertProductName = $shVmInsertProductName; } if (isset($shDMInsertCategories)) { // V 1.2.4.t $this->shDMInsertCategories = $shDMInsertCategories; } if (isset($shDMInsertCategoryId)) { // V 1.2.4.t $this->shDMInsertCategoryId = $shDMInsertCategoryId; } if (isset($shForcedHomePage)) { // V 1.2.4.t $this->shForcedHomePage = $shForcedHomePage; } if (isset($shInsertContentBlogName)) { // V 1.2.4.t $this->shInsertContentBlogName = $shInsertContentBlogName; } if (isset($shContentBlogName)) { // V 1.2.4.t $this->shContentBlogName = $shContentBlogName; } if (isset($shInsertMTreeName)) { // V 1.2.4.t $this->shInsertMTreeName = $shInsertMTreeName; } if (isset($shMTreeInsertListingName)) { // V 1.2.4.t $this->shMTreeInsertListingName = $shMTreeInsertListingName; } if (isset($shMTreeInsertListingId)) { // V 1.2.4.t $this->shMTreeInsertListingId = $shMTreeInsertListingId; } if (isset($shMTreePrependListingId)) { // V 1.2.4.t $this->shMTreePrependListingId = $shMTreePrependListingId; } if (isset($shMTreeInsertCategories)) { // V 1.2.4.t $this->shMTreeInsertCategories = $shMTreeInsertCategories; } if (isset($shMTreeInsertCategoryId)) { // V 1.2.4.t $this->shMTreeInsertCategoryId = $shMTreeInsertCategoryId; } if (isset($shMTreeInsertUserName)) { // V 1.2.4.t $this->shMTreeInsertUserName = $shMTreeInsertUserName; } if (isset($shMTreeInsertUserId)) { // V 1.2.4.t $this->shMTreeInsertUserId = $shMTreeInsertUserId; } if (isset($shInsertNewsPName)) { // V 1.2.4.t $this->shInsertNewsPName = $shInsertNewsPName; } if (isset($shNewsPInsertCatId)) { // V 1.2.4.t $this->shNewsPInsertCatId = $shNewsPInsertCatId; } if (isset($shNewsPInsertSecId)) { // V 1.2.4.t $this->shNewsPInsertSecId = $shNewsPInsertSecId; } if (isset($shInsertRemoName)) { // V 1.2.4.t $this->shInsertRemoName = $shInsertRemoName; } if (isset($shRemoInsertDocId)) { // V 1.2.4.t $this->shRemoInsertDocId = $shRemoInsertDocId; } if (isset($shRemoInsertDocName)) { // V 1.2.4.t $this->shRemoInsertDocName = $shRemoInsertDocName; } if (isset($shRemoInsertCategories)) { // V 1.2.4.t $this->shRemoInsertCategories = $shRemoInsertCategories; } if (isset($shRemoInsertCategoryId)) { // V 1.2.4.t $this->shRemoInsertCategoryId = $shRemoInsertCategoryId; } if (isset($shCBShortUserURL)) { // V 1.2.4.t $this->shCBShortUserURL = $shCBShortUserURL; } if (isset($shKeepStandardURLOnUpgrade)) { // V 1.2.4.t $this->shKeepStandardURLOnUpgrade = $shKeepStandardURLOnUpgrade; } if (isset($shKeepCustomURLOnUpgrade)) { // V 1.2.4.t $this->shKeepCustomURLOnUpgrade = $shKeepCustomURLOnUpgrade; } if (isset($shKeepMetaDataOnUpgrade)) { // V 1.2.4.t $this->shKeepMetaDataOnUpgrade = $shKeepMetaDataOnUpgrade; } if (isset($shKeepModulesSettingsOnUpgrade)) { // V 1.2.4.t $this->shKeepModulesSettingsOnUpgrade = $shKeepModulesSettingsOnUpgrade; } if (isset($shMultipagesTitle)) { // V 1.2.4.t $this->shMultipagesTitle = $shMultipagesTitle; } // shumisha end of new parameters if (isset($Enabled)) { $this->Enabled = $Enabled; } if (isset($replacement)) { $this->replacement = $replacement; } if (isset($pagerep)) { $this->pagerep = $pagerep; } if (isset($stripthese)) { $this->stripthese = $stripthese; } if (isset($friendlytrim)) { $this->friendlytrim = $friendlytrim; } if (isset($suffix)) { $this->suffix = $suffix; } if (isset($addFile)) { $this->addFile = $addFile; } if (isset($LowerCase)) { $this->LowerCase = $LowerCase; } if (isset($HideCat)) { $this->HideCat = $HideCat; } if (isset($replacement)) { $this->UseAlias = $UseAlias; } if (isset($UseAlias)) { $this->page404 = $page404; } if (isset($predefined)) { $this->predefined = $predefined; } if (isset($skip)) { $this->skip = $skip; } if (isset($nocache)) { $this->nocache = $nocache; } // V x if (isset($shKeepConfigOnUpgrade)) { // V 1.2.4.x $this->shKeepConfigOnUpgrade = $shKeepConfigOnUpgrade; } if (isset($shSecEnableSecurity)) { // V 1.2.4.x $this->shSecEnableSecurity = $shSecEnableSecurity; } if (isset($shSecLogAttacks)) { // V 1.2.4.x $this->shSecLogAttacks = $shSecLogAttacks; } if (isset($shSecOnlyNumVars)) { // V 1.2.4.x $this->shSecOnlyNumVars = $shSecOnlyNumVars; } if (isset($shSecAlphaNumVars)) { // V 1.2.4.x $this->shSecAlphaNumVars = $shSecAlphaNumVars; } if (isset($shSecNoProtocolVars)) { // V 1.2.4.x $this->shSecNoProtocolVars = $shSecNoProtocolVars; } $this->ipWhiteList = shReadFile(sh404SEF_ADMIN_ABS_PATH . 'security/sh404SEF_IP_white_list.dat'); $this->ipBlackList = shReadFile(sh404SEF_ADMIN_ABS_PATH . 'security/sh404SEF_IP_black_list.dat'); $this->uAgentWhiteList = shReadFile(sh404SEF_ADMIN_ABS_PATH . 'security/sh404SEF_uAgent_white_list.dat'); $this->uAgentBlackList = shReadFile(sh404SEF_ADMIN_ABS_PATH . 'security/sh404SEF_uAgent_black_list.dat'); if (isset($shSecCheckHoneyPot)) { // V 1.2.4.x $this->shSecCheckHoneyPot = $shSecCheckHoneyPot; } if (isset($shSecDebugHoneyPot)) { // V 1.2.4.x $this->shSecDebugHoneyPot = $shSecDebugHoneyPot; } if (isset($shSecHoneyPotKey)) { // V 1.2.4.x $this->shSecHoneyPotKey = $shSecHoneyPotKey; } if (isset($shSecEntranceText)) { // V 1.2.4.x $this->shSecEntranceText = $shSecEntranceText; } if (isset($shSecSmellyPotText)) { // V 1.2.4.x $this->shSecSmellyPotText = $shSecSmellyPotText; } if (isset($monthsToKeepLogs)) { // V 1.2.4.x $this->monthsToKeepLogs = $monthsToKeepLogs; } if (isset($shSecActivateAntiFlood)) { // V 1.2.4.x $this->shSecActivateAntiFlood = $shSecActivateAntiFlood; } if (isset($shSecAntiFloodOnlyOnPOST)) { // V 1.2.4.x $this->shSecAntiFloodOnlyOnPOST = $shSecAntiFloodOnlyOnPOST; } if (isset($shSecAntiFloodPeriod)) { // V 1.2.4.x $this->shSecAntiFloodPeriod = $shSecAntiFloodPeriod; } if (isset($shSecAntiFloodCount)) { // V 1.2.4.x $this->shSecAntiFloodCount = $shSecAntiFloodCount; } // if (isset($insertSectionInBlogTableLinks)) // V 1.2.4.x // $this->insertSectionInBlogTableLinks = $insertSectionInBlogTableLinks; $this->shLangTranslateList = $this->shInitLanguageList(isset($shLangTranslateList) ? $shLangTranslateList : null, 0, 0); $this->shLangInsertCodeList = $this->shInitLanguageList(isset($shLangInsertCodeList) ? $shLangInsertCodeList : null, 0, 0); if (isset($defaultComponentStringList)) { // V 1.2.4.x $this->defaultComponentStringList = $defaultComponentStringList; } $this->pageTexts = $this->shInitLanguageList(isset($pageTexts) ? $pageTexts : null, isset($pagetext) ? $pagetext : 'Page-%s', isset($pagetext) ? $pagetext : 'Page-%s'); // use value from prev versions if any if (isset($shAdminInterfaceType)) { // V 1.2.4.x $this->shAdminInterfaceType = $shAdminInterfaceType; } // compatibility with version earlier than V x if (isset($shShopName)) { // V 1.2.4.x $this->defaultComponentStringList['virtuemart'] = $shShopName; } if (isset($shIJoomlaMagName)) { // V 1.2.4.x $this->defaultComponentStringList['magazine'] = $shIJoomlaMagName; } if (isset($shCBName)) { // V 1.2.4.x $this->defaultComponentStringList['comprofiler'] = $shCBName; } if (isset($shFireboardName)) { // V 1.2.4.x $this->defaultComponentStringList['fireboard'] = $shFireboardName; } if (isset($shMyBlogName)) { // V 1.2.4.x $this->defaultComponentStringList['myblog'] = $shMyBlogName; } if (isset($shDocmanName)) { // V 1.2.4.x $this->defaultComponentStringList['docman'] = $shDocmanName; } if (isset($shMTreeName)) { // V 1.2.4.x $this->defaultComponentStringList['mtree'] = $shMTreeName; } if (isset($shNewsPName)) { // V 1.2.4.x $this->defaultComponentStringList['news_portal'] = $shNewsPName; } if (isset($shRemoName)) { // V 1.2.4.x $this->defaultComponentStringList['remository'] = $shRemoName; } // end of compatibility code // V 1.3 RC if (isset($shInsertNoFollowPDFPrint)) { $this->shInsertNoFollowPDFPrint = $shInsertNoFollowPDFPrint; } if (isset($shInsertReadMorePageTitle)) { $this->shInsertReadMorePageTitle = $shInsertReadMorePageTitle; } if (isset($shMultipleH1ToH2)) { $this->shMultipleH1ToH2 = $shMultipleH1ToH2; } // V 1.3.1 RC if (isset($shVmUsingItemsPerPage)) { $this->shVmUsingItemsPerPage = $shVmUsingItemsPerPage; } if (isset($shSecCheckPOSTData)) { $this->shSecCheckPOSTData = $shSecCheckPOSTData; } if (isset($shSecCurMonth)) { $this->shSecCurMonth = $shSecCurMonth; } if (isset($shSecLastUpdated)) { $this->shSecLastUpdated = $shSecLastUpdated; } if (isset($shSecTotalAttacks)) { $this->shSecTotalAttacks = $shSecTotalAttacks; } if (isset($shSecTotalConfigVars)) { $this->shSecTotalConfigVars = $shSecTotalConfigVars; } if (isset($shSecTotalBase64)) { $this->shSecTotalBase64 = $shSecTotalBase64; } if (isset($shSecTotalScripts)) { $this->shSecTotalScripts = $shSecTotalScripts; } if (isset($shSecTotalStandardVars)) { $this->shSecTotalStandardVars = $shSecTotalStandardVars; } if (isset($shSecTotalImgTxtCmd)) { $this->shSecTotalImgTxtCmd = $shSecTotalImgTxtCmd; } if (isset($shSecTotalIPDenied)) { $this->shSecTotalIPDenied = $shSecTotalIPDenied; } if (isset($shSecTotalUserAgentDenied)) { $this->shSecTotalUserAgentDenied = $shSecTotalUserAgentDenied; } if (isset($shSecTotalFlooding)) { $this->shSecTotalFlooding = $shSecTotalFlooding; } if (isset($shSecTotalPHP)) { $this->shSecTotalPHP = $shSecTotalPHP; } if (isset($shSecTotalPHPUserClicked)) { $this->shSecTotalPHPUserClicked = $shSecTotalPHPUserClicked; } if (isset($prependToPageTitle)) { $this->prependToPageTitle = $prependToPageTitle; } if (isset($appendToPageTitle)) { $this->appendToPageTitle = $appendToPageTitle; } if (isset($debugToLogFile)) { $this->debugToLogFile = $debugToLogFile; } if (isset($debugStartedAt)) { $this->debugStartedAt = $debugStartedAt; } if (isset($debugDuration)) { $this->debugDuration = $debugDuration; } // V 1.3.1 if (isset($shInsertOutboundLinksImage)) { $this->shInsertOutboundLinksImage = $shInsertOutboundLinksImage; } if (isset($shImageForOutboundLinks)) { $this->shImageForOutboundLinks = $shImageForOutboundLinks; } // V 1.0.12 if (isset($useCatAlias)) { $this->useCatAlias = $useCatAlias; } if (isset($useMenuAlias)) { $this->useMenuAlias = $useMenuAlias; } // V 1.5.3 if (isset($alwaysAppendItemsPerPage)) { $this->alwaysAppendItemsPerPage = $alwaysAppendItemsPerPage; } if (isset($redirectToCorrectCaseUrl)) { $this->redirectToCorrectCaseUrl = $redirectToCorrectCaseUrl; } // V 1.5.5 if (isset($jclInsertEventId)) { $this->jclInsertEventId = $jclInsertEventId; } if (isset($jclInsertCategoryId)) { $this->jclInsertCategoryId = $jclInsertCategoryId; } if (isset($jclInsertCalendarId)) { $this->jclInsertCalendarId = $jclInsertCalendarId; } if (isset($jclInsertCalendarName)) { $this->jclInsertCalendarName = $jclInsertCalendarName; } if (isset($jclInsertDate)) { $this->jclInsertDate = $jclInsertDate; } if (isset($jclInsertDateInEventView)) { $this->jclInsertDateInEventView = $jclInsertDateInEventView; } if (isset($ContentTitleShowCat)) { $this->ContentTitleShowCat = $ContentTitleShowCat; } if (isset($ContentTitleUseAlias)) { $this->ContentTitleUseAlias = $ContentTitleUseAlias; } if (isset($ContentTitleUseCatAlias)) { $this->ContentTitleUseCatAlias = $ContentTitleUseCatAlias; } if (isset($pageTitleSeparator)) { $this->pageTitleSeparator = $pageTitleSeparator; } if (isset($ContentTitleInsertArticleId)) { $this->ContentTitleInsertArticleId = $ContentTitleInsertArticleId; } if (isset($shInsertContentArticleIdCatList)) { $this->shInsertContentArticleIdCatList = $shInsertContentArticleIdCatList; } // 1.5.8 if (isset($shJSInsertJSName)) { $this->shJSInsertJSName = $shJSInsertJSName; } if (isset($shJSShortURLToUserProfile)) { $this->shJSShortURLToUserProfile = $shJSShortURLToUserProfile; } if (isset($shJSInsertUsername)) { $this->shJSInsertUsername = $shJSInsertUsername; } if (isset($shJSInsertUserFullName)) { $this->shJSInsertUserFullName = $shJSInsertUserFullName; } if (isset($shJSInsertUserId)) { $this->shJSInsertUserId = $shJSInsertUserId; } if (isset($shJSInsertUserFullName)) { $this->shJSInsertUserFullName = $shJSInsertUserFullName; } if (isset($shJSInsertGroupCategory)) { $this->shJSInsertGroupCategory = $shJSInsertGroupCategory; } if (isset($shJSInsertGroupCategoryId)) { $this->shJSInsertGroupCategoryId = $shJSInsertGroupCategoryId; } if (isset($shJSInsertGroupId)) { $this->shJSInsertGroupId = $shJSInsertGroupId; } if (isset($shJSInsertGroupBulletinId)) { $this->shJSInsertGroupBulletinId = $shJSInsertGroupBulletinId; } if (isset($shJSInsertDiscussionId)) { $this->shJSInsertDiscussionId = $shJSInsertDiscussionId; } if (isset($shJSInsertMessageId)) { $this->shJSInsertMessageId = $shJSInsertMessageId; } if (isset($shJSInsertPhotoAlbum)) { $this->shJSInsertPhotoAlbum = $shJSInsertPhotoAlbum; } if (isset($shJSInsertPhotoAlbumId)) { $this->shJSInsertPhotoAlbumId = $shJSInsertPhotoAlbumId; } if (isset($shJSInsertPhotoId)) { $this->shJSInsertPhotoId = $shJSInsertPhotoId; } if (isset($shJSInsertVideoCat)) { $this->shJSInsertVideoCat = $shJSInsertVideoCat; } if (isset($shJSInsertVideoCatId)) { $this->shJSInsertVideoCatId = $shJSInsertVideoCatId; } if (isset($shJSInsertVideoId)) { $this->shJSInsertVideoId = $shJSInsertVideoId; } if (isset($shFbInsertUserName)) { $this->shFbInsertUserName = $shFbInsertUserName; } if (isset($shFbInsertUserId)) { $this->shFbInsertUserId = $shFbInsertUserId; } if (isset($shFbShortUrlToProfile)) { $this->shFbShortUrlToProfile = $shFbShortUrlToProfile; } if (isset($shPageNotFoundItemid)) { $this->shPageNotFoundItemid = $shPageNotFoundItemid; } if (isset($autoCheckNewVersion)) { $this->autoCheckNewVersion = $autoCheckNewVersion; } if (isset($error404SubTemplate)) { $this->error404SubTemplate = $error404SubTemplate; } if (isset($enablePageId)) { $this->enablePageId = $enablePageId; } if (isset($compEnablePageId)) { $this->compEnablePageId = $compEnablePageId; } // V 2.1.0 if (isset($analyticsEnabled)) { $this->analyticsEnabled = $analyticsEnabled; } if (isset($analyticsReportsEnabled)) { $this->analyticsReportsEnabled = $analyticsReportsEnabled; } if (isset($analyticsType)) { $this->analyticsType = $analyticsType; } if (isset($analyticsId)) { $this->analyticsId = $analyticsId; } if (isset($analyticsUser)) { $this->analyticsUser = $analyticsUser; } if (isset($analyticsPassword)) { $this->analyticsPassword = $analyticsPassword; } if (isset($analyticsAccount)) { $this->analyticsAccount = $analyticsAccount; } if (isset($analyticsExcludeIP)) { $this->analyticsExcludeIP = $analyticsExcludeIP; } if (isset($analyticsMaxUserLevel)) { $this->analyticsMaxUserLevel = $analyticsMaxUserLevel; } if (isset($analyticsProfile)) { $this->analyticsProfile = $analyticsProfile; } if (isset($autoCheckNewAnalytics)) { $this->autoCheckNewAnalytics = $autoCheckNewAnalytics; } if (isset($analyticsDashboardDateRange)) { $this->analyticsDashboardDateRange = $analyticsDashboardDateRange; } if (isset($analyticsEnableTimeCollection)) { $this->analyticsEnableTimeCollection = $analyticsEnableTimeCollection; } if (isset($analyticsEnableUserCollection)) { $this->analyticsEnableUserCollection = $analyticsEnableUserCollection; } if (isset($analyticsDashboardDataType)) { $this->analyticsDashboardDataType = $analyticsDashboardDataType; } if (isset($slowServer)) { $this->slowServer = $slowServer; } // V 2.1.10 if (isset($useJoomsefRouter)) { $this->useJoomsefRouter = $useJoomsefRouter; } if (isset($useAcesefRouter)) { $this->useAcesefRouter = $useAcesefRouter; } // V 2.1.11 if (isset($insertShortlinkTag)) { $this->insertShortlinkTag = $insertShortlinkTag; } if (isset($insertRevCanTag)) { $this->insertRevCanTag = $insertRevCanTag; } if (isset($insertAltShorterTag)) { $this->insertAltShorterTag = $insertAltShorterTag; } if (isset($canReadRemoteConfig)) { $this->canReadRemoteConfig = $canReadRemoteConfig; } if (isset($stopCreatingShurls)) { $this->stopCreatingShurls = $stopCreatingShurls; } if (isset($shurlBlackList)) { $this->shurlBlackList = $shurlBlackList; } if (isset($shurlNonSefBlackList)) { $this->shurlNonSefBlackList = $shurlNonSefBlackList; } // V 3.0.0 if (isset($includeContentCat)) { $this->includeContentCat = $includeContentCat; } if (isset($includeContentCatCategories)) { $this->includeContentCatCategories = $includeContentCatCategories; } if (isset($contentCategoriesSuffix)) { $this->contentCategoriesSuffix = $contentCategoriesSuffix; } if (isset($contentTitleIncludeCat)) { $this->contentTitleIncludeCat = $contentTitleIncludeCat; } if (isset($useContactCatAlias)) { $this->useContactCatAlias = $useContactCatAlias; } if (isset($contactCategoriesSuffix)) { $this->contactCategoriesSuffix = $contactCategoriesSuffix; } if (isset($includeContactCat)) { $this->includeContactCat = $includeContactCat; } if (isset($includeContactCatCategories)) { $this->includeContactCatCategories = $includeContactCatCategories; } if (isset($useWeblinksCatAlias)) { $this->useWeblinksCatAlias = $useWeblinksCatAlias; } if (isset($weblinksCategoriesSuffix)) { $this->weblinksCategoriesSuffix = $weblinksCategoriesSuffix; } if (isset($includeWeblinksCat)) { $this->includeWeblinksCat = $includeWeblinksCat; } if (isset($includeWeblinksCatCategories)) { $this->includeWeblinksCatCategories = $includeWeblinksCatCategories; } $this->liveSites = $this->shInitLanguageList(isset($liveSites) ? $liveSites : array(), '', ''); if (isset($alternateTemplate)) { $this->alternateTemplate = $alternateTemplate; } if (isset($useJoomlaRouter)) { $this->useJoomlaRouter = $useJoomlaRouter; } if (isset($slugForUncategorizedContent)) { $this->slugForUncategorizedContent = $slugForUncategorizedContent; } if (isset($slugForUncategorizedContact)) { $this->slugForUncategorizedContact = $slugForUncategorizedContact; } if (isset($slugForUncategorizedWeblinks)) { $this->slugForUncategorizedWeblinks = $slugForUncategorizedWeblinks; } // 3.4 if (isset($enableMultiLingualSupport)) { $this->enableMultiLingualSupport = $enableMultiLingualSupport; } if (isset($enableOpenGraphData)) { $this->enableOpenGraphData = $enableOpenGraphData; } if (isset($ogEnableDescription)) { $this->ogEnableDescription = $ogEnableDescription; } if (isset($ogType)) { $this->ogType = $ogType; } if (isset($ogImage)) { $this->ogImage = $ogImage; } if (isset($ogEnableSiteName)) { $this->ogEnableSiteName = $ogEnableSiteName; } if (isset($ogSiteName)) { $this->ogSiteName = $ogSiteName; } if (isset($ogEnableLocation)) { $this->ogEnableLocation = $ogEnableLocation; } if (isset($ogLatitude)) { $this->ogLatitude = $ogLatitude; } if (isset($ogLongitude)) { $this->ogLongitude = $ogLongitude; } if (isset($ogStreetAddress)) { $this->ogStreetAddress = $ogStreetAddress; } if (isset($ogLocality)) { $this->ogLocality = $ogLocality; } if (isset($ogPostalCode)) { $this->ogPostalCode = $ogPostalCode; } if (isset($ogRegion)) { $this->ogRegion = $ogRegion; } if (isset($ogCountryName)) { $this->ogCountryName = $ogCountryName; } if (isset($ogEnableContact)) { $this->ogEnableContact = $ogEnableContact; } if (isset($ogEmail)) { $this->ogEmail = $ogEmail; } if (isset($ogPhoneNumber)) { $this->ogPhoneNumber = $ogPhoneNumber; } if (isset($ogFaxNumber)) { $this->ogFaxNumber = $ogFaxNumber; } if (isset($fbAdminIds)) { $this->fbAdminIds = $fbAdminIds; } if (isset($insertPaginationTags)) { $this->insertPaginationTags = $insertPaginationTags; } // define default values for seldom used params if (!defined('sh404SEF_PROTECT_AGAINST_DOCUMENT_TYPE_ERROR')) { // SECTION : GLOBAL PARAMETERS for sh404sef --------------------------------------------------------------------- $shDefaultParamsHelp['sh404SEF_PROTECT_AGAINST_DOCUMENT_TYPE_ERROR'] = '// if not 0, urls for pdf documents and rss feeds will be only partially turned into sef urls. //The query string &format=pdf or &format=feed will be still be appended. // This will protect against malfunctions when using some plugins which makes a call // to JFactory::getDocument() from a onAfterInitiliaze handler // At this time, SEF urls are not decoded and thus the document type is set to html instead of pdf or feed // resulting in the home page being displayed instead of the correct document'; $shDefaultParams['sh404SEF_PROTECT_AGAINST_DOCUMENT_TYPE_ERROR'] = 0; /* $shDefaultParamsHelp['sh404SEF_PROTECT_AGAINST_BAD_NON_DEFAULT_LANGUAGE_MENU_HOMELINK'] = '// Joomla mod_mainmenu module forces usage of JURI::base() for the homepage link // On multilingual sites, this causes homepage link in other than default language to // be wrong. If the following parameter is non-zero, such a homepage link // will be replaced by the correct link, similar to www.mysite.com/es/ for instance'; $shDefaultParams['sh404SEF_PROTECT_AGAINST_BAD_NON_DEFAULT_LANGUAGE_MENU_HOMELINK'] = 1; */ $shDefaultParamsHelp['sh404SEF_REDIRECT_IF_INDEX_PHP'] = '// if not 0, sh404SEF will do a 301 redirect from http://yoursite.com/index.php // or http://yoursite.com/index.php?lang=xx to http://yoursite.com/ // this may not work on some web servers, which transform yoursite.com into // yoursite.com/index.php, thus creating and endless loop. If your server does // that, set this param to 0'; $shDefaultParams['sh404SEF_REDIRECT_IF_INDEX_PHP'] = 1; $shDefaultParamsHelp['sh404SEF_NON_SEF_IF_SUPERADMIN'] = '// if superadmin logged in, force non-sef, for testing and setting up purpose'; $shDefaultParams['sh404SEF_NON_SEF_IF_SUPERADMIN'] = 0; $shDefaultParamsHelp['sh404SEF_DE_ACTIVATE_LANG_AUTO_REDIRECT'] = '// set to 1 to prevent 303 auto redirect based on user language // use with care, will prevent language switch to work for users without javascript'; $shDefaultParams['sh404SEF_DE_ACTIVATE_LANG_AUTO_REDIRECT'] = 1; $shDefaultParamsHelp['sh404SEF_CHECK_COMP_IS_INSTALLED'] = '// if 1, SEF URLs will only be built for installed components.'; $shDefaultParams['sh404SEF_CHECK_COMP_IS_INSTALLED'] = 1; $shDefaultParamsHelp['sh404SEF_REDIRECT_OUTBOUND_LINKS'] = '// if 1, all outbound links on page will be reached through a redirect // to avoid page rank leakage'; $shDefaultParams['sh404SEF_REDIRECT_OUTBOUND_LINKS'] = 0; $shDefaultParamsHelp['sh404SEF_PDF_DIR'] = '// if not empty, urls to pdf produced by Joomla will be prefixed with this // path. Can be : \'pdf\' or \'pdf/something\' (ie: don\'t put leading or trailing slashes) // Allows you to store some pre-built PDF in a directory called /pdf, with the same name // as a page. Such a pdf will be served directly by the web server instead of being built on // the fly by Joomla. This will save CPU and RAM. (only works this way if using htaccess'; $shDefaultParams['sh404SEF_PDF_DIR'] = 'pdf'; $shDefaultParamsHelp['SH404SEF_URL_CACHE_TTL'] = '// time to live for url cache in hours : default = 168h = 1 week // Set to 0 to keep cache forever'; $shDefaultParams['SH404SEF_URL_CACHE_TTL'] = 168; $shDefaultParamsHelp['SH404SEF_URL_CACHE_WRITES_TO_CHECK_TTL'] = '// number of cache write before checking cache TTL.'; $shDefaultParams['SH404SEF_URL_CACHE_WRITES_TO_CHECK_TTL'] = 1000; $shDefaultParamsHelp['sh404SEF_SEC_MAIL_ATTACKS_TO_ADMIN'] = '// if set to 1, an email will be send to site admin when an attack is logged // if the site is live, you could be drowning in email rapidly !!!'; $shDefaultParams['sh404SEF_SEC_MAIL_ATTACKS_TO_ADMIN'] = 0; $shDefaultParams['sh404SEF_SEC_EMAIL_TO_ADMIN_SUBJECT'] = 'Your site %sh404SEF_404_SITE_NAME% was subject to an attack'; $shDefaultParams['sh404SEF_SEC_EMAIL_TO_ADMIN_BODY'] = 'Hello !' . "\n\n" . 'This is sh404SEF security component, running at your site (%sh404SEF_404_SITE_URL%).' . "\n\n" . 'I have just blocked an attack on your site. Please check details below : ' . "\n" . '------------------------------------------------------------------------' . "\n" . '%sh404SEF_404_ATTACK_DETAILS%' . "\n" . '------------------------------------------------------------------------' . "\n\n" . 'Thanks for using sh404SEF!' . "\n\n"; $shDefaultParamsHelp['SH404SEF_PAGES_TO_CLEAN_LOGS'] = '// number of pages between checks to remove old log files // if 1, we check at every page request'; $shDefaultParams['SH404SEF_PAGES_TO_CLEAN_LOGS'] = 10000; $shDefaultParamsHelp['SH_VM_ALLOW_PRODUCTS_IN_MULTIPLE_CATS'] = '// SECTION : Virtuemart plugin parameters ---------------------------------------------------------------------------- // set to 1 for products to have requested category name included in url // useful if some products are in more than one category. If param set to 0, // only one category will be used for all pages. Not recommended now that sh404SEF // automatically handle rel=canonical on such pages'; $shDefaultParams['SH_VM_ALLOW_PRODUCTS_IN_MULTIPLE_CATS'] = 1; $shDefaultParamsHelp['sh404SEF_SOBI2_PARAMS_ALWAYS_INCLUDE_CATS'] = '// SECTION : SOBI2 plugin parameters ---------------------------------------------------------------------------- // set to 1 to always include categories in SOBI2 entries // details pages url'; $shDefaultParams['sh404SEF_SOBI2_PARAMS_ALWAYS_INCLUDE_CATS'] = 0; $shDefaultParamsHelp['sh404SEF_SOBI2_PARAMS_INCLUDE_ENTRY_ID'] = '// set to 1 so that entry id is prepended to url'; $shDefaultParams['sh404SEF_SOBI2_PARAMS_INCLUDE_ENTRY_ID'] = 0; $shDefaultParamsHelp['sh404SEF_SOBI2_PARAMS_INCLUDE_CAT_ID'] = '// set to 1 so that category id is prepended to category name'; $shDefaultParams['sh404SEF_SOBI2_PARAMS_INCLUDE_CAT_ID'] = 0; // end of parameters $sef_custom_config_file = sh404SEF_ADMIN_ABS_PATH . 'custom.sef.php'; // read user defined values, possibly recovered while upgrading if (JFile::exists($sef_custom_config_file)) { include $sef_custom_config_file; } // generate string for parameter modification if ($app->isAdmin()) { // only need to modify custom params in back-end $this->defaultParamList = '<?php // custom.sef.php : custom.configuration file for sh404SEF // 3.5.1.1299 - anything-digital.com/sh404sef/seo-analytics-and-security-for-joomla.html // DO NOT REMOVE THIS LINE : if (!defined(\'_JEXEC\')) die(\'Direct Access to this location is not allowed.\'); // DO NOT REMOVE THIS LINE' . "\n"; foreach ($shDefaultParams as $key => $value) { $this->defaultParamList .= "\n"; if (!empty($shDefaultParamsHelp[$key])) { $this->defaultParamList .= $shDefaultParamsHelp[$key] . "\n"; } // echo help text, if any $this->defaultParamList .= '$shDefaultParams[\'' . $key . '\'] = ' . (is_string($value) ? "'{$value}'" : $value) . ";\n"; } } // read user set values for these params and create constants if (!empty($shDefaultParams)) { foreach ($shDefaultParams as $key => $value) { define($key, $value); } } unset($shDefaultParams); unset($shDefaultParamsHelp); } // compatiblity variables, for sef_ext files usage from OpenSef/SEf Advance V 1.2.4.p $this->encode_page_suffix = ''; // if using an opensef sef_ext, we don't let them manage suffix $this->encode_space_char = $this->replacement; $this->encode_lowercase = $this->LowerCase; $this->encode_strip_chars = $this->stripthese; $this->content_page_name = empty($this->pageTexts[Sh404sefFactory::getPageInfo()->shMosConfig_locale]) ? 'Page' : str_replace('%s', '', $this->pageTexts[Sh404sefFactory::getPageInfo()->shMosConfig_locale]); // V 1.2.4.r $this->content_page_format = '%s' . $this->replacement . '%d'; // V 1.2.4.r $shTemp = $this->shGetReplacements(); foreach ($shTemp as $dest => $source) { $this->spec_chars_d .= $dest . ','; $this->spec_chars .= $source . ','; } JString::rtrim($this->spec_chars_d, ','); JString::rtrim($this->spec_chars, ','); }
/** * Recursive file name incrementation until no file with existing name * exists * * @param string $origFileName Initial file name * @param string $newFileName This recursions file name * @param int $version File version * * @return string New file name */ public static function incrementFileName($origFileName, $newFileName, $version) { if (JFile::exists($newFileName)) { $bits = explode('.', $newFileName); $ext = array_pop($bits); $f = implode('.', $bits); $f = JString::rtrim($f, $version - 1); $newFileName = $f . $version . "." . $ext; $version++; $newFileName = self::incrementFileName($origFileName, $newFileName, $version); } return $newFileName; }
/** * This is a better truncate implementation than what we * currently have available in the library. In particular, * on index.php/Banners/Banners/site-map.html JHtml's truncate * method would only return "Article...". This implementation * was taken directly from the Stack Overflow thread referenced * below. It was then modified to return a string rather than * print out the output and made to use the relevant JString * methods. * * @link http://stackoverflow.com/questions/1193500/php-truncate-html-ignoring-tags * @param mixed $html * @param mixed $maxLength */ public static function truncate($html, $maxLength = 0) { $printedLength = 0; $position = 0; $tags = array(); $output = ''; if (empty($html)) { return $output; } while ($printedLength < $maxLength && preg_match('{</?([a-z]+)[^>]*>|&#?[a-zA-Z0-9]+;}', $html, $match, PREG_OFFSET_CAPTURE, $position)) { list($tag, $tagPosition) = $match[0]; // Print text leading up to the tag. $str = JString::substr($html, $position, $tagPosition - $position); if ($printedLength + JString::strlen($str) > $maxLength) { $output .= JString::substr($str, 0, $maxLength - $printedLength); $printedLength = $maxLength; break; } $output .= $str; $lastCharacterIsOpenBracket = JString::substr($output, -1, 1) === '<'; if ($lastCharacterIsOpenBracket) { $output = JString::substr($output, 0, JString::strlen($output) - 1); } $printedLength += JString::strlen($str); if ($tag[0] == '&') { // Handle the entity. $output .= $tag; $printedLength++; } else { // Handle the tag. $tagName = $match[1][0]; if ($tag[1] == '/') { // This is a closing tag. $openingTag = array_pop($tags); $output .= $tag; } else { if ($tag[JString::strlen($tag) - 2] == '/') { // Self-closing tag. $output .= $tag; } else { // Opening tag. $output .= $tag; $tags[] = $tagName; } } } // Continue after the tag. if ($lastCharacterIsOpenBracket) { $position = $tagPosition - 1 + JString::strlen($tag); } else { $position = $tagPosition + JString::strlen($tag); } } // Print any remaining text. if ($printedLength < $maxLength && $position < JString::strlen($html)) { $output .= JString::substr($html, $position, $maxLength - $printedLength); } // Close any open tags. while (!empty($tags)) { $output .= sprintf('</%s>', array_pop($tags)); } $length = JString::strlen($output); $lastChar = JString::substr($output, $length - 1, 1); $characterNumber = ord($lastChar); if ($characterNumber === 194) { $output = JString::substr($output, 0, JString::strlen($output) - 1); } $output = JString::rtrim($output); return $output . '…'; }
/** * Builds an array containing the filters value and condition * * @param string $value initial value * @param string $condition intial $condition * @param string $eval how the value should be handled * * @return array (value condition) */ public function getFilterValue($value, $condition, $eval) { $this->escapeQueryValue($condition, $value); $db = FabrikWorker::getDbo(); if (is_array($value)) { // Ranged search list($value, $condition) = $this->getRangedFilterValue($value); } else { switch ($condition) { case 'notequals': case '<>': $condition = "<>"; // 2 = subquery so dont quote $value = $eval == FABRIKFILTER_QUERY ? '(' . $value . ')' : $db->quote($value); break; case 'equals': case '=': $condition = "="; $value = $eval == FABRIKFILTER_QUERY ? '(' . $value . ')' : $db->quote($value); break; case 'begins': case 'begins with': $condition = "LIKE"; $value = $eval == FABRIKFILTER_QUERY ? '(' . $value . ')' : $db->quote($value . '%'); break; case 'ends': case 'ends with': // @TODO test this with subsquery $condition = "LIKE"; $value = $eval == FABRIKFILTER_QUERY ? '(' . $value . ')' : $db->quote('%' . $value); break; case 'contains': // @TODO test this with subsquery $condition = "LIKE"; $value = $eval == FABRIKFILTER_QUERY ? '(' . $value . ')' : $db->quote('%' . $value . '%'); break; case '>': case '>': case 'greaterthan': $condition = '>'; break; case '<': case '<': case 'lessthan': $condition = '<'; break; case '>=': case '>=': case 'greaterthanequals': $condition = '>='; break; case '<=': case '<=': case 'lessthanequals': $condition = '<='; break; case 'in': $condition = 'IN'; $value = $eval == FABRIKFILTER_QUERY ? '(' . $value . ')' : '(' . $value . ')'; break; case 'not_in': $condition = 'NOT IN'; $value = $eval == FABRIKFILTER_QUERY ? '(' . $value . ')' : '(' . $value . ')'; break; } switch ($condition) { case '>': case '<': case '>=': case '<=': if ($eval == FABRIKFILTER_QUERY) { $value = '(' . $value . ')'; } else { if (!is_numeric($value)) { $value = $db->quote($value); } } break; } // $$$ hugh - if 'noquotes' (3) selected, strip off the quotes again! if ($eval == FABRKFILTER_NOQUOTES) { // $$$ hugh - darn, this is stripping the ' of the end of things like "select & from foo where bar = '123'" $value = JString::ltrim($value, "'"); $value = JString::rtrim($value, "'"); } if ($condition == '=' && $value == "'_null_'") { $condition = " IS NULL "; $value = ''; } } return array($value, $condition); }
/** * Get the root folder for images * * @param string $value Value * * @return string root folder */ protected function rootFolder($value = '') { $rootFolder = ''; $params = $this->getParams(); $canSelect = $params->get('image_front_end_select', '0') && JString::substr($value, 0, 4) !== 'http'; $defaultImg = $params->get('imagepath'); // Changed first || from a && - http://fabrikar.com/forums/index.php?threads/3-1rc1-image-list-options-bug.36585/#post-184266 if ($canSelect || (JFolder::exists($defaultImg) || JFolder::exists(COM_FABRIK_BASE . $defaultImg))) { $rootFolder = $defaultImg; } // $$$ hugh - tidy up a bit so we don't have so many ///'s in the URL's $rootFolder = JString::ltrim($rootFolder, '/'); $rootFolder = JString::rtrim($rootFolder, '/'); $rootFolder = $rootFolder === '' ? '' : $rootFolder . '/'; return $rootFolder; }
protected function isCacheable($uri = '') { if (empty($uri)) { $uri = JFactory::getURI()->toString(); } $uriSchemeHostPortPathParts = JFactory::getURI()->getScheme() . '://' . JFactory::getURI()->getHost() . JFactory::getURI()->getPort() . JFactory::getURI()->base(true); $relativeUriPathToCompare = str_replace($uriSchemeHostPortPathParts, '', $uri); $relativeUriPathToCompare = str_replace('index.php/', '', $relativeUriPathToCompare); $allowedRelativeUriPaths = array(); if ($this->params->get('homepagecache', 1)) { // Add relative paths that could be used for the homepage: $allowedRelativeUriPaths[] = ''; $allowedRelativeUriPaths[] = '/'; $allowedRelativeUriPaths[] = 'index.php'; } if ($this->params->get('priority_one_cache_switch', 1)) { // Add switchable on/off Priority One Cache Relative URLs: $priorityOneCache = $this->params->get('priority_one_cache', ''); $priorityOneCache = JString::trim($priorityOneCache); if (!empty($priorityOneCache)) { $priorityOneUris = explode("\r\n", $priorityOneCache); foreach ($priorityOneUris as $priorityOneUri) { $priorityOneUri = JString::trim($priorityOneUri); $priorityOneUri = str_replace('index.php/', '', $priorityOneUri); $priorityOneUri = JString::ltrim($priorityOneUri, '/'); $priorityOneUri = JString::rtrim($priorityOneUri, '/'); $allowedRelativeUriPaths[] = $priorityOneUri; } } } if ($this->params->get('priority_two_cache_switch', 1)) { // Add switchable on/off Priority Two Cache Relative URLs: $priorityTwoCache = $this->params->get('priority_two_cache', ''); $priorityTwoCache = JString::trim($priorityTwoCache); if (!empty($priorityTwoCache)) { $priorityTwoUris = explode("\r\n", $priorityTwoCache); foreach ($priorityTwoUris as $priorityTwoUri) { $priorityTwoUri = JString::trim($priorityTwoUri); $priorityTwoUri = str_replace('index.php/', '', $priorityTwoUri); $priorityTwoUri = JString::ltrim($priorityTwoUri, '/'); $priorityTwoUri = JString::rtrim($priorityTwoUri, '/'); $allowedRelativeUriPaths[] = $priorityTwoUri; } } } if ($this->params->get('priority_three_cache_switch', 1)) { // Add switchable on/off Priority Three Cache Relative URLs: $priorityThreeCache = $this->params->get('priority_three_cache', ''); $priorityThreeCache = JString::trim($priorityThreeCache); if (!empty($priorityThreeCache)) { $priorityThreeUris = explode("\r\n", $priorityThreeCache); foreach ($priorityThreeUris as $priorityThreeUri) { $priorityThreeUri = JString::trim($priorityThreeUri); $priorityThreeUri = str_replace('index.php/', '', $priorityThreeUri); $priorityThreeUri = JString::ltrim($priorityThreeUri, '/'); $priorityThreeUri = JString::rtrim($priorityThreeUri, '/'); $allowedRelativeUriPaths[] = $priorityThreeUri; } } } $relativeUriPathToCompare = JString::ltrim($relativeUriPathToCompare, '/'); $relativeUriPathToCompare = JString::rtrim($relativeUriPathToCompare, '/'); $result = in_array($relativeUriPathToCompare, $allowedRelativeUriPaths); if (!$result) { if ($this->params->get('allow_wildcards', 0)) { foreach ($allowedRelativeUriPaths as $allowedRelativeUriPath) { $wildcardResult = fnmatch($allowedRelativeUriPath, $relativeUriPathToCompare); if ($wildcardResult) { $result = $wildcardResult; break; } } } } return $result; }