]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blame - settings/install.php
settings/install.php: make a big start to the installation page
[irc/unrealircd/unrealircd-webpanel.git] / settings / install.php
CommitLineData
78069032
VP
1<?php
2
3require_once "../common.php";
4
5$uri = $_SERVER['REQUEST_URI'];
6define('BASE_URL', str_replace("settings/install.php","",$uri));
7
8$writable = (is_writable("../config/")) ? true: false;
9?>
10<!DOCTYPE html>
11<head>
12<div class="media">
13<div class="media-body">
14
15 <meta name="viewport" content="width=device-width, initial-scale=1">
16 <meta name="HandheldFriendly" content="true">
17
18<link href="<?php echo get_config("base_url"); ?>css/unrealircd-admin.css" rel="stylesheet">
19
20
21 <!-- Latest compiled and minified CSS -->
22 <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css">
23
24<!-- Font Awesome JS -->
25<script defer src="https://use.fontawesome.com/releases/v6.2.1/js/solid.js" integrity="sha384-tzzSw1/Vo+0N5UhStP3bvwWPq+uvzCMfrN1fEFe+xBmv1C/AtVX5K0uZtmcHitFZ" crossorigin="anonymous"></script>
26<script defer src="https://use.fontawesome.com/releases/v6.2.1/js/fontawesome.js" integrity="sha384-6OIrr52G08NpOFSZdxxz1xdNSndlD4vdcf/q2myIUVO0VsqaGHJsB0RaBE01VTOY" crossorigin="anonymous"></script>
27
28<!-- Font Awesome icons -->
29<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.1/css/all.min.css">
30<script src="<?php echo get_config("base_url"); ?>js/unrealircd-admin.js"></script>
31<title>UnrealIRCd Panel</title>
32<link rel="icon" type="image/x-icon" href="<?php echo get_config("base_url"); ?>img/favicon.ico">
33
34<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
35<!-- Popper.JS -->
36<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js" integrity="sha384-cs/chFZiN24E4KMATLdqdvsezGxaGsi4hLGOzlXwp5UZB1LY//20VyM2taTB4QvJ" crossorigin="anonymous"></script>
37<!-- Bootstrap JS -->
38<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js" integrity="sha384-uefMccjFJAIv6A+rW+L4AHf99KvxDjWSu1z9VI8SKNVmz4sk7buKt/6v9KI65qnm" crossorigin="anonymous"></script>
39</div></div>
40</head>
41
42<body role="document">
43
44 <div class="container"><div class="row"><img src="../img/unreal.jpg" width="35px" height="35px" style="margin-right: 15px"><h3>UnrealIRCd Admin Panel Configuration and Setup</h3></div></div><?php
45
46 if (file_exists("../config/config.php"))
47 {
48 ?><br><div class="container">You're already configured!
49 <br>
50 <a class="text-center btn btn-primary" href="<?php echo BASE_URL; ?>">Take me home!</a>
51 </div>
52 <?php
53 return;
54 }
55
56?>
57<div id="page1" class="container">
58 <br>
59 Welcome to the IRC admin panel setup page. This setup process will guide you through the necessary steps to configure your IRC uplink and choose your preferred authentication method.
60 <br><br>
61 The first page will ask you for your UnrealIRCd uplink credentials and will test them to ensure that the connection is successful. This step is crucial for the Admin Panel to function properly.
62 <br><br>
63 Next, you will be asked to choose your preferred authentication method between file-based and SQL. Depending on your choice, additional steps may be required. If you choose SQL, you will be given the option to set up the appropriate tables in the database.
64 <br><br>
65 After that, we'll take you through a short account creation process where you get to create your first account. Once you're setup and logged in, you'll be able to add more users and choose what they can do on your panel.
66 <br><br>
67 Finally, the last page will offer additional options that you can customize according to your preferences. Once you have completed all the necessary steps, your IRC admin panel will be fully configured and ready for use.
68 <br><br>
69 Should you wish to edit your config further, you will find it in the <code>config</code> directory called <code>config.php</code>
70 <br><br>
71 We recommend that you carefully read each page and fill in all the required information accurately to ensure a seamless setup process. Thank you for choosing UnrealIRCd Admin Panel, and we hope you find it useful for managing your server/network.
72 <br><br>
73
74 <div id="proceed_div" class="text-center"><?php echo ($writable)
75 ? '<div id="page1_proceed" class="btn btn-primary">Proceed</div>'
76 : 'Before we begin, you must let the shell user who owns the webpanel have permission to create files.<br>
77 <div id="chmod_help" class="btn btn-sm btn-info">Get info</div>'; ?>
78 </div>
79</div>
80
81<!-- Form start -->
82<form>
83<div id="page2" class="container">
84 <h5>RPC Uplink Information</h5>
85 <br>
86 First, let's get you linked with UnrealIRCd.
87 <br><br>
88 If you don't have your credentials, you will need to create them. This is done in your <code>unrealircd.conf</code> <div id="rpc_instructions" class="ml-4 btn btn-sm btn-info">View instructions</div>
89 <br><br>
90 <form>
91 <div class="form-group">
92 <label for="rpc_iphost">Hostname or IP</label>
93 <input name="rpc_iphost" type="text" class="form-control" id="rpc_iphost" aria-describedby="hostname_help" placeholder="127.0.0.1">
94 <small id="hostname_help" class="form-text text-muted">The hostname or IP address of your UnrealIRCd server. You should use <code>127.0.0.1</code> for the same machine.</small>
95 </div>
96 <div class="form-group">
97 <label for="rpc_port">Server Port</label>
98 <input name="rpc_port" type="text" class="form-control" id="rpc_port" aria-describedby="port_help" placeholder="8600">
99 <small id="port_help" class="form-text text-muted">The port which you designated for RPC connections in your <code>unrealircd.conf</code></small>
100 </div>
101 <div class="form-group form-check">
102 <input name="rpc_ssl" type="checkbox" class="form-check-input" id="rpc_ssl">
103 <label class="form-check-label" for="rpc_ssl">My UnrealIRCd server is on a different machine, verify the TLS connection.</label>
104 </div>
105 <div class="form-group">
106 <label for="rpc_username">Username</label>
107 <input name="rpc_user" type="text" class="form-control" id="rpc_user" aria-describedby="username_help" placeholder="apiuser">
108 <small id="username_help" class="form-text text-muted">The name of your <code>rpc-user</code> block as defined in your <code>unrealircd.conf</code></small>
109 </div>
110 <div class="form-group">
111 <label for="rpc_password">Password</label>
112 <input name="rpc_password" type="password" class="form-control" id="rpc_password">
113 </div>
114 <div class="text-center">
115 <div id="page2_back" class="btn btn-secondary mr-3">Back</div>
116 <div id="page2_next" class="btn btn-primary ml-3" style="display: none">Next</div>
117 <div id="page2_test_connection" class="btn btn-primary ml-3">Test connection</div>
118 </div>
119</div>
120
121
122<div id="page3" class="container">
123 <h5>Authentication Method</h5>
124 <br>
125 Here's where you can choose which type of authentication mechanism you want to use behind the scenes.
126 <br><br>
127 Please choose from the available options:
128 <div class="form-group">
129 <div class="form-check">
130 <input class="form-check-input" type="radio" name="auth_method" id="file_auth_radio" value="file_auth">
131 <label class="form-check-label" for="file_auth_radio">
132 File-based Authentication (Uses local files as a database, no setup needed)
133 </label>
134 </div>
135 <div class="form-check">
136 <input class="form-check-input" type="radio" name="auth_method" id="sql_auth_radio" value="sql_auth">
137 <label class="form-check-label" for="sql_auth_radio">
138 SQL Authentication (Requires an SQL database)
139 </label>
140 </div>
141 </div>
142 <br>
143 <div id="sql_form" style="display:none">
144 Please enter your SQL information. <div id="sql_instructions" class="ml-4 btn btn-sm btn-info">View instructions</div>
145 <div class="form-group">
146 <label for="sql_iphost">Hostname or IP</label>
147 <input name="sql_iphost" type="text" class="form-control" id="sql_iphost" aria-describedby="hostname_help" placeholder="127.0.0.1">
148 <small id="hostname_help" class="form-text text-muted">The hostname or IP address of your SQL server. You should use <code>127.0.0.1</code> for the same machine.</small>
149 </div>
150 <div class="form-group">
151 <label for="sql_db">Database name</label>
152 <input name="sql_db" type="text" class="form-control" id="sql_db" aria-describedby="port_help">
153 <small id="port_help" class="form-text text-muted">The name of the SQL database to write to and read from.</small>
154 </div>
155 <div class="form-group">
156 <label for="sql_username">Username</label>
157 <input name="sql_user" type="text" class="form-control" id="sql_user" aria-describedby="username_help">
158 <small id="username_help" class="form-text text-muted">The name of SQL user</small>
159 </div>
160 <div class="form-group">
161 <label for="sql_password">Password</label>
162 <input name="sql_password" type="password" class="form-control" id="sql_password">
163 </div>
164 </div>
165 <div class="text-center">
166 <div id="page3_back" class="btn btn-secondary mr-3">Back</div>
167 <div id="page3_next" class="btn btn-primary ml-3">Next</div>
168 <div id="page3_test_connection" class="btn btn-primary ml-3" style="display: none">Test connection</div>
169 </div>
170</div>
171<div id="page4" class="container" style="display:none">
172 <h5>Create your account</h5>
173 <br>
174 Great! Everything looks good so far! Just one last thing before we confirm everything and get you set up.<br>
175 You need an account! Let's make one.<br><br>
176 <div class="form-group">
177 <label for="account_username">Pick a username</label>
178 <input name="account_user" type="text" class="form-control" id="account_user" aria-describedby="username_help">
179 <small id="username_help" class="form-text text-muted">Pick a username! Please make sure it contains no spaces, and is made of only letters and numbers.</small>
180 </div>
181 <div class="form-group">
182 <label for="account_password">Password</label>
183 <input name="account_password" type="password" class="form-control" id="account_password" aria-describedby="password_help">
184 <small id="password_help" class="form-text text-muted">Please choose a password that at least 8 characters long, contains at least one uppercase letter, one lowercase letter, one number and one symbol.</small>
185 </div>
186 <div class="form-group">
187 <label for="account_password_conf">Confirm password</label>
188 <input name="account_password_conf" type="password" class="form-control" id="account_password_conf">
189 <small id="pass_not_match" class="form-text" style="color:red;display:none">Passwords do not match</small>
190 </div>
191 <div class="form-group">
192 <label for="account_email">Email address</label>
193 <input name="account_email" type="text" class="form-control" id="account_email" aria-describedby="email_help">
194 <small id="email_help" class="form-text" style="color:red;display:none">Please enter a valid email address</small>
195 </div>
196 <div class="form-group">
197 <label for="account_fname">First name</label>
198 <input name="account_fname" type="text" class="form-control" id="account_lname">
199 </div>
200 <div class="form-group">
201 <label for="account_lname">Last name</label>
202 <input name="account_lname" type="text" class="form-control" id="account_lname">
203 </div>
204 <div class="form-group">
205 <label for="account_bio">Bio</label>
206 <textarea name="account_bio" type="text" class="form-control" id="account_bio"></textarea>
207 </div>
208 <div class="text-center">
209 <div id="page4_back" class="btn btn-secondary mr-3">Back</div>
210 <div id="page4_next" class="btn btn-primary ml-3">Next</div>
211 </div>
212</div>
213
214<!-- Form end -->
215</form>
216<script>
217 let BASE_URL = '<?php echo BASE_URL; ?>';
218 let chmod_help = document.getElementById('chmod_help');
219
220 if (chmod_help)
221 chmod_help.addEventListener('click', e => {
222 window.open("https://www.unrealircd.org/docs/UnrealIRCd_webpanel#Permissions");
223 });
224
225 let page1 = document.getElementById('page1');
226 let page2 = document.getElementById('page2');
227 let page3 = document.getElementById('page3');
228 let rpc_instructions = document.getElementById('rpc_instructions');
229 let setup_start = document.getElementById('page1_proceed');
230
231 let rpc_host = document.getElementById('rpc_iphost');
232 let rpc_port = document.getElementById('rpc_port');
233 let rpc_user = document.getElementById('rpc_user');
234 let rpc_pass = document.getElementById('rpc_password');
235 let rpc_tls = document.getElementById('rpc_ssl');
236
237 let page2_back = document.getElementById('page2_back');
238 let page2_next = document.getElementById('page2_next');
239 let test_conn = document.getElementById('page2_test_connection');
240
241 let file_auth_radio = document.getElementById('file_auth_radio');
242 let sql_auth_radio = document.getElementById('sql_auth_radio');
243 let sql_form = document.getElementById('sql_form');
244 let sql_host = document.getElementById('sql_iphost');
245 let sql_db = document.getElementById('sql_db');
246 let sql_user = document.getElementById('sql_user');
247 let sql_pass = document.getElementById('sql_password');
248 let sql_test_conn = document.getElementById('page3_test_connection');
249 let page3_back = document.getElementById('page3_back');
250 let page3_next = document.getElementById('page3_next');
251
252
253 let page4_back = document.getElementById('page4_back');
254 let page4_next = document.getElementById('page4_next');
255
256 page2.style.display = 'none';
257 page3.style.display = 'none';
258
259 rpc_instructions.addEventListener('click', e => {
260 window.open("https://www.unrealircd.org/docs/UnrealIRCd_webpanel#Configuring_UnrealIRCd");
261 });
262
263 setup_start.addEventListener('click', e => {
264 page1.style.display = 'none';
265 page2.style.display = '';
266 });
267
268 page2_back.addEventListener('click', e => {
269 page2.style.display = 'none';
270 page1.style.display = '';
271 });
272 page2_next.addEventListener('click', e => {
273 page2.style.display = 'none';
274 page3.style.display = '';
275 sql_form.style.display = 'none';
276 });
277
278 /* The RPC connection tester! */
279 test_conn.addEventListener('click', e => {
280 test_conn.classList.add('disabled');
281 test_conn.innerHTML = "Checking...";
282 fetch(BASE_URL + 'api/test_connection.php?method=rpc&host='+rpc_host.value+'&port='+rpc_port.value+'&user='+rpc_user.value+'&password='+rpc_pass.value+'&tls_verify='+rpc_tls.checked)
283 .then(response => response.json())
284 .then(data => {
285 if (data.success)
286 {
287 // do something with the JSON data
288 test_conn.innerHTML = "Success!";
289 setTimeout(function() {
290 test_conn.style.display = 'none';
291 page2_next.style.display = '';
292 }, 2000);
293 }
294 else
295 {
296 test_conn.innerHTML = "Failed!";
297 setTimeout(function() {
298 test_conn.innerHTML = "Test connection";
299 test_conn.classList.remove('disabled');
300 }, 2000);
301 }
302 })
303 .catch(error => {
304 test_conn.innerHTML = "Failed!";
305 setTimeout(function() {
306 test_conn.innerHTML = "Test connection";
307 test_conn.classList.remove('disabled');
308 }, 2000);
309 });
310 });
311
312
313 page3_back.addEventListener('click', e => {
314 page3.style.display = 'none';
315 page2.style.display = '';
316 });
317 page3_next.addEventListener('click', e => {
318 page3.style.display = 'none';
319 page4.style.display = '';
320 });
321
322 file_auth_radio.addEventListener('click', e => {
323 if (file_auth_radio.checked){
324 sql_form.style.display = 'none';
325 sql_test_conn.style.display = 'none';
326 page3_next.style.display = '';
327 }
328 });
329 sql_auth_radio.addEventListener('click', e => {
330 if (!file_auth_radio.checked){
331 sql_form.style.display = '';
332 sql_test_conn.style.display = '';
333 page3_next.style.display = 'none';
334 }
335 });
336
337 sql_instructions.addEventListener('click', e => {
338 window.open("https://www.unrealircd.org/docs/UnrealIRCd_webpanel#SQL_Authentication");
339 });
340
341 sql_test_conn.addEventListener('click', e => {
342 sql_test_conn.classList.add('disabled');
343 sql_test_conn.innerHTML = "Checking...";
344 fetch(BASE_URL + 'api/test_connection.php?method=sql&host='+sql_host.value+'&database='+sql_db.value+'&user='+sql_user.value+'&password='+sql_pass.value)
345 .then(response => response.json())
346 .then(data => {
347 if (data.success)
348 {
349 // do something with the JSON data
350 sql_test_conn.innerHTML = "Success!";
351 setTimeout(function() {
352 sql_test_conn.style.display = 'none';
353 page3_next.style.display = '';
354 }, 2000);
355 }
356 else
357 {
358 sql_test_conn.innerHTML = "Failed!";
359 setTimeout(function() {
360 sql_test_conn.innerHTML = "Test connection";
361 sql_test_conn.classList.remove('disabled');
362 }, 2000);
363 }
364 })
365 .catch(error => {
366 sql_test_conn.innerHTML = "Failed!";
367 setTimeout(function() {
368 sql_test_conn.innerHTML = "Test connection";
369 sql_test_conn.classList.remove('disabled');
370 }, 2000);
371 });
372 });
373
374 page4_back.addEventListener('click', e => {
375 page4.style.display = 'none';
376 page3.style.display = '';
377 });
378 page4_next.addEventListener('click', e => {
379 page4.style.display = 'none';
380 page5.style.display = '';
381 });
382
383</script>