目前的程序中无法删除非本人上传的附件,修正后,拥有管理权限的用户则可以正常删除他人附件了。
1、找到文件 source/module/forum/forum_ajax.php 的 106 行附近,找到- } elseif($_G['gp_action'] == 'deleteattach') {
- if($_G['gp_aids']) {
- foreach($_G['gp_aids'] as $aid) {
- $query = DB::query("SELECT uid, attachment, thumb, remote, aid FROM ".DB::table(getattachtablebyaid($aid))." WHERE aid='$aid' AND uid='$_G[uid]'");
- if(DB::num_rows($query)) {
- DB::delete(getattachtablebyaid($aid), "aid='$aid'");
- DB::delete('forum_attachment', "aid='$aid'");
- }
- while($attach = DB::fetch($query)) {
- dunlink($attach);
- }
- }
- }
- include template('common/header_ajax');
- echo count($_G['gp_aids']);
- include template('common/footer_ajax');
- dexit();
复制代码 修改为- } elseif($_G['gp_action'] == 'deleteattach') {
- $count = 0;
- if($_G['gp_aids']) {
- foreach($_G['gp_aids'] as $aid) {
- $attach = DB::fetch_first("SELECT * FROM ".DB::table(getattachtablebyaid($aid))." WHERE aid='$aid'");
- if($attach && ($attach['pid'] && $attach['pid'] == $_G['gp_pid'] && $_G['uid'] == $attach['uid'] || $_G['forum']['ismoderator'] || !$attach['pid'] && $_G['uid'] == $attach['uid'])) {
- DB::delete(getattachtablebyaid($aid), "aid='$aid'");
- DB::delete('forum_attachment', "aid='$aid'");
- dunlink($attach);
- $count++;
- }
- }
- }
- include template('common/header_ajax');
- echo $count;
- include template('common/footer_ajax');
- dexit();
复制代码 2、找到文件 template/default/forum/post.htm 的 6 行附近,找到- var pid = parseInt('$pid');
复制代码 在他下面添加一行,修改后为- var pid = parseInt('$pid');
- var tid = parseInt('$_G[tid]');
复制代码 3、找到文件 static/js/forum_post.js 的 399 行附近,找到- x.get('forum.php?mod=ajax&action=deleteattach&inajax=yes' + aids, function() {});
复制代码 修改为- x.get('forum.php?mod=ajax&action=deleteattach&inajax=yes&tid=' + tid + '&pid=' + pid + aids, function() {});
复制代码 |