📄 news.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');
if(empty($_GET['do'])) {
if(strpos($_SERVER['QUERY_STRING'],'&order=aid')) {
$aid='admin.php?'.$_SERVER['QUERY_STRING'];
$hits='admin.php?'.str_replace('&order=aid','&order=hits',$_SERVER['QUERY_STRING']);
} elseif(strpos($_SERVER['QUERY_STRING'],'&order=hits')) {
$aid='admin.php?'.str_replace('&order=hits','&order=aid',$_SERVER['QUERY_STRING']);
$hits='admin.php?'.$_SERVER['QUERY_STRING'];
} else {
$aid='admin.php?'.$_SERVER['QUERY_STRING'].'&order=aid';
$hits='admin.php?'.$_SERVER['QUERY_STRING'].'&order=hits';
}
$order=empty($_GET['order']) ? 'aid' : $_GET['order'];
$perpage=35;
$rs=get_one("SELECT COUNT(*) AS count FROM duoxun_news WHERE topped=0");
$rs=$rs['count'];
$pages=ceil($rs/$perpage);
if(empty($_GET['page']) || $_GET['page']<1) {
$page=1;
$start=0;
} elseif($_GET['page']>$pages) {
$page=$pages;
$start=($page-1)*$perpage;
} else {
$page=$_GET['page'];
$start=($page-1)*$perpage;
}
$query=query("SELECT * FROM duoxun_news WHERE topped<>0 ORDER BY topped ASC");
while($rs=fetch_array($query)) {
$topped[]=$rs;
}
$topnum=!empty($topped) ? count($topped) : 0;
$query=query("SELECT * FROM duoxun_news WHERE topped=0 ORDER BY $order DESC LIMIT $start,$perpage");
while($rs=fetch_array($query)) {
$catedb[]=$rs;
}
$rs=get_one("SELECT COUNT(*) AS count FROM duoxun_news WHERE topped=0");
$num=$rs['count'];
$mpurl='admin.php?job=news';
$fenye=admin_fenye($num,$perpage,$page,$mpurl,0);
$u='admin.php?'.$_SERVER['QUERY_STRING'];
setcookie('u','',$timestamp-86400);
setcookie('u',$u,$timestamp+86400);
}
if(!empty($_GET['do'])) {
if($_GET['do']==='add') {
$postdate=$_POST['postdate'];
$topped=$_POST['topped'];
$author=$_POST['author'];
$itfrom=$_POST['itfrom'];
$subject=$_POST['subject'];
$content=$_POST['content'];
if($subject=='' || $content=='') {
header("Location: job.php?job=news&add=null");
} else {
$query=query("INSERT INTO duoxun_news (postdate,topped,author,itfrom,title_color,title_extra,subject,content) VALUES ('$postdate','$topped','$author','$itfrom','$title_color','$title_extra','$subject','$content')");
if($set['ifhtml']=='1') {
$aid=insert_id();
require_once(R_P.'cache/set.php');
require_once(R_P.'cache/template.php');
require_once(R_P.'cache/sort_cache.php');
!file_exists(R_P.'cache/read_top.php') ? touch(R_P.'cache/read_top.php') : $read_top=readover(R_P.'cache/read_top.php');
!file_exists(R_P.'cache/read_bottom.php') ? touch(R_P.'cache/read_bottom.php') : $read_bottom=readover(R_P.'cache/read_bottom.php');
$sql="SELECT * FROM duoxun_news WHERE aid='$aid'";
$rs=get_one($sql);
$subject=$rs['subject'];
$href_g=($set['ifhtml']==1 && file_exists(R_P.'news.html')) ? R_P.'news.html' : 'list.php?type=news&id='.$aid;
$from=$rs['itfrom'];
$author=$rs['author'];
$date=getdate($rs['postdate']);
$date=$date['year'].'/'.$date['mon'].'/'.$date['mday'];
$hits=$rs['hits'];
$content=$rs['content'];
$guide=$subject.' - '.$set['news'].' - ';
$guidee='<a href="'.$href_g.'">'.$set['news'].'</a> > '.$subject;
$fenye='';
ob_start();
include(R_P.$tplpath.'/readtpl.htm');
writeover("$aid.html",ob_get_contents(),"rb+",0);
ob_end_clean();
chmod("$aid.html",0777);
}
if($query) {
header("Location: job.php?job=news&add=success");
} else {
header("Location: job.php?job=news&add=fail");
}
}
} elseif($_GET['do']==='order') {
foreach($_POST as $key=>$value) {
query("UPDATE duoxun_news SET topped='$value' WHERE aid='$key'");
}
header("Location: job.php?job=news&order=success");
}
}
require_once template('news','admin');
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -