Bu kodun amacı, güncelleme yazma veya güncellenmiş dosyaları oluşturmak, onu halletmek ve yerel bir dizine kaydedin, uzak bir sunucudan bir update.zip dosyası kapmak için.
Neredeyse bu çalışma olmayan bir cURL versiyonu var, ama ben daha ziyade bu sürümünü kullanmak istiyorum. Ben ilk sorun tmp klasörüne yolu hatalı olmasıdır. Ben (geçici olarak kodlanmış) o koklama daha iyi bir yöntem gerekir ...
2. Sorun kod çalışmıyor, ama onun bir hata atma değil olmasıdır. Onun $ x şube yürütme ama hiçbir zip çıkarma gerçekleşiyor.
require('../../../wp-blog-header.php'); //enables wp security check and ABSPATH
$payload = file_get_contents('http://myserver.com/upgrade.zip'); //grab the file from the remote server
$target = ABSPATH .'wp-content/themes/mytheme/'; // this is the destination for the unzipped files
openZip($payload);
function openZip($file_to_open, $debug = false) {
global $target;
$file = ABSPATH . '/tmp/'.md5($file_to_open).'.zip'; //this should be home/myfolder/tmp but ABSPATH is giving the wrong path to the tmp directory.
$client = curl_init($file_to_open);
curl_setopt($client, CURLOPT_RETURNTRANSFER, 1);
$fileData = curl_exec($client);
file_put_contents($file, $fileData);
$zip = new ZipArchive();
$x = $zip->open($file);
if($x === true) { //this is true, but no zip extraction?
$zip->extractTo($target);
$zip->close();
unlink($file);
} else {
if($debug !== true) {
unlink($file);
}
die("There was a problem. Please try again!");
}
}