diff --git a/API-README b/API-README index ef61c81f..2829b95d 100644 --- a/API-README +++ b/API-README @@ -952,7 +952,9 @@ or in your cgminer.conf And in miner.php set $mcast = true; This will ignore the value of $rigs and overwrite it with the list of zero or -more rigs found on the network in the timout specified +more rigs found on the network in the timeout specified +A rig will not reply if the API settings would mean it would also ignore an +API request from the web server running miner.php --------- @@ -1196,6 +1198,14 @@ Set $mcast to true to look for your rigs and ignore $rigs --------- +Default: + $mcastexpect = 0; + +The minimum number of rigs expected to be found when $mcast is true +If fewer are found, an error will be included at the top of the page + +--------- + Default: $mcastaddr = '224.0.0.75'; @@ -1237,6 +1247,16 @@ N.B. the accuracy of the timing used to wait for the replies is --------- +Default: + $allowgen = false; + +Set $allowgen to true to allow customsummarypages to use 'gen' +false means ignore any 'gen' options +This is disabled by default due to the possible security risk +of using it, see the end of this document for an explanation + +--------- + Default: $rigipsecurity = true; @@ -1498,6 +1518,7 @@ The example given: With cgminer 2.10.2 and later, miner.php includes an extension to the custom pages that allows you to apply SQL style commands to the data: where, group, and having +cgminer 3.4.2 also includes another option 'gen' As an example, miner.php includes a more complex custom page called 'Pools' this includes the extension: @@ -1513,6 +1534,7 @@ $poolsext = array( 'STATS.Bytes Sent' => 'sum', 'STATS.Times Recv' => 'sum', 'STATS.Bytes Recv' => 'sum'), + 'gen' => array('AvShr', 'POOL.Difficulty Accepted/max(POOL.Accepted,1)), 'having' => array(array('STATS.Bytes Recv', '>', 0))) ); @@ -1564,3 +1586,21 @@ The first 4 are as expected - the numerical sum, average, minimum or maximum of course any valid 'DEVS.Xyz' would give the same 'count' value 'any' is effectively random: the field value in the 1st row of the grouped data An unrecognised 'function' uses 'any' + +A 'gen' allows you to generate new fields from any php valid function of any +of the other fields + e.g. 'gen' => array('AvShr', 'POOL.Difficulty Accepted/max(POOL.Accepted,1)), +will generate a new field called GEN.AvShr that is the function shown, which +in this case is the average difficulty of each share submitted + +THERE IS A SECURITY RISK WITH HOW GEN WORKS +It simply replaces all the variables with their values and then requests PHP +the execute the formula - thus if a field value returned from a cgminer API +request contained PHP code, it could be executed by your web server +Of course cgminer doesn't do this, but if you do not control the cgminer that +returns the data in the API calls, someone could modify cgminer to return a +PHP string in a field you use in 'gen' +Thus use 'gen' at your own risk +If someone feels the urge to write a mathematical interpreter in PHP to get +around this risk, feel free to write one and submit it to the API author for +consideration diff --git a/miner.php b/miner.php index 137db7ee..fdb9e52f 100644 --- a/miner.php +++ b/miner.php @@ -1,17 +1,20 @@ \n"; +# # See API-README for more details of these variables and how # to configure miner.php # @@ -48,6 +51,9 @@ $rigs = array('127.0.0.1:4028'); # Set $mcast to true to look for your rigs and ignore $rigs $mcast = false; # +# Set $mcastexpect to at least how many rigs you expect it to find +$mcastexpect = 0; +# # API Multicast address all cgminers are listening on $mcastaddr = '224.0.0.75'; # @@ -64,6 +70,10 @@ $mcastlistport = 4027; # to wait for replies to the Multicast message $mcasttimeout = 1.5; # +# Set $allowgen to true to allow customsummarypages to use 'gen' +# false means ignore any 'gen' options +$allowgen = false; +# # Set $rigipsecurity to false to show the IP/Port of the rig # in the socket error messages and also show the full socket message $rigipsecurity = true; @@ -139,7 +149,7 @@ $poolspage = array( 'POOL.Has GBT=GBT', 'STATS.Times Sent=TSent', 'STATS.Bytes Sent=BSent', 'STATS.Net Bytes Sent=NSent', 'STATS.Times Recv=TRecv', 'STATS.Bytes Recv=BRecv', - 'STATS.Net Bytes Recv=NRecv')); + 'STATS.Net Bytes Recv=NRecv', 'GEN.AvShr=AvShr')); # $poolssum = array( 'SUMMARY' => array('MHS av', 'Found Blocks', 'Accepted', @@ -156,7 +166,9 @@ $poolsext = array( 'calc' => array('POOL.Difficulty Accepted' => 'sum', 'POOL.Difficulty Rejected' => 'sum', 'STATS.Times Sent' => 'sum', 'STATS.Bytes Sent' => 'sum', 'STATS.Net Bytes Sent' => 'sum', 'STATS.Times Recv' => 'sum', - 'STATS.Bytes Recv' => 'sum', 'STATS.Net Bytes Recv' => 'sum'), + 'STATS.Bytes Recv' => 'sum', 'STATS.Net Bytes Recv' => 'sum', + 'POOL.Accepted' => 'sum'), + 'gen' => array('AvShr' => 'round(POOL.Difficulty Accepted/max(POOL.Accepted,1)*100)/100'), 'having' => array(array('STATS.Bytes Recv', '>', 0))) ); @@ -176,9 +188,12 @@ $warnfont = ''; $warnoff = ''; $dfmt = 'H:i:s j-M-Y \U\T\CP'; # -$miner_font_family = 'verdana,arial,sans'; +$miner_font_family = 'Verdana, Arial, sans-serif, sans'; $miner_font_size = '13pt'; # +$bad_font_family = '"Times New Roman", Times, serif'; +$bad_font_size = '18pt'; +# # Edit this or redefine it in myminer.php to change the colour scheme # See $colourtable below for the list of names $colouroverride = array(); @@ -198,7 +213,7 @@ if (file_exists('myminer.php')) # This is the system default that must always contain all necessary # colours so it must be a constant # You can override these values with $colouroverride -# The only one missing is in $warnfont +# The only one missing is $warnfont # - which you can override directly anyway global $colourtable; $colourtable = array( @@ -210,6 +225,8 @@ $colourtable = array( 'td.h background' => '#c4ffff', 'td.err color' => 'black', 'td.err background' => '#ff3050', + 'td.bad color' => 'black', + 'td.bad background' => '#ff3050', 'td.warn color' => 'black', 'td.warn background' => '#ffb050', 'td.sta color' => 'green', @@ -269,9 +286,10 @@ function getdom($domname) return getcss($domname, true); } # -function htmlhead($checkapi, $rig, $pg = null, $noscript = false) +function htmlhead($mcerr, $checkapi, $rig, $pg = null, $noscript = false) { - global $title, $miner_font_family, $miner_font_size; + global $doctype, $title, $miner_font_family, $miner_font_size; + global $bad_font_family, $bad_font_size; global $error, $readonly, $poolinputs, $here; global $ignorerefresh, $autorefresh; @@ -300,14 +318,16 @@ function htmlhead($checkapi, $rig, $pg = null, $noscript = false) $readonly = true; } $miner_font = "font-family:$miner_font_family; font-size:$miner_font_size;"; + $bad_font = "font-family:$bad_font_family; font-size:$bad_font_size;"; - echo "$refreshmeta + echo "$doctype$refreshmeta $title