mirror of
https://github.com/typecho/typecho.git
synced 2025-03-11 05:29:40 +01:00
This commit is contained in:
parent
0edb48fae0
commit
1b673e06ff
@ -1021,6 +1021,9 @@ function install_step_2_perform()
|
||||
case 'SQLite':
|
||||
$error = (new \Typecho\Validate())
|
||||
->addRule('dbFile', 'required', _t('确认您的配置'))
|
||||
->addRule('dbFile', function (string $path) {
|
||||
return !!preg_match("/^(\/[_a-z0-9-]+)*[a-z0-9]+\.[a-z0-9]{2,}$/i", $path);
|
||||
}, _t('确认您的配置'))
|
||||
->run($config);
|
||||
break;
|
||||
default:
|
||||
@ -1041,6 +1044,10 @@ function install_step_2_perform()
|
||||
$dbConfig['port'] = intval($dbConfig['port']);
|
||||
}
|
||||
|
||||
if (isset($dbConfig['file']) && preg_match("/^[a-z0-9]+\.[a-z0-9]{2,}$/i", $dbConfig['file'])) {
|
||||
$dbConfig['file'] = __DIR__ . '/usr/' . $dbConfig['file'];
|
||||
}
|
||||
|
||||
// check config file
|
||||
if ($config['dbNext'] == 'config' && !install_check('config')) {
|
||||
$code = install_config_file($config['dbAdapter'], $config['dbPrefix'], $dbConfig, true);
|
||||
|
@ -221,7 +221,7 @@ class Validate
|
||||
* @access public
|
||||
*
|
||||
* @param string $key 数值键值
|
||||
* @param string|array $rule 规则名称
|
||||
* @param string|callable $rule 规则名称
|
||||
* @param string $message 错误字符串
|
||||
*
|
||||
* @return $this
|
||||
@ -284,7 +284,7 @@ class Validate
|
||||
$params[1] = $data[$key];
|
||||
$params = array_slice($params, 1);
|
||||
|
||||
if (!call_user_func_array(is_array($method) ? $method : [$this, $method], $params)) {
|
||||
if (!call_user_func_array(is_callable($method) ? $method : [$this, $method], $params)) {
|
||||
$result[$key] = $message;
|
||||
break;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user