1 Star 0 Fork 4

六块砖/sxlog

forked from 冰优/sxlog 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
index.php 25.24 KB
一键复制 编辑 原始数据 按行查看 历史
冰优 提交于 2022-11-04 15:44 . 优化代码
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846
<?php
//作者:雪落
//时间:2022-01-10
//-------------------------------------------------
header('Content-Type: text/html; charset=utf-8');
date_default_timezone_set('PRC');
$_SERVER['_memory_usage'] = memory_get_usage();
$timeStart = microtime(true);
session_start();
//根目录
define('ROOT',str_replace('\\','/',__DIR__).'/');
//数据目录
define('DB',ROOT.'db/');
//类库目录
define('LIB',ROOT.'lib/');
//扩展目录
define('EXT',ROOT.'ext/');
//保存登陆状态
define('LOGIN', isset($_SESSION['login'])?$_SESSION['login']:0);
//版本
define('V','1.0.8');
//检测数据库是否可写
!is_writeable(DB) AND exit('db文件夹无写入权限,请检查!');
//引入库
include LIB.'function.php';
include LIB.'common.php';
include LIB.'fk.class.php';
include LIB.'tpl.class.php';
//配置信息
$conf = db('conf');
define('CONF', $conf);
//0:线上模式(无错)1:调试模式(无错+日志)2:开发模式(报错+日志)
define('DEBUG', $conf['debug']);
//伪静态url
$document_root = str_replace('\\','/',$_SERVER['DOCUMENT_ROOT']);
$home = substr(ROOT,substr($document_root,-1)==='/'?strlen($document_root)-1:strlen($document_root));
define('HOME',$home ? $home : '/');
define('URL',HOME.($conf['rewrite']?'':'?'));
function_exists('ini_set') AND ini_set('display_errors', DEBUG ? '1' : '0');
error_reporting(DEBUG ? E_ALL : 0);
DEBUG AND set_error_handler('errorHandle', -1);
//缓存信息
$_SESSION['ip'] = isset($_SESSION['ip']) ? $_SESSION['ip'] : ip();
$_SESSION['views'] = isset($_SESSION['views']) ? $_SESSION['views'] : [];
$_SESSION['isVisit'] = isset($_SESSION['isVisit']) ? $_SESSION['isVisit'] : 0;
$_SESSION['commentCount'] = isset($_SESSION['commentCount']) ? $_SESSION['commentCount'] : 0;
$_SESSION['loginCount'] = isset($_SESSION['loginCount']) ? $_SESSION['loginCount'] : 0;
$_SESSION['vcode'] = isset($_SESSION['vcode']) ? $_SESSION['vcode'] : 0;
//请求方式:POST、GET
$method = $_SERVER['REQUEST_METHOD'];
//是否为ajax请求
$ajax = (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower(trim($_SERVER['HTTP_X_REQUESTED_WITH'])) == 'xmlhttprequest');
//当前主题模板绝对路径
define('TPLPATH',ROOT.'tpl/'.$conf['tpl'].'/');
//当前主题模板相对路径
define('TPL',HOME.'tpl/'.$conf['tpl'].'/');
//当前主题样式路径
define('TPL_STYLE',HOME.'tpl/'.$conf['tpl'].'/style/');
//公共样式路径
define('LIB_STYLE',HOME.'lib/style/');
//当前网址
$host = (isHttps() ? 'https' : 'https').'://'.$_SERVER['SERVER_NAME'].HOME;
//前端页面
$page = get(0,'str','index');
//后端页面
$adminPage = get(1,'str','index');
//时间戳
$time = time();
//hook钩子名称预设
//前端
$hook=['head-header'=>[],'head-footer'=>[],'css'=>[],'script'=>[],'body-header'=>[],'body-footer'=>[],'editor'=>[]];
//后端
foreach ([
//头部导航菜单
'header-menu-1','header-menu-2','header-menu-3',
//菜单
'menu-header','menu-footer','menu-top','menu-bottom','menu-1','menu-2','menu-3',
//首页
'index-header','index-footer','index-top','index-bottom','index-info-top','index-info-bottom','index-system','index-system-top','index-system-bottom','index-news','index-server','index-server-top','index-server-bottom',
//文章管理
'article-header','article-footer','article-bottom','article-sidebar-top','article-sidebar-bottom','article-menu-header','article-menu-footer','article-menu-left-top','article-menu-left-bottom','article-menu-right-top','article-menu-right-bottom','article-list-operate',
//文章添加
'article.create-top','article.create-bottom','article.create-form1','article.create-form2','article.create-form3',
//文章编辑
'article.editor-top','article.editor-bottom','article.editor-form1','article.editor-form2','article.editor-form3',
//导航设置
'navbar-header','navbar-footer',
//友情链接
'link-header','link-footer',
//设置
'setting-header','setting-footer','setting-top','setting-bottom','setting-1','setting-2',
//主题
'tpl-header','tpl-footer','tpl-top','tpl-bottom','tpl-list','tpl-operate1','tpl-operate2','tpl-operate3',
//扩展
'ext-header','ext-footer','ext-top','ext-bottom','ext-tip','ext-operate1','ext-operate2','ext-operate3','ext-tip-bottom',
//访客
'visit-header','visit-footer','visit-top','visit-bottom','visit-tip','visit-tip-bottom',
//错误
'error-header','error-footer','error-top','error-bottom','error-tip','error-tip-bottom',
//登录
'login-header','login-footer','login-1','login-2','login-3'
] as $extTag) {
$hook[$extTag] = [];
}
//模板编译
$tpl = new Tpl([
'path' => '/tpl/',
'name' => $conf['tpl'],
'compile' => $conf['compile'],
]);
//获取配置信息
if($ajax){
if(post('getConf','int')){
ajax(0,['HOME'=>HOME,'URL'=>URL]);
}
}
//检测安装
if(!$conf['install']){
if(!extension_loaded('curl')) exit('请开启curl扩展!');
if(!extension_loaded('gd')) exit('请开启gd扩展!');
if($page == 'install'){
if($method == 'POST'){
$conf['title'] = post('title','str',$conf['title']);
$conf['name'] = post('name','str',$conf['name']);
$conf['intro'] = post('intro','str',$conf['intro']);
$conf['password'] = post('password','str',$conf['password']);
$conf['install'] = post('install','bool',$conf['install']);
if($conf['password']){
$tpl->compile();
dbSave('conf',$conf);
}
jump();
}
}
include LIB.'install.php';
exit;
}
//ip黑名单检测
$ip = $_SESSION['ip'];
if($conf['blacklist']){
$blacklist = explode(' ',$conf['blacklist']);
$error = '你的IP被系统拉入黑名单,如需解除,请联系管理员!';
foreach($blacklist as $_ip){
if(strpos($_ip,'/') !== false){
preg_match($_ip,$ip) AND exit($error);
}else{
$ip == $_ip AND exit($error);
}
}
}
//记录ip访问
if(!$_SESSION['isVisit'] && $ip){
$_SESSION['isVisit'] = 1;
$visit = db('visit');
if(isset($visit[$ip]) && date('Y-m-d',$visit[$ip]) !== date('Y-m-d')) unset($visit[$ip]);
//更新ip信息
$visit[$ip]=$time;
dbSave('visit',$visit);
//更新浏览量
$conf['views'] += 1;
dbSave('conf',$conf);
}
//文章列表
$articleList = db('article',[],['time'=>1]);
//分类标签
$tagList = db('tag');
//导航链接
$navbarList = initLink($conf['navbar']);
//友情链接
$linkList = initLink($conf['link']);
//加载已安装的扩展
$extList = db('ext');
foreach ($extList as $v) {
$commonPath = EXT.$v.'/common.php';
if(is_file($commonPath)) include $commonPath;
}
foreach ($extList as $v) {
$mainPath = EXT.$v.'/main.php';
if(is_file($mainPath)) include $mainPath;
}
//加载模板中的公共文件
$mainPath = TPLPATH.'main.php';
if(is_file($mainPath)) include $mainPath;
//页面路由
switch($page){
//验证码
case 'vcode':
include LIB.'vcode.class.php';
$code = new vcode($conf['vcode']['width'],$conf['vcode']['height'],$conf['vcode']['length']);
$_SESSION['vcode'] = $code->getCode();
echo $code->outimg();
exit;
//首页
case 'index':
$pageNum = get(1,'int',1);
$pageSize = $conf['article']['paging'];
$article = getArticle(LOGIN?[]:['private'=>0],['time'=>1,'top'=>1],'index/{page}',$pageNum,$pageSize);
include $tpl->view('index');
break;
//分类标签
case 'tag':
$tag = get(1,'urldecode');
$articleList = getTag($tag);
$cond = ['tag'=>['IN'=>$tag]];
if(!LOGIN)$cond['private'] = 0;
$pageNum = get(2,'int',1);
$pageSize = $conf['article']['paging'];
$article = getArticle($cond,[],'tag/'.$tag.'/{page}',$pageNum,$pageSize);
include $tpl->view(is_file(TPLPATH.'tag.php')?'tag':'index');
break;
//搜索页
case 'search':
$searchName = post('name','urldecode');
$searchName AND jump('search&name='.$searchName);
$searchName = get('name','urldecode');
$cond = ['title'=>['LIKE'=>$searchName]];
if(!LOGIN) $cond['private'] = 0;
$pageNum = get(1,'int',1);
$pageSize = $conf['article']['paging'];
$article = getArticle($cond,['time'=>1,'top'=>1],'search/{page}&name='.$searchName,$pageNum,$pageSize);
include $tpl->view(is_file(TPLPATH.'search.php')?'search':'index');
break;
//评论
case 'comment':
$action = get(1,'str');
//删除留言
if($action == 'delete'){
if(!LOGIN) jump('login');
$articleId = get(2);
delComment('comment/'.$articleId,get(3,'int',0));
commentsInit($articleId);
jump($articleId);
}
//添加留言
if($method == 'POST'){
$vcode = post('vcode','str');
if($conf['vcode']['open'] && (!$vcode || strtolower($_SESSION['vcode']) !== strtolower($vcode))){
prompt('验证码不正确');
}
if($_SESSION['commentCount'] > $conf['comment']['restrict']){
prompt('每日评论次数不能超过'.$conf['comment']['restrict'].'次哦!');
}
$pid = post('pid','int',0);
$content = trim(post('content','stripTags'));
if(mb_strlen($content) > 2000){
prompt('留言字数不能大于2000');
}
$pageName = post('page');
$path = $pageName ? 'comment/'.$pageName : 'comment';
if($pageName){
if(!isset($articleList[$pageName]) || !$articleList[$pageName]['comment']) prompt('非法操作');
$path = 'comment/'.$pageName;
}else{
$path = 'comment';
}
$comment = db($path);
$id = $comment ? $comment[count($comment)-1]['id'] + 1 : 1;
if(!empty($content)){
$arr = ['id' => $id,'pid' => $pid,'admin' => LOGIN,'content' => $content,'ip' => $ip,'time' => $time];
$selComment = arrWhere($comment,['ip'=>$ip,'content'=>$content,'time'=>['>'=>strtotime(date('Y-m-d',time()))]]);
if(count($selComment) > 2) prompt('非法操作!');
$comment[] = $arr;
dbSave($path,$comment);
$conf['comment']['count'] += 1;
dbSave('conf',$conf);
$_SESSION['commentCount'] += 1;
unset($_SESSION['vcode']);
}else{
prompt('留言内容不能为空');
}
commentsInit($pageName);
jump($pageName);
}
break;
//上传
case 'upload':
if(!LOGIN) ajax(1,'请登录');
$path = post('path','');
include LIB.'upload.class.php';
//参数(input控件name名称 , 文件上传路径)
$up = new Upload('file','db/upload/'.$path);
//设置上传文件的最大尺寸 1=1M
$up->setMaxSize(100);
$up->multiFile();
$error = $up->getErrorMsg();
$error AND ajax(1,is_array($error) ? $error[0] : $error);
$fileList = $up->getUploadFiles();
ajax(0,$fileList);
break;
//导入
case 'import':
if(!LOGIN) ajax(1,'请登录');
if(isset($_FILES['file']) && $_FILES['file']){
if(pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION) == 'sx'){
unsx($_FILES['file']['tmp_name']);
unlink($_FILES['file']['tmp_name']);
ajax(0,'导入成功');
}
}
ajax(1,'导入失败');
break;
//提示
case 'prompt':
if(empty($_SESSION['prompt'])) jump();
$prompt = $_SESSION['prompt']['text'];
$url = $_SESSION['prompt']['url'];
include $tpl->view($page);
unset($_SESSION['prompt']);
break;
//登录
case 'login':
if(is_file(TPLPATH.'login.php')){
include $tpl->view('login');
}else{
jump('admin/login');
}
break;
//后台
case 'admin':
$adminPage = get(1,'string','index');
//模板编译
$adminTpl = new Tpl([
'path' => '/lib/',
'name' => 'admin',
'compile' => $conf['compile'],
]);
//登录
if($adminPage == 'login'){
$conf['title'] = $conf['title'].'-登录';
if($method == 'POST'){
if($_SESSION['loginCount'] > 9) prompt('密码错误次数太多,请好好想想哦!');
$password = trim(post('password'));
if(!empty($password)){
if($password === (string)$conf['password']){
$_SESSION['login'] = 1;
}else{
$_SESSION['loginCount'] += 1;
prompt('密码错误');
}
}else{
prompt('密码不能为空');
}
jump();
}
include $adminTpl->view('login');
exit;
}
//提示
if($adminPage == 'prompt'){
if(empty($_SESSION['prompt'])) jump('admin');
$prompt = $_SESSION['prompt']['text'];
$url = $_SESSION['prompt']['url'];
include $adminTpl->view('prompt');
unset($_SESSION['prompt']);
exit;
}
if(!LOGIN) jump('login');
//后台路由
switch($adminPage){
//登出
case 'demo':
$res = curl('https://xueluo.cn/api/getVersion');
echo $res;
exit;
break;
//登出
case 'logout':
session_destroy();
jump();
break;
//查看phpinfo
case 'phpinfo':
print_r(phpinfo());
exit;
//查看server
case 'server':
echo '<!DOCTYPE html><html lang="zh-Hans"><head><meta http-equiv="Content-Type" content="text/html" charset="UTF-8"/><title>server</title></head><body style="white-space:pre-wrap;">';
print_r($_SERVER);
echo '</body></html>';
exit;
//检查更新
case 'checkUpdate':
ajax(0,checkUpdate());
break;
//数据库版本更新
case 'dbUpdate':
$data = curl('https://xueluo.cn/api/getDb');
if($data){
dbSync(type($data,'array'));
$conf = db('conf');
delCompile();
ajax(0,'更新成功');
}
ajax(1,'更新失败');
break;
//核心文件更新
case 'update':
$data = curl('https://xueluo.cn/api/getSxlog');
if($data){
unsx($data);
$list = db('list');
if(!$conf['db'] || $conf['db']['version'] != $list['#version']) dbSync($list);
delCompile();
ajax(0,'更新成功');
}
ajax(1,'更新失败');
break;
//首页
case 'index':
$_SESSION['updateAlert'] = isset($_SESSION['updateAlert']) ? 0 : 1;
include $adminTpl->view('index');
break;
//文章管理
case 'article':
$type = get(2,'str');
//分类标签
if($type == 'tag'){
$tag = get(3,'urldecode');
$articleList = getTag($tag);
$pageNum = get(4,'int',1);
$pageSize = $conf['article']['paging'];
$article = getArticle(['tag'=>['IN'=>$tag]],[],'admin/article/tag/'.$tag.'/{page}',$pageNum,$pageSize);
include $adminTpl->view('article');
}
//批量删除
elseif($type == 'delete'){
$id = post('id');
if(!$id) {
$id = get(3,'string');
$id = $id ? [$id] : 0;
}
if($id){
foreach ($id as $v) {
if(isset($articleList[$v])){
delContentFiles(db('article/'.$v,false));
$conf['article']['count'] -= 1;
unset($articleList[$v]);
delFile(dbPath('article/'.$v));
delFile(dbPath('comment/'.$v));
}
}
dbSave('conf',$conf);
dbSave('article',$articleList);
tagInit();
ajax(0,'删除成功');
}
ajax(1,'删除失败');
}
//移动分类
elseif($type == 'move'){
$id = post('id');
$tag = post('tag','str');
if($id && $tag){
foreach ($id as $v) {
if(isset($articleList[$v])){
$articleList[$v]['tag'] = $tag ? [$tag] : [];
}
}
dbSave('article',$articleList);
tagInit();
ajax(0,'操作成功');
}
ajax(1,'操作失败');
}
//创建
elseif($type == 'create'){
if($method == 'POST'){
$title = trim(post('title','stripTags'));
$content = trim(post('content'));
$id = trim(post('name'));
//是否为自定义url
$id = empty($id)?'T'.$time:$id;
if(isset($articleList[$id])) prompt('已存在该URL名称');
$tag = post('tag','trim',[]);
if($tag){
$tag = preg_replace('/\s+/',' ',$tag);
$tag = explode(' ', $tag);
}
$path = dbPath('article/'.$id);
if(!empty($content)){
$intro = post('intro','string');
if(!$intro){
$fk = new fk($content);
$html = preg_replace('/<[^>]+>/i','',$fk->html);
$html = preg_replace('/[\r\n]+/','',$html);
$intro = mb_substr($html,0,$conf['brief'],'utf-8');
}
//获取第一张图片
preg_match('/(\[img (.*?\.(jpg|jpeg|png|gif|bmp|tif)).*?\])/i', $content, $img);
$img = $img ? $img[2] : false;
$top = post('top','int',0);
$private = post('private','int',0);
$comment = post('comment','int',0);
if(save($path,$content)){
$articleList[$id] = [
'id'=>$id,
'title'=>$title,
'intro'=>$intro,
'img'=>$img,
'time'=>$time,
'top'=>$top,
'private'=>$private,
'views'=>0,
'comment'=>$comment,
'comments'=>0,
'tag'=>$tag
];
$conf['article']['count'] += 1;
dbSave('conf',$conf);
if(!dbSave('article',$articleList)){
delFile($path);
}
tagInit();
}
}
jump('admin/article');
}
include $adminTpl->view('article.create');
}
//编辑
elseif($type == 'editor'){
$id = get(3,'str');
$article = getArticle(['id'=>$id]);
if($article['list']){
$article = $article['list'][$id];
}else{
prompt('没有该数据');
}
$article['content'] = db('article/'.$id,false);
if($method == 'POST'){
$title = trim(post('title','stripTags'));
$content = trim(post('content'));
$path = dbPath('article/'.$id);
if(!empty($content)){
$intro = post('intro','string');
if(!$intro){
$fk = new fk($content);
$html = preg_replace('/<[^>]+>/i','',$fk->html);
$html = preg_replace('/[\r\n]+/','',$html);
$intro = mb_substr($html,0,$conf['brief'],'utf-8');
}
//获取第一张图片
$img = false;
if(strpos($content,'[!img]') === false){
preg_match('/img (src\s*=\s*[\'|"]+)?(.*?\.(jpg|jpeg|png|gif|bmp|tif))/i', $content, $img);
$img = $img ? $img[2] : false;
}
//判断编辑的文档是不是为上个文档的url,不是的话,删除旧有的数据,建立新数据
$name = trim(post('name'));
$newId = empty($name)?'T'.$time:$name;
//从内容中提取时间
preg_match('/\[\s*时间\s*\]\s*([\d\-\:\s]+)/i', $content, $match);
$time = $article['time'];
$top = post('top','int',0);
$private = post('private','int',0);
$comment = post('comment','int',0);
$views = $articleList[$id]['views'];
$comments = $articleList[$id]['comments'];
$tag = post('tag','trim',[]);
if($tag){
$tag = preg_replace('/\s+/',' ',$tag);
$tag = explode(' ', $tag);
}
if($newId != $id){
delFile($path);
unset($articleList[$id]);
$path = dbPath('article/'.$newId);
//重命名comment文件
include LIB.'file.util.class.php';
$util = new fileUtil();
$util->rename(DB.'comment/'.$id.'.php',$newId.'.php');
}
if(save($path,$content)){
$articleList[$newId] = [
'id'=>$newId,
'title'=>$title,
'intro'=>$intro,
'img'=>$img,
'time'=>$time,
'top'=>$top,
'private'=>$private,
'views'=>$views,
'comment'=>$comment,
'comments'=>$comments,
'tag'=>$tag
];
if(!dbSave('article',$articleList)){
delFile($path);
prompt('编辑失败');
}
tagInit();
}else{
prompt('编辑失败');
}
}else{
prompt('内容不能为空');
}
jump('admin/article');
}
include $adminTpl->view('article.editor');
}else{
$pageNum = get(2,'int',1);
$pageSize = $conf['article']['paging'];
$article = getArticle(LOGIN?[]:['private'=>0],['time'=>1,'top'=>1],'admin/article/{page}',$pageNum,$pageSize);
include $adminTpl->view('article');
}
break;
//导航设置
case 'navbar':
if($method == 'POST'){
$conf['navbar'] = post('navbar','str','');
dbSave('conf',$conf);
jump('admin/navbar');
}
include $adminTpl->view('navbar');
break;
//友情链接
case 'link':
if($method == 'POST'){
$conf['link'] = post('link','str','');
dbSave('conf',$conf);
jump('admin/link');
}
include $adminTpl->view('link');
break;
//基础设置
case 'setting':
$tplList = getTpl();
if($method == 'POST'){
$conf['title'] = post('title','str','');
$conf['name'] = post('name','str','');
$conf['intro'] = post('intro','str','');
$conf['mood'] = post('mood','str','');
$conf['key'] = post('key','str','');
$conf['desc'] = post('desc','str','');
$conf['brief'] = post('brief','int',0);
$conf['password'] = post('password','str',$conf['password']);
$compile = post('compile','bool');
if($compile !== $conf['compile']){
$conf['compile'] = $compile;
delCompile();
}
$conf['debug'] = post('debug','int',$conf['debug']);
$rewrite = post('rewrite','bool');
if($rewrite !== $conf['rewrite']){
$conf['rewrite'] = $rewrite;
delCompile();
}
$conf['comment']['restrict'] = post('commentRestrict','int',$conf['comment']['restrict']);
$conf['comment']['paging'] = post('commentPaging','int',$conf['comment']['paging']);
$conf['article']['paging'] = post('articlePaging','int',$conf['article']['paging']);
$conf['vcode']['open'] = post('vcodeOpen','bool',false);
$conf['vcode']['width'] = post('vcodeWidth','int',80);
$conf['vcode']['height'] = post('vcodeHeight','int',32);
$conf['vcode']['length'] = post('vcodeLength','int',4);
$conf['icp'] = post('icp','str','');
$conf['views'] = post('views','int',0);
$conf['blacklist'] = post('blacklist','str','');
$conf['js'] = post('js','str','');
dbSave('conf',$conf);
jump('admin/setting');
}
include $adminTpl->view('setting');
break;
//编译模板
case 'compile':
delCompile();
jump('admin/tpl');
break;
//主题管理
case 'tpl':
$tpl = getTpl();
$tplPage = get(2,'str');
$tplId = get(3,'str');
if($tplId && isset($tpl['list'][$tplId])){
if($tplPage == 'install'){
$conf = db('conf');
$conf['tpl'] = $tplId;
dbSave('conf',$conf);
}
elseif($tplPage == 'delete'){
include LIB.'file.util.class.php';
$util = new fileUtil();
$util->delete(ROOT.'tpl/'.$tplId);
}
elseif($tplPage == 'download'){
$sx = sx(ROOT.'tpl/'.$tplId);
echo $sx;
exit;
}
jump('admin/tpl');
}
include $adminTpl->view('tpl');
break;
//扩展管理
case 'ext':
$ext = getExt();
$extPage = get(2,'str');
$extId = get(3,'str');
$extList = db('ext');
if($extId && isset($ext['list'][$extId])){
$extConfPath = EXT.$extId.'/conf.php';
$extConf = include $extConfPath;
if($extPage == 'install'){
if(!in_array($extId,$extList)){
$extList[] = $extId;
dbSave('ext',$extList);
$installPath = EXT.$extId.'/install.php';
if(is_file($installPath)) include $installPath;
}
}
elseif($extPage == 'uninstall'){
if(in_array($extId,$extList)){
array_splice($extList,array_search($extId,$extList),1);
dbSave('ext',$extList);
$uninstallPath = EXT.$extId.'/uninstall.php';
if(is_file($uninstallPath)) include $uninstallPath;
}
}
elseif($extPage == 'delete'){
include LIB.'file.util.class.php';
$util = new fileUtil();
$util->delete(EXT.$extId);
}
elseif($extPage == 'download'){
$sx = sx(EXT.$extId);
echo $sx;
exit;
}
jump('admin/ext');
}
include $adminTpl->view('ext');
break;
//访客
case 'visit':
if(get(2) == 'delete'){
dbSave('visit',[]);
jump('admin/visit');
}
$pageNum = get(2,'int',1);
$pageSize = 30;
$visit = getVisit('admin/visit/{page}', $pageNum, $pageSize);
include $adminTpl->view('visit');
break;
//错误日志
case 'error':
if(get(2) == 'delete'){
dbSave('error',[]);
jump('admin/error');
}
$pageNum = get(2,'int',1);
$pageSize = 30;
$error = getError([],['time'=>1],'admin/error/{page}', $pageNum, $pageSize);
include $adminTpl->view('error');
break;
//其它
default:
prompt('没有这个页面');
}
break;
//其它
default:
$id = get(0,'string');
if(isset($articleList[$id]) && $data = db('article/'.$id,false)){
if($articleList[$id]['private'] && !LOGIN){
prompt('游客无法访问私密文章,请登录!');
}
}else{
prompt('没有该数据');
}
$page = 'page';
$article = $articleList[$id];
$article['id'] = $id;
$article['tag'] = $articleList[$id]['tag'];
//网站描述和标题
$conf['desc'] = $article['intro'];
$conf['title'] = $conf['title'].'-'.$articleList[$id]['title'];
$fk = new fk($data);
$article['content'] = $fk->html;
//留言板
$pageNum = get(1,'int',1);
$pageSize = $conf['comment']['paging'];
$comment = getComment($id,[],[],$id.'/{page}',$pageNum,$pageSize);
//更新浏览量
if(!in_array($id,$_SESSION['views'])){
$_SESSION['views'][]=$id;
$articleList[$id]['views'] += 1;
dbSave('article',$articleList);
}
include $tpl->view('page');
}
?>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/liukuaizhuan/sxlog.git
git@gitee.com:liukuaizhuan/sxlog.git
liukuaizhuan
sxlog
sxlog
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385