miner.php 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475
  1. <?php
  2. session_start();
  3. #
  4. global $miner, $port, $readonly, $notify, $rigs, $socktimeoutsec;
  5. global $checklastshare, $hidefields;
  6. global $ignorerefresh, $changerefresh, $autorefresh;
  7. global $allowcustompages, $customsummarypages;
  8. global $miner_font_family, $miner_font_size;
  9. global $colouroverride, $placebuttons;
  10. #
  11. # Don't touch these 2 - see $rigs below
  12. $miner = null;
  13. $port = null;
  14. #
  15. # Set $readonly to true to force miner.php to be readonly
  16. # Set $readonly to false then it will check cgminer 'privileged'
  17. $readonly = false;
  18. #
  19. # Set $notify to false to NOT attempt to display the notify command
  20. # Set $notify to true to attempt to display the notify command
  21. # If your older version of cgminer returns an 'Invalid command'
  22. # coz it doesn't have notify - it just shows the error status table
  23. $notify = true;
  24. #
  25. # set $checklastshare to true to do the following checks:
  26. # If a device's last share is 12x expected ago then display as an error
  27. # If a device's last share is 8x expected ago then display as a warning
  28. # If either of the above is true, also display the whole line highlighted
  29. # This assumes shares are 1 difficulty shares
  30. $checklastshare = true;
  31. #
  32. # Set $rigs to an array of your cgminer rigs that are running
  33. # format: 'IP:Port' or 'Host:Port'
  34. # If you only have one rig, it will just show the detail of that rig
  35. # If you have more than one rig it will show a summary of all the rigs
  36. # with buttons to show the details of each rig
  37. # e.g. $rigs = array('127.0.0.1:4028','myrig.com:4028');
  38. $rigs = array('127.0.0.1:4028');
  39. #
  40. # This should be OK for most cases
  41. # However, the longer it is the longer you have to wait while php
  42. # hangs if the target cgminer isn't runnning or listening
  43. # Feel free to increase it if your network is very slow
  44. # Also, on some windows PHP, apparently the $usec is ignored
  45. $socktimeoutsec = 10;
  46. #
  47. # List of fields NOT to be displayed
  48. # You can use this to hide data you don't want to see or don't want
  49. # shown on a public web page
  50. # The list of sections are: SUMMARY, POOL, PGA, GPU, NOTIFY, CONFIG
  51. # See the web page for the list of field names (the table headers)
  52. # It is an array of 'SECTION.Field Name' => 1
  53. # This example would hide the slightly more sensitive pool information
  54. #$hidefields = array('POOL.URL' => 1, 'POOL.User' => 1);
  55. $hidefields = array();
  56. #
  57. # Auto-refresh of the page (in seconds)
  58. # $ignorerefresh = true/false always ignore refresh parameters
  59. # $changerefresh = true/false show buttons to change the value
  60. # $autorefresh = default value, 0 means dont auto-refresh
  61. $ignorerefresh = false;
  62. $changerefresh = true;
  63. $autorefresh = 0;
  64. #
  65. # Should we allow custom pages?
  66. # (or just completely ignore then and don't display the buttons)
  67. $allowcustompages = true;
  68. #
  69. # OK this is a bit more complex item: Custom Summary Pages
  70. # A custom summary page in an array of 'section' => array('FieldA','FieldB'...)
  71. # This makes up what is displayed with each 'section' separately as a table
  72. # - empty tables are not shown
  73. # - empty columns (an unknown field) are not shown
  74. # - and missing field data shows as blank
  75. # There is a second array, listing fields to be totaled for each section
  76. # see the example below (if there is no matching data, no total will show)
  77. $mobilepage = array(
  78. 'SUMMARY' => array('Elapsed', 'MHS av', 'Found Blocks', 'Accepted', 'Rejected', 'Utility'),
  79. 'GPU' => array('GPU', 'Status', 'MHS av', 'Accepted', 'Rejected', 'Utility'),
  80. 'PGA' => array('ID', 'Name', 'Status', 'MHS av', 'Accepted', 'Rejected', 'Utility'),
  81. 'POOL' => array('POOL', 'Status', 'Accepted', 'Rejected', 'Last Share Time'));
  82. $mobilesum = array(
  83. 'SUMMARY' => array('MHS av' => 1, 'Found Blocks' => 1, 'Accepted' => 1, 'Rejected' => 1, 'Utility' => 1),
  84. 'GPU' => array('MHS av' => 1, 'Accepted' => 1, 'Rejected' => 1, 'Utility' => 1),
  85. 'PGA' => array('MHS av' => 1, 'Accepted' => 1, 'Rejected' => 1, 'Utility' => 1),
  86. 'POOL' => array('Accepted' => 1, 'Rejected' => 1));
  87. #
  88. # customsummarypages is an array of these Custom Summary Pages
  89. $customsummarypages = array('Mobile' => array($mobilepage, $mobilesum));
  90. #
  91. $here = $_SERVER['PHP_SELF'];
  92. #
  93. global $tablebegin, $tableend, $warnfont, $warnoff, $dfmt;
  94. #
  95. $tablebegin = '<tr><td><table border=1 cellpadding=5 cellspacing=0>';
  96. $tableend = '</table></td></tr>';
  97. $warnfont = '<font color=red><b>';
  98. $warnoff = '</b></font>';
  99. $dfmt = 'H:i:s j-M-Y \U\T\CP';
  100. #
  101. $miner_font_family = 'verdana,arial,sans';
  102. $miner_font_size = '13pt';
  103. #
  104. # Edit this or redefine it in myminer.php to change the colour scheme
  105. # See $colourtable below for the list of names
  106. $colouroverride = array();
  107. #
  108. # Where to place the buttons: 'top' 'bot' 'both'
  109. # anything else means don't show them - case sensitive
  110. $placebuttons = 'top';
  111. #
  112. # This below allows you to put your own settings into a seperate file
  113. # so you don't need to update miner.php with your preferred settings
  114. # every time a new version is released
  115. # Just create the file 'myminer.php' in the same directory as
  116. # 'miner.php' - and put your own settings in there
  117. if (file_exists('myminer.php'))
  118. include_once('myminer.php');
  119. #
  120. # This is the system default that must always contain all necessary
  121. # colours so it must be a constant
  122. # You can override these values with $colouroverride
  123. # The only one missing is in $warnfont
  124. # - which you can override directly anyway
  125. global $colourtable;
  126. $colourtable = array(
  127. 'body bgcolor' => '#ecffff',
  128. 'td color' => 'blue',
  129. 'td.h color' => 'blue',
  130. 'td.h background' => '#c4ffff',
  131. 'td.err color' => 'black',
  132. 'td.err background' => '#ff3050',
  133. 'td.warn color' => 'black',
  134. 'td.warn background' => '#ffb050',
  135. 'td.sta color' => 'green',
  136. 'td.tot color' => 'blue',
  137. 'td.tot background' => '#fff8f2',
  138. 'td.lst color' => 'blue',
  139. 'td.lst background' => '#ffffdd',
  140. 'td.hi color' => 'blue',
  141. 'td.hi background' => '#f6ffff',
  142. 'td.lo color' => 'blue',
  143. 'td.lo background' => '#deffff'
  144. );
  145. #
  146. # Ensure it is only ever shown once
  147. global $showndate;
  148. $showndate = false;
  149. #
  150. # For summary page to stop retrying failed rigs
  151. global $rigerror;
  152. $rigerror = array();
  153. #
  154. function getcss($cssname, $dom = false)
  155. {
  156. global $colourtable, $colouroverride;
  157. $css = '';
  158. foreach ($colourtable as $cssdata => $colour)
  159. {
  160. $cssobj = split(' ', $cssdata, 2);
  161. if ($cssobj[0] == $cssname)
  162. {
  163. if (isset($colouroverride[$cssdata]))
  164. $color = $colouroverride[$cssdata];
  165. if ($dom == true)
  166. $css .= ' '.$cssobj[1].'='.$colour;
  167. else
  168. $css .= $cssobj[1].':'.$colour.'; ';
  169. }
  170. }
  171. return $css;
  172. }
  173. #
  174. function htmlhead($checkapi, $rig, $pg = null)
  175. {
  176. global $miner_font_family, $miner_font_size;
  177. global $error, $readonly, $here;
  178. global $ignorerefresh, $autorefresh;
  179. $extraparams = '';
  180. if ($rig != null && $rig != '')
  181. $extraparams = "&rig=$rig";
  182. else
  183. if ($pg != null && $pg != '')
  184. $extraparams = "&pg=$pg";
  185. if ($ignorerefresh == true || $autorefresh == 0)
  186. $refreshmeta = '';
  187. else
  188. {
  189. $url = "$here?ref=$autorefresh$extraparams";
  190. $refreshmeta = "\n<meta http-equiv='refresh' content='$autorefresh;url=$url'>";
  191. }
  192. if ($readonly === false && $checkapi === true)
  193. {
  194. $error = null;
  195. $access = api('privileged');
  196. if ($error != null
  197. || !isset($access['STATUS']['STATUS'])
  198. || $access['STATUS']['STATUS'] != 'S')
  199. $readonly = true;
  200. }
  201. $miner_font = "font-family:$miner_font_family; font-size:$miner_font_size;";
  202. echo "<html><head>$refreshmeta
  203. <title>Mine</title>
  204. <style type='text/css'>
  205. td { $miner_font ".getcss('td')."}
  206. td.h { $miner_font ".getcss('td.h')."}
  207. td.err { $miner_font ".getcss('td.err')."}
  208. td.warn { $miner_font ".getcss('td.warn')."}
  209. td.sta { $miner_font ".getcss('td.sta')."}
  210. td.tot { $miner_font ".getcss('td.tot')."}
  211. td.lst { $miner_font ".getcss('td.lst')."}
  212. td.hi { $miner_font ".getcss('td.hi')."}
  213. td.lo { $miner_font ".getcss('td.lo')."}
  214. </style>
  215. </head><body".getcss('body',true).">
  216. <script type='text/javascript'>
  217. function pr(a,m){if(m!=null){if(!confirm(m+'?'))return}window.location='$here?ref=$autorefresh'+a}\n";
  218. if ($ignorerefresh == false)
  219. echo "function prr(a){if(a){v=document.getElementById('refval').value}else{v=0}window.location='$here?ref='+v+'$extraparams'}\n";
  220. if ($readonly === false && $checkapi === true)
  221. {
  222. echo "function prc(a,m){pr('&arg='+a,m)}
  223. 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)}
  224. 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)}\n";
  225. }
  226. ?>
  227. </script>
  228. <table width=100% height=100% border=0 cellpadding=0 cellspacing=0 summary='Mine'>
  229. <tr><td align=center valign=top>
  230. <table border=0 cellpadding=4 cellspacing=0 summary='Mine'>
  231. <?php
  232. }
  233. #
  234. global $haderror, $error;
  235. $haderror = false;
  236. $error = null;
  237. #
  238. function getsock($addr, $port)
  239. {
  240. global $haderror, $error, $socktimeoutsec;
  241. $error = null;
  242. $socket = null;
  243. $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
  244. if ($socket === false || $socket === null)
  245. {
  246. $haderror = true;
  247. $error = socket_strerror(socket_last_error());
  248. $msg = "socket create(TCP) failed";
  249. $error = "ERR: $msg '$error'\n";
  250. return null;
  251. }
  252. // Ignore if this fails since the socket connect may work anyway
  253. // and nothing is gained by aborting if the option cannot be set
  254. // since we don't know in advance if it can connect
  255. socket_set_option($socket, SOL_SOCKET, SO_SNDTIMEO, array('sec' => $socktimeoutsec, 'usec' => 0));
  256. $res = socket_connect($socket, $addr, $port);
  257. if ($res === false)
  258. {
  259. $haderror = true;
  260. $error = socket_strerror(socket_last_error());
  261. $msg = "socket connect($addr,$port) failed";
  262. $error = "ERR: $msg '$error'\n";
  263. socket_close($socket);
  264. return null;
  265. }
  266. return $socket;
  267. }
  268. #
  269. function readsockline($socket)
  270. {
  271. $line = '';
  272. while (true)
  273. {
  274. $byte = socket_read($socket, 1);
  275. if ($byte === false || $byte === '')
  276. break;
  277. if ($byte === "\0")
  278. break;
  279. $line .= $byte;
  280. }
  281. return $line;
  282. }
  283. #
  284. function api($cmd)
  285. {
  286. global $haderror, $error;
  287. global $miner, $port, $hidefields;
  288. $socket = getsock($miner, $port);
  289. if ($socket != null)
  290. {
  291. socket_write($socket, $cmd, strlen($cmd));
  292. $line = readsockline($socket);
  293. socket_close($socket);
  294. if (strlen($line) == 0)
  295. {
  296. $haderror = true;
  297. $error = "WARN: '$cmd' returned nothing\n";
  298. return $line;
  299. }
  300. # print "$cmd returned '$line'\n";
  301. $data = array();
  302. $objs = explode('|', $line);
  303. foreach ($objs as $obj)
  304. {
  305. if (strlen($obj) > 0)
  306. {
  307. $items = explode(',', $obj);
  308. $item = $items[0];
  309. $id = explode('=', $items[0], 2);
  310. if (count($id) == 1 or !ctype_digit($id[1]))
  311. $name = $id[0];
  312. else
  313. $name = $id[0].$id[1];
  314. if (strlen($name) == 0)
  315. $name = 'null';
  316. $sectionname = preg_replace('/\d/', '', $name);
  317. if (isset($data[$name]))
  318. {
  319. $num = 1;
  320. while (isset($data[$name.$num]))
  321. $num++;
  322. $name .= $num;
  323. }
  324. $counter = 0;
  325. foreach ($items as $item)
  326. {
  327. $id = explode('=', $item, 2);
  328. if (isset($hidefields[$sectionname.'.'.$id[0]]))
  329. continue;
  330. if (count($id) == 2)
  331. $data[$name][$id[0]] = $id[1];
  332. else
  333. $data[$name][$counter] = $id[0];
  334. $counter++;
  335. }
  336. }
  337. }
  338. return $data;
  339. }
  340. return null;
  341. }
  342. #
  343. function getparam($name, $both = false)
  344. {
  345. $a = null;
  346. if (isset($_POST[$name]))
  347. $a = $_POST[$name];
  348. if (($both === true) and ($a === null))
  349. {
  350. if (isset($_GET[$name]))
  351. $a = $_GET[$name];
  352. }
  353. if ($a == '' || $a == null)
  354. return null;
  355. // limit to 1K just to be safe
  356. return substr($a, 0, 1024);
  357. }
  358. #
  359. function classlastshare($when, $alldata, $warnclass, $errorclass)
  360. {
  361. global $checklastshare;
  362. if ($checklastshare === false)
  363. return '';
  364. if ($when == 0)
  365. return '';
  366. if (!isset($alldata['MHS av']))
  367. return '';
  368. if (!isset($alldata['Last Share Time']))
  369. return '';
  370. $expected = pow(2, 32) / ($alldata['MHS av'] * pow(10, 6));
  371. $howlong = $when - $alldata['Last Share Time'];
  372. if ($howlong < 1)
  373. $howlong = 1;
  374. if ($howlong > ($expected * 12))
  375. return $errorclass;
  376. if ($howlong > ($expected * 8))
  377. return $warnclass;
  378. return '';
  379. }
  380. #
  381. function fmt($section, $name, $value, $when, $alldata)
  382. {
  383. global $dfmt;
  384. if ($alldata == null)
  385. $alldata = array();
  386. $errorclass = ' class=err';
  387. $warnclass = ' class=warn';
  388. $lstclass = ' class=lst';
  389. $hiclass = ' class=hi';
  390. $loclass = ' class=lo';
  391. $b = '&nbsp;';
  392. $ret = $value;
  393. $class = '';
  394. if ($value === null)
  395. $ret = $b;
  396. else
  397. switch ($section.'.'.$name)
  398. {
  399. case 'GPU.Last Share Time':
  400. case 'PGA.Last Share Time':
  401. if ($value == 0
  402. || (isset($alldata['Last Share Pool']) && $alldata['Last Share Pool'] == -1))
  403. {
  404. $ret = 'Never';
  405. $class = $warnclass;
  406. }
  407. else
  408. {
  409. $ret = date('H:i:s', $value);
  410. $class = classlastshare($when, $alldata, $warnclass, $errorclass);
  411. }
  412. break;
  413. case 'POOL.Last Share Time':
  414. if ($value == 0)
  415. $ret = 'Never';
  416. else
  417. $ret = date('H:i:s d-M', $value);
  418. break;
  419. case 'GPU.Last Share Pool':
  420. case 'PGA.Last Share Pool':
  421. if ($value == -1)
  422. {
  423. $ret = 'None';
  424. $class = $warnclass;
  425. }
  426. break;
  427. case 'SUMMARY.Elapsed':
  428. $s = $value % 60;
  429. $value -= $s;
  430. $value /= 60;
  431. if ($value == 0)
  432. $ret = $s.'s';
  433. else
  434. {
  435. $m = $value % 60;
  436. $value -= $m;
  437. $value /= 60;
  438. if ($value == 0)
  439. $ret = sprintf("%dm$b%02ds", $m, $s);
  440. else
  441. {
  442. $h = $value % 24;
  443. $value -= $h;
  444. $value /= 24;
  445. if ($value == 0)
  446. $ret = sprintf("%dh$b%02dm$b%02ds", $h, $m, $s);
  447. else
  448. {
  449. if ($value == 1)
  450. $days = '';
  451. else
  452. $days = 's';
  453. $ret = sprintf("%dday$days$b%02dh$b%02dm$b%02ds", $value, $h, $m, $s);
  454. }
  455. }
  456. }
  457. break;
  458. case 'NOTIFY.Last Well':
  459. if ($value == '0')
  460. {
  461. $ret = 'Never';
  462. $class = $warnclass;
  463. }
  464. else
  465. $ret = date('H:i:s', $value);
  466. break;
  467. case 'NOTIFY.Last Not Well':
  468. if ($value == '0')
  469. $ret = 'Never';
  470. else
  471. {
  472. $ret = date('H:i:s', $value);
  473. $class = $errorclass;
  474. }
  475. break;
  476. case 'NOTIFY.Reason Not Well':
  477. if ($value != 'None')
  478. $class = $errorclass;
  479. break;
  480. case 'GPU.Utility':
  481. case 'PGA.Utility':
  482. case 'SUMMARY.Utility':
  483. $ret = $value.'/m';
  484. if ($value == 0)
  485. $class = $errorclass;
  486. else
  487. if (isset($alldata['MHS av']))
  488. {
  489. $expected = 60 * $alldata['MHS av'] * (pow(10, 6) / pow(2, 32));
  490. if ($expected == 0)
  491. $expected = 0.000001; // 1 H/s
  492. $ratio = $value / $expected;
  493. if ($ratio < 0.9)
  494. $class = $loclass;
  495. else
  496. if ($ratio > 1.1)
  497. $class = $hiclass;
  498. }
  499. break;
  500. case 'PGA.Temperature':
  501. $ret = $value.'&deg;C';
  502. break;
  503. case 'GPU.Temperature':
  504. $ret = $value.'&deg;C';
  505. case 'GPU.GPU Clock':
  506. case 'GPU.Memory Clock':
  507. case 'GPU.GPU Voltage':
  508. case 'GPU.GPU Activity':
  509. if ($value == 0)
  510. $class = $warnclass;
  511. break;
  512. case 'GPU.Fan Percent':
  513. if ($value == 0)
  514. $class = $warnclass;
  515. else
  516. {
  517. if ($value == 100)
  518. $class = $errorclass;
  519. else
  520. if ($value > 85)
  521. $class = $warnclass;
  522. }
  523. break;
  524. case 'GPU.Fan Speed':
  525. if ($value == 0)
  526. $class = $warnclass;
  527. else
  528. if (isset($alldata['Fan Percent']))
  529. {
  530. $test = $alldata['Fan Percent'];
  531. if ($test == 100)
  532. $class = $errorclass;
  533. else
  534. if ($test > 85)
  535. $class = $warnclass;
  536. }
  537. break;
  538. case 'GPU.MHS av':
  539. case 'PGA.MHS av':
  540. case 'SUMMARY.MHS av':
  541. $parts = explode('.', $value, 2);
  542. if (count($parts) == 1)
  543. $dec = '';
  544. else
  545. $dec = '.'.$parts[1];
  546. $ret = number_format($parts[0]).$dec;
  547. if ($value == 0)
  548. $class = $errorclass;
  549. else
  550. if (isset($alldata['Utility']))
  551. {
  552. $expected = 60 * $value * (pow(10, 6) / pow(2, 32));
  553. $utility = $alldata['Utility'];
  554. $ratio = $utility / $expected;
  555. if ($ratio < 0.9)
  556. $class = $hiclass;
  557. else
  558. if ($ratio > 1.1)
  559. $class = $loclass;
  560. }
  561. break;
  562. case 'GPU.Total MH':
  563. case 'PGA.Total MH':
  564. case 'SUMMARY.Total MH':
  565. case 'SUMMARY.Getworks':
  566. case 'GPU.Accepted':
  567. case 'PGA.Accepted':
  568. case 'SUMMARY.Accepted':
  569. case 'GPU.Rejected':
  570. case 'PGA.Rejected':
  571. case 'SUMMARY.Rejected':
  572. case 'SUMMARY.Local Work':
  573. case 'POOL.Getworks':
  574. case 'POOL.Accepted':
  575. case 'POOL.Rejected':
  576. case 'POOL.Discarded':
  577. $parts = explode('.', $value, 2);
  578. if (count($parts) == 1)
  579. $dec = '';
  580. else
  581. $dec = '.'.$parts[1];
  582. $ret = number_format($parts[0]).$dec;
  583. break;
  584. case 'GPU.Status':
  585. case 'PGA.Status':
  586. case 'POOL.Status':
  587. if ($value != 'Alive')
  588. $class = $errorclass;
  589. break;
  590. case 'GPU.Enabled':
  591. case 'PGA.Enabled':
  592. if ($value != 'Y')
  593. $class = $warnclass;
  594. break;
  595. case 'STATUS.When':
  596. $ret = date($dfmt, $value);
  597. break;
  598. }
  599. if ($section == 'NOTIFY' && substr($name, 0, 1) == '*' && $value != '0')
  600. $class = $errorclass;
  601. if ($class == '' && $section != 'POOL')
  602. $class = classlastshare($when, $alldata, $lstclass, $lstclass);
  603. return array($ret, $class);
  604. }
  605. #
  606. global $poolcmd;
  607. $poolcmd = array( 'Switch to' => 'switchpool',
  608. 'Enable' => 'enablepool',
  609. 'Disable' => 'disablepool' );
  610. #
  611. function showhead($cmd, $values, $justnames = false)
  612. {
  613. global $poolcmd, $readonly;
  614. echo '<tr>';
  615. foreach ($values as $name => $value)
  616. {
  617. if ($name == '0' or $name == '')
  618. $name = '&nbsp;';
  619. echo "<td valign=bottom class=h>$name</td>";
  620. }
  621. if ($justnames === false && $cmd == 'pools' && $readonly === false)
  622. foreach ($poolcmd as $name => $pcmd)
  623. echo "<td valign=bottom class=h>$name</td>";
  624. echo '</tr>';
  625. }
  626. #
  627. function details($cmd, $list, $rig)
  628. {
  629. global $tablebegin, $tableend, $dfmt;
  630. global $poolcmd, $readonly;
  631. global $showndate;
  632. $when = 0;
  633. $stas = array('S' => 'Success', 'W' => 'Warning', 'I' => 'Informational', 'E' => 'Error', 'F' => 'Fatal');
  634. echo $tablebegin;
  635. if ($showndate === false)
  636. {
  637. echo '<tr><td class=sta>Date: '.date($dfmt).'</td></tr>';
  638. echo $tableend.$tablebegin;
  639. $showndate = true;
  640. }
  641. if (isset($list['STATUS']))
  642. {
  643. echo '<tr>';
  644. echo '<td>Computer: '.$list['STATUS']['Description'].'</td>';
  645. if (isset($list['STATUS']['When']))
  646. {
  647. echo '<td>When: '.date($dfmt, $list['STATUS']['When']).'</td>';
  648. $when = $list['STATUS']['When'];
  649. }
  650. $sta = $list['STATUS']['STATUS'];
  651. echo '<td>Status: '.$stas[$sta].'</td>';
  652. echo '<td>Message: '.$list['STATUS']['Msg'].'</td>';
  653. echo '</tr>';
  654. }
  655. $section = '';
  656. foreach ($list as $item => $values)
  657. {
  658. if ($item == 'STATUS')
  659. continue;
  660. $sectionname = preg_replace('/\d/', '', $item);
  661. if ($sectionname != $section)
  662. {
  663. echo $tableend.$tablebegin;
  664. showhead($cmd, $values);
  665. $section = $sectionname;
  666. }
  667. echo '<tr>';
  668. foreach ($values as $name => $value)
  669. {
  670. list($showvalue, $class) = fmt($section, $name, $value, $when, $values);
  671. echo "<td$class>$showvalue</td>";
  672. }
  673. if ($cmd == 'pools' && $readonly === false)
  674. {
  675. reset($values);
  676. $pool = current($values);
  677. foreach ($poolcmd as $name => $pcmd)
  678. {
  679. echo '<td>';
  680. if ($pool === false)
  681. echo '&nbsp;';
  682. else
  683. {
  684. echo "<input type=button value='Pool $pool'";
  685. echo " onclick='prc(\"$pcmd|$pool&rig=$rig\",\"$name Pool $pool\")'>";
  686. }
  687. echo '</td>';
  688. }
  689. }
  690. echo '</tr>';
  691. }
  692. echo $tableend;
  693. }
  694. #
  695. global $devs;
  696. $devs = null;
  697. #
  698. function gpubuttons($count, $rig)
  699. {
  700. global $tablebegin, $tableend;
  701. global $devs;
  702. $basic = array( 'GPU', 'Enable', 'Disable', 'Restart' );
  703. $options = array( 'intensity' => 'Intensity',
  704. 'fan' => 'Fan Percent',
  705. 'engine' => 'GPU Clock',
  706. 'mem' => 'Memory Clock',
  707. 'vddc' => 'GPU Voltage' );
  708. echo $tablebegin.'<tr>';
  709. foreach ($basic as $head)
  710. echo "<td>$head</td>";
  711. foreach ($options as $name => $des)
  712. echo "<td nowrap>$des</td>";
  713. $n = 0;
  714. for ($c = 0; $c < $count; $c++)
  715. {
  716. echo '</tr><tr>';
  717. foreach ($basic as $name)
  718. {
  719. echo '<td>';
  720. if ($name == 'GPU')
  721. echo $c;
  722. else
  723. {
  724. echo "<input type=button value='$name $c' onclick='prs(\"gpu";
  725. echo strtolower($name);
  726. echo "|$c\",$rig)'>";
  727. }
  728. echo '</td>';
  729. }
  730. foreach ($options as $name => $des)
  731. {
  732. echo '<td>';
  733. if (!isset($devs["GPU$c"][$des]))
  734. echo '&nbsp;';
  735. else
  736. {
  737. $value = $devs["GPU$c"][$des];
  738. echo "<input type=button value='Set $c:' onclick='prs2(\"gpu$name|$c\",$n,$rig)'>";
  739. echo "<input size=7 type=text name=gi$n value='$value' id=gi$n>";
  740. $n++;
  741. }
  742. echo '</td>';
  743. }
  744. }
  745. echo '</tr>'.$tableend;
  746. }
  747. #
  748. function processgpus($rig)
  749. {
  750. global $error;
  751. global $warnfont, $warnoff;
  752. $gpus = api('gpucount');
  753. if ($error != null)
  754. echo '<tr><td>Error getting GPU count: '.$warnfont.$error.$warnoff.'</td></tr>';
  755. else
  756. {
  757. if (!isset($gpus['GPUS']['Count']))
  758. echo '<tr><td>No GPU count returned: '.$warnfont.$gpus['STATUS']['STATUS'].' '.$gpus['STATUS']['Msg'].$ro.'</td></tr>';
  759. else
  760. {
  761. $count = $gpus['GPUS']['Count'];
  762. if ($count == 0)
  763. echo '<tr><td>No GPUs</td></tr>';
  764. else
  765. gpubuttons($count, $rig);
  766. }
  767. }
  768. }
  769. #
  770. function process($cmds, $rig)
  771. {
  772. global $error, $devs;
  773. global $warnfont, $warnoff;
  774. $count = count($cmds);
  775. foreach ($cmds as $cmd => $des)
  776. {
  777. $process = api($cmd);
  778. if ($error != null)
  779. {
  780. echo "<tr><td colspan=100>Error getting $des: ";
  781. echo $warnfont.$error.$warnoff.'</td></tr>';
  782. break;
  783. }
  784. else
  785. {
  786. details($cmd, $process, $rig);
  787. # Not after the last one
  788. if (--$count > 0)
  789. echo '<tr><td><br><br></td></tr>';
  790. if ($cmd == 'devs')
  791. $devs = $process;
  792. }
  793. }
  794. }
  795. #
  796. # $head is a hack but this is just a demo anyway :)
  797. function doforeach($cmd, $des, $sum, $head, $datetime)
  798. {
  799. global $miner, $port;
  800. global $error, $readonly, $notify, $rigs;
  801. global $tablebegin, $tableend, $warnfont, $warnoff, $dfmt;
  802. global $rigerror;
  803. $when = 0;
  804. $header = $head;
  805. $anss = array();
  806. $count = 0;
  807. $preverr = count($rigerror);
  808. foreach ($rigs as $rig)
  809. {
  810. if (isset($rigerror[$rig]))
  811. continue;
  812. $parts = explode(':', $rig, 2);
  813. if (count($parts) == 2)
  814. {
  815. $miner = $parts[0];
  816. $port = $parts[1];
  817. $ans = api($cmd);
  818. if ($error != null)
  819. {
  820. echo "<tr><td colspan=100>Error on rig $count getting $des: ";
  821. echo $warnfont.$error.$warnoff.'</td></tr>';
  822. $rigerror[$rig] = $error;
  823. $error = null;
  824. }
  825. else
  826. $anss[$count] = $ans;
  827. }
  828. $count++;
  829. }
  830. if (count($anss) == 0)
  831. {
  832. echo '<tr><td>Failed to access any rigs successfully';
  833. if ($preverr > 0)
  834. echo ' (or rigs had previous errors)';
  835. echo '</td></tr>';
  836. return;
  837. }
  838. if ($datetime)
  839. {
  840. echo '<tr><td class=sta>Date: '.date($dfmt).'</td></tr>';
  841. echo $tableend.$tablebegin;
  842. $dthead = array('' => 1, 'STATUS' => 1, 'Description' => 1, 'When' => 1, 'API' => 1, 'CGMiner' => 1);
  843. showhead('', $dthead);
  844. foreach ($anss as $rig => $ans)
  845. {
  846. echo '<tr>';
  847. foreach ($ans as $item => $row)
  848. {
  849. if ($item != 'STATUS' && $item != 'VERSION')
  850. continue;
  851. foreach ($dthead as $name => $x)
  852. {
  853. if ($item == 'STATUS' && $name == '')
  854. echo "<td align=right><input type=button value='Rig $rig' onclick='pr(\"&rig=$rig\",null)'></td>";
  855. else
  856. {
  857. if (isset($row[$name]))
  858. {
  859. list($showvalue, $class) = fmt('STATUS', $name, $row[$name], $when, null);
  860. echo "<td$class align=right>$showvalue</td>";
  861. }
  862. }
  863. }
  864. }
  865. echo '</tr>';
  866. }
  867. echo $tableend;
  868. echo '<tr><td><br><br></td></tr>';
  869. echo $tablebegin;
  870. return;
  871. }
  872. $total = array();
  873. foreach ($anss as $rig => $ans)
  874. {
  875. foreach ($ans as $item => $row)
  876. {
  877. if ($item == 'STATUS')
  878. continue;
  879. if (count($row) > count($header))
  880. {
  881. $header = $head;
  882. foreach ($row as $name => $value)
  883. if (!isset($header[$name]))
  884. $header[$name] = '';
  885. }
  886. if ($sum != null)
  887. foreach ($sum as $name)
  888. {
  889. if (isset($row[$name]))
  890. {
  891. if (isset($total[$name]))
  892. $total[$name] += $row[$name];
  893. else
  894. $total[$name] = $row[$name];
  895. }
  896. }
  897. }
  898. }
  899. if ($sum != null)
  900. $anss['total']['total'] = $total;
  901. showhead('', $header);
  902. $section = '';
  903. foreach ($anss as $rig => $ans)
  904. {
  905. $when = 0;
  906. if (isset($ans['STATUS']['When']))
  907. $when = $ans['STATUS']['When'];
  908. foreach ($ans as $item => $row)
  909. {
  910. if ($item == 'STATUS')
  911. continue;
  912. echo '<tr>';
  913. $newsection = preg_replace('/\d/', '', $item);
  914. if ($newsection != 'total')
  915. $section = $newsection;
  916. foreach ($header as $name => $x)
  917. {
  918. if ($name == '')
  919. {
  920. if ($rig === 'total')
  921. echo "<td align=right class=tot>Total:</td>";
  922. else
  923. echo "<td align=right><input type=button value='Rig $rig' onclick='pr(\"&rig=$rig\",null)'></td>";
  924. }
  925. else
  926. {
  927. if (isset($row[$name]))
  928. $value = $row[$name];
  929. else
  930. $value = null;
  931. list($showvalue, $class) = fmt($section, $name, $value, $when, $row);
  932. if ($rig === 'total' and $class == '')
  933. $class = ' class=tot';
  934. echo "<td$class align=right>$showvalue</td>";
  935. }
  936. }
  937. echo '</tr>';
  938. }
  939. }
  940. }
  941. #
  942. function refreshbuttons()
  943. {
  944. global $readonly;
  945. global $ignorerefresh, $changerefresh, $autorefresh;
  946. if ($ignorerefresh == false && $changerefresh == true)
  947. {
  948. echo '&nbsp;&nbsp;&nbsp;&nbsp;';
  949. echo "<input type=button value='Auto Refresh:' onclick='prr(true)'>";
  950. echo "<input type=text name='refval' id='refval' size=2 value='$autorefresh'>";
  951. echo "<input type=button value='Off' onclick='prr(false)'>";
  952. }
  953. }
  954. #
  955. function pagebuttons($rig, $pg)
  956. {
  957. global $readonly, $rigs;
  958. global $allowcustompages, $customsummarypages;
  959. if ($rig === null)
  960. {
  961. if ($pg === null)
  962. $refresh = '';
  963. else
  964. $refresh = "&pg=$pg";
  965. }
  966. else
  967. $refresh = "&rig=$rig";
  968. echo '<tr><td><table cellpadding=0 cellspacing=0 border=0><tr><td nowrap>';
  969. echo "<input type=button value='Refresh' onclick='pr(\"$refresh\",null)'>&nbsp;";
  970. if (count($rigs) > 1)
  971. echo "<input type=button value='Summary' onclick='pr(\"\",null)'>&nbsp;";
  972. if ($allowcustompages === true)
  973. foreach ($customsummarypages as $pagename => $data)
  974. echo "<input type=button value='$pagename' onclick='pr(\"&pg=$pagename\",null)'>&nbsp;";
  975. echo '</td><td width=100%>&nbsp;</td><td nowrap>';
  976. if ($rig !== null && $readonly === false)
  977. {
  978. $rg = '';
  979. if (count($rigs) > 1)
  980. $rg = " Rig $rig";
  981. echo "<input type=button value='Restart' onclick='prc(\"restart&rig=$rig\",\"Restart CGMiner$rg\")'>";
  982. echo "&nbsp;<input type=button value='Quit' onclick='prc(\"quit&rig=$rig\",\"Quit CGMiner$rg\")'>";
  983. }
  984. refreshbuttons();
  985. echo "</td></tr></table></td></tr>";
  986. }
  987. #
  988. function doOne($rig, $preprocess)
  989. {
  990. global $haderror, $readonly, $notify, $rigs;
  991. global $placebuttons;
  992. htmlhead(true, $rig);
  993. if ($placebuttons == 'top' || $placebuttons == 'both')
  994. pagebuttons($rig, null);
  995. if ($preprocess != null)
  996. process(array($preprocess => $preprocess), $rig);
  997. $cmds = array( 'devs' => 'device list',
  998. 'summary' => 'summary information',
  999. 'pools' => 'pool list');
  1000. if ($notify)
  1001. $cmds['notify'] = 'device status';
  1002. $cmds['config'] = 'cgminer config';
  1003. process($cmds, $rig);
  1004. if ($haderror == false && $readonly === false)
  1005. processgpus($rig);
  1006. if ($placebuttons == 'bot' || $placebuttons == 'both')
  1007. pagebuttons($rig, null);
  1008. }
  1009. #
  1010. global $sectionmap;
  1011. # map sections to their api command
  1012. $sectionmap = array(
  1013. 'SUMMARY' => 'summary',
  1014. 'POOL' => 'pools',
  1015. 'GPU' => 'devs',
  1016. 'PGA' => 'devs',
  1017. 'NOTIFY' => 'notify',
  1018. 'CONFIG' => 'config');
  1019. #
  1020. function customset($showfields, $sum, $section, $num, $result, $total)
  1021. {
  1022. foreach ($result as $sec => $row)
  1023. {
  1024. $secname = preg_replace('/\d/', '', $sec);
  1025. if ($sec != 'total')
  1026. {
  1027. if ($secname != $section)
  1028. continue;
  1029. }
  1030. echo '<tr>';
  1031. $when = 0;
  1032. if (isset($result['STATUS']['When']))
  1033. $when = $result['STATUS']['When'];
  1034. if ($sec === 'total')
  1035. $class = ' class=tot';
  1036. else
  1037. $class = '';
  1038. echo "<td align=middle$class>$num</td>";
  1039. foreach ($showfields as $name => $one)
  1040. {
  1041. if (isset($row[$name]))
  1042. {
  1043. $value = $row[$name];
  1044. if (isset($sum[$secname][$name]))
  1045. {
  1046. if (isset($total[$name]))
  1047. $total[$name] += $value;
  1048. else
  1049. $total[$name] = $value;
  1050. }
  1051. }
  1052. else
  1053. {
  1054. if ($sec == 'total' && isset($total[$name]))
  1055. $value = $total[$name];
  1056. else
  1057. $value = null;
  1058. }
  1059. list($showvalue, $class) = fmt($section, $name, $value, $when, $row);
  1060. if ($sec === 'total' and $class == '')
  1061. $class = ' class=tot';
  1062. echo "<td$class align=right>$showvalue</td>";
  1063. }
  1064. echo '</tr>';
  1065. }
  1066. return $total;
  1067. }
  1068. #
  1069. function processcustompage($pagename, $sections, $sum)
  1070. {
  1071. global $sectionmap;
  1072. global $miner, $port;
  1073. global $rigs, $error;
  1074. global $warnfont, $warnoff;
  1075. global $tablebegin, $tableend, $dfmt;
  1076. global $readonly, $showndate;
  1077. $cmds = array();
  1078. $errors = array();
  1079. foreach ($sections as $section => $fields)
  1080. {
  1081. if (isset($sectionmap[$section]))
  1082. {
  1083. $cmd = $sectionmap[$section];
  1084. if (!isset($cmds[$cmd]))
  1085. $cmds[$cmd] = 1;
  1086. }
  1087. else
  1088. $errors[] = "Error: unknown section '$section' in custom summary page '$pagename'";
  1089. }
  1090. $results = array();
  1091. foreach ($rigs as $num => $rig)
  1092. {
  1093. $parts = explode(':', $rig, 2);
  1094. if (count($parts) == 2)
  1095. {
  1096. $miner = $parts[0];
  1097. $port = $parts[1];
  1098. foreach ($cmds as $cmd => $one)
  1099. {
  1100. $process = api($cmd);
  1101. if ($error != null)
  1102. {
  1103. $errors[] = "Error getting $cmd for $rig $warnfont$error$warnoff";
  1104. break;
  1105. }
  1106. else
  1107. $results[$cmd][$num] = $process;
  1108. }
  1109. }
  1110. }
  1111. if (count($results) > 0)
  1112. {
  1113. $first = true;
  1114. foreach ($sections as $section => $fields)
  1115. {
  1116. if (isset($results[$sectionmap[$section]]))
  1117. {
  1118. $rigresults = $results[$sectionmap[$section]];
  1119. $showfields = array();
  1120. foreach ($fields as $field)
  1121. foreach ($rigresults as $result)
  1122. foreach ($result as $sec => $row)
  1123. {
  1124. $secname = preg_replace('/\d/', '', $sec);
  1125. if ($secname == $section && isset($row[$field]))
  1126. $showfields[$field] = 1;
  1127. }
  1128. if (count($showfields) > 0)
  1129. {
  1130. if ($first === false)
  1131. echo '<tr><td>&nbsp;</td></tr>';
  1132. echo $tablebegin;
  1133. showhead('', array('Rig'=>1)+$showfields, true);
  1134. $total = array();
  1135. $add = array('total' => array());
  1136. foreach ($rigresults as $num => $result)
  1137. {
  1138. $rg = "<input type=button value='$num' onclick='pr(\"&rig=$num\",null)'>";
  1139. $total = customset($showfields, $sum, $section, $rg, $result, $total);
  1140. }
  1141. if (count($total) > 0)
  1142. customset($showfields, $sum, $section, '&Sigma;', $add, $total);
  1143. $first = false;
  1144. echo $tableend;
  1145. }
  1146. }
  1147. }
  1148. }
  1149. if (count($errors) > 0)
  1150. {
  1151. if (count($results) > 0)
  1152. echo '<tr><td>&nbsp;</td></tr>';
  1153. foreach ($errors as $err)
  1154. echo "<tr><td colspan=100>$err</td></tr>";
  1155. }
  1156. }
  1157. #
  1158. function showcustompage($pagename)
  1159. {
  1160. global $customsummarypages;
  1161. global $placebuttons;
  1162. htmlhead(false, null, $pagename);
  1163. if ($placebuttons == 'top' || $placebuttons == 'both')
  1164. pagebuttons(null, $pagename);
  1165. if (!isset($customsummarypages[$pagename]))
  1166. {
  1167. echo "<tr><td colspan=100>Unknown custom summary page '$pagename'</td></tr>";
  1168. return;
  1169. }
  1170. if (count($customsummarypages[$pagename]) != 2)
  1171. {
  1172. echo "<tr><td colspan=100>Invalid custom summary page '$pagename' (".count($customsummarypages[$pagename]).")</td></tr>";
  1173. return;
  1174. }
  1175. $page = $customsummarypages[$pagename][0];
  1176. $sum = $customsummarypages[$pagename][1];
  1177. if ($sum === null)
  1178. $sum = array();
  1179. if (count($page) <= 1)
  1180. {
  1181. echo "<tr><td colspan=100>Invalid custom summary page '$pagename' no content </td></tr>";
  1182. return;
  1183. }
  1184. processcustompage($pagename, $page, $sum);
  1185. if ($placebuttons == 'bot' || $placebuttons == 'both')
  1186. pagebuttons(null, $pagename);
  1187. }
  1188. #
  1189. function display()
  1190. {
  1191. global $tablebegin, $tableend;
  1192. global $miner, $port;
  1193. global $readonly, $notify, $rigs;
  1194. global $ignorerefresh, $autorefresh;
  1195. global $allowcustompages;
  1196. global $placebuttons;
  1197. if ($ignorerefresh == false)
  1198. {
  1199. $ref = trim(getparam('ref', true));
  1200. if ($ref != null && $ref != '')
  1201. $autorefresh = intval($ref);
  1202. }
  1203. $rig = trim(getparam('rig', true));
  1204. $arg = trim(getparam('arg', true));
  1205. $preprocess = null;
  1206. if ($arg != null and $arg != '')
  1207. {
  1208. $num = null;
  1209. if ($rig != null and $rig != '')
  1210. {
  1211. if ($rig >= 0 and $rig < count($rigs))
  1212. $num = $rig;
  1213. }
  1214. else
  1215. if (count($rigs) == 0)
  1216. $num = 0;
  1217. if ($num != null)
  1218. {
  1219. $parts = explode(':', $rigs[$num], 2);
  1220. if (count($parts) == 2)
  1221. {
  1222. $miner = $parts[0];
  1223. $port = $parts[1];
  1224. $preprocess = $arg;
  1225. }
  1226. }
  1227. }
  1228. if ($rigs == null or count($rigs) == 0)
  1229. {
  1230. echo "<tr><td>No rigs defined</td></tr>";
  1231. return;
  1232. }
  1233. if ($allowcustompages === true)
  1234. {
  1235. $pg = trim(getparam('pg', true));
  1236. if ($pg != null && $pg != '')
  1237. {
  1238. showcustompage($pg);
  1239. return;
  1240. }
  1241. }
  1242. if (count($rigs) == 1)
  1243. {
  1244. $parts = explode(':', $rigs[0], 2);
  1245. if (count($parts) == 2)
  1246. {
  1247. $miner = $parts[0];
  1248. $port = $parts[1];
  1249. doOne(0, $preprocess);
  1250. }
  1251. else
  1252. echo '<tr><td>Invalid "$rigs" array</td></tr>';
  1253. return;
  1254. }
  1255. if ($rig != null and $rig != '' and $rig >= 0 and $rig < count($rigs))
  1256. {
  1257. $parts = explode(':', $rigs[$rig], 2);
  1258. if (count($parts) == 2)
  1259. {
  1260. $miner = $parts[0];
  1261. $port = $parts[1];
  1262. doOne($rig, $preprocess);
  1263. }
  1264. else
  1265. echo '<tr><td>Invalid "$rigs" array</td></tr>';
  1266. return;
  1267. }
  1268. htmlhead(false, null);
  1269. if ($placebuttons == 'top' || $placebuttons == 'both')
  1270. pagebuttons(null, null);
  1271. if ($preprocess != null)
  1272. process(array($preprocess => $preprocess), $rig);
  1273. echo $tablebegin;
  1274. doforeach('version', 'rig summary', array(), array(), true);
  1275. $sum = array('MHS av', 'Getworks', 'Found Blocks', 'Accepted', 'Rejected', 'Discarded', 'Stale', 'Utility', 'Local Work', 'Total MH');
  1276. doforeach('summary', 'summary information', $sum, array(), false);
  1277. echo $tableend;
  1278. echo '<tr><td><br><br></td></tr>';
  1279. echo $tablebegin;
  1280. doforeach('devs', 'device list', $sum, array(''=>'','ID'=>'','Name'=>''), false);
  1281. echo $tableend;
  1282. echo '<tr><td><br><br></td></tr>';
  1283. echo $tablebegin;
  1284. doforeach('pools', 'pool list', $sum, array(''=>''), false);
  1285. echo $tableend;
  1286. if ($placebuttons == 'bot' || $placebuttons == 'both')
  1287. pagebuttons(null, null);
  1288. }
  1289. #
  1290. display();
  1291. #
  1292. ?>
  1293. </table></td></tr></table>
  1294. </body></html>