Пример #1
0
            if ($file == '.' || $file == '..') {
                continue;
            }
            // Rekursiv, If dir: FlxZipArchive::addDir(), else ::File();
            $do = filetype($location . $file) == 'dir' ? 'addDir' : 'addFile';
            $this->{$do}($location . $file, $name . $file);
        }
    }
}
//-----------------Class------------------//
//------------------Edit------------------//
require "../config/connect.php";
require "../engine/logger.php";
$uid = $_POST['uid'];
$did = $_POST['did'];
$seldir = mysql_query("select dirname,dirpath from directories where dirid='" . $did . "'");
$fetdir = mysql_fetch_array($seldir);
$path = "../data/" . $uid . "/files" . $fetdir['dirpath'] . $fetdir['dirname'];
$zip_name = "../data/" . $uid . "/zip/" . $fetdir['dirname'] . ".zip";
$zip = new FlxZipArchive();
$res = $zip->open($zip_name, ZipArchive::CREATE);
if ($res === TRUE) {
    $zip->addDir($path, basename($path));
    $zip->close();
    echo "data/" . $uid . "/zip/" . $fetdir['dirname'] . ".zip";
} else {
    echo 'ERROR';
    exit;
}
makelogger("Getdir", $uid, "", "", $fetdir['dirname']);
//------------------Edit------------------//
 public function zip($dir, $destination)
 {
     //Don't forget to remove the trailing slash
     $the_folder = $dir;
     $zip_file_name = $destination;
     $za = new FlxZipArchive();
     $res = $za->open($zip_file_name, ZipArchive::CREATE);
     if ($res === TRUE) {
         $za->addDir($the_folder, basename($the_folder));
         $za->close();
     } else {
         echo 'Could not create a zip archive';
     }
     return $destination;
 }
Пример #3
0
function archiveZip($directory, $file)
{
    $zip = new FlxZipArchive();
    $res = $zip->open($file, ZipArchive::CREATE);
    if ($res === TRUE) {
        $zip->addDir($directory, basename($directory));
        $zip->close();
        return true;
    } else {
        return false;
    }
}
Пример #4
0
         			$string .= "'".$_POST['argument7']."'".'"'." ";
         		}
         		*/
         $shell = shell_exec($string . " 2>&1");
         if (strlen($shell) > 5 && !(strpos(strtolower($shell), 'failure') === FALSE)) {
             $RESULT['success'] = false;
             $RESULT['message'] = 'Error while execution query. Please check your optional fields and File Format';
         } else {
             //$downloadFilePath = $folderId.'/'.$fileName.$_TARGET_FILE_FORMATS[$_POST['targetFormat']];
             $FilePath = $target_dir . $fileName . $_TARGET_FILE_FORMATS[$_POST['targetFormat']];
             if (is_dir($target_dir . $fileName . $_TARGET_FILE_FORMATS[$_POST['targetFormat']])) {
                 $za = new FlxZipArchive();
                 $res = $za->open($target_dir . $fileName . $_TARGET_FILE_FORMATS[$_POST['targetFormat']] . '.zip', ZipArchive::CREATE);
                 if ($res === TRUE) {
                     $za->addDir($target_dir . $fileName . $_TARGET_FILE_FORMATS[$_POST['targetFormat']], basename($target_dir . $fileName . $_TARGET_FILE_FORMATS[$_POST['targetFormat']]));
                     $za->close();
                     //$downloadFilePath .= '.zip';
                     $FilePath .= '.zip';
                 }
             }
             $RESULT['success'] = true;
             $RESULT['message'] = file_get_contents($FilePath);
             //shell_exec("rm -r $FilePath");
             //$RESULT['message'] = array($_BASE_URL."download.php?file=".$downloadFilePath, $_BASE_URL."map.php?file=".$downloadFilePath);
             //echo $string;
         }
     } else {
         $RESULT['success'] = false;
         $RESULT['message'] = 'Sorry, invalid zip file.';
     }
 } else {
Пример #5
0
 public function downloadProject()
 {
     $path = $_GET['fileDownload'];
     $project = $_GET['project'];
     $the_folder = $_SERVER['DOCUMENT_ROOT'] . '/workspaces/' . $project . '/' . $path;
     $zip_file_name = $path . '_' . time() . '.zip';
     $za = new FlxZipArchive();
     $res = $za->open($zip_file_name, ZipArchive::CREATE);
     if ($res === TRUE) {
         $za->addDir($the_folder, basename($the_folder));
         $za->close();
     } else {
         echo 'Could not create a zip archive';
     }
     header("Pragma: public");
     header("Expires: 0");
     header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
     header("Cache-Control: public");
     header("Content-Description: File Transfer");
     header("Content-type: application/zip");
     header("Content-Disposition: attachment; filename=\"" . $zip_file_name . "\"");
     header("Content-Transfer-Encoding: binary");
     header("Content-Length: " . filesize($zip_file_name));
     readfile($zip_file_name);
     unlink($zip_file_name);
     die;
 }