📄 forums.inc.php
字号:
} else {
$threadtypesnew = '';
}
$db->query("UPDATE {$tablepre}forumfields SET description='$descriptionnew', icon='$iconnew', password='$passwordnew', redirect='$redirectnew', rules='$rulesnew',
attachextensions='$attachextensionsnew', threadtypes='$threadtypesnew', postcredits='$postcreditsnew', replycredits='$replycreditsnew', viewperm='$viewpermnew',
postperm='$postpermnew', replyperm='$replypermnew', getattachperm='$getattachpermnew', postattachperm='$postattachpermnew' WHERE fid='$fid'");
if($statusnew == 0) {
$db->query("UPDATE {$tablepre}forums SET status='$statusnew' WHERE fup='$fid'", 'UNBUFFERED');
}
updatecache('forums');
cpmsg('forums_edit_succeed', 'admincp.php?action=forumsedit');
}
}
} elseif($action == 'forumdelete') {
$query = $db->query("SELECT COUNT(*) FROM {$tablepre}forums WHERE fup='$fid'");
if($db->result($query, 0)) {
cpmsg('forums_delete_sub_notnull');
}
if(!$confirmed) {
cpmsg('forums_delete_confirm', "admincp.php?action=forumdelete&fid=$fid", 'form');
} else {
require_once DISCUZ_ROOT.'./include/post.func.php';
$tids = 0;
$query = $db->query("SELECT tid FROM {$tablepre}threads WHERE attachment>'0' AND fid='$fid'");
while($thread = $db->fetch_array($query)) {
$tids .= ','.$thread['tid'];
}
if($tids) {
$query = $db->query("SELECT filename FROM {$tablepre}attachments WHERE tid IN ($tids)");
while($attach = $db->fetch_array($query)) {
@unlink($attachdir.'/'.$attach['filename']);
}
$db->query("DELETE FROM {$tablepre}attachments WHERE tid IN ($tids)");
}
$db->query("DELETE FROM {$tablepre}threads WHERE fid='$fid'");
$db->query("DELETE FROM {$tablepre}posts WHERE fid='$fid'");
$db->query("DELETE FROM {$tablepre}forums WHERE fid='$fid'");
$db->query("DELETE FROM {$tablepre}forumfields WHERE fid='$fid'");
$db->query("DELETE FROM {$tablepre}moderators WHERE fid='$fid'");
$db->query("DELETE FROM {$tablepre}access WHERE fid='$fid'");
updatecache('forums');
cpmsg('forums_delete_succeed', 'admincp.php?action=forumsedit');
}
} elseif($action == 'threadtypes') {
if(!submitcheck('typesubmit')) {
$forumsarray = array();
$query = $db->query("SELECT f.fid, f.name, ff.threadtypes FROM {$tablepre}forums f , {$tablepre}forumfields ff WHERE ff.threadtypes<>'' AND f.fid=ff.fid");
while($forum = $db->fetch_array($query)) {
$forum['threadtypes'] = unserialize($forum['threadtypes']);
if(is_array($forum['threadtypes']['types'])) {
foreach($forum['threadtypes']['types'] as $typeid => $name) {
$forumsarray[$typeid][] = '<a href="forumdisplay.php?fid='.$forum['fid'].'" target="_blank">'.$forum['name'].'</a> [<a href="admincp.php?action=forumdetail&fid='.$forum['fid'].'">'.$lang['edit'].'</a>]';
}
}
}
$threadtypes = '';
$query = $db->query("SELECT * FROM {$tablepre}threadtypes ORDER BY displayorder");
while($type = $db->fetch_array($query)) {
$threadtypes .= "<tr align=\"center\"><td bgcolor=\"".ALTBG1."\"><input type=\"checkbox\" name=\"delete[]\" value=\"$type[typeid]\"></td>\n".
"<td bgcolor=\"".ALTBG2."\"><input type=\"text\" size=\"15\" name=\"namenew[$type[typeid]]\" value=\"".dhtmlspecialchars($type['name'])."\"></td>\n".
"<td bgcolor=\"".ALTBG1."\"><input type=\"text\" size=\"2\" name=\"displayordernew[$type[typeid]]\" value=\"$type[displayorder]\"></td>\n".
"<td bgcolor=\"".ALTBG2."\"><input type=\"text\" size=\"30\" name=\"descriptionnew[$type[typeid]]\" value=\"$type[description]\"></td>\n".
"<td bgcolor=\"".ALTBG1."\">".(is_array($forumsarray[$type['typeid']]) ? implode(', ', $forumsarray[$type['typeid']]) : '')."</td></tr>\n";
}
?>
<table cellspacing="<?=INNERBORDERWIDTH?>" cellpadding="<?=TABLESPACE?>" width="95%" align="center" class="tableborder">
<tr class="header"><td><?=$lang['tips']?></td></tr>
<tr bgcolor="<?=ALTBG1?>"><td>
<br><?=$lang['forums_threadtypes_tips']?>
</td></tr></table>
<form method="post" action="admincp.php?action=threadtypes">
<input type="hidden" name="formhash" value="<?=FORMHASH?>">
<table cellspacing="<?=INNERBORDERWIDTH?>" cellpadding="<?=TABLESPACE?>" width="95%" align="center" class="tableborder">
<tr class="header"><td colspan="5"><?=$lang['forums_threadtypes']?></td></tr>
<tr align="center" class="category"><td><?=$lang['del']?></td><td><?=$lang['forums_threadtypes']?></td><td><?=$lang['display_order']?></td><td><?=$lang['description']?></td><td><?=$lang['forums_threadtypes_forums']?></td></tr>
<?=$threadtypes?>
<tr><td colspan="5" class="singleborder"> </td></tr>
<tr align="center"><td bgcolor="<?=ALTBG1?>"><?=$lang['add_new']?></td><td bgcolor="<?=ALTBG2?>"><input type='text' name="newname" size="15"></td><td bgcolor="<?=ALTBG1?>"><input type="text" name="newdisplayorder" size="2" value="0"></td><td bgcolor="<?=ALTBG2?>"><input type="text" name="newdescription" size="30" value=""></td><td bgcolor="<?=ALTBG1?>"> </td></tr>
</table><br>
<center><input type="submit" name="typesubmit" value="<?=$lang['submit']?>"></center>
</form>
<?
} else {
$modifiedtypes = array();
if(is_array($delete)) {
$modifiedtypes = $delete;
$deleteids = '\''.implode('\',\'', $delete).'\'';
$db->query("DELETE FROM {$tablepre}threadtypes WHERE typeid IN ($deleteids)");
if($db->affected_rows()) {
$db->query("UPDATE {$tablepre}threads SET typeid='0' WHERE typeid IN ($deleteids)");
}
}
if(is_array($namenew)) {
foreach($namenew as $typeid => $val) {
$db->query("UPDATE {$tablepre}threadtypes SET name='".trim($namenew[$typeid])."', description='".dhtmlspecialchars(trim($descriptionnew[$typeid]))."', displayorder='$displayordernew[$typeid]' WHERE typeid='$typeid'");
if($db->affected_rows()) {
$modifiedtypes[] = $typeid;
}
}
if($modifiedtypes = array_unique($modifiedtypes)) {
$query = $db->query("SELECT f.fid, ff.threadtypes FROM {$tablepre}forums f, {$tablepre}forumfields ff WHERE ff.threadtypes<>'' AND f.fid=ff.fid");
while($forum = $db->fetch_array($query)) {
$forum['threadtypes'] = unserialize($forum['threadtypes']);
foreach($modifiedtypes as $typeid) {
if(isset($forum['threadtypes']['types'][$typeid])) {
$db->query("SELECT * FROM {$tablepre}threadtypes WHERE typeid IN (".implode(',', array_keys($forum['threadtypes']['types'])).") ORDER BY displayorder");
$forum['threadtypes']['types'] = array();
while($type = $db->fetch_array($query)) {
$forum['threadtypes']['types'][$type['typeid']] = $type['name'];
}
$db->query("UPDATE {$tablepre}forumfields SET threadtypes='".addslashes(serialize($forum['threadtypes']))."' WHERE fid='$fid'");
break;
}
}
}
}
}
if($newname != '') {
$newname = dhtmlspecialchars(trim($newname));
$query = $db->query("SELECT typeid FROM {$tablepre}threadtypes WHERE name='$newname'");
if($db->num_rows($query)) {
cpmsg('forums_threadtypes_duplicate');
}
$db->query("INSERT INTO {$tablepre}threadtypes (name, description, displayorder) VALUES
('$newname', '".dhtmlspecialchars(trim($newdescription))."', '$newdisplayorder')");
}
cpmsg('forums_threadtypes_succeed', 'admincp.php?action=threadtypes');
}
} elseif($action == 'forumrules') {
if(empty($fid)) {
$forums = '';
if($adminid == 2) {
$query = $db->query("SELECT fid, name FROM {$tablepre}forums
WHERE alloweditrules>'0' AND type IN ('forum', 'sub')");
} else {
$query = $db->query("SELECT f.fid, f.name, m.uid FROM {$tablepre}forums f
LEFT JOIN {$tablepre}moderators m ON m.uid='$discuz_uid' AND m.fid=f.fid
WHERE alloweditrules>'0' AND f.type IN ('forum', 'sub')");
}
while($forum = $db->fetch_array($query)) {
if($forum['uid'] || $adminid == 2) {
$forums .= "<option value=\"$forum[fid]\">".strip_tags($forum['name'])."</option>";
}
}
if($forums) {
$forums = '<select name="fid">'.$forums.'</select>';
} else {
cpmsg('forums_rules_nopermission');
}
?>
<br><br><form method="post" action="admincp.php?action=forumrules">
<input type="hidden" name="formhash" value="<?=FORMHASH?>">
<table cellspacing="<?=INNERBORDERWIDTH?>" cellpadding="<?=TABLESPACE?>" width="70%" align="center" class="tableborder">
<tr class="header"><td colspan="2"><?=$lang['forums_edit']?></td></tr>
<tr bgcolor="<?=ALTBG2?>">
<td><?=$lang['forum']?>:</td><td><?=$forums?></td></tr>
</table><br><center>
<input type="submit" value="<?=$lang['submit']?>">
</center></form><br>
<?
} else {
$access = 0;
if($adminid == 2) {
$access = 1;
} elseif($adminid == 3) {
$query = $db->query("SELECT uid FROM {$tablepre}moderators WHERE uid='$discuz_uid' AND fid='$fid'");
$access = $db->num_rows($query) ? 1 : 0;
}
$query = $db->query("SELECT f.fid, f.name, f.alloweditrules, ff.rules FROM {$tablepre}forums f
LEFT JOIN {$tablepre}forumfields ff USING (fid)
WHERE f.fid='$fid' AND alloweditrules>'0' AND type IN ('forum', 'sub')");
if(!$access || !($forum = $db->fetch_array($query))) {
cpmsg('forums_rules_nopermission');
}
if(!submitcheck('rulessubmit')) {
$comment = $lang[($forum['alloweditrules'] == 1 ? 'forums_edit_edit_rules_html_no' : 'forums_edit_edit_rules_html_yes')];
?>
<br><br><form method="post" action="admincp.php?action=forumrules&fid=<?=$fid?>">
<input type="hidden" name="formhash" value="<?=FORMHASH?>">
<table cellspacing="<?=INNERBORDERWIDTH?>" cellpadding="<?=TABLESPACE?>" width="70%" align="center" class="tableborder">
<tr class="header"><td colspan="2"><?=$lang['forums_edit']?> - <?=$forum['name']?></td></tr>
<tr bgcolor="<?=ALTBG2?>"><td valign="top"><span class="bold"><?=$lang['forums_edit_rules']?></span><br><?=$comment?></td>
<td><textarea name="rulesnew" rows="5" cols="60"><?=dhtmlspecialchars($forum['rules'])?></textarea></td></tr>
</table><br><center>
<input type="submit" name="rulessubmit" value="<?=$lang['submit']?>">
</center></form><br>
<?
} else {
if($forum['alloweditrules'] != 2) {
$rulesnew = dhtmlspecialchars($rulesnew);
}
$db->query("UPDATE {$tablepre}forumfields SET rules='$rulesnew' WHERE fid='$fid'");
cpmsg('forums_rules_succeed');
}
}
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -