]>
Commit | Line | Data |
---|---|---|
46e8f612 VP |
1 | <?php |
2 | ||
3 | require_once "../../common.php"; | |
1cedd608 VP |
4 | ?> |
5 | <!DOCTYPE html> | |
6 | <head> | |
7 | <div class="media"> | |
8 | <div class="media-body"> | |
46e8f612 | 9 | |
1cedd608 VP |
10 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
11 | <meta name="HandheldFriendly" content="true"> | |
12 | ||
13 | <link href="<?php echo BASE_URL; ?>css/unrealircd-admin.css" rel="stylesheet"> | |
14 | ||
15 | ||
16 | <!-- Latest compiled and minified CSS --> | |
17 | <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css"> | |
18 | ||
19 | <!-- Font Awesome JS --> | |
20 | <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> | |
21 | <script defer src="https://use.fontawesome.com/releases/v6.2.1/js/fontawesome.js" integrity="sha384-6OIrr52G08NpOFSZdxxz1xdNSndlD4vdcf/q2myIUVO0VsqaGHJsB0RaBE01VTOY" crossorigin="anonymous"></script> | |
22 | ||
23 | <!-- Font Awesome icons --> | |
24 | <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.1/css/all.min.css"> | |
25 | <script src="<?php echo BASE_URL; ?>js/unrealircd-admin.js"></script> | |
26 | <title>UnrealIRCd Panel</title> | |
27 | <link rel="icon" type="image/x-icon" href="<?php echo BASE_URL; ?>img/favicon.ico"> | |
28 | </head> | |
29 | <body role="document"> | |
30 | ||
31 | <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script> | |
32 | <!-- Popper.JS --> | |
33 | <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> | |
34 | <!-- Bootstrap JS --> | |
35 | <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js" integrity="sha384-uefMccjFJAIv6A+rW+L4AHf99KvxDjWSu1z9VI8SKNVmz4sk7buKt/6v9KI65qnm" crossorigin="anonymous"></script> | |
36 | ||
37 | ||
38 | <?php | |
46e8f612 VP |
39 | if (!isset($_POST) || empty($_POST)) |
40 | { | |
41 | ?> | |
1cedd608 | 42 | <div class="container"> |
46e8f612 VP |
43 | <h4>SQL Setup</h4> |
44 | In order to use SQL Auth, the relevant SQL tables must be created.<br> | |
45 | If, for some reason, that's not what you want, please remove <code>"sql_auth"</code> from the plugins option in your webpanel configuration.<br><br> | |
46 | Thanks for using SQL Auth plugin!<br><br> | |
47 | ||
48 | <form method="post"> | |
49 | <button id="createbtn" name="createbtn" class="btn btn-primary" type="submit">Create the tables!</button> | |
50 | </form> | |
1cedd608 | 51 | </div> |
46e8f612 VP |
52 | <?php |
53 | } | |
54 | elseif (isset($_POST['createbtn'])) | |
55 | { | |
56 | $conn = sqlnew(); | |
57 | $conn->query("CREATE TABLE IF NOT EXISTS " . SQL_PREFIX . "users ( | |
58 | user_id int AUTO_INCREMENT NOT NULL, | |
59 | user_name VARCHAR(255) NOT NULL, | |
60 | user_pass VARCHAR(255) NOT NULL, | |
61 | user_email VARCHAR(255), | |
62 | user_fname VARCHAR(255), | |
63 | user_lname VARCHAR(255), | |
64 | user_bio VARCHAR(255), | |
65 | created VARCHAR(255), | |
66 | PRIMARY KEY (user_id) | |
67 | )"); | |
68 | ||
69 | /** | |
70 | * Patch for beta users | |
71 | * This adds the email column to existing tables without it | |
72 | */ | |
73 | $columns = $conn->query("SHOW COLUMNS FROM " . SQL_PREFIX . "users"); | |
74 | $column_names = array(); | |
75 | $c = $columns->fetchAll(); | |
76 | ||
77 | foreach($c as $column) { | |
78 | $column_names[] = $column['Field']; | |
79 | } | |
80 | $column_exists = in_array("user_email", $column_names); | |
81 | if (!$column_exists) { | |
82 | $conn->query("ALTER TABLE " . SQL_PREFIX . "users ADD COLUMN user_email varchar(255)"); | |
83 | } | |
84 | ||
85 | /** | |
86 | * Another patch for beta users | |
87 | * This changes the size of the meta_value so we can store more | |
88 | */ | |
89 | ||
90 | $conn->query("CREATE TABLE IF NOT EXISTS " . SQL_PREFIX . "user_meta ( | |
91 | meta_id int AUTO_INCREMENT NOT NULL, | |
92 | user_id int NOT NULL, | |
93 | meta_key VARCHAR(255) NOT NULL, | |
94 | meta_value VARCHAR(255), | |
95 | PRIMARY KEY (meta_id) | |
96 | )"); | |
97 | $conn->query("CREATE TABLE IF NOT EXISTS " . SQL_PREFIX . "auth_settings ( | |
98 | id int AUTO_INCREMENT NOT NULL, | |
99 | setting_key VARCHAR(255) NOT NULL, | |
100 | setting_value VARCHAR(255), | |
101 | PRIMARY KEY (id) | |
102 | )"); | |
103 | $conn->query("CREATE TABLE IF NOT EXISTS " . SQL_PREFIX . "fail2ban ( | |
104 | id int AUTO_INCREMENT NOT NULL, | |
105 | ip VARCHAR(255) NOT NULL, | |
106 | count VARCHAR(255), | |
107 | PRIMARY KEY (id) | |
108 | )"); | |
109 | $c = []; | |
110 | if (($columns = $conn->query("SHOW COLUMNS FROM ".SQL_PREFIX."user_meta"))); | |
111 | $c = $columns->fetchAll(); | |
112 | if (!empty($c)) | |
113 | $conn->query("ALTER TABLE `".SQL_PREFIX."user_meta` CHANGE `meta_value` `meta_value` VARCHAR(5000) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL"); | |
114 | ||
115 | ||
116 | new AuthSettings(); | |
117 | ||
118 | Message::Success("Congratulations, you're all ready to go!"); | |
119 | ?> | |
120 | <a class="btn btn-primary" href="<?php echo BASE_URL; ?>">Take me home!</a> | |
121 | <a class="btn btn-warning" href="<?php echo BASE_URL."settings"; ?>">Settings</a> | |
122 | <?php | |
123 | } | |
124 | require_once "../../footer.php"; |