📄 forums.inc.php
字号:
}
$fupadd = '';
if($fupnew != $forum['fup']) {
$query = $db->query("SELECT fid FROM {$tablepre}forums WHERE fup='$fid'");
if($db->num_rows($query)) {
cpmsg('forums_edit_sub_notnull', '', 'error');
}
$fup = $db->fetch_first("SELECT fid, type, inheritedmod FROM {$tablepre}forums WHERE fid='$fupnew'");
$fupadd = ", type='".($fup['type'] == 'forum' ? 'sub' : 'forum')."', fup='$fup[fid]'";
$db->query("DELETE FROM {$tablepre}moderators WHERE fid='$fid' AND inherited='1'");
$query = $db->query("SELECT * FROM {$tablepre}moderators WHERE fid='$fupnew' ".($fup['inheritedmod'] ? '' : "AND inherited='1'"));
while($mod = $db->fetch_array($query)) {
$db->query("REPLACE INTO {$tablepre}moderators (uid, fid, displayorder, inherited)
VALUES ('$mod[uid]', '$fid', '0', '1')");
}
$moderators = $tab = '';
$query = $db->query("SELECT m.username FROM {$tablepre}members m, {$tablepre}moderators mo WHERE mo.fid='$fid' AND mo.inherited='0' AND m.uid=mo.uid ORDER BY mo.displayorder");
while($mod = $db->fetch_array($query)) {
$moderators .= $tab.addslashes($mod['username']);
$tab = "\t";
}
$db->query("UPDATE {$tablepre}forumfields SET moderators='$moderators' WHERE fid='$fid'");
}
$allowpostspecialtrade = intval($allowpostspecialnew[2]);
$allowpostspecialnew = bindec(intval($allowpostspecialnew[6]).intval($allowpostspecialnew[5]).intval($allowpostspecialnew[4]).intval($allowpostspecialnew[3]).intval($allowpostspecialnew[2]).intval($allowpostspecialnew[1]));
$allowspecialonlynew = $allowpostspecialnew ? $allowspecialonlynew : 0;
$forumcolumnsnew = $forumcolumnsnew > 1 ? intval($forumcolumnsnew) : 0;
$threadcachesnew = max(0, min(100, intval($threadcachesnew)));
$subforumsindexnew = $subforumsindexnew == -1 ? 0 : ($subforumsindexnew == 0 ? 2 : 1);
$simplenew = bindec(sprintf('%02d', decbin($defaultorderfieldnew)).$defaultordernew.sprintf('%02d', decbin($subforumsindexnew)).'00'.$simplenew);
$allowglobalsticknew = $allowglobalsticknew ? 1 : 0;
$db->query("UPDATE {$tablepre}forums SET status='$statusnew', name='$namenew', styleid='$styleidnew', alloweditpost='$alloweditpostnew',
allowpostspecial='$allowpostspecialnew', allowspecialonly='$allowspecialonlynew', allowhtml='$allowhtmlnew', allowbbcode='$allowbbcodenew', allowimgcode='$allowimgcodenew', allowmediacode='$allowmediacodenew',
allowsmilies='$allowsmiliesnew', alloweditrules='$alloweditrulesnew', allowfeed='$allowfeednew', modnewposts='$modnewpostsnew',
recyclebin='$recyclebinnew', jammer='$jammernew', allowanonymous='$allowanonymousnew', forumcolumns='$forumcolumnsnew', threadcaches='$threadcachesnew',
simple='$simplenew', allowglobalstick='$allowglobalsticknew', disablewatermark='$disablewatermarknew', allowtag='$allowtagnew', autoclose='".intval($autoclosenew * $autoclosetimenew)."' $fupadd
WHERE fid='$fid'");
$query = $db->query("SELECT fid FROM {$tablepre}forumfields WHERE fid='$fid'");
if(!($db->num_rows($query))) {
$db->query("INSERT INTO {$tablepre}forumfields (fid)
VALUES ('$fid')");
}
foreach(array('post', 'reply', 'digest', 'postattach', 'getattach') as $item) {
if(${$item.'creditsnew'}) {
foreach(${$item.'creditsnew'} as $i => $v) {
if($v == '') {
unset(${$item.'creditsnew'}[$i]);
} else {
$v = intval($v);
${$item.'creditsnew'}[$i] = $v < -99 ? -99 : $v;
${$item.'creditsnew'}[$i] = $v > 99 ? 99 : $v;
}
}
}
${$item.'creditsnew'} = ${$item.'creditsnew'} ? addslashes(serialize(${$item.'creditsnew'})) : '';
}
$threadtypesnew['types'] = $threadtypesnew['flat'] = $threadtypes['selectbox'] = $threadtypes['special'] = $threadtypes['show'] = array();
$threadsortsnew['types'] = $threadsortsnew['flat'] = $threadsorts['selectbox'] = $threadsorts['special'] = $threadsorts['show'] = array();
if($allowthreadtypes) {
if(is_array($newname) && $newname) {
$newname = array_unique($newname);
if($newname) {
foreach($newname as $key => $val) {
$val = trim($val);
if($newenable[$key] && $val) {
$newtypeid = $db->result_first("SELECT typeid FROM {$tablepre}threadtypes WHERE name='$val'");
if(!$newtypeid) {
$db->query("INSERT INTO {$tablepre}threadtypes (name, description) VALUES
('$val', '".dhtmlspecialchars(trim($newdescription[$key]))."')");
$newtypeid = $db->insert_id();
}
if($newoptions[$key] == 1) {
$threadtypesnew['types'][$newtypeid] = $threadtypesnew['flat'][$newtypeid] = $val;
} elseif($newoptions[$key] == 2) {
$threadtypesnew['types'][$newtypeid] = $threadtypesnew['selectbox'][$newtypeid] = $val;
}
}
}
}
$threadtypesnew['status'] = 1;
} else {
$newname = array();
}
if($threadtypesnew['status']) {
if(is_array($threadtypesnew['options']) && $threadtypesnew['options']) {
$typeids = '0';
foreach($threadtypesnew['options'] as $key => $val) {
$typeids .= $val ? ', '.intval($key) : '';
}
$query = $db->query("SELECT * FROM {$tablepre}threadtypes WHERE typeid IN ($typeids) AND special='' ORDER BY displayorder");
while($type = $db->fetch_array($query)) {
if($threadtypesnew['options']['enable'][$type['typeid']]) {
if($threadtypesnew['options'][$type['typeid']] == 1) {
$threadtypesnew['types'][$type['typeid']] = $threadtypesnew['flat'][$type['typeid']] = $type['name'];
} elseif($threadtypesnew['options'][$type['typeid']] == 2) {
$threadtypesnew['types'][$type['typeid']] = $threadtypesnew['selectbox'][$type['typeid']] = $type['name'];
}
}
}
}
$threadtypesnew = $threadtypesnew['types'] ? addslashes(serialize(array
(
'required' => (bool)$threadtypesnew['required'],
'listable' => (bool)$threadtypesnew['listable'],
'prefix' => (bool)$threadtypesnew['prefix'],
'types' => $threadtypesnew['types'],
'selectbox' => $threadtypesnew['selectbox'],
'flat' => $threadtypesnew['flat'],
))) : '';
} else {
$threadtypesnew = '';
}
$threadtypesadd = "threadtypes='$threadtypesnew',";
if($threadsortsnew['status']) {
if(is_array($threadsortsnew['options']) && $threadsortsnew['options']) {
$sortids = '0';
foreach($threadsortsnew['options'] as $key => $val) {
$sortids .= $val ? ', '.intval($key) : '';
}
$query = $db->query("SELECT * FROM {$tablepre}threadtypes WHERE typeid IN ($sortids) AND special='1' ORDER BY displayorder");
while($sort = $db->fetch_array($query)) {
if($threadsortsnew['options']['enable'][$sort['typeid']]) {
if($threadsortsnew['options'][$sort['typeid']] == 1) {
$threadsortsnew['types'][$sort['typeid']] = $threadsortsnew['flat'][$sort['typeid']] = $sort['name'];
} elseif($threadsortsnew['options'][$sort['typeid']] == 2) {
$threadsortsnew['types'][$sort['typeid']] = $threadsortsnew['selectbox'][$sort['typeid']] = $sort['name'];
}
}
$threadsortsnew['expiration'][$sort['typeid']] = $sort['expiration'];
$threadsortsnew['show'][$sort['typeid']] = $threadsortsnew['options']['show'][$sort['typeid']] ? 1 : 0;
$threadsortsnew['typemodelid'][$sort['typeid']] = $sort['modelid'];
}
}
$threadsortsnew = $threadsortsnew['types'] ? addslashes(serialize(array
(
'required' => (bool)$threadsortsnew['required'],
'listable' => (bool)$threadsortsnew['listable'],
'prefix' => (bool)$threadsortsnew['prefix'],
'types' => $threadsortsnew['types'],
'selectbox' => $threadsortsnew['selectbox'],
'flat' => $threadsortsnew['flat'],
'show' => $threadsortsnew['show'],
'expiration' => $threadsortsnew['expiration'],
'modelid' => $threadsortsnew['typemodelid'],
))) : '';
} else {
$threadsortsnew = '';
}
$threadsortsadd = "threadsorts='$threadsortsnew',";
if($typemodel) {
$query = $db->query("SELECT id, name FROM {$tablepre}typemodels WHERE id IN (".implodeids($typemodel).") ORDER BY displayorder");
while($model = $db->fetch_array($query)) {
$threadtypemodel[$model['id']]['name'] = $model['name'];
}
$threadtypemodeladd = addslashes(serialize($threadtypemodel));
}
} else {
$threadtypesadd = $threadsortsadd = $threadtypemodeladd = '';
}
if(!empty($tradetypes) && is_array($tradetypes) && $allowpostspecialtrade) {
if(count($tradetypes) == count($tradetypesnew)) {
$tradetypesnew = '';
} else {
$tradetypesnew = addslashes(serialize($tradetypesnew));
}
} else {
$tradetypesnew = '';
}
$modrecommendnew['num'] = $modrecommendnew['num'] ? intval($modrecommendnew['num']) : 10;
$modrecommendnew['cachelife'] = $modrecommendnew['cachelife'] ? intval($modrecommendnew['cachelife']) : 900;
$modrecommendnew['maxlength'] = $modrecommendnew['maxlength'] ? intval($modrecommendnew['maxlength']) : 0;
$modrecommendnew['dateline'] = $modrecommendnew['dateline'] ? intval($modrecommendnew['dateline']) : 0;
$modrecommendnew = $modrecommendnew && is_array($modrecommendnew) ? addslashes(serialize($modrecommendnew)) : '';
$descriptionnew = addslashes(preg_replace('/on(mousewheel|mouseover|click|load|onload|submit|focus|blur)="[^"]*"/i', '', discuzcode(stripslashes($descriptionnew), 1, 0, 0, 0, 1, 1, 0, 0, 1)));
$rulesnew = addslashes(preg_replace('/on(mousewheel|mouseover|click|load|onload|submit|focus|blur)="[^"]*"/i', '', discuzcode(stripslashes($rulesnew), 1, 0, 0, 0, 1, 1, 0, 0, 1)));
$db->query("UPDATE {$tablepre}forumfields SET description='$descriptionnew', icon='$iconnew', password='$passwordnew', redirect='$redirectnew', rules='$rulesnew',
attachextensions='$attachextensionsnew', $threadtypesadd $threadsortsadd postcredits='$postcreditsnew', replycredits='$replycreditsnew', digestcredits='$digestcreditsnew',
postattachcredits='$postattachcreditsnew', getattachcredits='$getattachcreditsnew', viewperm='$viewpermnew', postperm='$postpermnew', replyperm='$replypermnew', tradetypes='$tradetypesnew', typemodels='$threadtypemodeladd',
getattachperm='$getattachpermnew', postattachperm='$postattachpermnew', formulaperm='$formulapermnew', modrecommend='$modrecommendnew', keywords='$keywordsnew' WHERE fid='$fid'");
if($modrecommendnew && !$modrecommendnew['sort']) {
require_once DISCUZ_ROOT.'./include/forum.func.php';
recommendupdate($fid, $modrecommendnew, '1');
}
if($statusnew == 0) {
$db->query("UPDATE {$tablepre}forums SET status='$statusnew' WHERE fup='$fid'", 'UNBUFFERED');
}
updatecache('forums');
if($foruminfosidestatus) {
$infosidestatusnew = $infosidestatus;
unset($infosidestatusnew['f'.$fid]);
$foruminfosidestatus[0] != $infosidestatus[0] && $foruminfosidestatus[0] != '' && $infosidestatusnew['f'.$fid][0] = $foruminfosidestatus[0];
$foruminfosidestatus['posts'] != $infosidestatus['posts'] && $foruminfosidestatus['posts'] != '' && $infosidestatusnew['f'.$fid]['posts'] = $foruminfosidestatus['posts'];
if($infosidestatus != $infosidestatusnew) {
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('infosidestatus', '".(addslashes(serialize($infosidestatusnew)))."')");
updatecache('settings');
}
}
if(submitcheck('saveconfigsubmit') && $type != 'group') {
$projectid = intval($projectid);
dheader("Location: $boardurl$BASESCRIPT?action=project&operation=add&id=$fid&type=forum&projectid=$projectid");
} else {
cpmsg('forums_edit_succeed', "$BASESCRIPT?action=forums&operation=edit&fid=$fid".($anchor ? "&anchor=$anchor" : ''), 'succeed');
}
}
}
} elseif($operation == 'delete') {
if($ajax) {
ob_end_clean();
require_once DISCUZ_ROOT.'./include/post.func.php';
$tids = 0;
$total = intval($total);
$pp = intval($pp);
$currow = intval($currow);
$query = $db->query("SELECT tid FROM {$tablepre}threads WHERE fid='$fid' LIMIT $pp");
while($thread = $db->fetch_array($query)) {
$tids .= ','.$thread['tid'];
}
if($tids) {
$query = $db->query("SELECT attachment, thumb, remote FROM {$tablepre}attachments WHERE tid IN ($tids)");
while($attach = $db->fetch_array($query)) {
dunlink($attach['attachment'], $attach['thumb'], $attach['remote']);
}
foreach(array('threads', 'threadsmod', 'relatedthreads', 'posts', 'polls', 'polloptions', 'trades', 'activities', 'activityapplies', 'debates', 'debateposts', 'videos', 'attachments', 'favorites', 'mythreads', 'myposts', 'subscriptions', 'typeoptionvars', 'forumrecommend') as $value) {
$db->query("DELETE FROM {$tablepre}$value WHERE tid IN ($tids)", 'UNBUFFERED');
}
}
if($currow + $pp > $total) {
$db->query("DELETE FROM {$tablepre}forum
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -