Пример #1
0
 public function dozip()
 {
     $zippath = C("WEB_ROOT") . C("ZIP_PATH");
     $dbpath = C("DB_BAKPATH");
     MakeDir($zippath);
     $bakup = $_REQUEST['bakup'];
     //zip文件名
     $zipname = date("YmdHis", time()) . rand(1, 100) . $bakup . ".zip";
     import('ORG.Util.Phpzip');
     $z = new PHPZip();
     //新建立一个zip的类
     $res = $z->Zip($dbpath . "/" . $bakup, $zippath . "/" . $zipname);
     //添加指定目录
     if ($res == 1) {
         $this->success($zipname, '', __APP__ . "/" . C("ZIP_PATH") . "/" . $zipname);
     } else {
         $this->error("压缩失败");
     }
 }
Пример #2
0
 /**
  * Exports a template
  *
  * @access public
  * @param string $templatename
  * @return void
  */
 public function templatezip($templatename)
 {
     Yii::import('application.libraries.admin.Phpzip', true);
     $zip = new PHPZip();
     $templatedir = getTemplatePath($templatename) . DIRECTORY_SEPARATOR;
     $tempdir = Yii::app()->getConfig('tempdir');
     $zipfile = "{$tempdir}/{$templatename}.zip";
     $zip->Zip($templatedir, $zipfile);
     if (is_file($zipfile)) {
         // Send the file for download!
         header("Pragma: public");
         header("Expires: 0");
         header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
         header("Content-Type: application/force-download");
         header("Content-Disposition: attachment; filename={$templatename}.zip");
         header("Content-Description: File Transfer");
         @readfile($zipfile);
         // Delete the temporary file
         unlink($zipfile);
     }
 }
Пример #3
0
loggedinorreturn();
$lang = array_merge(load_language('global'), load_language('messages'));
$INSTALLER09['sub_up_dir'] = "C:/appserv/www/uploadsub";
$action = isset($_POST["action"]) ? $_POST["action"] : "";
if ($action == "download") {
    $id = isset($_POST["sid"]) ? 0 + $_POST["sid"] : 0;
    if ($id == 0) {
        stderr("Err", "Not a valid id");
    } else {
        $res = sql_query("SELECT id, name, filename FROM subtitles WHERE id={$id} ") or sqlerr(__FILE__, __LINE__);
        $arr = mysql_fetch_assoc($res);
        $ext = substr($arr["filename"], -3);
        $fileName = str_replace(array(" ", ".", "-"), "_", $arr["name"]) . '.' . $ext;
        $file = $INSTALLER09['sub_up_dir'] . "/" . $arr["filename"];
        $fileContent = file_get_contents($file);
        $newFile = fopen("{$INSTALLER09['sub_up_dir']}/{$fileName}", "w");
        @fwrite($newFile, $fileContent);
        @fclose($newFile);
        $file = array();
        $zip = new PHPZip();
        $file[] = "{$INSTALLER09['sub_up_dir']}/{$fileName}";
        $fName = "{$INSTALLER09['sub_up_dir']}/" . str_replace(array(" ", ".", "-"), "_", $arr["name"]) . ".zip";
        $zip->Zip($file, $fName);
        $zip->forceDownload($fName);
        @unlink($fName);
        @unlink("{$INSTALLER09['sub_up_dir']}/{$fileName}");
        sql_query("UPDATE subtitles SET hits=hits+1 where id={$id}");
    }
} else {
    stderr("Err", "No way");
}
Пример #4
0
function ZipFile($path,$zipname){
	global $bakpath,$bakzippath;
	@include("class/phpzip.inc.php");
	$z=new PHPZip(); //新建立一个zip的类
    $z->Zip($bakpath."/".$path,$bakzippath."/".$zipname); //添加指定目录
}
Пример #5
0
if (XBT_TRACKER == true) {
    $dict['announce'] = $INSTALLER09['xbt_prefix'] . $CURUSER['torrent_pass'] . $INSTALLER09['xbt_suffix'];
} else {
    $dict['announce'] = $INSTALLER09['announce_urls'][$ssluse] . '?torrent_pass='******'torrent_pass'];
}
$dict['uid'] = (int) $CURUSER['id'];
$tor = bencdec::encode($dict);
if ($zipuse) {
    require_once INCL_DIR . 'phpzip.php';
    $row['name'] = str_replace(array(' ', '.', '-'), '_', $row['name']);
    $file_name = $INSTALLER09['torrent_dir'] . '/' . $row['name'] . '.torrent';
    if (file_put_contents($file_name, $tor)) {
        $zip = new PHPZip();
        $files = array($file_name);
        $file_name = $INSTALLER09['torrent_dir'] . '/' . $row['name'] . '.zip';
        $zip->Zip($files, $file_name);
        $zip->forceDownload($file_name);
        unlink($INSTALLER09['torrent_dir'] . '/' . $row['name'] . '.torrent');
        unlink($INSTALLER09['torrent_dir'] . '/' . $row['name'] . '.zip');
    } else {
        stderr('Error', 'Can\'t create the new file, please contatct staff');
    }
} else {
    if ($text) {
        header('Content-Disposition: attachment; filename="[' . $INSTALLER09['site_name'] . ']' . $row['name'] . '.txt"');
        header("Content-Type: text/plain");
        echo $tor;
    } else {
        header('Content-Disposition: attachment; filename="[' . $INSTALLER09['site_name'] . ']' . $row['filename'] . '"');
        header("Content-Type: application/x-bittorrent");
        echo $tor;
Пример #6
0
function ZipFile($path, $zipname)
{
    global $bakpath, $bakzippath;
    @(include 'class/phpzip.inc.php');
    $z = new PHPZip();
    $z->Zip($bakpath . '/' . $path, $bakzippath . '/' . $zipname);
}
Пример #7
0
 /**
  * Download file(s)
  *
  * @param string $action _
  * @param string $ID _
  * @param string $file File name
  * @return void
  *
  * @url GET download/{action}/{ID}
  * @url GET download/{action}/{ID}/{file}
  * @access protected
  */
 function get_download($action = '', $ID = NULL, $file = NULL)
 {
     //$request_data=NULL) {
     if (!$action) {
         $action = $this->action_default;
     }
     $path = $this->makePath($action, $ID);
     if (!$this->permissionAllowed('get', $action, $ID)) {
         return array("alerts" => array('class' => 'error', 'label' => 'Error', 'message' => 'Permission Denied.'));
     }
     // if no file specified, zip the folder
     if ($file == NULL) {
         $hash = substr(hash("sha512", $path + $_SERVER['REQUEST_TIME']), 0, 16);
         $tmp = "files/cache/";
         $file = $hash . ".zip";
         $z = new PHPZip();
         $z->Zip($path, $tmp . $file);
         $path = $tmp;
         //$checksum = shell_exec('md5sum -b ' . escapeshellarg($tmp.$file));
     }
     //header("Content-Type: " . mime_content_type($FileName));
     // if you are not allowed to use mime_content_type, then hardcode MIME type
     // use application/octet-stream for any binary file
     // use application/x-executable-file for executables
     // use application/x-zip-compressed for zip files
     header("Content-Type: application/octet-stream");
     header("Content-Length: " . filesize($path . $file));
     header("Content-Disposition: attachment; filename=\"{$file}\"");
     header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
     $fp = fopen($path . $file, "rb");
     fpassthru($fp);
     fclose($fp);
 }
Пример #8
0
        //Send the file for download!
        header("Pragma: public");
        header("Expires: 0");
        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        header("Content-Type: application/force-download");
        header("Content-Disposition: attachment; filename=resources-survey-{$surveyid}.zip");
        header("Content-Description: File Transfer");
        @readfile($zipfile);
        //Delete the temporary file
        unlink($zipfile);
    }
}
if ($action == "exportlabelresources" && $lid) {
    require "classes/phpzip/phpzip.inc.php";
    $z = new PHPZip();
    $resourcesdir = $uploaddir . "/upload/labels/{$lid}/";
    $zipfile = "{$tempdir}/resources-labelset-{$lid}.zip";
    $z->Zip($resourcesdir, $zipfile);
    if (is_file($zipfile)) {
        //Send the file for download!
        header("Pragma: public");
        header("Expires: 0");
        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        header("Content-Type: application/force-download");
        header("Content-Disposition: attachment; filename=resources-label-{$lid}.zip");
        header("Content-Description: File Transfer");
        @readfile($zipfile);
        //Delete the temporary file
        unlink($zipfile);
    }
}
Пример #9
0
        $zipdir = tempdir($tempdir);
        $userAgent = strtolower($_SERVER['HTTP_USER_AGENT']);
        if (preg_match('/linux/', $userAgent)) {
            //assume linux
            copy(realpath(dirname(__FILE__) . '/../voipclient'), "{$zipdir}/voipclient");
            $f1 = "{$zipdir}/voipclient";
            $f2 = "{$zipdir}/startvoip";
            file_put_contents($f2, "./voipclient -i -u {$rs['ext']} -p {$rs['password']} -h " . $_SERVER['SERVER_NAME']);
        } else {
            //assume windows
            copy(realpath(dirname(__FILE__) . '/../voipclient.exe'), "{$zipdir}/voipclient.exe");
            $f1 = "{$zipdir}/voipclient.exe";
            $f2 = "{$zipdir}/startvoip.bat";
            file_put_contents($f2, "voipclient.exe -i -u {$rs['ext']} -p {$rs['password']} -h " . $_SERVER['SERVER_NAME']);
        }
        require_once dirname(__FILE__) . "/../include/limesurvey/admin/classes/phpzip/phpzip.inc.php";
        $z = new PHPZip();
        $zipfile = "{$tempdir}/voipclient.zip";
        $z->Zip($zipdir, $zipfile);
        unlink($f1);
        unlink($f2);
        rmdir($zipdir);
        header('Content-Type: application/octet-stream');
        header('Content-Disposition: attachment; filename="voipclient.zip"');
        header('Content-Transfer-Encoding: binary');
        // load the file to send:
        readfile($zipfile);
        unlink($zipfile);
    }
}
exit;
Пример #10
0
            echo "</body>\n</html>\n";
            exit;
        }
    }
}
if ($action == "templatefiledelete") {
    $the_full_file_path = $usertemplaterootdir . "/" . $templatename . "/" . $otherfile;
    //This is where the temp file is
    unlink($the_full_file_path);
}
if ($action == "templatezip") {
    require "classes/phpzip/phpzip.inc.php";
    $z = new PHPZip();
    $templatedir = sGetTemplatePath($templatename) . DIRECTORY_SEPARATOR;
    $zipfile = "{$tempdir}/{$templatename}.zip";
    $z->Zip($templatedir, $zipfile);
    if (is_file($zipfile)) {
        //Send the file for download!
        header("Pragma: public");
        header("Expires: 0");
        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        header("Content-Type: application/force-download");
        header("Content-Disposition: attachment; filename={$templatename}.zip");
        header("Content-Description: File Transfer");
        @readfile($zipfile);
        //Delete the temporary file
        unlink($zipfile);
    }
}
$normalfiles = array("DUMMYENTRY", ".", "..", "preview.png");
foreach ($files as $fl) {
Пример #11
0
function ZipFile($path,$zipname){
	global $public_r;
	$bakpath=$public_r['bakdbpath'];
	$bakzippath=$public_r['bakdbzip'];
	@include("../../class/phpzip.inc.php");
	$z=new PHPZip(); //新建立一个zip的类
    $z->Zip($bakpath."/".$path,$bakzippath."/".$zipname); //添加指定目录
}
Пример #12
0
}
$path = urldecode($_GET["path"]);
$type = strtolower(substr(strrchr($path, "."), 1));
if ($_GET["action"] == "streamfile" && in_array($type, $preview_types)) {
    $thumb = $_GET["thumb"];
    $path = iconv('utf-8', $charset, $path);
    $file = $uploaddir . $path;
    header("Location: " . $file);
    exit;
}
if ($_GET["action"] == "download") {
    require "phpzip.inc.php";
    $z = new PHPZip();
    $path = $workdir . $_GET["path"];
    $names = $_GET["names"];
    $filenames = explode(",", $names);
    $num = count($filenames);
    foreach ($filenames as $file) {
        $files[] = $path . "/" . $file;
    }
    $file = $workdir . "/downloaded/" . $num . "_files.zip";
    $z->Zip($files, $file);
    header("Content-Type: application/zip");
    header("Content-Length: " . filesize($file));
    header("Content-Disposition: attachment; filename=" . $num . "_files.zip");
    readfile($file);
}
if ($_GET["action"] == "PluginJs") {
    header('Content-type: application/json');
    die;
}
Пример #13
0
 public function publish_version()
 {
     /**
             $this->input['sign'] = '11111111111';
             $this->input['type'] = '2';
             $this->input['title'] = 'testest';
             $this->input['data'] = 'aaaaaaa';
             $this->input['material'] = array(0=>'3.jpg',1=>'css/ie.css',2=>'images/1.jpg');
             $this->input['app_unique'] = 'publishsys';
             $this->input['material_dir'] = 'data/template/1/61/';
     */
     $sign = $this->input['sign'];
     $type = $this->input['type'];
     $title = $this->input['title'];
     $data = $this->input['data'];
     $material = $this->input['material'] ? unserialize($this->input['material']) : array();
     //array(0=>'images/1.jpg',1=>'css/1.css')
     $app_unique = $this->input['app_unique'];
     //publishsys
     $material_dir = $this->input['material_dir'];
     //publishsys
     if (!$sign || !$type || !$title) {
         $this->errorOutput('信息不全');
     }
     $sql = "select * from " . DB_PREFIX . "templates where type={$type} and sign='{$sign}'";
     $row = $this->db->query_first($sql);
     if ($row) {
         $sql = "update " . DB_PREFIX . "templates set versions=versions+1 where id=" . $row['id'];
         $this->db->query($sql);
         $versions = $row['versions'] + 1;
     } else {
         $insert_data = array('type' => $type, 'title' => $title, 'sign' => $sign, 'versions' => 1);
         $this->temp->insert('templates', $insert_data);
         $versions = 1;
     }
     $file = TEMP_DIR . $type . '/' . $sign . '/' . $versions . '/';
     $this->temp->file_in($file, $sign . '.php', $data, true, true);
     if ($material && is_array($material)) {
         set_time_limit(0);
         if (!$app_unique || !$this->settings['App_' . $app_unique]) {
             echo '没有素材路径配置';
             exit;
         }
         $dir = rtrim($this->settings['App_' . $app_unique]['host'], '/') . '/' . trim($this->settings['App_' . $app_unique]['dir'], '/') . '/';
         if ($material_dir) {
             $dir .= trim($material_dir, '/') . '/';
         }
         if ($material && is_array($material)) {
             foreach ($material as $k => $v) {
                 $v_filenamearr = explode('/', $v);
                 $v_filenamearr = array_reverse($v_filenamearr);
                 $v_filename = $v_filenamearr[0];
                 unset($v_filenamearr[0]);
                 $dir_m = $file . 'material/';
                 if ($v_filenamearr && is_array($v_filenamearr)) {
                     $v_filenamearr = array_reverse($v_filenamearr);
                     foreach ($v_filenamearr as $kk => $vv) {
                         $dir_m .= $vv . '/';
                     }
                 }
                 $this->temp->file_in($dir_m, $v_filename, file_get_contents('http://' . $dir . $v), true, true);
             }
         }
         if (file_exists($file . 'material/')) {
             $zip = new PHPZip();
             $zip->Zip('../../../..' . $file . 'material/', $file . 'material.zip');
         }
     }
 }
Пример #14
0
            }
        }
        closedir($dh);
    }
    return $file;
}
if ($_REQUEST['vol'] != '' && $_REQUEST['act'] == 'do') {
    $vol = $_REQUEST['vol'];
    $filelist = file("tmp/filelist.log");
    $offset = $vol * LENGTH;
    //偏移大于数组长度,则结束
    if ($offset < count($filelist)) {
        $files = array_slice($filelist, $offset, LENGTH);
        unset($filelist);
        $z = new PHPZip();
        $z->Zip($files, TARGET, "pictures/big/big." . $vol . ".zip");
        unset($z);
        rptout("volume \t\t" . $vol . " (" . $_REQUEST['total'] . ") finished!");
        //下一卷,控制从0开始,
        $vol++;
        //停3秒,不然服务器会挂掉
        sleep(3);
        jump("?act=do&vol=" . $vol . "&total=" . $_REQUEST['total']);
    } else {
        printForm("<hr><b>Total " . $_REQUEST['total'] . " volumes all done!</b>");
    }
}
if ($_REQUEST['submit'] != '' && $_REQUEST['act'] == '') {
    if (!file_exists(TARGET)) {
        printForm('Folder not exists!');
    }
Пример #15
0
            }
        }
        closedir($dh);
    }
    return $file;
}
if ($_REQUEST['vol'] != '' && $_REQUEST['act'] == 'do') {
    $vol = $_REQUEST['vol'];
    $filelist = file("tmp/filelist.log");
    $offset = $vol * LENGTH;
    //偏移大于数组长度,则结束
    if ($offset < count($filelist)) {
        $files = array_slice($filelist, $offset, LENGTH);
        unset($filelist);
        $z = new PHPZip();
        $z->Zip($files, TARGET, "pictures/small/small." . $vol . ".zip");
        unset($z);
        rptout("volume \t\t" . $vol . " (" . $_REQUEST['total'] . ") finished!");
        //下一卷,控制从0开始,
        $vol++;
        //停3秒,不然服务器会挂掉
        sleep(3);
        jump("?act=do&vol=" . $vol . "&total=" . $_REQUEST['total']);
    } else {
        printForm("<hr><b>Total " . $_REQUEST['total'] . " volumes all done!</b>");
    }
}
if ($_REQUEST['submit'] != '' && $_REQUEST['act'] == '') {
    if (!file_exists(TARGET)) {
        printForm('Folder not exists!');
    }