-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreorderserver.php
93 lines (90 loc) · 3.35 KB
/
reorderserver.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
<?php
/* BanManagement © 2012, a web interface for the Bukkit plugin BanManager
by James Mortemore of http://www.frostcast.net
is licenced under a Creative Commons
Attribution-NonCommercial-ShareAlike 2.0 UK: England & Wales.
Permissions beyond the scope of this licence
may be available at http://creativecommons.org/licenses/by-nc-sa/2.0/uk/.
Additional licence terms at https://raw.github.com/confuser/Ban-Management/master/banmanagement/licence.txt
*/
if (!defined('INTERNAL'))
die("Don't call me directly!");
if(!isset($_SESSION['admin']) || (isset($_SESSION['admin']) && !$_SESSION['admin']))
die('Hacking attempt');
else if(!isset($_GET['authid']) || (isset($_GET['authid']) && $_GET['authid'] != sha1($settings['password'])))
die('Hacking attempt');
else if(!isset($_GET['server']) || !is_numeric($_GET['server']))
die('Hacking attempt');
else if(!isset($settings['servers'][$_GET['server']]))
die('Hacking attempt');
else if(!isset($_GET['order']) || (isset($_GET['order']) && $_GET['order'] != 'up' && $_GET['order'] != 'down'))
die('Hacking attempt');
else {
// Get the server details
$servers = $settings['servers'];
if($_GET['order'] == 'up') {
$servers[$_GET['server']] = $servers[$_GET['server'] - 1];
$servers[$_GET['server'] - 1] = $settings['servers'][$_GET['server']];
} else {
$servers[$_GET['server']] = $servers[$_GET['server'] + 1];
$servers[$_GET['server'] + 1] = $settings['servers'][$_GET['server']];
}
// Success! Add it
$settings['servers'] = $servers;
$servers = serialize($servers);
$servers = "['servers'] = '".$servers;
$contents = file_get_contents('settings.php');
$contents = preg_replace("/\['servers'\] = '(.*?)/", $servers, $contents);
file_put_contents('settings.php', $contents);
}
if(isset($error))
$array['error'] = $error;
else {
$id = array_keys($settings['servers']);
$i = 0;
$count = count($settings['servers']) - 1;
$table = '
<table class="table table-striped table-bordered" id="servers">
<thead>
<th>Server Name</th>
<th>Options</th>
</thead>
<tbody>';
foreach($settings['servers'] as $server) {
$table .= '
<tr>
<td>'.$server['name'].'</td>
<td>
<a href="#" class="btn btn-danger deleteServer" data-serverid="'.$id[$i].'"><span class="glyphicon glyphicon-trash"></span></a>';
if($count > 0) {
if($i == 0)
$table .= '
<a href="#" class="btn reorderServer" data-order="down" data-serverid="'.$id[$i].'"><span class="glyphicon glyphicon-arrow-down"></span></a>';
else if($i == $count)
$table .= '
<a href="#" class="btn reorderServer" data-order="up" data-serverid="'.$id[$i].'"><span class="glyphicon glyphicon-arrow-up"></span></a>';
else {
$table .= '
<a href="#" class="btn reorderServer" data-order="up" data-serverid="'.$id[$i].'"><span class="glyphicon glyphicon-arrow-up"></span></a>
<a href="#" class="btn reorderServer" data-order="down" data-serverid="'.$id[$i].'"><span class="glyphicon glyphicon-arrow-down"></span></a>';
}
}
$table .= '
</td>
</tr>';
++$i;
}
$table .= '
</tbody>
<tfoot>
<tr>
<td colspan="2">
<a class="btn btn-primary btn-large" href="#addserver" data-toggle="modal">Add Server</a>
</td>
</tr>
</tfoot>
</table>';
$array['success'] = array('table' => $table);
}
echo json_encode($array);
?>