From 4511014d6e7e05fe70a1fc0968b45a5cd57022fe Mon Sep 17 00:00:00 2001 From: Kano Date: Tue, 11 Feb 2014 09:47:51 +1100 Subject: [PATCH] miner.php - define a default rigport (that can be changed) and don't require a port number in the rigs array --- doc/API | 12 ++++++++++-- miner.php | 51 ++++++++++++++++++++++++++++++++++++--------------- 2 files changed, 46 insertions(+), 17 deletions(-) diff --git a/doc/API b/doc/API index 1498e1d2..ae46ab1c 100644 --- a/doc/API +++ b/doc/API @@ -1270,16 +1270,24 @@ However, if $readonly is true, it will not display them --------- +Default: + $rigport = 4028; + +Default port to use if any $rigs entries don't specify the port number + +--------- + Default: $rigs = array('127.0.0.1:4028'); -Set $rigs to an array of your sgminer rigs that are running - format: 'IP:Port' or 'Host:Port' or 'Host:Port:Name' +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' If you only have one rig, it will just show the detail of that rig If you have more than one rig it will show a summary of all the rigs with buttons to show the details of each rig - the button contents will be 'Name' rather than rig number, if you specify 'Name' +If Port is missing or blank, it will try $rigport e.g. $rigs = array('127.0.0.1:4028','myrig.com:4028:Sugoi'); --------- diff --git a/miner.php b/miner.php index 91cd2971..12db6464 100644 --- a/miner.php +++ b/miner.php @@ -1,8 +1,8 @@ = 2) + if (count($parts) >= 1) { $miner = $parts[0]; - $port = $parts[1]; + if (count($parts) >= 2) + $port = $parts[1]; + else + $port = ''; if (count($parts) > 2) $name = $parts[2]; @@ -2589,10 +2598,13 @@ function processcustompage($pagename, $sections, $sum, $ext, $namemap) foreach ($rigs as $num => $rig) { $parts = explode(':', $rig, 3); - if (count($parts) >= 2) + if (count($parts) >= 1) { $miner = $parts[0]; - $port = $parts[1]; + if (count($parts) >= 2) + $port = $parts[1]; + else + $port = ''; if (count($parts) > 2) $name = $parts[2]; @@ -2950,10 +2962,13 @@ function display() if ($rig != null and $rig != '' and $rig >= 0 and $rig < count($rigs)) { $parts = explode(':', $rigs[$rig], 3); - if (count($parts) >= 2) + if (count($parts) >= 1) { $miner = $parts[0]; - $port = $parts[1]; + if (count($parts) >= 2) + $port = $parts[1]; + else + $port = ''; if ($readonly !== true) $preprocess = $arg; @@ -3002,10 +3017,13 @@ function display() if (count($rigs) == 1) { $parts = explode(':', $rigs[0], 3); - if (count($parts) >= 2) + if (count($parts) >= 1) { $miner = $parts[0]; - $port = $parts[1]; + if (count($parts) >= 2) + $port = $parts[1]; + else + $port = ''; htmlhead($mcerr, true, 0); doOne(0, $preprocess); @@ -3022,10 +3040,13 @@ function display() if ($rig != null and $rig != '' and $rig >= 0 and $rig < count($rigs)) { $parts = explode(':', $rigs[$rig], 3); - if (count($parts) >= 2) + if (count($parts) >= 1) { $miner = $parts[0]; - $port = $parts[1]; + if (count($parts) >= 2) + $port = $parts[1]; + else + $port = ''; htmlhead($mcerr, true, 0); doOne($rig, $preprocess);