Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
action_compress_file.php
Package: Generateur_v13.rar [view]
Upload User: feiyaoda
Upload Date: 2016-11-21
Package Size: 9556k
Code Size: 7k
Category:
WEB Mail
Development Platform:
PHP
- <?php
- include ('action_move_functions.php');
- // these parameters are given to compressor
- $archive_path = $_POST['archive_path'];
- $relative_paths = $_POST['relative_paths'];
- $compression_level = $_POST['compression_level'];
- $use_compression = $_POST['use_compression'];
- if ($_POST['do_not_verbose'])
- {
- $_INI['verbose'] = false;
- }
- if ($_POST['recursive_on_folders'])
- {
- // we copy it into a tmp variable
- $tmp_buffer_selection_files = $buffer_selection_files;
- foreach ($buffer_selection_files as $id => $filepath)
- {
- if (is_dir($filepath))
- $tmp_buffer_selection_files = r_add_files($filepath,$tmp_buffer_selection_files);
- else
- $tmp_buffer_selection_files[] = $filepath;
- }
- $buffer_selection_files=$tmp_buffer_selection_files;
- unset($tmp_buffer_selection_files);
- }
- // we flip it twice.
- // with this artifact we are sure that only one value exists : only one file
- $tmp = array_flip ($buffer_selection_files);
- $buffer_selection_files = array_flip ($tmp);
- echo sprintf($get_string->get('going_to_compress'),count($buffer_selection_files))."<br>n";
- if ($perform_compression)
- {
- // creating archive in correct folder
- $archive_path = $target_folder.$archive_path;
- // we checks if already exists
- if ($_POST['target_overwrite'])
- {
- if (is_file($archive_path)) die("<p class="error_box">".sprintf($get_string->get('file_already_exists'),$archive_path)."</p>n");
- }
- else echo "no check";
- $compression_begin_time = getmicrotime();
- switch($use_compression)
- {
- case 'tar':
- {
- if ($_POST['auto_add_ext']) $archive_path .= ".tar";
- include('action_tar_file.php');
- break;
- }
- case 'targzip':
- {
- $gzip_compression = true;
- if ($_POST['auto_add_ext']) $archive_path .= ".tgz";
- include('action_tar_file.php');
- break;
- }
- case 'gzip':
- {
- if ($_POST['auto_add_ext']) $archive_path .= ".gz";
- echo "<b>Not yet implemented</b>n";
- break;
- }
- case 'zip':
- {
- if ($_POST['auto_add_ext']) $archive_path .= ".zip";
- include('action_zip_file.php');
- break;
- }
- case 'bzip2':
- {
- if ($_POST['auto_add_ext']) $archive_path .= ".bz2";
- echo "<b>Not yet implemented</b>n";
- break;
- }
- case 'tarbzip2':
- {
- if ($_POST['auto_add_ext']) $archive_path .= ".tbz2";
- include('action_tarbzip2_file.php');
- break;
- }
- default:
- {
- die('<p class="error_box">'.$get_string->get('unknown_compression').'</p>');
- break;
- }
- }
- if ($compressor_return)
- {
- echo "<p class="success_box">".sprintf($get_string->get('create_arch_success'),$archive_path)."</p>n";
- }
- else
- {
- echo "<p class="error_box">".sprintf($get_string->get('create_arch_failed'),$archive_path)."</p>n";
- }
- $compression_end_time = getmicrotime();
- if (is_file($archive_path))
- {
- echo sprintf($get_string->get('compressor_stat_time'),number_format(($compression_end_time - $compression_begin_time),1),$compressor_files_added)."<br>n";
- // compressor_compressed_size
- $ccs = filesize($archive_path);
- // compressor_uncompressed_size
- $cus = $compressor_uncompressed_size;
- echo sprintf($get_string->get('compressor_stat_ratio'),FormatTailleFichier($cus,$get_string->get('file_size_unit')),FormatTailleFichier($ccs,$get_string->get('file_size_unit')),number_format(($cus/$ccs),0))."<br>n";
- if ($compressor_level_used) echo $get_string->get('compressor_stat_level')." <b>$compression_level</b>n";
- }
- if ($_POST['delete_source_after'])
- {
- if ($compressor_return)
- include('action_delete_file.php');
- }
- }// end of perform compression
- else
- {
- /*
- * WE ask for what kind of compression is wanted
- *
- */
- switch($pre_compression_method)
- {
- case 'tar': $cktar = ' selected'; break;
- case 'gzip': $ckgzip = ' selected'; break;
- case 'targzip': $cktargzip = ' selected'; break;
- case 'zip': $ckzip = ' selected'; break;
- case 'bzip2': $ckbzip2 = ' selected'; break;
- case 'tarbzip2':$cktarbzip2 = ' selected'; break;
- default:break;
- }
- echo "<form action=execute.php method=POST>n";
- migrate_across_request();
- echo "<input type=hidden name=perform_compression value=1>n";
- echo "<table border=0 cellpadding=2>n";
- echo "<tr><th>".$get_string->get('current_folder')."</th><td>".realpath_alternative($target_folder,true)."</td></tr>n";
- // input archive_path
- echo "<tr><th>".$get_string->get('save_to_archive')."</th><td><input type=text name="archive_path" value="archive" style="width:400px"></td></tr>n";
- // input auto_add_ext
- echo "<tr><th>".$get_string->get('auto_add_ext')."</th><td><input type=checkbox name="auto_add_ext" value="1" checked></td></tr>n";
- // target_overwrite
- echo "<tr><th>".$get_string->get('auto_overwrite')."</th><td><input type=checkbox name="target_overwrite" value="1" checked></td></tr>n";
- // separator
- echo "<tr><td colspan="2" align=center><hr></td></tr>n";
- // input relative_paths
- echo "<tr><th>".$get_string->get('use_paths')."</th><td><input type=radio name="relative_paths" value="true" checked> ".$get_string->get('relative')." <input type=radio name="relative_paths" value="false"> ".$get_string->get('absolute')."</td></tr>n";
- // input recursive_on_folders
- echo "<tr><th>".$get_string->get('recurse_add_dir_content')."</th><td><input type=checkbox name="recursive_on_folders" value="true" checked></td></tr>n";
- // input delete_source_after
- echo "<tr><th>".$get_string->get('delete_src_on_success')."</th><td><input type=checkbox name="delete_source_after" value="true"></td></tr>n";
- // input delete_source_after
- echo "<tr><th>".$get_string->get('do_not_verbose')."</th><td><input type=checkbox name="do_not_verbose" value="true"></td></tr>n";
- // input use_compression
- echo "<tr><th>".$get_string->get('compression')."</th><td>n";
- echo "<select name="use_compression">n";
- echo "<option value="">".$get_string->get('choose_compression')."</option>n";
- echo "<option value="tar"$cktar>".$get_string->get('tar')."</option>n";
- if ($_PHP_EXT['gzip'])
- {
- //echo "<option value="gzip"$ckgzip>".$get_string->get('gzip')."</option>n";
- echo "<option value="targzip"$cktargzip>".$get_string->get('targzip')."</option>n";
- echo "<option value="zip"$ckzip>".$get_string->get('zip')."</option>n";
- }
- if ($_PHP_EXT['bzip2'])
- {
- //echo "<option value="bzip2"$ckbzip2>".$get_string->get('bzip2')."</option>n";
- echo "<option value="tarbzip2"$cktarbzip2>".$get_string->get('tarbzip2')."</option>n";
- }
- echo "</select>n";
- echo "</td></tr>n";
- echo "<tr><th>".$get_string->get('compression_level')."</th><td><select name="compression_level">";
- echo "<option value="0">0 ".$get_string->get('compression_fastest')."</option>n";
- echo "<option value="1">1</option>n";
- echo "<option value="2">2</option>n";
- echo "<option value="3">3</option>n";
- echo "<option value="4">4</option>n";
- echo "<option value="5">5</option>n";
- echo "<option value="6">6</option>n";
- echo "<option value="7">7</option>n";
- echo "<option value="8">8</option>n";
- echo "<option value="9" selected>9 ".$get_string->get('compression_slowest')."</option>n";
- echo "</select>n";
- echo "</td></tr>n";
- echo "<tr><td colspan="2" align=center><input type=submit name="submit" value=">> ".$get_string->get('create_archive')." <<"></td></tr>n";
- echo "</table>n";
- echo "</form>n";
- }