1
// ********************************************************* // windows とそれ以外ではパスのセパレータ文字が違うので、注意 // ********************************************************* $sep = substr( strtoupper( php_uname("s") ), 0, 7 ) == 'WINDOWS' ? ";" : ":"; set_include_path( ".$sep../pear/zip" ); // ********************************************************* // 必要な Pear のライブラリ // ********************************************************* require_once "File/Archive.php"; if ( $_POST['send'] == "ダウンロード" ) { // ********************************************************* // 【pear のソースコード】 // ../pear/zip の下にあるファイルをアーカイブに // pear/zip というディレクトリを作成してカタログする // ********************************************************* $files = array( File_Archive::read( "../pear/zip", "pear/zip" ) ); // ********************************************************* // 【pear のソースコード】 // ../pear/zip の下にあるファイルをアーカイブにカタログする // ********************************************************* // $files = array( // "../pear/zip" // ); // ********************************************************* // File_Archive_src.zip という名前で、ダウンロード // ********************************************************* $dest = File_Archive::toArchive("File_Archive_src.zip", File_Archive::toOutput() ); $dest->newFile("code/zip_euc.php"); $v = file_get_contents( "zip_euc.php" ); $dest->writeData( $v ); File_Archive::extract( $files, $dest ); // ********************************************************* // ダウンロードさせる為にブラウザへ送信するので、以降を実行してはならない // ********************************************************* exit(); } if ( $_POST['send'] == "zipをサーバーに作成" ) { $files = array( File_Archive::read( "../pear/zip", "pear/zip" ) ); // ********************************************************* // File_Archive_src.zip という名前で、カレントディレクトリに作成 // ********************************************************* $dest = File_Archive::toArchive("File_Archive_src.zip", File_Archive::toFiles("./") ); $dest->newFile("code/zip_euc.php"); $v = file_get_contents( "zip_euc.php" ); $dest->writeData( $v ); File_Archive::extract( $files, $dest ); } if ( $_POST['send'] == "Archive.phpを解凍" ) { // ********************************************************* // 解凍するファイルの zip 内のパス // ********************************************************* $files = array( "File_Archive_src.zip/code/zip_euc.php" ); // ********************************************************* // 一つ上のディレクトリへ解凍 // ********************************************************* $dest = File_Archive::toFiles( "../" ); File_Archive::extract( $files, $dest ); } header( "Expires: Wed, 31 May 2000 14:59:58 GMT" ); header( "Content-Type: text/html; Charset=euc-jp" ); mb_language( "ja" ); mb_internal_encoding("EUC-JP"); ?>
zip 処理
( 実際に実行する場合は、disabled を削除して下さい )
( zipをサーバーに作成 を実行してからでないと処理できません )