📄 forums.inc.php
字号:
}
$threadtypesadd = "threadtypes='$threadtypesnew',";
} else {
$threadtypesadd = '';
}
$db->query("UPDATE {$tablepre}forumfields SET description='$descriptionnew', icon='$iconnew', password='$passwordnew', redirect='$redirectnew', rules='$rulesnew',
attachextensions='$attachextensionsnew', $threadtypesadd postcredits='$postcreditsnew', replycredits='$replycreditsnew', digestcredits='$digestcreditsnew',
postattachcredits='$postattachcreditsnew', getattachcredits='$getattachcreditsnew', viewperm='$viewpermnew', postperm='$postpermnew', replyperm='$replypermnew',
getattachperm='$getattachpermnew', postattachperm='$postattachpermnew'$supe_pushsettingadd WHERE fid='$fid'");
if($statusnew == 0) {
$db->query("UPDATE {$tablepre}forums SET status='$statusnew' WHERE fup='$fid'", 'UNBUFFERED');
}
updatecache('forums');
if(submitcheck('saveconfigsubmit') && $type != 'group') {
$projectid = intval($projectid);
dheader("Location: {$boardurl}admincp.php?action=projectadd&id=$fid&type=forum&projectid=$projectid");
} else {
cpmsg('forums_edit_succeed', 'admincp.php?action=forumsedit');
}
}
}
} elseif($action == 'forumdelete') {
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', 'attachments', 'favorites', 'mythreads', 'myposts', 'subscriptions') as $value) {
$db->query("DELETE FROM {$tablepre}$value WHERE tid IN ($tids)", 'UNBUFFERED');
}
}
if($currow + $pp > $total) {
$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'");
echo 'TRUE';
exit;
}
updatecache('forums');
echo 'GO';
exit;
} else {
if($finished) {
cpmsg('forums_delete_succeed', 'admincp.php?action=forumsedit');
}
$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 {
$query = $db->query("SELECT COUNT(*) FROM {$tablepre}threads WHERE fid='$fid'");
$threads = $db->result($query, 0);
echo "
<table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"6\"><tr><td>
<br><br><br><br><br><br>
<table width=\"500\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" align=\"center\" class=\"tableborder\">
<tr class=\"header\"><td>".$lang['discuz_message']."</td></tr><tr><td class=\"altbg2\"><div align=\"center\">
<form method=\"post\" action=\"admincp.php?action=forumdelete&fid=2\"><input type=\"hidden\" name=\"formhash\" value=\"6a47c68f\">
<br><br><br>".$lang['forums_delete_alarm']."<br><br>
<div class=\"process\" >
<div id=\"percent\" class=\"processbg\">0%</div>
</div>
<br><br><br><br></div><br><br>
</td></tr></table>
<br><br><br>
</td></tr></table>
";
echo "<div id=\"statusid\" style=\"display:none\"></div>";
echo "<script src=\"include/javascript/ajax.js\"></script>";
echo "
<script>
var xml_http_building_link = '{lang xml_http_building_link}';
var xml_http_sending = '{lang xml_http_sending}';
var xml_http_loading = '{lang xml_http_loading}';
var xml_http_load_failed = '{lang xml_http_load_failed}';
var xml_http_data_in_processed = '{lang xml_http_data_in_processed}';
function forumsdelete(url, total, pp, currow) {
var x = new Ajax('HTML', 'statusid');
x.get(url+'&ajax=1&pp='+pp+'&total='+total+'&currow='+currow, function(s) {
if(s != 'GO') {
location.href = 'admincp.php?action=forumdelete&finished=1';
}
currow += pp;
var percent = ((currow / total) * 100).toFixed(0);
percent = percent > 100 ? 100 : percent;
document.getElementById('percent').innerHTML = percent+'%';
document.getElementById('percent').style.backgroundPosition = '-'+percent+'%';
if(currow < total) {
forumsdelete(url, total, pp, currow);
}
});
}
forumsdelete('admincp.php?action=forumdelete&fid=$fid&confirmed=1', $threads, 2000, 0);
</script>
";
}
}
} elseif($action == 'threadtypes') {
if(!submitcheck('typesubmit')) {
$forumsarray = $fidsarray = 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>]';
$fidsarray[$typeid][] = $forum['fid'];
}
}
}
$threadtypes = '';
$query = $db->query("SELECT * FROM {$tablepre}threadtypes ORDER BY displayorder");
while($type = $db->fetch_array($query)) {
$threadtypes .= "<tr align=\"center\"><td class=\"altbg1\"><input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$type[typeid]\"></td>\n".
"<td class=\"altbg2\"><input type=\"text\" size=\"15\" name=\"namenew[$type[typeid]]\" value=\"".dhtmlspecialchars($type['name'])."\"></td>\n".
"<td class=\"altbg1\"><input type=\"text\" size=\"2\" name=\"displayordernew[$type[typeid]]\" value=\"$type[displayorder]\"></td>\n".
"<td class=\"altbg2\"><input type=\"text\" size=\"30\" name=\"descriptionnew[$type[typeid]]\" value=\"$type[description]\"></td>\n".
"<td class=\"altbg1\">".(is_array($forumsarray[$type['typeid']]) ? implode(', ', $forumsarray[$type['typeid']])."<input type=\"hidden\" name=\"fids[$type[typeid]]\" value=\"".implode(', ', $fidsarray[$type['typeid']])."\">" : '')."</td></tr>\n";
}
shownav('menu_forums_threadtypes');
showtips('forums_threadtypes_tips');
?>
<form method="post" action="admincp.php?action=threadtypes">
<input type="hidden" name="formhash" value="<?=FORMHASH?>">
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="tableborder">
<tr class="header"><td colspan="5"><?=$lang['forums_threadtypes']?></td></tr>
<tr align="center" class="category"><td><input class="checkbox" type="checkbox" name="chkall" class="category" onclick="checkall(this.form)"><?=$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 align="center" class="altbg1"><td><?=$lang['add_new']?></td><td><input type='text' name="newname" size="15"></td><td><input type="text" name="newdisplayorder" size="2" value="0"></td><td><input type="text" name="newdescription" size="30" value=""></td><td> </td></tr>
</table><br>
<center><input class="button" 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)");
foreach($delete AS $id) {
if(!empty($fids[$id])) {
$query = $db->query("SELECT fid, threadtypes FROM {$tablepre}forumfields WHERE fid IN ($fids[$id])");
while($forum = $db->fetch_array($query)) {
$forum['threadtypes'] = unserialize($forum['threadtypes']);
unset($forum['threadtypes']['types'][$id], $forum['threadtypes']['flat'][$id], $forum['threadtypes']['selectbox'][$id]);
$threadtypesnew = addslashes(serialize(array
(
'required' => (bool)$forum['threadtypes']['required'],
'listable' => (bool)$forum['threadtypes']['listable'],
'prefix' => (bool)$forum['threadtypes']['prefix'],
'types' => $forum['threadtypes']['types'],
'selectbox' => $forum['threadtypes']['selectbox'],
'flat' => $forum['threadtypes']['flat'],
)));
$db->query("UPDATE {$tablepre}forumfields SET threadtypes='$threadtypesnew' WHERE fid='$forum[fid]'");
}
}
}
}
}
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 = 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');
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -