class ZipArchive not found.) This updater cannot proceed without it.
You might be able to add zip support via your cPanel/WHM interface. Look for Module Installers, and try installing zip via PHP Pecl installer.";
http_response_code(400);
die($error);
}
if (isset($_REQUEST['backup'])) {
require_once '../Updater.php';
$updater = new Updater('ads-ez');
$updater->backup();
exit();
}
if (empty($_FILES)) {
http_response_code(400);
die("File upload error. No files reached the server!");
}
$ds = DIRECTORY_SEPARATOR;
$target = realpath("..$ds..") . $ds;
$ftp = new Ftp();
if (Ftp::isNeeded($target)) {
if (!$ftp->isReady) {
$error = "Cannot overwrite the Ads EZ files! Here are your options to proceed."
. "
dbCfg.php, and upload the rest to your server, overwriting the existing files.chmod -R 777 $target$root.";
die($error);
}
$toVerify = array('ads-ez.php', 'wp-ads-ez.php', 'ad.php', 'adServer.php');
foreach ($toVerify as $d) {
$idx = $zip->locateName($d, ZipArchive::FL_NODIR);
if ($idx === false) {
$idx = $zip->locateName($d);
}
if ($idx === false) {
$error = "Cannot locate a critical file ($d) in the uploaded zip file.";
http_response_code(400);
die($error);
}
}
// files to remove from the archive -- not to overwrite on the user's DB server details
$toDelete = array('dbCfg.php');
foreach ($toDelete as $d) {
$idx = $zip->locateName($d, ZipArchive::FL_NODIR);
if ($idx === false) {
$idx = $zip->locateName($d);
}
if ($idx === false) {
$error = "Cannot locate a critical file ($d) in the uploaded zip file.";
http_response_code(400);
die($error);
}
if (!$zip->deleteIndex($idx)) {
$error = "Cannot delete the empty file ($d) from the archive.";
http_response_code(400);
die($error);
}
}
$zip->close();
if ($zip->open($tmpName) !== TRUE) {
$error = "Cannot reopen the uploaded zip file (after removing config).";
http_response_code(400);
die($error);
}
$zipRoot = $zip->getNameIndex(0);
for ($i = 1; $i < $zip->numFiles; $i++) {
$filename = $zip->getNameIndex($i);
$sourceFile = "zip://$tmpName#$filename";
$targetFile = str_replace($zipRoot, $target, $filename);
if (is_dir($targetFile)) {
++$dirCount;
continue;
}
$lastChar = substr($sourceFile, -1);
if ($lastChar == $ds || $lastChar == '/') {
if (!$ftp->mkdir($targetFile)) {
$error = "Error creating the directory $targetFile";
http_response_code(400);
die($error);
}
continue;
}
$targetDir = dirname($targetFile);
if (!is_dir($targetDir) && !@$ftp->mkdir($targetDir)) {
$error = "Error creating the new folder $targetDir";
http_response_code(400);
die($error);
}
if (!$ftp->copy($sourceFile, $targetFile)) {
$error = "Error copying $filename to $targetFile";
http_response_code(400);
die($error);
}
}
if ($dirCount > 0) {
$warning = "Ignoring $dirCount folders, which already exist on your server.