Exemplo n.º 1
0
$fh = new FormHandle($form);
$fh->handle();
load('core/zip');
if ($fh->okay()) {
    $file = $fh->get('file');
    $zip = new zip($file);
    $zipFiles = $zip->list_files();
    $existingFiles = array();
    $newFiles = array();
    $nameFileToMove = md5(mt_rand());
    $toDeleteFiles = array();
    foreach ($zipFiles as $filePath) {
        if (file_exists(ROOT . $filePath)) {
            $existingFiles[] = $filePath;
        } elseif ($filePath == '_files_to_delete.txt') {
            $toDeleteFiles = explode("\n", $zip->extract_file('_files_to_delete.txt'));
        } elseif ($filePath == '_maj_infos.txt') {
            $nameFileToMove = $zip->extract_file('_maj_infos.txt');
        } else {
            $newFiles[] = $filePath;
        }
    }
    move_uploaded_file($file, ROOT . 'uploads/' . url_transform($nameFileToMove) . '.zip');
}
if (isset($_GET['confirmMAJ'])) {
    $file = ROOT . 'uploads/' . $_GET['confirmMAJ'] . '.zip';
    $zip = new zip($file);
    if ($zip->extract(ROOT)) {
        if (file_exists(ROOT . '_files_to_delete.txt')) {
            $toDeleteFiles = file(ROOT . '_files_to_delete.txt');
            foreach ($toDeleteFiles as $filePathDel) {