$files = array('/config.zip', '/bin/assets.zip', '/bin/libraries.zip', '/bin/minecraft.jar', '/bin/natives.zip'); foreach ($files as $file) { $fileNow = 'clients/' . $client . $file; if (!file_exists($fileNow)) { die('error'); } } break; case 'origZipsSize': if ($_POST['files'] == "") { die("error"); } $paths = explode(',', $_POST['files']); foreach ($paths as $p) { $file = 'clients/' . $_POST['server'] . '/' . $p; echo $p . '-' . get_zip_originalsize($file) . ','; } break; case 'filesList': $path = 'clients/' . $_POST['server']; $all_files = array(); GetListFiles($path, $all_files); $filesList = str_replace($path, "", implode(",", $all_files)); exit($filesList); break; case 'filesSize': $files = explode(",", $_POST['files']); $totalSize = 0; foreach ($files as $file) { $fileOne = "clients/" . $_POST['server'] . $file; $totalSize = $totalSize + filesize($fileOne);
//远程下载文件 if ($action == 'downloadFile') { if (is_dir('app')) { //完整版时 echo 1; exit; } else { $d = curl_get($download_file_url); if (strlen($d) < 2787715) { //下载失败 exit; } $zipFile = 'hdcms.zip'; file_put_contents($zipFile, $d); //解包 get_zip_originalsize($zipFile, './'); function dcopy($old, $new) { is_dir($new) or mkdir($new, 0755, TRUE); foreach (glob($old . '/*') as $v) { if ($v != 'upload/install.php') { $to = $new . '/' . basename($v); is_file($v) ? copy($v, $to) : dcopy($v, $to); } } return TRUE; } dcopy('upload', '.'); //删除目录 function del($dir) {
error_reporting(0); //设置错误级别0 require_once "../config.php"; //引入配置文件 require_once 'function.php'; //引入函数库 require_once "connect.php"; require_once "usercheck.php"; $destination_folder = '../data/'; $newfname = $destination_folder . basename($url); $file = fopen($url, "rb"); if ($file) { $newf = fopen($newfname, "wb"); if ($newf) { while (!feof($file)) { fwrite($newf, fread($file, 1024 * 8), 1024 * 8); } } } if ($file) { fclose($file); } if ($newf) { fclose($newf); } $jieya = get_zip_originalsize("../data/" . basename($url), '../'); if ($jieya == "ok") { echo "ok.更新完成"; } else { echo "bad.无法解压更新文件"; }