本文整理匯總了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]);
}
}