diff --git a/doc/API b/doc/API index c39f6385..1498e1d2 100644 --- a/doc/API +++ b/doc/API @@ -1284,6 +1284,27 @@ e.g. $rigs = array('127.0.0.1:4028','myrig.com:4028:Sugoi'); --------- +Default: + $rignames = false; + +Set $rignames to false to not affect the display. +Set $rignames to one of 'ip' or 'ipx' to alter the name displayed +if the rig doesn't have a 'name' in $rigs +Currently: + 'ip' means use the 4th byte of the rig IP address as an integer + 'ipx' means use the 4th byte of the rig IP address as 2 hex bytes + +--------- + +Default: + $rigbuttons = true; + +Set $rigbuttons to false to display a link rather than a button on +the left of any summary table with rig buttons, in order to reduce +the height of the table cells + +--------- + Default: $mcast = false; diff --git a/miner.php b/miner.php index 0bc21ec1..91cd2971 100644 --- a/miner.php +++ b/miner.php @@ -2,6 +2,7 @@ session_start(); # global $doctype, $title, $miner, $port, $readonly, $notify, $rigs; +global $rignames, $rigbuttons; global $mcast, $mcastexpect, $mcastaddr, $mcastport, $mcastcode; global $mcastlistport, $mcasttimeout, $mcastretries, $allowgen; global $rigipsecurity, $rigtotals, $forcerigtotals; @@ -48,6 +49,13 @@ $poolinputs = false; # format: 'IP:Port' or 'Host:Port' or 'Host:Port:Name' $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 $mcast = false; # @@ -247,6 +255,9 @@ $colourtable = array( $miner = null; $port = null; # +global $rigips; +$rigips = array(); +# # Ensure it is only ever shown once global $showndate; $showndate = false; @@ -289,6 +300,14 @@ function getdom($domname) 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) { global $doctype, $title, $miner_font_family, $miner_font_size; @@ -491,7 +510,7 @@ function getrigs() # function getsock($rig, $addr, $port) { - global $rigipsecurity; + global $rigips, $rignames, $rigipsecurity; global $haderror, $error, $socksndtimeoutsec, $sockrcvtimeoutsec; $error = null; @@ -534,6 +553,9 @@ function getsock($rig, $addr, $port) socket_close($socket); return null; } + if ($rignames !== false && !isset($rigips[$addr])) + if (socket_getpeername($socket, $ip) == true) + $rigips[$addr] = $ip; return $socket; } # @@ -1536,39 +1558,67 @@ function process($cmds, $rig) # function rigname($rig, $rigname) { - global $rigs; + global $rigs, $rignames, $rigips; if (isset($rigs[$rig])) { $parts = explode(':', $rigs[$rig], 3); if (count($parts) == 3) $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; } # -function riginput($rig, $rigname) +function riginput($rig, $rigname, $usebuttons) { $rigname = rigname($rig, $rigname); - return ""; + if ($usebuttons === true) + return ""; + else + return "$rigname"; } # -function rigbutton($rig, $rigname, $when, $row) +function rigbutton($rig, $rigname, $when, $row, $usebuttons) { list($value, $class) = fmt('BUTTON', 'Rig', '', $when, $row); if ($rig === '') $ri = ' '; else - $ri = riginput($rig, $rigname); + $ri = riginput($rig, $rigname, $usebuttons); return "