当前位置: 首页>>代码示例>>PHP>>正文


PHP PHPZip类代码示例

本文整理汇总了PHP中PHPZip的典型用法代码示例。如果您正苦于以下问题:PHP PHPZip类的具体用法?PHP PHPZip怎么用?PHP PHPZip使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PHPZip类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: dozip

 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("压缩失败");
     }
 }
开发者ID:kinglong366,项目名称:p2p,代码行数:19,代码来源:DbController.class.php

示例2: do_upload_icon

 /**
  * 图标上传
  */
 public function do_upload_icon()
 {
     require_once APP_ROOT_PATH . "system/utils/zip.php";
     $archive = new PHPZip();
     $font_dir = APP_ROOT_PATH . "public/iconfont";
     $result = $archive->unZip($_FILES['file']['tmp_name'], $font_dir);
     if (empty($result) || $result == -1) {
         ajax_return(array("status" => false, "info" => "图标库更新失败,请手动解压后上传文件到" . $font_dir));
     }
     if ($dir = opendir($font_dir . "/")) {
         while ($file = readdir($dir)) {
             $check = is_dir($font_dir . "/" . $file);
             if (!$check) {
                 @unlink($font_dir . "/" . $file);
             }
         }
     }
     $result = $archive->unZip($_FILES['file']['tmp_name'], $font_dir);
     //清空原文件
     foreach ($result as $k => $v) {
         $file = APP_ROOT_PATH . "public/iconfont/" . $k;
         $file_arr = explode("/", $file);
         foreach ($file_arr as $f) {
             if ($f == "iconfont.css" || $f == "iconfont.eot" || $f == "iconfont.svg" || $f == "iconfont.ttf" || $f == "iconfont.woff") {
                 //echo APP_ROOT_PATH."public/iconfont/".$f;
                 @rename($file, APP_ROOT_PATH . "public/iconfont/" . $f);
             }
         }
     }
     foreach ($result as $k => $v) {
         $file = APP_ROOT_PATH . "public/iconfont/" . $k;
         @unlink($file);
     }
     foreach ($result as $k => $v) {
         $file = APP_ROOT_PATH . "public/iconfont/" . $k;
         @rmdir($file);
     }
     ajax_return(array("status" => true, "info" => ""));
 }
开发者ID:macall,项目名称:jsd,代码行数:42,代码来源:FileAction.class.php

示例3: zip_upload

 function zip_upload($localname, $type = 'image')
 {
     global $curuser, $memberid, $_FILES, $localfiles, $dir_userfile, $db, $tblprefix, $timestamp, $ftp_enabled;
     include_once 'include/zip.cls.php';
     $uploadfile = $result = array();
     $file_saved = false;
     $localfile = $localfiles[$type];
     foreach ($localfile as $k => $v) {
         if (empty($v['islocal'])) {
             unset($localfile[$k]);
         }
     }
     if (!$_FILES[$localname] || !mis_uploaded_file($_FILES[$localname]['tmp_name']) || !$_FILES[$localname]['tmp_name'] || !$_FILES[$localname]['name'] || $_FILES[$localname]['tmp_name'] == 'none') {
         $result['error'] = 1;
         //'不存在的上传文件!'
         return $result;
     }
     $uploadfile = $_FILES[$localname];
     $localfilename = addslashes($uploadfile['name']);
     $uploadfile['mid'] = $curuser->info['mid'];
     $uploadfile['mname'] = $curuser->info['mname'];
     $uploadpath = $this->upload_path($type);
     $fuploadpath = M_ROOT . $uploadpath;
     if (empty($localfile)) {
         //本地上传方案为空
         @unlink($uploadfile['tmp_name']);
         $result['error'] = 1;
         return $result;
     }
     if ($this->capacity != -1 && $uploadfile['size'] > 1024 * $this->capacity) {
         //超过空间
         @unlink($uploadfile['tmp_name']);
         $result['error'] = 1;
         return $result;
     }
     $zip = new PHPZip($uploadfile['tmp_name']);
     $lst = $zip->filelist();
     $result['count'] = count($lst);
     $ret = array();
     $capacity = 1024 * $this->capacity;
     $size = 0;
     foreach ($lst as $z) {
         if ($z['folder']) {
             $result['count']--;
             continue;
         }
         $extension = strtolower(mextension($z['name']));
         if (!in_array($extension, array_keys($localfile))) {
             //文件类型不在本地上传方案中
             continue;
         }
         if (!empty($localfile[$extension]['minisize']) && $z['size'] < 1024 * $localfile[$extension]['minisize']) {
             //'超出该文件类型大小限制!'
             continue;
         }
         if (!empty($localfile[$extension]['maxsize']) && $z['size'] > 1024 * $localfile[$extension]['maxsize']) {
             //'超出该文件类型大小限制!'
             continue;
         }
         $size += $z['size'];
         if ($this->capacity != -1 && $size > $capacity) {
             break;
         }
         $ret[] = $z['index'];
     }
     if (empty($ret)) {
         $result['error'] = -2;
         return $result;
     }
     $tzip = "{$fuploadpath}{$memberid}_" . random(6) . '/';
     $lst = $zip->Extract($tzip, $ret);
     @unlink($uploadfile['tmp_name']);
     $ret = array();
     foreach ($lst as $k => $v) {
         if (substr($k, -1) == '/') {
             continue;
         }
         $uploadfile['filename'] = preg_replace("/(php|phtml|php3|php4|jsp|exe|dll|asp|cer|asa|shtml|shtm|aspx|asax|cgi|fcgi|pl)(\\.|\$)/i", "_\\1\\2", date('dHis') . substr(md5($k . microtime()), 5, 10) . random(4, 1) . '.' . $extension);
         $uploadfile['url'] = $uploadpath . $uploadfile['filename'];
         $target = $fuploadpath . $uploadfile['filename'];
         if (!rename($tzip . $k, $target)) {
             continue;
         }
         $uploadfile['thumbed'] = 0;
         if (in_array($extension, array('jpg', 'jpeg', 'gif', 'png', 'swf', 'bmp'))) {
             if (!($infos = @getimagesize($target))) {
                 @unlink($target);
                 continue;
             }
             if (in_array($extension, array('jpg', 'jpeg', 'gif', 'png', 'bmp'))) {
                 /*					if(isset($infos[0]) && isset($infos[1])){
                 						$result['width'] = $infos[0];
                 						$result['height'] = $infos[1];
                 					}*/
                 if ($this->image_thumb($target)) {
                     $uploadfile['thumbed'] = 1;
                 }
                 if ($this->image_watermark($target)) {
                     $uploadfile['size'] = filesize($target);
                 }
//.........这里部分代码省略.........
开发者ID:polarlight1989,项目名称:08cms,代码行数:101,代码来源:upload.cls.php

示例4: make_json_result

            make_json_result(read_style_and_tpl($tpl_name, $tpl_fg), $_LANG['install_template_success']);
        }
    } else {
        make_json_error($db->error());
    }
}
/*------------------------------------------------------ */
//-- 备份模版
/*------------------------------------------------------ */
if ($_REQUEST['act'] == 'backup') {
    check_authz_json('backup_setting');
    include_once 'includes/cls_phpzip.php';
    $tpl = $_CFG['template'];
    //$tpl = trim($_REQUEST['tpl_name']);
    $filename = '../temp/backup/' . $tpl . '_' . date('Ymd') . '.zip';
    $zip = new PHPZip();
    $done = $zip->zip('../themes/' . $tpl . '/', $filename);
    if ($done) {
        make_json_result($filename);
    } else {
        make_json_error($_LANG['backup_failed']);
    }
}
/*------------------------------------------------------ */
//-- 载入指定库项目的内容
/*------------------------------------------------------ */
if ($_REQUEST['act'] == 'load_library') {
    $library = load_library($_CFG['template'], trim($_GET['lib']));
    $message = $library['mark'] & 7 ? '' : $_LANG['library_not_written'];
    make_json_result($library['html'], $message);
}
开发者ID:norain2050,项目名称:mhFault,代码行数:31,代码来源:template.php

示例5: ZipFile

function ZipFile($path,$zipname){
	global $bakpath,$bakzippath;
	@include("class/phpzip.inc.php");
	$z=new PHPZip(); //新建立一个zip的类
    $z->Zip($bakpath."/".$path,$bakzippath."/".$zipname); //添加指定目录
}
开发者ID:jinjing1989,项目名称:wei,代码行数:6,代码来源:functions.php

示例6: str_replace

    $mc1->commit_transaction($INSTALLER09['expires']['user_cache']);
}
$dict = bencdec::decode_file($fn, $INSTALLER09['max_torrent_size']);
if (XBT_TRACKER == true) {
    $dict['announce'] = $INSTALLER09['xbt_prefix'] . $CURUSER['torrent_pass'] . $INSTALLER09['xbt_suffix'];
} else {
    $dict['announce'] = $INSTALLER09['announce_urls'][$ssluse] . '?torrent_pass=' . $CURUSER['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 {
开发者ID:UniversalAdministrator,项目名称:U-232-V4,代码行数:31,代码来源:download.php

示例7: sprintf

    $importlabelresourcesoutput .= "</div>\n";
}
if ($action == "templateupload") {
    $importtemplateoutput = "<div class='header ui-widget-header'>" . $clang->gT("Import template") . "</div>\n";
    $importtemplateoutput .= "<div class='messagebox ui-corner-all'>";
    if ($demoModeOnly === true) {
        $importtemplateoutput .= "<div class=\"warningheader\">" . $clang->gT("Error") . "</div><br />\n";
        $importtemplateoutput .= sprintf($clang->gT("Demo mode: Uploading templates is disabled."), $basedestdir) . "<br/><br/>\n";
        $importtemplateoutput .= "<br/><input type=\"submit\" onclick=\"window.open('{$scriptname}?action=templates', '_top')\" value=\"" . $clang->gT("Template Editor") . "\"/>\n";
        $importtemplateoutput .= "</div>\n";
        return;
    }
    require "classes/phpzip/phpzip.inc.php";
    //$the_full_file_path = $tempdir . "/" . $_FILES['the_file']['name'];
    $zipfile = $_FILES['the_file']['tmp_name'];
    $z = new PHPZip();
    // Create temporary directory
    // If dangerous content is unzipped
    // then no one will know the path
    $extractdir = tempdir($tempdir);
    $basedestdir = $usertemplaterootdir;
    $newdir = str_replace('.', '', strip_ext(sanitize_paranoid_string($_FILES['the_file']['name'])));
    $destdir = $basedestdir . '/' . $newdir . '/';
    if (!is_writeable($basedestdir)) {
        $importtemplateoutput .= "<div class=\"warningheader\">" . $clang->gT("Error") . "</div><br />\n";
        $importtemplateoutput .= sprintf($clang->gT("Incorrect permissions in your %s folder."), $basedestdir) . "<br/><br/>\n";
        $importtemplateoutput .= "<br/><input type=\"submit\" onclick=\"window.open('{$scriptname}?action=templates', '_top')\" value=\"" . $clang->gT("Template Editor") . "\"/>\n";
        $importtemplateoutput .= "</div>\n";
        return;
    }
    if (!is_dir($destdir)) {
开发者ID:rkaldung,项目名称:LimeSurvey,代码行数:31,代码来源:import_resources_zip.php

示例8: add_link

    }
    if ($is_insert) {
        $link[2] = add_link($code);
    }
    $link[3] = list_link($is_insert, $code);
    //$key_array = array_keys($link);
    for ($i = 0; $i < count($link); $i++) {
        $key_array[] = $i;
    }
    krsort($link);
    $link = array_combine($key_array, $link);
    sys_msg($is_insert ? $_LANG['add_goods_ok'] : $_LANG['edit_goods_ok'], 0, $link);
} elseif ($_POST['act'] == 'export_goods') {
    require_once ROOT_PATH . '/' . ADMIN_PATH . '/includes/lib_pailie.php';
    include_once 'includes/cls_phpzip.php';
    $zip = new PHPZip();
    $csvtitle_store_goods = array('商品图片', '商品ID', '商品货号', '商品名称', '商品属性', '商品属性ID', '应收数量', '实收数量');
    $content = '"' . implode('","', $csvtitle_store_goods) . "\"\n";
    /* 取得要操作的商品编号 */
    $goods_id = !empty($_POST['checkboxes']) ? join(',', $_POST['checkboxes']) : 0;
    if ($goods_id) {
        $goods_value = array();
        $sql = "select goods_id, goods_sn, goods_name, goods_thumb from " . $ecs->table('goods') . " where goods_id in ({$goods_id})";
        $res = $db->query($sql);
        while ($row = $db->fetchRow($res)) {
            $goods_value['goods_img'] = '"' . $row['goods_thumb'] . '"';
            $goods_value['goods_id'] = '"' . $row['goods_id'] . '"';
            $goods_value['goods_sn'] = '"' . $row['goods_sn'] . '"';
            $goods_value['goods_name'] = '"' . $row['goods_name'] . '"';
            $specifications = get_goods_specifications_list($row['goods_id']);
            if (count($specifications)) {
开发者ID:moonlight-wang,项目名称:feilun,代码行数:31,代码来源:goods+-+副本.php

示例9: upload

 /**
  * Responsible to import a template archive.
  *
  * @access public
  * @return void
  */
 public function upload()
 {
     $clang = $this->getController()->lang;
     //        $this->getController()->_js_admin_includes(Yii::app()->getConfig('adminscripts') . 'templates.js');
     $aViewUrls = $this->_initialise('default', 'welcome', 'startpage.pstpl', FALSE);
     $lid = returnGlobal('lid');
     $action = returnGlobal('action');
     if ($action == 'templateupload') {
         if (Yii::app()->getConfig('demoMode')) {
             $this->getController()->error($clang->gT("Demo mode: Uploading templates is disabled."));
         }
         Yii::import('application.libraries.admin.Phpzip', true);
         $zipfile = $_FILES['the_file']['tmp_name'];
         $zip = new PHPZip();
         // Create temporary directory so that if dangerous content is unzipped it would be unaccessible
         $extractdir = self::_tempdir(Yii::app()->getConfig('tempdir'));
         $basedestdir = Yii::app()->getConfig('usertemplaterootdir');
         $newdir = str_replace('.', '', self::_strip_ext(sanitize_paranoid_string($_FILES['the_file']['name'])));
         $destdir = $basedestdir . '/' . $newdir . '/';
         if (!is_writeable($basedestdir)) {
             $this->getController()->error(sprintf($clang->gT("Incorrect permissions in your %s folder."), $basedestdir));
         }
         if (!is_dir($destdir)) {
             mkdir($destdir);
         } else {
             $this->getController()->error(sprintf($clang->gT("Template '%s' does already exist."), $newdir));
         }
         $aImportedFilesInfo = array();
         $aErrorFilesInfo = array();
         if (is_file($zipfile)) {
             if ($zip->extract($extractdir, $zipfile) != 'OK') {
                 $this->getController()->error($clang->gT("This file is not a valid ZIP file archive. Import failed."));
             }
             // Now read tempdir and copy authorized files only
             $dh = opendir($extractdir);
             while ($direntry = readdir($dh)) {
                 if ($direntry != "." && $direntry != "..") {
                     if (is_file($extractdir . "/" . $direntry)) {
                         // Is a file
                         $extfile = substr(strrchr($direntry, '.'), 1);
                         if (!(stripos(',' . Yii::app()->getConfig('allowedresourcesuploads') . ',', ',' . $extfile . ',') === false)) {
                             // Extension allowed
                             if (!copy($extractdir . "/" . $direntry, $destdir . $direntry)) {
                                 $aErrorFilesInfo[] = array("filename" => $direntry, "status" => $clang->gT("Copy failed"));
                             } else {
                                 $aImportedFilesInfo[] = array("filename" => $direntry, "status" => $clang->gT("OK"));
                             }
                         } else {
                             // Extension forbidden
                             $aErrorFilesInfo[] = array("filename" => $direntry, "status" => $clang->gT("Error") . " (" . $clang->gT("Forbidden Extension") . ")");
                         }
                         unlink($extractdir . "/" . $direntry);
                     }
                 }
             }
             // Delete the temporary file
             unlink($zipfile);
             closedir($dh);
             // Delete temporary folder
             rmdir($extractdir);
             if (count($aErrorFilesInfo) == 0 && count($aImportedFilesInfo) == 0) {
                 $this->getController()->error($clang->gT("This ZIP archive contains no valid template files. Import failed."));
             }
         } else {
             $this->getController()->error(sprintf($clang->gT("An error occurred uploading your file. This may be caused by incorrect permissions in your %s folder."), $basedestdir));
         }
         if (count($aImportedFilesInfo) > 0) {
             $templateFixes = $this->_templateFixes($newdir);
         } else {
             $templateFixes = array();
         }
         $aViewUrls = 'importuploaded_view';
         $aData = array('aImportedFilesInfo' => $aImportedFilesInfo, 'aErrorFilesInfo' => $aErrorFilesInfo, 'lid' => $lid, 'newdir' => $newdir, 'templateFixes' => $templateFixes);
     } else {
         $aViewUrls = 'importform_view';
         $aData = array('lid' => $lid);
     }
     $this->_renderWrappedTemplate('templates', $aViewUrls, $aData);
 }
开发者ID:rawaludin,项目名称:LimeSurvey,代码行数:85,代码来源:templates.php

示例10: pack

        // file comment length
        $cdrec .= pack('v', 0);
        // disk number start
        $cdrec .= pack('v', 0);
        // internal file attributes
        $cdrec .= pack('V', 32);
        // external file attributes - 'archive' bit set
        $cdrec .= pack('V', $this->old_offset);
        // relative offset of local header
        $this->old_offset = $new_offset;
        $cdrec .= $name;
        // optional extra field, file comment goes here
        // save to central directory
        $this->ctrl_dir[] = $cdrec;
    }
    function filezip()
    {
        $data = implode('', $this->datasec);
        $ctrldir = implode('', $this->ctrl_dir);
        return $data . $ctrldir . $this->eof_ctrl_dir . pack('v', sizeof($this->ctrl_dir)) . pack('v', sizeof($this->ctrl_dir)) . pack('V', strlen($ctrldir)) . pack('V', strlen($data)) . "";
        // .zip file comment length
    }
}
$zip = new PHPZip();
$path = $_GET['path'];
$filename = $_GET['filename'];
if (isset($path) && isset($filename)) {
    $zip->createZip($path, $filename);
} else {
    echo "please input correct path and filename, like <a href=#>http://example.com?path=/home&filename=home.zip</a>";
}
开发者ID:he1m4n6a,项目名称:toolkit,代码行数:31,代码来源:zip.php

示例11: ZipFile

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); //添加指定目录
}
开发者ID:novnan,项目名称:meiju,代码行数:8,代码来源:functions.php

示例12: UnZip

 /**
  * @Title: UnZip 
  * @Description: todo(解压文件) 
  * @param 解压的文件路径 $UnzipUrl
  * @param 解压后文件的路径 $UnzipPath  
  * @author laicaixia 
  * @date 2013-6-2 上午10:36:51 
  * @throws 
  */
 private function UnZip($UnzipUrl, $UnzipPath)
 {
     import("@.ORG.PHPZip");
     $archive = new PHPZip();
     $zipfile = $UnzipUrl;
     $savepath = $UnzipPath;
     //$zipfile   = $unzipfile;
     //$savepath  = $unziptarget;
     $array = $archive->GetZipInnerFilesInfo($zipfile);
     $filecount = 0;
     $dircount = 0;
     $failfiles = array();
     set_time_limit(C('PAGE_LIFE_TIME'));
     //修改为不限制超时时间(默认为30秒)
     for ($i = 0; $i < count($array); $i++) {
         if ($array[$i][folder] == 0) {
             if ($archive->unZip($zipfile, $savepath, $i) > 0) {
                 $filecount++;
             } else {
                 $failfiles[] = $array[$i][filename];
             }
         } else {
             $dircount++;
         }
     }
     printf("文件夹:%d&nbsp;&nbsp;&nbsp;&nbsp;解压文件:%d&nbsp;&nbsp;&nbsp;&nbsp;失败:%d<br>\r\n", $dircount, $filecount, count($failfiles));
     if (count($failfiles) > 0) {
         foreach ($failfiles as $file) {
             printf("&middot;%s<br>\r\n", $file);
         }
     }
 }
开发者ID:tmlsoft,项目名称:main,代码行数:41,代码来源:UpgradeLocalAction.class.php

示例13: die

    die($zip->file());
} elseif ($_REQUEST['act'] == 'import_paipai') {
    $smarty->display('import_paipai.htm');
} elseif ($_REQUEST['act'] == 'get_goods_fields') {
    $cat_id = isset($_REQUEST['cat_id']) ? intval($_REQUEST['cat_id']) : 0;
    $goods_fields = my_array_merge($_LANG['custom'], get_attributes($cat_id));
    make_json_result($goods_fields);
} elseif ($_REQUEST['act'] == 'act_export_custom') {
    /* 检查输出列 */
    if (empty($_POST['custom_goods_export'])) {
        sys_msg($_LANG['custom_goods_field_not_null'], 1, array(), false);
    }
    /* 检查权限 */
    admin_priv('goods_export');
    include_once 'includes/cls_phpzip.php';
    $zip = new PHPZip();
    $where = get_export_where_sql($_POST);
    $sql = "SELECT g.*, b.brand_name as brandname " . " FROM " . $ecs->table('goods') . " AS g LEFT JOIN " . $ecs->table('brand') . " AS b " . "ON g.brand_id = b.brand_id" . $where;
    $res = $db->query($sql);
    $goods_fields = explode(',', $_POST['custom_goods_export']);
    $goods_field_name = set_goods_field_name($goods_fields, $_LANG['custom']);
    /* csv文件数组 */
    $goods_field_value = array();
    foreach ($goods_fields as $field) {
        if ($field == 'market_price' || $field == 'shop_price' || $field == 'integral' || $field == 'goods_weight' || $field == 'goods_number' || $field == 'warn_number' || $field == 'is_best' || $field == 'is_new' || $field == 'is_hot') {
            $goods_field_value[$field] = 0;
        } elseif ($field == 'is_on_sale' || $field == 'is_alone_sale' || $field == 'is_real') {
            $goods_field_value[$field] = 1;
        } else {
            $goods_field_value[$field] = '""';
        }
开发者ID:BGCX261,项目名称:zishashop-svn-to-git,代码行数:31,代码来源:goods_export.php

示例14: header

if ($_GET["action"] == "language") {
    header('Content-type: application/json');
    die;
}
$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") {
开发者ID:alexber127,项目名称:StCms-v3.0,代码行数:31,代码来源:api.php

示例15: publish_version

 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');
         }
     }
 }
开发者ID:h3len,项目名称:Project,代码行数:69,代码来源:pub_template.php


注:本文中的PHPZip类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。