‣ Downloading:
"; $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, "http://ars247.com/$mod/latest.php?get&ver=$ver"); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $data = curl_exec($curl); curl_close($curl); echo "    ✔ Downloaded.
"; } catch (Exception $ex) { echo "    ☠ Error downloading:
"; echo("
" . $ex->getMessage() . "
"); exit(1); } // Save it locally as install.zip try { echo " ‣ Saving:
"; $file = fopen("./install.zip", "w+"); fputs($file, $data); fclose($file); echo "    ✔ Saved.
"; } catch (Exception $ex) { echo "    ☠ Error saving:
"; echo("
" . $ex->getMessage() . "
"); exit(1); } // Make sure it did indeed download and save if (file_exists("./install.zip")) { // Unzip - Method 1 try { echo " ‣ Extracting using method 1:
"; $zip = new ZipArchive; $res = $zip->open("./install.zip"); if ($res) { $zip->extractTo(dirname(__FILE__) . "/"); $zip->close(); echo "    ✔ Extracted.
"; } else { echo "    ☠ Error decompressing:
"; echo("
Unknown error
"); exit(1); } } catch (Exception $ex) { echo "    ☠ Error decompressing:
"; echo("
" . $ex->getMessage() . "
"); exit(1); } // If the above unzip failed (missing library or whatever) then try with low level method if (!file_exists("./install.php")) { // Unzip - Method 2 try { echo " ‣ Extracting using method 2:
"; $zip = zip_open("./install.zip"); if ($zip) { while ($zip_entry = zip_read($zip)) { // Open directory entry for reading if (zip_entry_open($zip, $zip_entry)) { // Read open directory entry $filename = zip_entry_name($zip_entry); $filesize = intval(zip_entry_filesize($zip_entry)); $contents = zip_entry_read($zip_entry, $filesize); // Write to file file_put_contents($filename, $contents); zip_entry_close($zip_entry); } else { echo "    ☠ Error opening ZIP entry:
"; echo("
Unknown error
"); exit(1); } } zip_close($zip); } else { echo "    ☠ Error opening ZIP:
"; echo("
Unknown error
"); exit(1); } } catch (Exception $ex) { echo "    ☠ Error decompressing:
"; echo("
" . $ex->getMessage() . "
"); exit(1); } } } else { echo "    ☠ Error: Missing install.zip (2):
"; echo("
" . $ex->getMessage() . "
"); exit(1); } // Clean up echo "  ‣ Clean up
"; if (file_exists("./install.zip")) { unlink("./install.zip"); echo "    ✔ Removed install.zip
"; } unlink(__FILE__); echo "    ✔ Removed " . __FILE__ . "
"; // Launch installer echo " ";