Need a solution? Call Us Now!
1800 880 841

Joomla Coding Examples - Joomsef

Joomsef 1.5.1 Meta Generator Patch - Joomla SEO

Background
This is my latest patch for the JoomSEF component.  Fixes meta generator and hidden advert in the output HTML.  It may well be one of the best components for SEF but it really annoys me that Artio choose to put adverts in the output HTML.  Clearly SEF is vital in Search Engine Optimisation(SEO), reason, because search engines much prefer nice English language URL's but they hate adverts and hidden text.  Its a great little patch from Australian Joomla SEO Company, Kanga Internet.


The Problem
The problem with Joomsef is that although it is great it has a down side.  The standard Joomsef component has advertising used in it and this is produced in the form of the Meta Generator tag in the pages displayed.  This can affect website ranking in search engines.  It also bloats the meta tag information with advertising.  There can also be output at the bottom of the pages that have a link to the Joomsef website. 

The Joomsef 1.5.1 version still has a file called "signature.b64" included with it.  This file is checked in every call or click on the website links.  The signature file is a base 64 encoded string that, when decoded, contains the a HTML link to Artio.  Simply removing the base 64 file will not work and removing the mention of the base 64 file from within the calling PHP code will not work so I have modified the code to not even look for the file and removed all checking for it.  The code is quicker as it doesnt do a all the processing, decoding, placement, checking and the display of the advert that would normally happen on every click.

During the Artio install it actually mentions the inclusion of these adverts: "The latest open-source version of JoomSEF may contain links to ARTIO webpages or some of the JoomSEF development sponsors. Based on our policy, the older versions of JoomSEF available from our pages will be kept free of these links. You can also get the latest version without links of the JoomSEF from our webshop"

To gain a latest version without these sponsors shown in the output code you have to pay for it , that is unless you follow the directions in this patch at your own free will because this patch is.


The Solution
You need to locate the file "/components/com_sef/sef.php" and open it in a text editor.

Replace the contents of the whole file with the following.

<?php
/**
 * SEF module for Joomla!
 *
 * @author      $Author: michal $
 * @copyright   ARTIO s.r.o., http://www.artio.cz
 * @package     JoomSEF
 * @version     $Name$, ($Revision: 4994 $, $Date: 2005-11-03 20:50:05 +0100 (??t, 03 XI 2005) $)
 */

// Security check to ensure this file is being included by a parent file.
if (!defined('_VALID_MOS')) die('Direct Access to this location is not allowed.');

$debug = 0;
// IIS patch.
if (isset($_SERVER['HTTP_X_REWRITE_URL'])) {
    $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
}
// OpenSEF patch.
define('_OPENSEF', 1);

if ($mosConfig_sef) {
    // VirtueMart redirection hack
    if( file_exists($GLOBALS['mosConfig_absolute_path'].'/components/com_virtuemart/virtuemart.php') ) {
        @session_start();
        $_SESSION['vmhack'] = 1;
    }

    $sefDirAdmin = $GLOBALS['mosConfig_absolute_path'].'/administrator/components/com_sef/';

    // Load language file.
    if (file_exists($sefDirAdmin.'language/'.$mosConfig_lang.'.php')){
        include($sefDirAdmin.'language/'.$mosConfig_lang.'.php');
    }
    else {
        include($sefDirAdmin.'language/english.php');
    }

    // load config data
    $sef_config_class = $sefDirAdmin.'sef.class.php';
    $sef_config_file  = $sefDirAdmin.'config.sef.php';

    if (!is_readable($sef_config_file)) die(_COM_SEF_NOREAD."($sef_config_file)<br />"._COM_SEF_CHK_PERMS);
    if (is_readable($sef_config_class)) require_once($sef_config_class);
    else die(_COM_SEF_NOREAD."( $sef_config_class )<br />"._COM_SEF_CHK_PERMS);

    $sefConfig = new SEFConfig();


    // check for kind of SEF or no SEF at all
    // test if this is Joomla! style URL
    if (strstr($_SERVER['REQUEST_URI'], 'index.php/content/')
    || strstr($_SERVER['REQUEST_URI'], '/content/')
    || strstr($_SERVER['REQUEST_URI'], 'index.php/component/option,')
    || strstr($_SERVER['REQUEST_URI'], '/component/option,')) {
        require_once('functions.php');
        decodeurls_mambo();
    }
    // or TIM style url
    elseif (strstr($_SERVER['REQUEST_URI'], 'index.php/view/')) {
        require_once('functions.php');
        decodeurls_tim();
    }
    // otherwise operate as with JoomSEF URL
    else {
    }

        $sef404 = $GLOBALS['mosConfig_absolute_path']."/components/com_sef/joomsef.php";
        if (is_readable($sef404)) {
            $index = str_replace($GLOBALS['mosConfig_live_site'], '', $_SERVER['PHP_SELF']);
            $base = dirname($index);


            if ($base == '//') $base = '/';
            if (substr($base , -1) != '/' || $base == '') $base .= '/';

            $index = basename($index);
            $URI = array();
            if (isset($_SERVER['REQUEST_URI'])) {
                //strip out the base
                $REQUEST = str_replace($GLOBALS['mosConfig_live_site'], '', $_SERVER['REQUEST_URI']);
                $REQUEST = preg_replace("/^".preg_quote($base,'/').'/', '', $REQUEST);
                $URI = new Net_URL($REQUEST);
            }
            else {
                $QUERY_STRING = isset($_SERVER['QUERY_STRING']) ? '?'.$_SERVER['QUERY_STRING'] : '';
                $URI = new Net_URL($index.$QUERY_STRING);
            }

            if ($debug) {
                echo('<pre>');
                print_r($URI);
                print_r($_SERVER);
                echo('</pre>');
                die();
            }

            // Make sure host name matches our config, we need this later.
            if (strpos($GLOBALS['mosConfig_live_site'], $URI->host) === false) {
                header('HTTP/1.0 301 Moved Permanently');
                header('Location: '.$GLOBALS['mosConfig_live_site']);
            }
            else include_once($sef404);

            if (($URI->path == $base)
            || ($URI->path == ($base.$index))
            || (@$option == 'com_frontpage')) {

            }
            else {
            }
        }
        else die(_COM_SEF_NOREAD."($sef404)<br />"._COM_SEF_CHK_PERMS);
   
}
else {

    /**
     * Translate URL.
     *
     * @param  string $string
     * @return string
     */
    function sefRelToAbs($string)
    {
        return $string;
    }

}
?>

Or you can download the full Joomsef modified component here.

More about web development

Joomla Services

Joomla Brisbane
Joomla Web Design
Joomla Sydney
Joomla Melbourne
Joomla Designer
Joomla Design
Joomla SEO
Joomla Development
Joomla Perth
Joomla Developer
Joomla Company
Joomla Websites
 
Want to know more?Call 1300 880 841 or click here to contact us.

Featured Portfolio Websites

Sex Toys 24/7 website banner FRISKY ADULT SHOP