-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall_script.php
More file actions
executable file
·83 lines (64 loc) · 1.84 KB
/
install_script.php
File metadata and controls
executable file
·83 lines (64 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
error_reporting(E_ALL);
$content = file_get_contents(__DIR__ . '/config.dist.php');
$content = str_replace('{{ secret }}', $secret = bin2hex(random_bytes(16)), $content);
$config = [];
$y = ['y', '1', 'yes'];
$pname = ask('Project Name: ');
$content = str_replace(
"'name' => ''",
"'name' => '$pname'",
$content
);
if (in_array(strtolower(ask("Do you want to dump Files? [y/N]") ?: 'n'), $y, true)) {
$root = ask('Backup Root[.]: ') ?: '.';
$content = str_replace(
[
"'dump_files' => 0",
"'root' => '.'"
],
[
"'dump_files' => 1",
"'root' => '$root'"
],
$content
);
}
if (in_array(strtolower(ask("Do you want to dump DB? [Y/n]") ?: 'y'), $y, true)) {
$host = ask("Host[localhost]: ") ?: 'localhost';
$dbname = ask("DB Name: ");
$user = ask("User[root]: ") ?: 'root';
fwrite(STDOUT, "Password: ");
system('stty -echo');
$password = trim(fgets(STDIN));
system('stty echo');
$content = str_replace(
[
"'dump_database' => 0",
"'host' => 'localhost'",
"'user' => ''",
"'pass' => ''",
"'dbname' => ''",
],
[
"'dump_database' => 1",
"'host' => '$host'",
"'user' => '$user'",
"'pass' => '$password'",
"'dbname' => '$dbname'",
],
$content
);
}
$content = file_put_contents(__DIR__ . '/config.php', $content);
fwrite(STDOUT, "\nSuccess install backup.php file.\n\n");
if (in_array(strtolower(ask("Register backup to portal? [Y/n]") ?: 'y'), $y, true)) {
$_SERVER['argv'] = [__FILE__, 'register'];
include __DIR__ . '/backup.php';
}
fwrite(STDOUT, "\n");
function ask($question)
{
fwrite(STDOUT, $question);
return trim(fgets(STDIN), "\r\n");
}