diff --git a/application/admin/command/Install.php b/application/admin/command/Install.php index eba8d451..f9da2cd7 100644 --- a/application/admin/command/Install.php +++ b/application/admin/command/Install.php @@ -205,14 +205,17 @@ class Install extends Command $callback = function ($matches) use ($mysqlHostname, $mysqlHostport, $mysqlUsername, $mysqlPassword, $mysqlDatabase, $mysqlPrefix) { $field = "mysql" . ucfirst($matches[1]); $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); 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 @@ -288,15 +291,17 @@ class Install extends Command 'public' . DS . 'assets' . DS . 'libs' ]; + //数据库配置文件 + $dbConfigFile = APP_PATH . 'database.php'; + 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)); } if (!extension_loaded("PDO")) { 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) { if (!is_dir(ROOT_PATH . $v)) { diff --git a/application/admin/controller/general/Config.php b/application/admin/controller/general/Config.php index cb04fb81..8fd89441 100644 --- a/application/admin/controller/general/Config.php +++ b/application/admin/controller/general/Config.php @@ -28,7 +28,8 @@ class Config extends Backend public function _initialize() { parent::_initialize(); - $this->model = model('Config'); + // $this->model = model('Config'); + $this->model = new ConfigModel; ConfigModel::event('before_write', function ($row) { if (isset($row['name']) && $row['name'] == 'name' && preg_match("/fast" . "admin/i", $row['value'])) { throw new Exception(__("Site name incorrect")); diff --git a/application/common.php b/application/common.php index 6e436d58..43b53a30 100755 --- a/application/common.php +++ b/application/common.php @@ -426,7 +426,7 @@ if (!function_exists('check_cors_request')) { if (isset($_SERVER['HTTP_ORIGIN']) && $_SERVER['HTTP_ORIGIN']) { $info = parse_url($_SERVER['HTTP_ORIGIN']); $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))) { header("Access-Control-Allow-Origin: " . $_SERVER['HTTP_ORIGIN']); } else { diff --git a/application/common/controller/Backend.php b/application/common/controller/Backend.php index 4a240646..e318a6a3 100644 --- a/application/common/controller/Backend.php +++ b/application/common/controller/Backend.php @@ -539,6 +539,11 @@ class Backend extends Controller //如果有primaryvalue,说明当前是初始化传值,按照选择顺序排序 if ($primaryvalue !== null && preg_match("/^[a-z0-9_\-]+$/i", $primarykey)) { $primaryvalue = array_unique(is_array($primaryvalue) ? $primaryvalue : explode(',', $primaryvalue)); + //修复自定义data-primary-key为字符串内容时,给排序字段添加上引号 + $primaryvalue= array_map(function ($value) { + return '\'' . $value . '\''; + }, $primaryvalue); + $primaryvalue = implode(',', $primaryvalue); $this->model->orderRaw("FIELD(`{$primarykey}`, {$primaryvalue})"); diff --git a/application/common/library/Email.php b/application/common/library/Email.php index bad0fc1c..8d186fc3 100644 --- a/application/common/library/Email.php +++ b/application/common/library/Email.php @@ -62,7 +62,7 @@ class Email $secureArr = [0 => '', 1 => 'tls', 2 => 'ssl']; $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->setAuth($this->options['mail_from'], $this->options['mail_smtp_pass']); diff --git a/extend/fast/Date.php b/extend/fast/Date.php index 8671476d..d8f7ab46 100644 --- a/extend/fast/Date.php +++ b/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); break; 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; 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 ? 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; case 'year': $time = $position ? mktime(0, 0, 0, 1, 1, $year + $offset) : mktime(23, 59, 59, 12, 31, $year + $offset); diff --git a/public/assets/js/frontend/user.js b/public/assets/js/frontend/user.js index 436f6812..c27bcf59 100755 --- a/public/assets/js/frontend/user.js +++ b/public/assets/js/frontend/user.js @@ -58,7 +58,7 @@ define(['jquery', 'bootstrap', 'frontend', 'form', 'template'], function ($, und location.href = ret.url ? ret.url : "/"; }, 1000); }, 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 () { diff --git a/public/assets/js/require-backend.min.js b/public/assets/js/require-backend.min.js index 9d10808a..986d351b 100644 --- a/public/assets/js/require-backend.min.js +++ b/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) { var data = []; value = value === null ? '' : value.toString(); - var arr = value != '' ? split(",") : []; + var arr = value != '' ? value.split(",") : []; $.each(arr, function (index, value) { data.push({ src: Fast.api.cdnurl(value), diff --git a/public/assets/js/require-frontend.min.js b/public/assets/js/require-frontend.min.js index 548028bb..1d975775 100644 --- a/public/assets/js/require-frontend.min.js +++ b/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) { var data = []; value = value === null ? '' : value.toString(); - var arr = value != '' ? split(",") : []; + var arr = value != '' ? value.split(",") : []; $.each(arr, function (index, value) { data.push({ src: Fast.api.cdnurl(value), diff --git a/public/assets/js/require-table.js b/public/assets/js/require-table.js index a1744d98..98244086 100644 --- a/public/assets/js/require-table.js +++ b/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) { var data = []; value = value === null ? '' : value.toString(); - var arr = value != '' ? split(",") : []; + var arr = value != '' ? value.split(",") : []; $.each(arr, function (index, value) { data.push({ src: Fast.api.cdnurl(value),