/** * * @global OutputPage $wgOut * @param string $action * @param PonyDocsProduct $product * @param mixed $manual PonyDocsManual or NULL */ private function processImportForm($action, $product, $manual) { global $wgOut, $wgUser; $importer = new PonyDocsStaticDocImporter(PONYDOCS_STATIC_DIR); if (isset($_POST['version']) && isset($_POST['product']) && (is_null($manual) || isset($_POST['manual']))) { switch ($action) { case "add": if (PonyDocsProductVersion::IsVersion($_POST['product'], $_POST['version'])) { $wgOut->addHTML('<h3>Results of Import</h3>'); // Okay, let's make sure we have file provided if (!isset($_FILES['archivefile']) || $_FILES['archivefile']['error'] != 0) { $wgOut->addHTML('There was a problem using your uploaded file. Make sure you uploaded a file and try again.'); } else { try { if (is_null($manual)) { $importer->importFile($_FILES['archivefile']['tmp_name'], $_POST['product'], $_POST['version']); $wgOut->addHTML("Success: imported archive for {$_POST['product']} version {$_POST['version']}"); } else { $importer->importFile($_FILES['archivefile']['tmp_name'], $_POST['product'], $_POST['version'], $_POST['manual']); $wgOut->addHTML("Success: imported archive for {$_POST['product']} version {$_POST['version']}" . " manual {$_POST['manual']}"); } } catch (Exception $e) { $wgOut->addHTML('Error: ' . $e->getMessage()); error_log('WARNING [ponydocs] [staticdocs] [' . __METHOD__ . '] action="add" status="error"' . ' message="' . addcslashes($e->getMessage(), '"') . '"'); } } } break; case "remove": //Loading product versions for WEB-10732 PonyDocsProductVersion::LoadVersionsForProduct($_POST['product']); if (PonyDocsProductVersion::IsVersion($_POST['product'], $_POST['version'])) { $wgOut->addHTML('<h3>Results of Deletion</h3>'); try { if (is_null($manual)) { $importer->removeVersion($_POST['product'], $_POST['version']); $wgOut->addHTML("Successfully deleted {$_POST['product']} version {$_POST['version']}"); } else { $importer->removeVersion($_POST['product'], $_POST['version'], $_POST['manual']); $wgOut->addHTML("Successfully deleted {$_POST['product']} version {$_POST['version']}" . " manual {$_POST['manual']}"); } } catch (Exception $e) { $wgOut->addHTML('Error: ' . $e->getMessage()); error_log('WARNING [ponydocs] [staticdocs] [' . __METHOD__ . '] action="remove" status="error"' . ' message="' . addcslashes($e->getMessage(), '"') . '"'); } } else { $wgOut->addHTML("Error: Version {$_POST['version']} does not exist, or is not accessible"); error_log('WARNING [ponydocs] [staticdocs] [' . __METHOD__ . '] action="remove" status="error"' . ' message="version ' . $_POST['version'] . ' does not exist, or is not accessible"' . ' username="******"' . ' ip="' . IP::sanitizeIP(wfGetIP()) . '"'); } break; } $this->clearProductCache($_POST['product'], $_POST['version']); } }