-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathindex.php
More file actions
121 lines (114 loc) · 5.58 KB
/
index.php
File metadata and controls
121 lines (114 loc) · 5.58 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
<?php
require_once('RemoteAdmin.class.php');
$remoteAdmin = new RemoteAdmin();
$remoteData = $remoteAdmin->get_data();
$task = $_REQUEST['task'];
switch ($task)
{
default:
echo "<h2>Choose the method for the Remote Admin:</h2><table border =\"1\" cellpadding=\"5\">";
$group = "";
foreach ($remoteData AS $key=>$data)
{
if ($data->group != $group) {
$group = $data->group;
echo "<th colspan=\"2\"><h3>".$group."</h3></th>";
}
echo "<tr><td><a href=\"index.php?task=form&method=".$key."\">".$key."</a></td><td>".$data->description."</td></tr>";
}
echo "</table>";
break;
case 'form':
$method = $_REQUEST['method'];
$formData = $remoteData->$method;
echo "<h2>Remote Admin: ".$method."<h2>";
echo $formData->description."<br><br>";
echo "<form action=\"index.php\" method=\"post\" enctype=\"multipart/form-data\">";
echo "<input type=\"hidden\" name=\"method\" value=\"".$method."\">";
echo "<input type=\"hidden\" name=\"task\" value=\"post\">";
if (is_object($formData->Required))
{
echo "<table border =\"0\" cellpadding=\"5\"><th colspan=\"3\">Required fields: </th>";
foreach ($formData->Required AS $key => $field)
{
$default = "";
if (isset($field->default)) $default = " value=\"".$field->default."\"";
switch ($field->type)
{
default:
echo "<tr><td>".$key."</td><td><input type=\"text\" name=\"dat[".$key."]\"$default></td><td>".$field->description."</td></tr>";
break;
case 'hidden':
echo "<input type=\"hidden\" name=\"dat[".$key."]\"$default readonly>";
break;
case 'readonly':
echo "<tr><td>".$key."</td><td><input type=\"text\" name=\"dat[".$key."]\"$default readonly></td><td>".$field->description."</td></tr>";
break;
case 'file':
echo "<tr><td>".$key."</td><td><input type=\"file\" name=\"dat[".$key."]\"$default></td><td>".$field->description."</td></tr>";
break;
case 'boolean':
echo "<tr><td>".$key."</td><td><input type=\"checkbox\" name=\"dat[".$key."]\" value=\"True\" checked=\"checked\"$default></td><td>".$field->description."</td></tr>";
break;
}
}
echo "</table>";
}
if (is_object($formData->Optional))
{
echo "<table border =\"0\" cellpadding=\"5\"><th colspan=\"3\">Optional fields: </th>";
foreach ($formData->Optional AS $key => $field)
{
$default = "";
if (isset($field->default)) $default = " value=\"".$field->default."\"";
switch ($field->type)
{
default:
echo "<tr><td>".$key."</td><td><input type=\"text\" name=\"dat[".$key."]\"$default></td><td>".$field->description."</td></tr>";
break;
case 'hidden':
echo "<input type=\"hidden\" name=\"dat[".$key."]\"$default readonly>";
break;
case 'readonly':
echo "<tr><td>".$key."</td><td><input type=\"text\" name=\"dat[".$key."]\"$default readonly></td><td>".$field->description."</td></tr>";
break;
case 'file':
echo "<tr><td>".$key."</td><td><input type=\"file\" name=\"dat[".$key."]\"$default></td><td>".$field->description."</td></tr>";
break;
case 'boolean':
echo "<tr><td>".$key."</td><td><input type=\"checkbox\" name=\"dat[".$key."]\" value=\"True\" checked=\"checked\"$default></td><td>".$field->description."</td></tr>";
break;
}
}
echo "</table>";
}
echo "<br><input type=\"submit\" value=\"Submit\"></form>";
echo "<br><h3>Returned parameters:<h3> ".$formData->ReturnedParameters;
if (strlen($formData->ErrorMessages)>0) echo "<br><br><h3>Error messages: </h3>".$formData->ErrorMessages;
if (strlen($formData->Notes)>0) echo "<br><br><h3>Error messages: </h3>".$formData->Notes;
break;
case 'post':
$method = $_POST['method'];
$parameters = $_POST['dat'];
if (count($_FILES['dat']['name'])>0) {
require_once('config.php');
$parameters['filename'] = $file_dest_dir.$_FILES['dat']['name']['filename'];
move_uploaded_file($_FILES['dat']['tmp_name']['filename'],$parameters['filename']);
}
echo "<h2>Remote Admin: ".$method."</h2>";
echo "<h3>Results of the call to the simulator.</h3>";
$result = $remoteAdmin->SendCommand($method, $parameters);
echo "<table border =\"1\" cellpadding=\"5\"><th><b>Parameter</th><th>Value</th>";
foreach ($result AS $key=>$res)
{
if ($key=='lastlogin') {
$res = date('Y-m-d H:m:i',$res);
}
echo "<tr><td>".$key."</td><td>".$res."</td></tr>";
}
echo "</table>";
echo "<h3>Espected Results:</h3>";
echo $remoteData->$method->ReturnedParameters;
break;
}
?>