BLOG:CMS :: Support Forum

Support Forum for BLOG:CMS

You are not logged in.

#1 14.08.2004 21:15

Radek Hulán
Site Admin
From: Prague, Czech Republic
Registered: 17.03.2004
Posts: 2509
Website

NP_SEO

This plugin will convert:

* external links in articles
* external links in comments
* external smart user links <%userlink%>

into SEO optimized URLs, like http://mydomain.com/?url=http://yourdomain.com

file /redirect/index.php

Code:

<?php

function undoMagic($data) {
    return get_magic_quotes_gpc() ? stripslashes($data) : $data;
}
header('Location: '.undoMagic($_GET['url']));

?>

file /nucleus/plugins/NP_SEO.php:

Code:

<?php

/*
 ********************************
  (c) Radek HULAN
  http://hulan.info/blog/
 ********************************/

class NP_SEO extends NucleusPlugin {

var $server,$redirect;

    function getName( ){return 'SEO';} 
    function getAuthor( ){return 'Radek HULAN';} 
    function getURL( ){return 'http://hulan.info/blog/';} 
    function getVersion( ){return '1.0';} 
    function getEventList( ){return array('PreComment','PreItem');} 
    function getDescription( ){
      return 'This plugin will convert all external links in article, comment, and userlinks '.
             'into http://yourdomain/?url=http://externaldomain to achieve better page ranks';
    } 

    function install( ){
        $this->createOption("url", "Redirect URL (with index.php)", "text", "/redirect/");
        $this->createOption("item", "Redirect articles:", "yesno", "yes");
        $this->createOption("comment", "Redirect comments:", "yesno", "yes");
        $this->createOption("userlink", "Redirect smart user link in comments:", "yesno", "yes");
    }

    function init(){
      global $CONF;
      $this->server = $CONF['IndexURL'];
      $this->redirect = $this->getOption('url');
      $this->_item = ($this->getOption("item")=='yes');
      $this->_comment = ($this->getOption("comment")=='yes');
      $this->_userlink = ($this->getOption("userlink")=='yes');
    }

    function event_PreItem( $data){
      // article body and more
      $parts=array('body','more');
      if ($this->_item) foreach ($parts as $part) $this->doReplace($data['item']->$part);
    } 

      function event_PreComment($data) {
        // comment body
      if ($this->_comment)  $this->doReplace($data['comment']['body']);
      // smart user link
      if ($this->_userlink) {
      if (strstr($data['comment']['userlinkraw'],$this->server) || 
         ( !strstr($data['comment']['userlinkraw'],'http:/') && 
           !strstr($data['comment']['userlinkraw'],'https:/') &&
           !strstr($data['comment']['userlinkraw'],'ftp:/') ) ||
         strstr($data['comment']['userlinkraw'],'mailto:')
      ) ; else
        $data['comment']['userlinkraw'] = $this->redirect.'?url='.$data['comment']['userlinkraw'];
      }
    }

    function doReplace(&$text){
      $text = preg_replace_callback(
        '/<a(.*?)href=[\"|\'](.*?)[\"|\']/',
        array(&$this, 'myLink'),
        $text);
    }

    function myLink($matches){
      if (strstr($matches[2],$this->server) || 
         ( !strstr($matches[2],'http:/') && 
           !strstr($matches[2],'https:/') &&
           !strstr($matches[2],'ftp:/') ) ||
         strstr($matches[2],'mailto:')
      )
        return '<a'.$matches[1].'href="'.$matches[2].'"';
      else
        return '<a'.$matches[1].'href="'.$this->redirect.'?url='.$matches[2].'"';
    }


}

?>

--= BLOG:CMS developer =--

Offline

 

#2 14.08.2004 21:56

nontroppo
BLOG:CMS Senior
From: Airstrip One
Registered: 31.07.2004
Posts: 84
Website

Re: NP_SEO

Radek, do you have a link to an article outlining the advantages of this way of modifying external links. I know next to nothing about SEO, so I'm curious why external links that look like internal links work?

Offline

 

#3 14.08.2004 22:12

Radek Hulán
Site Admin
From: Prague, Czech Republic
Registered: 17.03.2004
Posts: 2509
Website

Re: NP_SEO

Google is penalising "link farms", pages with A LOT of external links, with this plugin, NO link will be external, and you will NOT be supporting other people GPR as well..

some reading: http://www.iprcom.com/papers/pagerank/


--= BLOG:CMS developer =--

Offline

 

#4 14.08.2004 22:18

Radek Hulán
Site Admin
From: Prague, Czech Republic
Registered: 17.03.2004
Posts: 2509
Website

Re: NP_SEO


--= BLOG:CMS developer =--

Offline

 

#5 15.08.2004 00:49

luisnumb
newbie...
From: valencia - venezuela
Registered: 10.08.2004
Posts: 9

Re: NP_SEO

where do i exactly have to paste this code?

Code:

<?php

function undoMagic($data) {
    return get_magic_quotes_gpc() ? stripslashes($data) : $data;
}
header('Location: '.undoMagic($_GET['url']));

?>

i suppose on the main index.php file.. i did it, and it displays this error message:

Code:

Fatal error: Cannot redeclare undomagic() (previously declared in c:\appserv\www\blogcms\index.php:13) in 
c:\appserv\www\blogcms\nucleus\libs\vars4.1.0.php on line 30

any idea of what is wrong?

Last edited by luisnumb (15.08.2004 00:50)


i'm a three, a  blue three.

Offline

 

#6 15.08.2004 00:52

Radek Hulán
Site Admin
From: Prague, Czech Republic
Registered: 17.03.2004
Posts: 2509
Website

Re: NP_SEO

luisnumb wrote:

where do i exactly have to paste this code?

create a new file called index.php and place it under /redirect/ directory


--= BLOG:CMS developer =--

Offline

 

#7 15.08.2004 01:13

luisnumb
newbie...
From: valencia - venezuela
Registered: 10.08.2004
Posts: 9

Re: NP_SEO

NOW it works perfectly, thanks man.


i'm a three, a  blue three.

Offline

 

#8 16.08.2004 07:56

muchio
BLOG:CMS Junior
From: Lithuania
Registered: 29.07.2004
Posts: 26
Website

Re: NP_SEO

Hi, just wondering will it be included in the next release?


Semper Fidelis

Offline

 

#9 18.08.2004 01:04

Radek Hulán
Site Admin
From: Prague, Czech Republic
Registered: 17.03.2004
Posts: 2509
Website

Re: NP_SEO

updated version (includes encoded urls, into an id, and some other stuff):

file /INDEX.php

Code:

<?php

$CONF = array();
$CONF['Self'] = './';
include('./config.php');

// NP_SEO plugin redirect
if (isset($_GET['id'])){
  $query=mysql_query("select url from ".sql_table("plug_seo")." where id='".undoMagic($_GET['id'])."'");
  if ($row=mysql_fetch_object($query)) {
   $row->url=stripslashes($row->url);
   $redirect=true;
   if (strpos($row->url,'|noseo|')!==false) {
    $arr=explode(",",'msnbot,googlebot,crawler,centrum');
    foreach ($arr as $s) if (strstr($_SERVER["HTTP_USER_AGENT"],$s)) $redirect=false;
    $arr=explode(",",'downloader.seznam,inktomi,yahoo,altavista,fasttrack,excite,hotbot,alltheweb,yahoo');
    $dns = strtolower(@gethostbyaddr($_SERVER["REMOTE_ADDR"]));
    foreach ($arr as $s) if (strstr($dns,$s)) $redirect=false;
    $row->url=str_replace('|noseo|','',$row->url);
  }
  if ($redirect) header('Location: '.$row->url);
 } else die("Bad request");
 unset($query);
}

include($DIR_PLUGINS."related/nusoap.php");
selector();

?>

file /nucleus/plugins/NP_SEO.php

Code:

<?php

/*
 ********************************
  (c) Radek HULAN
  http://hulan.info/blog/
 ********************************/

class NP_SEO extends NucleusPlugin {

var $server;

    function getName( ){return 'SEO';} 
    function getAuthor( ){return 'Radek HULAN';} 
    function getURL( ){return 'http://hulan.info/blog/';} 
    function getVersion( ){return '1.1';} 
    function getEventList( ){return array('PreComment','PreItem');} 
    function getDescription( ){
      return 'This plugin will convert all external links in article, comment, and userlinks '.
             'into http://yourdomain/?url=http://externaldomain to achieve better page ranks';
    } 

    function install( ){
        $this->createOption("item", "Redirect articles:", "yesno", "no");
        $this->createOption("comment", "Redirect comments:", "yesno", "yes");
        $this->createOption("userlink", "Redirect smart user link in comments:", "yesno", "yes");
        $this->createOption("hide", "Hide URLs from google and like in comments:", "yesno", "yes");
        sql_query("create table if not exists ".sql_table("plug_seo")." (".
                  "id varchar(255) primary key,".
                  "url varchar(255))");
    }

    function init(){
      global $CONF;
      $this->server = $CONF['IndexURL'];
      $this->_item = ($this->getOption("item")=='yes');
      $this->_comment = ($this->getOption("comment")=='yes');
      $this->_userlink = ($this->getOption("userlink")=='yes');
      $this->_hide = ($this->getOption("hide")=='yes');
    }

    function event_PreItem(&$data){
      // article body and more
      $parts=array('body','more');
      $this->hide = false; // never hide articles
      if ($this->_item) foreach ($parts as $part) $this->doReplace($data['item']->$part);
    } 

      function event_PreComment(&$data) {
        $this->hide = $this->_hide;
        // comment body
      if ($this->_comment) $this->doReplace($data['comment']['body']);
      // smart user link
      if ($this->_userlink) {
      if (strstr($data['comment']['userlinkraw'],$this->server) || 
         ( !strstr($data['comment']['userlinkraw'],'http:/') && 
           !strstr($data['comment']['userlinkraw'],'https:/') &&
           !strstr($data['comment']['userlinkraw'],'ftp:/') ) ||
         strstr($data['comment']['userlinkraw'],'mailto:')
      ) ; else
        $data['comment']['userlinkraw'] = $this->makeURL($data['comment']['userlinkraw']);
      }
    }

    function doReplace(&$text){
      $text = preg_replace_callback(
        '/<a(.*?)href=[\"|\'](.*?)[\"|\']/',
        array(&$this, 'myLink'),
        $text);
    }

    function myLink($matches){
      if (strstr($matches[2],$this->server) || 
         ( !strstr($matches[2],'http:/') && 
           !strstr($matches[2],'https:/') &&
           !strstr($matches[2],'ftp:/') ) ||
         strstr($matches[2],'mailto:')
      )
        return '<a'.$matches[1].'href="'.$matches[2].'"';
      else {
        return '<a'.$matches[1].'href="'.$this->makeURL($matches[2]).'" title="'.$matches[2].'"';
      }
    }
    
    function makeURL($url){
      if ($this->hide) $url.='|noseo|';
      $md=md5($url);
      $query=mysql_query("select id from ".sql_table("plug_seo")." where id='$md'");
      if (mysql_num_rows($query)==0) sql_query("insert into ".sql_table("plug_seo")." (id,url) values ('$md','".addslashes($url)."')");
      return $this->server."?id=".$md;
    }

}
?>

--= BLOG:CMS developer =--

Offline

 

#10 03.05.2005 18:19

crcw
newbie...
Registered: 03.05.2005
Posts: 1

Re: NP_SEO

when I use your plugin , it doesnt work.
run the file/index.php,will display :

Code:

Warning: main(./config.php) [function.main]: failed to open stream: No such file or directory in D:\user\jjuv\website\buy.jjuv.com\file\index.php on line 5

Warning: main() [function.include]: Failed opening './config.php' for inclusion (include_path='.;C:\php\pear') in D:\user\jjuv\website\buy.jjuv.com\file\index.php on line 5

Warning: main(related/nusoap.php) [function.main]: failed to open stream: No such file or directory in D:\user\jjuv\website\buy.jjuv.com\file\index.php on line 26

Warning: main() [function.include]: Failed opening 'related/nusoap.php' for inclusion (include_path='.;C:\php\pear') in D:\user\jjuv\website\buy.jjuv.com\file\index.php on line 26

Fatal error: Call to undefined function: selector() in D:\user\jjuv\website\buy.jjuv.com\file\index.php on line 27

what should i do?

Last edited by crcw (03.05.2005 18:22)

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson

TOPlist