-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTemplateNew.php
246 lines (199 loc) · 8.11 KB
/
TemplateNew.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
<?php
/*
GamePanelX
Description: Create a game template
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');
include_once('include/functions.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);
}
// 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>');
}
if (!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 <?php echo ucwords($url_server_type); ?> Template</span></td>
</tr>
</table>
<br /><br />
<form action="TemplateNew.php?type=<?php echo $url_server_type; ?>" method="post">
<table border="0" class="tablez" width="500" cellpadding="0" cellspacing="0" align="center">
<tr background="css/<?php echo $config['theme']; ?>/img/smallGrad.png" height="20">
<td colspan="3" align="left"> <span class="top_titles">New <?php echo ucwords($url_server_type); ?> Template</span></td>
</tr>
<tr class="rowz_title">
<td colspan="2"> </td>
</tr>
<tr class="rowz_title">
<td colspan="2" align="center"><img src="images/main/template_<?php echo $url_server_type; ?>.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">Create for server: </span></td>
<td align="left">
<select name="server" style="width:200px">
<option value="" selected="selected">Select a server</option>
<?php
// Connect to the database
$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!');
// Create a list of all available games
$result_gm = @mysql_query("SELECT short_name,long_name FROM servers WHERE type='$url_server_type' AND available='Y' ORDER BY short_name ASC") or die('<b>Error:</b> Failed to query the servers table!');
while($row_gm = mysql_fetch_array($result_gm))
{
$short_name = $row_gm['short_name'];
$long_name = $row_gm['long_name'];
echo '<option value="' . $short_name . '">' . $long_name . '</option>';
}
?>
</select>
</td>
</tr>
<tr class="rowz_title">
<td align="right"><span class="rowz_alt">Physical Server: </span></td>
<td align="left">
<select name="ip" style="width:170px">
<option value="" selected="selected">Select an IP Address</option>
<?php
$type = "physical";
list_available_ips($type);
?>
</select>
</td>
</tr>
<tr class="rowz_title">
<td align="right"><span class="rowz_alt">Full path to template directory: </span></td>
<td align="left"><input type="text" name="file_path" value="" class="userinput" style="width:170px"></td>
</tr>
<tr class="rowz_title">
<td align="right"><span class="rowz_alt">Description: </span></td>
<td align="left"><input type="text" name="description" value="" class="userinput" style="width:170px"></td>
</tr>
<tr class="rowz_title">
<td colspan="2"> </td>
</tr>
<tr class="rowz_title">
<td align="right"><span class="rowz_alt">Default for this game: </span></td>
<td align="left">
<select name="is_default">
<option value="Y" selected>Yes</option>
<option value="N">No</option>
</select>
</td>
</tr>
<tr class="rowz_title">
<td align="right"><span class="rowz_alt">Available for use: </span></td>
<td align="left">
<select name="available">
<option value="Y" selected>Yes</option>
<option value="N">No</option>
</select>
</td>
</tr>
<tr class="rowz_title">
<td colspan="2"> </td>
</tr>
<tr class="rowz_title">
<td align="center" colspan="2"><input type="submit" name="submit" value="Continue" style="width:170px"></td>
</tr>
<tr class="rowz_title">
<td colspan="2"> </td>
</tr>
</table>
</form>
</body>
</html>
<?php
}
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 <?php echo ucwords($url_server_type); ?> Templates</span></td>
</tr>
</table>
<br /><br />
<form action="include/runcmd.php" method="post">
<table border="1" class="tablez" width="400" cellpadding="0" cellspacing="0" align="center">
<tr background="css/<?php echo $config['theme']; ?>/img/smallGrad.png" height="20">
<td colspan="3" align="left"> <span class="top_titles">New Game Template</span></td>
</tr>
<tr class="rowz_title">
<td width="150" align="center"><b><u>Begin Setup Process:</u></b><br /><br />
<?php
// Check for empty fields
if(empty($_POST['file_path']) || empty($_POST['description']) || empty($_POST['ip']) || empty($_POST['server']))
{
die('<b>Error:</b> You left a required field blank!');
}
include_once('include/functions.php');
// Make a random nickname for tar file's name
$style = "normal";
$addonText = generateRandomText($style);
// Encode all POST variables in base64
$encoded_server = base64_encode($_POST['server']);
$encoded_file_path = base64_encode($_POST['file_path']);
$encoded_desc = base64_encode($_POST['description']);
$encoded_type = base64_encode($url_server_type);
$encoded_available = base64_encode($_POST['available']);
$encoded_default = base64_encode($_POST['is_default']);
$encoded_ip = base64_encode($_POST['ip']);
$encoded_rand = base64_encode($addonText);
?>
<input type="hidden" name="server" value="<?php echo $encoded_server; ?>">
<input type="hidden" name="file_path" value="<?php echo $encoded_file_path; ?>">
<input type="hidden" name="description" value="<?php echo $encoded_desc; ?>">
<input type="hidden" name="type" value="<?php echo $encoded_type; ?>">
<input type="hidden" name="available" value="<?php echo $encoded_available; ?>">
<input type="hidden" name="is_default" value="<?php echo $encoded_default; ?>">
<input type="hidden" name="ip" value="<?php echo $encoded_ip; ?>">
<input type="hidden" name="random_text" value="<?php echo $encoded_rand; ?>">
<input type="hidden" name="previous_page" value="TemplateNew.php?type=<?php echo $url_server_type; ?>">
<input type="hidden" name="allow_output" value="1">
<input type="hidden" name="skip_parent_check" value="1">
<br />
<input type="submit" name="create_template" value="Begin Setup">
<br /><br />
<b>Please Note:</b> This process can take up to 2 minutes to complete.<br /><br />
</td>
</tr>
</table>
</form>
</body>
</html>
<?php } ?>