本文整理汇总了PHP中Update::downloadFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Update::downloadFile方法的具体用法?PHP Update::downloadFile怎么用?PHP Update::downloadFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Update
的用法示例。
在下文中一共展示了Update::downloadFile方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: downloadAndInstall
/**
* 本地一键安装接口
*
* @return void
*/
public function downloadAndInstall()
{
header("content-Type: text/html; charset=utf-8");
// 获取下载地址
$id = intval($_GET['id']);
$url = $this->remoteBaseURL . '/index.php?s=admin/store/downloadApp&id=' . $id;
// dump($url);exit;
$info = wp_file_get_contents($url);
$info = json_decode($info, true);
if (!$info['status']) {
$this->error($info['error']);
exit;
}
// 载入下载类
Vendor('Update');
$updateClass = new \Update();
// 从服务器端下载应用到本地
$res = $updateClass->downloadFile($info['data']['packageURL']);
if ($res != 1) {
$this->error('下载应用失败,请确认网络是否正常');
exit;
}
// 压缩
$package = explode('/', $info['data']['packageURL']);
$packageName = array_pop($package);
$targetDir = $updateClass->downloadPath . 'unzip';
// 创建目录unzip
if (!is_dir($targetDir)) {
@mkdir($targetDir, 0777);
}
$res = $updateClass->unzipPackage($packageName, $targetDir);
if ($res != 1) {
$this->error('下载应用解压失败');
exit;
}
// 覆盖代码
switch ($info['data']['type']) {
case 3:
// 万能页面功能块
$res = $updateClass->overWrittenFile(SITE_PATH . '/Addons/Diy/Widget');
break;
case 2:
// 在线素材
$res = $updateClass->overWrittenFile(SITE_PATH . '/Addons/Material');
break;
case 2:
// 微官网模板
$res = $updateClass->overWrittenFile(SITE_PATH . '/Addons/WeiSite/View/default');
break;
default:
// 微信插件
$res = $updateClass->overWrittenFile(SITE_PATH . '/Addons');
if (empty($res)) {
$this->install($updateClass->addon_name);
exit;
}
}
$this->success('安装完成');
}
示例2: downloadAndInstall
/**
* 一键安装接口
* @return void
*/
public function downloadAndInstall()
{
header("content-Type: text/html; charset=utf-8");
// 获取下载地址
$develop_id = intval($_GET['develop_id']);
$url = $this->RemoteAppURL . '/index.php?app=public&mod=Tool&act=downloadApp&develop_id=' . $develop_id;
$info = file_get_contents($url);
$info = json_decode($info, true);
// 载入下载类
tsload(ADDON_PATH . '/library/Update.class.php');
$updateClass = new Update();
//从服务器端下载应用到本地
$res = $updateClass->downloadFile($info['packageURL']);
if ($res != 1) {
$this->error('下载应用失败,请确认网络是否正常');
exit;
}
// 压缩
$package = explode('/', $info['file']['filename']);
$packageName = array_pop($package);
$targetDir = $updateClass->downloadPath . 'unzip';
// 创建目录unzip
if (!is_dir($targetDir)) {
@mkdir($targetDir, 0777);
}
$res = $updateClass->unzipPackage($packageName, $targetDir);
if ($res != 1) {
$this->error('下载应用解压失败');
exit;
}
// 覆盖代码
switch ($info['type']) {
case 3:
// 应用
$res = $updateClass->overWrittenFile(APPS_PATH);
break;
case 2:
// 插件
$res = $updateClass->overWrittenFile(ADDON_PATH . '/plugin');
break;
case 1:
// 皮肤
$res = $updateClass->overWrittenFile(ADDON_PATH . '/theme');
break;
}
// 安装
switch ($info['type']) {
case 3:
// 应用
U('admin/Apps/preinstall', array('app_name' => $info['app_name'], 'install' => 1), true);
break;
case 2:
// 插件
U('admin/Addons/index', array('install' => 1), true);
break;
case 1:
U('admin/Apps/onLineApp', true);
break;
}
}
示例3: updateAdminTab
/**
* 对比后台菜单配置文件
*/
public function updateAdminTab()
{
/* 下载文件-begin */
tsload(ADDON_PATH . '/library/Update.class.php');
$updateClass = new Update();
$packageURL = C('TS_UPDATE_SITE') . '/data/lang/system_config.zip';
$updateClass->downloadFile($packageURL);
$updateClass->unzipPackage('system_config.zip', LANG_PATH, false);
/* 下载文件-end */
$tabFileArr = (include LANG_PATH . '/system_config.php');
$this->pageTitle[ACTION_NAME] = '对比后台菜单配置';
$this->pageKeyList = array('key', 'DOACTION');
$this->pageButton[] = array('title' => '同步', 'onclick' => "admin.updateAdminTab(this)");
$this->_listpk = 'tab_id';
foreach ($tabFileArr as $key => $val) {
$keys = explode('-', $key);
$map['list'] = $keys[1];
$map['key'] = $keys[0];
if ($res = D('system_config')->where($map)->find()) {
$localTab = unserialize($res['value']);
if (count($val['key']) != count($localTab['key'])) {
$arr[$key]['tab_id'] = $key;
$arr[$key]['key'] = $keys[0];
$arr[$key]['DOACTION'] = '<a href="javascript:void(0);" onclick="admin.updateAdminTab(\'' . $key . '\')">修改</a>';
} else {
foreach ($localTab as $k => $v) {
foreach ($v as $k1 => $v1) {
if (htmlspecialchars_decode($val[$k][$k1], ENT_QUOTES) != $v1) {
$arr[$key]['tab_id'] = $key;
$arr[$key]['key'] = $keys[0];
$arr[$key]['DOACTION'] = '<a href="javascript:void(0);" onclick="admin.updateAdminTab(\'' . $key . '\')">修改</a>';
}
}
}
}
} else {
$arr[$key]['tab_id'] = $key;
$arr[$key]['key'] = $keys[0];
$arr[$key]['DOACTION'] = '<a href="javascript:void(0);" onclick="admin.updateAdminTab(\'' . $key . '\')">添加</a>';
}
unset($map);
}
// dump(111);exit;
$listData['data'] = $arr;
$this->displayList($listData);
}
示例4: header
function step03_download()
{
header("content-Type: text/html; charset=utf-8");
$packageName = t($_GET['packageName']);
// $packageName = jiemi ( $packageName );
tsload(ADDON_PATH . '/library/Update.class.php');
$updateClass = new Update();
$packageURL = $this->updateURL . '/' . $packageName;
echo $updateClass->downloadFile($packageURL);
}