1
0
Fork 0

Commits vergleichen

..

1 Commits

Autor SHA1 Nachricht Datum
o.pinke cf63783cf6 Merge branch 'release/V1.0.1' 2022-03-11 19:40:53 +01:00
8 geänderte Dateien mit 83 neuen und 69 gelöschten Zeilen

Datei anzeigen

@ -9,10 +9,10 @@
<copyright>ConLite Team</copyright>
<mail>plugins@conlite.org</mail>
<website>https://conlite.org</website>
<version>1.0.2</version>
<version>1.0.1</version>
</general>
<requirements php="7.4">
<conlite minversion="2.3.0" />
<conlite minversion="2.1.0" />
</requirements>
<conlite>
<areas>

Datei anzeigen

@ -155,7 +155,7 @@ class ModRewrite extends ModRewriteBase {
$iCatId = (int) $iCatId;
// get websafe name
$sNewName = cApiStrCleanURLCharacters(clHtmlEntityDecode($sName));
$sNewName = cApiStrCleanURLCharacters(conHtmlEntityDecode($sName));
// remove double or more separators
$sNewName = mr_removeMultipleChars('-', $sNewName);
@ -196,7 +196,7 @@ class ModRewrite extends ModRewriteBase {
$iLangId = (int) $iLangId;
// create websafe name
$sNewName = cApiStrCleanURLCharacters(clHtmlEntityDecode($sName));
$sNewName = cApiStrCleanURLCharacters(conHtmlEntityDecode($sName));
// remove double or more separators
$sNewName = mr_removeMultipleChars('-', $sNewName);

Datei anzeigen

@ -149,8 +149,8 @@ class ModRewriteUrlStack {
$this->_chunkSetPrettyUrlParts($sStackId);
}
$aPretty = array(
'urlpath' => (empty($this->_aStack[$sStackId]['urlpath']))?'':$this->_aStack[$sStackId]['urlpath'],
'urlname' => (empty($this->_aStack[$sStackId]['urlname']))?'':$this->_aStack[$sStackId]['urlname']
'urlpath' => $this->_aStack[$sStackId]['urlpath'],
'urlname' => $this->_aStack[$sStackId]['urlname']
);
return $aPretty;
}
@ -168,7 +168,7 @@ class ModRewriteUrlStack {
$aUrl['query'] = str_replace('&amp;', '&', $aUrl['query']);
parse_str($aUrl['query'], $aUrl['params']);
}
if (empty($aUrl['params']) || !is_array($aUrl['params'])) {
if (!isset($aUrl['params']) && !is_array($aUrl['params'])) {
$aUrl['params'] = array();
}
return $aUrl;

Datei anzeigen

@ -27,12 +27,6 @@ if (!defined('CON_FRAMEWORK')) {
*/
class ModRewrite_ContentController extends ModRewrite_ControllerAbstract {
public $_oView;
public $_client;
/**
* @var array<string, mixed>
*/
public $_cfg;
/**
* Index action
*/
@ -47,12 +41,13 @@ class ModRewrite_ContentController extends ModRewrite_ControllerAbstract {
public function saveAction() {
$bDebug = $this->getProperty('bDebug');
$aSeparator = $this->getProperty('aSeparator');
$aWordSeparator = $this->getProperty('aWordSeparator');
$routingSeparator = $this->getProperty('routingSeparator');
$bError = false;
$aMR = [];
$aMR = array();
$request = ($_POST !== []) ? $_POST : $_GET;
$request = (count($_POST) > 0) ? $_POST : $_GET;
mr_requestCleanup($request);
// use cl-mod-rewrite
@ -66,7 +61,7 @@ class ModRewrite_ContentController extends ModRewrite_ControllerAbstract {
// root dir
if (mr_arrayValue($request, 'rootdir', '') !== '') {
if (!preg_match('/^[a-zA-Z0-9\-_\/.]*$/', $request['rootdir'])) {
if (!preg_match('/^[a-zA-Z0-9\-_\/\.]*$/', $request['rootdir'])) {
$sMsg = i18n("The root directory has a invalid format, alowed are the chars [a-zA-Z0-9\-_\/\.]", "cl-mod-rewrite");
$this->_oView->rootdir_error = $this->_notifyBox('error', $sMsg);
$bError = true;
@ -86,7 +81,7 @@ class ModRewrite_ContentController extends ModRewrite_ControllerAbstract {
$this->_oView->rootdir_error = $this->_notifyBox('warning', $sMsg);
}
}
$this->_oView->rootdir = clHtmlEntities($request['rootdir']);
$this->_oView->rootdir = conHtmlentities($request['rootdir']);
$aMR['cl-mod-rewrite']['rootdir'] = $request['rootdir'];
}
@ -247,13 +242,13 @@ class ModRewrite_ContentController extends ModRewrite_ControllerAbstract {
$bError = true;
}
$this->_oView->category_separator = clHtmlentities($categorySeperator);
$this->_oView->category_separator = conHtmlentities($categorySeperator);
$aMR['cl-mod-rewrite']['category_seperator'] = $categorySeperator;
$this->_oView->category_word_separator = clHtmlentities($categoryWordSeperator);
$this->_oView->category_word_separator = conHtmlentities($categoryWordSeperator);
$aMR['cl-mod-rewrite']['category_word_seperator'] = $categoryWordSeperator;
$this->_oView->article_separator = clHtmlentities($articleSeperator);
$this->_oView->article_separator = conHtmlentities($articleSeperator);
$aMR['cl-mod-rewrite']['article_seperator'] = $articleSeperator;
$this->_oView->article_word_separator = clHtmlentities($articleWordSeperator);
$this->_oView->article_word_separator = conHtmlentities($articleWordSeperator);
$aMR['cl-mod-rewrite']['article_word_seperator'] = $articleWordSeperator;
// file extension
@ -263,7 +258,7 @@ class ModRewrite_ContentController extends ModRewrite_ControllerAbstract {
$this->_oView->file_extension_error = $this->_notifyBox('error', $sMsg);
$bError = true;
}
$this->_oView->file_extension = clHtmlentities($request['file_extension']);
$this->_oView->file_extension = conHtmlentities($request['file_extension']);
$aMR['cl-mod-rewrite']['file_extension'] = $request['file_extension'];
} else {
$this->_oView->file_extension = '.html';
@ -293,12 +288,12 @@ class ModRewrite_ContentController extends ModRewrite_ControllerAbstract {
$this->_oView->add_startart_name_to_url_chk = ' checked="checked"';
$aMR['cl-mod-rewrite']['add_startart_name_to_url'] = 1;
if (mr_arrayValue($request, 'add_startart_name_to_url', '') !== '') {
if (!preg_match('/^[a-zA-Z0-9\-_\/.]*$/', $request['default_startart_name'])) {
if (!preg_match('/^[a-zA-Z0-9\-_\/\.]*$/', $request['default_startart_name'])) {
$sMsg = i18n("The article name has a invalid format, allowed are the chars /^[a-zA-Z0-9\-_\/\.]*$/", "cl-mod-rewrite");
$this->_oView->add_startart_name_to_url_error = $this->_notifyBox('error', $sMsg);
$bError = true;
}
$this->_oView->default_startart_name = clHtmlentities($request['default_startart_name']);
$this->_oView->default_startart_name = conHtmlentities($request['default_startart_name']);
$aMR['cl-mod-rewrite']['default_startart_name'] = $request['default_startart_name'];
} else {
$this->_oView->default_startart_name = '';
@ -326,10 +321,10 @@ class ModRewrite_ContentController extends ModRewrite_ControllerAbstract {
// routing
if (isset($request['rewrite_routing'])) {
$aRouting = [];
$aRouting = array();
$items = explode("\n", $request['rewrite_routing']);
foreach ($items as $item) {
$routingDef = explode($routingSeparator, $item);
foreach ($items as $p => $v) {
$routingDef = explode($routingSeparator, $v);
if (count($routingDef) !== 2) {
continue;
}
@ -340,11 +335,11 @@ class ModRewrite_ContentController extends ModRewrite_ControllerAbstract {
}
$aRouting[$routingDef[0]] = $routingDef[1];
}
$this->_oView->rewrite_routing = clHtmlentities($request['rewrite_routing']);
$this->_oView->rewrite_routing = conHtmlentities($request['rewrite_routing']);
$aMR['cl-mod-rewrite']['routing'] = $aRouting;
} else {
$this->_oView->rewrite_routing = '';
$aMR['cl-mod-rewrite']['routing'] = [];
$aMR['cl-mod-rewrite']['routing'] = array();
}
// redirect invalid article to errorsite
@ -390,8 +385,9 @@ class ModRewrite_ContentController extends ModRewrite_ControllerAbstract {
/**
* Checks, if any sseparators setting is modified or not
* @param array $aNewCfg New configuration send by requests.
* @return bool
*/
protected function _separatorModified($aNewCfg): bool {
protected function _separatorModified($aNewCfg) {
$aCfg = ModRewrite::getConfig();
if ($aCfg['category_seperator'] != $aNewCfg['category_seperator']) {
@ -409,19 +405,18 @@ class ModRewrite_ContentController extends ModRewrite_ControllerAbstract {
/**
* Does some checks like 'is_start_compatible' check.
* Adds notifications, if something will went wrong...
*
* @todo review text and translations
*/
protected function _doChecks() {
// Check for not supported '$cfg["is_start_compatible"] = true;' mode
if (!empty($this->_cfg['is_start_compatible']) && true === $this->_cfg['is_start_compatible']) {
$sMsg = i18n("Your Contenido installation runs with the setting 'is_start_compatible'. This plugin will not work properly in this mode.<br />Please check following topic in Contenido forum to change this:<br /><br /><a href='http://forum.contenido.org/viewtopic.php?t=32530' class='blue' target='_blank'>is_start_compatible auf neue Version umstellen</a>", "cl-mod-rewrite");
$this->_oView->content_before .= $this->_notifyBox('warning', $sMsg);
}
// Check for empty urlpath entries in cat_lang table
$dbConLite = new DB_ConLite();
$db = new DB_Contenido();
$sql = "SELECT idcatlang FROM " . $this->_cfg['tab']['cat_lang'] . " WHERE urlpath = ''";
if ($dbConLite->query($sql) && $dbConLite->next_record()) {
if ($db->query($sql) && $db->next_record()) {
$sMsg = i18n("It seems as if some categories don't have a set 'urlpath' entry in the database. Please reset empty aliases in %sFunctions%s area.", "cl-mod-rewrite");
$sMsg = sprintf($sMsg, '<a href="main.php?area=mod_rewrite_expert&frame=4&contenido=' . $this->_oView->sessid . '&idclient=' . $this->_client . '" onclick="parent.right_top.sub.clicked(parent.right_top.document.getElementById(\'c_1\').firstChild);">', '</a>');
$this->_oView->content_before .= $this->_notifyBox('warning', $sMsg);

Datei anzeigen

@ -77,9 +77,17 @@ class ModRewrite_ContentExpertController extends ModRewrite_ControllerAbstract {
return;
}
$source = $type == 'restrictive' ? $this->_htaccessRestrictive : $this->_htaccessSimple;
if ($type == 'restrictive') {
$source = $this->_htaccessRestrictive;
} else {
$source = $this->_htaccessSimple;
}
$dest = $copy == 'contenido' ? $aInfo['contenido_full_path'] . '.htaccess' : $aInfo['client_full_path'] . '.htaccess';
if ($copy == 'contenido') {
$dest = $aInfo['contenido_full_path'] . '.htaccess';
} else {
$dest = $aInfo['client_full_path'] . '.htaccess';
}
if (!$result = @copy($source, $dest)) {
$this->_oView->content_before = $this->_notifyBox('info', 'Die .htaccess konnte nicht von ' . $source . ' nach ' . $dest . ' kopiert werden!');
@ -100,12 +108,16 @@ class ModRewrite_ContentExpertController extends ModRewrite_ControllerAbstract {
return;
}
$source = $type == 'restrictive' ? $this->_htaccessRestrictive : $this->_htaccessSimple;
if ($type == 'restrictive') {
$source = $this->_htaccessRestrictive;
} else {
$source = $this->_htaccessSimple;
}
$this->_oView->content = file_get_contents($source);
header('Content-Type: text/plain');
header('Etag: ' . md5(random_int(0, mt_getrandmax())));
header('Etag: ' . md5(mt_rand()));
header('Content-Disposition: attachment; filename="' . $type . '.htaccess"');
$this->render('{CONTENT}');
}

Datei anzeigen

@ -60,25 +60,33 @@ class ModRewrite_ContentTestController extends ModRewrite_ControllerAbstract {
$this->_oView->content = '';
// Array for testcases
$aTests = [];
$aTests = array();
// Instance of mr test
$modRewriteTest = new ModRewriteTest($this->_iMaxItems);
$oMRTest = new ModRewriteTest($this->_iMaxItems);
$startTime = getmicrotime();
// Fetch complete CONTENIDO page structure
$aStruct = $modRewriteTest->fetchFullStructure();
$aStruct = $oMRTest->fetchFullStructure();
ModRewriteDebugger::add($aStruct, 'ModRewrite_ContentTestController::testAction() $aStruct');
// Loop through the structure and compose testcases
foreach ($aStruct as $aCat) {
foreach ($aStruct as $idcat => $aCat) {
// category
$aTests[] = ['url' => $modRewriteTest->composeURL($aCat, 'c'), 'level' => $aCat['level'], 'name' => $aCat['name']];
$aTests[] = array(
'url' => $oMRTest->composeURL($aCat, 'c'),
'level' => $aCat['level'],
'name' => $aCat['name']
);
foreach ($aCat['articles'] as $aArt) {
foreach ($aCat['articles'] as $idart => $aArt) {
// articles
$aTests[] = ['url' => $modRewriteTest->composeURL($aArt, 'a'), 'level' => $aCat['level'], 'name' => $aCat['name'] . ' :: ' . $aArt['title']];
$aTests[] = array(
'url' => $oMRTest->composeURL($aArt, 'a'),
'level' => $aCat['level'],
'name' => $aCat['name'] . ' :: ' . $aArt['title']
);
}
}
@ -88,7 +96,7 @@ class ModRewrite_ContentTestController extends ModRewrite_ControllerAbstract {
$oMRUrlStack = ModRewriteUrlStack::getInstance();
// first loop to add urls to mr url stack
foreach ($aTests as $v) {
foreach ($aTests as $p => $v) {
$oMRUrlStack->add($v['url']);
}
@ -96,15 +104,15 @@ class ModRewrite_ContentTestController extends ModRewrite_ControllerAbstract {
$failCounter = 0;
// second loop to do the rest
foreach ($aTests as $aTest) {
$url = mr_buildNewUrl($aTest['url']);
$arr = $modRewriteTest->resolveUrl($url);
foreach ($aTests as $p => $v) {
$url = mr_buildNewUrl($v['url']);
$arr = $oMRTest->resolveUrl($url);
$error = '';
$resUrl = $modRewriteTest->getResolvedUrl();
$resUrl = $oMRTest->getResolvedUrl();
$color = 'green';
if ($url !== $resUrl) {
if ($modRewriteTest->getRoutingFoundState()) {
if ($oMRTest->getRoutingFoundState()) {
$successCounter++;
$resUrl = 'route to -&gt; ' . $resUrl;
} else {
@ -136,18 +144,18 @@ class ModRewrite_ContentTestController extends ModRewrite_ControllerAbstract {
}
}
$pref = str_repeat(' ', $aTest['level']);
$pref = str_repeat(' ', $v['level']);
// render resolve information for current item
$itemTpl = $this->_oView->lng_result_item_tpl;
$itemTpl = str_replace('{pref}', $pref, $itemTpl);
$itemTpl = str_replace('{name}', $aTest['name'], $itemTpl);
$itemTpl = str_replace('{url_in}', $aTest['url'], $itemTpl);
$itemTpl = str_replace('{name}', $v['name'], $itemTpl);
$itemTpl = str_replace('{url_in}', $v['url'], $itemTpl);
$itemTpl = str_replace('{url_out}', $url, $itemTpl);
$itemTpl = str_replace('{color}', $color, $itemTpl);
$itemTpl = str_replace('{url_res}', $resUrl, $itemTpl);
$itemTpl = str_replace('{err}', $error, $itemTpl);
$itemTpl = str_replace('{data}', $modRewriteTest->getReadableResolvedData($arr), $itemTpl);
$itemTpl = str_replace('{data}', $oMRTest->getReadableResolvedData($arr), $itemTpl);
$this->_oView->content .= "\n" . $itemTpl . "\n";
}

Datei anzeigen

@ -72,13 +72,13 @@ abstract class ModRewrite_ControllerAbstract {
* Template file or template string to render
* @var string
*/
protected $_template;
protected $_template = null;
/**
* Additional properties list
* @var array
*/
protected $_properties = [];
protected $_properties = array();
/**
* Debug flag
@ -138,18 +138,20 @@ abstract class ModRewrite_ControllerAbstract {
/**
* Property setter.
* @param string $key
* @param mixed $value
*/
public function setProperty($key, mixed $value) {
public function setProperty($key, $value) {
$this->_properties[$key] = $value;
}
/**
* Property getter.
* @param string $key
* @param mixed $default
* @return mixed
*/
public function getProperty($key, mixed $default = null) {
return $this->_properties[$key] ?? $default;
public function getProperty($key, $default = null) {
return (isset($this->_properties[$key])) ? $this->_properties[$key] : $default;
}
/**
@ -200,7 +202,7 @@ abstract class ModRewrite_ControllerAbstract {
* @param mixed $default The default value
* @return mixed
*/
protected function _getParam($key, mixed $default = null) {
protected function _getParam($key, $default = null) {
if (isset($_GET[$key])) {
return $_GET[$key];
} elseif (isset($_POST[$key])) {

Datei anzeigen

@ -23,10 +23,6 @@
* @link http://www.4fb.de
* @link http://www.contenido.org
*/
use ConLite\Log\LogWriter;
use ConLite\Log\Log;
if (!defined('CON_FRAMEWORK')) {
die('Illegal call');
}
@ -619,7 +615,8 @@ function mr_loadConfiguration($clientId, $forceReload = false) {
}
function mr_getConfigurationFilePath($clientId) {
$fePath = cRegistry::getFrontendPath();
$clientConfig = cRegistry::getClientConfig((int) $clientId);
$fePath = $clientConfig['path']['frontend'];
return $fePath . 'data/config/' . CL_ENVIRONMENT . '/config.mod_rewrite.php';
}
@ -683,9 +680,9 @@ function mr_setConfiguration($clientId, array $config) {
try {
mkdir($sConfigClientPath, 0777, true);
} catch (Exception $ex) {
$writer = LogWriter::factory("File", array('destination' => 'contenido.log'));
$log = new Log($writer);
$log->log($ex->getFile() . " (" . $ex->getLine() . "): " . $ex->getMessage(), Log::WARN);
$oWriter = cLogWriter::factory("File", array('destination' => 'contenido.log'));
$oLog = new cLog($oWriter);
$oLog->log($ex->getFile() . " (" . $ex->getLine() . "): " . $ex->getMessage(), cLog::WARN);
}
}