-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTemplates.php
265 lines (215 loc) · 8.57 KB
/
Templates.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
<?php
/*
GamePanelX
Description: Manage Game/Voip Templates
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);
}
// 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"><?php echo ucwords($url_server_type); ?> Templates</span></td>
</tr>
</table>
<br /><br />
<form action="Templates.php?type=<?php echo $url_server_type; ?>" name="templates" method="post">
<table border="0" class="tablez" width="600" cellpadding="0" cellspacing="0" align="center">
<tr background="css/<?php echo $config['theme']; ?>/img/smallGrad.png" height="20">
<td align="center" width="30"><span class="top_titles">#</span></td>
<td align="left" width="40"><span class="top_titles"> </span></td>
<td align="left" width="200"><span class="top_titles">Server Name</span></td>
<td align="left" width="160"><span class="top_titles">Description</span></td>
<td align="center" width="60"><span class="top_titles">Default</span></td>
<td align="center" width="60"><span class="top_titles">Available</span></td>
<td align="center" width="60"><span class="top_titles">Action</span></td>
</tr>
<?php
// Grab all game restores from 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!');
$result_templates = @mysql_query("SELECT templates.id,templates.available,templates.is_default,templates.description,templates.ip,servers.short_name,servers.long_name FROM templates LEFT JOIN servers ON templates.server = servers.short_name WHERE templates.type='$url_server_type' ORDER BY templates.server ASC") or die('<b>Error:</b> Failed to query the templates table!');
$num_templates = mysql_num_rows($result_templates);
// Include alternating row colors
include('include/colors.php');
// Output for no rows
if($num_templates == 0)
{
?>
<tr valign="middle" style="background-color:<?php echo $bgColor; ?>" onmouseover="style.backgroundColor='<?php echo $bgOpp; ?>'" onmouseout="style.backgroundColor='<?php echo $bgColor; ?>'">
<td align="center" colspan="12"><span class="rowz_alt">No results to display</span></td>
</tr>
<?php
}
while($row_templates = mysql_fetch_array($result_templates))
{
// Include alternating row colors
include('include/colors.php');
// `templates` table
$id = $row_templates['id'];
$type = $row_templates['type'];
$available = $row_templates['available'];
$is_default = $row_templates['is_default'];
$desc = $row_templates['description'];
$ip = $row_templates['ip'];
// `servers` table
$short_name = $row_templates['short_name'];
$long_name = $row_templates['long_name'];
?>
<tr valign="middle" style="background-color:<?php echo $bgColor; ?>" onmouseover="style.backgroundColor='<?php echo $bgOpp; ?>'" onmouseout="style.backgroundColor='<?php echo $bgColor; ?>'">
<td align="center"><span class="rowz_alt"><input name="delete[]" id="delete[]" type="checkbox" value="<?php echo $id; ?>"></td>
<td align="left"><span class="rowz_alt"><img src="images/servers/small/<?php echo $short_name; ?>.png" border="0" /></span></td>
<td align="left"><span class="rowz_alt"><b><?php echo $long_name; ?></b></span></td>
<td align="left"><span class="rowz_alt"><?php echo $desc; ?></span></td>
<td align="center"><span class="rowz_alt">
<?php
// Default templates
if ($is_default == 'Y')
{
echo 'Yes';
}
elseif ($is_default == 'N')
{
echo 'No';
}
// Otherwise
else
{
echo '<i>Unset</i>';
}
?>
</span></td>
<td align="center"><span class="rowz_alt">
<?php
// Available templates
if ($available == 'Y')
{
echo 'Yes';
}
elseif ($available == 'N')
{
echo 'No';
}
// Otherwise
else
{
echo '<i>Unset</i>';
}
?>
</span></td>
<td align="center" valign="middle"><input type="button" name="edit" id="edit" value="Edit" style="width:100%" onClick="window.location.href='TemplateEdit.php?id=<?php echo $id; ?>'"></td>
<?php } ?>
</table>
<br /><br />
<center>
<input name="submit" type="submit" id="submit" value="Delete Game Template">
</center>
</form>
</body>
</html>
<?php
}
//
// Second Page
//
elseif (isset($_POST['submit']))
{
$checkDelete = $_REQUEST['delete'];
$delList = implode(",", $checkDelete);
//If nothing was selected...
if (empty($delList))
{
?>
<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"><?php echo ucwords($url_server_type); ?> Templates</span></td>
</tr>
</table>
<br /><br />
<center>
<b>Error:</b> No <?php echo ucwords($url_server_type); ?> Templates were selected!<br /><br />
Click <a href="Templates.php?type=<?php echo $url_server_type; ?>">here</a> to go back.
</center>
</body>
</html>
<?php
}
// Otherwise
else
{
?>
<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()">
<?php include("include/PopupInfo.html"); ?>
<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"><?php echo ucwords($url_server_type); ?> Templates - Edit Rows</span></td>
</tr>
</table>
<br /><br />
<center>
<?php
// Output
echo 'Row(s) <b>' . $delList . '</b> will be deleted.<br /><br />';
// Connect to sql and get the file path for this ID
$query = "SELECT ip,file_path FROM templates WHERE id IN($delList)";
sqlCon($query);
$file_path = $row['file_path'];
$ip = $row['ip'];
// Encode the file path in base64
$encoded_file_path = base64_encode($file_path);
$encoded_ip = base64_encode($ip);
$encoded_del_list = base64_encode($delList);
?>
Click below to confirm deletion of the template file(s) from the database and remote server.<br />
<br /><br />
<form action="include/runcmd.php" method="post">
<input type="hidden" name="file_path" id="file_path" value="<?php echo $encoded_file_path; ?>">
<input type="hidden" name="ip" id="ip" value="<?php echo $encoded_ip; ?>">
<input type="hidden" name="del_list" id="del_list" value="<?php echo $encoded_del_list; ?>">
<input type="hidden" name="previous_page" value="Templates.php?type=<?php echo $url_server_type; ?>">
<input type="submit" name="delete_template" id="delete_template" value="Delete Template">
</form>
<?php
}
}
?>