form1.php
来自「仿榕树下文章系统春节版 1. 将makpass.php文件的root_pass修」· PHP 代码 · 共 393 行
PHP
393 行
<?
include ("xqfunc.php");
include ("../makepass.php");
include ("admin_log.php");
//////////////////建立一个一级分类//////////////////////////////////
if ($act=="addform") {
$form_name=trim($form_name);
$form_dis=trim($form_dis);
$form_name=htmlspecialchars($form_name);
$form_dis=htmlspecialchars($form_dis);
if (empty ($form_name) or empty ($form_dis)) {
$msg="您没有输入一级分类 名称 或 描述";
$turn_page="form.php";
error_0($msg,$turn_page);
exit;
}
if (file_exists("../data/xq.php")){
$form_id=time();
$form_file="form|$form_id|$form_name|$form_dis|0|0||\n";
$fp=fopen("../data/xq.php","a+");
flock($fp,3);
fwrite($fp,$form_file);
fclose($fp);
$msg="您所建立的一级分类: $form_name 已经成功建立";
$turn_page="form.php";
error_1($msg,$turn_page);
exit;
}
else{
$msg="用于存储分类的xq.php不存在,请您手动建立";
$turn_page="form.php";
error_0($msg,$turn_page);
exit;
}
}
///////////////////建立一个二级分类/////////////////////////////
if ($act=="addtype") {
$type_id=trim($type_id);
$type_name=trim($type_name);
$type_dis=trim($type_dis);
$type_id=htmlspecialchars($type_id);
$type_name=htmlspecialchars($type_name);
$type_dis=htmlspecialchars($type_dis);
if (empty ($type_id) or empty ($type_name) or empty ($type_dis) ) {
$msg="您没有将二级分类资料填写完整";
$turn_page="form.php";
error_0($msg,$turn_page);
exit;
}
if (!ereg("^[a-z]+$",$type_id)) {
$msg="二级分类id必须是由小写英文字母组成";
$turn_page="form.php";
error_0($msg,$turn_page);
exit;
}
if (file_exists("../data/xq.php")){
$type_info=file("../data/xq.php");
$type_count=count($type_info);
for ($i=0;$i<=$type_count-1;$i++){
$type_code=explode("|",$type_info[$i]);
if ($type_id==$type_code[1]){
$msg="您所建立的二级分类id: $type_id 已经被使用了,请您更换";
$turn_page="form.php";
error_0($msg,$turn_page);
exit;
}
}
if ($type_id=="sty" or $type_id=="key" or $type_id==$user or $type_id=="xq" or $type_id=="spe") {
$msg="你添入的二级分类id: $type_id 为系统禁止使用的,请您更换";
$turn_page="form.php";
error_0($msg,$turn_page);
exit;
}
$type_file="type|$type_id|$type_name|$type_dis|0|0||\n";
$fp=fopen("../data/xq.php","a+");
flock($fp,3);
fwrite($fp,$type_file);
fclose($fp);
mkdir("../data/$type_id",0777);
$fp=fopen("../data/$type_id.new","w");
fclose($fp);
$fp=fopen("../data/$type_id.hot","w");
fclose($fp);
$fp=fopen("../data/$type_id/list.php","w");
fclose($fp);
$fp=fopen("../data/$type_id.tui","w");
fclose($fp);
$msg="您建立的二级分类: $type_name 成功建立";
$turn_page="form.php";
error_1($msg,$turn_page);
exit;
}
else{
$msg="用于存储分类的xq.php不存在,请您手动建立";
$turn_page="form.php";
error_0($msg,$turn_page);
exit;
}
}
#################下面是删除分类########################
if ($act=="delmod" and $job=="delete") {
$file_sort=file("../data/xq.php");
$file_count=count($file_sort)-1;
$fp=fopen("../data/xq.php","w");
flock($fp,3);
for ($i=0;$i<=$file_count;$i++){
$file_name=explode("|",$file_sort[$i]);
if ($target==$file_name[1]){
$type_or=$file_name[0];
$type_orname=$file_name[2];
continue;
}
fputs($fp,$file_sort[$i]);
}
fclose ($fp);
if ($type_or=="type"){
unlink("../data/$target.new");
delfile("../data/$target");
}
else {
$msg="您成功删除一级分类:$type_orname";
$turn_page="form.php";
error_1($msg,$turn_page);
exit;
}
}
///////////////////以下是修改分类//////////////////////////////////
if ($act=="delmod" and $job=="modify") {
$new_name=trim($new_name);
$new_name=htmlspecialchars($new_name);
$new_dis=trim($new_dis);
$new_dis=htmlspecialchars($new_dis);
if ($target=="all"){
$msg="您还没有选择分类";
$turn_page="form.php";
error_0($msg,$turn_page);
exit;
}
if (empty ($new_dis) or empty ($new_name)) {
$msg="您没有填写完整要修改的内容";
$turn_page="form.php";
error_0($msg,$turn_page);
exit;
}
if (file_exists("../data/xq.php")){
$file_sort=file("../data/xq.php");
$file_count=count($file_sort)-1;
$fp=fopen("../data/xq.php","w");
flock($fp,3);
for ($i=0;$i<=$file_count;$i++){
$file_name=explode("|",$file_sort[$i]);
if ($file_name[1]==$target) {
fputs($fp,"$file_name[0]|$file_name[1]|$new_name|$new_dis|$file_name[4]|$file_name[5]||\n");
$old_name=$file_name[2]; }
else
fputs($fp,$file_sort[$i]);
}
fclose ($fp);
$msg="您已经成功将 $old_name 分类修改为 $new_name";
$turn_page="form.php";
error_1($msg,$turn_page);
exit;
}
}
///////////////////以下是排序分类//////////////////////////////////
if ($act=="head"){
if ($item1=="all" or $item2=="all"){
$msg="您还没有选择要重新排序的分类";
$turn_page="form.php";
error_0($msg,$turn_page);
exit; }
else {
$forumdata=file("../data/xq.php");
$forumcount=count($forumdata);
$new="";
for ($i=0; $i<$forumcount; $i++) {
$detail=explode("|",$forumdata[$i]);
if ($detail[1]!=$item1) $new.=$forumdata[$i];
if ($detail[1]==$item2) {
for ($j=0; $j<$forumcount; $j++) {
$detail2=explode("|",$forumdata[$j]);
if ($detail2[1]==$item1) $new.=$forumdata[$j];
}
}
}
$fp=fopen("../data/xq.php","w");
flock($fp,3);
fwrite($fp,$new);
fclose($fp);
$msg="您已经成功将更改了分类顺序";
$turn_page="form.php";
error_1($msg,$turn_page);
exit;
}
}
//////////////////建立一个新专题//////////////////////////////////
if ($act=="addspe") {
$spe_name=trim($spe_name);
$spe_dis=trim($spe_dis);
$spe_name=htmlspecialchars($spe_name);
$spe_dis=htmlspecialchars($spe_dis);
if (empty ($spe_name) or empty ($spe_dis) or empty ($spe_id)) {
$msg="您没有输入专题 名称 或 描述";
$turn_page="spe.php";
error_0($msg,$turn_page);
exit;
}
if (!ereg("^[a-z]+$",$spe_id)) {
$msg="专题id必须是由小写英文字母组成";
$turn_page="spe.php";
error_0($msg,$turn_page);
exit;
}
if ($spe_type=="all"){
$msg="您还没有选择二级分类";
$turn_page="spe.php";
error_0($msg,$turn_page);
exit;
}
/////////////////////
$spe_info=file("../data/xq.cgi");
$spe_count=count($spe_info);
for ($i=0;$i<=$spe_count-1;$i++){
$spe_code=explode("|",$spe_info[$i]);
if ($spe_id==$spe_code[1]){
$msg="您所建立的专题id: $type_id 已经被使用了,请您更换";
$turn_page="spe.php";
error_0($msg,$turn_page);
exit;
}
}
////////////////////
if (file_exists("../data/xq.cgi")){
$spe_file="$spe_type|$spe_id|$spe_name|$spe_dis|0||\n";
$fp=fopen("../data/xq.cgi","a+");
flock($fp,3);
fwrite($fp,$spe_file);
fclose($fp);
$fp=fopen("../data/spe/$spe_id.spe","w");
fclose($fp);
////////////////////
$file_hot=file("../data/xq.php");
$file_hot_count=count($file_hot)-1;
$fp_hot=fopen("../data/xq.php","w");
flock($fp_hot,3);
for ($i=0;$i<=$file_hot_count;$i++){
$file_hot_code=explode("|",$file_hot[$i]);
if ($spe_type===$file_hot_code[1]) {
$new_file =$file_hot_code[5]+1;
fwrite($fp_hot,$file_hot_code[0]."|".$file_hot_code[1]."|".$file_hot_code[2]."|".$file_hot_code[3]."|".$file_hot_code[4]."|".$new_file."|"."|"."\n");}
else
fwrite($fp_hot,$file_hot_code[0]."|".$file_hot_code[1]."|".$file_hot_code[2]."|".$file_hot_code[3]."|".$file_hot_code[4]."|".$file_hot_code[5]."|".$file_hot_code[6]."|".$file_hot_code[7]);
}
fclose($fp_hot);
//////////////////////
$msg="您所建立的专题: $spe_name 已经成功建立";
$turn_page="spe.php";
error_1($msg,$turn_page);
exit;
}
else{
$msg="用于存储专题的xq.cgi不存在,请您手动建立";
$turn_page="spe.php";
error_0($msg,$turn_page);
exit;
}
}
///////////////////以下是排序专题//////////////////////////////////
if ($act=="headspe"){
if ($item1=="all" or $item2=="all"){
$msg="您还没有选择要重新排序的专题";
$turn_page="spe.php";
error_0($msg,$turn_page);
exit;
}
else {
$forumdata=file("../data/xq.cgi");
$forumcount=count($forumdata);
$new="";
for ($i=0; $i<$forumcount; $i++) {
$detail=explode("|",$forumdata[$i]);
if ($detail[1]!=$item1) $new.=$forumdata[$i];
if ($detail[1]==$item2) {
for ($j=0; $j<$forumcount; $j++) {
$detail2=explode("|",$forumdata[$j]);
if ($detail2[1]==$item1) $new.=$forumdata[$j];
}
}
}
$fp=fopen("../data/xq.cgi","w");
flock($fp,3);
fwrite($fp,$new);
fclose($fp);
$msg="您已经成功将更改了专题顺序";
$turn_page="spe.php";
error_1($msg,$turn_page);
exit;
}
}
///////////////////以下是修改专题//////////////////////////////////
if ($act=="delmod" and $work=="modify") {
$new_name=trim($new_name);
$new_name=htmlspecialchars($new_name);
$new_dis=trim($new_dis);
$new_dis=htmlspecialchars($new_dis);
if ($target=="all"){
$msg="您还没有选择要修改的专题";
$turn_page="spe.php";
error_0($msg,$turn_page);
exit;
}
if (empty ($new_dis) or empty ($new_name)) {
$msg="您没有填写完整要修改的内容";
$turn_page="spe.php";
error_0($msg,$turn_page);
exit;
}
if (file_exists("../data/xq.cgi")){
$file_sort=file("../data/xq.cgi");
$file_count=count($file_sort)-1;
$fp=fopen("../data/xq.cgi","w");
flock($fp,3);
for ($i=0;$i<=$file_count;$i++){
$file_name=explode("|",$file_sort[$i]);
if ($file_name[1]==$target) {
fputs($fp,"$file_name[0]|$file_name[1]|$new_name|$new_dis|$file_name[4]|$file_name[5]||\n");
$old_name=$file_name[2]; }
else
fputs($fp,$file_sort[$i]);
}
fclose ($fp);
$msg="您已经成功将 $old_name 分类修改为 $new_name";
$turn_page="spe.php";
error_1($msg,$turn_page);
exit;
}
}
//////////////////以下是删除一个专题///////////////////////////////
if ($act=="delmod" and $work=="delete") {
if ($target=="all"){
$msg="您还没有选择要删除的专题";
$turn_page="spe.php";
error_0($msg,$turn_page);
exit;
}
$file_sort=file("../data/xq.cgi");
$file_count=count($file_sort)-1;
$fp=fopen("../data/xq.cgi","w");
flock($fp,3);
for ($i=0;$i<=$file_count;$i++){
$file_name=explode("|",$file_sort[$i]);
if ($target==$file_name[1]){
$type_or=$file_name[0];
$type_orname=$file_name[2];
continue;
}
fputs($fp,$file_sort[$i]);
}
fclose ($fp);
@unlink("../data/spe/$target.spe");
//////////////////////
if ($type_or){
$file_hot=file("../data/xq.php");
$file_hot_count=count($file_hot)-1;
$fp_hot=fopen("../data/xq.php","w");
flock($fp_hot,3);
for ($i=0;$i<=$file_hot_count;$i++){
$file_hot_code=explode("|",$file_hot[$i]);
if ($type_or===$file_hot_code[1]) {
$new_file =$file_hot_code[5]-1;
fwrite($fp_hot,$file_hot_code[0]."|".$file_hot_code[1]."|".$file_hot_code[2]."|".$file_hot_code[3]."|".$file_hot_code[4]."|".$new_file."|"."|"."\n");}
else
fwrite($fp_hot,$file_hot_code[0]."|".$file_hot_code[1]."|".$file_hot_code[2]."|".$file_hot_code[3]."|".$file_hot_code[4]."|".$file_hot_code[5]."|".$file_hot_code[6]."|".$file_hot_code[7]);
}
fclose($fp_hot);
//////////////////////
$msg="您成功删除专题:$type_orname";
$turn_page="spe.php";
error_1($msg,$turn_page);
exit;
}
}
?>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?