1
0
Fork 0

optimize for php8

Dieser Commit ist enthalten in:
o.pinke 2023-07-19 18:59:11 +02:00
Ursprung e9d44453fb
Commit 606b832ce8
3 geänderte Dateien mit 27 neuen und 49 gelöschten Zeilen

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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