diff --git a/action/ajax.php b/action/ajax.php index 8eca95b..f038557 100644 --- a/action/ajax.php +++ b/action/ajax.php @@ -470,7 +470,7 @@ private function __get_siteexport_list_and_init_tocs($NS, $isRedirected = false) * Add page with ID to the package **/ private function __siteexport_add_site($ID) { - global $conf, $CURRENT_ID, $CURRENT_PARENT; + global $conf, $CURRENT_ID, $CURRENT_PARENT, $INPUT; // Which is the current ID? $CURRENT_ID = $ID; @@ -486,17 +486,17 @@ private function __siteexport_add_site($ID) { // say, what to export and Build URL // http://documentation:81/helpdesk/de/hds/getting-started?depthType=0&do=siteexport&ens=helpdesk%3Ade%3Ahds%3Agetting-started&pdfExport=1&renderer=siteexport_siteexportpdf&template=helpdesk - $do = (intval($_REQUEST['exportbody'] ?? 0) == 1 ? (empty($_REQUEST['renderer'] ?? '') ? $conf['renderer_xhtml'] : $_REQUEST['renderer']) : ''); + $do = $INPUT->int('exportbody', 0, true) == 1 ? $INPUT->str('renderer', $conf['renderer_xhtml'], true) : ''; if ($do == 'pdf' && $this->filewriter->canDoPDF()) { $do = 'export_siteexport_pdf'; - $_REQUEST['origRenderer'] = (empty($_REQUEST['renderer']) ? $conf['renderer_xhtml'] : $_REQUEST['renderer']); - } else if ( ($_REQUEST['renderer'] ?? '') == 'dw2pdf') { + $INPUT->set('origRenderer', $INPUT->str('renderer', $conf['renderer_xhtml'], true)); + } else if ($INPUT->str('renderer') == 'dw2pdf') { $do = 'pdf'; } - $do = ($do == $conf['renderer_xhtml'] && intval($_REQUEST['exportbody']) != 1) ? '' : 'export_' . $do; + $do = ($do == $conf['renderer_xhtml'] && $INPUT->int('exportbody', 0, true) != 1) ? '' : 'export_' . $do; if ($do != 'export_' && !empty($do) ) { @@ -504,8 +504,8 @@ private function __siteexport_add_site($ID) { } // set Template - if (!empty($_REQUEST['template'])) { - $request['template'] = $_REQUEST['template']; + if (!empty($INPUT->str('template'))) { + $request['template'] = $INPUT->str('template'); } $this->functions->debug->message("REQUEST for add_site:", $request, 2); @@ -1040,6 +1040,8 @@ private function __fetchAndReplaceLinkFinish( $DATA, $url, $noDeepReplace, $newA $this->functions->debug->message("Final Link after empty file from '$url'", null, 2); return $link; + } elseif ($tmpFile === true) { + return "file_not_found_and_ignored.html"; } $this->functions->debug->message("The fetched file looks good.", $tmpFile, 2); @@ -1233,13 +1235,16 @@ private function __getInternalRewriteURL($url) { **/ private function __getParamsAndDataRewritten(&$DATA, &$PARAMS, $IDKEY = 'id') { + if (empty($PARAMS)) + return array(); + $PARRAY = explode('&', str_replace('&', '&', $PARAMS)); $PARAMS = array(); foreach ($PARRAY as $item) { - list($key, $value) = explode('=', $item, 2); + list($key, $value) = array_pad( explode('=', $item, 2), 2, null ); if (empty($key) || empty($value)) - continue; + continue; if (strtolower(trim($key)) == $IDKEY) { $DATA[2] = preg_replace("%^" . preg_quote(DOKU_BASE, '%') . "%", "", str_replace(':', '/', $value)); diff --git a/helper.php b/helper.php index a032ad6..c393864 100644 --- a/helper.php +++ b/helper.php @@ -143,7 +143,7 @@ public function __getOrderedListOfPagesForStartEnd($ID, $start, $end) public function __siteexport_addpage() { - global $ID, $conf; + global $ID, $conf, $INPUT; $templateSwitching = false; $pdfExport = false; @@ -177,10 +177,10 @@ public function __siteexport_addpage() { $form->addElement(form_makeTextField('ens', $ID, $this->getLang('ens') . ':', 'ens')); $form->addElement(form_makeTag('br')); - $form->addElement(form_makeListboxField('depthType', array("0.0" => $this->getLang('depth.pageOnly'), "1.0" => $this->getLang('depth.allSubNameSpaces'), "2.0" => $this->getLang('depth.specifiedDepth')), (empty($_REQUEST['depthType']) ? $this->getLang('depth.allSubNameSpaces') : $_REQUEST['depthType']), $this->getLang('depthType') . ':', 'depthType', null, array_merge(array('class' => 'edit')))); + $form->addElement(form_makeListboxField('depthType', array("0.0" => $this->getLang('depth.pageOnly'), "1.0" => $this->getLang('depth.allSubNameSpaces'), "2.0" => $this->getLang('depth.specifiedDepth')), $INPUT->str('depthType', $this->getLang('depth.allSubNameSpaces'), true), $this->getLang('depthType') . ':', 'depthType', null, array_merge(array('class' => 'edit')))); $form->addElement(form_makeTag('br')); - $form->addElement(form_makeOpenTag("div", array('style' => 'display:' . ($_REQUEST['depthType'] == "2" ? "block" : "none") . ';', 'id' => 'depthContainer'))); + $form->addElement(form_makeOpenTag("div", array('style' => 'display:' . ($INPUT->str('depthType') == "2" ? "block" : "none") . ';', 'id' => 'depthContainer'))); $form->addElement(form_makeTextField('depth', $this->getConf('depth'), $this->getLang('depth') . ':', 'depth')); $form->addElement(form_makeCloseTag("div")); diff --git a/inc/functions.php b/inc/functions.php index a68a224..599b835 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -440,6 +440,9 @@ public function parseStringToRequestArray($inputArray, $decode=false) $outputArray = $inputArray; if ( !is_array($inputArray) ) { + if (empty($inputArray)) + return array(); + $intermediate = str_replace("&", "&", $inputArray); $outputArray = array(); @@ -677,7 +680,9 @@ public function getRelativeURL($replaceURL, $baseURL, $existingPageID = null) $isExternalPage = count($baseParts) == $originalBasePartsCount; // the new page is in the same plugin, with a different subcontext and same language - $isExternalPage = $isExternalPage || ($didKickSomeParts == 1 && $baseParts[0] != $replaceParts[0] && $baseParts[1] == $replaceParts[1] ); + $parts0equal = (isset($baseParts[0]) && isset($replaceParts[0]) && $baseParts[0] == $replaceParts[0]); + $parts1equal = (isset($baseParts[1]) && isset($replaceParts[1]) && $baseParts[1] == $replaceParts[1]); + $isExternalPage = $isExternalPage || ($didKickSomeParts == 1 && !$parts0equal && $parts1equal); // find out if this is outside of our own export context, beyond the baseURL $offsiteTemplate = $this->getConf("offSiteLinkTemplate"); diff --git a/inc/httpproxy.php b/inc/httpproxy.php index a6912a9..1601187 100644 --- a/inc/httpproxy.php +++ b/inc/httpproxy.php @@ -35,7 +35,7 @@ class HTTPProxy extends _HTTPProxy { * @param siteexport_functions $functions */ public function __construct($functions) { - global $conf; + global $conf, $INPUT; // The proxy should only be used if configured. // Usually the proxy will allow connections away from the current server. @@ -74,9 +74,9 @@ public function __construct($functions) { $this->headers['X-Real-Ip'] = clientIP(true); $this->headers['X-Site-Exporter'] = $functions->getSecurityToken(); - $this->headers['Accept-Encoding'] = $_SERVER['HTTP_ACCEPT_ENCODING'] ?? ''; - $this->headers['Accept-Charset'] = $_SERVER['HTTP_ACCEPT_CHARSET'] ?? ''; - $this->agent = $_SERVER['HTTP_USER_AGENT'] . ' DokuWiki/SiteExport'; + $this->headers['Accept-Encoding'] = $INPUT->server->str('HTTP_ACCEPT_ENCODING'); + $this->headers['Accept-Charset'] = $INPUT->server->str('HTTP_ACCEPT_CHARSET'); + $this->agent = $INPUT->server->str('HTTP_USER_AGENT') . ' DokuWiki/SiteExport'; } /** diff --git a/inc/settings.php b/inc/settings.php index 649543a..33c5ba6 100644 --- a/inc/settings.php +++ b/inc/settings.php @@ -98,7 +98,7 @@ public function __construct($functions) { $ens = $INPUT->str( 'ens' ); $this->exportNamespace = !empty($ens) && preg_match("%^" . preg_quote($functions->getNamespaceFromID($ens, $pg), '%') . "%", $this->namespace) ? $functions->getNamespaceFromID($ens, $pg) : $this->namespace; - $this->TOCMapWithoutTranslation = intval($_REQUEST['TOCMapWithoutTranslation'] ?? 0) == 1 ? true : false; + $this->TOCMapWithoutTranslation = ($INPUT->int('TOCMapWithoutTranslation', 0, true) == 1); $this->defaultLang = $INPUT->str( 'defaultLang', $conf['lang'], true ); diff --git a/preload.php b/preload.php index 7bea291..d018b0e 100644 --- a/preload.php +++ b/preload.php @@ -176,13 +176,15 @@ class preload_plugin_siteexport_controller extends _preload_plugin_siteexport_co * Setup disabling */ public function __construct() { + global $INPUT; + parent::__construct(); $disabledPlugins = array(); // support of old syntax - if (is_array($_REQUEST['diPlu'] ?? null)) { - $disabledPlugins = $_REQUEST['diPlu']; + if (is_array($INPUT->arr('diPlu'))) { + $disabledPlugins = $INPUT->arr('diPlu'); } if (!empty($_REQUEST['diInv'])) @@ -193,11 +195,11 @@ public function __construct() { if ($enabled == 1 && !file_exists(DOKU_PLUGIN . "$plugin/script.js") && !file_exists(DOKU_PLUGIN . "$plugin/style.css") && !file_exists(DOKU_PLUGIN . "$plugin/print.css")) { continue; } $allPlugins[] = $plugin; } - $disabledPlugins = empty($_REQUEST['diPlu']) ? $allPlugins : array_diff($allPlugins, $_REQUEST['diPlu']); + $disabledPlugins = empty($INPUT->arr('diPlu')) ? $allPlugins : array_diff($allPlugins, $INPUT->arr('diPlu')); } // if this is defined, it overrides the settings made above. obviously. - $disabledPlugins = empty($_REQUEST['disableplugin']) ? $disabledPlugins : $_REQUEST['disableplugin']; + $disabledPlugins = $INPUT->arr('disableplugin', $disabledPlugins, true); foreach ($disabledPlugins as $plugin) { $this->disable($plugin);