miner.php 33 KB

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