コード例 #1
0
ファイル: AppZip.php プロジェクト: ArcherSys/ArcherSysRuby
 static function installRawApp($zip, $dest_dir = false, $create_zip_name_dir = true, $overwrite = true)
 {
     $splitter = $create_zip_name_dir === true ? "." : "/";
     if ($dest_dir === false) {
         $dest_dir = substr($src_file, 0, strrpos($src_file, $splitter)) . "/";
     }
     // Create the directories to the destination dir if they don't already exist
     AppZip::createDirs($dest_dir);
     // For every file in the zip-packet
     while ($zip_entry = zip_read($zip)) {
         // Now we're going to create the directories in the destination directories
         // If the file is not in the root dir
         $pos_last_slash = strrpos(zip_entry_name($zip_entry), "/");
         if ($pos_last_slash !== false) {
             // Create the directory where the zip-entry should be saved (with a "/" at the end)
             AppZip::createDirs($dest_dir . substr(zip_entry_name($zip_entry), 0, $pos_last_slash + 1));
         }
         // Open the entry
         if (zip_entry_open($zip, $zip_entry, "r")) {
             // The name of the file to save on the disk
             $file_name = $dest_dir . zip_entry_name($zip_entry);
             // Check if the files should be overwritten or not
             if ($overwrite === true || $overwrite === false && !is_file($file_name)) {
                 // Get the content of the zip entry
                 $fstream = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
                 file_put_contents($file_name, $fstream);
                 // Set the rights
                 chmod($file_name, 0777);
                 echo "save: " . $file_name . "<br />";
             }
             // Close the entry
             zip_entry_close($zip_entry);
         }
     }
     // Close the zip-file
     zip_close($zip);
 }
コード例 #2
0
ファイル: admin.php プロジェクト: klarclm/sgv
 $adpath = $arr[count($arr) - 2];
 echo "<div class='Update'><h1>在线升级进行中第一步【文件升级】,请稍后......</h1><textarea rows=\"25\" readonly>正在下载升级文件包...\n";
 ob_flush();
 flush();
 sleep(2);
 $url = 'http://www.maccms.com/update/2014/';
 $f = !empty($p['file']) ? $p['file'] : MAC_VERSION;
 $url .= $f . '.zip';
 $html = getPage($url, 'utf-8');
 $path = 'bak/' . MAC_VERSION . '.zip';
 @fwrite(@fopen($path, 'wb'), $html);
 echo "下载升级包完毕...\n";
 ob_flush();
 flush();
 sleep(2);
 $z = new AppZip();
 if (is_file($path)) {
     echo "正在处理升级包的文件...\n\n";
     ob_flush();
     flush();
     $result = $z->Extract($path, '../');
     if ($result == -1) {
         echo "文件 {$path} 错误...\n";
         ob_flush();
         flush();
     } else {
         echo "\n文件部分处理完成,共处理 {$z->total_folders} 个目录,{$z->total_files} 个文件...\n";
         echo "\n稍后进入升级数据部分...\n";
         ob_flush();
         flush();
         @unlink($path);