$action();
}
if (!isset($GLOBALS['PHP_SELF'])) {
$GLOBALS['PHP_SELF'] = 'wm_install.php';
}
if (!file_exists('includes/application_top.php') && file_exists('../includes/application_top.php')) {
rename('./wm_install.php', '../wm_install.php');
header('Location:../wm_install.php');
exit;
}
include 'includes/application_top.php';
$isLoggedInAsAdmin = isset($_SESSION['customers_status']['customers_status_id']) && empty($_SESSION['customers_status']['customers_status_id']);
$this->printPage($isLoggedInAsAdmin);
}
private function respond($msg = ['success' => true]) {
echo json_encode($msg);
exit;
}
private function isZipSupported() {
if (class_exists('ZipArchive')) {
$this->respond();
} else {
$this->respond(['success' => false, 'continue' => false, 'msg' => 'PHP ZipArchive erforderlich! Bitte an Serveradmin oder Webhoster wenden!']);
}
}
private function checkDirectories() {
if ($this->checkDirectory('./cache') && $this->checkDirectory('./GXModules') && (!is_dir('./GXModules/Werbe-Markt') || $this->checkDirectory('./GXModules/Werbe-Markt'))) {
$this->respond();
} else {
$this->respond(['success' => false, 'continue' => false, 'msg' => 'Bitte prüfen Sie, dass sich die wm_install.php im Wurzelverzeichnis Ihres Shops befindet und das cache sowie GXModules-Verzeichnis beschreibbar sind (Zugriffsrechte via FTP-Programm setzen)!']);
}
}
private function checkDirectory($dir) {
if (is_dir($dir) && function_exists('is_writeable') && is_writable($dir)) {
return true;
}
$file = $dir . '/' . uniqid();
if (@touch($file)) {
unlink($file);
return true;
}
return false;
}
private function getZipFile() {
$ch = curl_init('https://www.werbe-markt.de/gambio_api/2/');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(['action' => 'getFile', 'id' => 72117, 'version' => $this->version]));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$res = curl_exec($ch);
$curlErr = curl_error($ch);
curl_close($ch);
if (!empty($curlErr)) {
$this->respond(['success' => false, 'continue' => false, 'msg' => 'Die Zip-Datei konnte nicht heruntergeladen werden! cURL-Fehler:
' . $curlErr]);
} elseif (!empty($res)) {
file_put_contents('./cache/gambioinstaller.zip', base64_decode($res));
$this->respond();
}
$this->respond(['success' => false, 'continue' => false, 'msg' => 'Die Zip-Datei konnte nicht heruntergeladen werden!']);
}
private function checkZipFile() {
if (md5_file('./cache/gambioinstaller.zip') === $this->checksum) {
$this->respond();
}
$this->respond(['success' => false, 'continue' => false, 'msg' => 'Die Zip-Datei scheint beschädigt zu sein!']);
}
private function extractZip() {
$zip = new ZipArchive();
if ($zip->open('./cache/gambioinstaller.zip') === true) {
$srcDir = './cache/tmp_install';
if (!file_exists($srcDir)) {
mkdir($srcDir, 0777);
}
$zip->extractTo($srcDir);
$zip->close();
if (is_dir($srcDir . '/Werbe-Markt')) {
$this->copyDir($srcDir . '/Werbe-Markt', './GXModules/Werbe-Markt');
} else {
$this->respond(['success' => false, 'continue' => false, 'msg' => 'Die Zip-Datei scheint beschädigt zu sein!']);
}
$this->respond();
} else {
$this->respond(['success' => false, 'continue' => false, 'msg' => 'Die Zip-Datei scheint beschädigt zu sein!']);
}
}
private function deleteZip() {
$file = './cache/gambioinstaller.zip';
if (!file_exists($file) || unlink($file)) {
$this->respond();
} else {
$this->respond(['success' => false, 'continue' => true, 'msg' => 'Die Datei ' . $file . ' konnte nicht gelöscht werden. Bitte löschen Sie die Datei manuell.']);
}
}
private function deleteTmpDir() {
$dir = './cache/tmp_install';
$this->cleanDir($dir);
if (!file_exists($dir)) {
$this->respond();
} else {
$this->respond(['success' => false, 'continue' => true, 'msg' => 'Das temporäre Verzeichnis ' . $dir . ' konnte nicht gelöscht werden. Bitte löschen Sie es manuell.']);
}
}
private function deleteInstallFile() {
if ((!isset($_SERVER['HTTP_HOST']) || $_SERVER['HTTP_HOST'] !== 'bumbio.de') && unlink(__FILE__)) {
$this->respond();
} else {
$this->respond(['success' => false, 'continue' => true, 'msg' => 'Die Datei ./wm_install.php konnte nicht gelöscht werden. Bitte löschen Sie die Datei manuell.']);
}
}
private function cleanDir($dir) {
if (strpos($dir, '/cache/tmp_install') !== false && is_dir($dir)) {
foreach (array_diff(scandir($dir), ['..', '.']) as $file) {
if (is_dir($dir . '/' . $file)) {
$this->cleanDir($dir . '/' . $file);
} else {
unlink($dir . '/' . $file);
}
}
if (count(scandir($dir)) == 2) {
rmdir($dir);
}
}
}
private function copyDir($src, $dst) {
if (!file_exists($dst)) {
mkdir($dst, 0777, true);
}
foreach (array_diff(scandir($src), ['..', '.']) as $file) {
if (is_dir($src . '/' . $file)) {
$this->copyDir($src . '/' . $file, $dst . '/' . $file);
} else {
copy($src . '/' . $file, $dst . '/' . $file);
}
}
}
public function printPage(bool $isLoggedInAsAdmin) {
?>
Die verwendete PHP-Version ist leider veraltet. Die Modulverwaltung benötigt mindestens PHP minPhpVersion; ?>.
Bitte zunächst als Shop-Administrator (Gambio-Admin) einloggen.