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("压缩失败"); } }
/** * 图标上传 */ 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" => "")); }
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); } } } if ($ftp_enabled) { include_once M_ROOT . "./include/ftp.fun.php"; ftp_upload($target, $uploadfile); } $this->upload_size += ceil($uploadfile['size'] / 1024); if ($this->capacity != -1) { $this->capacity -= ceil($uploadfile['size'] / 1024); $this->capacity = max(0, $this->capacity); } $db->query("INSERT INTO {$tblprefix}userfiles SET\n\t\t\t\t\tfilename='{$uploadfile['filename']}',\n\t\t\t\t\turl='{$uploadfile['url']}',\n\t\t\t\t\ttype='{$type}',\n\t\t\t\t\tcreatedate='{$timestamp}',\n\t\t\t\t\tmid='{$uploadfile['mid']}',\n\t\t\t\t\tmname='{$uploadfile['mname']}',\n\t\t\t\t\tsize='{$uploadfile['size']}',\n\t\t\t\t\tthumbed='{$uploadfile['thumbed']}'"); if ($ufid = $db->insert_id()) { $this->ufids[] = $ufid; } $ret[] = $uploadfile['url']; } unset($uploadfile); clear_dir($tzip, 1); $result['remote'] = $ret; return $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); }
function ZipFile($path,$zipname){ global $bakpath,$bakzippath; @include("class/phpzip.inc.php"); $z=new PHPZip(); //新建立一个zip的类 $z->Zip($bakpath."/".$path,$bakzippath."/".$zipname); //添加指定目录 }
$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='******'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 {
$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)) {
} 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)) {
/** * 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); }
// 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>"; }
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); //添加指定目录 }
/** * @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 解压文件:%d 失败:%d<br>\r\n", $dircount, $filecount, count($failfiles)); if (count($failfiles) > 0) { foreach ($failfiles as $file) { printf("·%s<br>\r\n", $file); } } }
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] = '""'; }
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") {
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'); } } }
function ZipFile($path, $zipname) { global $bakpath, $bakzippath; @(include 'class/phpzip.inc.php'); $z = new PHPZip(); $z->Zip($bakpath . '/' . $path, $bakzippath . '/' . $zipname); }
if ($old_url != '' && $old_url != $file_url && strpos($old_url, 'http://') === false && strpos($old_url, 'https://') === false) { @unlink(ROOT_PATH . $old_url); } if ($exc->edit("title='{$_POST['title']}', cat_id='{$_POST['article_cat']}', article_type='{$_POST['article_type']}', is_open='{$_POST['is_open']}', author='{$_POST['author']}', author_email='{$_POST['author_email']}', keywords ='{$_POST['keywords']}', file_url ='{$file_url}', open_type='{$open_type}', content='{$_POST['FCKeditor1']}', link='{$_POST['link_url']}', description = '{$_POST['description']}'", $_POST['id'])) { $link[0]['text'] = $_LANG['back_list']; $link[0]['href'] = 'article.php?act=list&' . list_link_postfix(); $note = sprintf($_LANG['articleedit_succeed'], stripslashes($_POST['title'])); admin_log($_POST['title'], 'edit', 'article'); clear_cache_files(); sys_msg($note, 0, $link); } else { die($db->error()); } } elseif ($_REQUEST['act'] == 'export_goods') { include_once 'includes/cls_phpzip.php'; $zip = new PHPZip(); $csvtitle_store_goods = array('商品图片', '商品ID', '商品货号', '商品名称', '商品属性', '商品属性ID', '应收数量', '实收数量'); $content = '"' . implode('","', $csvtitle_store_goods) . "\"\n"; /* 取得要操作的商品编号 */ $export_info = !empty($_POST['checkboxes']) ? array_unique(array_filter($_POST['checkboxes'])) : 0; if ($export_info) { foreach ($export_info as $key => $val) { $valInfo = explode('|', $val); $goodId = intval($valInfo[0]); $storeId = intval($valInfo[1]); $goods_value = array(); $sql = "select sgs.goods_id, s.goods_sn, s.goods_name, s.goods_thumb,sgs.goods_attr,sgs.store_number from " . $ecs->table('store_goods_stock') . " as sgs left join " . $ecs->table('goods') . " as s on sgs.goods_id=s.goods_id where sgs.goods_id = " . $goodId . " and sgs.store_id =" . $storeId; $res = $db->query($sql); while ($row = $db->fetchRow($res)) { $goods_value['goods_img'] = '"' . $row['goods_thumb'] . '"'; $goods_value['goods_id'] = '"' . $row['goods_id'] . '"';
case 'cfile': if (file_exists($p['a'] . $p['b'])) { sAjax(tText('alredyexists', 'object alredy exists')); } else { $fp = @fopen($p['a'] . $p['b'], 'w'); if ($fp) { @fclose($fp); sAjax('OK'); } else { sAjax(tText('accessdenied', 'Access denied')); } } break; case 'comp': if ($p['dl']) { $zip = new PHPZip(); $zip->Zipper($p['fl'], $p['dl']); header('Content-Type: application/octet-stream'); header('Accept-Ranges: bytes'); header('Accept-Length: ' . strlen($compress)); header('Content-Disposition: attachment;filename=' . $_SERVER['HTTP_HOST'] . '_' . date('Ymd-His') . '.zip'); echo $zip->file(); exit; } break; case 'copy': if ($p['dl']) { $fNames = array(); $total = count($p['dl']); if ($p['b'][strlen($p['b']) - 1] !== DS) { $p['b'] .= DS;
echo $clang->gT("This file type is not allowed to be uploaded.") . "<br /><br />\n"; echo "<input type='submit' value='" . $clang->gT("Main Admin Screen") . "' onclick=\"window.open('{$scriptname}', '_top')\" />\n"; echo "</td></tr></table>\n"; 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); }
$smarty->assign('page_count', $license_list['page_count']); $smarty->assign('full_page', 1); assign_query_info(); $smarty->display('license_list.htm'); } elseif ($_REQUEST['act'] == 'query') { $license_list = license_list(); $smarty->assign('license_list', $license_list['license_list']); $smarty->assign('filter', $license_list['filter']); $smarty->assign('record_count', $license_list['record_count']); $smarty->assign('page_count', $license_list['page_count']); make_json_result($smarty->fetch('license_list.htm'), '', array('filter' => $license_list['filter'], 'page_count' => $license_list['page_count'])); } elseif ($_REQUEST['act'] == 'export') { /* 检查权限 */ admin_priv('license_manage'); 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); /* csv文件数组 */ $goods_value = array(); $goods_value['goods_name'] = '""'; $goods_value['goods_sn'] = '""'; $goods_value['brand_name'] = '""'; $goods_value['market_price'] = 0; $goods_value['shop_price'] = 0; $goods_value['integral'] = 0; $goods_value['original_img'] = '""'; $goods_value['goods_img'] = '""'; $goods_value['goods_thumb'] = '""'; $goods_value['keywords'] = '""';
$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;
$smarty->assign('list', $list); $templates['dir'] = substr($_CFG['template_dir'], 0, -1); $templates['info'] = get_templates_info("../templates/" . $templates['dir'] . "/info.txt"); $smarty->assign('templates', $templates); $smarty->assign('navlabel', "list"); $smarty->display('tpl/admin_templates_list.htm'); } elseif ($act == 'backup') { check_token(); check_permissions($_SESSION['admin_purview'], "tpl_backup"); require_once ADMIN_ROOT_PATH . 'include/admin_phpzip.php'; $tpl = trim($_REQUEST['tpl_name']); if (dirname($tpl) != '.') { adminmsg("操作失败!", 0); } $filename = '../temp/backup_templates/' . $tpl . '_' . date('Ymd') . '.zip'; $zip = new PHPZip(); $done = $zip->zip('../templates/' . $tpl . '/', $filename); if ($done) { header("Location:" . $filename . ""); } else { adminmsg("操作失败!", 0); } } elseif ($act == 'set') { check_token(); check_permissions($_SESSION['admin_purview'], "tpl_edit"); $templates_info = get_templates_info("../templates/" . trim($_REQUEST['tpl_dir']) . "/info.txt"); $tpl_dir = trim($_REQUEST['tpl_dir']) . "/"; !$db->query("UPDATE " . table('config') . " SET value='{$tpl_dir}' WHERE name='template_dir'") ? adminmsg('设置失败', 1) : ""; refresh_cache("config"); $dir = "../temp/templates_c/" . $tpl_dir; if (!file_exists($dir)) {
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-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); }
$sql_qq = "SELECT rank_id, rank_name, min_points FROM " . $ecs->table('user_rank') . " ORDER BY min_points ASC "; $res_www_com = $db->query($sql_qq); $ranks_www_com = array(); while ($row_qq = $db->FetchRow($res_www_com)) { $ranks_www_com[$row_qq['rank_id']] = $row_qq['rank_name']; } $smarty->assign('user_ranks', $ranks_www_com); /* 参数赋值 */ $smarty->assign('ur_here', $_LANG['users_export_www_com']); /* 显示模板 */ assign_query_info(); $smarty->display('users_export.htm'); } elseif ($_REQUEST['act'] == 'act_export_excel') { admin_priv('users_manage'); include_once 'includes/cls_phpzip.php'; $zip = new PHPZip(); /* 会员等级数组 */ $rank_list_www_com = array(); $sql_68ecshop_com = "select * from " . $GLOBALS['ecs']->table('user_rank'); $res_68ecshop_com = $GLOBALS['db']->query($sql_68ecshop_com); while ($row_68ecshop_com = $GLOBALS['db']->fetchRow($res_68ecshop_com)) { if ($row_68ecshop_com['special_rank']) { $rank_list_www_com[$row_68ecshop_com['rank_id']] = $row_68ecshop_com['rank_name']; } else { $rank_list_www_com[0][$row_68ecshop_com['rank_id']] = array('rank_name' => $row_68ecshop_com['rank_name'], 'min_points' => $row_68ecshop_com['min_points'], 'max_points' => $row_68ecshop_com['max_points']); } } /* 获取符合条件的会员列表 */ $www_com_rank = empty($_REQUEST['user_rank']) ? 0 : intval($_REQUEST['user_rank']); $www_com_pay_points_gt = empty($_REQUEST['pay_points_gt']) ? 0 : intval($_REQUEST['pay_points_gt']); $www_com_pay_points_lt = empty($_REQUEST['pay_points_lt']) ? 0 : intval($_REQUEST['pay_points_lt']);
die($zip->file()); } elseif ($_REQUEST['act'] == 'get_goods_list') { include_once ROOT_PATH . 'includes/cls_json.php'; $json = new JSON(); $filters = $json->decode($_REQUEST['JSON']); $arr = get_goods_list($filters); $opt = array(); foreach ($arr as $key => $val) { $opt[] = array('goods_id' => $val['goods_id'], 'goods_name' => $val['goods_name']); } make_json_result($opt); } elseif ($_REQUEST['act'] == 'act_export_taobao V4.6') { /* 检查权限 */ admin_priv('goods_export'); include_once 'includes/cls_phpzip.php'; $zip = new PHPZip(); $where = get_export_where_sql($_POST); $goods_class = intval($_POST['goods_class']); $post_express = floatval($_POST['post_express']); $express = floatval($_POST['express']); $ems = floatval($_POST['ems']); $shop_province = '""'; $shop_city = '""'; if ($_CFG['shop_province'] || $_CFG['shop_city']) { $sql = "SELECT region_id, region_name FROM " . $ecs->table('region') . " WHERE region_id IN ('{$_CFG['shop_province']}', '{$_CFG['shop_city']}')"; $arr = $db->getAll($sql); if ($arr) { if (count($arr) == 1) { if ($arr[0]['region_id'] == $_CFG['shop_province']) { $shop_province = '"' . $arr[0]['region_name'] . '"'; } else {
public function zippro() { //打包项目 require_once COMMON_PATH . "tp_common.php"; //引入自定义的类 require_once COMMON_PATH . "tpmaker.class.php"; //引入自定义的类 require_once COMMON_PATH . "zip.class.php"; //引入自定义的类 $buideid = $_REQUEST['id']; $t = new tpmaker(); $t->projectid = $buideid; $zippath = $t->getapppath(); $projects = $t->getprojects(); $filename = './Backup/ZIP/' . $projects['proname'] . ".zip"; $z = new PHPZip(); $filesize = @filesize($filename); $_SESSION['zipdir'] = ''; //所有子目录 $_SESSION['zipfile'] = ''; //所有子目录 zipdir($zippath); $dirs = $_SESSION['zipdir']; //所有子目录 $files = $_SESSION['zipfile']; //所有文件 if ($dirs) { foreach ($dirs as $dir) { $z->add_dir($dir); //添加指定目录 msg($dir . "...添加目录成功!<br>"); //read_dir($dir); } } if ($files) { foreach ($files as $file) { $fp = @fopen($file, rb); $zipfilecontent = array($file, @fread($fp, $filesize)); @fclose($fp); $z->Add($zipfilecontent, 1); //可以多次执行 $zip->Add 来添加多个文件 msg($file . "...添加文件成功!<br>"); } } closedir($path); if (@fputs(@fopen($filename, "wb"), $z->get_file())) { //写入文件 msg("文件压缩成功!!"); } else { msg("文件压缩失败!!", 0); } echo "<a href='{$filename}' traget='_blank'>下载本文件:{$filename}</a>"; }
/** * 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); }
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"); }
} } } 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!');