-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRemoteServerNew.php
More file actions
392 lines (320 loc) · 11.6 KB
/
RemoteServerNew.php
File metadata and controls
392 lines (320 loc) · 11.6 KB
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
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
<?php
/*
GamePanelX
Description: Create a new remote server
Author: Ryan D. Gehrig
License: GNU General Public License (GPL)
*/
include_once('include/config.php');
include_once('include/auth.php');
include_once('include/SqlCon.php');
include_once('include/statusInfo.php');
//Make check to see if the logged in user is an admin.
$query = "SELECT is_admin FROM users WHERE username='$GPXuserName'";
sqlCon($query);
//
// Check if administrator
//
if($row['is_admin'] != 'Y')
{
require('Unauthorized.php');
exit;
}
if(!isset($_POST['submit']))
{
?>
<html>
<head>
<title><?php echo $config['title']; ?> | New Remote Server Setup</title>
<link rel="stylesheet" type="text/css" href="css/<?php echo $config['theme']; ?>/main.css">
<META NAME="ROBOTS" CONTENT="NONE">
<META NAME="GOOGLEBOT" CONTENT="NONE">
<META NAME="Slurp" CONTENT="NONE">
<script type="text/javascript">
// See if the checkbox is enabled
function verify_checked()
{
if (document.remoteForm.physical.checked)
{
// Enable all Physical Server options
document.remoteForm.ssh_username.disabled = false;
document.remoteForm.ssh_password.disabled = false;
document.remoteForm.ssh_port.disabled = false;
document.remoteForm.ssh_username.value = "";
document.remoteForm.ssh_password.value = "";
document.remoteForm.ssh_port.value = "";
}
else
{
// Disable all Physical Server options
document.remoteForm.ssh_username.disabled = true;
document.remoteForm.ssh_password.disabled = true;
document.remoteForm.ssh_port.disabled = true;
document.remoteForm.ssh_username.value = "(disabled)";
document.remoteForm.ssh_password.value = "";
document.remoteForm.ssh_port.value = "(disabled)";
}
}
function checkReq()
{
// IP Address
if(document.remoteForm.ip_address.value == "")
{
alert('Please enter an IP Address');
return false;
}
// Physical
if(document.remoteForm.physical.checked == true)
{
// Make sure SSH details were filled out
if(document.remoteForm.ssh_username.value == "")
{
alert('You left the SSH Username empty!');
return false;
}
if(document.remoteForm.ssh_password.value == "")
{
alert('You left the SSH Password empty!');
return false;
}
if(document.remoteForm.ssh_port.value == "")
{
alert('You left the SSH Port empty!');
return false;
}
}
else
{
// Check if a parent was selected
if(document.remoteForm.parent_servers.value == "")
{
alert('You must select a parent server!');
return false;
}
}
return true;
}
</script>
</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">New Remote Server</span></td>
</tr>
</table>
<br /><br />
<table width="400" cellpadding="0" cellspacing="0" class="tablez" style="border:1px solid black" align="center">
<tr background="css/<?php echo $config['theme']; ?>/img/smallGrad.png" height="20">
<td colspan="3" align="left"> <span class="top_titles">Server Details</span></td>
</tr>
<form method="post" action="<?php echo $PHP_SELF; ?>" name="remoteForm" onSubmit="return checkReq()">
<tr class="rowz_title">
<td colspan="2"> </td>
</tr>
<tr class="rowz_title">
<td colspan="2" align="center"><img src="images/main/server-64.png" border="0" /></td>
</tr>
<tr class="rowz_title">
<td colspan="2"> </td>
</tr>
<tr class="rowz_title">
<td align="right"> <b>IP Address: </b></td>
<td align="left"><input type="text" name="ip_address" id="ip_address" maxlength="20" style="width:150px" class="userinput" /></td>
</tr>
<tr class="rowz_title">
<td colspan="2"> </td>
</tr>
<tr class="rowz_title">
<td align="right"> <b>Operating System: </b></td>
<td align="left"><input type="text" name="os" style="width:150px;" maxlength="30" value="Linux" class="userinput"></td>
</tr>
<tr class="rowz_title">
<td align="right"> <b>Location: </b></td>
<td align="left"><input type="text" name="location" style="width:150px;" maxlength="30" value="<?php echo $_POST['location']; ?>" class="userinput"></td>
</tr>
<tr class="rowz_title">
<td align="right"> <b>Data Center: </b></td>
<td align="left"><input type="text" name="datacenter" style="width:150px;" maxlength="30" value="<?php echo $_POST['datacenter']; ?>" class="userinput"></td>
</tr>
<tr class="rowz_title">
<td colspan="2"> </td>
</tr>
<tr background="css/<?php echo $config['theme']; ?>/img/smallGrad.png" height="20">
<td colspan="2" align="left"> <span class="top_titles">Physical Server Settings</span></td>
</tr>
<tr class="rowz_title">
<td colspan="2"> </td>
</tr>
<tr class="rowz_title">
<td colspan="2" align="center"><input type="checkbox" name="physical" id="physical" value="1" onclick="verify_checked()"> <label for="physical">This is a Physical Server</label></td>
</tr>
<tr class="rowz_title">
<td colspan="2"> </td>
</tr>
<tr class="rowz_title">
<td align="right"><b>SSH Username:</b> </td>
<td align="left"><input type="text" name="ssh_username" id="ssh_username" value="(disabled)" disabled="true" class="userinput"></td>
</tr>
<tr class="rowz_title">
<td align="right"><b>SSH Password:</b> </td>
<td align="left"><input type="password" name="ssh_password" id="ssh_password" value="" disabled="true" class="userinput"></td>
</tr>
<tr class="rowz_title">
<td align="right"><b>SSH Port:</b> </td>
<td align="left"><input type="text" name="ssh_port" id="ssh_port" value="(disabled)" disabled="true" class="userinput"></td>
</tr>
<tr class="rowz_title">
<td colspan="2"> </td>
</tr>
<tr background="css/<?php echo $config['theme']; ?>/img/smallGrad.png" height="20">
<td colspan="2" align="left"> <span class="top_titles">Standard Server Settings</span></td>
</tr>
<tr class="rowz_title">
<td colspan="2"> </td>
</tr>
<tr class="rowz_title">
<td align="right"><b>Parent Server: </b></td>
<td align="left">
<select name="parent_servers" id="parent_servers">
<option value="">Select a Parent Server</option>
<?php
// Get all parent servers
require('include/functions.php');
$type = 'physical';
list_available_ips($type);
?>
</select>
</td>
</tr>
<tr class="rowz_title">
<td colspan="2"> </td>
</tr>
<tr background="css/<?php echo $config['theme']; ?>/img/smallGrad.png" height="20">
<td colspan="3" align="left"> <span class="top_titles">Other Options</span></td>
</tr>
<tr class="rowz_title">
<td colspan="2"> </td>
</tr>
<tr class="rowz_title">
<td align="right"><input type="checkbox" name="available" id="available" value="1" checked> </td>
<td align="left"><label for="available">This server is available for use</label></td>
</tr>
<tr class="rowz_title">
<td colspan="2"> </td>
</tr>
<tr class="rowz_title">
<td colspan="2" align="center"><input type="submit" value="Submit" name="submit" id="submit" style="width:170px"></td>
</tr>
<tr class="rowz_title">
<td colspan="2"> </td>
</tr>
</table>
</form>
</body>
</html>
<?
}
// Update values
elseif(isset($_POST['submit']))
{
?>
<html>
<head>
<title><?php echo $config['title']; ?> | New Remote Server Setup</title>
<link rel="stylesheet" type="text/css" href="css/<?php echo $config['theme']; ?>/main.css">
<META NAME="ROBOTS" CONTENT="NONE">
<META NAME="GOOGLEBOT" CONTENT="NONE">
<META NAME="Slurp" CONTENT="NONE">
</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">New Remote Server</span></td>
</tr>
</table>
<br /><br />
<?php
//Declare nicer variables
$available = $_POST['available'];
$operating_system = $_POST['os'];
$location = $_POST['location'];
$datacenter = $_POST['datacenter'];
$physical = $_POST['physical'];
$parent_server = $_POST['parent_servers'];
// If 'physical' is set, these options follow
$ssh_user = $_POST['ssh_username'];
$ssh_pass = $_POST['ssh_password'];
$ssh_port = $_POST['ssh_port'];
// SSH Encryption Key
$ssh_key = $config['encrypt_key'];
//Prepare "physical" for insert
if ($physical)
{
$is_physical = "Y";
}
else
{
$is_physical = "N";
}
//Prepare "available" for insert
if ($available)
{
$is_available = "Y";
}
else
{
$is_available = "N";
}
//If required fields are blank...
if(empty($_POST['ip_address']))
{
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/<?php echo $config['theme']; ?>/main.css">
<META NAME="ROBOTS" CONTENT="NONE">
<META NAME="GOOGLEBOT" CONTENT="NONE">
<META NAME="Slurp" CONTENT="NONE">
</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">New Remote Server</span></td>
</tr>
</table>
<br /><br />
<b>Error:</b> You didn't enter all the required fields!<br /><br />
Please go <a href="RemoteServerNew.php"><b>back</b></a> and try again.
</body>
</html>
<?
exit(0);
}
####################################################################
//
// Create Remote Server/IP
//
$ip_address = $_POST['ip_address'];
// Create Remote Server
require_once('include/functions.php');
if(!create_remote_server($ip_address,$is_available,$is_physical,$parent_server,$operating_system,$location,$datacenter,$ssh_user,$ssh_pass,$ssh_port))
{
die('<b>Error:</b> Remote Server creation failed!');
}
?>
<center>
<b>Success!</b>
<br /><br />
<a href="RemoteServerManager.php">Remote Server Manager</a>
</center>
</body>
</html>
<?php
}
?>