miner.php - define a default rigport (that can be changed) and don't require a port number in the rigs array
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
diff --git a/API-README b/API-README
index 1211f53..3416aba 100644
--- a/API-README
+++ b/API-README
@@ -1220,15 +1220,23 @@ 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 cgminer rigs that are running
- format: 'IP:Port' or 'Host:Port' or 'Host:Port:Name'
+ 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 1de3951..6fd0658 100644
--- a/miner.php
+++ b/miner.php
@@ -1,8 +1,8 @@
<?php
session_start();
#
-global $doctype, $title, $miner, $port, $readonly, $notify, $rigs;
-global $rignames, $rigbuttons;
+global $doctype, $title, $miner, $port, $readonly, $notify;
+global $rigport, $rigs, $rignames, $rigbuttons;
global $mcast, $mcastexpect, $mcastaddr, $mcastport, $mcastcode;
global $mcastlistport, $mcasttimeout, $mcastretries, $allowgen;
global $rigipsecurity, $rigtotals, $forcerigtotals;
@@ -45,8 +45,11 @@ $checklastshare = true;
# N.B. also if $readonly is true, it will not display the fields
$poolinputs = false;
#
+# Default port to use if any $rigs entries don't specify the port number
+$rigport = 4028;
+#
# Set $rigs to an array of your cgminer rigs that are running
-# format: 'IP:Port' or 'Host:Port' or 'Host:Port:Name'
+# format: 'IP' or 'Host' or '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'
@@ -510,9 +513,12 @@ function getrigs()
#
function getsock($rig, $addr, $port)
{
- global $rigips, $rignames, $rigipsecurity;
+ global $rigport, $rigips, $rignames, $rigipsecurity;
global $haderror, $error, $socksndtimeoutsec, $sockrcvtimeoutsec;
+ $port = trim($port);
+ if (strlen($port) == 0)
+ $port = $rigport;
$error = null;
$socket = null;
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
@@ -1679,10 +1685,13 @@ function doforeach($cmd, $des, $sum, $head, $datetime)
continue;
$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];
@@ -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);