maternal
Welcome, Guest. Please login or register.
Did you miss your activation email?

 
Advanced search

18655 Posts in 5531 Topics- by 9335 Members - Latest Member: Rythorn

May 23, 2013, 12:05:46 PM
  Show Posts
Pages: [1]
1  JoomGallery 1.5 MVC / JoomGallery MVC ALPHA / Re: Joomla Core SEF Problem (Detail view images BROKEN!) on: May 19, 2010, 02:37:30 PM
Hi, thanks for your reply
this plug-in is a part of nice component for SEO optimize (RSSEO)
that crowl and edit meta data for pages
sh404sef had many problems, i use joomla core sef for URLs
and use this component for edit meta tags and keywords
it's necessary for me,
but the main reason is

i think in NICE joomgallery component
it's important that your component works perfect with other
components and plug-ins,
also i know that is probably a non-compatibility from
this plug-in.
Code:
while (1=1) {
Thank You Chraneco
}
Smile
2  JoomGallery 1.5 MVC / JoomGallery MVC ALPHA / Re: Joomla Core SEF Problem (Detail view images BROKEN!) on: May 19, 2010, 10:43:10 AM
Hi
Thanks for your reply
the problem is with RSSEO System Plugin,
the code below is the rsseo.php plugin:
Code:
<?php
/**
* @version 1.0.0
* @package RSSEO! 1.0.0
* @copyright (C) 2009 www.rsjoomla.com
* @license GPL, http://www.gnu.org/licenses/gpl-2.0.html
*/

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport( 'joomla.plugin.plugin' );

/**
 * RSSeo system plugin
 */
class plgSystemRsseo extends JPlugin
{

/**
         * Constructor
         *
         * For php4 compatability we must not use the __constructor as a constructor for plugins
         * because func_get_args ( void ) returns a copy of all passed arguments NOT references.
         * This causes problems with cross-referencing necessary for the observer design pattern.
         *
         * @access      protected
         * @param       object  $subject The object to observe
         * @param       array   $config  An array that holds the plugin configuration
         * @since       1.0
         */
        function plgSystemRsseo( &$subject, $config )
        {
                parent::__construct( $subject, $config);
               
// load plugin parameters
$this->_plugin = & JPluginHelper::getPlugin('system', 'rsseo');
$this->_params = new JParameter($this->_plugin->params);
        }


/**
         * Do something onAfterInitialise
         */
function onAfterInitialise()
{
$db = JFactory::getDBO();
$app =& JFactory::getApplication();
$document =& JFactory::getDocument();
$u =& JURI::getInstance('SERVER');
$config = new JConfig();
$sef = $config->sef;


if($app->getName() == 'site')
{

$genabled = $this->_params->get('enable','0');
$type = $this->_params->get( 'type','google-site-verification');
$gcontent = $this->_params->get( 'content' );
if($genabled == 1)
{
$document->setMetaData($type, $gcontent);
}

$yenabled = $this->_params->get('enabley','0');
$ycontent = $this->_params->get( 'contenty' );
if($yenabled == 1)
{
$document->setMetaData('y_key', $ycontent);
}

$benabled = $this->_params->get('enableb','0');
$bcontent = $this->_params->get( 'contentb' );
if($benabled == 1)
{
$document->setMetaData('msvalidate.01', $bcontent);
}


//get the current url of the page
if($sef == 0)
$curl = $u->getScheme().'://'.$u->getHost().JRequest::getURI();
else $curl = JURI::current();


//load the redirects
$db->setQuery("SELECT * FROM #__rsseo_redirects WHERE published = 1 ");
$redirects = $db->loadObjectList();

//redirect method

foreach($redirects as $redirect)
{
if($this->_getRoute($redirect->RedirectFrom) == $curl )
{
if($redirect->RedirectType == 301)
{
header("HTTP/1.1 301 Moved Permanently");
header("Location: ".$this->_getRoute($redirect->RedirectTo));
exit;
} else if ($redirect->RedirectType == 302)
{
header("Location: ".$this->_getRoute($redirect->RedirectTo));
exit;
}
}
}
}


//canonicalization
$enablecan = $this->_params->get('enablecan','0');
$host = $this->_params->get('domain','');
$host = str_replace(array('http://','https://'),'',$host);

if($enablecan == 1 && trim($host) != '')
{

if(@$_SERVER['HTTP_HOST'] == $host || @$_SERVER['SERVER_NAME'] == $host) {
return true;
}

$protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://';

$url = $protocol . $host . $_SERVER['REQUEST_URI'];
header("HTTP/1.1 301 Moved Permanently");
header('Location: '. $url);
exit();
}

}



        /**
         * Do something onAfterDispatch
         */
        function onAfterDispatch()
        {
$app =& JFactory::getApplication();
$db = JFactory::getDBO();
$doc =& JFactory::getDocument();
$u =& JURI::getInstance('SERVER');
$config = new JConfig();
$sef = $config->sef;

if($app->getName() == 'site')
{

$base = JURI::base();

//see if the auto-crawler option is enabled
$db->setQuery("SELECT ConfigValue FROM #__rsseo_config WHERE ConfigName = 'crawler.enable.auto'");
$enable = $db->loadResult();

if($enable == 1)
{
//get the ignored links
$db->setQuery("SELECT ConfigValue FROM #__rsseo_config WHERE ConfigName = 'crawler.ignore'");
$ignored = $db->loadResult();
$ignored = str_replace("\r",'',$ignored);
$ignored = explode("\n",$ignored);


//get the links of the page requested
if($sef == 0)
{
$curl = $u->getScheme().'://'.$u->getHost().JRequest::getURI();
$linkToCheck = str_replace(array($base,'&'),array('','&amp;'),$curl);
} else
{
//$curl = JURI::current();
$curl = $u->getScheme().'://'.$u->getHost().JRequest::getURI();
$linkToCheck = str_replace(array($base,'&'),array('','&amp;'),$curl);
}


//see if the current page is already crawled
$db->setQuery("SELECT IdPage FROM #__rsseo_pages WHERE PageURL = '".$linkToCheck."'");
$result = $db->loadResult();


//if the page hasn`t been crawled , we crawl it
if(empty($result) && !$this->_is_ignored($linkToCheck, $ignored))
{
$db->setQuery("INSERT INTO #__rsseo_pages SET PageURL = '".$db->getEscaped($linkToCheck)."', PageTitle ='".$db->getEscaped($doc->getTitle())."', PageKeywords ='".$db->getEscaped($doc->getMetaData('keywords'))."', PageDescription = '".$db->getEscaped($doc->getDescription())."', PageSitemap=0, PageCrawled=0, PageLevel = 127");
$db->query();
}
}

//get the current link of the page
if($sef == 1)
{
$db->setQuery("SELECT `published` FROM `#__plugins` WHERE `element` = 'jfrouter' AND `folder` = 'system' ");
$JRouterEnable = $db->loadResult();

// joomfish hack
if(file_exists(JPATH_SITE.DS.'plugins'.DS.'system'.DS.'jfrouter.php') && $JRouterEnable)
{
if($u->getPath()=='/')
$u->setPath('/');
else
$u->setPath("/".JRequest::getVar('lang','en','get')."/".$u->getPath());
$u->delVar("lang");
}

$host = $u->getScheme().'://'.$u->getHost().JRequest::getURI();
$host = str_replace($base,'',$host);

} else
{
$host = $u->getScheme().'://'.$u->getHost().JRequest::getURI();
$host = str_replace($base,'',$host);

$ampHost = str_replace('&','&amp;',$host);

$db->setQuery("SELECT PageURL FROM #__rsseo_pages WHERE PageURL = '".$ampHost."' AND published = 1 LIMIT 1");
$result = $db->loadResult();

if(strpos($result,".php?") === FALSE) $sef_in_db = 1; else $sef_in_db = 0;
if(strpos($host,".php?") === FALSE) $sef_url = 1; else $sef_url = 0;
if($sef_url == 0 && $sef_in_db == 1)
{
$app = &JFactory::getApplication();
$router = &$app->getRouter();
$router->setMode(JROUTER_MODE_SEF);
$root = JURI::root(true);
$host = JRoute::_($host);
$host = str_replace($root,'',$host);
$router->setMode(JROUTER_MODE_RAW);
}
}


if (substr($host, 0, 1) == '/')
$host = substr($host, 1, strlen($host));

//load the page details
$db->setQuery("SELECT IdPage, PageModified, PageTitle , PageKeywords , PageDescription, PageCrawled , PageLevel FROM #__rsseo_pages WHERE PageURL = '".str_replace('&','&amp;',$host)."' AND published = 1 LIMIT 1");
$page = $db->loadObject();

//set the new Title , MetaKeywords , and the Description
if(!empty($page) && (($page->PageCrawled == 1 || $page->PageLevel == 0) || $page->PageModified == 1 ))
{
if(!($page->PageLevel == 0 && $page->PageTitle == null))
{
$doc->setTitle(html_entity_decode($page->PageTitle));
$doc->setMetaData('title',html_entity_decode($page->PageTitle));
$doc->setMetaData('keywords',html_entity_decode($page->PageKeywords));
$doc->setDescription(html_entity_decode($page->PageDescription));
}
}
}

$this->rsseofunction();
        }

        /**
         * Keywords Replacement and Redirect function
         */
        function rsseofunction()
        {
$app =& JFactory::getApplication();
$db = JFactory::getDBO();
$doc = JFactory::getDocument();
$u =& JURI::getInstance('SERVER');
$config = new JConfig();
$sef = $config->sef;


if($app->getName() == 'site')
{

//get the body of the component
$body = $doc->getBuffer();
$body = !isset($body['component']['']) ? $body : $body['component'][''] ;


$db->setQuery("SELECT ConfigValue FROM #__rsseo_config WHERE ConfigName = 'component.heading'");
$componentHeading = $db->loadResult();
$db->setQuery("SELECT ConfigValue FROM #__rsseo_config WHERE ConfigName = 'content.heading'");
$contentHeading = $db->loadResult();

$CompStartElement = '<'.$componentHeading.'>';
$CompEndElement   = '</'.$componentHeading.'>';
$ContStartElement = '<'.$contentHeading.'>';
$ContEndElement   = '</'.$contentHeading.'>';

//search for the contentheading and componentheading class
preg_match_all('#<div class="contentheading">(.*?)<\/div>#is', $body, $content);
preg_match_all('#<div class="componentheading">(.*?)<\/div>#is', $body, $component);

$contentCounter = count($content[0]);
$componentCounter = count($component[0]);

//replace the contentheading class
if($contentHeading != '0')
for($i=0;$i<$contentCounter;$i++)
{
$body = str_replace($content[0][$i],$ContStartElement.$content[1][$i].$ContEndElement,$body);
}

//replace the componentheading classa
if($componentHeading != '0')
for($i=0;$i<$componentCounter;$i++)
{
$body = str_replace($component[0][$i],$CompStartElement.$component[1][$i].$CompEndElement,$body);
}

//is the keyword replacement on
$db->setQuery("SELECT ConfigValue FROM #__rsseo_config WHERE ConfigName = 'enable.keyword.replace'");
$enableKeywords = $db->loadResult();

//replace the keywords
if($enableKeywords == 1)
{
//get all the keywords
$db->setQuery("SELECT Keyword , KeywordBold ,KeywordUnderline , KeywordLink FROM #__rsseo_keywords ORDER BY CHAR_LENGTH(Keyword) DESC");
$keywords = $db->loadObjectList();


if(!empty($keywords))
{
//get all the links in the body
preg_match_all('#<a href=\"(.*?)\">(.*?)<\/a>#i', $body, $links);
foreach($links[0] as $i => $link)
{
$body = str_replace($link,'{rsseo '.$i.'}', $body);
}

//replacement of the keywords
foreach($keywords as $keyword)
if(strpos($body, $keyword->Keyword) !== FALSE)
{
$body = $this->keywordReplace($body, $keyword->Keyword, $this->_setOptions($keyword->Keyword,$keyword->KeywordBold,$keyword->KeywordUnderline,$keyword->KeywordLink));

preg_match_all('#<a href=\"(.*?)\">(.*?)<\/a>#i', $body, $links2[$keyword->Keyword]);
if(!empty($links2))
foreach($links2[$keyword->Keyword][0] as $i => $link)
{
$body = str_replace($link,'{rsseo '.md5($keyword->Keyword).' '.$i.'}', $body);
}
}

foreach ($links[0] as $i => $link)
{
$body = str_replace('{rsseo '.$i.'}', $link, $body);
}

foreach ($keywords as $keyword)
if (!empty($links2[$keyword->Keyword][0]))
foreach ($links2[$keyword->Keyword][0] as $i => $link)
$body = str_replace('{rsseo '.md5($keyword->Keyword).' '.$i.'}', $link, $body);
}
}

$doc->setBuffer($body,'component');
}
        }


//function for Routing the url

function _getRoute($url)
{
$config = new JConfig();
$sef = $config->sef;
$u =& JURI::getInstance('SERVER');
$host = $u->getScheme().'://'.$u->getHost();
if(strpos($url,".php?") === FALSE) $sef_url = 1; else $sef_url = 0;

if($sef == 1 && $sef_url == 1)
return JURI::root().$url;
else if ($sef == 1 && $sef_url == 0)
return $host.JRoute::_($url);
else if ($sef == 0 && $sef_url == 0)
return JURI::root().$url;
else if ($sef == 0 && $sef_url == 1)
return JURI::root().$url;
}


function _is_ignored($url, $pattern_array)
{
$return = false;
if (is_array($pattern_array))
foreach ($pattern_array as $pattern)
{
$pattern = str_replace('&', '&amp;', $pattern);
$pattern = $this->_transform_string($pattern);
preg_match_all($pattern, $url, $matches);

if (count($matches[0]) > 0)
$return = true;
}
return $return;
}

function _transform_string($string)
{
$string = preg_quote($string, '/');
$string = str_replace(preg_quote('{*}', '/'), '(.*)', $string);

$pattern = '#\\\{(\\\\\?){1,}\\\}#';
preg_match_all($pattern, $string, $matches);
if (count($matches[0]) > 0)
foreach ($matches[0] as $match)
{
$count = count(explode('\?', $match)) - 1;
$string = str_replace($match, '(.){'.$count.'}', $string);
}

return '#'.$string.'#';
}

//add custom tags to the keyword
function _setOptions($text,$bold = '0',$underline = '0',$link = '')
{
if($bold == '1')
{
$startB = '<strong>';
$endB = '</strong>';
} elseif($bold == '2')
{
$startB = '<b>';
$endB = '</b>';
} elseif($bold == '0')
{
$startB = '';
$endB = '';
}

if ($underline == '1')
{
$startU = '<u>';
$endU = '</u>';
} elseif ($underline)
{
$startU = '';
$endU = '';
} else {
$startU = '';
$endU = '';
}

if($link != '' && strpos($link,'http://') !== FALSE)
{
return $startB.$startU.'<a href="'.$link.'" target="_blank">'.$text.'</a>'.$endU.$endB;
} elseif ($link =='' || strpos($link,'http://') === FALSE)
{
return $startB.$startU.$text.$endU.$endB;
}

}

//function to replace the keywords
function keywordReplace($bodyText, $searchTerm, $replaceWith)
{
$db = JFactory::getDBO();
$newText = '';
$i = -1;
$lcSearchTerm = strtolower($searchTerm);
$lcBodyText = strtolower($bodyText);

$db->setQuery("SELECT ConfigValue FROM #__rsseo_config WHERE ConfigName = 'approved.chars'");
$chars = $db->loadResult();

while (strlen($bodyText) > 0) {

//Get index of search term
$i = $this->_indexOf($lcBodyText, $lcSearchTerm, $i+1);

if ($i < 0) {
$newText .= $bodyText;
$bodyText = '';
} else {
// skip anything inside an HTML tag
if (($this->_lastIndexOf($bodyText,">",$i) >= $this->_lastIndexOf($bodyText,"<",$i)))
{
// skip anything inside a <script> or <style> block
if (($this->_lastIndexOf($lcBodyText,"/script>",$i) >= $this->_lastIndexOf($lcBodyText,"<script",$i)) && ($this->_lastIndexOf($lcBodyText,"/style>",$i) >= $this->_lastIndexOf($lcBodyText,"<style",$i)) && ($this->_lastIndexOf($lcBodyText,"/button>",$i) >= $this->_lastIndexOf($lcBodyText,"<button",$i)) && ($this->_lastIndexOf($lcBodyText,"/textarea>",$i) >= $this->_lastIndexOf($lcBodyText,"<textarea",$i)) && ($this->_lastIndexOf($lcBodyText,"/select>",$i) >= $this->_lastIndexOf($lcBodyText,"<select",$i)) && ($this->_lastIndexOf($lcBodyText,"/a>",$i) >= $this->_lastIndexOf($lcBodyText,"<a",$i)) )
{

$word = substr($bodyText, $i - 1, strlen($searchTerm) + 2);
$firstChar = substr($word, 0, 1);
$lastChar = substr($word, -1);

if( (strpos($chars,$firstChar) !== FALSE) && (strpos($chars,$lastChar) !== FALSE))
{
$newText .= substr($bodyText, 0, $i) . $replaceWith;
$bodyText = substr($bodyText, $i+strlen($searchTerm));
$lcBodyText = strtolower($bodyText);
$i = -1;
}
}
}
}
}
return $newText;
}

function _indexOf($text, $search, $i)
{
$return = strpos($text, $search, $i);

if ($return === false)
$return = -1;

return $return;
}

function _lastIndexOf($text, $search, $i)
{
$length = strlen($text);
$i = ($i > 0)?($length - $i):abs($i);
$pos = strpos(strrev($text), strrev($search), $i);
return ($pos === false)? -1 : ( $length - $pos - strlen($search) );
}

}

How can i optimize this code with joomgallery or reverse,
 how can i change joomgallery route.php to work with this plug in sir

Thank you in advance
3  JoomGallery 1.5 MVC / JoomGallery MVC ALPHA / Joomla Core SEF Problem (Detail view images BROKEN!) on: May 16, 2010, 07:06:59 AM
Hi
i have JoomGallery 1.5.5 MVC BETA 2
i use joomla core SEF,
in image detail view images broken, i think core SEF eats som parts of link
i have check aliases for images in categories, everything ok but images broken!

my gallery URL: http://www.talanews.com/fa/jurnal.html
Code:
##  Can be commented out if causes errors, see notes above.
Options +FollowSymLinks

#
#  mod_rewrite in use

RewriteEngine On

Redirect 301 /index.php http://www.talanews.com/fa/

########## Begin - Rewrite rules to block out some common exploits
## If you experience problems on your site block out the operations listed below
## This attempts to block the most common type of exploit `attempts` to Joomla!
#
## Deny access to extension xml files (uncomment out to activate)
#<Files ~ "\.xml$">
#Order allow,deny
#Deny from all
#Satisfy all
#</Files>
## End of deny access to extension xml files
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
# Block out any script trying to base64_encode crap to send via URL
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
# Block out any script that includes a <script> tag in URL
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Send all blocked request to homepage with 403 Forbidden error!
RewriteRule ^(.*)$ index.php [F,L]
#
########## End - Rewrite rules to block out some common exploits

RewriteBase /fa
# Rule for duplicate content removal : www.domain.com vs domain.com
RewriteCond %{HTTP_HOST} !^www.talanews.com [NC]
RewriteRule ^(.*)$ http://www.talanews.com/fa/$1 [QSA,L,R=301]

########## Begin - Joomla! core SEF Section
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$  [NC]
RewriteRule (.*) index.php
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
#
########## End - Joomla! core SEF Section

4  JoomGallery 1.5 MVC / Interaction with other components / Re: Joomla core SEF in new version? on: May 14, 2010, 11:45:53 AM
Hi
i have JoomGallery 1.5.5 MVC BETA 2
i use joomla core SEF,
in image detail view images broken, i think core SEF eats som parts of link
i have check aliases for images in categories, everything ok but images broken!

my gallery URL: http://www.talanews.com/fa/jurnal.html
Code:
##  Can be commented out if causes errors, see notes above.
Options +FollowSymLinks

#
#  mod_rewrite in use

RewriteEngine On

Redirect 301 /index.php http://www.talanews.com/fa/

########## Begin - Rewrite rules to block out some common exploits
## If you experience problems on your site block out the operations listed below
## This attempts to block the most common type of exploit `attempts` to Joomla!
#
## Deny access to extension xml files (uncomment out to activate)
#<Files ~ "\.xml$">
#Order allow,deny
#Deny from all
#Satisfy all
#</Files>
## End of deny access to extension xml files
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
# Block out any script trying to base64_encode crap to send via URL
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
# Block out any script that includes a <script> tag in URL
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Send all blocked request to homepage with 403 Forbidden error!
RewriteRule ^(.*)$ index.php [F,L]
#
########## End - Rewrite rules to block out some common exploits

RewriteBase /fa
# Rule for duplicate content removal : www.domain.com vs domain.com
RewriteCond %{HTTP_HOST} !^www.talanews.com [NC]
RewriteRule ^(.*)$ http://www.talanews.com/fa/$1 [QSA,L,R=301]

########## Begin - Joomla! core SEF Section
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$  [NC]
RewriteRule (.*) index.php
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
#
########## End - Joomla! core SEF Section

5  JoomGallery 1.5 MVC - Extensions / Modules / JoomImages (for 1.5.5 MVC BETA2) Thumbs Broken - Core Joomla SEF Problem on: April 19, 2010, 08:16:32 AM
Hi
mod_joomimg has some problems with "Core Joomla SEF".
in home page (www.xxx.com/) thumbs show and everything is ok
but in other child pages and content pages, thumbs show broken.
for example
broken images URL is: http://www.xxx.com/articles/reports/13.raw?type=thumb&option=com_joomgallery
correct images URL in main page is: http://www.xxx.com/index.php?view=image&format=raw&type=thumb&id=13&option=com_joomgallery

i'm using mod_rewrite engine, sef is ENABLED and i'm using joomla 1.5.15 .htaccess file
!!!!???
Pages: [1]
Theme orange-lt created by panic

Bad Behavior has blocked 918 access attempts in the last 7 days.

maternal