41
wishcraft
Re: SEO hack for CBB v3.08

Resized Image
http://www.ohloh.net/accounts/226400

Follow, Like & Read:-

twitter.com/RegaltyFamily
github.com/Chronolabs-Cooperative
facebook.com/DrAntonyRoberts

42
ghia
Re: SEO hack for CBB v3.08
  • 2009/4/12 1:05

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


In http://www.chronolabs.org.au/modules/xforum/index.php the option 'view all posts' in the dropdown is not working and returns a 404 error. A rule to short?

43
wishcraft
Re: SEO hack for CBB v3.08

Quote:

ghia wrote:
In http://www.chronolabs.org.au/modules/xforum/index.php the option 'view all posts' in the dropdown is not working and returns a 404 error. A rule to short?


Say so ghia..
Resized Image
http://www.ohloh.net/accounts/226400

Follow, Like & Read:-

twitter.com/RegaltyFamily
github.com/Chronolabs-Cooperative
facebook.com/DrAntonyRoberts

44
Monika
Re: SEO hack for CBB v3.08
  • 2009/4/12 12:14

  • Monika

  • Not too shy to talk

  • Posts: 103

  • Since: 2008/12/19


Quote:

ghia wrote:
I don't think they can be used togheter.
What steps did you do and what is in your .htaccess?


Hi Ghia, WishCraft thanks for the reply.
I have deleted Dugris xorewrite hack temporarily to see if the problem comes from it but the CBB seo hack doesn't work still.
These are the steps i followed to install it:
https://xoops.org/modules/newbb/viewtopic.php?post_id=277049#forumpost277049

Now when i click on a forum I get this URL
http://localhost/testsite/forum/f/15//


Error 404




45
Monika
Re: SEO hack for CBB v3.08
  • 2009/5/1 15:35

  • Monika

  • Not too shy to talk

  • Posts: 103

  • Since: 2008/12/19


Bump

lol

46
Catzwolf
Re: SEO hack for CBB v3.08
  • 2009/5/1 16:07

  • Catzwolf

  • Home away from home

  • Posts: 1392

  • Since: 2007/9/30


Quote:

Monika wrote:
dump


I think that you mean Bump?

Because here in the UK, what you said means something quite different, Doesn't it JV? lol

Catz

47
srdjan007
Re: SEO hack for CBB v3.08
  • 2009/6/23 10:03

  • srdjan007

  • Just popping in

  • Posts: 6

  • Since: 2008/7/9 9


Hello, I am trying to use this hack in content module for xoops.
I almost got it work but not really sure where is the problem.

I have put the include of seo_url.php in mainfile.php, because I want that rewrite works also at the root not only when I am in module content.
Module content has only index.php and there is no header.php.
I have put both seo.php and seo_url.php in modules/content directory.
This is how I did but still missing something:

1. seo_url.php
-------------------------------------------------------------------------------------
if (!defined("XOOPS_ROOT_PATH") || !defined("XOOPS_URL") ) {
exit();
}


define('REAL_MODULE_NAME', 'content');
define('SEO_MODULE_NAME', 'storitve');

ob_start('seo_urls');

function seo_urls($s)
{
$XPS_URL = str_replace('/','\/', quotemeta(XOOPS_URL) );
$s = content_absolutize($s); // Fix URLs and HTML.

$module_name = REAL_MODULE_NAME;

$search = array(
// Search URLs of modules' directry.
'/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})'.$XPS_URL.'\/modules\/'.$module_name.'\/(index.php)([^>\'\"]*)([\'\"]{1})([^>]*)>/i',
);

$s = preg_replace_callback($search, 'replace_links', $s);

return $s;
}

function replace_links($matches)
{
switch ($matches[5]) {
case 'index.php':
$add_to_url = '';
$req_string = $matches[6];
if (!empty($matches[6]))
{
// replacing id=x
if(preg_match('/id=([0-9]+)/', $matches[6], $mvars))
{
$add_to_url = 'c/'.$mvars[1].'/'.content_seo_id($mvars[1]).'/';
$req_string = preg_replace('/id=[0-9]+/','', $matches[6]);
}
else
{
return $matches['0'];
}
}
// break;
// case 'viewcontent.php':
// $add_to_url = '';
// $req_string = $matches[6];
// if (!empty($matches[6]))
// {
// replacing content=x
// if(preg_match('/content=([0-9]+)/', $matches[6], $mvars))
// {
// $add_to_url = 'f/'.$mvars[1].'/'.content_seo_content($mvars[1]).'/';
// $req_string = preg_replace('/content=[0-9]+/','', $matches[6]);
// }
// else
// {
// return $matches['0'];
// }
// }
// break;
// case 'viewtopic.php':
// $add_to_url = '';
// $req_string = $matches[6];
// if (!empty($matches[6]))
// {
//
// replacing topic_id=x
// if(preg_match('/topic_id=([0-9]+)/', $matches[6], $mvars))
// {
// $add_to_url = 't/'.$mvars[1].'/'.content_seo_topic($mvars[1]).'/';
// $req_string = preg_replace('/topic_id=[0-9]+/','', $matches[6]);
// }
// else
// {
// return $matches['0'];
// }
// }
// break;
//
// default:
// break;
}
if ($req_string == '?')
{
$req_string = '';
}
$ret = '<'.$matches[1].$matches[2].$matches[3].'='.$matches[4].XOOPS_URL.'/'.SEO_MODULE_NAME.'/'.$add_to_url.$req_string.$matches[7].$matches[8].'>';
return $ret;
}

function content_seo_id($_id)
{
$db =& Database::getInstance();
$query = "
SELECT
ptitle
FROM
nova_content
WHERE
storyid = $_id
";
$result = $db->query($query);
$res = $db->fetchArray($result);
$ret = content_seo_title($res['ptitle']);
return $ret;
}

//function content_seo_content($_id)
//{
// $db =& Database::getInstance();
// $query = "
// SELECT
// content_name
// FROM
// spir3d_bb_contents
// WHERE
// content_id = $_id
// ";
// $result = $db->query($query);
// $res = $db->fetchArray($result);
// $ret = content_seo_title($res['content_name']);
// return $ret;
//}
//function content_seo_topic($_id)
//{
// $db =& Database::getInstance();
// $query = "
// SELECT
// topic_title
// FROM
// spir3d_bb_topics
// WHERE
// topic_id = $_id
// ";
// $result = $db->query($query);
// $res = $db->fetchArray($result);
// $ret = content_seo_title($res['topic_title']);
// return $ret;
//}

function content_seo_title($title='', $withExt=false)
{
/**
* if XOOPS ML is present, let's sanitize the title with the current language
*/
$myts = MyTextSanitizer::getInstance();
if (method_exists($myts, 'formatForML')) {
$title = $myts->formatForML($title);
}

// Transformation de la chaine en minuscule
// Codage de la chaine afin d'éviter les erreurs 500 en cas de caract?res imprévus
$title = rawurlencode(strtolower($title));

// Transformation des ponctuations
// Tab Space ! " # % & ' ( ) , / : ; < = > ? @ [ \ ] ^ { | } ~ .
$pattern = array("/%09/", "/%20/", "/%21/", "/%22/", "/%23/", "/%25/", "/%26/", "/%27/", "/%28/", "/%29/", "/%2C/", "/%2F/", "/%3A/", "/%3B/", "/%3C/", "/%3D/", "/%3E/", "/%3F/", "/%40/", "/%5B/", "/%5C/", "/%5D/", "/%5E/", "/%7B/", "/%7C/", "/%7D/", "/%7E/", "/\./", "/%2A/");
$rep_pat = array( "-" , "-" , "" , "" , "" , "-100" , "" , "-" , "" , "" , "" , "-" , "" , "" , "" , "-" , "" , "" , "-at-" , "" , "-" , "" , "-" , "" , "-" , "" , "-" , "" , "" );
$title = preg_replace($pattern, $rep_pat, $title);

// Transformation des caract?res accentués
// ? é ? ë ç ? â ä î ? ? ü ? ô ö
$pattern = array("/%B0/", "/%E8/", "/%E9/", "/%EA/", "/%EB/", "/%E7/", "/%E0/", "/%E2/", "/%E4/", "/%EE/", "/%EF/", "/%F9/", "/%FC/", "/%FB/", "/%F4/", "/%F6/");
$rep_pat = array( "-", "e" , "e" , "e" , "e" , "c" , "a" , "a" , "a" , "i" , "i" , "u" , "u" , "u" , "o" , "o" );
$title = preg_replace($pattern, $rep_pat, $title);

if (sizeof($title) > 0)
{
if ($withExt) {
$title .= '.html';
}
return $title;
}
else
return '';
}

function content_absolutize($s){
if(preg_match('/\/$/',$_SERVER['REQUEST_URI'])){
$req_dir=preg_replace('/\/$/','',$_SERVER['REQUEST_URI']);
$req_php="";
}else{
$req_dir=dirname($_SERVER['REQUEST_URI']);
$req_php=preg_replace('/.*(\/[a-zA-Z0-9_\-]+)\.php.*/','\\1.php',$_SERVER['REQUEST_URI']);
}
$req_dir = ($req_dir == "\\" || $req_dir == "/" ) ? "" : $req_dir ;
$dir_arr=explode('/', $req_dir);
$m = count($dir_arr)-1;
$d1 = @str_replace('/'.$dir_arr[$m], '', $req_dir);
$d2 = @str_replace('/'.$dir_arr[$m-1], '', $d1);
$d3 = @str_replace('/'.$dir_arr[$m-2], '', $d2);
$d4 = @str_replace('/'.$dir_arr[$m-3], '', $d3);
$d5 = @str_replace('/'.$dir_arr[$m-4], '', $d4);
$host = 'http://'.$_SERVER['HTTP_HOST'];
$in = array(
'/<([^>\?\&]*)(href|src|action|background|window\.location)=([^\"\' >]+)([^>]*)>/i'
,'/<([^>\?\&]*)(href|src|action|background|window\.location)=([\"\']{1})\.\.\/\.\.\/\.\.\/([^\"\']*)([\"\']{1})([^>]*)>/i'
,'/<([^>\?\&]*)(href|src|action|background|window\.location)=([\"\']{1})\.\.\/\.\.\/([^\"\']*)([\"\']{1})([^>]*)>/i'
,'/<([^>\?\&]*)(href|src|action|background|window\.location)=([\"\']{1})\.\.\/([^\"\']*)([\"\']{1})([^>]*)>/i'
,'/<([^>\?\&]*)(href|src|action|background|window\.location)=([\"\']{1})\/([^\"\']*)([\"\']{1})([^>]*)>/i'
,'/<([^>\?\&]*)(href|src|action|background|window\.location)=([\"\']{1})\?([^\"\']*)([\"\']{1})([^>]*)>/i'
//This dir
,'/<([^>\?\&]*)(href|src|action|background|window\.location)=([\"\']{1})([^#]{1}[^\/\"\'>]*)([\"\']{1})([^>]*)>/i'
,'/<([^>\?\&]*)(href|src|action|background|window\.location)=([\"\']{1})(?:\.\/)?([^\"\'\/:]*\/*)?([^\"\'\/:]*\/*)?([^\"\'\/:]*\/*)?([a-zA-Z0-9_\-]+)\.([^\"\'>]*)([\"\']{1})([^>]*)>/i'
,'/[^"\'a-zA-Z_0-9](window\.open|url)\(([\"\']{0,1})(?:\.\/)?([^\"\'\/]*)\.([^\"\'\/]+)([\"\']*)([^\)]*)/i'
,'/]*)url=([a-zA-Z0-9_\-]+)\.([^\"\'>]*)([\"\']{1})([^>]*)>/i'
);
$out = array(
'<\\1\\2="\\3"\\4>'
,'<\\1\\2=\\3'.$host.$d3.'/\\4\\5\\6>'
,'<\\1\\2=\\3'.$host.$d2.'/\\4\\5\\6>'
,'<\\1\\2=\\3'.$host.$d1.'/\\4\\5\\6>'
,'<\\1\\2=\\3'.$host.'/\\4\\5\\6>'
,'<\\1\\2=\\3'.$host.$_SERVER['PHP_SELF'].'?\\4\\5\\6>'
//This dir.
,'<\\1\\2=\\3'.$host.$req_dir.'/\\4\\5\\6\\7>'
,'<\\1\\2=\\3'.$host.$req_dir.'/\\4\\5\\6\\7.\\8\\9\\10>'
,'$1($2'.$host.$req_dir.'/$3.$4$5$6'
,''
);
$s = preg_replace($in, $out, $s);

return $s;
}
?>
-------------------------------------------------------------------------------------------


2. seo.php
-------------------------------------------------------------------------------------------
/*
* $Id: seo.php,v 1.5 2006/08/15 19:52:08 malanciault Exp $
* Module: content
* Author: Sudhaker Raj <http://xoops.biz>
* Licence: GNU
*/

$seoArg = $_GET['seoOp'];


if (!empty($seoArg))
{
$seoOther = explode("/",$seoOther);
}

$seoMap = array(
'c' => 'index.php',

);

if (! empty($seoArg) && ! empty($seoMap[$seoArg]))
{
// module specific dispatching logic, other module must implement as
// per their requirements.
$newUrl = '/modules/content/' . $seoMap[$seoArg];

$_ENV['PHP_SELF'] = $newUrl;
$_SERVER['SCRIPT_NAME'] = $newUrl;
$_SERVER['PHP_SELF'] = $newUrl;
switch ($seoArg) {
case 'c':
default:
$_SERVER['REQUEST_URI'] = $newUrl . '?id=' . $seoArg;
$_GET['id'] = $seoArg;
}

include( $seoMap[$seoArg]);
}

exit;

?>
----------------------------------------------------------------------------------------

3. and finaly .htaccess
----------------------------------------------------------------------------------------
RewriteEngine On
RewriteRule ^storitve/([a-z]+)/([0-9]+)(/(.+))? modules/content/seo.php?seoArg=$1&%{QUERY_STRING} [L]
RewriteRule ^storitve(/)? modules/content/?%{QUERY_STRING} [L]


Please help, how to make it work.
Thanks,
Srdan



48
ghia
Re: SEO hack for CBB v3.08
  • 2009/6/23 16:09

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


Quote:
I almost got it work but not really sure where is the problem.
It s not clear if there is anything already working or what the symptons are. Apache logs?
Quote:
I have put the include of seo_url.php in mainfile.php, because I want that rewrite works also at the root not only when I am in module content.
Module content has only index.php and there is no header.php.
Don't do that for a starter. It is already complicated enough to just transpose it from one module to another. Follow as close as possible the original instructions.
If there is no header.php in the module, find the place where the root header.php is included, propably in index.php. Look out for code similarities of the CBB header.php, to spot the insertion point.

49
srdjan007
Re: SEO hack for CBB v3.08
  • 2009/6/24 11:05

  • srdjan007

  • Just popping in

  • Posts: 6

  • Since: 2008/7/9 9


Hello,
at first I would really like to thank you for quick respond. Thank you.

No errors are in apache log,
at first when adopting there were errors like file missing...now i did it so that there is no errors (i had a problem with htacces written wrong, now it is correct and after that there is no apache errors).

web page is at: http://crevar.eu/nova (you can click it to see what I mean)

Access log from apache:
213.229.236.82 - - [24/Jun/2009:12:53:27 +0200] "GET /nova/storitve/c/4/izdelava-spletnih-strani/ HTTP/1.1" 200 -

If you put the mouse over the "Spletne strani" link at the left side of the page, you will see that it points to the correct rewrited link:
http://crevar.eu/nova/storitve/c/4/izdelava-spletnih-strani/

original link of that content is:
http://crevar.eu/nova/modules/content/index.php?id=4

and when click there is blank page. There is no php errors, no MySQL errors and no apache errors. I just think that in seo.php file defined in last post is something wrong written -changed.

header.php is included in index.php, i also try to include seo_url.php in index.php and there is no difference. So I put the include back to mainfile.php.

Is there anything else that I can send?
Thank you for your help again.

BR,
Srdan

50
ghia
Re: SEO hack for CBB v3.08
  • 2009/6/24 13:59

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


Quote:
and when click there is blank page.
That is not what I see. Header and columns are showed normal, but at the place of the content:
Quote:
Izbrani modul ne obstaja!
Module unknown or not existant?

One weird thing i see is that your Apache rewrite rule in .htaccess uses seoArg to pass data to seo.php, which tries to retrieve the seoArg from seoOp.

Login

Who's Online

328 user(s) are online (65 user(s) are browsing Support Forums)


Members: 0


Guests: 328


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Oct 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits