miner.php 17 KB

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