📄 editpost.inc.php
字号:
case 'virtual':$item_transport = 3;break;
case 'logistics':$item_transport = 4;break;
}
$db->query("UPDATE {$tablepre}trades SET account='$seller', subject='$item_name', price='$item_price', amount='$item_number', quality='$item_quality', locus='$item_locus',
transport='$item_transport', ordinaryfee='$postage_mail', expressfee='$postage_express', emsfee='$postage_ems', itemtype='$item_type', expiration='$expiration', closed='$closed' WHERE tid='$tid'", 'UNBUFFERED');
} elseif($thread['special'] == 3 && ($allowpostreward || $thread['authorid'] == $discuz_uid)) {
if($thread['price'] > 0 && $thread['price'] != $rewardprice) {
$rewardprice = intval($rewardprice);
if($rewardprice <= 0){
showmessage("reward_credits_invalid");
}
$addprice = ceil(($rewardprice - $thread['price']) + ($rewardprice - $thread['price']) * $creditstax);
if(!$forum['ismoderator']) {
if($rewardprice < $thread['price']) {
showmessage("reward_credits_fall");
} elseif($rewardprice < $minrewardprice || ($maxrewardprice > 0 && $rewardprice > $maxrewardprice)) {
showmessage("reward_credits_between");
} elseif($addprice > $_DSESSION["extcredits$creditstrans"]) {
showmessage('reward_credits_shortage');
}
}
$realprice = ceil($thread['price'] + $thread['price'] * $creditstax) + $addprice;
$db->query("UPDATE {$tablepre}members SET extcredits$creditstrans=extcredits$creditstrans-$addprice WHERE uid='$thread[authorid]'");
$db->query("UPDATE {$tablepre}rewardlog SET netamount='$realprice' WHERE tid='$tid' AND authorid='$thread[authorid]'");
}
if(!$forum['ismoderator'] && $thread['authorid'] == $discuz_uid) {
if($thread['replies'] > 1) {
$subject = $thread['subject'];
}
if($thread['price'] < 0) {
$rewardprice = abs($thread['price']);
}
}
$price = $thread['price'] > 0 ? $rewardprice : -$rewardprice;
} elseif($thread['special'] == 4 && ($allowpostactivity || $thread['authorid'] == $discuz_uid)) {
if(empty($starttimefrom[$activitytime])) {
showmessage('activity_fromtime_please');
} elseif(strtotime($starttimefrom[$activitytime]) === -1 || strtotime($starttimefrom[$activitytime]) === FALSE) {
showmessage('activity_fromtime_error');
} elseif(strtotime($starttimefrom[$activitytime]) < $timestamp) {
showmessage('activity_smaller_current');
} elseif($activitytime && ((strtotime($starttimefrom) > strtotime($starttimeto) || !$starttimeto))) {
showmessage('activity_fromtime_error');
} elseif(!trim($activityclass)) {
showmessage('activity_sort_please');
} elseif(!trim($activityplace)) {
showmessage('activity_address_please');
} elseif(trim($activityexpiration) && (strtotime($activityexpiration) === -1 || strtotime($activityexpiration) === FALSE)) {
showmessage('activity_totime_error');
}
$activity = array();
$activity['class'] = dhtmlspecialchars(trim($activityclass));
$activity['starttimefrom'] = strtotime($starttimefrom[$activitytime]);
$activity['starttimeto'] = $activitytime ? strtotime($starttimeto) : 0;
$activity['place'] = dhtmlspecialchars(trim($activityplace));
$activity['cost'] = intval($cost);
$activity['gender'] = intval($gender);
$activity['number'] = intval($activitynumber);
if($activityexpiration) {
$activity['expiration'] = strtotime($activityexpiration);
} else {
$activity['expiration'] = 0;
}
$db->query("UPDATE {$tablepre}activities SET cost='$activity[cost]', starttimefrom='$activity[starttimefrom]', starttimeto='$activity[starttimeto]', place='$activity[place]', class='$activity[class]', gender='$activity[gender]', number='$activity[number]', expiration='$activity[expiration]' WHERE tid='$tid'", 'UNBUFFERED');
}
$sgidadd = '';
if($iscircle && $sgid) {
$sgidadd = ', sgid=0';
require_once DISCUZ_ROOT.'./include/supesite.func.php';
if(supe_circlepermission($sgid)) {
$sgidadd = ", sgid='$sgid'";
}
}
$db->query("UPDATE {$tablepre}threads SET iconid='$iconid', typeid='$typeid', subject='$subject', readperm='$readperm', price='$price' $authoradd $polladd $sgidadd ".($auditstatuson && $audit == 1 ? ",displayorder='0', moderated='1'" : '')." WHERE tid='$tid'", 'UNBUFFERED');
} else {
if($subject == '' && $message == '') {
showmessage('post_sm_isnull');
}
}
if($editedby && ($timestamp - $orig['dateline']) > 60 && $adminid != 1) {
include_once language('misc');
$editor = $isanonymous && $isorigauthor ? $language['anonymous'] : $discuz_user;
$edittime = gmdate($_DCACHE['settings']['dateformat'].' '.$_DCACHE['settings']['timeformat'], $timestamp + $timeoffset * 3600);
eval("\$message .= \"$language[post_edit]\";");
}
$bbcodeoff = checkbbcodes($message, !empty($bbcodeoff));
$smileyoff = checksmilies($message, !empty($smileyoff));
$htmlon = $orig['allowhtml'] && !empty($htmlon) ? 1 : 0;
$tattachment = 0;
$pattachment = ($allowpostattach && $attachments = attach_upload()) ? 1 : 0;
$uattachment = ($allowpostattach && $uattachments = attach_upload('attachupdate')) ? 1 : 0;
$query = $db->query("SELECT aid, readperm, price, attachment, description, thumb, remote FROM {$tablepre}attachments WHERE pid='$pid'");
while($attach = $db->fetch_array($query)) {
$attachpermadd = $allowsetattachperm && $attach['readperm'] != $attachpermnew[$attach['aid']] ? ", readperm='{$attachpermnew[$attach['aid']]}'" : '' ;
$attachpricenew[$attach['aid']] = intval($attachpricenew[$attach['aid']]);
$attachpriceadd = $maxprice && $attach['price'] != $attachpricenew[$attach['aid']] && $attachpricenew[$attach['aid']] <= $maxprice ? ", price='{$attachpricenew[$attach['aid']]}'" : '' ;
$attachdescnew[$attach['aid']] = cutstr(dhtmlspecialchars($attachdescnew[$attach['aid']]), 100);
$attachdescadd = $attach['description'] != $attachdescnew[$attach['aid']] ? 1 : 0;
if($uattachment || $attachpermadd || $attachdescadd || $attachpriceadd) {
$paid = 'paid'.$attach['aid'];
$attachfileadd = '';
if($uattachment && isset($uattachments[$paid])) {
dunlink($attach['attachment'], $attach['thumb'], $attach['remote']);
$attachfileadd = ', dateline=\''.$timestamp.'\',
filename=\''.$uattachments[$paid]['name'].'\',
filetype=\''.$uattachments[$paid]['type'].'\',
filesize=\''.$uattachments[$paid]['size'].'\',
attachment=\''.$uattachments[$paid]['attachment'].'\',
thumb=\''.$uattachments[$paid]['thumb'].'\',
isimage=\''.$uattachments[$paid]['isimage'].'\',
remote=\''.$uattachments[$paid]['remote'].'\'';
unset($uattachments[$paid]);
}
$db->query("UPDATE {$tablepre}attachments SET description='{$attachdescnew[$attach['aid']]}' $attachpermadd $attachpriceadd $attachfileadd WHERE aid='$attach[aid]'");
}
}
if(!empty($uattachments)) {
foreach($uattachments as $attach) {
dunlink($attach['attachment'], $attach['thumb'], $attach['remote']);
}
}
if(!empty($deleteaid) || $pattachment) {
if(!empty($deleteaid) && is_array($deleteaid)) {
$deleteaids = '\''.implode("','", $deleteaid).'\'';
$query = $db->query("SELECT aid, attachment, thumb, remote FROM {$tablepre}attachments WHERE aid IN ($deleteaids) AND pid='$pid'");
while($attach = $db->fetch_array($query)) {
dunlink($attach['attachment'], $attach['thumb'], $attach['remote']);
}
$db->query("DELETE FROM {$tablepre}attachments WHERE aid IN ($deleteaids)");
updatecredits($orig['authorid'], $postattachcredits, -($db->affected_rows()));
}
if($pattachment) {
$searcharray = $pregarray = $replacearray = array();
foreach($attachments as $key => $attach) {
$db->query("INSERT INTO {$tablepre}attachments (tid, pid, dateline, readperm, price, filename, description, filetype, filesize, attachment, downloads, isimage, uid, thumb, remote)
VALUES ('$tid', '$pid', '$timestamp', '$attach[perm]', '$attach[price]', '$attach[name]', '$attach[description]', '$attach[type]', '$attach[size]', '$attach[attachment]', '0', '$attach[isimage]', '$attach[uid]', '$attach[thumb]', '$attach[remote]')");
$searcharray[] = '[local]'.$localid[$key].'[/local]';
$pregarray[] = '/\[localimg=(\d{1,3}),(\d{1,3})\]'.$localid[$key].'\[\/localimg\]/is';
$replacearray[] = '[attach]'.$db->insert_id().'[/attach]';
}
$message = str_replace($searcharray, $replacearray, preg_replace($pregarray, $replacearray, $message));
updatecredits($orig['authorid'], $postattachcredits, count($attachments));
} else {
$query = $db->query("SELECT aid FROM {$tablepre}attachments WHERE pid='$pid' LIMIT 1");
$pattachment = $db->result($query, 0) ? 1 : 0;
}
if($pattachment) {
$tattachment = 1;
} else {
$query = $db->query("SELECT a.aid FROM {$tablepre}posts p, {$tablepre}attachments a WHERE a.tid='$tid' AND a.pid=p.pid AND p.invisible='0' LIMIT 1");
$tattachment = $db->result($query, 0) ? 1 : 0;
}
$db->query("UPDATE {$tablepre}threads SET attachment='$tattachment' WHERE tid='$tid'");
}
if($auditstatuson && $audit == 1) {
updatepostcredits('+', $orig['authorid'], ($isfirstpost ? $postcredits : $replycredits));
updatemodworks('MOD', 1);
updatemodlog($tid, 'MOD');
}
$message = preg_replace('/\[attachimg\](\d+)\[\/attachimg\]/is', '[attach]\1[/attach]', $message);
$db->query("UPDATE {$tablepre}posts SET message='$message', usesig='$usesig', htmlon='$htmlon', bbcodeoff='$bbcodeoff', parseurloff='$parseurloff',
smileyoff='$smileyoff', subject='$subject' ".($pattachment ? ", attachment='1'" : '')." $anonymousadd ".($auditstatuson && $audit == 1 ? ",invisible='0'" : '')." WHERE pid='$pid'");
$forum['lastpost'] = explode("\t", $forum['lastpost']);
if($orig['dateline'] == $forum['lastpost'][2] && ($orig['author'] == $forum['lastpost'][3] || ($forum['lastpost'][3] == '' && $orig['anonymous']))) {
$lastpost = "$tid\t".($isfirstpost ? $subject : addslashes($thread['subject']))."\t$orig[dateline]\t".($isanonymous ? '' : addslashes($orig['author']));
$db->query("UPDATE {$tablepre}forums SET lastpost='$lastpost' WHERE fid='$fid'", 'UNBUFFERED');
}
if($thread['lastpost'] == $orig['dateline'] && ((!$orig['anonymous'] && $thread['lastposter'] == $orig['author']) || ($orig['anonymous'] && $thread['lastposter'] == '')) && $orig['anonymous'] != $isanonymous) {
$db->query("UPDATE {$tablepre}threads SET lastposter='".($isanonymous ? '' : addslashes($orig['author']))."' WHERE tid='$tid'", 'UNBUFFERED');
}
if(!$isorigauthor) {
updatemodworks('EDT', 1);
require_once DISCUZ_ROOT.'./include/misc.func.php';
modlog($thread, 'EDT');
}
} else {
if(($isfirstpost && $thread['replies'] > 0) || !$isorigauthor) {
showmessage(($thread['special'] == 3 ? 'post_edit_reward_already_reply' : 'post_edit_nopermission'), NULL, 'HALTED');
}
if($thread['special'] == 3) {
if($thread['price'] < 0 && ($thread['dateline'] + 1 == $orig['dateline'])) {
showmessage('post_edit_reward_nopermission', NULL, 'HALTED');
}
}
updatepostcredits('-', $orig['authorid'], ($isfirstpost ? $postcredits : $replycredits));
if($thread['special'] == 3 && $isfirstpost) {
$db->query("UPDATE {$tablepre}members SET extcredits$creditstrans=extcredits$creditstrans+$thread[price] WHERE uid='$orig[authorid]'", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}rewardlog WHERE tid='$tid'", 'UNBUFFERED');
}
$thread_attachment = $post_attachment = 0;
$query = $db->query("SELECT pid, attachment, thumb, remote FROM {$tablepre}attachments WHERE tid='$tid'");
while($attach = $db->fetch_array($query)) {
if($attach['pid'] == $pid) {
$post_attachment = 1;
dunlink($attach['attachment'], $attach['thumb'], $attach['remote']);
updatecredits($orig['authorid'], $postattachcredits, -($db->affected_rows()));
} else {
$thread_attachment = 1;
}
}
if($post_attachment) {
$db->query("DELETE FROM {$tablepre}attachments WHERE pid='$pid'", 'UNBUFFEREED');
}
$db->query("DELETE FROM {$tablepre}posts WHERE pid='$pid'");
if($isfirstpost) {
$forumadd = 'threads=threads-1, posts=posts-1';
$db->query("DELETE FROM {$tablepre}threadsmod WHERE tid='$tid'", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}relatedthreads WHERE tid='$tid'", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}threads WHERE tid='$tid'", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}polloptions WHERE tid='$tid'");
$db->query("DELETE FROM {$tablepre}polls WHERE tid='$tid'", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}mythreads WHERE tid='$tid'", 'UNBUFFERED');
if($globalstick && in_array($thread['displayorder'], array(2, 3))) {
require_once DISCUZ_ROOT.'./include/cache.func.php';
updatecache('globalstick');
}
} else {
$forumadd = 'posts=posts-1';
$query = $db->query("SELECT author, dateline FROM {$tablepre}posts WHERE tid='$tid' AND invisible='0' ORDER BY dateline DESC LIMIT 1");
$lastpost = $db->fetch_array($query);
$lastpost['author'] = addslashes($lastpost['author']);
$db->query("UPDATE {$tablepre}threads SET replies=replies-1, attachment='$thread_attachment', lastposter='$lastpost[author]', lastpost='$lastpost[dateline]' WHERE tid='$tid'", 'UNBUFFERED');
}
$forum['lastpost'] = explode("\t", $forum['lastpost']);
if($orig['dateline'] == $forum['lastpost'][2] && ($orig['author'] == $forum['lastpost'][3] || ($forum['lastpost'][3] == '' && $orig['anonymous']))) {
$query = $db->query("SELECT tid, subject, lastpost, lastposter FROM {$tablepre}threads
WHERE fid='$fid' AND displayorder>='0' ORDER BY lastpost DESC LIMIT 1");
$lastthread = daddslashes($db->fetch_array($query), 1);
$forumadd .= ", lastpost='$lastthread[tid]\t$lastthread[subject]\t$lastthread[lastpost]\t$lastthread[lastposter]'";
}
$db->query("UPDATE {$tablepre}forums SET $forumadd WHERE fid='$fid'", 'UNBUFFERED');
}
// debug: update thread caches ?
if($forum['threadcaches']) {
if($isfirstpost || $page == 1 || $thread['replies'] < $_DCACHE['pospperpage'] || !empty($delete)) {
$forum['threadcaches'] && deletethreadcaches($tid);
} else {
$query = $db->query("SELECT COUNT(*) FROM {$tablepre}posts WHERE tid='$tid' AND pid<'$pid'");
if($db->result($query, 0) < $_DCACHE['settings']['postperpage']) {
$forum['threadcaches'] && deletethreadcaches($tid);
}
}
}
if($auditstatuson) {
if($audit == 1) {
showmessage('auditstatuson_succeed', "viewthread.php?tid=$tid&page=$page&extra=$extra#pid$pid");
} else {
showmessage('audit_edit_succeed');
}
} else {
if(!empty($delete) && $isfirstpost) {
showmessage('post_edit_delete_succeed', "forumdisplay.php?fid=$fid");
} else {
showmessage('post_edit_succeed', "viewthread.php?tid=$tid&page=$page&extra=$extra#pid$pid");
}
}
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -