1) Thank you (althought I didn't need that part cause we don't use docs rewrite part)
2) Now it's clear
3) I changed with RewrtiteBase
4) This is a real problem, cause webBots are ravenous with links in pages, and we would think about a parsing solution to use url_rewriting method also in pages and menu slots
5) So, we wouldn't use user part of the script, for now...
6) I really can't understand, but, unfortunately I can't test in local cause (I don't know the reason) my wampserver goes crazy if I try to use url_rewriting...
So, if you had time to look at the code, this is my plugin:
headerchange.setup.php
<?PHP
/* ====================
COTONTI - Website engine
Copyright COTONTI
http://www.cotonti.com
[BEGIN_SED]
File=plugins/headerchange/headerchange.setup.php
Version=1
Updated=2009/08/04
Type=Plugin
Author=donP
[END_SED]
[BEGIN_SED_EXTPLUGIN]
Code=headerchange
Name=headerchange
Description=Plugin that changes background image and text string in header.tpl accordingly to category or other parameters
Version=1
Date=2009/08/04
Author=donP
Copyright=www.sangelo.net
Auth_guests=R
Lock_guests=W12345A
Auth_members=R
Lock_members=12345
Notes=Syntax is divided by two parts <strong>url:logo</strong><br />URL can be: flat url (but only from root), single php file name, category code or a number eg. for forum sections and topics (look for logochanger.config.gif in plugin archive to see example configuration). In logo part, all paths can be from root or from skin selected folder. So you can use logo with path from root to skin folder (eg. skins/myskin/img/mylogo01.jpg) or you can use logo without path at all (then current skin folder will be used eg. mylogo01.jpg or img/mylogo01.jpg) Don't use full paths (with http://) in any of url:logo. If some url/php-module/category/fsection/ftopic was not specified, then default logo will be returned.
[END_SED_EXTPLUGIN]
[BEGIN_SED_EXTPLUGIN_CONFIG]
deflogo=01:string:::Default logo
logos=02:text:::URL and Logo
[END_SED_EXTPLUGIN_CONFIG]
==================== */
defined('SED_CODE') or die('Wrong URL');
?>
headerchange.php
<?PHP
/* ====================
COTONTI - Website engine
Copyright COTONTI
http://www.cotonti.com
[BEGIN_SED]
File=plugins/headerchange/headerchange.php
Version=1
Updated=2009/08/04
Type=Plugin
Author=donP
Description=Plugin that changes background and text string in header.tpl accordingly to category or other parameters
[END_SED]
[BEGIN_SED_EXTPLUGIN]
Code=headerchange
Part=Header
File=headerchange
Hooks=header.tags
Tags=header.tpl:{LOGOCHANGER}, {LOGOBANNER}
Minlevel=0
Order=10
[END_SED_EXTPLUGIN]
==================== */
defined('SED_CODE') or die('Wrong URL');
if (!$logo or count($logo) < 4)
{
$logo = explode("\r\n", $cfg['plugin']['headerchange']['logos']);
sed_cache_store('logo',$logo,3600);
}
/* ------------------ */
$t->assign(array(
"LOGOCHANGER" => substr(logochanger_get_logo($logo), 0, strpos(logochanger_get_logo($logo),"[")),
"LOGOBANNER" => substr(logochanger_get_logo($logo), strpos(logochanger_get_logo($logo),"[")+1)
));
function logochanger_get_logo($logo)
{
global $cfg, $db_pages, $out;
foreach($logo as $key => $val)
{
$pos = strpos($val, ':');
$selector[0] = substr($val, 0, $pos); // url
$selector[1] = substr($val, 0, 2); // selector name
$selector[2] = substr($val, 2, $pos-2); // selector param
$selector[3] = substr($val, $pos+1); // logo+banner
// based on URL (with dot)
if(!(strpos($selector[0], '.') === false))
{
if(!(strpos($out['uri'], $selector[0]) === false))
return logochanger_check_path($selector[3]);
}
// Others (without dot in URL)
else
{
switch($selector[1])
{
// based on CATEGORY CODE
case 'c=':
$al = sed_import('al','G','ALP', 64);
$c = sed_import('c','G','STX', 64);
// get the area location
$area_location = substr($out['uri'], 0, strpos($out['uri'], '.'));
if(!empty($c) && ($area_location=='index' || $area_location=='list'))
{
if($c == $selector[2]) return logochanger_check_path($selector[3]);
}
switch($area_location)
{
case 'page':
$id = sed_import('id','G','INT');
if(!empty($al)) $sql = sed_sql_query("SELECT page_cat FROM $db_pages WHERE page_alias='$al' LIMIT 1");
else $sql = sed_sql_query("SELECT page_cat FROM $db_pages WHERE page_id='$id' LIMIT 1");
$pag = sed_sql_fetcharray($sql);
if($pag['page_cat'] == $selector[2]) return logochanger_check_path($selector[3]);
break;
case 'forum':
if(sed_import('s','G','INT') == $selector[2]) return logochanger_check_path($selector[3]);
break;
if(sed_import('q','G','INT') == $selector[2]) return logochanger_check_path($selector[3]);
break;
//case 'list':
default:
if($c == $selector[2]) return logochanger_check_path($selector[3]);
}
break;
}
}
}
return logochanger_check_path($cfg['plugin']['headerchange']['deflogo']);
}
/* ------------------ */
function logochanger_check_path($logo)
{
global $skin;
if(strpos($logo, 'skins/') === false) $logo = 'skins/'.$skin.'/img/'.$logo;
return $logo;
}
?>