Browse Source

支持PHP8

pull/244/head
xiaoz 3 days ago
parent
commit
cb3d61a6fa
  1. 2
      auto_install.json
  2. 12
      class/Api.php
  3. 16
      controller/init.php
  4. 2
      functions/helper.php
  5. 4
      templates/admin/click.php

2
auto_install.json

@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
"php_ext":"opcache",
"chmod":[],
"success_url":"/index.php",
"php_versions":"56,70,71,72,73,74",
"php_versions":"72,73,74,80,81,82,83",
"db_config":"",
"admin_username":"",
"admin_password":"",

12
class/Api.php

@ -1675,7 +1675,7 @@ class Api { @@ -1675,7 +1675,7 @@ class Api {
public function check_weak_password($token){
$this->auth($token);
//如果用户名、密码为初始密码,则提示修改
if ( ( USER == 'xiaoz' ) && ( PASSWORD == 'xiaoz.me' ) ) {
if ( defined('PASSWORD') && USER == 'xiaoz' && PASSWORD == 'xiaoz.me' ) {
$this->err_msg(-1,'Weak password!');
}
}
@ -2507,8 +2507,18 @@ class Api { @@ -2507,8 +2507,18 @@ class Api {
//备份目录
$backup_dir = 'data/backup/';
//目录不存在时先创建,避免 scandir 返回 false 后 count() 在 PHP 8 下抛 TypeError
if ( !is_dir($backup_dir) ) {
if ( !mkdir($backup_dir, 0755, true) ) {
$this->return_json(-2000, '', '备份目录创建失败,请检查目录权限!');
}
}
//遍历备份列表
$dbs = scandir($backup_dir);
if ( !is_array($dbs) ) {
$dbs = [];
}
$newdbs = $dbs;
//去除.和..

16
controller/init.php

@ -10,32 +10,32 @@ @@ -10,32 +10,32 @@
function check_env() {
//获取组件信息
$ext = get_loaded_extensions();
//检查PHP版本,需要大于7.0小于8.0
$php_version = floatval(PHP_VERSION);
//检查PHP版本,最低要求7.2,兼容8.x
$php_version = PHP_VERSION;
$uri = $_SERVER["REQUEST_URI"];
// var_dump($uri);
if( ( $php_version < 7 ) || ( $php_version > 8 ) ) {
exit("当前PHP版本{$php_version}不满足要求,需要7.0 <= PHP <= 7.4");
if ( version_compare($php_version, '7.2.0', '<') ) {
exit("当前PHP版本{$php_version}不满足要求,需要PHP >= 7.2");
}
//检查是否支持pdo_sqlite
if ( !array_search('pdo_sqlite',$ext) ) {
if ( !in_array('pdo_sqlite', $ext, true) ) {
exit("不支持PDO_SQLITE组件,请先开启!");
}
if ( !array_search('openssl', $ext) ) {
if ( !in_array('openssl', $ext, true) ) {
exit("不支持OPENSSL组件,请先开启!");
}
//检查是否支持zlib
if ( !array_search('zlib', $ext) ) {
if ( !in_array('zlib', $ext, true) ) {
exit("不支持ZLIB组件,请先开启!");
}
//检查是否支持curl
if ( !array_search('curl', $ext) ) {
if ( !in_array('curl', $ext, true) ) {
exit("不支持CURL组件,请先开启!");
}

2
functions/helper.php

@ -231,7 +231,7 @@ function check_all_cat(){ @@ -231,7 +231,7 @@ function check_all_cat(){
* name:检查是否存在明文密码参数,如果存在,则提示重新初始化
*/
function unSafe() {
$password = @PASSWORD;
$password = defined('PASSWORD') ? PASSWORD : null;
if( isset($password) && $password !== 'PASSWORD' ) {
exit("由于安全升级,请删除站点目录下的 data/config.php 文件后,重新完成初始化,此操作不会影响数据!");

4
templates/admin/click.php

@ -137,13 +137,13 @@ @@ -137,13 +137,13 @@
<div class="notice-title">即将跳转到外部网站</div>
<div class="notice-des">安全性未知,是否继续</div>
<div class="link" title="主链接">
<span class="icon"><?xml?><svg width="24" height="24" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M26.2401 16.373L17.1001 7.23303C14.4388 4.57168 10.0653 4.6303 7.33158 7.36397C4.59791 10.0976 4.53929 14.4712 7.20064 17.1325L15.1359 25.0678" stroke="#f3f3f3" stroke-width="4" stroke-linecap="round" stroke-linejoin="bevel"/><path d="M32.9027 23.0031L40.838 30.9384C43.4994 33.5998 43.4407 37.9733 40.7071 40.707C37.9734 43.4407 33.5999 43.4993 30.9385 40.8379L21.7985 31.6979" stroke="#f3f3f3" stroke-width="4" stroke-linecap="round" stroke-linejoin="bevel"/><path d="M26.1093 26.1416C28.843 23.4079 28.9016 19.0344 26.2403 16.373" stroke="#f3f3f3" stroke-width="4" stroke-linecap="round" stroke-linejoin="bevel"/><path d="M21.7989 21.7984C19.0652 24.5321 19.0066 28.9056 21.6679 31.5669" stroke="#f3f3f3" stroke-width="4" stroke-linecap="round" stroke-linejoin="bevel"/></svg></span>
<span class="icon"><svg width="24" height="24" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M26.2401 16.373L17.1001 7.23303C14.4388 4.57168 10.0653 4.6303 7.33158 7.36397C4.59791 10.0976 4.53929 14.4712 7.20064 17.1325L15.1359 25.0678" stroke="#f3f3f3" stroke-width="4" stroke-linecap="round" stroke-linejoin="bevel"/><path d="M32.9027 23.0031L40.838 30.9384C43.4994 33.5998 43.4407 37.9733 40.7071 40.707C37.9734 43.4407 33.5999 43.4993 30.9385 40.8379L21.7985 31.6979" stroke="#f3f3f3" stroke-width="4" stroke-linecap="round" stroke-linejoin="bevel"/><path d="M26.1093 26.1416C28.843 23.4079 28.9016 19.0344 26.2403 16.373" stroke="#f3f3f3" stroke-width="4" stroke-linecap="round" stroke-linejoin="bevel"/><path d="M21.7989 21.7984C19.0652 24.5321 19.0066 28.9056 21.6679 31.5669" stroke="#f3f3f3" stroke-width="4" stroke-linecap="round" stroke-linejoin="bevel"/></svg></span>
<a href="<?php echo $link['url']; ?>" rel = "nofollow" title = "<?php echo $link['title']; ?>"><?php echo $link['url']; ?></a>
</div>
<?php if( !empty( $link['url_standby'] ) ) { ?>
<div class="link" title = "备用链接">
<span class="icon">
<?xml?><svg width="24" height="24" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M30 19H20C15.5817 19 12 22.5817 12 27C12 31.4183 15.5817 35 20 35H36C40.4183 35 44 31.4183 44 27C44 24.9711 43.2447 23.1186 42 21.7084" stroke="#f3f3f3" stroke-width="4" stroke-linecap="round" stroke-linejoin="bevel"/><path d="M6 24.2916C4.75527 22.8814 4 21.0289 4 19C4 14.5817 7.58172 11 12 11H28C32.4183 11 36 14.5817 36 19C36 23.4183 32.4183 27 28 27H18" stroke="#f3f3f3" stroke-width="4" stroke-linecap="round" stroke-linejoin="bevel"/></svg>
<svg width="24" height="24" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M30 19H20C15.5817 19 12 22.5817 12 27C12 31.4183 15.5817 35 20 35H36C40.4183 35 44 31.4183 44 27C44 24.9711 43.2447 23.1186 42 21.7084" stroke="#f3f3f3" stroke-width="4" stroke-linecap="round" stroke-linejoin="bevel"/><path d="M6 24.2916C4.75527 22.8814 4 21.0289 4 19C4 14.5817 7.58172 11 12 11H28C32.4183 11 36 14.5817 36 19C36 23.4183 32.4183 27 28 27H18" stroke="#f3f3f3" stroke-width="4" stroke-linecap="round" stroke-linejoin="bevel"/></svg>
</span>
<a href="<?php echo $link['url_standby']; ?>" rel = "nofollow" title = "<?php echo $link['title']; ?>"><?php echo $link['url_standby']; ?></a>
</div>

Loading…
Cancel
Save