]>
Commit | Line | Data |
---|---|---|
9ffc5134 VP |
1 | <?php |
2 | require_once "../common.php"; | |
3 | require_once UPATH . "/header.php"; | |
4 | ||
721db4c3 VP |
5 | $rehash_errors = []; |
6 | $rehash_warnings = []; | |
7 | $rehash_success = []; | |
8 | ||
9c968544 VP |
9 | if (!empty($_POST)) |
10 | { | |
11 | do_log($_POST); | |
721db4c3 VP |
12 | if (isset($_POST['rehash'])) |
13 | foreach ($_POST['serverch'] as $servID) | |
14 | if ($response = $rpc->server()->rehash($servID)) | |
15 | { | |
16 | $serb = $rpc->server()->get($servID); | |
17 | do_log($servID, $response); | |
18 | if ($response->success || (!isset($response->success) != false && $response == true)) | |
19 | { | |
20 | $rehash_success[] = $serb->name; | |
21 | foreach($response->log as $log) | |
22 | { | |
23 | do_log($log->level); | |
24 | if ($log->level == "warn") | |
25 | $rehash_warnings[$log->log_source][] = $log->msg; | |
26 | } | |
27 | } | |
28 | else if (isset($response->success) && !$response->success) | |
29 | { | |
30 | foreach ($response->log as $log) | |
31 | { | |
32 | if ($log->level == "error") | |
33 | $rehash_errors[$log->log_source][] = $log->msg; | |
34 | } | |
35 | } | |
36 | } | |
9c968544 | 37 | } |
d72d1923 | 38 | $checkforupdates = (isset($_POST['checkforupdates'])) ? true : false; |
9ffc5134 VP |
39 | /* Get the server list */ |
40 | $servers = $rpc->server()->getAll(); | |
d72d1923 VP |
41 | $latest = 0; |
42 | if ($checkforupdates) | |
43 | { | |
44 | $latest = get_unreal_latest_version(); | |
45 | } | |
9ffc5134 VP |
46 | ?> |
47 | <h4>Servers Overview</h4> | |
721db4c3 VP |
48 | <?php |
49 | if (isset($_POST['rehash'])) | |
50 | { | |
1bc2dc2c VP |
51 | if (!empty($rehash_success)) { |
52 | do_log($rehash_success); | |
53 | $servlist_bullet = "<ol>"; | |
54 | ||
55 | foreach ($rehash_success as $serv) { | |
56 | $servlist_bullet .= "<li>$serv</li>"; | |
57 | } | |
58 | $servlist_bullet .= "</ol>"; | |
59 | $servlist_err_bullet = ""; | |
60 | foreach ($rehash_errors as $serv => $err) { | |
61 | $servlist_err_bullet .= "<h6>$serv</h6><ol>"; | |
62 | foreach ($err as $er) | |
63 | $servlist_err_bullet .= "<li>$er</li>"; | |
64 | echo "</ol>"; | |
65 | } | |
66 | $servlist_warn_bullet = ""; foreach ($rehash_warnings as $server => $warning) { | |
67 | $servlist_warn_bullet .= "<h6>$serv</h6><ol>"; | |
68 | foreach ($warning as $w) | |
69 | $servlist_warn_bullet .= "<li>$w</li>"; | |
70 | $servlist_warn_bullet .= "</ol>"; | |
71 | } | |
721db4c3 | 72 | if (!empty($rehash_success)) |
1bc2dc2c VP |
73 | Message::Success( |
74 | "The following server(s) were successfully rehashed:", | |
75 | $servlist_bullet | |
76 | ); | |
77 | if (!empty($rehash_warnings)) | |
78 | Message::Warning( | |
79 | "The following warning(s) were encountered:", | |
80 | $servlist_warn_bullet | |
81 | ); | |
82 | if (!empty($rehash_errors)) | |
83 | Message::Fail( | |
84 | "The following error(s) were encountered and the server(s) failed to rehash:", | |
85 | $servlist_err_bullet | |
86 | ); | |
87 | } | |
721db4c3 VP |
88 | } |
89 | if (isset($_POST['sf_name']) && strlen($_POST['sf_name'])) | |
90 | Message::Info("Listing servers which match name: \"" . $_POST['sf_name'] . "\""); | |
9ffc5134 | 91 | |
721db4c3 | 92 | ?> |
9ffc5134 VP |
93 | Click on a server name to view more information. |
94 | ||
95 | <div id="Servers"> | |
96 | ||
721db4c3 | 97 | |
ce3de101 | 98 | <table class="container-xxl table table-sm table-responsive caption-top table-striped"> |
9ffc5134 VP |
99 | <thead> |
100 | <th scope="col"><h5>Filter:</h5></th> | |
101 | <form action="" method="post"> | |
102 | <th scope="col" colspan="2">Name<input name="sf_name" type="text" class="form-control short-form-control"> | |
ce3de101 | 103 | <th scope="col"> <input class="btn btn-primary btn-sm" type="submit" value="Search"></th></form> |
9ffc5134 | 104 | </thead></table> |
d72d1923 VP |
105 | <form action="index.php" method="post"> |
106 | <div class="btn btn-sm btn-warning" data-toggle="modal" data-target="#rehash_modal"><i class="fa-solid fa-arrows-rotate"></i> Rehash Selected</div> | |
107 | <button name="checkforupdates" type="submit" class="btn btn-sm btn-info"><i class="fa-solid fa-cloud-arrow-down"></i> Check for upgrades</div><br> | |
1bc2dc2c VP |
108 | |
109 | <div class="modal fade" id="rehash_modal" tabindex="-1" role="dialog" aria-labelledby="confirmModalCenterTitle" aria-hidden="true"> | |
110 | <div class="modal-dialog modal-dialog-centered" role="document"> | |
111 | <div class="modal-content"> | |
d72d1923 VP |
112 | <div class="modal-header"> |
113 | <h5 class="modal-title" id="myModalLabel">Rehash Selected Servers</h5> | |
114 | <button type="button" class="close" data-dismiss="modal" aria-label="Close"> | |
115 | <span aria-hidden="true">×</span> | |
116 | </button> | |
117 | </div> | |
118 | <div class="modal-body"> | |
119 | Are you sure you want to rehash the selected servers? | |
120 | </div> | |
121 | <div class="modal-footer"> | |
122 | <button id="CloseButton" type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button> | |
123 | <button type="submit" class="btn btn-primary" name="rehash">Rehash Selected</button> | |
124 | </div> | |
1bc2dc2c VP |
125 | </div> |
126 | </div> | |
127 | </div> | |
ce3de101 | 128 | <table class="container-xxl table table-sm table-responsive caption-top table-striped"> |
9ffc5134 VP |
129 | <thead class="table-primary"> |
130 | <th scope="col"><input type="checkbox" label='selectall' onClick="toggle_server(this)" /></th> | |
131 | <th scope="col">Name</th> | |
11475e36 BM |
132 | <th scope="col">Users</th> |
133 | <th scope="col">Version</th> | |
9ffc5134 | 134 | <th scope="col">Connected to</th> |
11475e36 | 135 | <th scope="col">Up since</th> |
9ffc5134 VP |
136 | </thead> |
137 | ||
138 | <tbody> | |
9ffc5134 VP |
139 | <?php |
140 | ||
141 | foreach($servers as $server) | |
142 | { | |
143 | ||
144 | ||
145 | /* Some basic filtering for NAME */ | |
146 | if (isset($_POST['sf_name']) && strlen($_POST['sf_name']) && | |
147 | strpos(strtolower($server->name), strtolower($_POST['sf_name'])) !== 0 && | |
148 | strpos(strtolower($server->name), strtolower($_POST['sf_name'])) == false) | |
149 | continue; | |
150 | ||
d72d1923 VP |
151 | $update = ""; |
152 | if ($checkforupdates && $latest) | |
153 | { | |
154 | ||
155 | $tok = split($server->server->features->software, "-"); | |
156 | if (!strcasecmp($tok[0],"unrealircd")) | |
157 | { | |
158 | if ($latest > $tok[1]) | |
159 | $update = " <i class=\"fa-solid fa-cloud-arrow-down\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"Upgrade available!\"></i>"; | |
160 | } | |
161 | } | |
9ffc5134 VP |
162 | |
163 | echo "<tr>"; | |
721db4c3 | 164 | echo "<th scope=\"row\"><input type=\"checkbox\" value='$server->id' name=\"serverch[]\"></th>"; |
d72d1923 | 165 | echo "<td><a href=\"details.php?server=".$server->id."\">$server->name</a> $update</td>"; |
11475e36 | 166 | echo "<td>".$server->server->num_users."</td>"; |
9307bb12 | 167 | |
dca62e70 | 168 | $s = sinfo_conv_version_string($server); |
d72d1923 | 169 | |
9307bb12 | 170 | echo "<td>$s</td>"; |
11475e36 BM |
171 | if (isset($server->server->uplink)) |
172 | echo "<td>".$server->server->uplink."</td>"; | |
173 | else | |
174 | echo "<td></td>"; /* self */ | |
175 | echo "<td>".$server->server->boot_time."</td>"; | |
9ffc5134 VP |
176 | } |
177 | ?> | |
721db4c3 | 178 | </form> |
9ffc5134 VP |
179 | </tbody></table> |
180 | </div> | |
181 | ||
182 | <?php require_once UPATH.'/footer.php'; ?> |