diff --git a/API-README b/API-README
index a71b694f..14f8b53c 100644
--- a/API-README
+++ b/API-README
@@ -937,6 +937,38 @@ true
---------
+Default:
+ $userlist = null;
+
+Define password checking and default access
+ null means there is no password checking
+
+$userlist is an array of 3 arrays e.g.
+$userlist = array('sys' => array('boss' => 'bpass'),
+ 'usr' => array('user' => 'upass', 'pleb' => 'ppass'),
+ 'def' => array('Pools'));
+
+'sys' is an array of system users and passwords (full access)
+'usr' is an array of user level users and passwords (readonly access)
+'def' is an array of custompages that anyone not logged in can view
+
+Any of the 3 can be null, meaning there are none of that item
+
+All validated 'usr' users are given $readonly = true; access
+All validated 'sys' users are given the $readonly access you defined
+
+If 'def' has one or more values, and allowcustompages is true, then
+anyone without a password can see the list of custompage buttons given
+in 'def' and will see the first one when they go to the web page, with
+a login button at the top right
+
+From the login page, if you login with no username or password, it will
+show the first 'def' custompage (if there are any)
+
+If you are logged in, it will show a logout button at the top right
+
+---------
+
Default:
$notify = true;
diff --git a/miner.php b/miner.php
index 8c393ac8..b0e80030 100644
--- a/miner.php
+++ b/miner.php
@@ -8,7 +8,7 @@ global $checklastshare, $poolinputs, $hidefields;
global $ignorerefresh, $changerefresh, $autorefresh;
global $allowcustompages, $customsummarypages;
global $miner_font_family, $miner_font_size;
-global $colouroverride, $placebuttons;
+global $colouroverride, $placebuttons, $userlist;
#
# See API-README for more details of these variables and how
# to configure miner.php
@@ -20,6 +20,9 @@ $title = 'Mine';
# Set $readonly to false then it will check cgminer 'privileged'
$readonly = false;
#
+# Set $userlist to null to allow anyone access or read API-README
+$userlist = null;
+#
# Set $notify to false to NOT attempt to display the notify command
# Set $notify to true to attempt to display the notify command
$notify = true;
@@ -212,6 +215,10 @@ $rigerror = array();
global $rownum;
$rownum = 0;
#
+// Login
+global $ses;
+$ses = 'rutroh';
+#
function getcss($cssname, $dom = false)
{
global $colourtable, $colouroverride;
@@ -239,7 +246,7 @@ function getdom($domname)
return getcss($domname, true);
}
#
-function htmlhead($checkapi, $rig, $pg = null)
+function htmlhead($checkapi, $rig, $pg = null, $noscript = false)
{
global $title, $miner_font_family, $miner_font_size;
global $error, $readonly, $poolinputs, $here;
@@ -285,8 +292,10 @@ td.lst { $miner_font ".getcss('td.lst')."}
td.hi { $miner_font ".getcss('td.hi')."}
td.lo { $miner_font ".getcss('td.lo')."}
-
-\n";
+}
?>
-
@@ -1507,7 +1517,6 @@ function doforeach($cmd, $des, $sum, $head, $datetime)
#
function refreshbuttons()
{
- global $readonly;
global $ignorerefresh, $changerefresh, $autorefresh;
if ($ignorerefresh == false && $changerefresh == true)
@@ -1521,7 +1530,7 @@ function refreshbuttons()
#
function pagebuttons($rig, $pg)
{
- global $readonly, $rigs;
+ global $readonly, $rigs, $userlist, $ses;
global $allowcustompages, $customsummarypages;
if ($rig === null)
@@ -1557,18 +1566,33 @@ function pagebuttons($rig, $pg)
}
echo ' | ";
}
#
@@ -2410,13 +2440,126 @@ function showcustompage($pagename)
pagebuttons(null, $pagename);
}
#
+function onlylogin()
+{
+ global $here;
+
+ htmlhead(false, null, null, true);
+
+?>
+ |
+
+
+
+ |
+No rigs defined");
+ return;
+ }
if ($ignorerefresh == false)
{
@@ -2425,52 +2568,65 @@ function display()
$autorefresh = intval($ref);
}
- $rig = trim(getparam('rig', true));
-
- $arg = trim(getparam('arg', true));
- $preprocess = null;
- if ($arg != null and $arg != '')
+ if ($pagesonly !== true)
{
- $num = null;
- if ($rig != null and $rig != '')
- {
- if ($rig >= 0 and $rig < count($rigs))
- $num = $rig;
- }
- else
- if (count($rigs) == 0)
- $num = 0;
+ $rig = trim(getparam('rig', true));
- if ($num != null)
+ $arg = trim(getparam('arg', true));
+ $preprocess = null;
+ if ($arg != null and $arg != '')
{
- $parts = explode(':', $rigs[$num], 3);
- if (count($parts) >= 2)
+ if ($rig != null and $rig != '' and $rig >= 0 and $rig < count($rigs))
{
- $miner = $parts[0];
- $port = $parts[1];
+ $parts = explode(':', $rigs[$rig], 3);
+ if (count($parts) >= 2)
+ {
+ $miner = $parts[0];
+ $port = $parts[1];
- if ($readonly !== true)
- $preprocess = $arg;
+ if ($readonly !== true)
+ $preprocess = $arg;
+ }
}
}
}
- if ($rigs == null or count($rigs) == 0)
- {
- otherrow("No rigs defined | ");
- return;
- }
-
if ($allowcustompages === true)
{
$pg = trim(getparam('pg', true));
- if ($pg != null && $pg != '')
+ if ($pagesonly === true)
+ {
+ if ($pg !== null && $pg !== '')
+ {
+ if ($userlist !== null && isset($userlist['def'])
+ && !in_array($pg, $userlist['def']))
+ $pg = null;
+ }
+ else
+ {
+ if ($userlist !== null && isset($userlist['def']))
+ foreach ($userlist['def'] as $pglook)
+ if (isset($customsummarypages[$pglook]))
+ {
+ $pg = $pglook;
+ break;
+ }
+ }
+ }
+
+ if ($pg !== null && $pg !== '')
{
showcustompage($pg);
return;
}
}
+ if ($pagesonly === true)
+ {
+ onlylogin();
+ return;
+ }
+
if (count($rigs) == 1)
{
$parts = explode(':', $rigs[0], 3);
|