EasyImages2.0/install/contorl.php

69 lines
1.8 KiB
PHP
Raw Permalink Normal View History

2021-11-09 03:43:23 +00:00
<?php
2023-03-08 18:42:50 +00:00
require_once __DIR__ . '/../app/function.php';
2021-11-09 03:43:23 +00:00
if (file_exists(APP_ROOT . '/config/install.lock')) {
2021-11-09 03:43:23 +00:00
exit(header("Location:/../index.php"));
}
if (isset($_POST['password'])) {
2024-03-07 18:20:24 +00:00
if ($_POST['password'] === $_POST['repassword']) {
2021-11-09 03:43:23 +00:00
2023-03-04 05:52:50 +00:00
$config['password'] = hash('sha256', $_POST['password']);
$config['user'] = $_POST['user'];
2021-11-09 03:43:23 +00:00
} else {
exit('<script>window.alert("两次密码不一致请重新输入!");location.href="./index.php";</script>');
2021-11-09 03:43:23 +00:00
}
}
if (isset($_POST['domain'])) {
2022-01-05 10:41:45 +00:00
$config['domain'] = $_POST['domain'];
2021-11-09 03:43:23 +00:00
}
if (isset($_POST['imgurl'])) {
2022-01-05 10:41:45 +00:00
$config['imgurl'] = $_POST['imgurl'];
2021-11-09 03:43:23 +00:00
}
$config_file = APP_ROOT . '/config/config.php';
cache_write($config_file, $config);
2024-03-07 18:20:24 +00:00
// 创建安装程序锁
file_put_contents(APP_ROOT . '/config/install.lock', '安装程序锁定文件。');
2021-11-09 03:43:23 +00:00
// 删除安装目录
if (isset($_POST['del_install'])) {
2024-03-07 18:20:24 +00:00
if ($_POST['del_install'] === "del") {
2023-02-01 15:06:02 +00:00
try {
@deldir(APP_ROOT . "/install");
} catch (Exception $e) {
echo $e->getMessage();
}
2021-11-09 03:43:23 +00:00
}
}
2022-02-06 22:20:07 +00:00
// 删除多余文件.whitesource
2022-01-17 08:39:59 +00:00
if (isset($_POST['del_extra_files'])) {
2024-03-07 18:20:24 +00:00
if ($_POST['del_extra_files'] === "del") {
2023-02-01 15:06:02 +00:00
try {
@unlink(APP_ROOT . '/LICENSE');
@unlink(APP_ROOT . '/README.md');
@deldir(APP_ROOT . "/admin/logs");
@deldir(APP_ROOT . "/SECURITY.md");
@unlink(APP_ROOT . '/.whitesource');
@unlink(APP_ROOT . '/CODE_OF_CONDUCT.md');
@unlink(APP_ROOT . '/config/EasyIamge.lock');
@deldir(APP_ROOT . "/.github");
@deldir(APP_ROOT . "/.git");
2023-02-05 17:40:22 +00:00
@deldir(APP_ROOT . "/docs");
2023-02-01 15:06:02 +00:00
} catch (Exception $e) {
echo $e->getMessage();
}
2022-01-17 08:39:59 +00:00
}
}
2024-03-07 18:20:24 +00:00
?>
<!-- 跳转主页 -->
2022-01-17 08:39:59 +00:00
2024-03-07 18:20:24 +00:00
<script>
window.alert("安装成功,即将为您跳转到登陆界面!");
location.href = "../admin/index.php";
</script>