本文整理汇总了PHP中Dir::delFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Dir::delFile方法的具体用法?PHP Dir::delFile怎么用?PHP Dir::delFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dir
的用法示例。
在下文中一共展示了Dir::delFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: gc
public function gc()
{
foreach (glob($this->dir . '/*.php') as $f) {
if (basename($f) != basename($this->file) && filemtime($this->file) + $this->expire < time()) {
Dir::delFile($f);
}
}
}
示例2: upgrade
public function upgrade()
{
switch (q('get.action')) {
case 'downloadLists':
$data = f('_upgrade_');
if (empty($data['data']['files'])) {
//文件全部下载完成或本次更新没有修改的文件时,更新数据库
go(u('upgrade', ['action' => 'sql']));
}
return view('downloadLists')->with('data', $data);
break;
case 'download':
$data = f('_upgrade_');
$fileLists = $data['data']['files'];
//下载文件,根据文件类型 ADM AM下载,D删除
if (empty($fileLists)) {
//全部下载完成
$res = ['valid' => 2];
} else {
//从第一个文件开始下载
$firstFile = current($fileLists);
$action = strtoupper($firstFile[0]);
$file = trim(substr($firstFile, 1));
if ($action == 'D') {
if (\Dir::delFile($file)) {
array_shift($fileLists);
$res = ['valid' => 1];
} else {
$res = ['valid' => 0];
}
} else {
//下载文件
$postData = ['file' => $file, 'releaseCode' => $data['data']['version'][0]['releaseCode']];
$content = \Curl::post($this->url . '&a=cloud/download&t=web&siteid=1&m=store', $postData);
is_dir(dirname($file)) or mkdir(dirname($file), 0755, TRUE);
$res = json_decode($content, TRUE);
if (isset($res['valid']) && $res['valid'] == 0) {
$res = ['valid' => 0];
} else {
if (in_array(basename($file), ['database.php'])) {
$res = ['valid' => 1, 'file' => $file];
} else {
if (in_array(dirname($file), ['theme', 'addons', 'attachment'])) {
$res = ['valid' => 1, 'file' => $file];
} else {
if (file_put_contents($file, $content)) {
$res = ['valid' => 1, 'file' => $file];
} else {
$res = ['valid' => 0, 'file' => $file];
}
}
}
}
}
}
$data['data']['files'] = $fileLists;
f('_upgrade_', $data);
echo json_encode($res);
break;
case 'sql':
if (IS_POST) {
cli('migrate:make');
echo json_encode($res = ['valid' => 2]);
exit;
}
return view('updateSql')->with('data', f('_upgrade_'));
break;
case 'finish':
$data = f('_upgrade_');
//全部更新完成
$this->db['id'] = 1;
$this->db['versionCode'] = $data['data']['version'][0]['versionCode'];
$this->db['releaseCode'] = $data['data']['version'][0]['releaseCode'];
$this->db['createtime'] = time();
$this->db->save();
//删除更新缓存
f('_upgrade_', '[del]');
message('恭喜! 系统更新完成', 'upgrade', 'success');
break;
default:
$hdcms = $this->db->find(1);
$data = \Curl::get($this->url . "&a=cloud/HdcmsUpgrade&t=web&siteid=1&m=store&AppSecret={$hdcms['AppSecret']}&releaseCode=" . $hdcms['releaseCode']);
$data = json_decode($data, TRUE);
f('_upgrade_', $data);
return view()->with(['data' => $data, 'hdcms' => $hdcms]);
}
}