mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-14 12:30:49 +08:00
finish update
This commit is contained in:
@@ -1665,7 +1665,7 @@ DROP TABLE IF EXISTS `settings`;
|
|||||||
/*!40101 SET character_set_client = utf8 */;
|
/*!40101 SET character_set_client = utf8 */;
|
||||||
CREATE TABLE `settings` (
|
CREATE TABLE `settings` (
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
`name` varchar(255) NOT NULL,
|
`name` varchar(255) NOT NULL DEFAULT '',
|
||||||
`value` mediumtext,
|
`value` mediumtext,
|
||||||
`created_at` datetime DEFAULT NULL,
|
`created_at` datetime DEFAULT NULL,
|
||||||
`updated_at` datetime DEFAULT NULL,
|
`updated_at` datetime DEFAULT NULL,
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ class DB
|
|||||||
}
|
}
|
||||||
$this->driver->query("SET NAMES UTF8");
|
$this->driver->query("SET NAMES UTF8");
|
||||||
$this->driver->query("SET collation_connection = 'utf8_general_ci'");
|
$this->driver->query("SET collation_connection = 'utf8_general_ci'");
|
||||||
// $this->driver->query("SET sql_mode=''");
|
$this->driver->query("SET sql_mode=''");
|
||||||
$this->isConnected = true;
|
$this->isConnected = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,28 +111,6 @@ class Install
|
|||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function listShouldAlterTableTableRows()
|
|
||||||
{
|
|
||||||
$tables = $this->listExistsTable();
|
|
||||||
$data = [];
|
|
||||||
foreach ($tables as $table) {
|
|
||||||
$sql = "desc $table";
|
|
||||||
$res = sql_query($sql);
|
|
||||||
while ($row = mysql_fetch_assoc($res)) {
|
|
||||||
if ($row['Type'] == 'datetime' && $row['Default'] == '0000-00-00 00:00:00') {
|
|
||||||
$data[$table][] = $row['Field'];
|
|
||||||
$data[] = [
|
|
||||||
'label' => "$table." . $row['Field'],
|
|
||||||
'required' => 'default null',
|
|
||||||
'current' => '0000-00-00 00:00:00',
|
|
||||||
'result' => 'NO',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function listRequirementTableRows()
|
public function listRequirementTableRows()
|
||||||
{
|
{
|
||||||
$gdInfo = gd_info();
|
$gdInfo = gd_info();
|
||||||
@@ -294,7 +272,7 @@ class Install
|
|||||||
$table .= '<div class="table-cell bg-gray-200 text-gray-700 px-4 py-2 text-sm">' . $value['label'] . '</div>';
|
$table .= '<div class="table-cell bg-gray-200 text-gray-700 px-4 py-2 text-sm">' . $value['label'] . '</div>';
|
||||||
$table .= '<div class="table-cell bg-gray-200 text-gray-700 px-4 py-2 text-sm">' . $value['required'] . '</div>';
|
$table .= '<div class="table-cell bg-gray-200 text-gray-700 px-4 py-2 text-sm">' . $value['required'] . '</div>';
|
||||||
$table .= '<div class="table-cell bg-gray-200 text-gray-700 px-4 py-2 text-sm">' . $value['current'] . '</div>';
|
$table .= '<div class="table-cell bg-gray-200 text-gray-700 px-4 py-2 text-sm">' . $value['current'] . '</div>';
|
||||||
$table .= '<div class="table-cell bg-' . ($value['result'] == 'YES' ? 'green' : 'gray') . '-200 text-gray-700 px-4 py-2 text-sm">' . $value['result'] . '</div>';
|
$table .= '<div class="table-cell bg-' . ($value['result'] == 'YES' ? 'green' : 'red') . '-200 text-gray-700 px-4 py-2 text-sm">' . $value['result'] . '</div>';
|
||||||
$table .= '</div>';
|
$table .= '</div>';
|
||||||
}
|
}
|
||||||
$table .= '</div>';
|
$table .= '</div>';
|
||||||
|
|||||||
@@ -7,12 +7,6 @@ class Update extends Install
|
|||||||
|
|
||||||
protected $steps = ['环境检测', '添加 .env 文件', '修改&创建数据表', '导入数据'];
|
protected $steps = ['环境检测', '添加 .env 文件', '修改&创建数据表', '导入数据'];
|
||||||
|
|
||||||
protected $initializeTables = [
|
|
||||||
'adminpanel', 'agent_allowed_exception', 'agent_allowed_family', 'allowedemails', 'audiocodecs', 'avps', 'bannedemails', 'categories',
|
|
||||||
'caticons', 'codecs', 'countries', 'downloadspeed', 'faq', 'isp', 'language', 'media', 'modpanel', 'processings', 'rules', 'schools',
|
|
||||||
'searchbox', 'secondicons', 'sources', 'standards', 'stylesheets', 'sysoppanel', 'teams', 'torrents_state', 'uploadspeed', 'agent_allowed_family',
|
|
||||||
];
|
|
||||||
|
|
||||||
|
|
||||||
public function getLogFile()
|
public function getLogFile()
|
||||||
{
|
{
|
||||||
@@ -51,30 +45,4 @@ class Update extends Install
|
|||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function importInitialData($sqlFile = '')
|
|
||||||
{
|
|
||||||
if (empty($sqlFile)) {
|
|
||||||
$sqlFile = ROOT_PATH . '_db/dbstructure_v1.6.sql';
|
|
||||||
}
|
|
||||||
$string = file_get_contents($sqlFile);
|
|
||||||
$pattern = "/INSERT INTO `(\w+)` VALUES \(.*\);\n/i";
|
|
||||||
preg_match_all($pattern, $string, $matches, PREG_SET_ORDER);
|
|
||||||
foreach ($matches as $match) {
|
|
||||||
$table = $match[1];
|
|
||||||
$sql = trim($match[0]);
|
|
||||||
if (!in_array($table, $this->initializeTables)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
//if table not empty, skip
|
|
||||||
$count = get_row_count($table);
|
|
||||||
if ($count > 0) {
|
|
||||||
$this->doLog("[IMPORT DATA] $table, not empty, skip");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$this->doLog("[IMPORT DATA] $table, $sql");
|
|
||||||
sql_query("truncate table $table");
|
|
||||||
sql_query($sql);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user