I am making an auto-update system, but I am having some trouble figuring out how to download and extract a ZIP file onto my server. I dont know whether to use cURL or file_get_contents. So far, I have the code that checks for the right version and displays a dialog. My code is below.
<?php
function check_for_updates(){
$phoenix_version = '1.0.0';
$rc = @fsockopen("www.phoenix.ltda", 80, $errno, $errstr, 1);
if (is_resource($rc)) {
define('REMOTE_VERSION', 'https://phoenix.ltda/updates/version.txt');
$remote_version=trim(file_get_contents(REMOTE_VERSION));
$remote_version = preg_replace('/[^\\d.]+/', '', $remote_version);
if(version_compare($remote_version, $phoenix_version) == 1){
echo 'New Version Detected!';
}
}
}
}
check_for_updates();
?>
How would I fetch the update ZIP from my server and extract it to the root directory (public_html or httpdocs) with PHP? Other questions only mentioned reading the ZIP file.