-
Notifications
You must be signed in to change notification settings - Fork 4
/
parser.php
191 lines (181 loc) · 7.74 KB
/
parser.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
<?php
/**
* Claymore-PhoenixMiner-Web-Stats
*
* Simple PHP page to connect to any number of Claymore and PhoenixMiner miners and view hashrates, GPU temps, and fan speeds.
*
* @package claymore-phoenixminer-web-stats
* @version 1.0.2
* @author James D (jimok82@gmail.com)
* @copyright Copyright (c) 2018-2021 James D.
* @license This file is part of claymore-phoenixminer-web-stats - free software licensed under the GNU General Public License version 3
* @link https://github.com/JaymZZZZ/claymore-phoenixminer-web-stats
*
*
*
* @var boolean $debug_mode
* @var object $miner_list
* @var integer $node_count
* @var integer $execution_time
* @var integer $refresh_interval
* @var integer $wait_timeout
* @var integer $gpu_temp_yellow
* @var integer $gpu_temp_red
* @var integer $gpu_mem_temp_yellow
* @var integer $gpu_mem_temp_red
* @var integer $gpu_fan_high_yellow
* @var integer $gpu_fan_high_red
* @var integer $gpu_fan_low_yellow
* @var integer $gpu_fan_low_red
* @var integer $require_admin_password
* @var string $admin_password
*/
// ------------------------------------------------------------------------
session_start();
require_once 'conf.php';
require_once 'json_parser.class.php';
if ($require_admin_password) {
if (!isset($_SESSION['user_logged_in']) || !isset($_SESSION['admin_password_hash']) || $_SESSION['admin_password_hash'] != md5($admin_password)) {
die();
}
}
$parser = new json_parser();
if ($debug_mode) {
error_reporting(E_ERROR | E_WARNING);
ini_set('display_errors', 1);
$parser->debug = TRUE;
} else {
error_reporting(0);
ini_set('display_errors', 0);
}
$parser->miner_list = $miner_list;
$parser->wait_timeout = $wait_timeout;
$parser->gpu_temp_yellow = $gpu_temp_yellow;
$parser->gpu_temp_red = $gpu_temp_red;
$parser->gpu_mem_temp_yellow = $gpu_mem_temp_yellow;
$parser->gpu_mem_temp_red = $gpu_mem_temp_red;
$parser->gpu_fan_high_yellow = $gpu_fan_high_yellow;
$parser->gpu_fan_high_red = $gpu_fan_high_red;
$parser->gpu_fan_low_yellow = $gpu_fan_low_yellow;
$parser->gpu_fan_low_red = $gpu_fan_low_red;
$parser->parse_all_json_rpc_calls($_GET['name']);
?>
<?php foreach ($parser->miner_data_results as $name => $miner) { ?>
<div id="results_<?php echo $name; ?>"
class="box <?php if ($parser->miner_status->{$name} != 1) { ?> box-down <?php } else { ?> box-up <?php } ?>">
<div class="box__header">
<?php if ($parser->miner_status->{$name} == 1) { ?>
<div class="server">
<ul>
<li></li>
<li></li>
<li></li>
</ul>
</div>
<?php } else { ?>
<div class="server error">
<ul>
<li></li>
<li></li>
<li></li>
</ul>
</div>
<?php } ?>
</div>
<div class="box__body">
<div class="stats stats--main">
<?php if ($parser->error) {
echo $parser->error;
} ?>
<div class="stats__name"><?php echo $name; ?>
(<?php echo ($miner->coin == null) ? "N/A" : $miner->coin ?>)
</div>
<div class="stats__caption">
Miner: <?php echo ($miner->version == null) ? "N/A" : $miner->version ?></div>
<div class="stats__change">
<div class="stats__value stats__value--positive">Uptime</div>
<div class="stats__period"><?php echo ($miner->uptime == null) ? "DOWN" : $miner->uptime ?></div>
</div>
</div>
<div class="stats">
<div class="stats__amount">Pool</div>
<div class="stats__caption"><?php echo ($miner->pool == null) ? "N/A" : $miner->pool ?></div>
</div>
<div class="stats">
<div class="stats__amount">Shares (Submitted / Stale / Rejected)</div>
<div class="stats__caption">
<div class="stats__value--positive"
style="display: inline;"><?php echo number_format($miner->stats->shares, 0) ?></div>
/ <?php echo number_format($miner->stats->stale, 0) ?> /
<div class="stats__value--negative"
style="display: inline;"><?php echo number_format($miner->stats->rejected, 0) ?></div>
</div>
</div>
<div class="stats">
<div class="stats__amount">Miner
Hashrate <?php if (!is_null($miner->profitability->result->profit)) { ?>(Daily Profit)<?php } ?></div>
<div class="stats__caption result_hashrate">
<?php echo ($miner->stats->hashrate == null) ? "0.0" : $miner->stats->hashrate ?>
MH/s <?php if (!is_null($miner->profitability->result->profit)) { ?>(<?php echo $parser->show_profit($miner->profitability->result->profit) ?>)<?php } ?>
</div>
</div>
<div class="stats">
<div class="stats__amount">Video Card Stats</div>
<div class="stats__amount" style="padding-bottom: 10px;">
________________________________________________________________________________
</div>
<div class="stats__caption">
<table style="width: 100%">
<thead>
<tr>
<th class="stats__amount" style="text-align: left;">GPU Name</th>
<th class="stats__amount">Hashrate</th>
<th class="stats__amount">GPU Temp</th>
<th class="stats__amount">Mem Temp</th>
<th class="stats__amount">Fan %</th>
</tr>
</thead>
<tbody>
<?php
if (count((array)$miner->card_stats) >= 1) {
foreach ($miner->card_stats as $key => $stat) { ?>
<tr>
<th style="width: 40%; text-align: left;"><?php echo $stat->name; ?></th>
<th><?php echo number_format($stat->hashrate, 2) ?> MH/s</th>
<th><?php echo $parser->show_temp_warning($stat->temp, "° C") ?></th>
<th><?php echo $parser->show_mem_temp_warning($stat->mem_temp, "° C") ?></th>
<th><?php echo $parser->show_fan_warning($stat->fan, "%") ?></th>
</tr>
<?php }
} else { ?>
<tr>
<td colspan="5"> No Card Data Available</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
<div>
<div class="stats__update_time">Last Updated On: <?php echo date("Y-m-d | H:i:s"); ?></div>
</div>
</div>
</div>
<?php }
if ($debug_mode) { ?>
<div class="box-debug">
DEBUG MODE
<?php
foreach ($parser->miner_list as $miner) {
$miner->hostname = "MASKED";
$miner->port = "MASKED";
$miner->password = "MASKED";
}
echo "<pre>";
print_r($parser);
echo "Node Count:" . $node_count . "<br>";
echo "Execution Time:" . $execution_time . "<br>";
echo "</pre>";
?>
</div>
<?php } ?>