diff --git a/index.php b/index.php index 313bdb6..4b226cf 100644 --- a/index.php +++ b/index.php @@ -15,9 +15,10 @@ if($db_config['type'] == 'sqlite'){ }catch (Exception $e) { Amsg(-1,'载入数据库失败'.$db_config['path']); } -}elseif($db_config['type'] == 'mysql'){ +}elseif($db_config['type'] == 'mysql' || $db_config['type'] == 'mariadb' ){ try { - $db = new Medoo\Medoo(['type' => 'mysql', + $db = new Medoo\Medoo([ + 'type' => $db_config['type'], 'host' => $db_config['host'], 'port' => $db_config['port'], 'database' => $db_config['name'], @@ -36,6 +37,7 @@ $c = Get('c'); $libs = $global_config['Libs']; $layui['js'] = $libs.'/Layui/v2.8.17/layui.js'; $layui['css'] = $libs.'/Layui/v2.8.17/css/layui.css'; +$global_config['static_link'] = isset($global_config['static_link']) ? $global_config['static_link'] : 0; define('libs',$global_config['Libs']); define('SysVer',Get_Version()); define('Debug',$global_config['Debug'] == 1); diff --git a/system/ATool.php b/system/ATool.php index a1749df..a59f2ff 100644 --- a/system/ATool.php +++ b/system/ATool.php @@ -200,9 +200,10 @@ function Load_db(){ }catch (Exception $e) { Amsg(-1,'载入数据库失败'.$db_config['path']); } - }elseif($db_config['type'] == 'mysql'){ + }elseif($db_config['type'] == 'mysql' || $db_config['type'] == 'mariadb'){ try { - $db = new Medoo\Medoo(['type' => 'mysql', + $db = new Medoo\Medoo([ + 'type' => $db_config['type'], 'host' => $db_config['host'], 'port' => $db_config['port'], 'database' => $db_config['name'], diff --git a/system/api.php b/system/api.php index 93232bf..9dc0702 100644 --- a/system/api.php +++ b/system/api.php @@ -1459,7 +1459,8 @@ function read_data(){ $log .= "SQLite:".(is_writable($db_config['path'])?'数据库读写正常':'数据库只读(请将权限设为755)')."\n"; }elseif($db_config['type'] == 'mysql'){ $log .= "MySQL:".$db->info ()['version']."\n"; - + }elseif($db_config['type'] == 'mariadb'){ + $log .= "MariaDB:".$db->info ()['version']."\n"; } $path = './data/test_'.time().'.txt'; diff --git a/system/api_root.php b/system/api_root.php index 29539e4..82484ee 100644 --- a/system/api_root.php +++ b/system/api_root.php @@ -108,7 +108,7 @@ function other_upsys(){ set_time_limit(5*60); try { //根据数据库类型扫描不同目录,并声明执行SQL语句的函数 - if($GLOBALS['db_config']['type'] == 'mysql'){ + if($GLOBALS['db_config']['type'] == 'mysql' || $GLOBALS['db_config']['type'] == 'mariadb'){ $dir = './system/MySQL'; function exe_sql($content) { global $db; diff --git a/system/install.php b/system/install.php index 990a2cc..98a7e2a 100644 --- a/system/install.php +++ b/system/install.php @@ -148,7 +148,7 @@ $db_config = array( } // mysql - if($_POST['db_type'] === 'mysql'){ + if($_POST['db_type'] === 'mysql' || $_POST['db_type'] === 'mariadb'){ if( !isset($_POST['db_host']) || !isset($_POST['db_port']) || !isset($_POST['db_name']) || !isset($_POST['db_user']) || !isset($_POST['db_password']) ){ msg(-1,'MySQL配置错误,请检查..'); } @@ -156,7 +156,7 @@ $db_config = array( require (DIR.'/system/Medoo.php'); //载入框架 try { $db = new Medoo\Medoo([ - 'type' => 'mysql', + 'type' => $_POST['db_type'], 'host' => $_POST['db_host'], 'port' => $_POST['db_port'], 'database' => $_POST['db_name'], @@ -164,10 +164,15 @@ $db_config = array( 'password' => $_POST['db_password'], 'charset' => 'utf8mb4' ]); - - //判断版本,目前基于5.6.50开发,其他版本兼容性未知,若您需要强制安装请屏蔽检测 - if(version_compare($db->info ()['version'],'5.6.0','<')) msg(-1,'MySQL数据库版本不能低于5.6,当前版本:'.$db->info ()['version']); - //链接成功.. + if($_POST['db_type'] === 'mysql'){ + if(version_compare($db->info ()['version'],'5.6.0','<')){ + msg(-1,'MySQL数据库版本不能低于5.6,当前版本:'.$db->info ()['version']); + } + }else{ + if(version_compare($db->info ()['version'],'10.1.0','<')){ + msg(-1,'MariaDB数据库版本不能低于10.1,当前版本:'.$db->info ()['version']); + } + } }catch (Exception $e) { $E = $e->getMessage(); if(strstr($E,'[1044]') || strstr($E,'[1049]')){ @@ -195,7 +200,7 @@ $db_config = array( $config = ' "mysql", //类型 + "type" => "'.$_POST['db_type'].'", //类型 "host" => "'.$_POST['db_host'].'", //地址 "port" => '.$_POST['db_port'].', //端口 "name" => "'.$_POST['db_name'].'", //库名 @@ -283,19 +288,40 @@ function Write_Config(){ insert_db("global_config", ["k" => "s_templates","v" => $templates,"d" => '默认模板']); //写站点配置 - $o_config['Login'] = 'login'; //登录入口 - $o_config['Register'] = 'register'; //注册入口 - $o_config['RegOption'] = '0'; //注册配置 - $o_config['Libs'] = './static'; //静态库路径 - $o_config['Default_User'] = $_POST['User']; //默认用户 - $o_config['XSS_WAF'] = '0'; //防XSS脚本 - $o_config['SQL_WAF'] = '0'; //防SQL注入 - $o_config['offline'] = '0'; //离线模式 - $o_config['Debug'] = '0'; //调试模式 - $o_config['Maintenance'] = '0'; //维护模式 - $o_config['Sub_domain'] = '0'; //二级域名 - $o_config['copyright'] = ''; //版权信息 - $o_config['c_code'] = '0'; //禁用默认用户使用自定义代码 + $o_config['Default_User'] = $_POST['User']; + $o_config['default_page'] = 0; + $o_config['default_UserGroup'] = ''; + $o_config['RegOption'] = 0; + $o_config['Register'] = 'register'; + $o_config['Login'] = 'login'; + $o_config['Libs'] = './static'; + $o_config['ICP'] = ''; + $o_config['XSS_WAF'] = 0; + $o_config['SQL_WAF'] = 0; + $o_config['offline'] = 0; + $o_config['Update_Source'] = 0; + $o_config['Update_Overtime'] = 3; + $o_config['Debug'] = 0; + $o_config['Maintenance'] = 0; + $o_config['static_link'] = 0; + $o_config['Privacy'] = 0; + $o_config['Sub_domain'] = 0; + $o_config['copyright'] = ''; + $o_config['global_header'] = ''; + $o_config['global_footer'] = ''; + $o_config['api_extend'] = 0; + $o_config['apply'] = 0; + $o_config['guestbook'] = 0; + $o_config['link_extend'] = 0; + $o_config['article'] = 0; + $o_config['c_name'] = 0; + $o_config['c_desc'] = 0; + $o_config['l_name'] = 0; + $o_config['l_url'] = 0; + $o_config['l_key'] = 0; + $o_config['l_desc'] = 0; + $o_config['c_code'] = 0; + insert_db("global_config", ["k" => "o_config","v" => $o_config,"d" => '网站配置']); @@ -379,8 +405,9 @@ function Write_Config(){
@@ -394,40 +421,40 @@ function Write_Config(){ - + - +
安装方式:全新安装      
推荐配置:Nginx-1.20 + PHP-8.1
@@ -482,7 +509,7 @@ layui.use(['form'], function(){ return false; }else if(d.db_type == 'mysql'){ if(d.db_host.length == 0 || d.db_port.length == 0 || d.db_name.length == 0 || d.db_user.length == 0 || d.db_password.length == 0){ - layer.msg('MySQL配置有误,请检查.', {icon: 5}); + layer.msg('数据库配置有误,请检查.', {icon: 5}); return false; } } @@ -517,7 +544,7 @@ layui.use(['form'], function(){ //数据库类型切换 function set_db_type(v){ document.cookie="db_type="+v; - if(v == 'mysql'){ + if(v == 'mysql' || v == 'mariadb'){ $("#db_mysql").show(); $("#db_sqlite").hide(); }else if(v == 'sqlite'){ diff --git a/system/public.php b/system/public.php index e4276ca..90b6df5 100644 --- a/system/public.php +++ b/system/public.php @@ -726,67 +726,14 @@ function Get_Rand_Str( $length = 8 ,$extend = false){ } //发送邮件 function send_email($config){ - if(!is_file(DIR.'/system/PHPMailer/PHPMailer.php')){ - msg(-1,'未安装PHPMailer!'); - } - - require DIR.'/system/PHPMailer/Exception.php'; - require DIR.'/system/PHPMailer/PHPMailer.php'; - require DIR.'/system/PHPMailer/SMTP.php'; - $mail = new PHPMailer\PHPMailer\PHPMailer(true); - try { - $mail->CharSet ="UTF-8"; - $mail->SMTPDebug = 0; - $mail->isSMTP(); - $mail->Host = $config['host']; - $mail->SMTPAuth = true; - $mail->Username = $config['user']; - $mail->Password = $config['pwd']; - $mail->SMTPSecure = $config['secure']; - $mail->Port = intval($config['port']); - - if(preg_match('/(.+)<(.+@.+)>$/', $config['sender'], $match)){ - $mail->setFrom($match[2],$match[1]); - }else{ - $mail->setFrom($config['user'],empty($config['sender'])?'TwoNav':$config['sender']); - } - - $mail->addAddress($config['addressee']); //收件人 - - $mail->isHTML(true); - $mail->Subject = $config['Subject']; - $mail->Body = $config['Body']; - $mail->send(); - if(!empty($config['return']) && $config['return'] == 'bool'){ - return true; - } - msg(1,'邮件发送成功'); - } catch (Exception $e) { - if(!empty($config['return']) && $config['return'] == 'bool'){ - return false; - } - if(Debug){ - msgA(['code'=>-1,'msg'=>'发送失败:'.$mail->ErrorInfo]); - }else{ - msg(-1,'发送失败'); - } - } + msg(0,'免费版不支持此功能'); } //统计访问ip数 function count_ip(){ - $ip = Get_IP(); //取访客IP - $k = date('Ymd'); $t = 'ip_list'; - $ip_list = get_db('user_count','e',['uid'=>UID,'k'=>$k,'t'=>$t]); //取列表 - $ip_list = empty($ip_list) ? [] : unserialize($ip_list); //反序列化 - //判断IP是否存在列表中 - if(!in_array($ip, $ip_list)){ - $ip_list[] = $ip; //加入列表 - if(!has_db('user_count',['uid'=>UID,'t'=>$t,'k'=>$k])){ - insert_db("user_count", ['uid'=>UID,"k"=>$k,"e"=>$ip_list,'t'=>$t]); - }else{ - update_db("user_count", ["e"=>$ip_list],['uid'=>UID,'t'=>$t,'k'=>$k]); - } + $ip = Get_IP(); $k = date('Ymd'); $t = 'access_ip'; + if(!has_db('user_count',['uid'=>UID,'k'=>$k,'t'=>$t,'v'=>$ip])){ + insert_db("user_count",['uid'=>UID,'k'=>$k,'t'=>$t,'v'=>$ip]); write_user_count($k,'ip_count');//访问ip数+1 } } diff --git a/system/version.txt b/system/version.txt index ad9d402..97a62fa 100644 --- a/system/version.txt +++ b/system/version.txt @@ -1 +1 @@ -v2.1.01-20231002 \ No newline at end of file +v2.1.02-20231012 \ No newline at end of file diff --git a/templates/admin/page/root/vip.php b/templates/admin/page/root/vip.php index 3da329a..d85d9d7 100644 --- a/templates/admin/page/root/vip.php +++ b/templates/admin/page/root/vip.php @@ -12,12 +12,20 @@ if(!empty($Notice)){
+

不要使用盗版/破解版,盗版无法升级却存在诸多问题,所造成的损失与本程序无关

+
+
  • 如何激活授权:
  • +
  • 1. 购买授权后将授权号(卡密)和邮箱填入下方并点击保存
  • +
  • 2. 返回概要页面 > 刷新 > 更新系统 ( 不更新还是免费版 )
  • +
  • 3. 更新成功后就是授权版的系统了,可使用全部功能
  • +
  • 4. 禁止传播/破解授权版源代码,违者封授权并追责
  • +

    当前域名:

    - +
    @@ -50,8 +58,7 @@ if(!empty($Notice)){
    - - + diff --git a/templates/admin/page/updatelog.php b/templates/admin/page/updatelog.php index ed7eef0..4fb2d74 100644 --- a/templates/admin/page/updatelog.php +++ b/templates/admin/page/updatelog.php @@ -2,6 +2,18 @@
    +
  • + +
    +

    v2.1.02-20231012

    +
      +
    • [优化] IP统计的记录方式,提高性能和稳定性
    • +
    • [修复] 未在系统设置保存过设置时因缺少参数而导致部分页面加载异常
    • +
    • [安装] 数据库类型选项新增MariaDB,其他细节调整
    • +
    • [变更] 免费版升级授权版的相关提示信息
    • +
    +
    +