問(wèn)題說(shuō)明:知識(shí)付費(fèi)系統(tǒng)存在任意文件刪除方法,可以刪除系統(tǒng)任意文件
解決方法:限制刪除目錄
修改文件:extend/service/UtilService
修改方法:rmPublicResource()
/**
* 刪除公告資源
* @param $url
* @return \StdClass
*/
public static function rmPublicResource($url, $isPath = false)
{
$path = $isPath ? $url : realpath(self::urlToPath($url));
if (!$path) return JsonService::fail('刪除文件不存在!');
if (!file_exists($path)) return JsonService::fail('刪除路徑不合法!');
if(0 !== strpos($path,ROOT_PATH.'public/uploads/') || 0 === strpos($path,ROOT_PATH.'public/uploads/config/file/')) return JsonService::fail('刪除路徑不合法!');
if (!unlink($path)) return JsonService::fail('刪除文件失敗!');
return JsonService::successful();
}