-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCreateSupportedServer.php
336 lines (288 loc) · 11.6 KB
/
CreateSupportedServer.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
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
<?php
/*
GamePanelX
Description: Create new server support
Author: Ryan D. Gehrig
License: GNU General Public License (GPL)
*/
include_once('include/config.php');
include_once('include/auth.php');
include_once('include/statusInfo.php');
include_once('include/SqlCon.php');
//Make check to see if the logged in user is an admin.
$query = "SELECT is_admin FROM users WHERE username='$GPXuserName'";
sqlCon($query);
if($row['is_admin'] != 'Y')
{
include('Unauthorized.php');
exit(0);
}
if(!isset($_POST['submit']))
{
// Get server type from URL
$url_server_type = $_GET['type'];
// No funny business with the URL
if($url_server_type != 'game' && $url_server_type != 'voip' && $url_server_type != 'other' && !empty($url_server_type))
{
die('<center><b>Error:</b> Invalid type in the URL!</center>');
}
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/<?php echo $config['theme']; ?>/main.css">
</head>
<body leftmargin="0px" topmargin="0px" marginwidth="0px" marginheight="0px" onLoad="init()">
<div id="loading" style="position:absolute; top:60px; left:5px; overflow: hidden;"><img src="images/loading.gif" border="0"></div>
<script src="include/loading.js"></script>
<table border="0" cellpadding="0" cellspacing="0" align="center" width="100%" height="40" background="css/<?php echo $config['theme']; ?>/img/largeGrad.png">
<tr>
<td align="center" valign="middle"><span class="top_page_titles">Create Supported <?php echo ucwords($url_server_type); ?> Server</span></td>
</tr>
</table>
<br /><br />
<form method="post" action="CreateSupportedServer.php?type=<?php echo $url_server_type; ?>">
<table border="0" class="tablez" cellpadding="2" cellspacing="0" align="center" width="400">
<tr background="css/<?php echo $config['theme']; ?>/img/smallGrad.png" height="20">
<td colspan="2" align="left"> <span class="top_titles"><?php echo ucwords($url_server_type); ?> Configuration</span></td>
</tr>
<tr class="rowz_title">
<td colspan="2"> </td>
</tr>
<tr class="rowz_title">
<td colspan="2" align="center">
<?php
// Display correct image
if($url_server_type == 'game')
{
echo '<img src="images/main/supported_games.png" border="0" />';
}
elseif($url_server_type == 'voip')
{
echo '<img src="images/main/supported_voip.png" border="0" />';
}
else
{
echo '<img src="images/main/supported_games.png" border="0" />';
}
?>
</td>
</tr>
<tr class="rowz_title">
<td colspan="2"> </td>
</tr>
<tr class="rowz_title">
<td align="right"><span class="rowz_alt">Short Name: </span></td>
<td align="left"><input type="text" value="" name="short_name" maxlength="12" class="userinput" style="width:170px"></td>
</tr>
<tr class="rowz_title">
<td align="right"><span class="rowz_alt">Long Name: </span></td>
<td align="left"><input type="text" value="" name="long_name" maxlength="255" class="userinput" style="width:170px"></td>
</tr>
<?php
// Only show 'style' for games
if($url_server_type == 'game')
{
?>
<tr class="rowz_title">
<td align="right"><span class="rowz_alt">Style: </span></td>
<td align="left"><input type="text" value="" name="style" maxlength="255" class="userinput" style="width:170px"></td>
</tr>
<?php
}
?>
<tr class="rowz_title">
<td align="right"><span class="rowz_alt">Log File: </span></td>
<td align="left"><input type="text" value="" name="log_file" maxlength="255" class="userinput" style="width:170px"></td>
</tr>
<tr class="rowz_title">
<td align="right"><span class="rowz_alt">Default Port: </span></td>
<td align="left"><input type="text" value="" name="port" maxlength="255" class="userinput" style="width:170px"></td>
</tr>
<tr class="rowz_title">
<td align="right"><span class="rowz_alt">Reserved Ports: </span></td>
<td align="left"><input type="text" value="" name="reserved_ports" maxlength="255" class="userinput" style="width:170px"></td>
</tr>
<tr class="rowz_title">
<td align="right"><span class="rowz_alt">TCP Ports: </span></td>
<td align="left"><input type="text" value="" name="tcp_ports" maxlength="255" class="userinput" style="width:170px"></td>
</tr>
<tr class="rowz_title">
<td align="right"><span class="rowz_alt">UDP Ports: </span></td>
<td align="left"><input type="text" value="" name="udp_ports" maxlength="255" class="userinput" style="width:170px"></td>
</tr>
<tr class="rowz_title">
<td align="right"><span class="rowz_alt">Executable: </span></td>
<td align="left"><input type="text" value="" name="executable" maxlength="255" class="userinput" style="width:170px"></td>
</tr>
<tr class="rowz_title">
<td align="right"><span class="rowz_alt">Max Slots: </span></td>
<td align="left"><input type="text" value="" name="max_slots" maxlength="255" class="userinput" style="width:170px"></td>
</tr>
<?php
// Only show 'map' for games
if($url_server_type == 'game')
{
?>
<tr class="rowz_title">
<td align="right"><span class="rowz_alt">Default Map: </span></td>
<td align="left"><input type="text" value="" name="map" maxlength="255" class="userinput" style="width:170px"></td>
</tr>
<?php
}
?>
<tr class="rowz_title">
<td align="right"><span class="rowz_alt">Setup CMD Line: </span></td>
<td align="left"><input type="text" value="" name="setup_cmd" maxlength="255" class="userinput" style="width:170px"></td>
</tr>
<tr class="rowz_title">
<td align="right"><span class="rowz_alt">CMD Line: </span></td>
<td align="left"><input type="text" value="" name="cmd_line" maxlength="255" class="userinput" style="width:170px"></td>
</tr>
<tr class="rowz_title">
<td align="right"><span class="rowz_alt">Working Directory: </span></td>
<td align="left"><input type="text" value="" name="working_dir" maxlength="255" class="userinput" style="width:170px"></td>
</tr>
<tr class="rowz_title">
<td align="right"><span class="rowz_alt">Setup Directory: </span></td>
<td align="left"><input type="text" value="" name="setup_dir" maxlength="255" class="userinput" style="width:170px"></td>
</tr>
<tr class="rowz_title">
<td colspan="2"> </td>
</tr>
<tr class="rowz_title">
<td align="center" colspan="2"><input type="checkbox" name="available" id="available"> <label for="available">This is available for use</label></td>
</tr>
<tr class="rowz_title">
<td colspan="2"> </td>
</tr>
</table>
<br />
<table border="0" style="border:1px solid black" cellpadding="2" cellspacing="0" align="center">
<tr background="css/<?php echo $config['theme']; ?>/img/smallGrad.png" height="20">
<td align="left" width="20"><span class="top_titles">Description</span></td>
<td align="left"><span class="top_titles">Value</span></td>
<td align="center" width="50"><span class="top_titles">#</span></td>
<td align="left" width="120"><span class="top_titles"> </span></td>
</tr>
<?php
// Loop through all 10 config options
for($i=1; $i <= 10; $i++)
{
// Option names
$opt_name = 'opt' . $i . '_name';
$opt_edit = 'opt' . $i . '_edit';
$opt_value = 'opt' . $i . '_value';
echo '<tr class="rowz_title">' . "\n";
echo ' <td align="left" width="20"><input type="text" value="" name="' . $opt_name . '" style="width:140px;text-align:right"></td>' . "\n";
echo ' <td align="left"><input type="text" value="" name="' . $opt_value . '" style="width:100%"></td>' . "\n";
echo ' <td align="right"><span class="rowz_alt" style="font-weight:normal">%opt' . $i . '%</span></td>' . "\n";
echo ' <td align="right">';
echo '<input type="checkbox" name="' . $opt_edit . '" id="' . $opt_edit . '">';
echo ' <label for="' . $opt_edit . '">Client-Editable</label></td></tr>';
}
?>
<tr class="rowz_title">
<td colspan="4"> </td>
</tr>
<tr class="rowz_title">
<td colspan="4" align="center"><input type="submit" name="submit" value="Submit" style="width:170px"></td>
</tr>
<tr class="rowz_title">
<td colspan="4"> </td>
</tr>
</table>
<?php
}
// Insert Page
elseif(isset($_POST['submit']))
{
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/<?php echo $config['theme']; ?>/main.css">
</head>
<body leftmargin="0px" topmargin="0px" marginwidth="0px" marginheight="0px" onLoad="init()">
<div id="loading" style="position:absolute; top:60px; left:5px; overflow: hidden;"><img src="images/loading.gif" border="0"></div>
<script src="include/loading.js"></script>
<table border="0" cellpadding="0" cellspacing="0" align="center" width="100%" height="40" background="css/<?php echo $config['theme']; ?>/img/largeGrad.png">
<tr>
<td align="center" valign="middle"><span class="top_page_titles">Create Supported <?php echo ucwords($url_server_type); ?> Server</span></td>
</tr>
</table>
<br /><br />
<?php
// Server Type
$url_server_type = $_GET['type'];
// Post Values
$post_short_name = $_POST['short_name'];
$post_long_name = $_POST['long_name'];
$post_available = $_POST['available'];
$post_style = $_POST['style'];
$post_log_file = $_POST['log_file'];
$post_port = $_POST['port'];
$post_res_ports = $_POST['reserved_ports'];
$post_tcp_ports = $_POST['tcp_ports'];
$post_udp_ports = $_POST['udp_ports'];
$post_executable = $_POST['executable'];
$post_max_slots = $_POST['max_slots'];
$post_map = $_POST['map'];
$post_setup_cmd = $_POST['setup_cmd'];
$post_cmd_line = $_POST['cmd_line'];
$post_working_dir = $_POST['working_dir'];
$post_setup_dir = $_POST['setup_dir'];
// Format 'game available'
if($post_available == 'on')
{
$post_available = 'Y';
}
else
{
$post_available = 'N';
}
// Begin insert query
$insert_query = "INSERT INTO servers VALUES('','$post_short_name','$post_long_name','$url_server_type','$post_available','$post_style','$post_log_file','$post_port','$post_res_ports','$post_tcp_ports','$post_udp_ports','$post_executable','$post_max_slots','$post_map','$post_setup_cmd','$post_cmd_line','$post_working_dir','$post_setup_dir',";
// Loop through 10 config options
for($i=1; $i <= 10; $i++)
{
// Option names
$this_opt_name = 'opt' . $i . '_name';
$this_opt_value = 'opt' . $i . '_value';
$this_opt_edit = 'opt' . $i . '_edit';
// Post values
$post_name = $_POST[$this_opt_name];
$post_value = $_POST[$this_opt_value];
$post_edit = $_POST[$this_opt_edit];
// Format client-edit
if($post_edit == 'on')
{
$post_edit = 'Y';
}
else
{
$post_edit = 'N';
}
// Add these options to the insert query
if($i == 10)
{
$insert_query .= "'$post_name','$post_edit','$post_value')";
}
else
{
$insert_query .= "'$post_name','$post_edit','$post_value',";
}
}
// Connect to the DB
$db = @mysql_connect($config['sql_host'],$config['sql_user'],$config['sql_pass']) or die('<b>Error:</b> Failed to connect to the database!');
@mysql_select_db($config['sql_db']) or die('<b>Error:</b> Failed to select the database!');
// Insert game into database
@mysql_query($insert_query) or die('<b>Error:</b> Failed to insert into the servers table!');
?>
<center>
<b>Success!</b>
<br /><br />
Successfully created your new server support.
<br /><br />
<a href="SupportedServers.php">Click here to go back</a>
</center>
<?php
}