Browse Source

0.9.34

pull/180/head
xiaoz 8 months ago
parent
commit
17644ac77a
  1. 11
      controller/admin.php
  2. 4
      controller/index.php
  3. 10
      controller/init.php

11
controller/admin.php

@ -23,6 +23,12 @@ check_auth($site_setting['user'],$site_setting['password']);
$version = new_get_version(); $version = new_get_version();
$page = empty($_GET['page']) ? 'index' : $_GET['page']; $page = empty($_GET['page']) ? 'index' : $_GET['page'];
// 正则判断page,只能允许字符+数字和下划线组合
$pattern = "/^[a-zA-Z0-9_\/]+$/";
if ( !preg_match($pattern,$page) ) {
exit('非法请求!');
}
//如果是后台首页,则判断是否是手机访问,并决定是否跳转到手机版页面 //如果是后台首页,则判断是否是手机访问,并决定是否跳转到手机版页面
if( $page == 'index' ) { if( $page == 'index' ) {
@ -323,6 +329,11 @@ function check_auth($user,$password){
} }
} }
// 判断$page文件是否存在,不存在,则终止执行
$full_page_path = 'templates/admin/'.$page;
if( !file_exists($full_page_path) ) {
exit("file does not exist!");
}
// 载入前台首页模板 // 载入前台首页模板
require('templates/admin/'.$page); require('templates/admin/'.$page);

4
controller/index.php

@ -9,6 +9,8 @@ $site = unserialize($site);
// 获取链接数量,默认为30 // 获取链接数量,默认为30
$link_num = empty( $site['link_num'] ) ? 30 : intval($site['link_num']); $link_num = empty( $site['link_num'] ) ? 30 : intval($site['link_num']);
//如果已经登录,获取所有分类和链接 //如果已经登录,获取所有分类和链接
// 载入辅助函数 // 载入辅助函数
require('functions/helper.php'); require('functions/helper.php');
@ -77,6 +79,8 @@ if( is_login() ){
} }
//如果没有登录,只获取公有链接 //如果没有登录,只获取公有链接
else{ else{
// 检查分类是否全私有,如果是,则跳转到登录界面
check_all_cat();
//查询分类目录 //查询分类目录
$categorys = []; $categorys = [];
//查询一级分类目录,分类fid为0的都是一级分类 //查询一级分类目录,分类fid为0的都是一级分类

10
controller/init.php

@ -66,6 +66,16 @@ function init($data){
if( empty($data['username']) || empty($data['password']) ) { if( empty($data['username']) || empty($data['password']) ) {
err_msg(-2000,'用户名或密码不能为空!'); err_msg(-2000,'用户名或密码不能为空!');
} }
// 正则验证用户名
$u_patt = '/^[0-9a-z]{3,32}$/';
if( !preg_match($u_patt,$data['username']) ) {
err_msg(-2000,'用户名格式不正确!');
}
// 正则验证密码
$p_patt = '/^[0-9a-zA-Z!@#%^*.()]{6,16}$/';
if( !preg_match($p_patt,$data['password']) ) {
err_msg(-2000,'密码格式不正确!');
}
$config_file = "data/config.php"; $config_file = "data/config.php";
//检查配置文件是否存在,存在则不允许设置 //检查配置文件是否存在,存在则不允许设置
if( file_exists($config_file) ) { if( file_exists($config_file) ) {

Loading…
Cancel
Save