/** * 模板下载 */ public function downTpl() { $web = $this->getWebId(); $this->updApi(ACTION_NAME); if (!$web) { die('error'); } if (strstr($web['filename'], '.zip')) { $arr = explode('/', $web['filename']); $count = count($arr); $filename = $arr[$count - 1]; unset($arr[$count - 1]); $path = implode('/', $arr); self::downFile(WEB_ROOT . $path . '/', $filename); exit; } $tplName = $web['tpl_style']; if (file_exists(WEB_ROOT . '/MediaTpl/' . $tplName . '/islua.flag')) { $path = WEB_ROOT . '/MediaTpl/' . $tplName . '/'; $tplName = $tplName . '.zip'; self::downFile($path, $tplName); exit; } else { if (file_exists(WEB_ROOT . '/' . $web['filename'] . '/' . $web['tpl_style'] . '.zip')) { unlink(WEB_ROOT . '/' . $web['filename'] . '/' . $web['tpl_style'] . '.zip'); } $Zip = new \Think\PHPZip(); $Zip->Zip(WEB_ROOT . $web['filename'], WEB_ROOT . '/' . $web['filename'] . '/' . $web['tpl_style'] . '.zip'); self::downFile(WEB_ROOT . '/' . $web['filename'] . '/', $web['tpl_style'] . '.zip'); exit; } }
public function down() { $Zip = new \Think\PHPZip(); $Zip->Zip('./MediaTpl/Train/train/', './MediaTpl/Train/train/data.zip'); $this->downFile('./MediaTpl/Train/train/', 'data.zip'); unlink('./MediaTpl/Train/train/data.zip'); exit; }