The purpose of this code is to pull upgrade.zip from a central server, extract it and place it in a folder on the resident server. I get no errors, it just results in the die("!There was a problem. Please try again!");
require('../../../wp-blog-header.php');
function openZip($file_to_open) {
global $target;
$zip = new ZipArchive();
$x = $zip->open($file_to_open);
if($x === true) {
$zip->extractTo($target);
$zip->close();
unlink($file_to_open);
} else {
die("!There was a problem. Please try again!");
}
}
$payload = file_get_contents('http://myserver.com/upgrade.zip');
if(isset($payload))
{
$filename = 'upgrade.zip';
$source = file_get_contents('http://myserver.com/upgrade.zip');
$target = ABSPATH.'wp-content/themes/mytheme/';
// permission settings for newly created folders
$chmod = 0755;
$saved_file_location = $target . $filename;
openZip($saved_file_location);
}
You get the contents of the remote zip file into a string... but you never save it anywhere.
You should investigate the return value from $zip->open()
. It may be any of the following:
ZIPARCHIVE::ER_EXISTS
ZIPARCHIVE::ER_INCONS
ZIPARCHIVE::ER_INVAL
ZIPARCHIVE::ER_MEMORY
ZIPARCHIVE::ER_NOENT
ZIPARCHIVE::ER_NOZIP
ZIPARCHIVE::ER_OPEN
ZIPARCHIVE::ER_READ
ZIPARCHIVE::ER_SEEK
Also, why not try to open the downloaded zip-file manually using your favourite unzip program to check if the file is indeed valid?