本文整理汇总了PHP中Zip::zip_dir方法的典型用法代码示例。如果您正苦于以下问题:PHP Zip::zip_dir方法的具体用法?PHP Zip::zip_dir怎么用?PHP Zip::zip_dir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zip
的用法示例。
在下文中一共展示了Zip::zip_dir方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doeditxml
function doeditxml()
{
if (!isset($this->post['stylesave']) && !isset($this->post['styleshare'])) {
$xmlcon = $_ENV['theme']->read_xml($this->get[2]);
$this->view->assign('stylename', $this->get[2]);
$this->view->assign('style', $xmlcon);
$this->view->assign('share', $this->get[3]);
$this->view->display('admin_themexml_edit');
} else {
if ($_FILES['styleimg']['name'] != '') {
$image = $_FILES['styleimg'];
$extname = file::extname($image['name']);
if ($extname == 'jpg') {
$destfile = 'style/' . $this->get[2] . '/screenshot.' . $extname;
$result = file::uploadfile($image, $destfile);
if ($result['result']) {
util::image_compress($destfile, NULL, 158, 118);
} else {
$this->message($result['msg'], 'BACK');
}
} else {
$this->message($this->view->lang['uploadFormatWrong'], 'BACK');
}
}
//insert into db
$style = $this->post['style'];
$style['hdversion'] = HDWIKI_VERSION;
$style['path'] = trim($this->get[2]);
$style['charset'] = $_ENV['theme']->style_charset($style[path]);
$stylecon = $_ENV['theme']->add_check_style($style['path']);
if ($stylecon == null) {
$_ENV['theme']->add_style($style);
} else {
$_ENV['theme']->update_style($style);
}
//得到需要插入的blocks的sql。
$style['sql'] = '';
$blocks = $_ENV['theme']->get_blocks_by_theme($this->get[2]);
if ($blocks) {
$insertsql = "INSERT INTO wiki_block (theme,file,area,areaorder,block,fun,tpl,params) VALUES ";
foreach ($blocks as $val) {
$insertsql .= "( '{$val['theme']}','{$val['file']}','{$val['area']}','{$val['areaorder']}','{$val['block']}','{$val['fun']}','{$val['tpl']}','{$val['params']}' ),";
}
$style['sql'] = substr($insertsql, 0, -1);
}
//write to xml
$_ENV['theme']->write_xml($style);
if (isset($this->post['stylesubmit'])) {
$this->message($this->view->lang['docEditSuccess'], 'index.php?admin_theme');
} else {
if (isset($this->post['stylesave'])) {
$this->message($this->view->lang['docEditSuccess'], 'index.php?admin_theme-editxml-' . $style[path] . '-share');
} else {
if (isset($this->post['styleshare'])) {
//check
$filename = 'style/' . $style['path'] . '/share.lock';
if (is_file($filename)) {
$this->message($this->view->lang['style_share_lock'] . $filename, 'BACK');
} else {
file::writetofile($filename, $a = '');
}
//zip
require HDWIKI_ROOT . "/lib/zip.class.php";
$zip = new Zip();
$filedir = array('style/' . $style['path'], 'view/' . $style['path'], 'block/' . $style['path']);
$zipdir = array('hdwiki/style/' . $style['path'], 'hdwiki/view/' . $style['path'], 'hdwiki/block/' . $style['path']);
file::forcemkdir(HDWIKI_ROOT . '/data/tmp/');
$tmpname = HDWIKI_ROOT . '/data/tmp/' . util::random(6) . '.zip';
@$zip->zip_dir($filedir, $tmpname, $zipdir);
//share
if (is_file($tmpname)) {
$zip_content = file::readfromfile($tmpname);
$upload_url = $this->setting['app_url'] . "/hdapp.php?action=upload&type=template";
$data = 'data=' . base64_encode($zip_content);
unlink($tmpname);
if ('1' == @util::hfopen($upload_url, 0, $data)) {
$this->message($this->view->lang['styleShareSuccess'], 'index.php?admin_theme');
} else {
$this->message($this->view->lang['styleShareFaile'], 'index.php?admin_theme');
}
} else {
$this->message($this->view->lang['styleFileZipFail'], 'index.php?admin_theme');
}
}
}
}
}
}