miner.php allow summary header in custom pages
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 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
diff --git a/miner.php b/miner.php
index 5e8f80e..e0fc398 100644
--- a/miner.php
+++ b/miner.php
@@ -72,9 +72,13 @@ $allowcustompages = true;
# - empty tables are not shown
# - empty columns (an unknown field) are not shown
# - and missing field data shows as blank
+# - section = 'DATE' displays a date table like 'Summary'
+# - section = 'RIGS' displays a rig table like 'Summary'
# There is a second array, listing fields to be totaled for each section
# see the example below (if there is no matching data, no total will show)
$mobilepage = array(
+ 'DATE' => null,
+ 'RIGS' => null,
'SUMMARY' => array('Elapsed', 'MHS av', 'Found Blocks', 'Accepted', 'Rejected', 'Utility'),
'DEVS' => array('ID', 'Name', 'GPU', 'Status', 'MHS av', 'Accepted', 'Rejected', 'Utility'),
'POOL' => array('POOL', 'Status', 'Accepted', 'Rejected', 'Last Share Time'));
@@ -888,6 +892,50 @@ function process($cmds, $rig)
}
}
#
+function showdatetime()
+{
+ global $dfmt;
+
+ echo '<tr><td class=sta>Date: '.date($dfmt).'</td></tr>';
+}
+#
+function showrigs($anss, $headname, $rigname)
+{
+ $dthead = array($headname => 1, 'STATUS' => 1, 'Description' => 1, 'When' => 1, 'API' => 1, 'CGMiner' => 1);
+ showhead('', $dthead);
+
+ foreach ($anss as $rig => $ans)
+ {
+ echo '<tr>';
+
+ $when = 0;
+ if (isset($ans['STATUS']['When']))
+ $when = $ans['STATUS']['When'];
+
+ foreach ($ans as $item => $row)
+ {
+ if ($item != 'STATUS' && $item != 'VERSION')
+ continue;
+
+ foreach ($dthead as $name => $x)
+ {
+ if ($item == 'STATUS' && $name == $headname)
+ echo "<td align=right><input type=button value='$rigname$rig' onclick='pr(\"&rig=$rig\",null)'></td>";
+ else
+ {
+ if (isset($row[$name]))
+ {
+ list($showvalue, $class) = fmt('STATUS', $name, $row[$name], $when, null);
+ echo "<td$class align=right>$showvalue</td>";
+ }
+ }
+ }
+ }
+
+ echo '</tr>';
+ }
+}
+#
# $head is a hack but this is just a demo anyway :)
function doforeach($cmd, $des, $sum, $head, $datetime)
{
@@ -940,39 +988,10 @@ function doforeach($cmd, $des, $sum, $head, $datetime)
if ($datetime)
{
- echo '<tr><td class=sta>Date: '.date($dfmt).'</td></tr>';
-
+ showdatetime();
echo $tableend.$tablebegin;
- $dthead = array('' => 1, 'STATUS' => 1, 'Description' => 1, 'When' => 1, 'API' => 1, 'CGMiner' => 1);
- showhead('', $dthead);
-
- foreach ($anss as $rig => $ans)
- {
- echo '<tr>';
-
- foreach ($ans as $item => $row)
- {
- if ($item != 'STATUS' && $item != 'VERSION')
- continue;
-
- foreach ($dthead as $name => $x)
- {
- if ($item == 'STATUS' && $name == '')
- echo "<td align=right><input type=button value='Rig $rig' onclick='pr(\"&rig=$rig\",null)'></td>";
- else
- {
- if (isset($row[$name]))
- {
- list($showvalue, $class) = fmt('STATUS', $name, $row[$name], $when, null);
- echo "<td$class align=right>$showvalue</td>";
- }
- }
- }
- }
-
- echo '</tr>';
- }
+ showrigs($anss, '', 'Rig ');
echo $tableend;
echo '<tr><td><br><br></td></tr>';
echo $tablebegin;
@@ -1147,7 +1166,9 @@ global $sectionmap;
# map sections to their api command
# DEVS is a special case that will match GPU or PGA
# so you can have a single table with both in it
+# DATE is hard coded so not in here
$sectionmap = array(
+ 'RIGS' => 'version',
'SUMMARY' => 'summary',
'POOL' => 'pools',
'DEVS' => 'devs',
@@ -1274,11 +1295,37 @@ function processcustompage($pagename, $sections, $sum)
}
}
+ $shownsomething = false;
if (count($results) > 0)
{
$first = true;
foreach ($sections as $section => $fields)
{
+ if ($section === 'DATE')
+ {
+ if ($shownsomething)
+ echo '<tr><td> </td></tr>';
+
+ echo $tablebegin;
+ showdatetime();
+ echo $tableend;
+ // On top of the next table
+ $shownsomething = false;
+ continue;
+ }
+
+ if ($section === 'RIGS')
+ {
+ if ($shownsomething)
+ echo '<tr><td> </td></tr>';
+
+ echo $tablebegin;
+ showrigs($results['version'], 'Rig', '');
+ echo $tableend;
+ $shownsomething = true;
+ continue;
+ }
+
if (isset($results[$sectionmap[$section]]))
{
$rigresults = $results[$sectionmap[$section]];
@@ -1294,7 +1341,7 @@ function processcustompage($pagename, $sections, $sum)
if (count($showfields) > 0)
{
- if ($first === false)
+ if ($shownsomething)
echo '<tr><td> </td></tr>';
echo $tablebegin;
@@ -1316,6 +1363,7 @@ function processcustompage($pagename, $sections, $sum)
$first = false;
echo $tableend;
+ $shownsomething = true;
}
}
}
@@ -1354,6 +1402,11 @@ function showcustompage($pagename)
}
$page = $customsummarypages[$pagename][0];
+
+ foreach ($page as $name => $fields)
+ if ($fields === null)
+ $page[$name] = array();
+
$sum = $customsummarypages[$pagename][1];
if ($sum === null)
$sum = array();