$sql = "SELECT id,name,remote FROM `sys:attach` WHERE id in(" . $list . ")"; //查询数据库_总记录数 $row_count = System::$db->getCount($sql); $result = System::$db->getAll($sql); foreach ($result as $row) { //删除数据_记录 $sql = "DELETE FROM `sys:attach` WHERE id=" . $row['id']; System::$db->execute($sql); //远程附件 if ($row["remote"]) { //连接 FTP $ftp = new ClsFTP($_G['setting']["attach"]["FTP_USER"], $_G['setting']["attach"]["FTP_PASS"], $_G['setting']["attach"]["FTP_HOST"], $_G['setting']["attach"]["FTP_PORT"]); //FTP 模式 $ftp->pasv($_G['setting']['attach']['FTP_PASV'] == 'true'); //删除文件 $ftp->delete($row['name']); //关闭 FTP $ftp->close(); } else { //删除数据_文件 if (file_exists(VI_ROOT . $row['name'])) { unlink(VI_ROOT . $row['name']); } } } //写入日志 System::insert_event($func, time(), time(), "删除文件:" . $list); //System :: redirect($url,"所选文件成功被删除!"); $_G['project']['message'] = $row_count . "个文件成功被删除!"; break; }
public static function delete_remote($file, $param) { global $_G; require VI_ROOT . 'source/class/ftp.php'; //转换成相对路径 $file = str_replace($_G['setting']['attach']['FTP_SITE'], $_G['setting']['attach']['FTP_ROOT'], $file); //连接 FTP $ftp = new ClsFTP($_G['setting']["attach"]["FTP_USER"], $_G['setting']["attach"]["FTP_PASS"], $_G['setting']["attach"]["FTP_HOST"], $_G['setting']["attach"]["FTP_PORT"]); //FTP 模式 $ftp->pasv($_G['setting']['attach']['FTP_PASV'] == 'true'); if (in_array(fileext($file), $_G['upload']['image'])) { if ($param['thumb']) { //删除图片缩略图 $thumb = fix_thumb($file); $ftp->delete($thumb); } if (is_array($param['group'])) { foreach ($param['group'] as $g) { $thumb = explode("*", $g); if (is_array($thumb)) { //删除图片缩略图 $thumb = fix_thumb($file, $thumb); $ftp->delete($thumb); } } } } //删除文件 $res = $ftp->delete($file); //关闭 FTP $ftp->close(); return $res; }