📄 addarticle.php
字号:
<?php
!$_SERVER['PHP_SELF'] && $_SERVER['PHP_SELF']=$_SERVER['SCRIPT_NAME'];
substr($_SERVER['PHP_SELF'],-9,-4)!=='admin' && exit('Forbidden');
require_once(R_P.'cache/set.php');
require_once(R_P.'cache/sortcache.php');
if(!empty($_GET['do'])) {
if($_GET['do']=='add') {
$sid=$_POST['sid'];
$title_color=$_POST['title_color'];
$title_extra=$_POST['title_extra'];
$subject=$_POST['subject'];
$author=$_POST['author'];
$rs=get_one("SELECT uid FROM duoxun_members WHERE username='$author'");
$authorid=$rs['uid'];
$itfrom=$_POST['itfrom'];
$topped=$_POST['topped'];
$ifshow=$_POST['ifshow'];
$ifcommect=$_POST['ifcommect'];
$commect_check=$_POST['commect_check'];
$postdate=$timestamp;
$ipfrom=cvipfrom($onlineip);
$ipfrom=str_replace("\n","",$ipfrom);
$content=$_POST['content'];
query("INSERT INTO duoxun_subject (sid,title_color,title_extra,author,authorid,itfrom,subject,topped,ifshow,postdate,userip,ipfrom,ifcommect,commect_check) VALUES ('$sid','$title_color','$title_extra','$author','$authorid','$itfrom','$subject','$topped','$ifshow','$postdate','$userip','$ipfrom','$ifcommect','$commect_check')");
$aid=insert_id();
$pid=empty($_GET['pid']) ? 1 : $_GET['pid'];
$p_id=$pid+1;
query("INSERT INTO duoxun_content (aid,pid,content) VALUES ('$aid','$pid','$content')");
if($set['ifhtml']=='1') {
$query=query("SELECT * FROM duoxun_content WHERE aid='$aid' ORDER BY pid ASC");
while($rs=fetch_array($query)) {
$catedb[]=$rs;
}
if(count($catedb)<=1) {
$fenye='';
$content=$catedb[0]['content'];
ob_start();
include(R_P.$tplpath.'/readtpl.htm');
writeover(R_P.$sid.'_'.$aid.'.html',ob_get_contents(),'rb+',0);
ob_end_clean();
@chmod(R_P.$sid.'_'.$aid.'.html',0777);
unset($catedb);
} elseif(count($catedb)>1) {
foreach($catedb as $key=>$cate) {
$key++;
if($key==1) {
$fenye='页码:<b><a href="'.$sid.'_'.$aid.'.html">'.$key.'</a></b>|';
for($i=2;$i<count($catedb)+1;$i++) {
$fenye.="<a href=".$sid."_".$aid."_".$i.".html>".$i."</a>|";
}
$content=$cate['content'];
ob_start();
include(R_P.$tplpath.'/readtpl.htm');
writeover(R_P.$sid.'_'.$aid.'.html',ob_get_contents(),'rb+',0);
ob_end_clean();
@chmod(R_P.$sid.'_'.$aid.'.html',0777);
} else {
$fenye='页码:<a href="'.$sid.'_'.$aid.'.html">1</a>|';
for($i=2;$i<count($catedb)+1;$i++) {
$page=$i==$key ? '<b>'.$i.'</b>' : $i;
$fenye.="<a href=".$sid."_".$aid."_".$i.".html>".$page."</a> |";
}
$content=$cate['content'];
ob_start();
include(R_P.$tplpath.'/readtpl.htm');
writeover(R_P.$sid.'_'.$aid.'_'.$key.'.html',ob_get_contents(),'rb+',0);
ob_end_clean();
@chmod(R_P.$sid.'_'.$aid.'_'.$key.'.html',0777);
}
}
unset($catedb);
}
}
echo "<script language=\"javascript\">alert(\"文章添加成功\")</script>";
echo "<meta http-equiv='refresh' content='0;url=admin.php?job=addarticle&show=add&id=$aid&pid=$p_id'>";
exit;
}
}
if(!empty($_GET['show'])) {
if($_GET['show']=='add') {
$aid=$_GET['id'];
$pid=$_GET['pid'];
}
}
if(!empty($_GET['add'])) {
if($_GET['add']=='pid') {
$aid=$_POST['aid'];
$pid=$_POST['pid'];
$content=$_POST['content'];
$query=query("INSERT INTO duoxun_content (aid,pid,content) VALUES ('$aid','$pid','$content')");
if($set['ifhtml']=='1') {
$query=query("SELECT * FROM duoxun_content WHERE aid='$aid' ORDER BY pid ASC");
while($rs=fetch_array($query)) {
$catedb[]=$rs;
}
if(count($catedb)<=1) {
$fenye='';
$content=$catedb[0]['content'];
ob_start();
include(R_P.$tplpath.'/readtpl.htm');
writeover(R_P.$sid.'_'.$aid.'.html',ob_get_contents(),'rb+',0);
ob_end_clean();
@chmod(R_P.$sid.'_'.$aid.'.html',0777);
unset($catedb);
} elseif(count($catedb)>1) {
foreach($catedb as $key=>$cate) {
$key++;
if($key==1) {
$fenye='页码:<b><a href="'.$sid.'_'.$aid.'.html">'.$key.'</a></b>|';
for($i=2;$i<count($catedb)+1;$i++) {
$fenye.="<a href=".$sid."_".$aid."_".$i.".html>".$i."</a>|";
}
$content=$cate['content'];
ob_start();
include(R_P.$tplpath.'/readtpl.htm');
writeover(R_P.$sid.'_'.$aid.'.html',ob_get_contents(),'rb+',0);
ob_end_clean();
@chmod(R_P.$sid.'_'.$aid.'.html',0777);
} else {
$fenye='页码:<a href="'.$sid.'_'.$aid.'.html">1</a>|';
for($i=2;$i<count($catedb)+1;$i++) {
$page=$i==$key ? '<b>'.$i.'</b>' : $i;
$fenye.="<a href=".$sid."_".$aid."_".$i.".html>".$page."</a> |";
}
$content=$cate['content'];
ob_start();
include(R_P.$tplpath.'/readtpl.htm');
writeover(R_P.$sid.'_'.$aid.'_'.$key.'.html',ob_get_contents(),'rb+',0);
ob_end_clean();
@chmod(R_P.$sid.'_'.$aid.'_'.$key.'.html',0777);
}
}
unset($catedb);
}
}
if($query) {
$pid=$pid+1;
echo "<script language=\"javascript\">alert(\"文章添加成功\")</script>";
echo "<meta http-equiv='refresh' content='0;url=admin.php?job=addarticle&show=add&id=$aid&pid=$pid'>";
exit;
} else {
echo "<script language=\"javascript\">alert(\"文章添加失败请重试!\")</script>";
echo "<meta http-equiv='refresh' content='0;url=admin.php?job=addarticle&show=pid&id=$aid&pid={$_POST['pid']}'>";
exit;
}
}
}
require_once template('addarticle','admin');
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -