📄 setforum.php
字号:
<?
$thisprog="setforum.php";
require("admincp.php");
require("bbsdata/config.php");
$forumfile="bbsdata/forumdata.php";
print "$admintopad
<tr>
<td bgcolor=#f2f8ff align=center colspan=2>
<b>备份版块数据</b>
</td>
</tr>
<tr bgcolor=#99ccff>
<td align=center><a href=admin.php?adminjob=forum_back&action=backup>开始备份</a> <a href=admin.php?adminjob=forum_back&action=del>删除备份</a>
<a href=admin.php?adminjob=forum_back&action=edit>手动修改数据</a></td>
<td align=center><a href=admin.php?adminjob=forum_back&action=renew>还原数据</a> <a href=admin.php?adminjob=forum_back&action=view>查看备份数据</a></td>
</tr>
";
if (file_exists($forumfile)) {
$forumdata=file($forumfile);
$count=count($forumdata);
}
if (empty($action)) {
$forumselect="";
$forumonly="";
for($i=0; $i<$count; $i++) {
$detail=explode("|",$forumdata[$i]);
if(empty($forumid)) $forumid=$detail[3];
if ($detail[0]=="category") {
if($detail[3]==$forumid) {
$ifselected="selected";
$forumname=$detail[1];
$cateadmin=$detail[2];
$forumdes="";
$forumpwd="";
} else {
$ifselected="";
}
$forumselect.="<option value=\"$detail[3]\" $ifselected>$detail[1]</option>";
}else{
if($detail[3]==$forumid) {
$ifselected="selected";
$forumname=$detail[1];
$forumdes=$detail[2];
$forumpwd=$detail[5];
$forumlogo=$detail[14];
if($detail[13]==1) $checked1="checked";else $checked2="checked";
$announcetitle=str_replace("<","《",$detail[10]);
$forumannounce=str_replace("<br>","\n",$detail[11]);
$cateadmin="";
} else {
$ifselected="";
}
if ($detail[4]==0){
$forumselect.="<option value=\"$detail[3]\" $ifselected> |- $detail[1]</option>";
$forumonly.="<option value=\"$detail[3]\">$detail[1]</option>";}
else{
$forumselect.="<option value=\"$detail[3]\" $ifselected> |- $detail[1]</option>";
$forumonly.="<option value=\"$detail[3]\"> |- $detail[1]</option>";}
}
}
$forumselect.="</select>"; $forumonly.="</select>";
$dh=opendir("userdata/style/");
while ($userskin=readdir($dh)) {
if (($userskin!=".") && ($userskin!="..") ) {
$user_skin[]=$userskin;
}
}
closedir($dh);
$count=count($user_skin);
$forumstyle="<select name='forumskin'><option value=''>请选择风格</option><option value='默认风格'>默认风格</option>";
for ($i=0; $i<$count; $i++) {
$forumstyle.="<option value=$user_skin[$i]>$user_skin[$i]</option>";
}
$forumstyle.="</select>";
print <<<EOT
<script language=JavaScript>
<!--
function menu(){
var URL=document.mod.target.options[document.mod.target.selectedIndex].value;
URL="$thisporg?forumid="+URL;
top.location.href=URL;target='_self';
}
</script>
<tr><td bgcolor=f2f8ff colspan=3>
<form action="$thisprog" method=POST><input type=hidden name="action" value="newitem">
$tab_top
<b>1.新建一个分类区/版块:( 位于: $idpath )</b></td></tr>
<tr><td bgcolor=#f2f8ff>
分类区只须填名称,其它如不设置则不要选择/填写<br><input type=radio checked name="type" value="category">分类区 <input type=radio name="type" value="forum">开放版块 <input type=radio name="type" value="former">正规版块 <input type=radio name="type" value="locked">认证版块 <input type=radio name="type" value="closed">关闭版块 <input type=radio name="type" value="hidden">隐藏版块 <input type=radio name="type" value="selection">只读版块 <br>设为子版块,所属版块<select name="forumid"><option value="0">请选择版块</option>$forumonly 使用风格$forumstyle 版块密码<input type=text name="forumpwd" size=10><br>
名称<input type=text name="name" size=10> 描述<input type=text name="des" size=26> 版块logo地址<input type=text name="forumlogo" size=26><br>是否只显示子版块<input type=radio name=setifchildren value=1>是<input type=radio name=setifchildren value=2 checked>否(必须拥有子版块才有效)<br>允许加密贴<input type=radio name=post value=1 checked>是<input type=radio name=post value=0>否 允许隐藏贴<input type=radio name=hide value=1 checked>是<input type=radio name=hide value=0>否 允许出售贴<input type=radio name=sell value=1 checked>是<input type=radio name=sell value=0>否
<input type=submit value="提 交">
$tab_bottom</form>
<form action="$thisprog" method=POST><input type=hidden name="action" value="modifyorder">
$tab_top
<b>2.改变项目顺序:</b></td></tr>
<tr><td bgcolor=#f2f8ff>
如果你想改变一个版块的位置或者比如是新建一个版块应该属于前面的类别。<br>
将项目 <select name="item1">$forumselect 移动到 <select name="item2">$forumselect 之后 <input type=submit value="提 交">
$tab_bottom</form>
<form action="$thisprog" method=POST><input type=hidden name="action" value="moderator">
$tab_top
<b>3.版块管理员设置</b></td></tr>
<tr><td bgcolor=#f2f8ff>
在这里你可以增加和删除版块管理员<br>
具体动向:<input type=radio checked name="job" value="add">增加 <input type=radio checked name="job" value="del">删除
斑竹:<input type=text name="userid" size=8> 执行版块:<select name="forumid">$forumonly <input type=submit value="提 交">
$tab_bottom</form>
<form action="$thisprog" method=POST name=mod><input type=hidden name="action" value="moditem">
$tab_top
<b>4.删除/修改项目</b></td></tr>
<tr><td bgcolor=#f2f8ff>
版块密码请重新输入,不填则清空,其它不填则不改变原来设定<br>
对象:<select name="target" onChange=menu()>$forumselect<br>动作:<input type=radio checked name="job" value="modify">修改(不填则不做修改) <input type=radio name="job" value="delete">删除<input type=radio name="job" value="addchildren">设为子版块 <input type=radio name="job" value="delchildren">移出子版块,所属版块<select name="forumid"><option value="0">请选择版块</option>$forumonly<br>新名称<input type=text name="name" size=10 value="$forumname"> 新描述<input type=text name="des" size=26 value="$forumdes"> 版块logo地址<input type=text name="forumlogo" value="$forumlogo" size=26><br>新类别<select name="forumtype"><option value="">请选择类别</option><option value="forum">开放版块</option><option value="former">正规版块</option><option value="locked">认证版块</option><option value="hidden">隐藏版块</option><option value="closed">关闭版块</option><option value="selection">只读版块</option></select> 新风格$forumstyle 新密码<input type=text name="forumpwd" size=10 value="$forumpwd">
<br>是否只显示子版块<input type=radio name=setifchildren value=1 $checked1>是<input type=radio name=setifchildren value=2 $checked2>否(必须拥有子版块才有效)
<br>允许加密贴<input type=radio name=post value=1 checked>是<input type=radio name=post value=0>否 允许隐藏贴<input type=radio name=hide value=1 checked>是<input type=radio name=hide value=0>否 允许出售贴<input type=radio name=sell value=1 checked>是<input type=radio name=sell value=0>否 <br>
版务公告标题:<input type=text name="announcetitle" size=60 value="$announcetitle"><br>
版务公告内容:<textarea cols=60 rows=6 name="forumannounce">$forumannounce</textarea><br>
<center><input type=submit value="提 交"> <input type=reset value="重 置"></center>
$tab_bottom</form>
</td></tr>$adminbottomad</td></tr></table></body></html>
EOT;
exit;
}elseif ($action=="newitem") {
//-------新建项目-----------
$newstring="";
print "<tr><td bgcolor=f2f8ff valign=middle align=center colspan=2><b>新建项目</b></td></tr>
<tr><td bgcolor=f2f8ff colspan=2>";
if ($type=="category") {
//-----增加分类------
$name=str_replace("|","",$name);
$categoryadmin=str_replace("|","",$categoryadmin);$categoryadmin=stripslashes($categoryadmin);
$t=time();
$newstring="category|$name|$categoryadmin|$t|\n";
} else {
//-----增加版块------
global $idpath;
$des=str_replace("|","",$des); $name=str_replace("|","",$name); $name=stripslashes($name); $des=stripslashes($des); $forumskin=str_replace("|","",$forumskin);
if(!empty($forumpwd)) $forumpwd=md5($forumpwd);
$max=0;
for ($i=0; $i<$count; $i++) {
$temp=explode("|",$forumdata[$i]);
if ($temp[0]!="category") $max=max($max,$temp[3]);
}
$id=$max+1;
while(file_exists("{$idpath}forum$id")) $id++;
if (mkdir("{$idpath}forum$id",0777)) {
echo "<b>成功建立目录forum$id</b>";
} else {
echo "<b>建立目录forum$id失败,请手工建立并设置权限为777</b>";
}
$newstring="$type|$name|$des|$id|$forumid|$forumpwd|$forumskin|$post|$hide|$sell|版务公告标题|这里是版务公告内容|1|$setifchildren|$forumlogo|\n";
}
$fp=fopen($forumfile,"a");
if (fwrite($fp,$newstring)) echo "<br><br>成功更新论坛列表资料<b></b><br>";
else echo "<br><br>论坛列表更新失败,请检查datafile目录及forumdata.php之属性<b></b><br>";
fclose($fp);
}elseif ($action=="modifyorder") {
//-------改变顺序-----------
print "<tr><td bgcolor=f2f8ff valign=middle align=center colspan=2><b>修改顺序</b></td></tr>
<tr><td bgcolor=f2f8ff colspan=2>";
$new="";
for ($i=0; $i<$count; $i++) {
$detail=explode("|",$forumdata[$i]);
if ($detail[3]!=$item1) $new.=$forumdata[$i];
if ($detail[3]==$item2) {
for ($j=0; $j<$count; $j++) {
$detail2=explode("|",$forumdata[$j]);
if ($detail2[3]==$item1) $new.=$forumdata[$j];
}
}
}
writetofile($forumfile,$new);
}elseif ($action=="moderator") {
//-------斑竹设置-----------
print "<tr><td bgcolor=f2f8ff valign=middle align=center colspan=2><b>斑竹设置</b></td></tr>
<tr><td bgcolor=f2f8ff colspan=2>";
$adminfile="bbsdata/admin.php";
$userid=str_replace("|","",$userid); $userid=stripslashes($userid);
if ($job=="add") {
$fp=fopen($adminfile,"a");
flock($fp,LOCK_EX);
fputs($fp,"$forumid|$userid|\n");
fclose($fp);
}else {
$adminlist=file($adminfile);
$count=count($adminlist);
$fp=fopen($adminfile,"w");
flock($fp,LOCK_EX);
for ($i=0; $i<$count; $i++){
$info=explode("|",$adminlist[$i]);
if ($info[0]!=$forumid || $info[1]!=$userid) fputs($fp,$adminlist[$i]);
}
fclose($fp);
}
}elseif ($action=="moditem") {
//-------删除/修改项目-----------
print "<tr><td bgcolor=f2f8ff valign=middle align=center colspan=2><b>修改/删除项目</b></td></tr>
<tr><td bgcolor=f2f8ff colspan=2>";
for ($i=0; $i<$count; $i++) {
$detail=explode("|",$forumdata[$i]);
if ($detail[3]==$target) {
if ($job!="delete") {
if (!empty($forumtype)||$forumtype!="") $detail[0]=$forumtype;
if ($job=="addchildren" && $detail[0]!="category") $detail[4]=$forumid;
if ($job=="delchildren" && $detail[0]!="category") $detail[4]=0;
if (!empty($name)) $detail[1]=$name;
if (!empty($des) && $detail[0]!="category") $detail[2]=$des;
if (!empty($forumpwd)) $forumpwd=md5($forumpwd);
$forumannounce=str_replace("\n","<br>",$forumannounce);
$forumannounce=str_replace("\r","",$forumannounce);
if ($detail[0]!="category") {$detail[5]=$forumpwd;$detail[7]=$post;$detail[8]=$hide;$detail[9]=$sell;$detail[10]=$announcetitle;$detail[11]=$forumannounce;$detail[12]="1";$detail[13]=$setifchildren;$detail[14]=$forumlogo;}
$forumskin=stripslashes($forumskin);
if (!empty($forumskin) && $detail[0]!="category") {if($forumskin=="默认风格") $forumskin=""; $detail[6]=$forumskin;}
if ($detail[0]=="category") {$detail[2]=$categoryadmin;$detail[4]="1";$detail[5]="2";$detail[6]="3";$detail[7]="\n";}
$new[]=implode("|",$detail);
}
}
else $new[]=$forumdata[$i];
}
$new=implode("",$new);
$new=str_replace("
","
",$new);
writetofile($forumfile,$new);
}
print "<br><b> 操作完成</b><br><br> >> <a href=$thisprog>返回执行其他动作</a></td></tr></table></body></html>";
exit;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -