Browse Source

0.9.34

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

11
controller/admin.php

@ -23,6 +23,12 @@ check_auth($site_setting['user'],$site_setting['password']); @@ -23,6 +23,12 @@ check_auth($site_setting['user'],$site_setting['password']);
$version = new_get_version();
$page = empty($_GET['page']) ? 'index' : $_GET['page'];
// 正则判断page,只能允许字符+数字和下划线组合
$pattern = "/^[a-zA-Z0-9_\/]+$/";
if ( !preg_match($pattern,$page) ) {
exit('非法请求!');
}
//如果是后台首页,则判断是否是手机访问,并决定是否跳转到手机版页面
if( $page == 'index' ) {
@ -323,6 +329,11 @@ function check_auth($user,$password){ @@ -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);

2
controller/api.php

@ -667,4 +667,4 @@ function global_search() { @@ -667,4 +667,4 @@ function global_search() {
function upload_backup(){
global $api;
$api->general_upload('data/backup/',['db3']);
}
}

4
controller/index.php

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

10
controller/init.php

@ -66,6 +66,16 @@ function init($data){ @@ -66,6 +66,16 @@ function init($data){
if( empty($data['username']) || empty($data['password']) ) {
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";
//检查配置文件是否存在,存在则不允许设置
if( file_exists($config_file) ) {

Loading…
Cancel
Save