📄 editpost.inc.php
字号:
<?php
/*
[Discuz!] (C)2001-2007 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$RCSfile: editpost.inc.php,v $
$Revision: 1.131.2.17 $
$Date: 2007/03/22 20:38:01 $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$discuz_action = 13;
$query = $db->query("SELECT m.adminid, p.first, p.authorid, p.author, p.dateline, u.allowhtml, p.anonymous, p.invisible FROM {$tablepre}posts p
LEFT JOIN {$tablepre}members m ON m.uid=p.authorid
LEFT JOIN {$tablepre}usergroups u USING(groupid)
WHERE pid='$pid' AND tid='$tid' AND fid='$fid'");
$orig = $db->fetch_array($query);
if($magicstatus) {
$query = $db->query("SELECT magicid FROM {$tablepre}threadsmod WHERE tid='$tid' AND magicid='10'");
$magicid = $db->result($query, 0);
$allowanonymous = $allowanonymous || $magicid ? 1 : $allowanonymous;
}
$isfirstpost = $orig['first'] ? 1 : 0;
$isorigauthor = $discuz_uid && $discuz_uid == $orig['authorid'];
$isanonymous = $isanonymous && $allowanonymous ? 1 : 0;
$audit = $orig['invisible'] == -2 || $thread['displayorder'] == -2 ? $audit : 0;
if((!$forum['ismoderator'] || !$alloweditpost || (in_array($orig['adminid'], array(1, 2, 3)) && $adminid > $orig['adminid'])) && !($forum['alloweditpost'] && $isorigauthor)) {
showmessage('post_edit_nopermission', NULL, 'HALTED');
} elseif($isorigauthor && !$forum['ismoderator']) {
if($edittimelimit && $timestamp - $orig['dateline'] > $edittimelimit * 60) {
showmessage('post_edit_timelimit', NULL, 'HALTED');
} elseif(($isfirstpost && $modnewthreads) || (!$isfirstpost && $modnewreplies)) {
showmessage('post_edit_moderate');
}
}
$thread['pricedisplay'] = $thread['price'] == -1 ? 0 : $thread['price'];
if(!submitcheck('editsubmit')) {
include_once language('misc');
$typeselect = typeselect($thread['typeid']);
if($iscircle) {
$mycircles = array();
if($discuz_uid) {
supe_dbconnect();
$query = $supe['db']->query("SELECT gid, groupname FROM {$supe[tablepre]}groupuid WHERE uid='$discuz_uid' AND flag=1");
while($mycircle = $supe['db']->fetch_array($query)) {
$mycircles[$mycircle['gid']] = $mycircle['groupname'];
}
}
if($sgid = $thread['sgid']) {
supe_dbconnect();
$query = $supe['db']->query("SELECT g.groupname, gf.headerimage, gf.css FROM {$supe[tablepre]}groups g, {$supe[tablepre]}groupfields gf WHERE g.gid='$sgid' AND g.flag=1 AND g.gid=gf.gid");
$circle = $supe['db']->fetch_array($query);
}
}
$icons = '';
if(is_array($_DCACHE['icons']) && $isfirstpost) {
$key = 1;
foreach($_DCACHE['icons'] as $id => $icon) {
$icons .= ' <input class="radio" type="radio" name="iconid" value="'.$id.'" '.($thread['iconid'] == $id ? 'checked' : '').'><img src="'.SMDIR.'/'.$icon.'" alt="" />';
$icons .= !(++$key % 10) ? '<br>' : '';
}
}
$query = $db->query("SELECT * FROM {$tablepre}posts WHERE pid='$pid' AND tid='$tid' AND fid='$fid'");
$postinfo = $db->fetch_array($query);
$usesigcheck = $postinfo['usesig'] ? 'checked' : '';
$urloffcheck = $postinfo['parseurloff'] ? 'checked' : '';
$smileyoffcheck = $postinfo['smileyoff'] == 1 ? 'checked' : '';
$codeoffcheck = $postinfo['bbcodeoff'] == 1 ? 'checked' : '';
$htmloncheck = $postinfo['htmlon'] ? 'checked' : '';
$poll = $temppoll = '';
if($isfirstpost) {
$thread['freecharge'] = $maxchargespan && $timestamp - $thread['dateline'] >= $maxchargespan * 3600 ? 1 : 0;
if($thread['special'] == 1 && ($alloweditpoll || $thread['authorid'] == $discuz_uid)) {
$query = $db->query("SELECT polloptionid, displayorder, polloption, multiple, visible, maxchoices, expiration FROM {$tablepre}polloptions AS polloptions LEFT JOIN {$tablepre}polls AS polls ON polloptions.tid=polls.tid WHERE polls.tid ='$tid' ORDER BY displayorder");
while($temppoll = $db->fetch_array($query)) {
$poll['multiple'] = $temppoll['multiple'];
$poll['visible'] = $temppoll['visible'];
$poll['maxchoices'] = $temppoll['maxchoices'];
$poll['expiration'] = $temppoll['expiration'];
$poll['polloptionid'][] = $temppoll['polloptionid'];
$poll['displayorder'][] = $temppoll['displayorder'];
$poll['polloption'][] = stripslashes($temppoll['polloption']);
}
} elseif($thread['special'] == 2 && ($allowposttrade || $thread['authorid'] == $discuz_uid)) {
$query = $db->query("SELECT * FROM {$tablepre}trades WHERE tid='$tid'");
$trade = $db->fetch_array($query);
$trade['expiration'] = $trade['expiration'] ? date('Y-m-d', $trade['expiration']) : '';
$expiration_7 = date('Y-m-d', $timestamp + 86400 * 7);
$expiration_14 = date('Y-m-d', $timestamp + 86400 * 14);
$expiration_month = date('Y-m-d', mktime(0, 0, 0, date('m')+1, date('d'), date('Y')));
} elseif($thread['special'] == 3) {
$rewardprice = abs($thread['price']);
} elseif($thread['special'] == 4 && ($allowpostactivity || $thread['authorid'] == $discuz_uid)) {
$query = $db->query("SELECT * FROM {$tablepre}activities WHERE tid='$tid'");
$activity = $db->fetch_array($query);
$activity['starttimefrom'] = gmdate("Y-m-d H:i", $activity['starttimefrom'] + $timeoffset * 3600);
$activity['starttimeto'] = $activity['starttimeto'] ? gmdate("Y-m-d H:i", $activity['starttimeto'] + $timeoffset * 3600) : '';
$activity['expiration'] = $activity['expiration'] ? gmdate("Y-m-d H:i", $activity['expiration'] + $timeoffset * 3600) : '';
}
}
if($postinfo['attachment']) {
require_once DISCUZ_ROOT.'./include/attachment.func.php';
$attachfind = $attachreplace = $attachments = array();
$query = $db->query("SELECT * FROM {$tablepre}attachments WHERE pid='$postinfo[pid]'");
while($attach = $db->fetch_array($query)) {
$attach['dateline'] = gmdate("$dateformat $timeformat", $attach['dateline'] + $timeoffset * 3600);
$attach['filesize'] = sizecount($attach[filesize]);
$attach['filetype'] = attachtype(fileext($attach['attachment'])."\t".$attach['filetype']);
if($attach['isimage']) {
$attach['url'] = $attach['remote'] ? $ftp['attachurl'] : $attachurl;
list($attach['width']) = @getimagesize($attach['url'].'/'.$attach['attachment']);
$attach['width'] = !$attach['width'] || $attach['width'] > $thumbwidth ? $thumbwidth : $attach['width'];
$attachfind[] = "/\[attach\]$attach[aid]\[\/attach\]/i";
$attachreplace[] = '[attachimg]'.$attach['aid'].'[/attachimg]';
}
$attachments[] = $attach;
}
}
$postinfo['subject'] = str_replace('"', '"', $postinfo['subject']);
$postinfo['message'] = dhtmlspecialchars($postinfo['message']);
$postinfo['message'] = preg_replace($language['post_edit_regexp'], '', $postinfo['message']);
if($postinfo['attachment'] && $attachfind) {
$postinfo['message'] = preg_replace($attachfind, $attachreplace, $postinfo['message']);
}
include template($iscircle && $sgid ? 'supesite_post_editpost' : 'post_editpost');
} else {
if(empty($delete)) {
if($post_invalid = checkpost()) {
showmessage($post_invalid);
}
if($allowpostattach && is_array($_FILES['attach'])) {
foreach($_FILES['attach']['name'] as $attachname) {
if($attachname != '') {
checklowerlimit($creditspolicy['postattach']);
break;
}
}
}
if(!$isorigauthor && !$allowanonymous) {
if($orig['anonymous'] && !$isanonymous) {
$isanonymous = 0;
$authoradd = ', author=\''.addslashes($orig['author']).'\'';
$anonymousadd = ', anonymous=\'0\'';
} else {
$isanonymous = $orig['anonymous'];
$authoradd = $anonymousadd = '';
}
} else {
$authoradd = ', author=\''.($isanonymous ? '' : addslashes($orig['author'])).'\'';
$anonymousadd = ", anonymous='$isanonymous'";
}
if($isfirstpost) {
if($subject == '' || $message == '') {
showmessage('post_sm_isnull');
}
$typeid = isset($forum['threadtypes']['types'][$typeid]) ? $typeid : 0;
$iconid = isset($_DCACHE['icons'][$iconid]) ? $iconid : 0;
if(!$typeid && $forum['threadtypes']['required']) {
showmessage('post_type_isnull');
}
$readperm = $allowsetreadperm ? $readperm : ($isorigauthor ? 0 : 'readperm');
$price = intval($price);
$price = $thread['price'] < 0 && !$thread['special'] ?
($isorigauthor || !$price ? -1 : $price) :
($maxprice ? ($price <= $maxprice ? ($price > 0 ? $price : 0) : $maxprice) : ($isorigauthor ? 0 : $thread['price']));
if($price > 0 && floor($price * (1 - $creditstax)) == 0) {
showmessage('post_net_price_iszero');
}
$polladd = '';
if(($alloweditpoll || $thread['authorid'] == $discuz_uid) && $thread['special'] == 1 && !empty($polls)) {
$pollarray = '';
$pollarray['options'] = $polloption;
if($pollarray['options']) {
if(count($pollarray['options']) > $maxpolloptions) {
showmessage('post_poll_option_toomany');
}
foreach($pollarray['options'] as $key => $value) {
if(!trim($value)) {
$db->query("DELETE FROM {$tablepre}polloptions WHERE polloptionid='$key' AND tid='$tid'");
unset($pollarray['options'][$key]);
}
}
$polladd = ', special=\'1\'';
foreach($displayorder as $key => $value) {
if(preg_match("/^-?\d*$/", $value)) {
$pollarray['displayorder'][$key] = $value;
}
}
$pollarray['multiple'] = !empty($multiplepoll);
$pollarray['visible'] = empty($visibilitypoll);
$pollarray['expiration'] = $expiration;
foreach($polloptionid as $key => $value) {
if(!preg_match("/^\d*$/", $value)) {
showmessage('submit_invalid');
}
}
$maxchoices = $maxchoices >= count($pollarray['options']) ? count($pollarray['options']) : $maxchoices;
if(preg_match("/^\d*$/", $maxchoices)) {
if(!$pollarray['multiple']) {
$pollarray['maxchoices'] = 1;
} elseif(empty($maxchoices)) {
$pollarray['maxchoices'] = 0;
} else {
$pollarray['maxchoices'] = $maxchoices;
}
}
if($close) {
$pollarray['expiration'] = $timestamp;
} elseif(preg_match("/^\d*$/", $pollarray['expiration'])) {
if(empty($pollarray['expiration'])) {
$pollarray['expiration'] = 0;
} else {
$pollarray['expiration'] = $timestamp + 86400 * $expiration;
}
}
$optid = '';
$query = $db->query("SELECT polloptionid FROM {$tablepre}polloptions WHERE tid='$tid'");
while($tempoptid = $db->fetch_array($query)) {
$optid[] = $tempoptid['polloptionid'];
}
foreach($pollarray['options'] as $key => $value) {
$value = dhtmlspecialchars(trim($value));
if(in_array($polloptionid[$key], $optid)) {
if($alloweditpoll) {
$db->query("UPDATE {$tablepre}polloptions SET displayorder='".$pollarray['displayorder'][$key]."', polloption='$value' WHERE polloptionid='$polloptionid[$key]' AND tid='$tid'");
} else {
$db->query("UPDATE {$tablepre}polloptions SET displayorder='".$pollarray['displayorder'][$key]."' WHERE polloptionid='$polloptionid[$key]' AND tid='$tid'");
}
} else {
$db->query("INSERT INTO {$tablepre}polloptions (tid, displayorder, polloption) VALUES ('$tid', '".$pollarray['displayorder'][$key]."', '$value')");
}
}
$db->query("UPDATE {$tablepre}polls SET multiple='$pollarray[multiple]', visible='$pollarray[visible]', maxchoices='$pollarray[maxchoices]', expiration='$pollarray[expiration]' WHERE tid='$tid'", 'UNBUFFERED');
} else {
$polladd = ', special=\'0\'';
$db->query("DELETE FROM {$tablepre}polls WHERE tid='$tid'");
$db->query("DELETE FROM {$tablepre}polloptions WHERE tid='$tid'");
}
} elseif($thread['special'] == 2 && ($allowposttrade || $thread['authorid'] == $discuz_uid)) {
$seller = dhtmlspecialchars(trim($seller));
$item_name = dhtmlspecialchars(trim($item_name));
$item_price = floatval($item_price);
$item_locus = dhtmlspecialchars(trim($item_locus));
$item_number = intval($item_number);
$item_quality = intval($item_quality);
$item_transport = intval($item_transport);
$postage_mail = intval($postage_mail);
$postage_express = intval(trim($postage_express));
$postage_ems = intval($postage_ems);
$item_type = intval($item_type);
if(!$seller) {
showmessage('trade_alipay_please');
} elseif(!$item_name) {
showmessage('trade_please_name');
} elseif($maxtradeprice && ($mintradeprice > $item_price || $maxtradeprice < $item_price)) {
showmessage('trade_price_between');
} elseif(!$maxtradeprice && $mintradeprice > $item_price) {
showmessage('trade_price_more_than');
} elseif(!trim($item_locus)) {
showmessage('trade_please_locus');
} elseif($item_number < 0) {
showmessage('tread_please_number');
}
$expiration = $item_expiration ? strtotime($item_expiration) : 0;
$closed = $expiration > 0 && strtotime($item_expiration) < $timestamp ? 1 : $closed;
switch($transport) {
case 'seller':$item_transport = 1;break;
case 'buyer':$item_transport = 2;break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -