mirror of
https://github.com/tznb1/TwoNav.git
synced 2025-08-10 08:51:49 +00:00
v2.1.02-20231012
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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'],
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 = '<?php
|
||||
//数据库配置
|
||||
$db_config = array(
|
||||
"type" => "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(){
|
||||
<label class="layui-form-label">数据库类型</label>
|
||||
<div class="layui-input-block">
|
||||
<select id="db_type" name="db_type" lay-filter="db_type" >
|
||||
<option value="sqlite" selected="">SQLite ( 个人和工作室推荐 )</option>
|
||||
<option value="mysql" >MySQL ( 大量用户推荐 )</option>
|
||||
<option value="sqlite" selected="">SQLite ( 推荐 )</option>
|
||||
<option value="mysql" >MySQL ≥ 5.6.0 </option>
|
||||
<option value="mariadb" >MariaDB ≥ 10.1 </option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
@@ -394,40 +421,40 @@ function Write_Config(){
|
||||
</div>
|
||||
<!--SQLite配置-->
|
||||
|
||||
<!--MySQL配置-->
|
||||
<!--MySQL/MariaDB 配置-->
|
||||
<div id='db_mysql' style = "display:none;">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">MySQL地址</label>
|
||||
<label class="layui-form-label">地址</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="db_host" value="localhost" placeholder="请输入服务器地址" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">MySQL端口</label>
|
||||
<label class="layui-form-label">端口</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" name="db_port" value="3306" placeholder="请输入服务器端口" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">MySQL库名</label>
|
||||
<label class="layui-form-label">库名</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="db_name" placeholder="请输入数据库库名" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">MySQL账号</label>
|
||||
<label class="layui-form-label">账号</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="db_user" placeholder="请输入数据库账号" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">MySQL密码</label>
|
||||
<label class="layui-form-label">密码</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="db_password" placeholder="请输入数据库密码" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!--MySQL配置 End-->
|
||||
<!--MySQL/MariaDB 配置 End-->
|
||||
<div class="layui-form-mid layui-word-aux">安装方式:全新安装      </div>
|
||||
<div class="layui-form-mid layui-word-aux">推荐配置:Nginx-1.20 + PHP-8.1 </div>
|
||||
<button class="layui-btn" lay-submit lay-filter="register" style = "width:100%;">开始安装</button>
|
||||
@@ -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'){
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
v2.1.01-20231002
|
||||
v2.1.02-20231012
|
||||
@@ -12,12 +12,20 @@ if(!empty($Notice)){
|
||||
<div class="layuimini-container">
|
||||
<div class="layuimini-main">
|
||||
<div class="layui-form layuimini-form layui-form-pane">
|
||||
<h4 style = "margin-bottom:1em;"><font color="red">不要使用盗版/破解版,盗版无法升级却存在诸多问题,所造成的损失与本程序无关</font></h4>
|
||||
<blockquote class="layui-elem-quote layui-text" style="color:red" >
|
||||
<li> 如何激活授权: </li>
|
||||
<li>1. 购买授权后将授权号(卡密)和邮箱填入下方并点击保存</li>
|
||||
<li>2. 返回概要页面 > 刷新 > 更新系统 ( 不更新还是免费版 )</li>
|
||||
<li>3. 更新成功后就是授权版的系统了,可使用全部功能</li>
|
||||
<li>4. 禁止传播/破解授权版源代码,违者封授权并追责</li>
|
||||
</blockquote>
|
||||
<h3 style = "margin-bottom:1em;">当前域名:<font color="red"><?php echo $HTTP_HOST; ?></font></h3>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">授权卡密</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" id = "order_id" name="order_id" value="<?php echo $subscribe['order_id']; ?>" required autocomplete="off" placeholder="请输入授权单号/卡密" class="layui-input">
|
||||
<input type="text" id = "order_id" name="order_id" value="<?php echo $subscribe['order_id']; ?>" required autocomplete="off" placeholder="请输入授权号或卡密" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -50,8 +58,7 @@ if(!empty($Notice)){
|
||||
</div>
|
||||
|
||||
<div class="layui-btn-group">
|
||||
<button class="layui-btn layui-btn-normal" lay-submit lay-filter="save_key">保存设置</button>
|
||||
<button class="layui-btn layui-btn-warm" lay-submit lay-filter="del_key">删除</button>
|
||||
<button class="layui-btn layui-btn-normal" lay-submit lay-filter="save_key">保存</button>
|
||||
<button class="layui-btn layui-btn-danger" lay-submit lay-filter="buy_vip" data-url="<?php echo empty($data['pay_rul']) ?'':$data['pay_rul']?>" >购买授权</button>
|
||||
<button class="layui-btn" lay-submit lay-filter="query_key">查询授权</button>
|
||||
<button class="layui-btn layui-bg-purple" type="button" id="validate" style="<?php echo empty($subscribe['order_id']) ? 'display:none;':''; ?>">正版验证</button>
|
||||
|
||||
@@ -2,6 +2,18 @@
|
||||
<body>
|
||||
<div class="layuimini-container">
|
||||
<div class="layuimini-main" style=" margin-left: 20px;">
|
||||
<li class="layui-timeline-item">
|
||||
<i class="layui-icon layui-timeline-axis"></i>
|
||||
<div class="layui-timeline-content layui-text">
|
||||
<h4 class="layui-timeline-title">v2.1.02-20231012</h4>
|
||||
<ul>
|
||||
<li>[优化] IP统计的记录方式,提高性能和稳定性</li>
|
||||
<li>[修复] 未在系统设置保存过设置时因缺少参数而导致部分页面加载异常</li>
|
||||
<li>[安装] 数据库类型选项新增MariaDB,其他细节调整</li>
|
||||
<li>[变更] 免费版升级授权版的相关提示信息</li>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
<li class="layui-timeline-item">
|
||||
<i class="layui-icon layui-timeline-axis"></i>
|
||||
<div class="layui-timeline-content layui-text">
|
||||
|
||||
Reference in New Issue
Block a user