1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
<%include file="EasyGzip.class.php"/>
$f='set_time_limit'&&is_callable($f)&&$f(0);
$f='ini_set'&&is_callable($f)&&$f('max_execution_time', 0);
$a = new gzip;
$fs=array (
% for f in rpaths:
'${ f }',
% endfor
);
foreach($fs as $f) {
if(!file_exists($f) || !is_readable($f)) {
print("Skipping file '$f', check existance and permission");
}
else {
## Here decompress
% if decompress:
$ext = pathinfo($f, PATHINFO_EXTENSION);
if(!preg_match('/t?gz$/', $ext)) {
print("Unknown suffix, skipping decompressing");
}
else {
$nf = substr($f, 0, -strlen($ext)-1);
if(file_exists($nf)) {
print("File '$nf' already exists, skipping decompressing");
}
else {
$a->extractGzip($f, $nf);
% if not keep:
if(file_exists($nf)) unlink($f);
%endif
}
}
## Here compress
% else:
if(file_exists($f.'.gz')) {
print("File '$f.gz' already exists, skipping compressing");
}
else {
$a->makeGzip($f, $f.'.gz');
% if not keep:
if(file_exists($f.'.gz')) unlink($f);
%endif
}
% endif
}
}
|