mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-14 20:40:49 +08:00
fix installation for beta5
This commit is contained in:
@@ -20,9 +20,7 @@ class Install
|
||||
'searchbox', 'secondicons', 'sources', 'standards', 'stylesheets', 'sysoppanel', 'teams', 'torrents_state', 'uploadspeed', 'agent_allowed_family',
|
||||
];
|
||||
|
||||
protected $envNames = ['MYSQL_HOST', 'MYSQL_PORT', 'MYSQL_USERNAME', 'MYSQL_PASSWORD', 'MYSQL_DATABASE', 'REDIS_HOST', 'REDIS_PORT', 'REDIS_DATABASE'];
|
||||
|
||||
|
||||
protected $envNames = ['DB_HOST', 'DB_PORT', 'DB_USERNAME', 'DB_PASSWORD', 'DB_DATABASE', 'REDIS_HOST', 'REDIS_PORT', 'REDIS_DB'];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@@ -423,15 +421,15 @@ class Install
|
||||
}
|
||||
$this->doLog("[CREATE ENV] final newData: " . json_encode($newData));
|
||||
unset($key, $value);
|
||||
mysql_connect($newData['MYSQL_HOST'], $newData['MYSQL_USERNAME'], $newData['MYSQL_PASSWORD'], $newData['MYSQL_DATABASE'], $newData['MYSQL_PORT']);
|
||||
mysql_connect($newData['DB_HOST'], $newData['DB_USERNAME'], $newData['DB_PASSWORD'], $newData['DB_DATABASE'], $newData['DB_PORT']);
|
||||
if (extension_loaded('redis') && !empty($newData['REDIS_HOST'])) {
|
||||
$redis = new \Redis();
|
||||
$redis->connect($newData['REDIS_HOST'], $newData['REDIS_PORT'] ?: 6379);
|
||||
if (isset($newData['REDIS_DATABASE'])) {
|
||||
if (!ctype_digit($newData['REDIS_DATABASE']) || $newData['REDIS_DATABASE'] < 0 || $newData['REDIS_DATABASE'] > 15) {
|
||||
throw new \InvalidArgumentException("invalid redis database: " . $newData['redis_database']);
|
||||
if (isset($newData['REDIS_DB'])) {
|
||||
if (!ctype_digit($newData['REDIS_DB']) || $newData['REDIS_DB'] < 0 || $newData['REDIS_DB'] > 15) {
|
||||
throw new \InvalidArgumentException("invalid redis database: " . $newData['REDIS_DB']);
|
||||
}
|
||||
$redis->select($newData['REDIS_DATABASE']);
|
||||
$redis->select($newData['REDIS_DB']);
|
||||
}
|
||||
}
|
||||
$content = "";
|
||||
@@ -502,8 +500,13 @@ class Install
|
||||
$sqlFile = ROOT_PATH . '_db/dbstructure_v1.6.sql';
|
||||
}
|
||||
$string = file_get_contents($sqlFile);
|
||||
$pattern = "/INSERT INTO `(\w+)` VALUES \(.*\);\n/i";
|
||||
if ($string === false) {
|
||||
throw new \RuntimeException("can't not read dbstructure file: $sqlFile");
|
||||
}
|
||||
//@todo test in php 7.3
|
||||
$pattern = "/INSERT INTO `(\w+)` VALUES \(.*\);/i";
|
||||
preg_match_all($pattern, $string, $matches, PREG_SET_ORDER);
|
||||
$this->doLog("[IMPORT DATA] matches count: " . count($matches));
|
||||
foreach ($matches as $match) {
|
||||
$table = $match[1];
|
||||
$sql = trim($match[0]);
|
||||
|
||||
@@ -25,7 +25,8 @@ if ($currentStep == 1) {
|
||||
}
|
||||
|
||||
if ($currentStep == 2) {
|
||||
$envExampleFile = "$rootpath.env.example";
|
||||
$envExampleFile = $rootpath . ".env.example";
|
||||
$dbstructureFile = $rootpath . "_db/dbstructure_v1.6.sql";
|
||||
$envExampleData = readEnvFile($envExampleFile);
|
||||
$envFormControls = $install->listEnvFormControls();
|
||||
$newData = array_column($envFormControls, 'value', 'name');
|
||||
@@ -41,11 +42,17 @@ if ($currentStep == 2) {
|
||||
}
|
||||
$tableRows = [
|
||||
[
|
||||
'label' => '.env.example',
|
||||
'label' => basename($envExampleFile),
|
||||
'required' => 'exists && readable',
|
||||
'current' => $envExampleFile,
|
||||
'result' => $install->yesOrNo(file_exists($envExampleFile) && is_readable($envExampleFile)),
|
||||
],
|
||||
[
|
||||
'label' => basename($dbstructureFile),
|
||||
'required' => 'exists && readable',
|
||||
'current' => $dbstructureFile,
|
||||
'result' => $install->yesOrNo(file_exists($dbstructureFile) && is_readable($dbstructureFile)),
|
||||
],
|
||||
];
|
||||
$fails = array_filter($tableRows, function ($value) {return $value['result'] == 'NO';});
|
||||
$pass = empty($fails);
|
||||
|
||||
@@ -354,8 +354,8 @@
|
||||
'code' =>
|
||||
array (
|
||||
'mainversion' => 'NexusPHP',
|
||||
'subversion' => 'v1.6.0-beta4',
|
||||
'releasedate' => '2021-03-19',
|
||||
'subversion' => 'v1.6.0-beta5',
|
||||
'releasedate' => '2021-04-30',
|
||||
'website' => '<a href="https://nexusphp.org" target="_blank">https://nexusphp.org</a>',
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user