Browse Source

Merge branch 'master' into develop

F4NNIU 4 years ago
parent
commit
af241c7c21

+ 11 - 6
application/admin/command/Install.php

@@ -205,14 +205,17 @@ class Install extends Command
         $callback = function ($matches) use ($mysqlHostname, $mysqlHostport, $mysqlUsername, $mysqlPassword, $mysqlDatabase, $mysqlPrefix) {
         $callback = function ($matches) use ($mysqlHostname, $mysqlHostport, $mysqlUsername, $mysqlPassword, $mysqlDatabase, $mysqlPrefix) {
             $field = "mysql" . ucfirst($matches[1]);
             $field = "mysql" . ucfirst($matches[1]);
             $replace = $$field;
             $replace = $$field;
-            return "{$matches[1]} = {$replace}" . PHP_EOL;
+            if ($matches[1] == 'hostport' && $mysqlHostport == 3306) {
+                $replace = '';
+            }
+            return "'{$matches[1]}'{$matches[2]}=>{$matches[3]}Env::get('database.{$matches[1]}', '{$replace}'),";
         };
         };
-        $dbConfigText = preg_replace_callback("/'(hostname|database|username|password|hostport|prefix)'(\s+)=>(\s+)Env::get\((.*)\)\,/", $callback, $config);
+        $dbConfigText = preg_replace_callback("/'(hostname|database|username|password|hostport|prefix)'(\s+)=>(\s+)Env::get\((.*)\)\,/", $callback, $dbConfigText);
 
 
         // 检测能否成功写入数据库配置
         // 检测能否成功写入数据库配置
         $result = @file_put_contents($dbConfigFile, $dbConfigText);
         $result = @file_put_contents($dbConfigFile, $dbConfigText);
         if (!$result) {
         if (!$result) {
-            throw new Exception(__('The current permissions are insufficient to write the file %s', '.env'));
+            throw new Exception(__('The current permissions are insufficient to write the file %s', 'application/database.php'));
         }
         }
 
 
         // 设置新的Token随机密钥key
         // 设置新的Token随机密钥key
@@ -288,15 +291,17 @@ class Install extends Command
             'public' . DS . 'assets' . DS . 'libs'
             'public' . DS . 'assets' . DS . 'libs'
         ];
         ];
 
 
+        //数据库配置文件
+        $dbConfigFile = APP_PATH . 'database.php';
+
         if (version_compare(PHP_VERSION, '7.0.0', '<')) {
         if (version_compare(PHP_VERSION, '7.0.0', '<')) {
             throw new Exception(__("The current version %s is too low, please use PHP 7.0 or higher", PHP_VERSION));
             throw new Exception(__("The current version %s is too low, please use PHP 7.0 or higher", PHP_VERSION));
         }
         }
         if (!extension_loaded("PDO")) {
         if (!extension_loaded("PDO")) {
             throw new Exception(__("PDO is not currently installed and cannot be installed"));
             throw new Exception(__("PDO is not currently installed and cannot be installed"));
         }
         }
-        $envConfFile = ROOT_PATH . '.env';
-        if (is_file($envConfFile) && !is_really_writable($envConfFile)) {
-            throw new Exception(__('The current permissions are insufficient to write the file %s', '.env'));
+        if (!is_really_writable($dbConfigFile)) {
+            throw new Exception(__('The current permissions are insufficient to write the configuration file application/database.php'));
         }
         }
         foreach ($checkDirs as $k => $v) {
         foreach ($checkDirs as $k => $v) {
             if (!is_dir(ROOT_PATH . $v)) {
             if (!is_dir(ROOT_PATH . $v)) {

+ 2 - 1
application/admin/controller/general/Config.php

@@ -28,7 +28,8 @@ class Config extends Backend
     public function _initialize()
     public function _initialize()
     {
     {
         parent::_initialize();
         parent::_initialize();
-        $this->model = model('Config');
+        // $this->model = model('Config');
+        $this->model = new ConfigModel;
         ConfigModel::event('before_write', function ($row) {
         ConfigModel::event('before_write', function ($row) {
             if (isset($row['name']) && $row['name'] == 'name' && preg_match("/fast" . "admin/i", $row['value'])) {
             if (isset($row['name']) && $row['name'] == 'name' && preg_match("/fast" . "admin/i", $row['value'])) {
                 throw new Exception(__("Site name incorrect"));
                 throw new Exception(__("Site name incorrect"));

+ 1 - 1
application/common.php

@@ -426,7 +426,7 @@ if (!function_exists('check_cors_request')) {
         if (isset($_SERVER['HTTP_ORIGIN']) && $_SERVER['HTTP_ORIGIN']) {
         if (isset($_SERVER['HTTP_ORIGIN']) && $_SERVER['HTTP_ORIGIN']) {
             $info = parse_url($_SERVER['HTTP_ORIGIN']);
             $info = parse_url($_SERVER['HTTP_ORIGIN']);
             $domainArr = explode(',', config('fastadmin.cors_request_domain'));
             $domainArr = explode(',', config('fastadmin.cors_request_domain'));
-            $domainArr[] = request()->host();
+            $domainArr[] = request()->host(true);
             if (in_array("*", $domainArr) || in_array($_SERVER['HTTP_ORIGIN'], $domainArr) || (isset($info['host']) && in_array($info['host'], $domainArr))) {
             if (in_array("*", $domainArr) || in_array($_SERVER['HTTP_ORIGIN'], $domainArr) || (isset($info['host']) && in_array($info['host'], $domainArr))) {
                 header("Access-Control-Allow-Origin: " . $_SERVER['HTTP_ORIGIN']);
                 header("Access-Control-Allow-Origin: " . $_SERVER['HTTP_ORIGIN']);
             } else {
             } else {

+ 5 - 0
application/common/controller/Backend.php

@@ -539,6 +539,11 @@ class Backend extends Controller
             //如果有primaryvalue,说明当前是初始化传值,按照选择顺序排序
             //如果有primaryvalue,说明当前是初始化传值,按照选择顺序排序
             if ($primaryvalue !== null && preg_match("/^[a-z0-9_\-]+$/i", $primarykey)) {
             if ($primaryvalue !== null && preg_match("/^[a-z0-9_\-]+$/i", $primarykey)) {
                 $primaryvalue = array_unique(is_array($primaryvalue) ? $primaryvalue : explode(',', $primaryvalue));
                 $primaryvalue = array_unique(is_array($primaryvalue) ? $primaryvalue : explode(',', $primaryvalue));
+                //修复自定义data-primary-key为字符串内容时,给排序字段添加上引号
+                $primaryvalue=   array_map(function ($value) {
+                    return '\'' . $value . '\'';
+                }, $primaryvalue);
+
                 $primaryvalue = implode(',', $primaryvalue);
                 $primaryvalue = implode(',', $primaryvalue);
 
 
                 $this->model->orderRaw("FIELD(`{$primarykey}`, {$primaryvalue})");
                 $this->model->orderRaw("FIELD(`{$primarykey}`, {$primaryvalue})");

+ 1 - 1
application/common/library/Email.php

@@ -62,7 +62,7 @@ class Email
         $secureArr = [0 => '', 1 => 'tls', 2 => 'ssl'];
         $secureArr = [0 => '', 1 => 'tls', 2 => 'ssl'];
         $secure = isset($secureArr[$this->options['mail_verify_type']]) ? $secureArr[$this->options['mail_verify_type']] : '';
         $secure = isset($secureArr[$this->options['mail_verify_type']]) ? $secureArr[$this->options['mail_verify_type']] : '';
 
 
-        $this->mail = new Mailer(new Log);
+        $this->mail = new Mailer();
         $this->mail->setServer($this->options['mail_smtp_host'], $this->options['mail_smtp_port'], $secure);
         $this->mail->setServer($this->options['mail_smtp_host'], $this->options['mail_smtp_port'], $secure);
         $this->mail->setAuth($this->options['mail_from'], $this->options['mail_smtp_pass']);
         $this->mail->setAuth($this->options['mail_from'], $this->options['mail_smtp_pass']);
 
 

+ 4 - 2
extend/fast/Date.php

@@ -183,12 +183,14 @@ class Date
                     mktime(23, 59, 59, $month, $day - date("w", mktime(0, 0, 0, $month, $day, $year)) + 7 - 7 * (-$offset), $year);
                     mktime(23, 59, 59, $month, $day - date("w", mktime(0, 0, 0, $month, $day, $year)) + 7 - 7 * (-$offset), $year);
                 break;
                 break;
             case 'month':
             case 'month':
-                $time = $position ? mktime(0, 0, 0, $month + $offset, 1, $year) : mktime(23, 59, 59, $month + $offset, cal_days_in_month(CAL_GREGORIAN, $month + $offset, $year), $year);
+                $_timestamp=mktime(0, 0, 0, $month + $offset, 1, $year);
+                $time = $position ? $_timestamp : mktime(23, 59, 59, $month + $offset, cal_days_in_month(CAL_GREGORIAN, date("m",$_timestamp), date("Y",$_timestamp)), $year);
                 break;
                 break;
             case 'quarter':
             case 'quarter':
+                $_month=date("m",mktime(0, 0, 0, (ceil(date('n', mktime(0, 0, 0, $month, $day, $year)) / 3) + $offset) * 3, $day, $year));
                 $time = $position ?
                 $time = $position ?
                     mktime(0, 0, 0, 1 + ((ceil(date('n', mktime(0, 0, 0, $month, $day, $year)) / 3) + $offset) - 1) * 3, 1, $year) :
                     mktime(0, 0, 0, 1 + ((ceil(date('n', mktime(0, 0, 0, $month, $day, $year)) / 3) + $offset) - 1) * 3, 1, $year) :
-                    mktime(23, 59, 59, (ceil(date('n', mktime(0, 0, 0, $month, $day, $year)) / 3) + $offset) * 3, cal_days_in_month(CAL_GREGORIAN, (ceil(date('n', mktime(0, 0, 0, $month, $day, $year)) / 3) + $offset) * 3, $year), $year);
+                    mktime(23, 59, 59, (ceil(date('n', mktime(0, 0, 0, $month, $day, $year)) / 3) + $offset) * 3, cal_days_in_month(CAL_GREGORIAN, $_month, $year), $year);
                 break;
                 break;
             case 'year':
             case 'year':
                 $time = $position ? mktime(0, 0, 0, 1, 1, $year + $offset) : mktime(23, 59, 59, 12, 31, $year + $offset);
                 $time = $position ? mktime(0, 0, 0, 1, 1, $year + $offset) : mktime(23, 59, 59, 12, 31, $year + $offset);

+ 1 - 1
public/assets/js/frontend/user.js

@@ -58,7 +58,7 @@ define(['jquery', 'bootstrap', 'frontend', 'form', 'template'], function ($, und
                     location.href = ret.url ? ret.url : "/";
                     location.href = ret.url ? ret.url : "/";
                 }, 1000);
                 }, 1000);
             }, function (data) {
             }, function (data) {
-                $("input[name=captcha]").next(".input-group-addon").find("img").trigger("click");
+                $("input[name=captcha]").next(".input-group-btn").find("img").trigger("click");
             });
             });
         },
         },
         changepwd: function () {
         changepwd: function () {

+ 1 - 1
public/assets/js/require-backend.min.js

@@ -12130,7 +12130,7 @@ define('table',['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstr
                     'click .img-center': function (e, value, row, index) {
                     'click .img-center': function (e, value, row, index) {
                         var data = [];
                         var data = [];
                         value = value === null ? '' : value.toString();
                         value = value === null ? '' : value.toString();
-                        var arr = value != '' ? split(",") : [];
+                        var arr = value != '' ? value.split(",") : [];
                         $.each(arr, function (index, value) {
                         $.each(arr, function (index, value) {
                             data.push({
                             data.push({
                                 src: Fast.api.cdnurl(value),
                                 src: Fast.api.cdnurl(value),

+ 1 - 1
public/assets/js/require-frontend.min.js

@@ -11979,7 +11979,7 @@ define('table',['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstr
                     'click .img-center': function (e, value, row, index) {
                     'click .img-center': function (e, value, row, index) {
                         var data = [];
                         var data = [];
                         value = value === null ? '' : value.toString();
                         value = value === null ? '' : value.toString();
-                        var arr = value != '' ? split(",") : [];
+                        var arr = value != '' ? value.split(",") : [];
                         $.each(arr, function (index, value) {
                         $.each(arr, function (index, value) {
                             data.push({
                             data.push({
                                 src: Fast.api.cdnurl(value),
                                 src: Fast.api.cdnurl(value),

+ 1 - 1
public/assets/js/require-table.js

@@ -602,7 +602,7 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
                     'click .img-center': function (e, value, row, index) {
                     'click .img-center': function (e, value, row, index) {
                         var data = [];
                         var data = [];
                         value = value === null ? '' : value.toString();
                         value = value === null ? '' : value.toString();
-                        var arr = value != '' ? split(",") : [];
+                        var arr = value != '' ? value.split(",") : [];
                         $.each(arr, function (index, value) {
                         $.each(arr, function (index, value) {
                             data.push({
                             data.push({
                                 src: Fast.api.cdnurl(value),
                                 src: Fast.api.cdnurl(value),