|
|
@ -1,7 +1,8 @@ |
|
|
|
<?php |
|
|
|
<?php |
|
|
|
session_start(); |
|
|
|
session_start(); |
|
|
|
# |
|
|
|
# |
|
|
|
global $doctype, $title, $miner, $port, $readonly, $notify, $rigs; |
|
|
|
global $doctype, $title, $miner, $port, $readonly, $notify; |
|
|
|
|
|
|
|
global $rigport, $rigs, $rignames, $rigbuttons; |
|
|
|
global $mcast, $mcastexpect, $mcastaddr, $mcastport, $mcastcode; |
|
|
|
global $mcast, $mcastexpect, $mcastaddr, $mcastport, $mcastcode; |
|
|
|
global $mcastlistport, $mcasttimeout, $mcastretries, $allowgen; |
|
|
|
global $mcastlistport, $mcasttimeout, $mcastretries, $allowgen; |
|
|
|
global $rigipsecurity, $rigtotals, $forcerigtotals; |
|
|
|
global $rigipsecurity, $rigtotals, $forcerigtotals; |
|
|
@ -44,10 +45,20 @@ $checklastshare = true; |
|
|
|
# N.B. also if $readonly is true, it will not display the fields |
|
|
|
# N.B. also if $readonly is true, it will not display the fields |
|
|
|
$poolinputs = false; |
|
|
|
$poolinputs = false; |
|
|
|
# |
|
|
|
# |
|
|
|
# Set $rigs to an array of your sgminer rigs that are running |
|
|
|
# Default port to use if any $rigs entries don't specify the port number |
|
|
|
# format: 'IP:Port' or 'Host:Port' or 'Host:Port:Name' |
|
|
|
$rigport = 4028; |
|
|
|
|
|
|
|
# |
|
|
|
|
|
|
|
# Set $rigs to an array of your rigs that are running |
|
|
|
|
|
|
|
# format: 'IP' or 'Host' or 'IP:Port' or 'Host:Port' or 'Host:Port:Name' |
|
|
|
$rigs = array('127.0.0.1:4028'); |
|
|
|
$rigs = array('127.0.0.1:4028'); |
|
|
|
# |
|
|
|
# |
|
|
|
|
|
|
|
# Set $rignames to false, or one of 'ip' or 'ipx' |
|
|
|
|
|
|
|
# this says what to use if $rigs doesn't have a 'name' |
|
|
|
|
|
|
|
$rignames = false; |
|
|
|
|
|
|
|
# |
|
|
|
|
|
|
|
# Set $rigbuttons to false to display a link rather than a button |
|
|
|
|
|
|
|
$rigbuttons = true; |
|
|
|
|
|
|
|
# |
|
|
|
# Set $mcast to true to look for your rigs and ignore $rigs |
|
|
|
# Set $mcast to true to look for your rigs and ignore $rigs |
|
|
|
$mcast = false; |
|
|
|
$mcast = false; |
|
|
|
# |
|
|
|
# |
|
|
@ -247,6 +258,9 @@ $colourtable = array( |
|
|
|
$miner = null; |
|
|
|
$miner = null; |
|
|
|
$port = null; |
|
|
|
$port = null; |
|
|
|
# |
|
|
|
# |
|
|
|
|
|
|
|
global $rigips; |
|
|
|
|
|
|
|
$rigips = array(); |
|
|
|
|
|
|
|
# |
|
|
|
# Ensure it is only ever shown once |
|
|
|
# Ensure it is only ever shown once |
|
|
|
global $showndate; |
|
|
|
global $showndate; |
|
|
|
$showndate = false; |
|
|
|
$showndate = false; |
|
|
@ -289,6 +303,14 @@ function getdom($domname) |
|
|
|
return getcss($domname, true); |
|
|
|
return getcss($domname, true); |
|
|
|
} |
|
|
|
} |
|
|
|
# |
|
|
|
# |
|
|
|
|
|
|
|
# N.B. don't call this before calling htmlhead() |
|
|
|
|
|
|
|
function php_pr($cmd) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
global $here, $autorefresh; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return "$here?ref=$autorefresh$cmd"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
# |
|
|
|
function htmlhead($mcerr, $checkapi, $rig, $pg = null, $noscript = false) |
|
|
|
function htmlhead($mcerr, $checkapi, $rig, $pg = null, $noscript = false) |
|
|
|
{ |
|
|
|
{ |
|
|
|
global $doctype, $title, $miner_font_family, $miner_font_size; |
|
|
|
global $doctype, $title, $miner_font_family, $miner_font_size; |
|
|
@ -491,9 +513,12 @@ function getrigs() |
|
|
|
# |
|
|
|
# |
|
|
|
function getsock($rig, $addr, $port) |
|
|
|
function getsock($rig, $addr, $port) |
|
|
|
{ |
|
|
|
{ |
|
|
|
global $rigipsecurity; |
|
|
|
global $rigport, $rigips, $rignames, $rigipsecurity; |
|
|
|
global $haderror, $error, $socksndtimeoutsec, $sockrcvtimeoutsec; |
|
|
|
global $haderror, $error, $socksndtimeoutsec, $sockrcvtimeoutsec; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$port = trim($port); |
|
|
|
|
|
|
|
if (strlen($port) == 0) |
|
|
|
|
|
|
|
$port = $rigport; |
|
|
|
$error = null; |
|
|
|
$error = null; |
|
|
|
$socket = null; |
|
|
|
$socket = null; |
|
|
|
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); |
|
|
|
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); |
|
|
@ -534,6 +559,9 @@ function getsock($rig, $addr, $port) |
|
|
|
socket_close($socket); |
|
|
|
socket_close($socket); |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if ($rignames !== false && !isset($rigips[$addr])) |
|
|
|
|
|
|
|
if (socket_getpeername($socket, $ip) == true) |
|
|
|
|
|
|
|
$rigips[$addr] = $ip; |
|
|
|
return $socket; |
|
|
|
return $socket; |
|
|
|
} |
|
|
|
} |
|
|
|
# |
|
|
|
# |
|
|
@ -1536,39 +1564,67 @@ function process($cmds, $rig) |
|
|
|
# |
|
|
|
# |
|
|
|
function rigname($rig, $rigname) |
|
|
|
function rigname($rig, $rigname) |
|
|
|
{ |
|
|
|
{ |
|
|
|
global $rigs; |
|
|
|
global $rigs, $rignames, $rigips; |
|
|
|
|
|
|
|
|
|
|
|
if (isset($rigs[$rig])) |
|
|
|
if (isset($rigs[$rig])) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$parts = explode(':', $rigs[$rig], 3); |
|
|
|
$parts = explode(':', $rigs[$rig], 3); |
|
|
|
if (count($parts) == 3) |
|
|
|
if (count($parts) == 3) |
|
|
|
$rigname = $parts[2]; |
|
|
|
$rigname = $parts[2]; |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
if ($rignames !== false) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
switch ($rignames) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
case 'ip': |
|
|
|
|
|
|
|
if (isset($parts[0]) && isset($rigips[$parts[0]])) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$ip = explode('.', $rigips[$parts[0]]); |
|
|
|
|
|
|
|
if (count($ip) == 4) |
|
|
|
|
|
|
|
$rigname = intval($ip[3]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 'ipx': |
|
|
|
|
|
|
|
if (isset($parts[0]) && isset($rigips[$parts[0]])) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$ip = explode('.', $rigips[$parts[0]]); |
|
|
|
|
|
|
|
if (count($ip) == 4) |
|
|
|
|
|
|
|
$rigname = intval($ip[3], 16); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return $rigname; |
|
|
|
return $rigname; |
|
|
|
} |
|
|
|
} |
|
|
|
# |
|
|
|
# |
|
|
|
function riginput($rig, $rigname) |
|
|
|
function riginput($rig, $rigname, $usebuttons) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$rigname = rigname($rig, $rigname); |
|
|
|
$rigname = rigname($rig, $rigname); |
|
|
|
|
|
|
|
|
|
|
|
return "<input type=button value='$rigname' onclick='pr(\"&rig=$rig\",null)'>"; |
|
|
|
if ($usebuttons === true) |
|
|
|
|
|
|
|
return "<input type=button value='$rigname' onclick='pr(\"&rig=$rig\",null)'>"; |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
return "<a href='".php_pr("&rig=$rig")."'>$rigname</a>"; |
|
|
|
} |
|
|
|
} |
|
|
|
# |
|
|
|
# |
|
|
|
function rigbutton($rig, $rigname, $when, $row) |
|
|
|
function rigbutton($rig, $rigname, $when, $row, $usebuttons) |
|
|
|
{ |
|
|
|
{ |
|
|
|
list($value, $class) = fmt('BUTTON', 'Rig', '', $when, $row); |
|
|
|
list($value, $class) = fmt('BUTTON', 'Rig', '', $when, $row); |
|
|
|
|
|
|
|
|
|
|
|
if ($rig === '') |
|
|
|
if ($rig === '') |
|
|
|
$ri = ' '; |
|
|
|
$ri = ' '; |
|
|
|
else |
|
|
|
else |
|
|
|
$ri = riginput($rig, $rigname); |
|
|
|
$ri = riginput($rig, $rigname, $usebuttons); |
|
|
|
|
|
|
|
|
|
|
|
return "<td align=middle$class>$ri</td>"; |
|
|
|
return "<td align=middle$class>$ri</td>"; |
|
|
|
} |
|
|
|
} |
|
|
|
# |
|
|
|
# |
|
|
|
function showrigs($anss, $headname, $rigname) |
|
|
|
function showrigs($anss, $headname, $rigname) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
global $rigbuttons; |
|
|
|
|
|
|
|
|
|
|
|
$dthead = array($headname => 1, 'STATUS' => 1, 'Description' => 1, 'When' => 1, 'API' => 1, 'sgminer' => 1); |
|
|
|
$dthead = array($headname => 1, 'STATUS' => 1, 'Description' => 1, 'When' => 1, 'API' => 1, 'sgminer' => 1); |
|
|
|
showhead('', $dthead); |
|
|
|
showhead('', $dthead); |
|
|
|
|
|
|
|
|
|
|
@ -1591,7 +1647,7 @@ function showrigs($anss, $headname, $rigname) |
|
|
|
foreach ($dthead as $name => $x) |
|
|
|
foreach ($dthead as $name => $x) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if ($item == 'STATUS' && $name == $headname) |
|
|
|
if ($item == 'STATUS' && $name == $headname) |
|
|
|
echo rigbutton($rig, $rigname.$rig, $when, null); |
|
|
|
echo rigbutton($rig, $rigname.$rig, $when, null, $rigbuttons); |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (isset($row[$name])) |
|
|
|
if (isset($row[$name])) |
|
|
@ -1610,7 +1666,7 @@ function showrigs($anss, $headname, $rigname) |
|
|
|
function doforeach($cmd, $des, $sum, $head, $datetime) |
|
|
|
function doforeach($cmd, $des, $sum, $head, $datetime) |
|
|
|
{ |
|
|
|
{ |
|
|
|
global $miner, $port; |
|
|
|
global $miner, $port; |
|
|
|
global $error, $readonly, $notify, $rigs; |
|
|
|
global $error, $readonly, $notify, $rigs, $rigbuttons; |
|
|
|
global $warnfont, $warnoff, $dfmt; |
|
|
|
global $warnfont, $warnoff, $dfmt; |
|
|
|
global $rigerror; |
|
|
|
global $rigerror; |
|
|
|
|
|
|
|
|
|
|
@ -1629,10 +1685,13 @@ function doforeach($cmd, $des, $sum, $head, $datetime) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
$parts = explode(':', $rig, 3); |
|
|
|
$parts = explode(':', $rig, 3); |
|
|
|
if (count($parts) >= 2) |
|
|
|
if (count($parts) >= 1) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$miner = $parts[0]; |
|
|
|
$miner = $parts[0]; |
|
|
|
$port = $parts[1]; |
|
|
|
if (count($parts) >= 2) |
|
|
|
|
|
|
|
$port = $parts[1]; |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
$port = ''; |
|
|
|
|
|
|
|
|
|
|
|
if (count($parts) > 2) |
|
|
|
if (count($parts) > 2) |
|
|
|
$name = $parts[2]; |
|
|
|
$name = $parts[2]; |
|
|
@ -1747,7 +1806,7 @@ function doforeach($cmd, $des, $sum, $head, $datetime) |
|
|
|
echo "<td align=right$class>Total:</td>"; |
|
|
|
echo "<td align=right$class>Total:</td>"; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
echo rigbutton($rig, "Rig $rig", $when, $row); |
|
|
|
echo rigbutton($rig, "Rig $rig", $when, $row, $rigbuttons); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1780,7 +1839,7 @@ function refreshbuttons() |
|
|
|
# |
|
|
|
# |
|
|
|
function pagebuttons($rig, $pg) |
|
|
|
function pagebuttons($rig, $pg) |
|
|
|
{ |
|
|
|
{ |
|
|
|
global $readonly, $rigs, $userlist, $ses; |
|
|
|
global $readonly, $rigs, $rigbuttons, $userlist, $ses; |
|
|
|
global $allowcustompages, $customsummarypages; |
|
|
|
global $allowcustompages, $customsummarypages; |
|
|
|
|
|
|
|
|
|
|
|
if ($rig === null) |
|
|
|
if ($rig === null) |
|
|
@ -1819,10 +1878,12 @@ function pagebuttons($rig, $pg) |
|
|
|
if ($userlist === null || isset($_SESSION[$ses])) |
|
|
|
if ($userlist === null || isset($_SESSION[$ses])) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if ($prev !== null) |
|
|
|
if ($prev !== null) |
|
|
|
echo riginput($prev, 'Prev').' '; |
|
|
|
echo riginput($prev, 'Prev', true).' '; |
|
|
|
|
|
|
|
|
|
|
|
echo "<input type=button value='Refresh' onclick='pr(\"$refresh\",null)'> "; |
|
|
|
echo "<input type=button value='Refresh' onclick='pr(\"$refresh\",null)'> "; |
|
|
|
|
|
|
|
|
|
|
|
if ($next !== null) |
|
|
|
if ($next !== null) |
|
|
|
echo riginput($next, 'Next').' '; |
|
|
|
echo riginput($next, 'Next', true).' '; |
|
|
|
echo ' '; |
|
|
|
echo ' '; |
|
|
|
if (count($rigs) > 1) |
|
|
|
if (count($rigs) > 1) |
|
|
|
echo "<input type=button value='Summary' onclick='pr(\"\",null)'> "; |
|
|
|
echo "<input type=button value='Summary' onclick='pr(\"\",null)'> "; |
|
|
@ -2184,6 +2245,8 @@ function secmatch($section, $field) |
|
|
|
# |
|
|
|
# |
|
|
|
function customset($showfields, $sum, $section, $rig, $isbutton, $result, $total) |
|
|
|
function customset($showfields, $sum, $section, $rig, $isbutton, $result, $total) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
global $rigbuttons; |
|
|
|
|
|
|
|
|
|
|
|
foreach ($result as $sec => $row) |
|
|
|
foreach ($result as $sec => $row) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$secname = preg_replace('/\d/', '', $sec); |
|
|
|
$secname = preg_replace('/\d/', '', $sec); |
|
|
@ -2200,7 +2263,7 @@ function customset($showfields, $sum, $section, $rig, $isbutton, $result, $total |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($isbutton) |
|
|
|
if ($isbutton) |
|
|
|
echo rigbutton($rig, $rig, $when, $row); |
|
|
|
echo rigbutton($rig, $rig, $when, $row, $rigbuttons); |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
list($ignore, $class) = fmt('total', '', '', $when, $row); |
|
|
|
list($ignore, $class) = fmt('total', '', '', $when, $row); |
|
|
@ -2535,10 +2598,13 @@ function processcustompage($pagename, $sections, $sum, $ext, $namemap) |
|
|
|
foreach ($rigs as $num => $rig) |
|
|
|
foreach ($rigs as $num => $rig) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$parts = explode(':', $rig, 3); |
|
|
|
$parts = explode(':', $rig, 3); |
|
|
|
if (count($parts) >= 2) |
|
|
|
if (count($parts) >= 1) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$miner = $parts[0]; |
|
|
|
$miner = $parts[0]; |
|
|
|
$port = $parts[1]; |
|
|
|
if (count($parts) >= 2) |
|
|
|
|
|
|
|
$port = $parts[1]; |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
$port = ''; |
|
|
|
|
|
|
|
|
|
|
|
if (count($parts) > 2) |
|
|
|
if (count($parts) > 2) |
|
|
|
$name = $parts[2]; |
|
|
|
$name = $parts[2]; |
|
|
@ -2896,10 +2962,13 @@ function display() |
|
|
|
if ($rig != null and $rig != '' and $rig >= 0 and $rig < count($rigs)) |
|
|
|
if ($rig != null and $rig != '' and $rig >= 0 and $rig < count($rigs)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$parts = explode(':', $rigs[$rig], 3); |
|
|
|
$parts = explode(':', $rigs[$rig], 3); |
|
|
|
if (count($parts) >= 2) |
|
|
|
if (count($parts) >= 1) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$miner = $parts[0]; |
|
|
|
$miner = $parts[0]; |
|
|
|
$port = $parts[1]; |
|
|
|
if (count($parts) >= 2) |
|
|
|
|
|
|
|
$port = $parts[1]; |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
$port = ''; |
|
|
|
|
|
|
|
|
|
|
|
if ($readonly !== true) |
|
|
|
if ($readonly !== true) |
|
|
|
$preprocess = $arg; |
|
|
|
$preprocess = $arg; |
|
|
@ -2948,10 +3017,13 @@ function display() |
|
|
|
if (count($rigs) == 1) |
|
|
|
if (count($rigs) == 1) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$parts = explode(':', $rigs[0], 3); |
|
|
|
$parts = explode(':', $rigs[0], 3); |
|
|
|
if (count($parts) >= 2) |
|
|
|
if (count($parts) >= 1) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$miner = $parts[0]; |
|
|
|
$miner = $parts[0]; |
|
|
|
$port = $parts[1]; |
|
|
|
if (count($parts) >= 2) |
|
|
|
|
|
|
|
$port = $parts[1]; |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
$port = ''; |
|
|
|
|
|
|
|
|
|
|
|
htmlhead($mcerr, true, 0); |
|
|
|
htmlhead($mcerr, true, 0); |
|
|
|
doOne(0, $preprocess); |
|
|
|
doOne(0, $preprocess); |
|
|
@ -2968,10 +3040,13 @@ function display() |
|
|
|
if ($rig != null and $rig != '' and $rig >= 0 and $rig < count($rigs)) |
|
|
|
if ($rig != null and $rig != '' and $rig >= 0 and $rig < count($rigs)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$parts = explode(':', $rigs[$rig], 3); |
|
|
|
$parts = explode(':', $rigs[$rig], 3); |
|
|
|
if (count($parts) >= 2) |
|
|
|
if (count($parts) >= 1) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$miner = $parts[0]; |
|
|
|
$miner = $parts[0]; |
|
|
|
$port = $parts[1]; |
|
|
|
if (count($parts) >= 2) |
|
|
|
|
|
|
|
$port = $parts[1]; |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
$port = ''; |
|
|
|
|
|
|
|
|
|
|
|
htmlhead($mcerr, true, 0); |
|
|
|
htmlhead($mcerr, true, 0); |
|
|
|
doOne($rig, $preprocess); |
|
|
|
doOne($rig, $preprocess); |
|
|
|