/**
 * Implementation of hook_page.
 * Zip current file/folder 
 */
function ft_zip_page($act)
{
    global $ft;
    if ($act == 'zip') {
        $_REQUEST['file'] = trim(ft_stripslashes($_REQUEST['file']));
        // nom de fichier/repertoire
        $zip = new zipfile();
        if ($ft["plugins"]["zip"]["filebuffer"]) {
            $zip->setOutFile($ft["plugins"]["zip"]["filebuffer"]);
        }
        $substr_base = strlen(ft_get_dir()) + 1;
        foreach (ft_zip_getfiles(ft_get_dir() . '/' . $_REQUEST['file']) as $file) {
            $filename = substr($file, $substr_base);
            $filesize = filesize($file);
            if ($filesize > 0) {
                $fp = fopen($file, 'r');
                $content = fread($fp, $filesize);
                fclose($fp);
            } else {
                $content = '';
            }
            $zip->addfile($content, $filename);
        }
        if ($ft["plugins"]["zip"]["filebuffer"]) {
            $zip->finish();
            $filesize = filesize($ft["plugins"]["zip"]["filebuffer"]);
        } else {
            $archive = $zip->file();
            $filesize = strlen($archive);
        }
        header('Content-Type: application/x-zip');
        header('Content-Disposition: inline; filename="' . $_REQUEST['file'] . '.zip"');
        header('Content-Length: ' . $filesize);
        if ($ft["plugins"]["zip"]["filebuffer"]) {
            readfile($ft["plugins"]["zip"]["filebuffer"]);
            unlink($ft["plugins"]["zip"]["filebuffer"]);
        } else {
            echo $archive;
        }
        exit;
    }
}
Exemple #2
0
            while ($row = mysql_fetch_assoc($result)) {
                echo $row['Field'] . "; ";
                $l++;
            }
        }
        echo "\n";
        $values = mysql_query('SELECT * FROM ' . $table . $clause_where);
        while ($rowr = mysql_fetch_row($values)) {
            for ($j = 0; $j < $l; $j++) {
                $d = str_replace('"', '""', $rowr[$j]);
                echo '"' . str_replace('
', '\\n', $d) . '";';
            }
            echo "\n";
        }
        $zip->addfile(utf8_decode(ob_get_contents()), $nom_fichier);
        //on ajoute le fichier
        ob_end_clean();
        //on vide le cache
    }
}
$archive = $zip->file();
// on associe l'archive
// on enregistre l'archive dans un fichier
$open = fopen('exports/' . $filename . '.zip', "wb");
fwrite($open, $archive);
fclose($open);
// code à insérer à la place des 3lignes ( fopen, fwrite, fclose )
header('Content-Type: application/x-zip');
//on détermine les en-tête
header('Content-Disposition: inline; filename=' . $filename . '.zip');
<?php

include "config.php";
if (isset($_REQUEST['p'])) {
    $path = $_REQUEST['p'];
} else {
    die("Unknown path!");
}
require_once 'zip.lib.php';
$zip = new zipfile();
$cmd = "/usr/bin/find files/{$path} -name \"*\" | grep -v svn | grep -v DS_Store";
exec($cmd, $files);
if (count($files) == 0) {
    die("No files to download");
}
foreach ($files as $key => $filename) {
    if (!is_dir($filename)) {
        $fp = fopen($filename, 'r');
        $content = fread($fp, filesize($filename));
        fclose($fp);
        $filename = str_replace("files/", "", $filename);
        $zip->addfile($content, $filename);
    }
}
$archive = $zip->file();
$archive_name = str_replace("//", "/", $path);
$archive_name = str_replace("/", "_", $archive_name);
header('Content-Type: application/x-zip');
header('Content-Disposition: inline; filename=' . $archive_name . '.zip');
echo $archive;
Exemple #4
0
        if ($crypteretour == 'OUI') {
            echo URLCrypt($bindRes[$i], $PublicKey) . 'PHP4WDSEP';
        } else {
            echo $bindRes[$i] . 'PHP4WDSEP';
        }
    }
}
if ($methode == 'zip') {
    $value = $value . '--FINSQL--' . 'PHP4WDSEP';
} else {
    echo '--FINSQL--' . 'PHP4WDSEP';
}
$func_close($session);
if ($methode == 'zip') {
    $zip = new zipfile();
    $zip->addfile($value, $filename);
    $archive = $zip->file();
    if ($crypteretour == 'OUI') {
        $archive = URLCrypt($archive, $PublicKey);
    }
    // céation d'un fichier temporaire
    $tmpfname = tempnam("/tmp", "arch_");
    $handle = fopen($tmpfname, 'a');
    fwrite($handle, $archive);
    fclose($handle);
    $fsize = filesize($tmpfname);
    $bufsize = 20000;
    header("HTTP/1.1 200 OK");
    header("Content-Length: {$fsize}");
    header("Content-Type: application/force-download");
    header("Pragma: no-cache");
 function Lib_zipDirectory($filename, $replace = 0, $extension = '.zip', $tab_files = array())
 {
     $filename_gz = '../../img_ftp/' . $filename . $extension;
     Lib_myLog("Debut zipDirectory {$filename}");
     if ($replace && file_exists($filename_gz)) {
         unlink($filename_gz);
     }
     if (!empty($tab_files)) {
         // création d'un objet 'zipfile'
         $zip = new zipfile();
         // Création du zip
         foreach ($tab_files as $chemin_archive => $file) {
             $fp = fopen('../../img_ftp/' . $file, 'r');
             $content = fread($fp, filesize('../../img_ftp/' . $file));
             fclose($fp);
             // ajout du fichier dans l'objet 'zipfile'
             $zip->addfile($content, $chemin_archive);
         }
         // production de l'archive' Zip
         $archive = $zip->file();
         $fp = fopen($filename_gz, "w");
         fputs($fp, '../../img_ftp/' . $archive);
         fclose($fp);
     }
 }