Location: PHPKode > projects > PHPExplorer > modules/archive.php
<?

require_once("../include/varsfuncs.php");
require_once("$instp/include/ziplib.php");

if($act){
$q = new Zip($zipname);
for($i=0;$act[$i];$i++) $act[$i]=$dir.$act[$i];
$q->create($act,"",$dir);
header("Location: $path"."index.php?dir=$dir&rand=".rand(0,999));
exit();}

if($target_archive=="new"&&$newarch){
  if(!@file_exists($newarch)){
   $q=new Zip($newarch); $q->create("");
 }
}

if(!file_exists($target_archive)){ fclose(fopen($target_archive,"w+"));  $q=new Zip($newarch); $q->create(""); }

if(!$target_archive){
  include("$instp/skins/$sk/_pl_clipb/_archive_choice.php");
exit();}

if($flist&&$target_archive&&$ac!="Restaurer"){
set_time_limit(100);
$q=new Zip($target_archive);
if($q->listContent()===0) $q->create("");
function archivedir($d){
 if(substr($d,-1,1)!="/") $d.="/";
 $k=@explode("@",@fgets(@fopen($d."_wgzxv.pid","r"),999));
 $cut=$k[1]; $from=$k[0]; if(substr($from,-1,1)!="/") $from.="/";
 $z=opendir($d); readdir($z); readdir($z);
 while($a=readdir($z)){
   if(is_dir($d.$a)) archivedir($d.$a."/");
   else @unlink($d.$a);
 }
 @rmdir($d);
 return $from."/*/".$cut;
}

if(substr($tmpd,-1,1)!="/") $tmpd.="/";
$z=opendir($tmpd);
while($d=readdir($z)){
  if($d!="."&&$d!=".."){
    for($i=0;$flist[$i];$i++){
      if($flist[$i]==$d||$flist[$i].".txt"==$d){
         if(is_dir($tmpd.$d)){
	$k=explode("/*/",archivedir($tmpd.$d)); $fro=$k[0]; $cut=$k[1];
	$q->add($fro,"",dirname($fro));
	if($cut) @delrep($from);
         }else{
	$k=@explode("@",@fgets(@fopen($tmpd.$d,"r"),999)); $fro=$k[0]; $cut=$k[3];
	$q->add($fro,"",$k[1]);
	@unlink($tmpd.$d);
	if($cut) @unlink($fro);
         }
     }
   }
  }
}
exit("<html><Script>alert('Les fichiers ont été archivés !'); window.location.href='$PHP_SELF?target_archive=$target_archive&dir=$dir';</Script></html>");
}

if($ac=="Restaurer"&&$flist){
$z=opendir($tmpd);
 while($s=readdir($z)){
  for($i=0;$flist[$i];$i++){
   $e=$flist[$i];
   if($s==$e||$s==$e.".txt"){
    if(is_dir($tmpd."/".$s)){
      delrep($tmpd."/".$s);
    }else{
      unlink($tmpd."/".$s);
    }
  }
 }}
header("Location: $PHP_SELF?dir=$dir&target_archive=$target_archive&rand=".rand(0,999));
exit();}

//---- Headers
include("$instp/skins/$sk/_pl_clipb/_archive_head.php");
//---- Analyse Temp dir
$z=opendir($tmpd); $nn=0;
while($d=readdir($z)){
//---- Must not be current and parent folder
 if($d!="."&&$d!=".."){$nn++;
//---- Directory ?
  if(is_dir($tmpd."\\".$d)){
//--- Shortcut analyse
   $fromdir=fgets(fopen($tmpd."\\".$d."\\_wgzxv.pid","r"),9999);
//---- Split the params separed by @
   $piec=explode("@",$fromdir); $cut=$piec[1];
//---- Copied or Cutted ?
   $fromdir=$piec[0]; if($cut==1) $cut="Oui"; else $cut="Non";
//---- List elements (dirs)
include("$instp/skins/$sk/_pl_clipb/_list.php");
  }else{
   $k=explode("@",fgets(fopen($tmpd."\\".$d,"r"),9999));
//---- Copied/Cutted ? -- Original directory
   $fromdir=$k[1]; $cut=$k[3]; $d=$k[2]; 
   if($cut==1) $cut="Oui"; else $cut="Non"; 
//---- List elements (files)
include("$instp/skins/$sk/_pl_clipb/_list.php");
  }
 }
}if($nn==0){ 
//---- Clipboad empty
include("$instp/skins/$sk/_pl_clipb/_empty.php");
}
include("$instp/skins/$sk/_pl_clipb/_archive_foot.php");

?>
Return current item: PHPExplorer