forked from pshep/ANUBIS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathedithost.php
More file actions
230 lines (185 loc) · 6.28 KB
/
Copy pathedithost.php
File metadata and controls
230 lines (185 loc) · 6.28 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
<?
require("config.inc.php");
require("func.inc.php");
$dbh = anubis_db_connect();
$config = get_config_data();
if (isset($_POST['delete']) && isset($_POST['savehostid']))
{
$id = 0 + $_POST['savehostid'];
$id_quote = $dbh->quote($id);
$delq = "DELETE FROM hosts WHERE id = $id_quote";
$delr = $dbh->exec($delq);
}
if (isset($_POST['savehostid']) && !isset($_POST['delete']))
{
$id = 0 + $_POST['savehostid'];
$id_quote = $dbh->quote($id);
$newname = $dbh->quote($_POST['macname']);
$address = $dbh->quote($_POST['ipaddress']);
$port = $dbh->quote($_POST['port']);
$mhash = $dbh->quote($_POST['mhash']);
if ($newname && $newname !== "" && $address && $address !== "")
{
$updq = "UPDATE hosts SET name = $newname, address = $address, port = $port, mhash_desired = $mhash WHERE id = $id_quote";
$updr = $dbh->exec($updq);
if (!$updr)
{
die('FATAL: DB-Error: ' . db_error());
}
}
}
if (!isset($id))
$id = 0 + $_GET['id'];
if (!$id || $id == 0)
{
echo "Need a Host to deal with !";
die;
}
if($host_data = get_host_data($id))
{
if($host_alive = get_host_status($host_data))
{
/* Determine if we can change values on this host */
$privileged = get_privileged_status($host_data);
if ($privileged)
{
if (isset($_POST['top']))
{
$arr = array ('command'=>'switchpool','parameter'=>$_POST['top']);
send_request_to_host($arr, $host_data);
sleep(2);
}
if (isset($_POST['stop']))
{
$arr = array ('command'=>'disablepool','parameter'=>$_POST['stop']);
send_request_to_host($arr, $host_data);
sleep(2);
}
if (isset($_POST['start']))
{
$arr = array ('command'=>'enablepool','parameter'=>$_POST['start']);
send_request_to_host($arr, $host_data);
sleep(2);
}
}
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Anubis - a cgminer web frontend</title>
<link href="templatemo_style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="css/ddsmoothmenu.css" />
<script type="text/javascript" src="scripts/jquery.min.js"></script>
<script type="text/javascript" src="scripts/ddsmoothmenu.js">
/***********************************************
* Smooth Navigational Menu- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
</script>
<script type="text/javascript">
ddsmoothmenu.init({
mainmenuid: "templatemo_menu", //menu DIV id
orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
classname: 'ddsmoothmenu', //class added to menu's outer DIV
//customtheme: ["#1c5a80", "#18374a"],
contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
})
</script>
</head>
<body>
<div id="templatemo_wrapper">
<div id="templatemo_header">
<div id="site_title"><h1><a href="index.php">Main</a></h1></div>
<div id="templatemo_menu" class="ddsmoothmenu">
<ul>
<li><a href="index.php" class="selected">Home</a></li>
</li>
<li><a href="config.php">Configuration</a>
</li>
<li><a href="faq.php">FAQ</a>
</li>
<li><a href="contact.php">Contact/Donate</a></li>
</ul>
<br style="clear: left" />
</div> <!-- end of templatemo_menu -->
</div> <!-- end of header -->
<div id="templatemo_main">
<div class="col_fw">
<div class="templatemo_megacontent">
<h2>Host detail</h2>
<div class="cleaner h20"></div>
<?
if ($host_data)
{
if ($host_alive)
{
echo "<table id='rounded-corner' summary='HostInfo' width='100'>";
echo process_host_info($host_data);
echo "</table>";
}
echo "<table id='rounded-corner' summary='HostSummary' align='center'>";
echo create_host_header();
echo get_host_summary($host_data);
echo "</table>";
if ($host_alive)
{
echo "<form name=pool action='edithost.php?id=".$id."' method='post'>";
echo "<table id='rounded-corner' summary='PoolSummary' align='center'>";
echo create_pool_header();
echo process_pools_disp($host_data, $privileged);
echo "</table>";
echo "</form>";
echo "<table id='rounded-corner' summary='DevsSummary' align='center'>";
echo create_devs_header();
echo process_devs_disp($host_data);
echo "</table>";
}
?>
<form name=save action="edithost.php?id=<?=$id?>" method="post">
<table id="savetable" align=center>
<thead>
<tr>
<th scope="col" class="rounded-company">Name</th>
<th scope="col" class="rounded-q1">IP / Hostname</th>
<th scope="col" class="rounded-q1">Port</th>
<th scope="col" class="rounded-q1">MH/s desired</th>
</tr>
<tr>
<td align=center><input type="text" name="macname" value="<?=$host_data['name']?>"></td>
<td align=center><input type="text" name="ipaddress" value="<?=$host_data['address']?>"></td>
<td align=center><input type="text" name="port" value="<?=$host_data['port']?>"></td>
<td align=center><input type="text" name="mhash" value="<?=$host_data['mhash_desired']?>"></td>
</tr>
<tr>
<td colspan=4 align=center><input type=hidden name="savehostid" value="<?=$id?>"><input type="submit" value="Save" name="save"><input type="submit" value="Delete this host" name="delete"></td>
</tr>
</thead>
</table>
</form>
<?
}
else {
echo "Host not found or you just deleted the host !<BR>";
}
?>
<div class="cleaner h20"></div>
<!-- <a href="#" class="more float_r"></a> -->
</div>
<div class="cleaner"></div>
</div>
<div class="cleaner"></div>
</div>
</div>
<div class="cleaner"></div>
<div id="templatemo_footer_wrapper">
<div id="templatemo_footer">
<? include("footer.inc.php"); ?>
<div class="cleaner"></div>
</div>
</div>
</body>
</html>