-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
290 lines (251 loc) · 14.2 KB
/
index.php
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
<?php
session_start();
if(file_exists("../installed")) {
header("location: ../");
}
//fopen("../installed","w");
if(!isset($_GET["step"]) || empty($_GET["step"])) {
$step = "1";
} else {
$step = $_GET["step"];
}
if($step=="3") {
$cf_title = $_GET["cf_title"];
$cf_slogan = $_GET["cf_slogan"];
$cf_url = $_GET["cf_url"];
$cf_sub = $_GET["cf_sub"];
$cf_lang = $_GET["cf_lang"];
$db_host = $_GET["db_host"];
$db_user = $_GET["db_user"];
$db_pass = $_GET["db_pass"];
$db_tale = $_GET["db_tale"];
$conn = new mysqli($db_host, $db_user, $db_pass, $db_tale);
$conn->set_charset("utf8mb4");
if(!$conn->connect_error) {
// Insert data from SQL file to Database
// https://stackoverflow.com/questions/19751354/how-do-i-import-a-sql-file-in-mysql-database-using-php Thx!
$filename = 'kr34t3.sql';
$templine = '';
$lines = file($filename);
foreach ($lines as $line) {
if (substr($line, 0, 2) == '--' || $line == '')continue;
$templine .= $line;
if (substr(trim($line), -1, 1) == ';') {
$conn->query($templine);
$templine = '';
}
}
echo "Tables imported successfully! You may continue with the istallation. If the next step errors, please comment on the latest KR34T3 thread on the Leak.to Forums (thread author: saint).";
}
$file = fopen("config.inc.php", "a+");
fwrite($file, "<?php\n\n");
fwrite($file, "\$config[\"general\"][\"name\"] = \"$cf_title\";\n");
fwrite($file, "\$config[\"general\"][\"slogan\"] = \"$cf_slogan\";\n");
fwrite($file, "\$config[\"general\"][\"url\"] = \"$cf_url\";\n");
fwrite($file, "\$config[\"general\"][\"folder\"] = \"$cf_sub\";\n");
fwrite($file, "\$config[\"general\"][\"murdoch_murdoch\"] = \"0\";\n");
fwrite($file, "\$config[\"general\"][\"lang\"] = \"$cf_lang\";\n\n");
fwrite($file, "\$config[\"db\"][\"host\"] = \"$db_host\";\n");
fwrite($file, "\$config[\"db\"][\"user\"] = \"$db_user\";\n");
fwrite($file, "\$config[\"db\"][\"pass\"] = \"$db_pass\";\n");
fwrite($file, "\$config[\"db\"][\"tale\"] = \"$db_tale\";\n\n");
fwrite($file, "/* DO NOT EDIT BELOW THIS LINE */\n\n");
fwrite($file, "\$name = \$config[\"general\"][\"name\"];\n");
fwrite($file, "\$slogan = \$config[\"general\"][\"slogan\"];\n");
fwrite($file, "\$url = \$config[\"general\"][\"url\"].\$config[\"general\"][\"folder\"];\n\n");
fwrite($file, "\$conn = new mysqli(\$config[\"db\"][\"host\"], \$config[\"db\"][\"user\"], \$config[\"db\"][\"pass\"], \$config[\"db\"][\"tale\"]);\n");
fwrite($file, "\$conn->set_charset(\"utf8mb4\");\n\n");
fwrite($file, "if (\$conn->connect_error) {\n");
fwrite($file, " // Something went wrong?\n");
fwrite($file, " die(\"Couldn't connect to Database: \" . \$conn->connect_error);\n");
fwrite($file, "}\n");
fwrite($file, "\n?>");
fclose($file);
$before = "config.inc.php";
$after = "../core/config.inc.php";
rename($before, $after);
chmod($after, 0777);
}
if($step=="4") {
$at_user = $_GET["at_user"];
$at_pass1 = $_GET["at_pass1"];
$at_pass2 = $_GET["at_pass2"];
if($at_pass1===$at_pass2) {
$db_host = $_GET["db_host"];
$db_user = $_GET["db_user"];
$db_pass = $_GET["db_pass"];
$db_tale = $_GET["db_tale"];
$conn = new mysqli($db_host, $db_user, $db_pass, $db_tale);
$conn->set_charset("utf8mb4");
$at_pass = $at_pass1;
$at_pass = hash('sha512', $at_pass);
$conn->query("INSERT INTO `user`(`username`, `password`) VALUES('$at_user','$at_pass')");
} else {
echo "<script>
history.back()
</script>";
}
}
if($step=="5") {
fopen("../installed", "w");
header("location: ../index.php?page=admin&act=login");
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://unpkg.com/nes.css@2.3.0/css/nes.min.css" rel="stylesheet" />
<title>Installation: Step <?= $step ?> -=- KR34T3-Release-System</title>
<link href="https://saintly2k.github.io/saintly2k/cnd/css/KR34T3.css" type="text/css" rel="stylesheet">
<link href="../assets/css/style.css" type="text/css" rel="stylesheet">
</head>
<body style="background-color:grey;color:#fff;padding-top:20px">
<div class="container">
<main class="main-content">
<section class="topic nes-container is-rounded is-dark is-centered">
<a href="#" style="text-decoration: none;">
<img src="banner.png" width="100%">
</a>
</section>
<?php if($step=="1") { ?>
<div class="nes-container is-dark is-rounded with-title">
<p class="title">KR34T3 Installation</p>
<p>Welcome to KR34T3! In the next few steps, you're gonna setup your own System :P</p>
<a type="button" class="nes-btn is-primary" style="width:100%" href="?step=2">Let's start!</a>
</div>
<?php } elseif($step=="2") { ?>
<form method="get" action="">
<input type="text" readonly hidden value="3" name="step">
<div class="nes-container is-dark is-rounded with-title">
<p class="title">Default Config</p>
<div style="background-color:#212529; padding: 1rem;" class="nes-field is-inline">
<label for="cf_title" style="color:#fff;">Name</label>
<input required type="text" id="cf_title" class="nes-input is-dark" placeholder="KR34T3" name="cf_title">
</div>
<div style="background-color:#212529; padding: 1rem;" class="nes-field is-inline">
<label for="cf_slogan" style="color:#fff;">Slogan</label>
<input type="text" id="cf_slogan" class="nes-input is-dark" placeholder="your own release-system" name="cf_slogan">
</div>
<div style="background-color:#212529; padding: 1rem;" class="nes-field is-inline">
<label for="cf_url" style="color:#fff;">Domain</label>
<input required type="text" id="cf_url" class="nes-input is-dark" placeholder="https://kr34t3.url/" name="cf_url">
</div>
<div style="background-color:#212529; padding: 1rem;" class="nes-field is-inline">
<label for="cf_sub" style="color:#fff;">Folder</label>
<input type="text" id="cf_sub" class="nes-input is-dark" placeholder="kr34t3/" name="cf_sub">
</div>
<div style="background-color:#212529; padding: 1rem 1.2rem 1rem 1rem;width:calc(100% + 8px)">
<label for="cf_lang" style="color:#fff">Language</label>
<div class="nes-select is-dark">
<select required id="cf_lang" name="cf_lang">
<option value="" disabled selected hidden>Select...</option>
<option value="de-informal">Deutsch (Du-Form, Informal)</option>
<option value="de-formal">Deutsch (Sie-Form, Formal)</option>
<option value="en-us">English (US)</option>
</select>
</div>
</div>
</div>
<div class="nes-container is-dark is-rounded with-title">
<p class="title">MySQL Database</p>
<div style="background-color:#212529; padding: 1rem;" class="nes-field is-inline">
<label for="db_host" style="color:#fff;">Host</label>
<input required type="text" id="db_host" class="nes-input is-dark" placeholder="localhost" name="db_host">
</div>
<div style="background-color:#212529; padding: 1rem;" class="nes-field is-inline">
<label for="db_user" style="color:#fff;">User</label>
<input required type="text" id="db_user" class="nes-input is-dark" placeholder="root" name="db_user">
</div>
<div style="background-color:#212529; padding: 1rem;" class="nes-field is-inline">
<label for="db_pass" style="color:#fff;">Password</label>
<input type="text" id="db_pass" class="nes-input is-dark" placeholder="root" name="db_pass">
</div>
<div style="background-color:#212529; padding: 1rem;" class="nes-field is-inline">
<label for="db_tale" style="color:#fff;">Table</label>
<input type="text" id="db_tale" class="nes-input is-dark" placeholder="kr34t3" name="db_tale">
</div>
</div>
<div class="nes-container is-dark is-rounded with-title">
<p class="title">Save Config</p>
<input type="submit" class="nes-btn is-primary" style="width:100%" value="Save Config">
</div>
</form>
<?php } elseif($step=="3") { ?>
<?php if(!$conn->connect_error) {?>
<div class="nes-container is-dark is-rounded with-title">
<p class="title">Success</p>
<p>Successfully connected to Database!</p>
</div>
<?php if(empty($_GET["cf_title"]) || !isset($_GET["cf_title"])) { ?>
<div class="nes-container is-dark is-error is-rounded with-title">
<p class="title">Error</p>
<p>If you leave "Name" empty, it will result in an error! <button onclick="history.back()" type="button" class="nes-btn is-error">Fix this!</button></p>
</div>
<?php } ?>
<?php if(empty($_GET["cf_url"]) || !isset($_GET["cf_url"])) { ?>
<div class="nes-container is-dark is-error is-rounded with-title">
<p class="title">Error</p>
<p>If you leave "Domain" empty, it will result in an error! <button onclick="history.back()" type="button" class="nes-btn is-error">Fix this!</button></p>
</div>
<?php } ?>
<?php if(empty($_GET["cf_lang"]) || !isset($_GET["cf_lang"])) { ?>
<div class="nes-container is-dark is-error is-rounded with-title">
<p class="title">Error</p>
<p>If you leave "Language" empty, it will result in an error! <button onclick="history.back()" type="button" class="nes-btn is-error">Fix this!</button></p>
</div>
<?php } ?>
<form method="get" action="">
<div class="nes-container is-dark is-rounded with-title">
<p class="title">Create Admin</p>
<div style="background-color:#212529; padding: 1rem;" class="nes-field is-inline">
<label for="at_user" style="color:#fff;">Username</label>
<input required type="text" name="step" value="4" hidden readonly>
<input required type="text" name="db_host" value="<?= $_GET["db_host"] ?>" hidden readonly>
<input required type="text" name="db_user" value="<?= $_GET["db_user"] ?>" hidden readonly>
<input required type="text" name="db_pass" value="<?= $_GET["db_pass"] ?>" hidden readonly>
<input required type="text" name="db_tale" value="<?= $_GET["db_tale"] ?>" hidden readonly>
<input required type="text" id="at_user" class="nes-input is-dark" placeholder="admin" name="at_user">
</div>
<div style="background-color:#212529; padding: 1rem;" class="nes-field is-inline">
<label for="at_pass1" style="color:#fff;">Password</label>
<input required type="password" id="at_pass1" class="nes-input is-dark" placeholder="c00l_p4ssw0rd_6969" name="at_pass1">
</div>
<div style="background-color:#212529; padding: 1rem;" class="nes-field is-inline">
<label for="at_pass2" style="color:#fff;">Repeat</label>
<input required type="password" id="at_pass2" class="nes-input is-dark" placeholder="c00l_p4ssw0rd_6969" name="at_pass2">
</div>
<input type="submit" class="nes-btn is-primary" style="width:100%" value="Create Account!">
</div>
</form>
<?php } else { ?>
<div class="nes-container is-dark is-error is-rounded with-title">
<p class="title">Error</p>
<p>Errror establishing a MySQL Connection: <?= $conn->connect_error ?> <button onclick="history.back()" type="button" class="nes-btn is-error">fix this!</button></p>
</div>
<?php } ?>
<?php } elseif($step=="4") { ?>
<?php if(!$conn->connect_error) { ?>
<div class="nes-container is-dark is-rounded with-title">
<form method="get" action="">
<p class="title">Success</p>
<p>Your System is ready to go!</p>
<input required type="text" name="step" value="5" hidden readonly>
<input type="submit" class="nes-btn is-primary" style="width:100%" value="Lock installation Panel">
</form>
</div>
<?php } else { ?>
<div class="nes-container is-dark is-error is-rounded with-title">
<p class="title">Error</p>
<p>Errror establishing a MySQL Connection: <?= $conn->connect_error ?> <button onclick="history.back()" type="button" class="nes-btn is-error">Fix this!</button></p>
</div>
<?php } ?>
<?php } ?>
</main>
</div>
<div class="nes-container is-rounded is-dark is-centered">
Copyright © 2021-2022 Project H33T x HENAI.eu</a>
</div>
</body>
</html>