lylme_spage/include/updbase.php

111 lines
3.5 KiB
PHP
Raw Normal View History

2022-05-03 14:03:44 +08:00
<?php
2023-12-16 17:20:06 +08:00
2024-01-09 15:59:25 +08:00
if (empty(constant("VERSION"))) {
2023-12-16 17:20:06 +08:00
return 0;
}
function get_vernum($version)
{
$vn = explode('.', str_replace('v', '', $version));
$vernum = $vn[0] . sprintf("%02d", $vn[1]) . sprintf("%02d", $vn[2]);
return $vernum;
2022-05-03 14:03:44 +08:00
}
$sqlvn = get_vernum($conf['version']); //数据库版本
$filevn = get_vernum(constant("VERSION")); // 文件版本
2024-01-09 15:59:25 +08:00
if ($sqlvn < $filevn) {
2022-05-03 14:03:44 +08:00
//文件版本大于数据库版本执行更新
2023-12-16 17:20:06 +08:00
$sql = '';
2024-01-09 15:59:25 +08:00
if ($sqlvn < 10101) {
2023-12-16 17:20:06 +08:00
$version = 'v1.1.1';
$sql = $sql . file_get_contents(ROOT . 'install/data/update.sql');
}
2024-01-09 15:59:25 +08:00
if ($sqlvn < 10103) {
2023-12-16 17:20:06 +08:00
$version = 'v1.1.3';
@unlink(ROOT . 'include/head.php');
@unlink(ROOT . 'include/home.php');
@unlink(ROOT . 'include/apply.php');
@unlink(ROOT . 'include/footer.php');
$sql = $sql . file_get_contents(ROOT . 'install/data/update1.sql');
}
2024-01-09 15:59:25 +08:00
if ($sqlvn < 10104) {
2023-12-16 17:20:06 +08:00
$version = 'v1.1.4';
}
2024-01-09 15:59:25 +08:00
if ($sqlvn < 10105) {
2023-12-16 17:20:06 +08:00
$version = 'v1.1.5';
$sql = $sql . file_get_contents(ROOT . 'install/data/update2.sql');
}
2024-01-09 15:59:25 +08:00
if ($sqlvn < 10106) {
2023-12-16 17:20:06 +08:00
$version = 'v1.1.6';
$sql = $sql . file_get_contents(ROOT . 'install/data/update3.sql');
}
2024-01-09 15:59:25 +08:00
if ($sqlvn < 10109) {
2023-12-16 17:20:06 +08:00
$version = 'v1.1.9';
$sql = $sql . file_get_contents(ROOT . 'install/data/update4.sql');
}
2024-01-09 15:59:25 +08:00
if ($sqlvn < 10200) {
2023-12-16 17:20:06 +08:00
$version = 'v1.2.0';
$sql = $sql . file_get_contents(ROOT . 'install/data/update5.sql');
}
2024-01-09 15:59:25 +08:00
if ($sqlvn < 10205) {
2023-12-16 17:20:06 +08:00
$version = 'v1.2.5';
}
2024-01-09 15:59:25 +08:00
if ($sqlvn < 10300) {
2023-12-16 17:20:06 +08:00
$version = 'v1.3.0';
}
2024-01-09 15:59:25 +08:00
if ($sqlvn < 10304) {
2023-12-16 17:20:06 +08:00
$version = 'v1.3.4';
}
2024-01-09 15:59:25 +08:00
if ($sqlvn < 10500) {
2023-12-16 17:20:06 +08:00
$version = 'v1.5.0';
}
2024-01-09 15:59:25 +08:00
if ($sqlvn < 10501) {
2023-12-16 17:20:06 +08:00
$version = 'v1.5.1';
$sql = $sql . file_get_contents(ROOT . 'install/data/update6.sql');
}
2024-01-09 15:59:25 +08:00
if ($sqlvn < 10600) {
2023-12-16 17:20:06 +08:00
$version = 'v1.6.0';
$sql = $sql . file_get_contents(ROOT . 'install/data/update7.sql');
}
2024-01-09 15:59:25 +08:00
if ($sqlvn < 10700) {
2023-12-16 17:20:06 +08:00
$version = 'v1.7.0';
}
2024-01-09 15:59:25 +08:00
if ($sqlvn < 10800) {
2023-12-16 17:20:06 +08:00
$version = 'v1.8.0';
$sql = $sql . file_get_contents(ROOT . 'install/data/update8.sql');
if (!isset($conf['md5pass'])) {
//MD5加密密码
$admin_pwd = md5('lylme' . $conf['admin_pwd']);
$DB->query("INSERT INTO `lylme_config` (`k`, `v`, `description`) VALUES ('md5pass', '1', '启用md5加密密码');");
saveSetting('admin_pwd', $admin_pwd);
}
2024-01-09 11:08:01 +08:00
}
2024-01-09 15:59:25 +08:00
if ($sqlvn < 10805) {
2024-01-09 11:08:01 +08:00
$version = 'v1.8.5';
if (!isset($conf['about'])) {
2024-01-09 15:59:25 +08:00
$DB->query("INSERT INTO `lylme_config` (`k`, `v`, `description`) VALUES ('about', '1', '新版关于页面');");
2024-01-09 11:08:01 +08:00
$about_file = ROOT . 'about/about.txt';
2024-01-09 15:59:25 +08:00
if (file_exists($about_file)) {
$about_content = str_replace(PHP_EOL, '\r\n', daddslashes(file_get_contents($about_file)));
$about = " INSERT INTO `lylme_config` (`k`, `v`, `description`) VALUES ('about_content', '$about_content', '关于页面');";
$DB->query($about);
@unlink(ROOT . 'about/说明.txt');
2024-01-09 11:08:01 +08:00
}
}
2023-12-16 17:20:06 +08:00
}
2024-05-06 00:37:40 +08:00
if ($sqlvn < 10900) {
$version = 'v1.9.0';
}
if ($sqlvn < 10905) {
$version = 'v1.9.5';
}
2023-12-16 17:20:06 +08:00
$sql = explode(';', $sql);
2024-01-09 15:59:25 +08:00
for ($i = 0; $i < count($sql); $i++) {
2023-12-16 17:20:06 +08:00
if (trim($sql[$i]) == '') {
continue;
}
2024-01-09 15:59:25 +08:00
if ($DB->query($sql[$i])) {
2023-12-16 17:20:06 +08:00
}
}
saveSetting('version', $version);
2022-05-03 14:03:44 +08:00
}