Moin,
danke für den Tipp. Wenn ich allerdings die Version aus dem genannten Thread bei mir hochlade, dann bekomme ich global diese Fehlermeldung:
Fatal error: Class 'ModRewriteBase' not found in class.modrewritecontroller.php on line 29
Und was ich da ändern sollte, weiß ich nicht, denn eine Base kann ich in dieser Datei nicht finden. Also müßte es wieder woanders festgelegt sein und da greift dann mein gefährliches Halbwissen

Da ändere ich lieber nichts auf Verdacht.
Aktuell verwende ich die MR Version vom 16.04.2008. Ich kopier sie mal ganz rein, damit du nicht danach suchen musst:
Code: Alles auswählen
<?php
/**
* Includes Mod Rewrite controller class.
*
* @author Murat Purc <murat@purc.de>
* @copyright © Murat Purc 2008
* @package Contenido
* @subpackage ModRewrite
*/
if(!defined('CON_FRAMEWORK')) {
die('Illegal call');
}
/**
* Mod Rewrite controller class. Extracts url parts and sets some necessary globals like:
* - $idart
* - $idcat
* - $client
* - $changeclient
* - $lang
* - $changelang
*
* TODO: Adapt to PHP 5 coding standards...
*
* @author Murat Purc <murat@purc.de>
* @date 16.04.2008
* @package Contenido
* @subpackage ModRewrite
*/
class ModRewriteController {
/**
* Contenido configuration array (see $GLOBALS['cfg'])
*
* @var array
*/
var $_aCfg;
/**
* Mod Rewrite configuration array (see $GLOBALS['cfg']['mod_rewrite'])
*
* @var array
*/
var $_aCfgMR;
/**
* Extracted request uri path parts by path separator '/'
*
* @var array
*/
var $_aParts;
/**
* Extracted article name from request uri
*
* @var string
*/
var $_sArtName;
/**
* Remaining path for path resolver (see $GLOBALS['path'])
*
* @var string
*/
var $_sPath;
/**
* Incomming URL
*
* @var string
*/
var $_sIncommingUrl;
/**
* Resolved URL
*
* @var string
*/
var $_sResolvedUrl;
/**
* Client id used by this class
*
* @var int
*/
var $_iClientMR;
/**
* Flag about occured errors
*
* @var bool
*/
var $_bError = false;
/**
* Flag about found routing definition
*
* @var bool
*/
var $_bRoutingFound = false;
/**
* Constructor, sets several properties.
*
* @param string $incommingUrl Incomming URL
*/
function ModRewriteController($incommingUrl) {
$this->_sIncommingUrl = $incommingUrl;
$this->_aCfg = & $GLOBALS['cfg'];
$this->_aCfgMR = & $GLOBALS['cfg']['mod_rewrite'];
$this->_aParts = array();
}
/**
* Getter for overwritten client id (see $GLOBALS['client'])
*
* @return int Client id
*/
function getClient() {
return $GLOBALS['client'];
}
/**
* Getter for overwritten change client id (see $GLOBALS['changeclient'])
*
* @return int Change client id
*/
function getChangeClient() {
return $GLOBALS['changeclient'];
}
/**
* Getter for article id (see $GLOBALS['idart'])
*
* @return int Article id
*/
function getIdArt() {
return $GLOBALS['idart'];
}
/**
* Getter for category id (see $GLOBALS['idcat'])
*
* @return int Category id
*/
function getIdCat() {
return $GLOBALS['idcat'];
}
/**
* Getter for language id (see $GLOBALS['lang'])
*
* @return int Language id
*/
function getLang() {
return $GLOBALS['lang'];
}
/**
* Getter for change language id (see $GLOBALS['change_lang'])
*
* @return int Change language id
*/
function getChangeLang() {
return $GLOBALS['changelang'];
}
/**
* Getter for path (see $GLOBALS['path'])
*
* @return string Path, used by path resolver
*/
function getPath() {
return $this->_sPath;
}
/**
* Getter for resolved url
*
* @return string Resolved url
*/
function getResolvedUrl() {
return $this->_sResolvedUrl;
}
/**
* Returns a flag about found routing definition
*
* return bool Flag about found routing
*/
function getRoutingFoundState() {
return $this->_bRoutingFound;
}
/**
* Getter for occured error state
*
* @return bool Flag for occured error
*/
function errorOccured(){
return $this->_bError;
}
/**
* Main function to call for mod rewrite related preprocessing jobs.
*
* Executes some private functions to extract request URI and to set needed membervariables
* (client, language, article id, category id, etc.)
*/
function execute() {
if (ModRewrite::is_enabled() == false) {
return;
}
$this->_extractRequestUri();
$this->_overrideConfig();
$this->_preprocessVariables();
$this->_setClientId();
# $GLOBALS['mpDebug']->addDebug($GLOBALS['client'], 'ModRewriteController::execute() $GLOBALS[\'client\']');
mr_loadConfiguration($this->_iClientMR);
$this->_setLanguageId();
# $GLOBALS['mpDebug']->addDebug($GLOBALS['lang'], 'ModRewriteController::execute() $GLOBALS[\'lang\']');
// second call after setting client and language
$this->_extractRequestUri(true);
$this->_setPathresolverSetting();
# $GLOBALS['mpDebug']->addDebug($this->_aParts, 'ModRewriteController::execute() after _setPathresolverSetting');
$this->_setIdart();
$GLOBALS['mpDebug']->addDebug($this->_aParts, 'ModRewriteController::execute() _setIdart');
$this->_postValidation();
}
/**
* Extracts request URI and sets member variables $this->_sArtName and $this->_aParts
*
* @access private
*/
function _extractRequestUri($secondCall=false) {
// check for defined rootdir
if ($this->_aCfgMR['rootdir'] !== '/' && strpos($_SERVER['REQUEST_URI'], $this->_sIncommingUrl) === 0) {
$this->_sIncommingUrl = str_replace($this->_aCfgMR['rootdir'], '/', $this->_sIncommingUrl);
}
# $GLOBALS['mpDebug']->addDebug($this->_sIncommingUrl, 'ModRewriteController::_extractRequestUri() this->_sIncommingUrl');
$aUrlComponents = $this->parseUrl($this->_sIncommingUrl);
if (isset($aUrlComponents['path'])) {
if ($secondCall == true) {
// TODO: damn routing code...
// check for routing definition
if (is_array($this->_aCfgMR['routing']) && isset($this->_aCfgMR['routing'][$aUrlComponents['path']])) {
$aUrlComponents['path'] = $this->_aCfgMR['routing'][$aUrlComponents['path']];
if (strpos($aUrlComponents['path'], 'front_content.php') !== false) {
// routing destination contains front_content.php
$this->_bRoutingFound = true;
// set client language, if not set before
mr_set_client_language($GLOBALS['client']);
//rebuild URL
$url = mr_build_new_url($aUrlComponents['path']);
$aUrlComponents = $this->parseUrl($url);
$this->_aParts = array();
}
} else {
return;
}
}
$aPaths = explode('/', $aUrlComponents['path']);
foreach ($aPaths as $p => $item) {
if (!empty($item)) {
// pathinfo would also work
$arr = explode('.', $item);
if (count($arr) > 0 && '.'.strtolower($arr[count($arr)-1]) == $this->_aCfgMR['file_extension']) {
array_pop($arr);
$this->_sArtName = implode('.', $arr);
} else {
$this->_aParts[] = $item;
}
}
}
if ($secondCall == true) {
// reprocess extracting client and language
$this->_setClientId();
mr_loadConfiguration($this->_iClientMR);
$this->_setLanguageId();
}
}
$GLOBALS['mpDebug']->addDebug($this->_aParts, 'ModRewriteController::_extractRequestUri() $this->_aParts');
// loop parts array and remove existing 'front_content.php'
if ($this->_hasPartArrayItems()) {
foreach($this->_aParts as $p => $item) {
if ($item == 'front_content.php') {
unset($this->_aParts[$p]);
}
}
}
# $GLOBALS['mpDebug']->addDebug($this->_aParts, 'ModRewriteController::_extractRequestUri() $this->_aParts 2.');
// set parts property top null, if needed
if ($this->_hasPartArrayItems() == false) {
$this->_aParts = null;
}
# $GLOBALS['mpDebug']->addDebug($this->_aParts, 'ModRewriteController::_extractRequestUri() $this->_aParts 3.');
// set artname to null if needed
if (!isset($this->_sArtName) || empty($this->_sArtName) || strlen($this->_sArtName) == 0) {
$this->_sArtName = null;
}
# $GLOBALS['mpDebug']->addDebug($this->_sArtName, 'ModRewriteController::_extractRequestUri() $this->_sArtName');
}
/**
* Overrides local mod rewrite cfg settings with client settings from database
*
* @access private
*/
function _overrideConfig() {
if ((int) substr($this->_aCfg['version'],0,1) . substr($this->_aCfg['version'],2,1) >= 46) {
$this->_iClientMR = 0;
if (isset($GLOBALS['client']) && !empty($GLOBALS['client']) && !isset($GLOBALS['changeclient'])) {
$this->_iClientMR = $GLOBALS['client'];
} elseif (isset($GLOBALS['changeclient']) && !empty($GLOBALS['changeclient'])) {
$this->_iClientMR = $GLOBALS['changeclient'];
} else {
$this->_iClientMR = $GLOBALS['load_client'];
}
if ((int) $this->_iClientMR !== 0) {
// set global $GLOBALS['client'] variable
$GLOBALS['client'] = (int) $this->_iClientMR;
}
}
}
/**
* Preprocesses article name and parts list, sets article name and parts list
* if settings for usage of categories as a html file is active and valid.
*
* @deprecated
*
* @access private
*/
function _preprocessVariables() {
return;
// check for html file only links and prepare variables
if ($this->_sArtName && ModRewrite::validate_setting_categories_as_html()) {
$aParts = explode($this->_aCfgMR['article_seperator'], $this->_sArtName);
if (count($aParts) > 0) {
$this->_aParts = (isset($aParts[0]) && strlen($aParts[0]) > 0) ? explode($this->_aCfgMR['category_seperator'], $aParts[0]) : false;
$this->_sArtName = (isset($aParts[1]) && strlen($aParts[1]) > 0) ? $aParts[1] : false;
#$GLOBALS['mpDebug']->vdump($this->_aParts, '_preprocessVariables $this->_aParts');
#$GLOBALS['mpDebug']->vdump($this->_sArtName, '_preprocessVariables $this->_sArtName');
}
}
}
/**
* Sets client id
*
* @access private
*/
function _setClientId() {
if ($this->_hasPartArrayItems() == false || $this->_aCfgMR['use_client'] !== 1) {
return;
}
if ($this->_aCfgMR['use_client_name'] == 1) {
$GLOBALS['changeclient'] = mr_get_client_id(array_shift($this->_aParts));
$this->_iClientMR = $GLOBALS['changeclient'];
} else {
$GLOBALS['changeclient'] = (int) array_shift($this->_aParts);
$this->_iClientMR = $GLOBALS['changeclient'];
}
if (empty($GLOBALS['changeclient']) || (int) $GLOBALS['changeclient'] == 0) {
$GLOBALS['changeclient'] = $GLOBALS['load_client'];
}
if (isset($GLOBALS['client']) && $GLOBALS['changeclient'] !== $GLOBALS['client']) {
// overwrite existing global $GLOBALS['client'] variable
$GLOBALS['client'] = $GLOBALS['changeclient'];
$this->_iClientMR = $GLOBALS['changeclient'];
}
# $GLOBALS['mpDebug']->addDebug($GLOBALS['changeclient'], 'ModRewriteController::_setClientId() $GLOBALS[\'changeclient\']');
# $GLOBALS['mpDebug']->addDebug($this->_iClientMR, 'ModRewriteController::_setClientId() $this->_iClientMR');
}
/**
* Sets language id
*
* @access private
*/
function _setLanguageId() {
if ($this->_hasPartArrayItems() == false || $this->_aCfgMR['use_language'] !== 1) {
return;
}
if ($this->_aCfgMR['use_language_name'] == 1) {
// thanks to Nicolas Dickinson for multi Client/Language BugFix
$GLOBALS['changelang'] = mr_get_language_id(array_shift($this->_aParts) , $this->_iClientMR);
} else {
$GLOBALS['changelang'] = (int) array_shift($this->_aParts);
}
# $GLOBALS['mpDebug']->addDebug($GLOBALS['changelang'], 'ModRewriteController::_setLanguageId() $GLOBALS[\'changelang\']');
if (empty($GLOBALS['changelang']) || (int) $GLOBALS['changelang'] == 0) {
unset($GLOBALS['changelang']);
} else {
$GLOBALS['lang'] = $GLOBALS['changelang'];
}
}
/**
* Sets path resolver and category id
*
* @access private
*/
function _setPathresolverSetting() {
if ($this->_hasPartArrayItems() == false) {
return;
}
$this->_sPath = '/' .implode('/', $this->_aParts) . '/';
// TODO: time to get catid is to long, should be cached!!!
if (!isset($GLOBALS['lang'])) {
if (!isset($GLOBALS['load_lang'])) {
// load_client is set in frontend/config.php
$GLOBALS['lang'] = $GLOBALS['load_lang'];
} else {
// get client id from table
cInclude('classes', 'contenido/class.clientslang.php');
$clCol = new cApiClientLanguageCollection();
$clCol->setWhere('idclient', $GLOBALS['client']);
$clCol->query();
if ($clItem = $clCol->next()) {
$GLOBALS['lang'] = $clItem->get('idlang');
}
}
}
$GLOBALS['idcat'] = prResolvePathViaURLNames($this->_sPath);
# $GLOBALS['idcat'] = mr_prResolvePathViaURLNames($this->_sPath);
if (!$GLOBALS['idcat'] || (int) $GLOBALS['idcat'] == 0) {
// set this flag, it's used in front_content.php
$this->_bError = true;
unset($GLOBALS['idcat']);
} else {
// unset $this->_sPath if $GLOBALS['idcat'] could set, otherwhise it would be resolved again.
unset($this->_sPath);
}
$GLOBALS['mpDebug']->addDebug($GLOBALS['idcat'], 'ModRewriteController->_setPathresolverSetting $GLOBALS[\'idcat\']');
$GLOBALS['mpDebug']->addDebug($this->_sPath, 'ModRewriteController->_setPathresolverSetting $this->_sPath');
}
/**
* Sets article id
*
* @access private
*/
function _setIdart() {
// startarticle name in url
if ($this->_aCfgMR['add_startart_name_to_url'] && isset($this->_sArtName)) {
if ($this->_sArtName == $this->_aCfgMR['default_startart_name']) {
// stored articlename is the default one, remove it mr_get_idart()
// will find the real article name
$this->_sArtName = null;
}
}
if (isset($GLOBALS['idcat']) && $this->_sArtName && !isset($GLOBALS['idart'])) {
// existing idcat with article name and no idart
$GLOBALS['idart'] = mr_get_idart($this->_sArtName, $GLOBALS['idcat']);
} elseif ($GLOBALS['idcat'] > 0 && $this->_sArtName == null && !isset($GLOBALS['idart'])) {
# if (!$this->_aCfgMR['add_startart_name_to_url'] ||
# ($this->_aCfgMR['add_startart_name_to_url'] && $this->_aCfgMR['default_startart_name'] == '')) {
if ($this->_aCfgMR['add_startart_name_to_url'] && $this->_aCfgMR['default_startart_name'] == '') {
// existing idcat without article name and idart
cInclude('classes', 'class.article.php');
$artColl = new ArticleCollection(array('idcat' => $GLOBALS['idcat'], 'start' => 1));
if ($artItem = $artColl->startArticle()) {
$GLOBALS['idart'] = $artItem->get('idart');
}
}
} elseif (!isset($GLOBALS['idcat']) && isset($this->_sArtName) && !isset($GLOBALS['idart'])) {
// no idcat and idart but article name
$GLOBALS['idart'] = mr_get_idart($this->_sArtName);
}
if (isset($GLOBALS['idart']) && (!$GLOBALS['idart'] || (int) $GLOBALS['idart'] == 0)) {
if ($this->_aCfgMR['redirect_invalid_article_to_errorsite'] == 1) {
$this->_bError = true;
unset($GLOBALS['idart']);
}
}
$GLOBALS['mpDebug']->addDebug($GLOBALS['idart'], 'ModRewriteController->_setIdart $GLOBALS[\'idart\']');
}
/**
* Does post validation of the extracted data.
*
* One main goal of this function is to prevent duplicated content, which could happen, if
* the configuration 'startfromroot' is activated.
*/
function _postValidation() {
if ($this->_bError || $this->_bRoutingFound) {
return;
}
if ($this->_aCfgMR['startfromroot'] == 1 && $this->_aCfgMR['prevent_duplicated_content'] == 1 && count($this->_aParts) > 0) {
// prevention of duplicated content if '/firstcat/' is directly requested!
// compose new parameter
$param = '';
if ($this->getIdCat()) {
$param .= 'idcat=' . (int) $this->getIdCat();
}
if ($this->getIdArt()) {
$param .= ($param !== '') ? '&idart=' . (int) $this->getIdArt() : 'idart=' . (int) $this->getIdArt();
}
if ($param == '') {
return;
}
// set client language, if not set before
mr_set_client_language($GLOBALS['client']);
//rebuild url
$url = mr_build_new_url('front_content.php?' . $param);
$aUrlComponents = @parse_url($this->_sIncommingUrl);
$incommingUrl = (isset($aUrlComponents['path'])) ? $aUrlComponents['path'] : '';
$GLOBALS['mpDebug']->addDebug($url, 'ModRewriteController->_postValidation validate uri');
$GLOBALS['mpDebug']->addDebug($incommingUrl, 'ModRewriteController->_postValidation incommingUri');
// now the new generated uri should be identical with the request uri
if ($incommingUrl !== $url) {
$this->_bError = true;
unset($GLOBALS['idcat']);
}
}
}
function parseUrl($url) {
$this->_sResolvedUrl = $url;
if (ModRewrite::validate_setting_categories_as_html()) {
$ext = $this->_aCfgMR['file_extension'];
$url = str_replace($ext, '{EXT}', $url);
// replace category seperator against /
$url = str_replace($this->_aCfgMR['category_seperator'], '/', $url);
// replace article seperator against /
$url = str_replace($this->_aCfgMR['article_seperator'], '/', $url);
$url = str_replace('{EXT}', $ext, $url);
}
# $this->_sResolvedUrl = $url;
# $GLOBALS['mpDebug']->addDebug($url, 'ModRewriteController->parseUrl $url');
return @parse_url($url);
}
/**
* Returns state of parts property
*
* @return bool True if $this->_aParts propery is an array and contains items
* @access private
*/
function _hasPartArrayItems() {
if (is_array($this->_aParts) && count($this->_aParts) > 0) {
return true;
} else {
return false;
}
}
}
Hier gab es, wie gesagt, nur die eine Stelle in Zeile 565 die auf deine Beschreibung passte.
Danke nochmal!!
Jochen