xoops forums

Forum Index


Board index » All Posts (srdjan007)




srdjan007

Just popping in
Posted on: 2009/6/29 12:48
srdjan007
srdjan007 (Show more)
Just popping in
Posts: 6
Since: 2008/7/9 9
#1

Re: SEO hack for CBB v3.08

Please help.
So close but cannot get it work.


srdjan007

Just popping in
Posted on: 2009/6/24 14:56
srdjan007
srdjan007 (Show more)
Just popping in
Posts: 6
Since: 2008/7/9 9
#2

Re: SEO hack for CBB v3.08

Hello,
thats correct, i somehow found which line in seo.php is causing me troubles, if I comment:
//$newUrl = ('/modules/content/'.$seoMap[$seoOp]);

---------------------

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

$seoOp = $_GET['seoOp'];
$seoArg = $_GET['seoArg'];
$seoOther = $_GET['seoOther'];


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

$seoMap = array('c' => "index.php");

if (! empty($seoOp) && ! empty($seoMap[$seoOp]))
{
// module specific dispatching logic, other module must implement as
// per their requirements.

//$newUrl = ('/modules/content/'.$seoMap[$seoOp]);




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

include($seoMap[$seoOp]);
}

}

exit;

?>


------------------
than I get page but with msg: module does not exist.

if i put: $newUrl = ('/modules/content/'.$seoMap[$seoOp]);
back,then i get blank page...what do you think it could be?
some modifications should be done in index.php?

Did you mean that rewrite rule is not correct?

br,
Srdan





srdjan007

Just popping in
Posted on: 2009/6/24 11:05
srdjan007
srdjan007 (Show more)
Just popping in
Posts: 6
Since: 2008/7/9 9
#3

Re: SEO hack for CBB v3.08

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


srdjan007

Just popping in
Posted on: 2009/6/23 10:03
srdjan007
srdjan007 (Show more)
Just popping in
Posts: 6
Since: 2008/7/9 9
#4

Re: SEO hack for CBB v3.08

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
-------------------------------------------------------------------------------------
<?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'
,'/<meta([^>]*)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'
,'<meta$1url='.$host.$req_dir.'/$2.$3$4$5>'
);
$s = preg_replace($in, $out, $s);

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


2. seo.php
-------------------------------------------------------------------------------------------
<?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




srdjan007

Just popping in
Posted on: 2008/7/10 12:39
srdjan007
srdjan007 (Show more)
Just popping in
Posts: 6
Since: 2008/7/9 9
#5

Re: question on xbs meta tags module

It is working! Great, you solved my problem! Thx very very much!


srdjan007

Just popping in
Posted on: 2008/7/9 9:55
srdjan007
srdjan007 (Show more)
Just popping in
Posts: 6
Since: 2008/7/9 9
#6

Re: question on xbs meta tags module

Hello there, I have a little problem - big for me I suppose...I am using XOOPS 2.0.18.1, and have succesfuly instaled xbs_tags module. I have changed the footer.php as it is described for 2.0.14:

before the line (at line 39)

$xoopsTpl->display('db:'.$xoopsOption['template_main']);

Insert

/**
* Hack by A Kitson to enable XBS MetaTags
*/
if (file_exists(XOOPS_ROOT_PATH."/modules/xbs_tags/include/metatags.php")) {
include XOOPS_ROOT_PATH."/modules/xbs_tags/include/metatags.php";
}
/**
* End hack
*/

before the line (at line 75)

$xoTheme->render();

Insert

/**
* Hack by A Kitson to enable XBS MetaTags
*/
if (file_exists(XOOPS_ROOT_PATH."/modules/xbs_tags/include/metatags.php")) {
include XOOPS_ROOT_PATH."/modules/xbs_tags/include/metatags.php";
}
/**
* End hack
*/


but if I use the module I am able to change only TITLE of the page but not the description and keywords. Is there some more tricks about this? Do I have to change my theme.html=? or header.php? Could anyone help please. Thx.



TopTop