miner.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800
  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. }
  296. if ($section == 'NOTIFY' && substr($name, 0, 1) == '*' && $value != '0')
  297. $class = $errorclass;
  298. return array($ret, $class);
  299. }
  300. #
  301. global $poolcmd;
  302. $poolcmd = array( 'Switch to' => 'switchpool',
  303. 'Enable' => 'enablepool',
  304. 'Disable' => 'disablepool' );
  305. #
  306. function showhead($cmd, $item, $values)
  307. {
  308. global $poolcmd, $readonly;
  309. echo '<tr>';
  310. foreach ($values as $name => $value)
  311. {
  312. if ($name == '0')
  313. $name = '&nbsp;';
  314. echo "<td valign=bottom class=h>$name</td>";
  315. }
  316. if ($cmd == 'pools' && $readonly === false)
  317. foreach ($poolcmd as $name => $pcmd)
  318. echo "<td valign=bottom class=h>$name</td>";
  319. echo '</tr>';
  320. }
  321. #
  322. function details($cmd, $list, $rig)
  323. {
  324. global $tablebegin, $tableend;
  325. global $poolcmd, $readonly;
  326. $dfmt = 'H:i:s j-M-Y \U\T\CP';
  327. $stas = array('S' => 'Success', 'W' => 'Warning', 'I' => 'Informational', 'E' => 'Error', 'F' => 'Fatal');
  328. echo $tablebegin;
  329. echo '<tr><td class=sta>Date: '.date($dfmt).'</td></tr>';
  330. echo $tableend.$tablebegin;
  331. if (isset($list['STATUS']))
  332. {
  333. echo '<tr>';
  334. echo '<td>Computer: '.$list['STATUS']['Description'].'</td>';
  335. if (isset($list['STATUS']['When']))
  336. echo '<td>When: '.date($dfmt, $list['STATUS']['When']).'</td>';
  337. $sta = $list['STATUS']['STATUS'];
  338. echo '<td>Status: '.$stas[$sta].'</td>';
  339. echo '<td>Message: '.$list['STATUS']['Msg'].'</td>';
  340. echo '</tr>';
  341. }
  342. $section = '';
  343. foreach ($list as $item => $values)
  344. {
  345. if ($item == 'STATUS')
  346. continue;
  347. $sectionname = preg_replace('/\d/', '', $item);
  348. if ($sectionname != $section)
  349. {
  350. echo $tableend.$tablebegin;
  351. showhead($cmd, $item, $values);
  352. $section = $sectionname;
  353. }
  354. echo '<tr>';
  355. foreach ($values as $name => $value)
  356. {
  357. list($showvalue, $class) = fmt($section, $name, $value);
  358. echo "<td$class>$showvalue</td>";
  359. }
  360. if ($cmd == 'pools' && $readonly === false)
  361. {
  362. reset($values);
  363. $pool = current($values);
  364. foreach ($poolcmd as $name => $pcmd)
  365. {
  366. echo '<td>';
  367. if ($pool === false)
  368. echo '&nbsp;';
  369. else
  370. {
  371. echo "<input type=button value='Pool $pool'";
  372. echo " onclick='prc(\"$pcmd|$pool&rig=$rig\",\"$name Pool $pool\")'>";
  373. }
  374. echo '</td>';
  375. }
  376. }
  377. echo '</tr>';
  378. }
  379. echo $tableend;
  380. }
  381. #
  382. global $devs;
  383. $devs = null;
  384. #
  385. function gpubuttons($count, $rig)
  386. {
  387. global $tablebegin, $tableend;
  388. global $devs;
  389. $basic = array( 'GPU', 'Enable', 'Disable', 'Restart' );
  390. $options = array( 'intensity' => 'Intensity',
  391. 'fan' => 'Fan Percent',
  392. 'engine' => 'GPU Clock',
  393. 'mem' => 'Memory Clock',
  394. 'vddc' => 'GPU Voltage' );
  395. echo $tablebegin.'<tr>';
  396. foreach ($basic as $head)
  397. echo "<td>$head</td>";
  398. foreach ($options as $name => $des)
  399. echo "<td nowrap>$des</td>";
  400. $n = 0;
  401. for ($c = 0; $c < $count; $c++)
  402. {
  403. echo '</tr><tr>';
  404. foreach ($basic as $name)
  405. {
  406. echo '<td>';
  407. if ($name == 'GPU')
  408. echo $c;
  409. else
  410. {
  411. echo "<input type=button value='$name $c' onclick='prs(\"gpu";
  412. echo strtolower($name);
  413. echo "|$c\",$rig)'>";
  414. }
  415. echo '</td>';
  416. }
  417. foreach ($options as $name => $des)
  418. {
  419. echo '<td>';
  420. if (!isset($devs["GPU$c"][$des]))
  421. echo '&nbsp;';
  422. else
  423. {
  424. $value = $devs["GPU$c"][$des];
  425. echo "<input type=button value='Set $c:' onclick='prs2(\"gpu$name|$c\",$n,$rig)'>";
  426. echo "<input size=7 type=text name=gi$n value='$value' id=gi$n>";
  427. $n++;
  428. }
  429. echo '</td>';
  430. }
  431. }
  432. echo '</tr>'.$tableend;
  433. }
  434. #
  435. function processgpus($rig)
  436. {
  437. global $error;
  438. global $warnfont, $warnoff;
  439. $gpus = api('gpucount');
  440. if ($error != null)
  441. echo '<tr><td>Error getting GPU count: '.$warnfont.$error.$warnoff.'</td></tr>';
  442. else
  443. {
  444. if (!isset($gpus['GPUS']['Count']))
  445. echo '<tr><td>No GPU count returned: '.$warnfont.$gpus['STATUS']['STATUS'].' '.$gpus['STATUS']['Msg'].$ro.'</td></tr>';
  446. else
  447. {
  448. $count = $gpus['GPUS']['Count'];
  449. if ($count == 0)
  450. echo '<tr><td>No GPUs</td></tr>';
  451. else
  452. gpubuttons($count, $rig);
  453. }
  454. }
  455. }
  456. #
  457. function process($cmds, $rig)
  458. {
  459. global $error, $devs;
  460. global $warnfont, $warnoff;
  461. foreach ($cmds as $cmd => $des)
  462. {
  463. $process = api($cmd);
  464. if ($error != null)
  465. {
  466. echo "<tr><td colspan=100>Error getting $des: ";
  467. echo $warnfont.$error.$warnoff.'</td></tr>';
  468. break;
  469. }
  470. else
  471. {
  472. details($cmd, $process, $rig);
  473. echo '<tr><td><br><br></td></tr>';
  474. if ($cmd == 'devs')
  475. $devs = $process;
  476. }
  477. }
  478. }
  479. #
  480. # $head is a hack but this is just a demo anyway :)
  481. function doforeach($cmd, $des, $sum, $head)
  482. {
  483. global $miner, $port;
  484. global $error, $readonly, $notify, $rigs;
  485. global $tablebegin, $tableend, $warnfont, $warnoff;
  486. $header = $head;
  487. $anss = array();
  488. $count = 0;
  489. foreach ($rigs as $rig)
  490. {
  491. $parts = explode(':', $rig, 2);
  492. if (count($parts) == 2)
  493. {
  494. $miner = $parts[0];
  495. $port = $parts[1];
  496. $ans = api($cmd);
  497. if ($error != null)
  498. {
  499. echo "<tr><td colspan=100>Error on rig $count getting $des: ";
  500. echo $warnfont.$error.$warnoff.'</td></tr>';
  501. $error = null;
  502. }
  503. else
  504. $anss[$count] = $ans;
  505. }
  506. $count++;
  507. }
  508. if (count($anss) == 0)
  509. {
  510. echo "<tr><td>Failed to access any rigs successfully</td></tr>";
  511. return;
  512. }
  513. $total = array();
  514. foreach ($anss as $rig => $ans)
  515. {
  516. foreach ($ans as $item => $row)
  517. {
  518. if ($item == 'STATUS')
  519. continue;
  520. if (count($row) > count($header))
  521. {
  522. $header = $head;
  523. foreach ($row as $name => $value)
  524. if (!isset($header[$name]))
  525. $header[$name] = '';
  526. }
  527. if ($sum != null)
  528. foreach ($sum as $name)
  529. {
  530. if (isset($row[$name]))
  531. {
  532. if (isset($total[$name]))
  533. $total[$name] += $row[$name];
  534. else
  535. $total[$name] = $row[$name];
  536. }
  537. }
  538. }
  539. }
  540. if ($sum != null)
  541. $anss['total']['total'] = $total;
  542. showhead('', null, $header);
  543. $section = '';
  544. foreach ($anss as $rig => $ans)
  545. {
  546. foreach ($ans as $item => $row)
  547. {
  548. if ($item == 'STATUS')
  549. continue;
  550. echo '<tr>';
  551. $newsection = preg_replace('/\d/', '', $item);
  552. if ($newsection != 'total')
  553. $section = $newsection;
  554. foreach ($header as $name => $x)
  555. {
  556. if ($name == '')
  557. {
  558. if ($rig === 'total')
  559. echo "<td align=right class=tot>Total:</td>";
  560. else
  561. echo "<td align=right><input type=button value='Rig $rig' onclick='pr(\"?rig=$rig\",null)'></td>";
  562. }
  563. else
  564. {
  565. if (isset($row[$name]))
  566. list($showvalue, $class) = fmt($section, $name, $row[$name]);
  567. else
  568. {
  569. $class = '';
  570. $showvalue = '&nbsp;';
  571. }
  572. if ($rig === 'total' and $class == '')
  573. $class = ' class=tot';
  574. echo "<td$class align=right>$showvalue</td>";
  575. }
  576. }
  577. echo '</tr>';
  578. }
  579. }
  580. }
  581. #
  582. function doOne($rig, $preprocess)
  583. {
  584. global $error, $readonly, $notify;
  585. global $rigs;
  586. htmlhead(true);
  587. $error = null;
  588. echo "<tr><td><table cellpadding=0 cellspacing=0 border=0><tr><td>";
  589. echo "<input type=button value='Refresh' onclick='pr(\"?rig=$rig\",null)'></td>";
  590. if (count($rigs) > 1)
  591. echo "<td><input type=button value='Summary' onclick='pr(\"\",null)'></td>";
  592. echo "<td width=100%>&nbsp;</td><td>";
  593. if ($readonly === false)
  594. {
  595. $msg = 'Quit CGMiner';
  596. if (count($rigs) > 1)
  597. $msg .= " Rig $rig";
  598. echo "<input type=button value='Quit' onclick='prc(\"quit&rig=$rig\",\"$msg\")'>";
  599. }
  600. echo "</td></tr></table></td></tr>";
  601. if ($preprocess != null)
  602. process(array($preprocess => $preprocess), $rig);
  603. $cmds = array( 'devs' => 'device list',
  604. 'summary' => 'summary information',
  605. 'pools' => 'pool list');
  606. if ($notify)
  607. $cmds['notify'] = 'device status';
  608. $cmds['config'] = 'cgminer config';
  609. process($cmds, $rig);
  610. if ($error == null && $readonly === false)
  611. processgpus($rig);
  612. }
  613. #
  614. function display()
  615. {
  616. global $tablebegin, $tableend;
  617. global $miner, $port;
  618. global $error, $readonly, $notify, $rigs;
  619. $rig = trim(getparam('rig', true));
  620. $arg = trim(getparam('arg', true));
  621. $preprocess = null;
  622. if ($arg != null and $arg != '')
  623. {
  624. $num = null;
  625. if ($rig != null and $rig != '')
  626. {
  627. if ($rig >= 0 and $rig < count($rigs))
  628. $num = $rig;
  629. }
  630. else
  631. if (count($rigs) == 0)
  632. $num = 0;
  633. if ($num != null)
  634. {
  635. $parts = explode(':', $rigs[$num], 2);
  636. if (count($parts) == 2)
  637. {
  638. $miner = $parts[0];
  639. $port = $parts[1];
  640. $preprocess = $arg;
  641. }
  642. }
  643. }
  644. if ($rigs == null or count($rigs) == 0)
  645. {
  646. echo "<tr><td>No rigs defined</td></tr>";
  647. return;
  648. }
  649. if (count($rigs) == 1)
  650. {
  651. $parts = explode(':', $rigs[0], 2);
  652. if (count($parts) == 2)
  653. {
  654. $miner = $parts[0];
  655. $port = $parts[1];
  656. doOne(0, $preprocess);
  657. }
  658. else
  659. echo '<tr><td>Invalid "$rigs" array</td></tr>';
  660. return;
  661. }
  662. if ($rig != null and $rig != '' and $rig >= 0 and $rig < count($rigs))
  663. {
  664. $parts = explode(':', $rigs[$rig], 2);
  665. if (count($parts) == 2)
  666. {
  667. $miner = $parts[0];
  668. $port = $parts[1];
  669. doOne($rig, $preprocess);
  670. }
  671. else
  672. echo '<tr><td>Invalid "$rigs" array</td></tr>';
  673. return;
  674. }
  675. htmlhead(false);
  676. echo "<tr><td><table cellpadding=0 cellspacing=0 border=0><tr><td>";
  677. echo "<input type=button value='Refresh' onclick='pr(\"\",null)'>";
  678. echo "</td></tr></table></td></tr>";
  679. if ($preprocess != null)
  680. process(array($preprocess => $preprocess), $rig);
  681. echo $tablebegin;
  682. $sum = array('MHS av', 'Getworks', 'Found Blocks', 'Accepted', 'Rejected', 'Discarded', 'Stale', 'Utility', 'Local Work', 'Total MH');
  683. doforeach('summary', 'summary information', $sum, array());
  684. echo $tableend;
  685. echo '<tr><td><br><br></td></tr>';
  686. echo $tablebegin;
  687. doforeach('devs', 'device list', $sum, array(''=>'','ID'=>'','Name'=>''));
  688. echo $tableend;
  689. echo '<tr><td><br><br></td></tr>';
  690. echo $tablebegin;
  691. doforeach('pools', 'pool list', $sum, array(''=>''));
  692. echo $tableend;
  693. }
  694. #
  695. display();
  696. #
  697. ?>
  698. </table></td></tr></table>
  699. </body></html>