miner.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804
  1. <?php
  2. session_start();
  3. #
  4. global $miner, $port, $readonly, $notify, $rigs;
  5. #
  6. # Don't touch these 2 - see $rigs below
  7. $miner = null;
  8. $port = null;
  9. #
  10. # Set $readonly to true to force miner.php to be readonly
  11. # Set $readonly to false then it will check cgminer 'privileged'
  12. $readonly = false;
  13. #
  14. # Set $notify to false to NOT attempt to display the notify command
  15. # Set $notify to true to attempt to display the notify command
  16. # If your older version of cgminer returns an 'Invalid command'
  17. # coz it doesn't have notify - it just shows the error status table
  18. $notify = true;
  19. #
  20. # Set $rigs to an array of your cgminer rigs that are running
  21. # format: 'IP:Port' or 'Host:Port'
  22. # If you only have one rig, it will just show the detail of that rig
  23. # If you have more than one rig it will show a summary of all the rigs
  24. # with buttons to show the details of each rig
  25. # e.g. $rigs = array('127.0.0.1:4028','myrig.com:4028');
  26. $rigs = array('127.0.0.1:4028');
  27. #
  28. $here = $_SERVER['PHP_SELF'];
  29. #
  30. global $tablebegin, $tableend, $warnfont, $warnoff;
  31. $tablebegin = '<tr><td><table border=1 cellpadding=5 cellspacing=0>';
  32. $tableend = '</table></td></tr>';
  33. $warnfont = '<font color=red><b>';
  34. $warnoff = '</b></font>';
  35. #
  36. function htmlhead($checkapi)
  37. {
  38. global $error, $readonly, $here;
  39. if ($readonly === false && $checkapi === true)
  40. {
  41. $access = api('privileged');
  42. if ($error != null
  43. || !isset($access['STATUS']['STATUS'])
  44. || $access['STATUS']['STATUS'] != 'S')
  45. $readonly = true;
  46. }
  47. ?>
  48. <html><head><title>Mine</title>
  49. <style type='text/css'>
  50. td { color:blue; font-family:verdana,arial,sans; font-size:13pt; }
  51. td.h { color:blue; font-family:verdana,arial,sans; font-size:13pt; background:#d0ffff }
  52. td.err { color:black; font-family:verdana,arial,sans; font-size:13pt; background:#ff3050 }
  53. td.warn { color:black; font-family:verdana,arial,sans; font-size:13pt; background:#ffb050 }
  54. td.sta { color:green; font-family:verdana,arial,sans; font-size:13pt; }
  55. td.tot { color:blue; font-family:verdana,arial,sans; font-size:13pt; background:#fff8f2 }
  56. </style>
  57. </head><body bgcolor=#ecffff>
  58. <script type='text/javascript'>
  59. function pr(a,m){if(m!=null){if(!confirm(m+'?'))return}window.location="<?php echo $here ?>"+a}
  60. <?php
  61. if ($readonly === false && $checkapi === true)
  62. {
  63. ?>
  64. function prc(a,m){pr('?arg='+a,m)}
  65. function prs(a,r){var c=a.substr(3);var z=c.split('|',2);var m=z[0].substr(0,1).toUpperCase()+z[0].substr(1)+' GPU '+z[1];prc(a+'&rig='+r,m)}
  66. function prs2(a,n,r){var v=document.getElementById('gi'+n).value;var c=a.substr(3);var z=c.split('|',2);var m='Set GPU '+z[1]+' '+z[0].substr(0,1).toUpperCase()+z[0].substr(1)+' to '+v;prc(a+','+v+'&rig='+r,m)}
  67. <?php
  68. }
  69. ?>
  70. </script>
  71. <table width=100% height=100% border=0 cellpadding=0 cellspacing=0 summary='Mine'>
  72. <tr><td align=center valign=top>
  73. <table border=0 cellpadding=4 cellspacing=0 summary='Mine'>
  74. <?php
  75. }
  76. #
  77. global $error;
  78. $error = null;
  79. #
  80. function getsock($addr, $port)
  81. {
  82. global $error;
  83. $socket = null;
  84. $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
  85. if ($socket === false || $socket === null)
  86. {
  87. $error = socket_strerror(socket_last_error());
  88. $msg = "socket create(TCP) failed";
  89. $error = "ERR: $msg '$error'\n";
  90. return null;
  91. }
  92. $res = socket_connect($socket, $addr, $port);
  93. if ($res === false)
  94. {
  95. $error = socket_strerror(socket_last_error());
  96. $msg = "socket connect($addr,$port) failed";
  97. $error = "ERR: $msg '$error'\n";
  98. socket_close($socket);
  99. return null;
  100. }
  101. return $socket;
  102. }
  103. #
  104. function readsockline($socket)
  105. {
  106. $line = '';
  107. while (true)
  108. {
  109. $byte = socket_read($socket, 1);
  110. if ($byte === false || $byte === '')
  111. break;
  112. if ($byte === "\0")
  113. break;
  114. $line .= $byte;
  115. }
  116. return $line;
  117. }
  118. #
  119. function api($cmd)
  120. {
  121. global $miner, $port;
  122. $socket = getsock($miner, $port);
  123. if ($socket != null)
  124. {
  125. socket_write($socket, $cmd, strlen($cmd));
  126. $line = readsockline($socket);
  127. socket_close($socket);
  128. if (strlen($line) == 0)
  129. {
  130. $error = "WARN: '$cmd' returned nothing\n";
  131. return $line;
  132. }
  133. # print "$cmd returned '$line'\n";
  134. $data = array();
  135. $objs = explode('|', $line);
  136. foreach ($objs as $obj)
  137. {
  138. if (strlen($obj) > 0)
  139. {
  140. $items = explode(',', $obj);
  141. $item = $items[0];
  142. $id = explode('=', $items[0], 2);
  143. if (count($id) == 1 or !ctype_digit($id[1]))
  144. $name = $id[0];
  145. else
  146. $name = $id[0].$id[1];
  147. if (strlen($name) == 0)
  148. $name = 'null';
  149. if (isset($data[$name]))
  150. {
  151. $num = 1;
  152. while (isset($data[$name.$num]))
  153. $num++;
  154. $name .= $num;
  155. }
  156. $counter = 0;
  157. foreach ($items as $item)
  158. {
  159. $id = explode('=', $item, 2);
  160. if (count($id) == 2)
  161. $data[$name][$id[0]] = $id[1];
  162. else
  163. $data[$name][$counter] = $id[0];
  164. $counter++;
  165. }
  166. }
  167. }
  168. return $data;
  169. }
  170. return null;
  171. }
  172. #
  173. function getparam($name, $both = false)
  174. {
  175. $a = null;
  176. if (isset($_POST[$name]))
  177. $a = $_POST[$name];
  178. if (($both === true) and ($a === null))
  179. {
  180. if (isset($_GET[$name]))
  181. $a = $_GET[$name];
  182. }
  183. if ($a == '' || $a == null)
  184. return null;
  185. // limit to 1K just to be safe
  186. return substr($a, 0, 1024);
  187. }
  188. #
  189. function fmt($section, $name, $value)
  190. {
  191. $errorclass = ' class=err';
  192. $warnclass = ' class=warn';
  193. $b = '&nbsp;';
  194. $ret = $value;
  195. $class = '';
  196. switch ($section.'.'.$name)
  197. {
  198. case 'GPU.Last Share Time':
  199. case 'PGA.Last Share Time':
  200. $ret = date('H:i:s', $value);
  201. break;
  202. case 'SUMMARY.Elapsed':
  203. $s = $value % 60;
  204. $value -= $s;
  205. $value /= 60;
  206. if ($value == 0)
  207. $ret = $s.'s';
  208. else
  209. {
  210. $m = $value % 60;
  211. $value -= $m;
  212. $value /= 60;
  213. if ($value == 0)
  214. $ret = sprintf("%dm$b%02ds", $m, $s);
  215. else
  216. {
  217. $h = $value % 24;
  218. $value -= $h;
  219. $value /= 24;
  220. if ($value == 0)
  221. $ret = sprintf("%dh$b%02dm$b%02ds", $h, $m, $s);
  222. else
  223. {
  224. if ($value == 1)
  225. $days = '';
  226. else
  227. $days = 's';
  228. $ret = sprintf("%dday$days$b%02dh$b%02dm$b%02ds", $value, $h, $m, $s);
  229. }
  230. }
  231. }
  232. break;
  233. case 'NOTIFY.Last Well':
  234. if ($value == '0')
  235. {
  236. $ret = 'Never';
  237. $class = $warnclass;
  238. }
  239. else
  240. $ret = date('H:i:s', $value);
  241. break;
  242. case 'NOTIFY.Last Not Well':
  243. if ($value == '0')
  244. $ret = 'Never';
  245. else
  246. {
  247. $ret = date('H:i:s', $value);
  248. $class = $errorclass;
  249. }
  250. break;
  251. case 'NOTIFY.Reason Not Well':
  252. if ($value != 'None')
  253. $class = $errorclass;
  254. break;
  255. case 'GPU.Utility':
  256. case 'PGA.Utility':
  257. case 'SUMMARY.Utility':
  258. $ret = $value.'/m';
  259. break;
  260. case 'GPU.Temperature':
  261. case 'PGA.Temperature':
  262. $ret = $value.'&deg;C';
  263. break;
  264. case 'GPU.MHS av':
  265. case 'PGA.MHS av':
  266. case 'SUMMARY.MHS av':
  267. case 'GPU.Total MH':
  268. case 'PGA.Total MH':
  269. case 'SUMMARY.Total MH':
  270. case 'SUMMARY.Getworks':
  271. case 'GPU.Accepted':
  272. case 'PGA.Accepted':
  273. case 'SUMMARY.Accepted':
  274. case 'GPU.Rejected':
  275. case 'PGA.Rejected':
  276. case 'SUMMARY.Rejected':
  277. case 'SUMMARY.Local Work':
  278. case 'POOL.Getworks':
  279. case 'POOL.Accepted':
  280. case 'POOL.Rejected':
  281. case 'POOL.Discarded':
  282. $parts = explode('.', $value, 2);
  283. if (count($parts) == 1)
  284. $dec = '';
  285. else
  286. $dec = '.'.$parts[1];
  287. $ret = number_format($parts[0]).$dec;
  288. break;
  289. case 'GPU.Status':
  290. case 'PGA.Status':
  291. case 'POOL.Status':
  292. if ($value != 'Alive')
  293. $class = $errorclass;
  294. break;
  295. case 'GPU.Enabled':
  296. case 'PGA.Enabled':
  297. if ($value != 'Y')
  298. $class = $warnclass;
  299. break;
  300. }
  301. if ($section == 'NOTIFY' && substr($name, 0, 1) == '*' && $value != '0')
  302. $class = $errorclass;
  303. return array($ret, $class);
  304. }
  305. #
  306. global $poolcmd;
  307. $poolcmd = array( 'Switch to' => 'switchpool',
  308. 'Enable' => 'enablepool',
  309. 'Disable' => 'disablepool' );
  310. #
  311. function showhead($cmd, $item, $values)
  312. {
  313. global $poolcmd, $readonly;
  314. echo '<tr>';
  315. foreach ($values as $name => $value)
  316. {
  317. if ($name == '0')
  318. $name = '&nbsp;';
  319. echo "<td valign=bottom class=h>$name</td>";
  320. }
  321. if ($cmd == 'pools' && $readonly === false)
  322. foreach ($poolcmd as $name => $pcmd)
  323. echo "<td valign=bottom class=h>$name</td>";
  324. echo '</tr>';
  325. }
  326. #
  327. function details($cmd, $list, $rig)
  328. {
  329. global $tablebegin, $tableend;
  330. global $poolcmd, $readonly;
  331. $dfmt = 'H:i:s j-M-Y \U\T\CP';
  332. $stas = array('S' => 'Success', 'W' => 'Warning', 'I' => 'Informational', 'E' => 'Error', 'F' => 'Fatal');
  333. echo $tablebegin;
  334. echo '<tr><td class=sta>Date: '.date($dfmt).'</td></tr>';
  335. echo $tableend.$tablebegin;
  336. if (isset($list['STATUS']))
  337. {
  338. echo '<tr>';
  339. echo '<td>Computer: '.$list['STATUS']['Description'].'</td>';
  340. if (isset($list['STATUS']['When']))
  341. echo '<td>When: '.date($dfmt, $list['STATUS']['When']).'</td>';
  342. $sta = $list['STATUS']['STATUS'];
  343. echo '<td>Status: '.$stas[$sta].'</td>';
  344. echo '<td>Message: '.$list['STATUS']['Msg'].'</td>';
  345. echo '</tr>';
  346. }
  347. $section = '';
  348. foreach ($list as $item => $values)
  349. {
  350. if ($item == 'STATUS')
  351. continue;
  352. $sectionname = preg_replace('/\d/', '', $item);
  353. if ($sectionname != $section)
  354. {
  355. echo $tableend.$tablebegin;
  356. showhead($cmd, $item, $values);
  357. $section = $sectionname;
  358. }
  359. echo '<tr>';
  360. foreach ($values as $name => $value)
  361. {
  362. list($showvalue, $class) = fmt($section, $name, $value);
  363. echo "<td$class>$showvalue</td>";
  364. }
  365. if ($cmd == 'pools' && $readonly === false)
  366. {
  367. reset($values);
  368. $pool = current($values);
  369. foreach ($poolcmd as $name => $pcmd)
  370. {
  371. echo '<td>';
  372. if ($pool === false)
  373. echo '&nbsp;';
  374. else
  375. {
  376. echo "<input type=button value='Pool $pool'";
  377. echo " onclick='prc(\"$pcmd|$pool&rig=$rig\",\"$name Pool $pool\")'>";
  378. }
  379. echo '</td>';
  380. }
  381. }
  382. echo '</tr>';
  383. }
  384. echo $tableend;
  385. }
  386. #
  387. global $devs;
  388. $devs = null;
  389. #
  390. function gpubuttons($count, $rig)
  391. {
  392. global $tablebegin, $tableend;
  393. global $devs;
  394. $basic = array( 'GPU', 'Enable', 'Disable', 'Restart' );
  395. $options = array( 'intensity' => 'Intensity',
  396. 'fan' => 'Fan Percent',
  397. 'engine' => 'GPU Clock',
  398. 'mem' => 'Memory Clock',
  399. 'vddc' => 'GPU Voltage' );
  400. echo $tablebegin.'<tr>';
  401. foreach ($basic as $head)
  402. echo "<td>$head</td>";
  403. foreach ($options as $name => $des)
  404. echo "<td nowrap>$des</td>";
  405. $n = 0;
  406. for ($c = 0; $c < $count; $c++)
  407. {
  408. echo '</tr><tr>';
  409. foreach ($basic as $name)
  410. {
  411. echo '<td>';
  412. if ($name == 'GPU')
  413. echo $c;
  414. else
  415. {
  416. echo "<input type=button value='$name $c' onclick='prs(\"gpu";
  417. echo strtolower($name);
  418. echo "|$c\",$rig)'>";
  419. }
  420. echo '</td>';
  421. }
  422. foreach ($options as $name => $des)
  423. {
  424. echo '<td>';
  425. if (!isset($devs["GPU$c"][$des]))
  426. echo '&nbsp;';
  427. else
  428. {
  429. $value = $devs["GPU$c"][$des];
  430. echo "<input type=button value='Set $c:' onclick='prs2(\"gpu$name|$c\",$n,$rig)'>";
  431. echo "<input size=7 type=text name=gi$n value='$value' id=gi$n>";
  432. $n++;
  433. }
  434. echo '</td>';
  435. }
  436. }
  437. echo '</tr>'.$tableend;
  438. }
  439. #
  440. function processgpus($rig)
  441. {
  442. global $error;
  443. global $warnfont, $warnoff;
  444. $gpus = api('gpucount');
  445. if ($error != null)
  446. echo '<tr><td>Error getting GPU count: '.$warnfont.$error.$warnoff.'</td></tr>';
  447. else
  448. {
  449. if (!isset($gpus['GPUS']['Count']))
  450. echo '<tr><td>No GPU count returned: '.$warnfont.$gpus['STATUS']['STATUS'].' '.$gpus['STATUS']['Msg'].$ro.'</td></tr>';
  451. else
  452. {
  453. $count = $gpus['GPUS']['Count'];
  454. if ($count == 0)
  455. echo '<tr><td>No GPUs</td></tr>';
  456. else
  457. gpubuttons($count, $rig);
  458. }
  459. }
  460. }
  461. #
  462. function process($cmds, $rig)
  463. {
  464. global $error, $devs;
  465. global $warnfont, $warnoff;
  466. foreach ($cmds as $cmd => $des)
  467. {
  468. $process = api($cmd);
  469. if ($error != null)
  470. {
  471. echo "<tr><td colspan=100>Error getting $des: ";
  472. echo $warnfont.$error.$warnoff.'</td></tr>';
  473. break;
  474. }
  475. else
  476. {
  477. details($cmd, $process, $rig);
  478. echo '<tr><td><br><br></td></tr>';
  479. if ($cmd == 'devs')
  480. $devs = $process;
  481. }
  482. }
  483. }
  484. #
  485. # $head is a hack but this is just a demo anyway :)
  486. function doforeach($cmd, $des, $sum, $head)
  487. {
  488. global $miner, $port;
  489. global $error, $readonly, $notify, $rigs;
  490. global $tablebegin, $tableend, $warnfont, $warnoff;
  491. $header = $head;
  492. $anss = array();
  493. $count = 0;
  494. foreach ($rigs as $rig)
  495. {
  496. $parts = explode(':', $rig, 2);
  497. if (count($parts) == 2)
  498. {
  499. $miner = $parts[0];
  500. $port = $parts[1];
  501. $ans = api($cmd);
  502. if ($error != null)
  503. {
  504. echo "<tr><td colspan=100>Error on rig $count getting $des: ";
  505. echo $warnfont.$error.$warnoff.'</td></tr>';
  506. $error = null;
  507. }
  508. else
  509. $anss[$count] = $ans;
  510. }
  511. $count++;
  512. }
  513. if (count($anss) == 0)
  514. {
  515. echo "<tr><td>Failed to access any rigs successfully</td></tr>";
  516. return;
  517. }
  518. $total = array();
  519. foreach ($anss as $rig => $ans)
  520. {
  521. foreach ($ans as $item => $row)
  522. {
  523. if ($item == 'STATUS')
  524. continue;
  525. if (count($row) > count($header))
  526. {
  527. $header = $head;
  528. foreach ($row as $name => $value)
  529. if (!isset($header[$name]))
  530. $header[$name] = '';
  531. }
  532. if ($sum != null)
  533. foreach ($sum as $name)
  534. {
  535. if (isset($row[$name]))
  536. {
  537. if (isset($total[$name]))
  538. $total[$name] += $row[$name];
  539. else
  540. $total[$name] = $row[$name];
  541. }
  542. }
  543. }
  544. }
  545. if ($sum != null)
  546. $anss['total']['total'] = $total;
  547. showhead('', null, $header);
  548. $section = '';
  549. foreach ($anss as $rig => $ans)
  550. {
  551. foreach ($ans as $item => $row)
  552. {
  553. if ($item == 'STATUS')
  554. continue;
  555. echo '<tr>';
  556. $newsection = preg_replace('/\d/', '', $item);
  557. if ($newsection != 'total')
  558. $section = $newsection;
  559. foreach ($header as $name => $x)
  560. {
  561. if ($name == '')
  562. {
  563. if ($rig === 'total')
  564. echo "<td align=right class=tot>Total:</td>";
  565. else
  566. echo "<td align=right><input type=button value='Rig $rig' onclick='pr(\"?rig=$rig\",null)'></td>";
  567. }
  568. else
  569. {
  570. if (isset($row[$name]))
  571. list($showvalue, $class) = fmt($section, $name, $row[$name]);
  572. else
  573. {
  574. $class = '';
  575. $showvalue = '&nbsp;';
  576. }
  577. if ($rig === 'total' and $class == '')
  578. $class = ' class=tot';
  579. echo "<td$class align=right>$showvalue</td>";
  580. }
  581. }
  582. echo '</tr>';
  583. }
  584. }
  585. }
  586. #
  587. function doOne($rig, $preprocess)
  588. {
  589. global $error, $readonly, $notify;
  590. global $rigs;
  591. htmlhead(true);
  592. $error = null;
  593. echo "<tr><td><table cellpadding=0 cellspacing=0 border=0><tr><td>";
  594. echo "<input type=button value='Refresh' onclick='pr(\"?rig=$rig\",null)'></td>";
  595. if (count($rigs) > 1)
  596. echo "<td><input type=button value='Summary' onclick='pr(\"\",null)'></td>";
  597. echo "<td width=100%>&nbsp;</td><td>";
  598. if ($readonly === false)
  599. {
  600. $msg = 'Quit CGMiner';
  601. if (count($rigs) > 1)
  602. $msg .= " Rig $rig";
  603. echo "<input type=button value='Quit' onclick='prc(\"quit&rig=$rig\",\"$msg\")'>";
  604. }
  605. echo "</td></tr></table></td></tr>";
  606. if ($preprocess != null)
  607. process(array($preprocess => $preprocess), $rig);
  608. $cmds = array( 'devs' => 'device list',
  609. 'summary' => 'summary information',
  610. 'pools' => 'pool list');
  611. if ($notify)
  612. $cmds['notify'] = 'device status';
  613. $cmds['config'] = 'cgminer config';
  614. process($cmds, $rig);
  615. if ($error == null && $readonly === false)
  616. processgpus($rig);
  617. }
  618. #
  619. function display()
  620. {
  621. global $tablebegin, $tableend;
  622. global $miner, $port;
  623. global $error, $readonly, $notify, $rigs;
  624. $rig = trim(getparam('rig', true));
  625. $arg = trim(getparam('arg', true));
  626. $preprocess = null;
  627. if ($arg != null and $arg != '')
  628. {
  629. $num = null;
  630. if ($rig != null and $rig != '')
  631. {
  632. if ($rig >= 0 and $rig < count($rigs))
  633. $num = $rig;
  634. }
  635. else
  636. if (count($rigs) == 0)
  637. $num = 0;
  638. if ($num != null)
  639. {
  640. $parts = explode(':', $rigs[$num], 2);
  641. if (count($parts) == 2)
  642. {
  643. $miner = $parts[0];
  644. $port = $parts[1];
  645. $preprocess = $arg;
  646. }
  647. }
  648. }
  649. if ($rigs == null or count($rigs) == 0)
  650. {
  651. echo "<tr><td>No rigs defined</td></tr>";
  652. return;
  653. }
  654. if (count($rigs) == 1)
  655. {
  656. $parts = explode(':', $rigs[0], 2);
  657. if (count($parts) == 2)
  658. {
  659. $miner = $parts[0];
  660. $port = $parts[1];
  661. doOne(0, $preprocess);
  662. }
  663. else
  664. echo '<tr><td>Invalid "$rigs" array</td></tr>';
  665. return;
  666. }
  667. if ($rig != null and $rig != '' and $rig >= 0 and $rig < count($rigs))
  668. {
  669. $parts = explode(':', $rigs[$rig], 2);
  670. if (count($parts) == 2)
  671. {
  672. $miner = $parts[0];
  673. $port = $parts[1];
  674. doOne($rig, $preprocess);
  675. }
  676. else
  677. echo '<tr><td>Invalid "$rigs" array</td></tr>';
  678. return;
  679. }
  680. htmlhead(false);
  681. echo "<tr><td><table cellpadding=0 cellspacing=0 border=0><tr><td>";
  682. echo "<input type=button value='Refresh' onclick='pr(\"\",null)'>";
  683. echo "</td></tr></table></td></tr>";
  684. if ($preprocess != null)
  685. process(array($preprocess => $preprocess), $rig);
  686. echo $tablebegin;
  687. $sum = array('MHS av', 'Getworks', 'Found Blocks', 'Accepted', 'Rejected', 'Discarded', 'Stale', 'Utility', 'Local Work', 'Total MH');
  688. doforeach('summary', 'summary information', $sum, array());
  689. echo $tableend;
  690. echo '<tr><td><br><br></td></tr>';
  691. echo $tablebegin;
  692. doforeach('devs', 'device list', $sum, array(''=>'','ID'=>'','Name'=>''));
  693. echo $tableend;
  694. echo '<tr><td><br><br></td></tr>';
  695. echo $tablebegin;
  696. doforeach('pools', 'pool list', $sum, array(''=>''));
  697. echo $tableend;
  698. }
  699. #
  700. display();
  701. #
  702. ?>
  703. </table></td></tr></table>
  704. </body></html>