public function remoteinstall() { //安全验证 $this->checksafeauth(); $url = $this->_get('url'); $ext = strtolower(strrchr($url, '.')); $filepath = ltrim(strrchr($url, '/'), '/'); if ($ext != '.zip') { //兼容旧版本 $url = xbase64_decode($url); $ext = strtolower(strrchr($url, '.')); $filepath = ltrim(strrchr($url, '/'), '/'); if ($ext != '.zip') { $this->error('远程文件格式必须为.zip'); } } $content = fopen_url($url); if (empty($content)) { $this->error('远程获取文件失败!'); } $filename = substr($filepath, 0, -4); File::write_file($filepath, $content); import('ORG.PclZip'); $zip = new PclZip($filepath); $zip->extract(PCLZIP_OPT_PATH, './'); @unlink($filepath); //删除安装文件 $this->success('操作成功!', U('App/index')); }
public function remoteinstall() { $url = $this->_get('url'); if ($ext != '.zip') { //兼容旧版本 $url = xbase64_decode($url); $ext = strtolower(strrchr($url, '.')); $filepath = ltrim(strrchr($url, '/'), '/'); if ($ext != '.zip') { $this->error('远程文件格式必须为.zip'); } } $content = fopen_url($url); if (empty($content)) { $this->assign('waitSecond', 20); $this->error('远程获取文件失败!,<a href="' . $url . '" target="_blank">本地下载安装</a>'); } $filename = substr($filepath, 0, -4); //检测是否已经安装 $model = M('arcmodel'); $id = $model->order('id desc')->getField('id') + 1; if ($model->where("nid='" . $filename . "'")->find()) { $this->error('系统已安装当前模型!'); } //获取数据并解压缩 $tplpath = './Public/Model/' . $filename; File::write_file($filepath, $content); import('ORG.PclZip'); $zip = new PclZip($filepath); $zip->extract(PCLZIP_OPT_PATH, $tplpath); //删除压缩包 @unlink($filepath); //导入数据 $sqlfile = $tplpath . '/data.sql'; if (is_file($sqlfile)) { $sql = explode('###', strtr(File::read_file($sqlfile), array('#@__' => C('DB_PREFIX'), '__LINE__' => $id))); foreach ($sql as $v) { $model->execute(trim($v)); } } //刷新缓存 jump(U('Arcmodel/over')); }
public function remoteinstall() { //安全验证 $this->checksafeauth(); $url = $this->_get('url'); $ext = strtolower(strrchr($url, '.')); $filepath = ltrim(strrchr($url, '/'), '/'); if ($ext != '.zip') { //兼容旧版本 $url = xbase64_decode($url); $ext = strtolower(strrchr($url, '.')); $filepath = ltrim(strrchr($url, '/'), '/'); if ($ext != '.zip') { $this->error('远程文件格式必须为.zip'); } } $content = fopen_url($url); if (empty($content)) { $this->assign('waitSecond', 20); $this->error('远程获取文件失败!,<a href="' . $url . '" target="_blank">本地下载安装</a>'); } $filename = substr($filepath, 0, -4); $tplpath = './Public/Wap/' . $filename; if (is_dir($tplpath)) { $this->error('模板目录已存在!'); } File::write_file($filepath, $content); import('ORG.PclZip'); $zip = new PclZip($filepath); $zip->extract(PCLZIP_OPT_PATH, $tplpath); @unlink($filepath); //删除安装文件 $this->success('操作成功!', U('Wap/index')); }
public function remoteinstall() { //安全验证 $this->checksafeauth(); $url = $this->_get('url'); $ext = strtolower(strrchr($url, '.')); $filepath = ltrim(strrchr($url, '/'), '/'); if ($ext != '.zip') { //兼容旧版本 $url = xbase64_decode($url); $ext = strtolower(strrchr($url, '.')); $filepath = ltrim(strrchr($url, '/'), '/'); if ($ext != '.zip') { $this->error('远程文件格式必须为.zip'); } } $content = fopen_url($url); if (empty($content)) { $this->assign('waitSecond', 20); $this->error('远程获取文件失败!,<a href="' . $url . '" target="_blank">本地下载安装</a>'); } $filename = substr($filepath, 0, -4); $tplpath = './Public/Special/' . $filename; if (is_dir($tplpath)) { $this->error('专题目录已存在!'); } File::write_file($filepath, $content); import('ORG.PclZip'); $zip = new PclZip($filepath); $zip->extract(PCLZIP_OPT_PATH, $tplpath); @unlink($filepath); //删除安装文件 //导入数据 $xmlpath = './Public/Special/' . $filename . '/special.xml'; if (is_file($xmlpath)) { $xml = simplexml_load_file($xmlpath); $data['title'] = (string) $xml->title; $data['seotitle'] = (string) $xml->seotitle; $data['keywords'] = (string) $xml->keywords; $data['description'] = (string) $xml->description; $data['content'] = (string) $xml->content; $data['tempindex'] = (string) $xml->tempindex; $data['waptempindex'] = (string) $xml->waptempindex; $data['pubdate'] = time(); $model = M('special'); $model->add($data); } $this->success('操作成功!', U('Special/index')); }