如果是全新安裝,也就是沒安裝其他插件……就請覆蓋原本檔案吧!怕麻煩插件全重裝也行…
注意:要配合安裝〔删帖扣分依主题及回复得分〕 //Polo!,覆蓋的三個文件都不必改……
前臺操作批量刪貼、編輯刪貼,完全可以依照得多少刪多少扣除……積分和金錢都一樣;
刪除的金錢或積分後台可以設置喔…
topicadmin.php
- <?php
- /*
- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- :: [DISCUZ!] Crossday Discuz! Board ::
- :: (c) 2001-2005 Comsenz Technology Ltd (www.discuz.com) ::
- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- :: Author: Crossday (tech@discuz.com) Cnteacher (cnteacher@discuz.com) ::
- :: Version: 2.5F 2004/10/01 05:15 ::
- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- */
- //fix: BY pk0909
- /*
- 1 對分割后的主題缺少html轉義處理
- 2 跳轉的url參數問題
- 3 批量刪除主題時,沒有刪除對應附件
- */
- require './include/common.php';
- require_once DISCUZ_ROOT.'./include/post.php';
- $discuz_action = 151;
- $tid = $tid ? $tid :'';
- $page = intval($page);
- $fpage = intval($fpage);
- //〔刪帖扣分依主題及回復得分〕 加入下面兩行
- $postcredits = $forum['postcredits'] != -1 ? $forum['postcredits'] : $postcredits;
- $replycredits = $forum['replycredits'] != -1 ? $forum['replycredits'] : $replycredits;
- //後台金錢設置 by 地獄死神
- $postmoney = $forum['postmoney'] != -1 ? $forum['postmoney'] : $postmoney;
- $replymoney = $forum['replymoney'] != -1 ? $forum['replymoney'] : $replymoney;
- //後台金錢設置 by 地獄死神
- if($tid) {
- $query = $db->query("SELECT * FROM $table_threads WHERE tid='$tid'");
- $thread = $db->fetch_array($query);
- $thread['subject'] .= $action == 'delthread' ? ", etc." : NULL;
- }
- if($forum['type'] == 'forum') {
- $navigation = "» <a href="forumdisplay.php?fid=$fid&page=$fpage">$forum[name]</a> » <a href="viewthread.php?tid=$tid">$thread[subject]</a> ";
- $navtitle = ' - '.strip_tags($forum['name']).' - '.$thread['subject'];
- } else {
- $query = $db->query("SELECT name, fid, moderator FROM $table_forums WHERE fid='$forum[fup]'");
- $fup = $db->fetch_array($query);
- $navigation = "» <a href="forumdisplay.php?fid=$fup[fid]">$fup[name]</a> » <a href="forumdisplay.php?fid=$fid&page=$fpage">$forum[name]</a> » <a href="viewthread.php?tid=$tid">$thread[subject]</a> ";
- $navtitle = ' - '.strip_tags($fup['name']).' - '.strip_tags($forum['name']).' - '.$thread['subject'];
- }
- if(!$discuz_user || !$discuz_pw || !modcheck($discuz_user)) {
- showmessage('admin_nopermission', NULL, 'HALTED');
- }
- $fupadd = $fup ? "OR (fid='$fup[fid]' && type<>'group')" : NULL;
- if($action == 'moderate') {
- if(!is_array($moderate) || !count($moderate)) {
- showmessage('admin_moderate_nothread');
- }elseif(!$operation){
- showmessage('admin_moderate_nooperation');
- }
- $tids = implode_ids($moderate);
- $query = $db->query("SELECT * FROM $table_threads WHERE tid IN($tids) ");
- if(!submitcheck('moderatesubmit')){
- $threadlist = array();
- while($thread = $db->fetch_array($query)) {
- if($thread['fid'] == $fid){
- $thread['lastposterenc'] = rawurlencode($thread['lastposter']);
- if($thread['attachment']) {
- require_once DISCUZ_ROOT.'./include/attachment.php';
- $thread['attachment'] = attachtype($thread['attachment']).' ';
- } else {
- $thread['attachment'] = '';
- }
- $thread[subject] = cutstr($thread[subject],77);
- $thread['dateline'] = gmdate($dateformat, $thread['dateline'] + $timeoffset * 3600);
- $thread['lastpost'] = gmdate("$dateformat $timeformat", $thread['lastpost'] + $timeoffset * 3600);
- $threadlist[] = $thread;
- }
- }
-
- if(!$threadlist) showmessage('admin_moderate_nothread');
- if($operation == 'move') {
- require_once DISCUZ_ROOT.'./include/forum.php';
- $forumselect = forumselect();
- }
- include template('topicadmin_moderate');
-
- }else{
-
- if($operation == 'move' && $allowmove) {
- if(!$moveto) {
- showmessage('admin_move_invalid');
- }
- accesscheck($query);
- $displayorderadd = !$adminglobal ? ", displayorder='0'" : NULL;
- $db->query("UPDATE $table_threads SET fid='$moveto' $displayorderadd WHERE tid IN($tids)");
- $db->query("UPDATE $table_posts SET fid='$moveto' WHERE tid IN($tids) ");
- if ($forum['type'] == 'sub') {
- $query= $db->query("SELECT fup FROM $table_forums WHERE fid='$fid' LIMIT 1");
- $fup = $db->result($query, 0);
- updateforumcount($fup);
- }
- modlog();
- updateforumcount($moveto);
- updateforumcount($fid);
- showmessage('admin_succeed', "forumdisplay.php?fid=$fid&page=$page");
- }elseif($operation == 'stick' && $allowtop){
- accesscheck($query);
- if($level < 0 || $level > 3) {
- showmessage('undefined_action');
- }
- $db->query("UPDATE $table_threads SET displayorder='$level' WHERE tid IN ($tids)");
- modlog();
- showmessage('admin_succeed', "forumdisplay.php?fid=$fid&page=$page");
- }elseif($operation == 'delete' && $allowdelpost) {
- accesscheck($query);
- //〔刪帖扣分依主題及回復得分〕 加入下面一行
- $tuids = $tcomma = '';
- $uids = $comma = '';
- //〔刪帖扣分依主題及回復得分〕 開始
- $query = $db->query("SELECT authorid FROM $table_threads WHERE tid IN ($tids)");
- while($post = $db->fetch_array($query)) {
- $tuids .= "$tcomma$post[authorid]";
- $tcomma = ',';
- }
- updatemember_mark('-', $tuids, ($postcredits-$replycredits), ($postmoney-$replymoney));
- //〔刪帖扣分依主題及回復得分〕 終止
- $haveattach = 0;
- $query = $db->query("SELECT authorid ,aid FROM $table_posts WHERE tid IN ($tids)");
- while($post = $db->fetch_array($query)) {
- $uids .= "$comma$post[authorid]";
- $comma = ',';
- if ($post['aid']) $haveattach++;
- }
- //updatemember('-', $uids, $deletedcredits);
- updatemember('-', $uids, $replycredits, $replymoney);
- if ($haveattach){
- $query = $db->query("SELECT attachment FROM $table_attachments WHERE tid IN ($tids)");
- while($attach = $db->fetch_array($query)) {
- @unlink(DISCUZ_ROOT.'./'.$attachdir.'/'.$attach['attachment']);
- }
- $db->query("DELETE FROM $table_attachments WHERE tid IN ($tids)");
- }
-
- $db->query("DELETE FROM $table_threads WHERE tid IN ($tids)");
- $db->query("DELETE FROM $table_polls WHERE tid IN ($tids)");
- $db->query("DELETE FROM $table_posts WHERE tid IN ($tids)");
- updateforumcount($fid);
- modlog();
- showmessage('admin_succeed', "forumdisplay.php?fid=$fid&page=$page");
- }elseif($operation == 'close' && $allowclose){
- accesscheck($query);
- $close = $type ? 1 : 0;
- $db->query("UPDATE $table_threads SET closed='$close' WHERE tid in($tids)");
- modlog();
- showmessage('admin_succeed', "forumdisplay.php?fid=$fid&page=$page");
- }elseif($operation == 'digest' && $allowdigest){
- if($level < 0 || $level > 3) {
- showmessage('undefined_action', NULL, 'HALTED');
- }
- while($thread = $db->fetch_array($query)) {
- if ($thread['fid'] == $fid && $thread['digest']<>$level){
- $digest_mark=($level-intval($thread['digest']))*$digestcredits;
- $db->query("UPDATE $table_threads SET digest='$level' WHERE tid='$thread[tid]'");
- if($digest_mark && $discuz_uid != $thread[authorid]) {
- $db->query("UPDATE $table_members SET credit=credit".($digest_mark > 0 ? '+' : '')."$digest_mark WHERE uid='$thread[authorid]'");
- }
- }
- }
- modlog();
- showmessage('admin_succeed', "forumdisplay.php?fid=$fid&page=$page");
- }else{
- showmessage('admin_nopermission', NULL, 'HALTED');
- }
- }
- } elseif($action == 'delpost' && $allowdelpost) {
- if(!is_array($delete) || !count($delete)) {
- showmessage('admin_delpost_invalid');
- }
- if(!submitcheck('delpostsubmit')) {
- $query = $db->query("SELECT COUNT(*) FROM $table_posts WHERE tid='$tid'");
- if(count($delete) < $db->result($query, 0)) {
- $deleteid = '';
- foreach($delete as $id) {
- $deleteid .= '<input type="hidden" name="delete[]" value="'.$id.'">';
- }
- include template('topicadmin_delpost');
-
- } else {
- header("Location: {$boardurl}topicadmin.php?action=delete&fid=$fid&tid=$tid&page=$page&fpage=$fpage");
- }
- } else {
- $pids = implode_ids( $delete );
- $uids = $comma = '';
- $actionpost = $totalpost = $aids = 0;
- $query = $db->query("SELECT pid, authorid, aid FROM $table_posts WHERE tid='$tid'");
- $totalpost = $db->num_rows($query);
- while($post = $db->fetch_array($query)) {
- if (in_array($post[pid], $delete)){
- $uids .= "$comma$post[authorid]";
- $comma = ',';
- $actionpost ++;
- if ($post['aid']) $aids .=','.$post[pid];
- }
- }
- if ($actionpost < 1) {
- showmessage('admin_delpost_invalid');
- }elseif($actionpost <> count($delete)){
- showmessage('admin_moderate_accesserror', NULL, 'HALTED');
- }elseif($actionpost >= $totalpost ){
- header("Location: {$boardurl}topicadmin.php?action=delete&fid=$fid&tid=$tid&page=$page&fpage=$fpage");
- }
-
- //updatemember('-', $uids, $deletedcredits);
- updatemember('-', $uids, $replycredits, $replymoney);
-
- if ($aids){
- require_once DISCUZ_ROOT.'./include/attachment.php';
- $query = $db->query("SELECT pid, attachment, filetype FROM $table_attachments WHERE pid IN ($aids)");
- while($attach = $db->fetch_array($query)) {
- @unlink(DISCUZ_ROOT.'./'.$attachdir.'/'.$attach['attachment']);
- }
- $db->query("DELETE FROM $table_attachments WHERE pid IN ($aids)");
- updatethread_type($tid , $thread['attachment']);
- }
- $db->query("DELETE FROM $table_posts WHERE pid IN ($pids)");
- updatethreadcount($tid);
- updateforumcount($fid);
- modlog();
- showmessage('admin_succeed', "viewthread.php?tid=$tid&page=$page&fpage=$fpage");
- }
- } elseif($action == 'highlight' && $allowhighlight) {
- if(!submitcheck('highlightsubmit')) {
- $string = sprintf('%02d', $thread['highlight']);
- $stylestr = sprintf('%03b', $string[0]);
- for($i = 1; $i <= 3; $i++) {
- $stylecheck[$i] = $stylestr[$i - 1] ? 'checked' : NULL;
- }
- $colorcheck = array($string[1] => 'checked');
-
- include template('topicadmin_highlight');
- } else {
- $stylebin = '';
- for($i = 1; $i <= 3; $i++) {
- $stylebin .= empty($highlight_style[$i]) ? '0' : '1';
- }
- $highlight_style = bindec($stylebin);
- if($highlight_style < 0 || $highlight_style > 7 || $highlight_color < 0 || $highlight_color > 8) {
- showmessage('undefined_action', NULL, 'HALTED');
- }
- $db->query("UPDATE $table_threads SET highlight='$highlight_style$highlight_color' WHERE tid='$tid'");
- modlog();
- showmessage('admin_succeed', "forumdisplay.php?fid=$fid&page=$fpage");
- }
- } elseif($action == 'digest' && $allowdigest) {
- if(!submitcheck('digestsubmit')) {
- include template('topicadmin_digest');
- } else {
- if($level < 0 || $level > 3) {
- showmessage('undefined_action', NULL, 'HALTED');
- }
- $digest_mark=($level-intval($thread['digest']))*$digestcredits;
- $db->query("UPDATE $table_threads SET digest='$level' WHERE tid='$tid'");
- if($digest_mark && $discuz_uid != $thread['authorid'] ) {
- $db->query("UPDATE $table_members SET credit=credit".($digest_mark > 0 ? '+' : '')."$digest_mark WHERE uid='$thread[authorid]'");
- }
- modlog();
- showmessage('admin_succeed', "forumdisplay.php?fid=$fid&page=$fpage");
- }
- } elseif($action == 'recount') {
- $query = $db->query("SELECT COUNT(*) FROM $table_posts WHERE tid='$tid'");
- $replies = $db->result($query, 0) - 1;
- $query = $db->query("SELECT author, dateline FROM $table_posts WHERE tid='$tid' ORDER BY dateline DESC LIMIT 1");
- $post = $db->fetch_array($query);
- $db->query("UPDATE $table_threads SET replies='$replies', lastpost='$post[dateline]', lastposter='".addslashes($post['author'])."' WHERE tid='$tid'");
- showmessage('admin_succeed', "viewthread.php?tid=$tid&fpage=$fpage");
- } elseif($action == 'delete' && $allowdelpost) {
- if(!submitcheck('deletesubmit')) {
- include template('topicadmin_delete');
- } else {
- //〔刪帖扣分依主題及回復得分〕 開始
- updatemember_mark('-', $thread[authorid], ($postcredits-$replycredits), ($postmoney-$replymoney));
- //〔刪帖扣分依主題及回復得分〕 終止
- $uids = $comma = '';
- $query = $db->query("SELECT authorid,aid FROM $table_posts WHERE tid='$tid'");
- $aids = 0;
- while($post = $db->fetch_array($query)) {
- $uids .= "$comma$post[authorid]";
- $comma = ',';
- if ($post['aid']) $aids++;
- }
- //updatemember('-', $uids, $deletedcredits);
- updatemember('-', $uids, $replycredits, $replymoney);
- $db->query("DELETE FROM $table_threads WHERE tid='$tid'");
- $db->query("DELETE FROM $table_posts WHERE tid='$tid'");
-
- if ($aids){
- $query = $db->query("SELECT attachment FROM $table_attachments WHERE tid='$tid'");
- while($attach = $db->fetch_array($query)) {
- @unlink(DISCUZ_ROOT.'./'.$attachdir.'/'.$attach['attachment']);
- }
- $db->query("DELETE FROM $table_attachments WHERE tid='$tid'");
- }
-
- updateforumcount($fid);
- if ($forum['type'] == 'sub') {
- updateforumcount($fup['fid']);
- }
- modlog();
- showmessage('admin_succeed', "forumdisplay.php?fid=$fid&page=$fpage");
- }
- } elseif($action == 'close' && $allowclose) {
- if(!submitcheck('closesubmit')) {
- include template('topicadmin_openclose');
- } else {
- $openclose = $thread['closed'] ? 0 : 1;
- $db->query("UPDATE $table_threads SET closed='$openclose' WHERE tid='$tid' AND fid='$fid'");
- modlog();
- showmessage('admin_succeed', "forumdisplay.php?fid=$fid&page=$fpage");
- }
- } elseif($action == 'move' && $allowmove) {
- if(!submitcheck('movesubmit')) {
- require_once DISCUZ_ROOT.'./include/forum.php';
- $forumselect = forumselect();
- include template('topicadmin_move');
- } else {
- if(!$moveto) {
- showmessage('admin_move_invalid');
- }
- $displayorderadd = !$adminglobal ? ", displayorder='0'" : NULL;
- if($type == 'normal') {
- $db->query("UPDATE $table_threads SET fid='$moveto' $displayorderadd WHERE tid='$tid' AND fid='$fid'");
- $db->query("UPDATE $table_posts SET fid='$moveto' WHERE tid='$tid' AND fid='$fid'");
- } else {
- $db->query("INSERT INTO $table_threads (fid, creditsrequire, iconid, author, authorid, subject, dateline, lastpost, lastposter, views, replies, displayorder, digest, closed, poll, attachment)
- VALUES ('$thread[fid]', '$thread[creditsrequire]', '$thread[iconid]', '".addslashes($thread['author'])."', '$thread[authorid]', '$thread[subject]', '$thread[dateline]', '$thread[lastpost]', '$thread[lastposter]', '0', '0', '0', '0', '$thread[tid]', '0', '0')");
- $db->query("UPDATE $table_threads SET fid='$moveto' $displayorderadd WHERE tid='$tid' AND fid='$fid'");
- $db->query("UPDATE $table_posts SET fid='$moveto' WHERE tid='$tid' AND fid='$fid'");
- }
- if ($forum['type'] == 'sub') {
- $query= $db->query("SELECT fup FROM $table_forums WHERE fid='$fid' LIMIT 1");
- $fup = $db->result($query, 0);
- updateforumcount($fup);
- }
- modlog();
- updateforumcount($moveto);
- updateforumcount($fid);
- showmessage('admin_succeed', "forumdisplay.php?fid=$fid&page=$fpage");
- }
- } elseif($action == 'top' && $allowtop) {
- if(!submitcheck('topsubmit')) {
- include template('topicadmin_topuntop');
- } else {
- if($level < 0 || $level > 3) {
- showmessage('undefined_action');
- }
- $db->query("UPDATE $table_threads SET displayorder='$level' WHERE tid='$tid' AND fid='$fid'");
- modlog();
- showmessage('admin_succeed', "forumdisplay.php?fid=$fid&page=$fpage");
- }
- } elseif($action == 'getip' && $allowviewip) {
- require_once DISCUZ_ROOT.'./include/misc.php';
- $query = $db->query("SELECT m.adminid, p.useip FROM $table_posts p
- LEFT JOIN $table_members m ON m.uid=p.authorid
- WHERE pid='$pid' AND tid='$tid'");
- if(!$member = $db->fetch_array($query)) {
- showmessage('thread_nonexistence', NULL, 'HALTED');
- } elseif(($member['adminid'] == 1 && $adminid > 1) || ($member['adminid'] == 2 && $adminid > 2)) {
- showmessage('admin_getip_nopermission', NULL, 'HALTED');
- }
- $member['iplocation'] = convertip($member['useip']);
- include template('topicadmin_getip');
- } elseif($action == 'bump') {
- if(!submitcheck('bumpsubmit')) {
- include template('topicadmin_bump');
- } else {
- $query = $db->query("SELECT subject, lastposter, lastpost FROM $table_threads WHERE tid='$tid' LIMIT 1");
- $thread = $db->fetch_array($query);
- $thread[lastposter] = addslashes($thread['lastposter']);
- $db->query("UPDATE $table_threads SET lastpost='$timestamp' WHERE tid='$tid' AND fid='$fid'");
- $db->query("UPDATE $table_forums SET lastpost='$thread[subject]\t$timestamp\t$thread[lastposter]' WHERE fid='$fid' $fupadd");
- modlog();
- showmessage('admin_succeed', "forumdisplay.php?fid=$fid&page=$fpage");
- }
- } elseif($action == 'split' && $allowsplit) {
- if(!submitcheck('splitsubmit')) {
- require_once DISCUZ_ROOT.'./include/discuzcode.php';
- $replies = $thread['replies'];
- if($replies <= 0) {
- showmessage('admin_split_invalid');
- }
- $postlist = array();
- $query = $db->query("SELECT * FROM $table_posts WHERE tid='$tid' ORDER BY dateline");
- while($post = $db->fetch_array($query)) {
- $post['message'] = postify($post['message'], $post['smileyoff'], $post['bbcodeoff']);
- $postlist[] = $post;
- }
- include template('topicadmin_split');
- } else {
- if(!trim($subject)) {
- showmessage('admin_split_subject_invalid');
- }
- $subject = $subject ? dhtmlspecialchars(censor(trim($subject))) :'';
- $pids = implode_ids( $split );
- if($pids) {
- $db->query("INSERT INTO $table_threads (fid, subject) VALUES ('$fid', '$subject')");
- $newtid = $db->insert_id();
- $db->query("UPDATE $table_posts SET tid='$newtid' WHERE pid IN ($pids)");
- $db->query("UPDATE $table_attachments SET tid='$newtid' WHERE pid IN ($pids)");
- $query = $db->query("SELECT author, authorid, dateline FROM $table_posts WHERE tid='$tid' ORDER BY dateline ASC LIMIT 1");
- $fpost = $db->fetch_array($query);
- $db->query("UPDATE $table_threads SET author='$fpost[author]', authorid='$fpost[authorid]', dateline='$fpost[dateline]' WHERE tid='$tid'");
- $query = $db->query("SELECT author, authorid, dateline FROM $table_posts WHERE tid='$newtid' ORDER BY dateline ASC LIMIT 1");
- $fpost = $db->fetch_array($query);
- $db->query("UPDATE $table_threads SET author='$fpost[author]', authorid='$fpost[authorid]', dateline='$fpost[dateline]' WHERE tid='$newtid'");
- updatethreadcount($tid);
- updatethreadcount($newtid);
- updateforumcount($fid);
- modlog();
- showmessage('admin_succeed', "forumdisplay.php?fid=$fid&page=$fpage");
- } else {
- showmessage('admin_split_new_invalid');
- }
- }
- } elseif($action == 'merge' && $allowmerge) {
- if(!submitcheck('mergesubmit')) {
- include template('topicadmin_merge');
- } else {
- $query = $db->query("SELECT fid, views, replies FROM $table_threads WHERE tid='$othertid'");
- if(!$other = $db->fetch_array($query)) {
- showmessage('admin_merge_nonexistence');
- }
- if(!$adminglobal && $other['fid'] != $forum['fid']) {
- showmessage('admin_merge_invalid');
- }
- $other['views'] = intval($other['views']);
- $other['replies']++;
- $db->query("UPDATE $table_posts SET tid='$tid' WHERE tid='$othertid'");
- $postsmerged = $db->affected_rows();
- $db->query("UPDATE $table_attachments SET tid='$tid' WHERE tid='$othertid'");
- $db->query("DELETE FROM $table_threads WHERE tid='$othertid'");
- $db->query("UPDATE $table_threads SET views=views+$other[views], replies=replies+$other[replies] WHERE tid='$tid'");
-
- if($fid == $other['fid']) {
- $db->query("UPDATE $table_forums SET threads=threads-1 WHERE fid='$fid' $fupadd");
- } else {
- $db->query("UPDATE $table_forums SET threads=threads-1, posts=posts-$postsmerged WHERE fid='$other[fid]'");
- $db->query("UPDATE $table_forums SET posts=$posts+$postsmerged WHERE fid='$fid' $fupadd");
- }
- modlog();
- showmessage('admin_succeed', "forumdisplay.php?fid=$fid&page=$fpage");
- }
- } else {
- showmessage('admin_nopermission', NULL, 'HALTED');
- }
- function modlog($action = '') {
- global $discuz_user, $groupid, $adminid, $onlineip, $timestamp, $forum, $thread, $operation, $tids;
- if(!$action) {
- $action = $GLOBALS['action'];
- }
- if (!$thread['tid']) $thread['tid']=intval($GLOBALS['tid']);
- if ($action == 'moderate'){
- $action .='_'.$operation;
- $thread[subject] = $tids;
- $thread[tid] = 0;
- }
- @$fp = fopen(DISCUZ_ROOT.'./forumdata/modslog.php', 'a');
- @flock($fp, 2);
- @fwrite($fp, "$timestamp\t$discuz_user\t$groupid\t$onlineip\t$forum[fid]\t$forum[name]\t$thread[tid]\t$thread[subject]\t$action\n");
- @fclose($fp);
- }
- function accesscheck($query) {
- global $db,$fid;
- while($thread = $db->fetch_array($query)) {
- if($thread['fid'] <> $fid){
- showmessage('admin_moderate_accesserror', NULL, 'HALTED');
- }
- }
- }
- ?>
复制代码
.\include\post.php
- <?php
- /*
- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- :: [DISCUZ!] Crossday Discuz! Board ::
- :: (c) 2001-2005 Comsenz Technology Ltd (www.discuz.com) ::
- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- :: Author: Crossday (tech@discuz.com) Cnteacher (cnteacher@discuz.com) ::
- :: Version: 2.5F 2004/10/01 05:15 ::
- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- */
- //fix: BY pk0909
- /*
- 1 smilecheck
- 2 保存文件名的stripslashes
- */
- if(!defined('IN_DISCUZ')) {
- exit('Access Denied');
- }
- function attach_upload() {
- global $attach, $attach_name, $attach_size, $attach_fname, $attach_type, $attachperm, $allowsetattachperm, $timestamp;
- $success_upload = array();
- if (is_array($attach) && count($attach)){
- foreach( $attach as $key => $t_attach) {
- $t_attach_name = daddslashes($attach_name[$key]);
- $t_attachment = attach_upload_file($t_attach, $t_attach_name, $attach_size[$key], $attach_fname[$key],$attach_type[$key]);
- if ($t_attachment){
- $success_upload[$key] = array (
- 'filename' => $t_attach_name,
- 'filetype' => $attach_type[$key],
- 'filesize' => $attach_size[$key],
- 'attachment' => $t_attachment,
- 'creditsrequire' => $allowsetattachperm ? $attachperm[$key] : 0,
- 'dateline' => $GLOBALS['timestamp'],
- );
- }
- }
- }elseif($attach){
- $attach_name = daddslashes($attach_name);
- $t_attachment = attach_upload_file($attach, $attach_name, $attach_size, $attach_fname,$attach_type);
- if ($t_attachment){
- $success_upload[0] =array(
- 'filename' => $attach_name,
- 'filetype' => $attach_type,
- 'filesize' => $attach_size,
- 'attachment' => $t_attachment,
- 'creditsrequire' => $allowsetattachperm ? $attachperm : 0,
- 'dateline' => $GLOBALS['timestamp'],
- );
- }
- }
- return $success_upload;
- }
- function attach_upload_file($attach, $attach_name, $attach_size, $attach_fname, $attach_type) {
- global $db, $table_attachtypes, $extension, $typemaxsize;
- global $attachdir, $maxattachsize, $attachextensions,$attachsave;
- if(!($attach != 'none' && strpos($attach, '..') === FALSE && $attach && trim($attach_name))) {
- return false;
- }
- $filename = $attach_name;
- $attach_ext = $extension = strtolower(fileext($attach_name));
- if($attachextensions && @!eregi($attach_ext, $attachextensions)) {
- showmessage('post_attachment_ext_notallowed');
- }
- if(!$attach_size || ($maxattachsize && $attach_size > $maxattachsize)) {
- showmessage('post_attachment_toobig');
- }
- $query = $db->query("SELECT maxsize FROM $table_attachtypes WHERE extension='".addslashes($attach_ext)."'");
- if($type = $db->fetch_array($query)) {
- if($type['maxsize'] == 0) {
- showmessage('post_attachment_ext_notallowed');
- } elseif($attach_size > $type['maxsize']) {
- $typemaxsize = sizecount($type['maxsize']);
- showmessage('post_attachment_type_toobig');
- }
- }
- if($attachsave) {
- switch($attachsave) {
- case 1: $attach_subdir = 'forumid_'.$GLOBALS['fid']; break;
- case 2: $attach_subdir = 'ext_'.$extension; break;
- case 3: $attach_subdir = 'month_'.date('ym'); break;
- case 4: $attach_subdir = 'day_'.date('ymd'); break;
- }
- $attach_dir = DISCUZ_ROOT.'./'.$attachdir.'/'.$attach_subdir;
- if(!is_dir($attach_dir)) {
- mkdir($attach_dir, 0777);
- fclose(fopen($attach_dir.'/index.htm', 'w'));
- }
- $attach_fname = $attach_subdir.'/';
- } else {
- $attach_fname = '';
- }
- $filename = substr($filename, 0, strlen($filename) - strlen($extension) - 1);
- if(preg_match("/[\x7f-\xff]+/s", $filename)) {
- $filename = str_replace('/', '', base64_encode(substr($filename, 0, 20)));
- }
- if(in_array($attach_ext, array('php', 'php3', 'jsp', 'asp', 'aspx', 'cgi', 'pl'))) {
- $extension = '_'.$extension;
- }
- $attach_saved = false;
- $attach_fname .= substr($filename, 0, 64).'_'.random(12).'.'.$extension;
- $target = DISCUZ_ROOT.'./'.$attachdir.'/'.stripslashes($attach_fname);
- if(@copy($attach, $target) || (function_exists('move_uploaded_file') && @move_uploaded_file($attach, $target))) {
- $attach_saved = true;
- }
- if(!$attach_saved && @is_readable($attach)) {
- @$fp = fopen($attach, 'rb');
- @flock($fp, 2);
- @$attachedfile = fread($fp, $attach_size);
- @fclose($fp);
- @$fp = fopen($target, 'wb');
- @flock($fp, 2);
- if(@fwrite($fp, $attachedfile)) {
- $attach_saved = true;
- }
- @fclose($fp);
- }
- if($attach_saved) {
- if(in_array($attach_ext, array('jpg', 'gif', 'png', 'swf', 'bmp')) && function_exists('getimagesize') && !getimagesize($target)) {
- @unlink($target);
- showmessage('post_attachment_ext_notallowed');
- } else {
- return $attach_fname;
- }
- } else {
- showmessage('post_attachment_save_error');
- }
- }
- function checkflood() {
- global $disablepostctrl, $floodctrl, $discuz_uid, $timestamp, $lastpost, $forum;
- if(!$disablepostctrl && $floodctrl) {
- if($discuz_uid) {
- if($timestamp - $floodctrl <= $lastpost) {
- return TRUE;
- }
- } else {
- $lastpost = explode("\t", $forum['lastpost']);
- if(($timestamp - $floodctrl) <= $lastpost[1] && $discuz_user == $lastpost[2]) {
- return TRUE;
- }
- }
- }
- return FALSE;
- }
- function checkpost() {
- global $subject, $message, $disablepostctrl, $minpostsize, $maxpostsize;
- if(strlen($subject) > 80) {
- return 'post_subject_toolang';
- }
- if(!$disablepostctrl) {
- if($maxpostsize && strlen($message) > $maxpostsize) {
- return 'post_message_toolang';
- } elseif($minpostsize && strlen(preg_replace("/\[quote\].+?\[\/quote\]/is", '', $message)) < $minpostsize) {
- return 'post_message_tooshort';
- }
- }
- return FALSE;
- }
- function checkbbcodes($message, $bbcodeoff) {
- return !$bbcodeoff && !preg_match("/\[.+\].*\[\/.+\]/s", $message) ? -1 : $bbcodeoff;
- }
- function checksmilies($message, $smileyoff) {
- $message = stripcslashes($message);
- $smilies = array();
- foreach($GLOBALS['_DCACHE']['smilies'] as $smiley) {
- $smilies[]= preg_quote($smiley['code'], '/');
- }
- return !$smileyoff && !preg_match('/'.implode('|', $smilies).'/', $message) ? -1 : $smileyoff;
- }
- /*
- function updatemember($operator, $uid, $credits) {
- global $db, $table_members, $table_usergroups, $discuz_uid, $adminid, $groupid, $credit, $timestamp;
-
- $addcredit = $addpost = $newcredit = $newpost =0;
-
- if(!$uid ) return;
- if($uid == $discuz_uid) {
- $groupidadd = NULL;
- $newcredit = $credit + intval("$operator$credits");
- if($adminid == 0 && $credits <> 0 && !($newcredit % 10)) {
- $query = $db->query("SELECT groupid FROM $table_usergroups WHERE type='member' AND '$newcredit'>=creditshigher AND '$newcredit'<creditslower");
- $groupidadd = ", groupid='".$db->result($query, 0)."'";
- }
- $db->query("UPDATE $table_members SET postnum=postnum$operator(1), credit=$newcredit, lastpost='$timestamp' $groupidadd WHERE uid='$uid'");
- } else {
- $member = array();
- foreach(explode(',', $uid) as $id) {
- $member[trim($id)]++;
- }
- foreach($member as $uid => $posts) {
- if($credits) {
- $query = $db->query("SELECT m.adminid, u.groupid FROM $table_members m
- LEFT JOIN $table_usergroups u ON (u.creditshigher<>'0' || u.creditslower<>'0') AND m.credit$operator$credits*$posts>=u.creditshigher AND m.credit$operator$credits*$posts<u.creditslower
- WHERE uid='$uid'");
- if($member2 = $db->fetch_array($query)) {
- $groupidadd = $member2['adminid'] == 0 ? ", groupid='$member2[groupid]'" : NULL;
- $db->query("UPDATE $table_members SET postnum=postnum$operator$posts, credit=credit$operator($credits*$posts) $groupidadd WHERE uid='$uid'", 'UNBUFFERED');
- }
- } else {
- $db->query("UPDATE $table_members SET postnum=postnum$operator$posts WHERE uid='$uid'", 'UNBUFFERED');
- }
- }
- }
- }
- */
- function updatemember($operator, $uid, $credits, $usermoneys) {
- global $db, $table_members, $table_usergroups, $discuz_uid, $adminid, $groupid, $credit, $timestamp;
-
- $addcredit = $addpost = $newcredit = $newpost = $newmoney =0;
- $newmoney = intval("$usermoneys");
-
- if(!$uid ) return;
- if($uid == $discuz_uid) {
- $groupidadd = NULL;
- $newcredit = $credit + intval("$operator$credits");
- if($adminid == 0 && $credits <> 0 && !($newcredit % 10)) {
- $query = $db->query("SELECT groupid FROM $table_usergroups WHERE type='member' AND
- '$newcredit'>=creditshigher AND '$newcredit'<creditslower");
- $groupidadd = ", groupid='".$db->result($query, 0)."'";
- }
- $db->query("UPDATE $table_members SET postnum=postnum$operator(1), credit=$newcredit, lastpost='$timestamp' $groupidadd, money=money$operator$newmoney WHERE uid='$uid'");
- } else {
- $member = array();
- foreach(explode(',', $uid) as $id) {
- $member[trim($id)]++;
- }
-
- foreach($member as $uid => $posts) {
- if($credits) {
- $query = $db->query("SELECT m.adminid, u.groupid FROM $table_members m
- LEFT JOIN $table_usergroups u ON (u.creditshigher<>'0' ||
- u.creditslower<>'0') AND m.credit$operator$credits*$posts>=u.creditshigher AND
- m.credit$operator$credits*$posts<u.creditslower
- WHERE uid='$uid'");
- if($member2 = $db->fetch_array($query)) {
- $groupidadd = $member2['adminid'] == 0 ? ", groupid='$member2[groupid]'" : NULL;
- $db->query("UPDATE $table_members SET postnum=postnum$operator$posts, money=money$operator($newmoney*$posts), credit=credit$operator($credits*$posts) $groupidadd WHERE uid='$uid'", 'UNBUFFERED');
- }
- } else {
-
- $db->query("UPDATE $table_members SET postnum=postnum$operator$posts, money=money$operator($newmoney*$posts) WHERE uid='$uid'", 'UNBUFFERED');
- }
- }
- }
- }
- //mark <<
- function updatemember_mark($operator, $uid, $credits, $usermoneys) {
- global $db, $table_members, $table_usergroups, $discuz_uid, $adminid, $groupid, $credit, $timestamp;
-
- $addcredit = $addpost = $newcredit = $newpost = $newmoney =0;
- $newmoney = intval("$usermoneys");
-
- if(!$uid ) return;
- if($uid == $discuz_uid) {
- $groupidadd = NULL;
- $newcredit = $credit + intval("$operator$credits");
- if($adminid == 0 && $credits <> 0 && !($newcredit % 10)) {
- $query = $db->query("SELECT groupid FROM $table_usergroups WHERE type='member' AND
- '$newcredit'>=creditshigher AND '$newcredit'<creditslower");
- $groupidadd = ", groupid='".$db->result($query, 0)."'";
- }
- $db->query("UPDATE $table_members SET postnum=postnum$operator(0), credit=$newcredit, lastpost='$timestamp' $groupidadd, money=money$operator$newmoney WHERE uid='$uid'");
- } else {
- $member = array();
- foreach(explode(',', $uid) as $id) {
- $member[trim($id)]++;
- }
- foreach($member as $uid => $posts) {
- if($credits) {
- $query = $db->query("SELECT m.adminid, u.groupid FROM $table_members m
- LEFT JOIN $table_usergroups u ON (u.creditshigher<>'0' ||
- u.creditslower<>'0') AND m.credit$operator$credits*$posts>=u.creditshigher AND
- m.credit$operator$credits*$posts<u.creditslower
- WHERE uid='$uid'");
- if($member2 = $db->fetch_array($query)) {
- $groupidadd = $member2['adminid'] == 0 ? ", groupid='$member2[groupid]'" : NULL;
- $db->query("UPDATE $table_members SET money=money$operator($newmoney*$posts), credit=credit$operator($credits*$posts) $groupidadd WHERE uid='$uid'", 'UNBUFFERED');
- }
- } else {
- $db->query("UPDATE $table_members SET money=money$operator($newmoney*$posts) WHERE uid='$uid'", 'UNBUFFERED');
- }
- }
- }
- }
- //mark >>
- function updateforumcount($fid) {
- global $db, $table_threads, $table_forums;
- $query = $db->query("SELECT COUNT(*) AS threadcount, SUM(t.replies)+COUNT(*) AS replycount FROM $table_threads t, $table_forums f WHERE f.fid='$fid' AND t.fid=f.fid");
- extract($db->fetch_array($query));
- $query = $db->query("SELECT subject, lastpost, lastposter FROM $table_threads USE INDEX(displayorder) WHERE fid='$fid' ORDER BY lastpost DESC LIMIT 1");
- $thread = $db->fetch_array($query);
- $thread['subject'] = addslashes($thread['subject']);
- $thread['lastposter'] = addslashes($thread['lastposter']);
- $db->query("UPDATE $table_forums SET posts='$replycount', threads='$threadcount', lastpost='$thread[subject]\t$thread[lastpost]\t$thread[lastposter]' WHERE fid='$fid'", 'UNBUFFERED');
- }
- function updatethreadcount($tid) {
- global $db, $table_threads, $table_posts;
- $query = $db->query("SELECT COUNT(*) FROM $table_posts WHERE tid='$tid'");
- $replycount = $db->result($query, 0) - 1;
- if($replycount < 0) {
- $db->query("DELETE FROM $table_threads WHERE tid='$tid'");
- $db->query("DELETE FROM $table_polls WHERE tid='$tid'");
- return;
- }
- $query = $db->query("SELECT author, dateline FROM $table_posts WHERE tid='$tid' ORDER BY dateline DESC LIMIT 1");
- $lastpost = $db->fetch_array($query);
- $lastpost['author'] = addslashes($lastpost['author']);
- $db->query("UPDATE $table_threads SET replies='$replycount', lastposter='$lastpost[author]', lastpost='$lastpost[dateline]' WHERE tid='$tid'", 'UNBUFFERED');
- }
- ?>
复制代码
.\include\editpost.php
- <?
- /*
- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- :: [DISCUZ!] Crossday Discuz! Board ::
- :: (c) 2001-2005 Comsenz Technology Ltd (www.discuz.com) ::
- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- :: Author: Crossday (tech@discuz.com) Cnteacher (cnteacher@discuz.com) ::
- :: Version: 2.5F 2004/10/01 05:15 ::
- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- */
- //fix: BY pk0909
- /*
- 1 編輯附件中,右邊的附件鏈接如果設了防盜鏈,就不能點擊了
- 2 圖標排列問題
- 3 主題圖標更新問題
- 4 附件數量限制問題
- */
- if(!defined('IN_DISCUZ')) {
- exit('Access Denied');
- }
- $discuz_action = 13;
- $query = $db->query("SELECT pid FROM $table_posts WHERE tid='$tid' ORDER BY dateline LIMIT 1");
- $isfirstpost = $db->result($query, 0) == $pid ? 1 : 0;
- $query = $db->query("SELECT m.adminid, p.authorid, p.dateline, p.aid, p.dateline FROM $table_posts p LEFT JOIN $table_members m ON m.uid=p.authorid WHERE pid='$pid' AND tid='$tid' AND fid='$fid'");
- $orig = $db->fetch_array($query);
- $isorigauthor = $discuz_uid && $discuz_uid == $orig['authorid'];
- $alloweditpost = $alloweditpost && !(in_array($orig['adminid'], array(1, 2, 3)) && $adminid > $orig['adminid']) ? 1 : 0;
- if((!$ismoderator || !$alloweditpost) && !$isorigauthor) {
- showmessage('post_edit_nopermission', NULL, 'HALTED');
- }
- if(!submitcheck('editsubmit')) {
- $icons = '';
- if(is_array($_DCACHE['icons']) && $isfirstpost) {
- $key = 1;
- foreach($_DCACHE['icons'] as $id => $icon) {
- $icons .= ' <input type="radio" name="iconid" value="'.$id.'" '.($thread['iconid'] == $id ? 'checked' : '').'><img src="'.SMDIR.'/'.$icon.'">';
- $icons .= !(++$key % 10) ? '<br>' : '';
- }
- }
- $query = $db->query("SELECT * FROM $table_posts WHERE pid='$pid' AND tid='$tid' AND fid='$fid'");
- $postinfo = $db->fetch_array($query);
- if($delayeditpost && ($timestamp -$postinfo['dateline'] >$delayeditpost) && !$ismoderator ) {
- showmessage('post_edit_timeout', NULL, 'HALTED');
- }
- $usesigcheck = $postinfo['usesig'] ? 'checked="checked"' : NULL;
- $urloffcheck = $postinfo['parseurloff'] ? 'checked="checked"' : NULL;
- $smileyoffcheck = $postinfo['smileyoff'] == 1 ? 'checked="checked"' : NULL;
- $codeoffcheck = $postinfo['bbcodeoff'] == 1 ? 'checked="checked"' : NULL;
- if($alloweditpoll && $thread['poll']) {
- $query = $db->query("SELECT pollopts FROM $table_polls WHERE tid='$tid'");
- $polloptions = unserialize($db->result($query, 0));
- for($i = 0; $i < count($polloptions['options']); $i++) {
- $polloptions['options'][$i][0] = htmlspecialchars(stripslashes($polloptions['options'][$i][0]))."\n";
- }
- } else {
- $polloptions = '';
- }
- if($allowpostattach) {
- if($postinfo['aid']) {
- require_once DISCUZ_ROOT.'./include/attachment.php';
- $attachquery = $db->query("select * from $table_attachments where pid = '$postinfo[pid]' ORDER BY aid");
- while($attaches = $db->fetch_array($attachquery)) {
- $extension = strtolower(fileext($attaches['filename']));
- $attaches['attachicon'] = attachtype($extension."\t".$attaches['filetype']);
- $attaches['attachsize'] = sizecount($attaches['filesize']);
- $attaches['dateline'] = $attaches['dateline']?gmdate("$dateformat $timeformat", $attaches['dateline'] + $timeoffset * 3600):gmdate("$dateformat $timeformat", $orig['dateline'] + $timeoffset * 3600);
- $attaches[checkid] = substr(md5($attaches['filesize']),0,5);
- $postinfo[attach_list][] = $attaches;
- }
- }
- }
- $postinfo['subject'] = str_replace('"', """, $postinfo['subject']);
- $postinfo['message'] = dhtmlspecialchars($postinfo['message']);
- $postinfo['message'] = preg_replace("/\n{2}\[\[i\] Last edited by .+? on .+? at .+? \[\/i\]\]$/s", '', $postinfo['message']);
- if($previewpost) {
- $postinfo['message'] = $message;
- }
-
- $multiattach = $allowpostattach && $attach_editpost ? array_fill(1,$attach_editpost,'1'):0;
- include template('post_editpost');
- } else {
- if( $editmethord == 'post' && !$delete ) {
- if($post_invalid = checkpost()) {
- showmessage($post_invalid);
- }
- $viewpermadd = ($allowsetviewperm && $isfirstpost) ? "creditsrequire='$viewperm'" : NULL;
- if($isfirstpost) {
- if($subject == '' || $message == '') {
- showmessage('post_sm_isnull');
- }
- $pollopts = '';
- if($alloweditpoll && $thread['poll'] && trim($polloptions)) {
- $query = $db->query("SELECT pollopts FROM $table_polls WHERE tid='$tid'");
- $pollarray = unserialize($db->result($query, 0));
- $optsdeleted = 0;
- $pollarray['max'] = 0;
- foreach($polloptions as $key => $option) {
- if(trim($option)) {
- $pollarray['options'][$key][0] = $option;
- if($pollarray['options'][$key][1] > $pollarray['max']) {
- $pollarray['max'] = $pollarray['options'][$key][1];
-
- }
- } else {
- $optsdeleted = 1;
- $pollarray['total'] -= $pollarray['options'][$key][1];
- unset($pollarray['options'][$key]);
- }
- }
- if($optsdeleted) {
- $newoptions = array();
- foreach($pollarray['options'] as $option) {
- $newoptions[] = $option;
- }
- $pollarray['options'] = $newoptions;
- unset($newoptions);
- }
- $pollarray['multiple'] = $multiplepoll;
- $pollopts = addslashes(serialize($pollarray));
- }
- $db->query("UPDATE $table_threads SET iconid='$iconid', subject='$subject' WHERE tid='$tid'", 'UNBUFFERED');
- if($pollopts) {
- $db->query("UPDATE $table_polls SET pollopts='$pollopts' WHERE tid='$tid'", 'UNBUFFERED');
- }
- } else {
- if($subject == '' && $message == '') {
- showmessage('post_sm_isnull');
- }
- }
- if($editedby && ($timestamp - $orig['dateline']) > 60 && $adminid != 1){
- $editdate = gmdate($_DCACHE['settings']['dateformat'], $timestamp + $timeoffset * 3600);
- $edittime = gmdate($_DCACHE['settings']['timeformat'], $timestamp + $timeoffset * 3600);
- $message .= "\n\n[[i] Last edited by $discuz_user on $editdate at $edittime [/i]]";
- }
- $bbcodeoff = checkbbcodes($message, $bbcodeoff);
- $smileyoff = checksmilies($message, $smileyoff);
-
- $db->query("UPDATE $table_posts SET message='$message', usesig='$usesig', bbcodeoff='$bbcodeoff', parseurloff='$parseurloff', smileyoff='$smileyoff', subject='$subject' WHERE pid='$pid'");
- if($viewpermadd) {
- $db->query("UPDATE $table_threads SET $viewpermadd WHERE tid='$tid'", 'UNBUFFERED');
- }
- $modaction = 'editpost';
- }elseif ($editmethord == 'attach') {
- $post_attaches =array();
- $post_attaches_count = $delAtt = $del_aids = $uploadCount = 0;
- if ($orig['aid']){
- $attachquery = $db->query("select * from $table_attachments where pid ='$pid'");
- while($att = $db->fetch_array($attachquery)) {
- $saveaid = 1;
- if(is_array($deleteaids) && count($deleteaids)){
- if (in_array($att[aid],$deleteaids)){
- $del_aids .=','.$att[aid]; @unlink(DISCUZ_ROOT.'./'.$attachdir.'/'.$att['attachment']);
- $saveaid = 0;
- $delAtt++;
- }
- }
- if ($saveaid) {
- if ($allowsetattachperm && $att[creditsrequire] != $origattachperm["$att[aid]"]){
- $att[creditsrequire] = $origattachperm["$att[aid]"];
- $db->query("UPDATE $table_attachments set creditsrequire='$att[creditsrequire]' WHERE aid='$att[aid]'", 'UNBUFFERED');
- }
- $post_attaches_count ++;
- }
- }
- if ($del_aids) {
- $db->query("DELETE FROM $table_attachments WHERE pid='$pid' and aid in($del_aids)", 'UNBUFFERED');
- }
- }
- foreach ($attach_name as $tmp) {
- if (trim($tmp)) $uploadCount++;
- }
- if ($attach_max && ($uploadCount + $post_attaches_count) >$attach_max){
- showmessage('attachment_edit_more', "post.php?action=edit&fid=$fid&tid=$tid&pid=$pid&page=$page");
- }
- $post_attaches = attach_upload();
- if($post_attaches && $allowpostattach) {
- foreach( $post_attaches as $v) {
- $db->query("INSERT INTO $table_attachments (tid, pid ,uid, creditsrequire, filename, filetype, filesize, attachment, dateline, downloads)
- VALUES ('$tid','$pid','$discuz_uid', '$v[creditsrequire]', '$v[filename]', '$v[filetype]', '$v[filesize]', '$v[attachment]','$timestamp', '0')");
- $post_attaches_count++;
- }
- unset($post_attaches, $v);
- }
- if ( $delAtt || $uploadCount ){
- updatethread_type($tid , $thread['attachment']);
- if($orig['aid'] <> $post_attaches_count){
- $db->query("UPDATE $table_posts SET aid='$post_attaches_count' WHERE pid='$pid'", 'UNBUFFERED');
- }
- }
- $modaction = 'editattach';
- } elseif( $editmethord == 'post' && $delete ) {
- if(!$allowdelpost && !$isorigauthor) {
- showmessage('post_edit_nopermission', NULL, 'HALTED');
- }
- if(!$isfirstpost) {
- //updatemember('-', $orig['authorid'], $deletedcredits);
- //〔刪帖扣分依主題及回復得分〕
- updatemember('-', $orig['authorid'], $replycredits, $replymoney); //mark
- if ($orig['aid']){
- $query = $db->query("SELECT attachment FROM $table_attachments WHERE pid='$pid'");
- while($post_attachment = $db->fetch_array($query)) {
- @unlink(DISCUZ_ROOT.'./'.$attachdir.'/'.$post_attachment['attachment']);
- }
- $db->query("DELETE FROM $table_attachments WHERE pid='$pid'");
- updatethread_type($tid , $thread['attachment']);
- }
- $db->query("DELETE FROM $table_posts WHERE pid='$pid'", 'UNBUFFERED');
- updateforumcount($fid);
- updatethreadcount($tid);
- $modaction = 'delposts';
- } else {
- if(!$allowdelpost && $isorigauthor && $thread['replies'] >= 1) {
- showmessage('post_edit_nopermission', NULL, 'HALTED');
- }
- $uids = $comma = '';
- $query = $db->query("SELECT authorid FROM $table_posts WHERE tid='$tid'");
- while($post = $db->fetch_array($query)) {
- $uids .= "$comma$post[authorid]";
- $comma = ',';
- }
- //updatemember('-', $uids, $deletedcredits);
- updatemember('-', $uids, $postcredits, $postmoney);//mark
- $db->query("DELETE FROM $table_threads WHERE tid='$tid' OR closed='$tid'", 'UNBUFFERED');
- $db->query("DELETE FROM $table_polls WHERE tid='$tid'", 'UNBUFFERED');
- $query = $db->query("SELECT attachment FROM $table_attachments WHERE tid='$tid'");
- while($thread_attachment = $db->fetch_array($query)) {
- @unlink(DISCUZ_ROOT.'./'.$attachdir.'/'.$thread_attachment['attachment']);
- }
- $db->query("DELETE FROM $table_attachments WHERE tid='$tid'", 'UNBUFFERED');
- $db->query("DELETE FROM $table_posts WHERE tid='$tid'");
- updateforumcount($fid);
- $modaction = 'delete';
- }
- }
- if(!$isorigauthor) {
- @$fp = fopen(DISCUZ_ROOT.'./forumdata/modslog.php', 'a');
- @flock($fp, 2);
- @fwrite($fp, "$timestamp\t$discuz_user\t$groupid\t$onlineip\t$forum[fid]\t$forum[name]\t$thread[tid]\t$thread[subject]\t$modaction\n");
- @fclose($fp);
- }
- if($delete && $isfirstpost) {
- showmessage('post_edit_delete_succeed', "forumdisplay.php?fid=$fid");
- }elseif($editmethord == 'attach') {
- showmessage('attachment_edit_succeed', "post.php?action=edit&fid=$fid&tid=$tid&pid=$pid&page=$page");
- } else {
- showmessage('post_edit_succeed', "viewthread.php?tid=$tid&page=$page#pid$pid");
- }
- }
- ?>
复制代码
[ Last edited by 瘋狂cc on 2005-5-9 at 15:14 ] |