miner.php 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122
  1. <?php
  2. session_start();
  3. #
  4. global $title, $miner, $port, $readonly, $notify, $rigs;
  5. global $rigipsecurity, $rigtotals, $forcerigtotals;
  6. global $socksndtimeoutsec, $sockrcvtimeoutsec;
  7. global $checklastshare, $poolinputs, $hidefields;
  8. global $ignorerefresh, $changerefresh, $autorefresh;
  9. global $allowcustompages, $customsummarypages;
  10. global $miner_font_family, $miner_font_size;
  11. global $colouroverride, $placebuttons;
  12. #
  13. # See API-README for more details of these variables and how
  14. # to configure miner.php
  15. #
  16. # Web page title
  17. $title = 'Mine';
  18. #
  19. # Set $readonly to true to force miner.php to be readonly
  20. # Set $readonly to false then it will check cgminer 'privileged'
  21. $readonly = false;
  22. #
  23. # Set $notify to false to NOT attempt to display the notify command
  24. # Set $notify to true to attempt to display the notify command
  25. $notify = true;
  26. #
  27. # Set $checklastshare to true to do the following checks:
  28. # If a device's last share is 12x expected ago then display as an error
  29. # If a device's last share is 8x expected ago then display as a warning
  30. # If either of the above is true, also display the whole line highlighted
  31. # This assumes shares are 1 difficulty shares
  32. $checklastshare = true;
  33. #
  34. # Set $poolinputs to true to show the input fields for adding a pool
  35. # and changing the pool priorities
  36. # N.B. also if $readonly is true, it will not display the fields
  37. $poolinputs = false;
  38. #
  39. # Set $rigs to an array of your cgminer rigs that are running
  40. # format: 'IP:Port' or 'Host:Port' or 'Host:Port:Name'
  41. $rigs = array('127.0.0.1:4028');
  42. #
  43. # Set $rigipsecurity to false to show the IP/Port of the rig
  44. # in the socket error messages and also show the full socket message
  45. $rigipsecurity = true;
  46. #
  47. # Set $rigtotals to true to display totals on the single rig page
  48. # 'false' means no totals (and ignores $forcerigtotals)
  49. # You can force it to always show rig totals when there is only
  50. # one line by setting $forcerigtotals = true;
  51. $rigtotals = true;
  52. $forcerigtotals = false;
  53. #
  54. # These should be OK for most cases
  55. $socksndtimeoutsec = 10;
  56. $sockrcvtimeoutsec = 40;
  57. #
  58. # List of fields NOT to be displayed
  59. # This example would hide the slightly more sensitive pool information
  60. #$hidefields = array('POOL.URL' => 1, 'POOL.User' => 1);
  61. $hidefields = array();
  62. #
  63. # Auto-refresh of the page (in seconds) - integers only
  64. # $ignorerefresh = true/false always ignore refresh parameters
  65. # $changerefresh = true/false show buttons to change the value
  66. # $autorefresh = default value, 0 means dont auto-refresh
  67. $ignorerefresh = false;
  68. $changerefresh = true;
  69. $autorefresh = 0;
  70. #
  71. # Should we allow custom pages?
  72. # (or just completely ignore them and don't display the buttons)
  73. $allowcustompages = true;
  74. #
  75. # OK this is a bit more complex item: Custom Summary Pages
  76. # As mentioned above, see API-README
  77. # see the example below (if there is no matching data, no total will show)
  78. $mobilepage = array(
  79. 'DATE' => null,
  80. 'RIGS' => null,
  81. 'SUMMARY' => array('Elapsed', 'MHS av', 'Found Blocks=Blks', 'Accepted', 'Rejected=Rej', 'Utility'),
  82. 'DEVS+NOTIFY' => array('DEVS.Name=Name', 'DEVS.ID=ID', 'DEVS.Status=Status', 'DEVS.Temperature=Temp',
  83. 'DEVS.MHS av=MHS av', 'DEVS.Accepted=Accept', 'DEVS.Rejected=Rej',
  84. 'DEVS.Utility=Utility', 'NOTIFY.Last Not Well=Not Well'),
  85. 'POOL' => array('POOL', 'Status', 'Accepted', 'Rejected=Rej', 'Last Share Time'));
  86. $mobilesum = array(
  87. 'SUMMARY' => array('MHS av', 'Found Blocks', 'Accepted', 'Rejected', 'Utility'),
  88. 'DEVS+NOTIFY' => array('DEVS.MHS av', 'DEVS.Accepted', 'DEVS.Rejected', 'DEVS.Utility'),
  89. 'POOL' => array('Accepted', 'Rejected'));
  90. #
  91. $statspage = array(
  92. 'DATE' => null,
  93. 'RIGS' => null,
  94. 'SUMMARY' => array('Elapsed', 'MHS av', 'Found Blocks=Blks',
  95. 'Accepted', 'Rejected=Rej', 'Utility',
  96. 'Hardware Errors=HW Errs', 'Network Blocks=Net Blks',
  97. 'Work Utility'),
  98. 'COIN' => array('*'),
  99. 'STATS' => array('*'));
  100. #
  101. $statssum = array(
  102. 'SUMMARY' => array('MHS av', 'Found Blocks', 'Accepted',
  103. 'Rejected', 'Utility', 'Hardware Errors',
  104. 'Work Utility'));
  105. #
  106. # customsummarypages is an array of these Custom Summary Pages
  107. $customsummarypages = array('Mobile' => array($mobilepage, $mobilesum),
  108. 'Stats' => array($statspage, $statssum));
  109. #
  110. $here = $_SERVER['PHP_SELF'];
  111. #
  112. global $tablebegin, $tableend, $warnfont, $warnoff, $dfmt;
  113. #
  114. $tablebegin = '<tr><td><table border=1 cellpadding=5 cellspacing=0>';
  115. $tableend = '</table></td></tr>';
  116. $warnfont = '<font color=red><b>';
  117. $warnoff = '</b></font>';
  118. $dfmt = 'H:i:s j-M-Y \U\T\CP';
  119. #
  120. $miner_font_family = 'verdana,arial,sans';
  121. $miner_font_size = '13pt';
  122. #
  123. # Edit this or redefine it in myminer.php to change the colour scheme
  124. # See $colourtable below for the list of names
  125. $colouroverride = array();
  126. #
  127. # Where to place the buttons: 'top' 'bot' 'both'
  128. # anything else means don't show them - case sensitive
  129. $placebuttons = 'top';
  130. #
  131. # This below allows you to put your own settings into a seperate file
  132. # so you don't need to update miner.php with your preferred settings
  133. # every time a new version is released
  134. # Just create the file 'myminer.php' in the same directory as
  135. # 'miner.php' - and put your own settings in there
  136. if (file_exists('myminer.php'))
  137. include_once('myminer.php');
  138. #
  139. # This is the system default that must always contain all necessary
  140. # colours so it must be a constant
  141. # You can override these values with $colouroverride
  142. # The only one missing is in $warnfont
  143. # - which you can override directly anyway
  144. global $colourtable;
  145. $colourtable = array(
  146. 'body bgcolor' => '#ecffff',
  147. 'td color' => 'blue',
  148. 'td.two color' => 'blue',
  149. 'td.two background' => '#ecffff',
  150. 'td.h color' => 'blue',
  151. 'td.h background' => '#c4ffff',
  152. 'td.err color' => 'black',
  153. 'td.err background' => '#ff3050',
  154. 'td.warn color' => 'black',
  155. 'td.warn background' => '#ffb050',
  156. 'td.sta color' => 'green',
  157. 'td.tot color' => 'blue',
  158. 'td.tot background' => '#fff8f2',
  159. 'td.lst color' => 'blue',
  160. 'td.lst background' => '#ffffdd',
  161. 'td.hi color' => 'blue',
  162. 'td.hi background' => '#f6ffff',
  163. 'td.lo color' => 'blue',
  164. 'td.lo background' => '#deffff'
  165. );
  166. #
  167. # Don't touch these 2
  168. $miner = null;
  169. $port = null;
  170. #
  171. # Ensure it is only ever shown once
  172. global $showndate;
  173. $showndate = false;
  174. #
  175. # For summary page to stop retrying failed rigs
  176. global $rigerror;
  177. $rigerror = array();
  178. #
  179. global $rownum;
  180. $rownum = 0;
  181. #
  182. function getcss($cssname, $dom = false)
  183. {
  184. global $colourtable, $colouroverride;
  185. $css = '';
  186. foreach ($colourtable as $cssdata => $value)
  187. {
  188. $cssobj = explode(' ', $cssdata, 2);
  189. if ($cssobj[0] == $cssname)
  190. {
  191. if (isset($colouroverride[$cssdata]))
  192. $value = $colouroverride[$cssdata];
  193. if ($dom == true)
  194. $css .= ' '.$cssobj[1].'='.$value;
  195. else
  196. $css .= $cssobj[1].':'.$value.'; ';
  197. }
  198. }
  199. return $css;
  200. }
  201. #
  202. function getdom($domname)
  203. {
  204. return getcss($domname, true);
  205. }
  206. #
  207. function htmlhead($checkapi, $rig, $pg = null)
  208. {
  209. global $title, $miner_font_family, $miner_font_size;
  210. global $error, $readonly, $poolinputs, $here;
  211. global $ignorerefresh, $autorefresh;
  212. $extraparams = '';
  213. if ($rig != null && $rig != '')
  214. $extraparams = "&rig=$rig";
  215. else
  216. if ($pg != null && $pg != '')
  217. $extraparams = "&pg=$pg";
  218. if ($ignorerefresh == true || $autorefresh == 0)
  219. $refreshmeta = '';
  220. else
  221. {
  222. $url = "$here?ref=$autorefresh$extraparams";
  223. $refreshmeta = "\n<meta http-equiv='refresh' content='$autorefresh;url=$url'>";
  224. }
  225. if ($readonly === false && $checkapi === true)
  226. {
  227. $error = null;
  228. $access = api($rig, 'privileged');
  229. if ($error != null
  230. || !isset($access['STATUS']['STATUS'])
  231. || $access['STATUS']['STATUS'] != 'S')
  232. $readonly = true;
  233. }
  234. $miner_font = "font-family:$miner_font_family; font-size:$miner_font_size;";
  235. echo "<html><head>$refreshmeta
  236. <title>$title</title>
  237. <style type='text/css'>
  238. td { $miner_font ".getcss('td')."}
  239. td.two { $miner_font ".getcss('td.two')."}
  240. td.h { $miner_font ".getcss('td.h')."}
  241. td.err { $miner_font ".getcss('td.err')."}
  242. td.warn { $miner_font ".getcss('td.warn')."}
  243. td.sta { $miner_font ".getcss('td.sta')."}
  244. td.tot { $miner_font ".getcss('td.tot')."}
  245. td.lst { $miner_font ".getcss('td.lst')."}
  246. td.hi { $miner_font ".getcss('td.hi')."}
  247. td.lo { $miner_font ".getcss('td.lo')."}
  248. </style>
  249. </head><body".getdom('body').">
  250. <script type='text/javascript'>
  251. function pr(a,m){if(m!=null){if(!confirm(m+'?'))return}window.location='$here?ref=$autorefresh'+a}\n";
  252. if ($ignorerefresh == false)
  253. echo "function prr(a){if(a){v=document.getElementById('refval').value}else{v=0}window.location='$here?ref='+v+'$extraparams'}\n";
  254. if ($readonly === false && $checkapi === true)
  255. {
  256. echo "function prc(a,m){pr('&arg='+a,m)}
  257. 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)}
  258. 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";
  259. if ($poolinputs === true)
  260. echo "function cbs(s){var t=s.replace(/\\\\/g,'\\\\\\\\'); return t.replace(/,/g, '\\\\,')}\nfunction pla(r){var u=document.getElementById('purl').value;var w=document.getElementById('pwork').value;var p=document.getElementById('ppass').value;pr('&rig='+r+'&arg=addpool|'+cbs(u)+','+cbs(w)+','+cbs(p),'Add Pool '+u)}\nfunction psp(r){var p=document.getElementById('prio').value;pr('&rig='+r+'&arg=poolpriority|'+p,'Set Pool Priorities to '+p)}\n";
  261. }
  262. ?>
  263. </script>
  264. <table width=100% height=100% border=0 cellpadding=0 cellspacing=0 summary='Mine'>
  265. <tr><td align=center valign=top>
  266. <table border=0 cellpadding=4 cellspacing=0 summary='Mine'>
  267. <?php
  268. }
  269. #
  270. global $haderror, $error;
  271. $haderror = false;
  272. $error = null;
  273. #
  274. function getsock($rig, $addr, $port)
  275. {
  276. global $rigipsecurity;
  277. global $haderror, $error, $socksndtimeoutsec, $sockrcvtimeoutsec;
  278. $error = null;
  279. $socket = null;
  280. $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
  281. if ($socket === false || $socket === null)
  282. {
  283. $haderror = true;
  284. if ($rigipsecurity === false)
  285. {
  286. $error = socket_strerror(socket_last_error());
  287. $msg = "socket create(TCP) failed";
  288. $error = "ERR: $msg '$error'\n";
  289. }
  290. else
  291. $error = "ERR: socket create(TCP) failed\n";
  292. return null;
  293. }
  294. // Ignore if this fails since the socket connect may work anyway
  295. // and nothing is gained by aborting if the option cannot be set
  296. // since we don't know in advance if it can connect
  297. socket_set_option($socket, SOL_SOCKET, SO_SNDTIMEO, array('sec' => $socksndtimeoutsec, 'usec' => 0));
  298. socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array('sec' => $sockrcvtimeoutsec, 'usec' => 0));
  299. $res = socket_connect($socket, $addr, $port);
  300. if ($res === false)
  301. {
  302. $haderror = true;
  303. if ($rigipsecurity === false)
  304. {
  305. $error = socket_strerror(socket_last_error());
  306. $msg = "socket connect($addr,$port) failed";
  307. $error = "ERR: $msg '$error'\n";
  308. }
  309. else
  310. $error = "ERR: socket connect($rig) failed\n";
  311. socket_close($socket);
  312. return null;
  313. }
  314. return $socket;
  315. }
  316. #
  317. function readsockline($socket)
  318. {
  319. $line = '';
  320. while (true)
  321. {
  322. $byte = socket_read($socket, 1);
  323. if ($byte === false || $byte === '')
  324. break;
  325. if ($byte === "\0")
  326. break;
  327. $line .= $byte;
  328. }
  329. return $line;
  330. }
  331. #
  332. function api_convert_escape($str)
  333. {
  334. $res = '';
  335. $len = strlen($str);
  336. for ($i = 0; $i < $len; $i++)
  337. {
  338. $ch = substr($str, $i, 1);
  339. if ($ch != '\\' || $i == ($len-1))
  340. $res .= $ch;
  341. else
  342. {
  343. $i++;
  344. $ch = substr($str, $i, 1);
  345. switch ($ch)
  346. {
  347. case '|':
  348. $res .= "\1";
  349. break;
  350. case '\\':
  351. $res .= "\2";
  352. break;
  353. case '=':
  354. $res .= "\3";
  355. break;
  356. case ',':
  357. $res .= "\4";
  358. break;
  359. default:
  360. $res .= $ch;
  361. }
  362. }
  363. }
  364. return $res;
  365. }
  366. #
  367. function revert($str)
  368. {
  369. return str_replace(array("\1", "\2", "\3", "\4"), array("|", "\\", "=", ","), $str);
  370. }
  371. #
  372. function api($rig, $cmd)
  373. {
  374. global $haderror, $error;
  375. global $miner, $port, $hidefields;
  376. $socket = getsock($rig, $miner, $port);
  377. if ($socket != null)
  378. {
  379. socket_write($socket, $cmd, strlen($cmd));
  380. $line = readsockline($socket);
  381. socket_close($socket);
  382. if (strlen($line) == 0)
  383. {
  384. $haderror = true;
  385. $error = "WARN: '$cmd' returned nothing\n";
  386. return $line;
  387. }
  388. # print "$cmd returned '$line'\n";
  389. $line = api_convert_escape($line);
  390. $data = array();
  391. $objs = explode('|', $line);
  392. foreach ($objs as $obj)
  393. {
  394. if (strlen($obj) > 0)
  395. {
  396. $items = explode(',', $obj);
  397. $item = $items[0];
  398. $id = explode('=', $items[0], 2);
  399. if (count($id) == 1 or !ctype_digit($id[1]))
  400. $name = $id[0];
  401. else
  402. $name = $id[0].$id[1];
  403. if (strlen($name) == 0)
  404. $name = 'null';
  405. $sectionname = preg_replace('/\d/', '', $name);
  406. if (isset($data[$name]))
  407. {
  408. $num = 1;
  409. while (isset($data[$name.$num]))
  410. $num++;
  411. $name .= $num;
  412. }
  413. $counter = 0;
  414. foreach ($items as $item)
  415. {
  416. $id = explode('=', $item, 2);
  417. if (isset($hidefields[$sectionname.'.'.$id[0]]))
  418. continue;
  419. if (count($id) == 2)
  420. $data[$name][$id[0]] = revert($id[1]);
  421. else
  422. $data[$name][$counter] = $id[0];
  423. $counter++;
  424. }
  425. }
  426. }
  427. return $data;
  428. }
  429. return null;
  430. }
  431. #
  432. function getparam($name, $both = false)
  433. {
  434. $a = null;
  435. if (isset($_POST[$name]))
  436. $a = $_POST[$name];
  437. if (($both === true) and ($a === null))
  438. {
  439. if (isset($_GET[$name]))
  440. $a = $_GET[$name];
  441. }
  442. if ($a == '' || $a == null)
  443. return null;
  444. // limit to 1K just to be safe
  445. return substr($a, 0, 1024);
  446. }
  447. #
  448. function newtable()
  449. {
  450. global $tablebegin, $rownum;
  451. echo $tablebegin;
  452. $rownum = 0;
  453. }
  454. #
  455. function newrow()
  456. {
  457. echo '<tr>';
  458. }
  459. #
  460. function otherrow($row)
  461. {
  462. echo "<tr>$row</tr>";
  463. }
  464. #
  465. function endrow()
  466. {
  467. global $rownum;
  468. echo '</tr>';
  469. $rownum++;
  470. }
  471. #
  472. function endtable()
  473. {
  474. global $tableend;
  475. echo $tableend;
  476. }
  477. #
  478. function classlastshare($when, $alldata, $warnclass, $errorclass)
  479. {
  480. global $checklastshare;
  481. if ($checklastshare === false)
  482. return '';
  483. if ($when == 0)
  484. return '';
  485. if (!isset($alldata['MHS av']))
  486. return '';
  487. if ($alldata['MHS av'] == 0)
  488. return '';
  489. if (!isset($alldata['Last Share Time']))
  490. return '';
  491. if (!isset($alldata['Last Share Difficulty']))
  492. return '';
  493. $expected = pow(2, 32) / ($alldata['MHS av'] * pow(10, 6));
  494. // If the share difficulty changes while waiting on a share,
  495. // this calculation will of course be incorrect
  496. $expected *= $alldata['Last Share Difficulty'];
  497. $howlong = $when - $alldata['Last Share Time'];
  498. if ($howlong < 1)
  499. $howlong = 1;
  500. if ($howlong > ($expected * 12))
  501. return $errorclass;
  502. if ($howlong > ($expected * 8))
  503. return $warnclass;
  504. return '';
  505. }
  506. #
  507. function fmt($section, $name, $value, $when, $alldata)
  508. {
  509. global $dfmt, $rownum;
  510. if ($alldata == null)
  511. $alldata = array();
  512. $errorclass = ' class=err';
  513. $warnclass = ' class=warn';
  514. $lstclass = ' class=lst';
  515. $hiclass = ' class=hi';
  516. $loclass = ' class=lo';
  517. $c2class = ' class=two';
  518. $totclass = ' class=tot';
  519. $b = '&nbsp;';
  520. $ret = $value;
  521. $class = '';
  522. $nams = explode('.', $name);
  523. if (count($nams) > 1)
  524. $name = $nams[count($nams)-1];
  525. if ($value === null)
  526. $ret = $b;
  527. else
  528. switch ($section.'.'.$name)
  529. {
  530. case 'GPU.Last Share Time':
  531. case 'PGA.Last Share Time':
  532. case 'DEVS.Last Share Time':
  533. if ($value == 0
  534. || (isset($alldata['Last Share Pool']) && $alldata['Last Share Pool'] == -1))
  535. {
  536. $ret = 'Never';
  537. $class = $warnclass;
  538. }
  539. else
  540. {
  541. $ret = date('H:i:s', $value);
  542. $class = classlastshare($when, $alldata, $warnclass, $errorclass);
  543. }
  544. break;
  545. case 'POOL.Last Share Time':
  546. if ($value == 0)
  547. $ret = 'Never';
  548. else
  549. $ret = date('H:i:s d-M', $value);
  550. break;
  551. case 'GPU.Last Share Pool':
  552. case 'PGA.Last Share Pool':
  553. case 'DEVS.Last Share Pool':
  554. if ($value == -1)
  555. {
  556. $ret = 'None';
  557. $class = $warnclass;
  558. }
  559. break;
  560. case 'SUMMARY.Elapsed':
  561. $s = $value % 60;
  562. $value -= $s;
  563. $value /= 60;
  564. if ($value == 0)
  565. $ret = $s.'s';
  566. else
  567. {
  568. $m = $value % 60;
  569. $value -= $m;
  570. $value /= 60;
  571. if ($value == 0)
  572. $ret = sprintf("%dm$b%02ds", $m, $s);
  573. else
  574. {
  575. $h = $value % 24;
  576. $value -= $h;
  577. $value /= 24;
  578. if ($value == 0)
  579. $ret = sprintf("%dh$b%02dm$b%02ds", $h, $m, $s);
  580. else
  581. {
  582. if ($value == 1)
  583. $days = '';
  584. else
  585. $days = 's';
  586. $ret = sprintf("%dday$days$b%02dh$b%02dm$b%02ds", $value, $h, $m, $s);
  587. }
  588. }
  589. }
  590. break;
  591. case 'NOTIFY.Last Well':
  592. if ($value == '0')
  593. {
  594. $ret = 'Never';
  595. $class = $warnclass;
  596. }
  597. else
  598. $ret = date('H:i:s', $value);
  599. break;
  600. case 'NOTIFY.Last Not Well':
  601. if ($value == '0')
  602. $ret = 'Never';
  603. else
  604. {
  605. $ret = date('H:i:s', $value);
  606. $class = $errorclass;
  607. }
  608. break;
  609. case 'NOTIFY.Reason Not Well':
  610. if ($value != 'None')
  611. $class = $errorclass;
  612. break;
  613. case 'GPU.Utility':
  614. case 'PGA.Utility':
  615. case 'DEVS.Utility':
  616. case 'SUMMARY.Utility':
  617. case 'total.Utility':
  618. $ret = $value.'/m';
  619. if ($value == 0)
  620. $class = $errorclass;
  621. else
  622. if (isset($alldata['Difficulty Accepted'])
  623. && isset($alldata['Accepted'])
  624. && isset($alldata['MHS av'])
  625. && ($alldata['Difficulty Accepted'] > 0)
  626. && ($alldata['Accepted'] > 0))
  627. {
  628. $expected = 60 * $alldata['MHS av'] * (pow(10, 6) / pow(2, 32));
  629. if ($expected == 0)
  630. $expected = 0.000001; // 1 H/s
  631. $da = $alldata['Difficulty Accepted'];
  632. $a = $alldata['Accepted'];
  633. $expected /= ($da / $a);
  634. $ratio = $value / $expected;
  635. if ($ratio < 0.9)
  636. $class = $loclass;
  637. else
  638. if ($ratio > 1.1)
  639. $class = $hiclass;
  640. }
  641. break;
  642. case 'SUMMARY.Work Utility':
  643. case 'total.Work Utility':
  644. $ret = $value.'/m';
  645. break;
  646. case 'PGA.Temperature':
  647. case 'GPU.Temperature':
  648. case 'DEVS.Temperature':
  649. $ret = $value.'&deg;C';
  650. if (!isset($alldata['GPU']))
  651. break;
  652. case 'GPU.GPU Clock':
  653. case 'DEVS.GPU Clock':
  654. case 'GPU.Memory Clock':
  655. case 'DEVS.Memory Clock':
  656. case 'GPU.GPU Voltage':
  657. case 'DEVS.GPU Voltage':
  658. case 'GPU.GPU Activity':
  659. case 'DEVS.GPU Activity':
  660. if ($value == 0)
  661. $class = $warnclass;
  662. break;
  663. case 'GPU.Fan Percent':
  664. case 'DEVS.Fan Percent':
  665. if ($value == 0)
  666. $class = $warnclass;
  667. else
  668. {
  669. if ($value == 100)
  670. $class = $errorclass;
  671. else
  672. if ($value > 85)
  673. $class = $warnclass;
  674. }
  675. break;
  676. case 'GPU.Fan Speed':
  677. case 'DEVS.Fan Speed':
  678. if ($value == 0)
  679. $class = $warnclass;
  680. else
  681. if (isset($alldata['Fan Percent']))
  682. {
  683. $test = $alldata['Fan Percent'];
  684. if ($test == 100)
  685. $class = $errorclass;
  686. else
  687. if ($test > 85)
  688. $class = $warnclass;
  689. }
  690. break;
  691. case 'GPU.MHS av':
  692. case 'PGA.MHS av':
  693. case 'DEVS.MHS av':
  694. case 'SUMMARY.MHS av':
  695. case 'total.MHS av':
  696. $parts = explode('.', $value, 2);
  697. if (count($parts) == 1)
  698. $dec = '';
  699. else
  700. $dec = '.'.$parts[1];
  701. $ret = number_format((float)$parts[0]).$dec;
  702. if ($value == 0)
  703. $class = $errorclass;
  704. else
  705. if (isset($alldata['Difficulty Accepted'])
  706. && isset($alldata['Accepted'])
  707. && isset($alldata['Utility'])
  708. && ($alldata['Difficulty Accepted'] > 0)
  709. && ($alldata['Accepted'] > 0))
  710. {
  711. $expected = 60 * $value * (pow(10, 6) / pow(2, 32));
  712. if ($expected == 0)
  713. $expected = 0.000001; // 1 H/s
  714. $da = $alldata['Difficulty Accepted'];
  715. $a = $alldata['Accepted'];
  716. $expected /= ($da / $a);
  717. $ratio = $alldata['Utility'] / $expected;
  718. if ($ratio < 0.9)
  719. $class = $hiclass;
  720. else
  721. if ($ratio > 1.1)
  722. $class = $loclass;
  723. }
  724. break;
  725. case 'GPU.Total MH':
  726. case 'PGA.Total MH':
  727. case 'DEVS.Total MH':
  728. case 'SUMMARY.Total MH':
  729. case 'total.Total MH':
  730. case 'SUMMARY.Getworks':
  731. case 'POOL.Getworks':
  732. case 'total.Getworks':
  733. case 'GPU.Accepted':
  734. case 'PGA.Accepted':
  735. case 'DEVS.Accepted':
  736. case 'SUMMARY.Accepted':
  737. case 'POOL.Accepted':
  738. case 'total.Accepted':
  739. case 'GPU.Rejected':
  740. case 'PGA.Rejected':
  741. case 'DEVS.Rejected':
  742. case 'SUMMARY.Rejected':
  743. case 'POOL.Rejected':
  744. case 'total.Rejected':
  745. case 'SUMMARY.Local Work':
  746. case 'total.Local Work':
  747. case 'SUMMARY.Discarded':
  748. case 'POOL.Discarded':
  749. case 'total.Discarded':
  750. case 'POOL.Diff1 Shares':
  751. case 'total.Diff1 Shares':
  752. case 'GPU.Diff1 Work':
  753. case 'PGA.Diff1 Work':
  754. case 'total.Diff1 Work':
  755. $parts = explode('.', $value, 2);
  756. if (count($parts) == 1)
  757. $dec = '';
  758. else
  759. $dec = '.'.$parts[1];
  760. $ret = number_format((float)$parts[0]).$dec;
  761. break;
  762. case 'GPU.Status':
  763. case 'PGA.Status':
  764. case 'DEVS.Status':
  765. case 'POOL.Status':
  766. if ($value != 'Alive')
  767. $class = $errorclass;
  768. break;
  769. case 'GPU.Enabled':
  770. case 'PGA.Enabled':
  771. case 'DEVS.Enabled':
  772. if ($value != 'Y')
  773. $class = $warnclass;
  774. break;
  775. case 'STATUS.When':
  776. case 'COIN.Current Block Time':
  777. $ret = date($dfmt, $value);
  778. break;
  779. case 'BUTTON.Rig':
  780. case 'BUTTON.Pool':
  781. case 'BUTTON.GPU':
  782. $ret = $value;
  783. break;
  784. }
  785. if ($section == 'NOTIFY' && substr($name, 0, 1) == '*' && $value != '0')
  786. $class = $errorclass;
  787. if ($class == '' && $section != 'POOL')
  788. $class = classlastshare($when, $alldata, $lstclass, $lstclass);
  789. if ($class == '' && $section == 'total')
  790. $class = $totclass;
  791. if ($class == '' && ($rownum % 2) == 0)
  792. $class = $c2class;
  793. if ($ret === '')
  794. $ret = $b;
  795. return array($ret, $class);
  796. }
  797. #
  798. global $poolcmd;
  799. $poolcmd = array( 'Switch to' => 'switchpool',
  800. 'Enable' => 'enablepool',
  801. 'Disable' => 'disablepool',
  802. 'Remove' => 'removepool' );
  803. #
  804. function showhead($cmd, $values, $justnames = false)
  805. {
  806. global $poolcmd, $readonly;
  807. newrow();
  808. foreach ($values as $name => $value)
  809. {
  810. if ($name == '0' or $name == '')
  811. $name = '&nbsp;';
  812. echo "<td valign=bottom class=h>$name</td>";
  813. }
  814. if ($justnames === false && $cmd == 'pools' && $readonly === false)
  815. foreach ($poolcmd as $name => $pcmd)
  816. echo "<td valign=bottom class=h>$name</td>";
  817. endrow();
  818. }
  819. #
  820. function showdatetime()
  821. {
  822. global $dfmt;
  823. otherrow('<td class=sta>Date: '.date($dfmt).'</td>');
  824. }
  825. #
  826. global $singlerigsum;
  827. $singlerigsum = array(
  828. 'devs' => array('MHS av' => 1, 'MHS 5s' => 1, 'Accepted' => 1, 'Rejected' => 1,
  829. 'Hardware Errors' => 1, 'Utility' => 1, 'Total MH' => 1),
  830. 'pools' => array('Getworks' => 1, 'Accepted' => 1, 'Rejected' => 1, 'Discarded' => 1,
  831. 'Stale' => 1, 'Get Failures' => 1, 'Remote Failures' => 1,
  832. 'Diff1 Shares' => 1),
  833. 'notify' => array('*' => 1));
  834. #
  835. function showtotal($total, $when, $oldvalues)
  836. {
  837. global $rigtotals;
  838. list($showvalue, $class) = fmt('total', '', 'Total:', $when, null);
  839. echo "<td$class align=right>$showvalue</td>";
  840. $skipfirst = true;
  841. foreach ($oldvalues as $name => $value)
  842. {
  843. if ($skipfirst === true)
  844. {
  845. $skipfirst = false;
  846. continue;
  847. }
  848. if (isset($total[$name]))
  849. $newvalue = $total[$name];
  850. else
  851. $newvalue = '';
  852. list($showvalue, $class) = fmt('total', $name, $newvalue, $when, null);
  853. echo "<td$class";
  854. if ($rigtotals === true)
  855. echo ' align=right';
  856. echo ">$showvalue</td>";
  857. }
  858. }
  859. #
  860. function details($cmd, $list, $rig)
  861. {
  862. global $dfmt, $poolcmd, $readonly, $showndate;
  863. global $rownum, $rigtotals, $forcerigtotals, $singlerigsum;
  864. $when = 0;
  865. $stas = array('S' => 'Success', 'W' => 'Warning', 'I' => 'Informational', 'E' => 'Error', 'F' => 'Fatal');
  866. newtable();
  867. if ($showndate === false)
  868. {
  869. showdatetime();
  870. endtable();
  871. newtable();
  872. $showndate = true;
  873. }
  874. if (isset($list['STATUS']))
  875. {
  876. newrow();
  877. echo '<td>Computer: '.$list['STATUS']['Description'].'</td>';
  878. if (isset($list['STATUS']['When']))
  879. {
  880. echo '<td>When: '.date($dfmt, $list['STATUS']['When']).'</td>';
  881. $when = $list['STATUS']['When'];
  882. }
  883. $sta = $list['STATUS']['STATUS'];
  884. echo '<td>Status: '.$stas[$sta].'</td>';
  885. echo '<td>Message: '.$list['STATUS']['Msg'].'</td>';
  886. endrow();
  887. }
  888. if ($rigtotals === true && isset($singlerigsum[$cmd]))
  889. $dototal = $singlerigsum[$cmd];
  890. else
  891. $dototal = array();
  892. $total = array();
  893. $section = '';
  894. $oldvalues = null;
  895. foreach ($list as $item => $values)
  896. {
  897. if ($item == 'STATUS')
  898. continue;
  899. $sectionname = preg_replace('/\d/', '', $item);
  900. // Handle 'devs' possibly containing >1 table
  901. if ($sectionname != $section)
  902. {
  903. if ($oldvalues != null && count($total) > 0
  904. && ($rownum > 2 || $forcerigtotals === true))
  905. showtotal($total, $when, $oldvalues);
  906. endtable();
  907. newtable();
  908. showhead($cmd, $values);
  909. $section = $sectionname;
  910. }
  911. newrow();
  912. foreach ($values as $name => $value)
  913. {
  914. list($showvalue, $class) = fmt($section, $name, $value, $when, $values);
  915. echo "<td$class";
  916. if ($rigtotals === true)
  917. echo ' align=right';
  918. echo ">$showvalue</td>";
  919. if (isset($dototal[$name])
  920. || (isset($dototal['*']) and substr($name, 0, 1) == '*'))
  921. {
  922. if (isset($total[$name]))
  923. $total[$name] += $value;
  924. else
  925. $total[$name] = $value;
  926. }
  927. }
  928. if ($cmd == 'pools' && $readonly === false)
  929. {
  930. reset($values);
  931. $pool = current($values);
  932. foreach ($poolcmd as $name => $pcmd)
  933. {
  934. list($ignore, $class) = fmt('BUTTON', 'Pool', '', $when, $values);
  935. echo "<td$class>";
  936. if ($pool === false)
  937. echo '&nbsp;';
  938. else
  939. {
  940. echo "<input type=button value='Pool $pool'";
  941. echo " onclick='prc(\"$pcmd|$pool&rig=$rig\",\"$name Pool $pool\")'>";
  942. }
  943. echo '</td>';
  944. }
  945. }
  946. endrow();
  947. $oldvalues = $values;
  948. }
  949. if ($oldvalues != null && count($total) > 0
  950. && ($rownum > 2 || $forcerigtotals === true))
  951. showtotal($total, $when, $oldvalues);
  952. endtable();
  953. }
  954. #
  955. global $devs;
  956. $devs = null;
  957. #
  958. function gpubuttons($count, $rig)
  959. {
  960. global $devs;
  961. $basic = array( 'GPU', 'Enable', 'Disable', 'Restart' );
  962. $options = array( 'intensity' => 'Intensity',
  963. 'fan' => 'Fan Percent',
  964. 'engine' => 'GPU Clock',
  965. 'mem' => 'Memory Clock',
  966. 'vddc' => 'GPU Voltage' );
  967. newtable();
  968. newrow();
  969. foreach ($basic as $head)
  970. echo "<td class=h>$head</td>";
  971. foreach ($options as $name => $des)
  972. echo "<td class=h nowrap>$des</td>";
  973. $n = 0;
  974. for ($c = 0; $c < $count; $c++)
  975. {
  976. endrow();
  977. newrow();
  978. foreach ($basic as $name)
  979. {
  980. list($ignore, $class) = fmt('BUTTON', 'GPU', '', 0, null);
  981. echo "<td$class>";
  982. if ($name == 'GPU')
  983. echo $c;
  984. else
  985. {
  986. echo "<input type=button value='$name $c' onclick='prs(\"gpu";
  987. echo strtolower($name);
  988. echo "|$c\",$rig)'>";
  989. }
  990. echo '</td>';
  991. }
  992. foreach ($options as $name => $des)
  993. {
  994. list($ignore, $class) = fmt('BUTTON', 'GPU', '', 0, null);
  995. echo "<td$class>";
  996. if (!isset($devs["GPU$c"][$des]))
  997. echo '&nbsp;';
  998. else
  999. {
  1000. $value = $devs["GPU$c"][$des];
  1001. echo "<input type=button value='Set $c:' onclick='prs2(\"gpu$name|$c\",$n,$rig)'>";
  1002. echo "<input size=7 type=text name=gi$n value='$value' id=gi$n>";
  1003. $n++;
  1004. }
  1005. echo '</td>';
  1006. }
  1007. }
  1008. endrow();
  1009. endtable();
  1010. }
  1011. #
  1012. function processgpus($rig)
  1013. {
  1014. global $error;
  1015. global $warnfont, $warnoff;
  1016. $gpus = api($rig, 'gpucount');
  1017. if ($error != null)
  1018. otherrow("<td>Error getting GPU count: $warnfont$error$warnoff</td>");
  1019. else
  1020. {
  1021. if (!isset($gpus['GPUS']['Count']))
  1022. {
  1023. $rw = '<td>No GPU count returned: '.$warnfont;
  1024. $rw .= $gpus['STATUS']['STATUS'].' '.$gpus['STATUS']['Msg'];
  1025. $rw .= $warnoff.'</td>';
  1026. otherrow($rw);
  1027. }
  1028. else
  1029. {
  1030. $count = $gpus['GPUS']['Count'];
  1031. if ($count == 0)
  1032. otherrow('<td>No GPUs</td>');
  1033. else
  1034. gpubuttons($count, $rig);
  1035. }
  1036. }
  1037. }
  1038. #
  1039. function showpoolinputs($rig, $ans)
  1040. {
  1041. global $readonly, $poolinputs;
  1042. if ($readonly === true || $poolinputs === false)
  1043. return;
  1044. newtable();
  1045. newrow();
  1046. $inps = array('Pool URL' => array('purl', 20),
  1047. 'Worker Name' => array('pwork', 10),
  1048. 'Worker Password' => array('ppass', 10));
  1049. $b = '&nbsp;';
  1050. echo "<td align=right class=h> Add a pool: </td><td>";
  1051. foreach ($inps as $text => $name)
  1052. echo "$text: <input name='".$name[0]."' id='".$name[0]."' value='' type=text size=".$name[1]."> ";
  1053. echo "</td><td align=middle><input type=button value='Add' onclick='pla($rig)'></td>";
  1054. endrow();
  1055. if (count($ans) > 1)
  1056. {
  1057. newrow();
  1058. echo '<td align=right class=h> Set pool priorities: </td>';
  1059. echo "<td> Comma list of pool numbers: <input type=text name=prio id=prio size=20>";
  1060. echo "</td><td align=middle><input type=button value='Set' onclick='psp($rig)'></td>";
  1061. endrow();
  1062. }
  1063. endtable();
  1064. }
  1065. #
  1066. function process($cmds, $rig)
  1067. {
  1068. global $error, $devs;
  1069. global $warnfont, $warnoff;
  1070. $count = count($cmds);
  1071. foreach ($cmds as $cmd => $des)
  1072. {
  1073. $process = api($rig, $cmd);
  1074. if ($error != null)
  1075. {
  1076. otherrow("<td colspan=100>Error getting $des: $warnfont$error$warnoff</td>");
  1077. break;
  1078. }
  1079. else
  1080. {
  1081. details($cmd, $process, $rig);
  1082. if ($cmd == 'devs')
  1083. $devs = $process;
  1084. if ($cmd == 'pools')
  1085. showpoolinputs($rig, $process);
  1086. # Not after the last one
  1087. if (--$count > 0)
  1088. otherrow('<td><br><br></td>');
  1089. }
  1090. }
  1091. }
  1092. #
  1093. function rigbutton($rig, $rigname, $when, $row)
  1094. {
  1095. global $rigs;
  1096. if (isset($rigs[$rig]))
  1097. {
  1098. $parts = explode(':', $rigs[$rig], 3);
  1099. if (count($parts) == 3)
  1100. $rigname = $parts[2];
  1101. }
  1102. list($value, $class) = fmt('BUTTON', 'Rig', '', $when, $row);
  1103. $button = "<td align=middle$class><input type=button value='$rigname'";
  1104. $button .= " onclick='pr(\"&rig=$rig\",null)'></td>";
  1105. return $button;
  1106. }
  1107. #
  1108. function showrigs($anss, $headname, $rigname)
  1109. {
  1110. $dthead = array($headname => 1, 'STATUS' => 1, 'Description' => 1, 'When' => 1, 'API' => 1, 'CGMiner' => 1);
  1111. showhead('', $dthead);
  1112. foreach ($anss as $rig => $ans)
  1113. {
  1114. if ($ans == null)
  1115. continue;
  1116. newrow();
  1117. $when = 0;
  1118. if (isset($ans['STATUS']['When']))
  1119. $when = $ans['STATUS']['When'];
  1120. foreach ($ans as $item => $row)
  1121. {
  1122. if ($item != 'STATUS' && $item != 'VERSION')
  1123. continue;
  1124. foreach ($dthead as $name => $x)
  1125. {
  1126. if ($item == 'STATUS' && $name == $headname)
  1127. echo rigbutton($rig, $rigname.$rig, $when, null);
  1128. else
  1129. {
  1130. if (isset($row[$name]))
  1131. {
  1132. list($showvalue, $class) = fmt('STATUS', $name, $row[$name], $when, null);
  1133. echo "<td$class align=right>$showvalue</td>";
  1134. }
  1135. }
  1136. }
  1137. }
  1138. endrow();
  1139. }
  1140. }
  1141. #
  1142. # $head is a hack but this is just a demo anyway :)
  1143. function doforeach($cmd, $des, $sum, $head, $datetime)
  1144. {
  1145. global $miner, $port;
  1146. global $error, $readonly, $notify, $rigs;
  1147. global $warnfont, $warnoff, $dfmt;
  1148. global $rigerror;
  1149. $when = 0;
  1150. $header = $head;
  1151. $anss = array();
  1152. $count = 0;
  1153. $preverr = count($rigerror);
  1154. foreach ($rigs as $num => $rig)
  1155. {
  1156. $anss[$num] = null;
  1157. if (isset($rigerror[$rig]))
  1158. continue;
  1159. $parts = explode(':', $rig, 3);
  1160. if (count($parts) >= 2)
  1161. {
  1162. $miner = $parts[0];
  1163. $port = $parts[1];
  1164. if (count($parts) > 2)
  1165. $name = $parts[2];
  1166. else
  1167. $name = $num;
  1168. $ans = api($name, $cmd);
  1169. if ($error != null)
  1170. {
  1171. $rw = "<td colspan=100>Error on rig $name getting ";
  1172. $rw .= "$des: $warnfont$error$warnoff</td>";
  1173. otherrow($rw);
  1174. $rigerror[$rig] = $error;
  1175. $error = null;
  1176. }
  1177. else
  1178. {
  1179. $anss[$num] = $ans;
  1180. $count++;
  1181. }
  1182. }
  1183. }
  1184. if ($count == 0)
  1185. {
  1186. $rw = '<td>Failed to access any rigs successfully';
  1187. if ($preverr > 0)
  1188. $rw .= ' (or rigs had previous errors)';
  1189. $rw .= '</td>';
  1190. otherrow($rw);
  1191. return;
  1192. }
  1193. if ($datetime)
  1194. {
  1195. showdatetime();
  1196. endtable();
  1197. newtable();
  1198. showrigs($anss, '', 'Rig ');
  1199. endtable();
  1200. otherrow('<td><br><br></td>');
  1201. newtable();
  1202. return;
  1203. }
  1204. $total = array();
  1205. foreach ($anss as $rig => $ans)
  1206. {
  1207. if ($ans == null)
  1208. continue;
  1209. foreach ($ans as $item => $row)
  1210. {
  1211. if ($item == 'STATUS')
  1212. continue;
  1213. if (count($row) > count($header))
  1214. {
  1215. $header = $head;
  1216. foreach ($row as $name => $value)
  1217. if (!isset($header[$name]))
  1218. $header[$name] = '';
  1219. }
  1220. if ($sum != null)
  1221. foreach ($sum as $name)
  1222. {
  1223. if (isset($row[$name]))
  1224. {
  1225. if (isset($total[$name]))
  1226. $total[$name] += $row[$name];
  1227. else
  1228. $total[$name] = $row[$name];
  1229. }
  1230. }
  1231. }
  1232. }
  1233. if ($sum != null)
  1234. $anss['total']['total'] = $total;
  1235. showhead('', $header);
  1236. foreach ($anss as $rig => $ans)
  1237. {
  1238. if ($ans == null)
  1239. continue;
  1240. $when = 0;
  1241. if (isset($ans['STATUS']['When']))
  1242. $when = $ans['STATUS']['When'];
  1243. foreach ($ans as $item => $row)
  1244. {
  1245. if ($item == 'STATUS')
  1246. continue;
  1247. newrow();
  1248. $section = preg_replace('/\d/', '', $item);
  1249. foreach ($header as $name => $x)
  1250. {
  1251. if ($name == '')
  1252. {
  1253. if ($rig === 'total')
  1254. {
  1255. list($ignore, $class) = fmt($rig, '', '', $when, $row);
  1256. echo "<td align=right$class>Total:</td>";
  1257. }
  1258. else
  1259. echo rigbutton($rig, "Rig $rig", $when, $row);
  1260. }
  1261. else
  1262. {
  1263. if (isset($row[$name]))
  1264. $value = $row[$name];
  1265. else
  1266. $value = null;
  1267. list($showvalue, $class) = fmt($section, $name, $value, $when, $row);
  1268. echo "<td$class align=right>$showvalue</td>";
  1269. }
  1270. }
  1271. endrow();
  1272. }
  1273. }
  1274. }
  1275. #
  1276. function refreshbuttons()
  1277. {
  1278. global $readonly;
  1279. global $ignorerefresh, $changerefresh, $autorefresh;
  1280. if ($ignorerefresh == false && $changerefresh == true)
  1281. {
  1282. echo '&nbsp;&nbsp;&nbsp;&nbsp;';
  1283. echo "<input type=button value='Auto Refresh:' onclick='prr(true)'>";
  1284. echo "<input type=text name='refval' id='refval' size=2 value='$autorefresh'>";
  1285. echo "<input type=button value='Off' onclick='prr(false)'>";
  1286. }
  1287. }
  1288. #
  1289. function pagebuttons($rig, $pg)
  1290. {
  1291. global $readonly, $rigs;
  1292. global $allowcustompages, $customsummarypages;
  1293. if ($rig === null)
  1294. {
  1295. if ($pg === null)
  1296. $refresh = '';
  1297. else
  1298. $refresh = "&pg=$pg";
  1299. }
  1300. else
  1301. $refresh = "&rig=$rig";
  1302. echo '<tr><td><table cellpadding=0 cellspacing=0 border=0><tr><td nowrap>';
  1303. echo "<input type=button value='Refresh' onclick='pr(\"$refresh\",null)'>&nbsp;";
  1304. if (count($rigs) > 1)
  1305. echo "<input type=button value='Summary' onclick='pr(\"\",null)'>&nbsp;";
  1306. if ($allowcustompages === true)
  1307. foreach ($customsummarypages as $pagename => $data)
  1308. echo "<input type=button value='$pagename' onclick='pr(\"&pg=$pagename\",null)'>&nbsp;";
  1309. echo '</td><td width=100%>&nbsp;</td><td nowrap>';
  1310. if ($rig !== null && $readonly === false)
  1311. {
  1312. $rg = '';
  1313. if (count($rigs) > 1)
  1314. $rg = " Rig $rig";
  1315. echo "<input type=button value='Restart' onclick='prc(\"restart&rig=$rig\",\"Restart CGMiner$rg\")'>";
  1316. echo "&nbsp;<input type=button value='Quit' onclick='prc(\"quit&rig=$rig\",\"Quit CGMiner$rg\")'>";
  1317. }
  1318. refreshbuttons();
  1319. echo "</td></tr></table></td></tr>";
  1320. }
  1321. #
  1322. function doOne($rig, $preprocess)
  1323. {
  1324. global $haderror, $readonly, $notify, $rigs;
  1325. global $placebuttons;
  1326. htmlhead(true, $rig);
  1327. if ($placebuttons == 'top' || $placebuttons == 'both')
  1328. pagebuttons($rig, null);
  1329. if ($preprocess != null)
  1330. process(array($preprocess => $preprocess), $rig);
  1331. $cmds = array( 'devs' => 'device list',
  1332. 'summary' => 'summary information',
  1333. 'pools' => 'pool list');
  1334. if ($notify)
  1335. $cmds['notify'] = 'device status';
  1336. $cmds['config'] = 'cgminer config';
  1337. process($cmds, $rig);
  1338. if ($haderror == false && $readonly === false)
  1339. processgpus($rig);
  1340. if ($placebuttons == 'bot' || $placebuttons == 'both')
  1341. pagebuttons($rig, null);
  1342. }
  1343. #
  1344. global $sectionmap;
  1345. # map sections to their api command
  1346. # DEVS is a special case that will match GPU or PGA
  1347. # so you can have a single table with both in it
  1348. # DATE is hard coded so not in here
  1349. $sectionmap = array(
  1350. 'RIGS' => 'version',
  1351. 'SUMMARY' => 'summary',
  1352. 'POOL' => 'pools',
  1353. 'DEVS' => 'devs',
  1354. 'GPU' => 'devs', // You would normally use DEVS
  1355. 'PGA' => 'devs', // You would normally use DEVS
  1356. 'NOTIFY' => 'notify',
  1357. 'DEVDETAILS' => 'devdetails',
  1358. 'STATS' => 'stats',
  1359. 'CONFIG' => 'config',
  1360. 'COIN' => 'coin');
  1361. #
  1362. function joinfields($section1, $section2, $join, $results)
  1363. {
  1364. global $sectionmap;
  1365. $name1 = $sectionmap[$section1];
  1366. $name2 = $sectionmap[$section2];
  1367. $newres = array();
  1368. // foreach rig in section1
  1369. foreach ($results[$name1] as $rig => $result)
  1370. {
  1371. $status = null;
  1372. // foreach answer section in the rig api call
  1373. foreach ($result as $name1b => $fields1b)
  1374. {
  1375. if ($name1b == 'STATUS')
  1376. {
  1377. // remember the STATUS from section1
  1378. $status = $result[$name1b];
  1379. continue;
  1380. }
  1381. // foreach answer section in the rig api call (for the other api command)
  1382. foreach ($results[$name2][$rig] as $name2b => $fields2b)
  1383. {
  1384. if ($name2b == 'STATUS')
  1385. continue;
  1386. // If match the same field values of fields in $join
  1387. $match = true;
  1388. foreach ($join as $field)
  1389. if ($fields1b[$field] != $fields2b[$field])
  1390. {
  1391. $match = false;
  1392. break;
  1393. }
  1394. if ($match === true)
  1395. {
  1396. if ($status != null)
  1397. {
  1398. $newres[$rig]['STATUS'] = $status;
  1399. $status = null;
  1400. }
  1401. $subsection = $section1.'+'.$section2;
  1402. $subsection .= preg_replace('/[^0-9]/', '', $name1b.$name2b);
  1403. foreach ($fields1b as $nam => $val)
  1404. $newres[$rig][$subsection]["$section1.$nam"] = $val;
  1405. foreach ($fields2b as $nam => $val)
  1406. $newres[$rig][$subsection]["$section2.$nam"] = $val;
  1407. }
  1408. }
  1409. }
  1410. }
  1411. return $newres;
  1412. }
  1413. #
  1414. function joinall($section1, $section2, $results)
  1415. {
  1416. global $sectionmap;
  1417. $name1 = $sectionmap[$section1];
  1418. $name2 = $sectionmap[$section2];
  1419. $newres = array();
  1420. // foreach rig in section1
  1421. foreach ($results[$name1] as $rig => $result)
  1422. {
  1423. // foreach answer section in the rig api call
  1424. foreach ($result as $name1b => $fields1b)
  1425. {
  1426. if ($name1b == 'STATUS')
  1427. {
  1428. // copy the STATUS from section1
  1429. $newres[$rig][$name1b] = $result[$name1b];
  1430. continue;
  1431. }
  1432. // foreach answer section in the rig api call (for the other api command)
  1433. foreach ($results[$name2][$rig] as $name2b => $fields2b)
  1434. {
  1435. if ($name2b == 'STATUS')
  1436. continue;
  1437. $subsection = $section1.'+'.$section2;
  1438. $subsection .= preg_replace('/[^0-9]/', '', $name1b.$name2b);
  1439. foreach ($fields1b as $nam => $val)
  1440. $newres[$rig][$subsection]["$section1.$nam"] = $val;
  1441. foreach ($fields2b as $nam => $val)
  1442. $newres[$rig][$subsection]["$section2.$nam"] = $val;
  1443. }
  1444. }
  1445. }
  1446. return $newres;
  1447. }
  1448. #
  1449. function joinsections($sections, $results, $errors)
  1450. {
  1451. global $sectionmap;
  1452. #echo "results['pools']=".print_r($results['pools'],true)."<br>";
  1453. // GPU's don't have Name,ID fields - so create them
  1454. foreach ($results as $section => $res)
  1455. foreach ($res as $rig => $result)
  1456. foreach ($result as $name => $fields)
  1457. {
  1458. $subname = preg_replace('/[0-9]/', '', $name);
  1459. if ($subname == 'GPU' and isset($result[$name]['GPU']))
  1460. {
  1461. $results[$section][$rig][$name]['Name'] = 'GPU';
  1462. $results[$section][$rig][$name]['ID'] = $result[$name]['GPU'];
  1463. }
  1464. }
  1465. foreach ($sections as $section => $fields)
  1466. if ($section != 'DATE' && !isset($sectionmap[$section]))
  1467. {
  1468. $both = explode('+', $section, 2);
  1469. if (count($both) > 1)
  1470. {
  1471. switch($both[0])
  1472. {
  1473. case 'SUMMARY':
  1474. switch($both[1])
  1475. {
  1476. case 'POOL':
  1477. case 'DEVS':
  1478. case 'CONFIG':
  1479. case 'COIN':
  1480. $sectionmap[$section] = $section;
  1481. $results[$section] = joinall($both[0], $both[1], $results);
  1482. break;
  1483. default:
  1484. $errors[] = "Error: Invalid section '$section'";
  1485. break;
  1486. }
  1487. break;
  1488. case 'DEVS':
  1489. $join = array('Name', 'ID');
  1490. switch($both[1])
  1491. {
  1492. case 'NOTIFY':
  1493. case 'DEVDETAILS':
  1494. $sectionmap[$section] = $section;
  1495. $results[$section] = joinfields($both[0], $both[1], $join, $results);
  1496. break;
  1497. default:
  1498. $errors[] = "Error: Invalid section '$section'";
  1499. break;
  1500. }
  1501. break;
  1502. default:
  1503. $errors[] = "Error: Invalid section '$section'";
  1504. break;
  1505. }
  1506. }
  1507. else
  1508. $errors[] = "Error: Invalid section '$section'";
  1509. }
  1510. return array($results, $errors);
  1511. }
  1512. #
  1513. function secmatch($section, $field)
  1514. {
  1515. if ($section == $field)
  1516. return true;
  1517. if ($section == 'DEVS'
  1518. && ($field == 'GPU' || $field == 'PGA'))
  1519. return true;
  1520. return false;
  1521. }
  1522. #
  1523. function customset($showfields, $sum, $section, $rig, $isbutton, $result, $total)
  1524. {
  1525. foreach ($result as $sec => $row)
  1526. {
  1527. $secname = preg_replace('/\d/', '', $sec);
  1528. if ($sec != 'total')
  1529. if (!secmatch($section, $secname))
  1530. continue;
  1531. newrow();
  1532. $when = 0;
  1533. if (isset($result['STATUS']['When']))
  1534. $when = $result['STATUS']['When'];
  1535. if ($isbutton)
  1536. echo rigbutton($rig, $rig, $when, $row);
  1537. else
  1538. {
  1539. list($ignore, $class) = fmt('total', '', '', $when, $row);
  1540. echo "<td align=middle$class>$rig</td>";
  1541. }
  1542. foreach ($showfields as $name => $one)
  1543. {
  1544. if (isset($row[$name]))
  1545. {
  1546. $value = $row[$name];
  1547. if (isset($sum[$section][$name]))
  1548. {
  1549. if (isset($total[$name]))
  1550. $total[$name] += $value;
  1551. else
  1552. $total[$name] = $value;
  1553. }
  1554. }
  1555. else
  1556. {
  1557. if ($sec == 'total' && isset($total[$name]))
  1558. $value = $total[$name];
  1559. else
  1560. $value = null;
  1561. }
  1562. if (strpos($secname, '+') === false)
  1563. list($showvalue, $class) = fmt($secname, $name, $value, $when, $row);
  1564. else
  1565. {
  1566. $parts = explode('.', $name, 2);
  1567. list($showvalue, $class) = fmt($parts[0], $parts[1], $value, $when, $row);
  1568. }
  1569. echo "<td$class align=right>$showvalue</td>";
  1570. }
  1571. endrow();
  1572. }
  1573. return $total;
  1574. }
  1575. #
  1576. function processcustompage($pagename, $sections, $sum, $namemap)
  1577. {
  1578. global $sectionmap;
  1579. global $miner, $port;
  1580. global $rigs, $error;
  1581. global $warnfont, $warnoff;
  1582. global $dfmt;
  1583. global $readonly, $showndate;
  1584. $cmds = array();
  1585. $errors = array();
  1586. foreach ($sections as $section => $fields)
  1587. {
  1588. $all = explode('+', $section);
  1589. foreach ($all as $section)
  1590. {
  1591. if (isset($sectionmap[$section]))
  1592. {
  1593. $cmd = $sectionmap[$section];
  1594. if (!isset($cmds[$cmd]))
  1595. $cmds[$cmd] = 1;
  1596. }
  1597. else
  1598. if ($section != 'DATE')
  1599. $errors[] = "Error: unknown section '$section' in custom summary page '$pagename'";
  1600. }
  1601. }
  1602. $results = array();
  1603. foreach ($rigs as $num => $rig)
  1604. {
  1605. $parts = explode(':', $rig, 3);
  1606. if (count($parts) >= 2)
  1607. {
  1608. $miner = $parts[0];
  1609. $port = $parts[1];
  1610. if (count($parts) > 2)
  1611. $name = $parts[2];
  1612. else
  1613. $name = $rig;
  1614. foreach ($cmds as $cmd => $one)
  1615. {
  1616. $process = api($name, $cmd);
  1617. if ($error != null)
  1618. {
  1619. $errors[] = "Error getting $cmd for $name $warnfont$error$warnoff";
  1620. break;
  1621. }
  1622. else
  1623. $results[$cmd][$num] = $process;
  1624. }
  1625. }
  1626. }
  1627. $shownsomething = false;
  1628. if (count($results) > 0)
  1629. {
  1630. list($results, $errors) = joinsections($sections, $results, $errors);
  1631. $first = true;
  1632. foreach ($sections as $section => $fields)
  1633. {
  1634. if ($section === 'DATE')
  1635. {
  1636. if ($shownsomething)
  1637. otherrow('<td>&nbsp;</td>');
  1638. newtable();
  1639. showdatetime();
  1640. endtable();
  1641. // On top of the next table
  1642. $shownsomething = false;
  1643. continue;
  1644. }
  1645. if ($section === 'RIGS')
  1646. {
  1647. if ($shownsomething)
  1648. otherrow('<td>&nbsp;</td>');
  1649. newtable();
  1650. showrigs($results['version'], 'Rig', '');
  1651. endtable();
  1652. $shownsomething = true;
  1653. continue;
  1654. }
  1655. if (isset($results[$sectionmap[$section]]))
  1656. {
  1657. $rigresults = $results[$sectionmap[$section]];
  1658. $showfields = array();
  1659. $showhead = array();
  1660. foreach ($fields as $field)
  1661. foreach ($rigresults as $result)
  1662. foreach ($result as $sec => $row)
  1663. {
  1664. $secname = preg_replace('/\d/', '', $sec);
  1665. if (secmatch($section, $secname))
  1666. {
  1667. if ($field === '*')
  1668. {
  1669. foreach ($row as $f => $v)
  1670. {
  1671. $showfields[$f] = 1;
  1672. $map = $section.'.'.$f;
  1673. if (isset($namemap[$map]))
  1674. $showhead[$namemap[$map]] = 1;
  1675. else
  1676. $showhead[$f] = 1;
  1677. }
  1678. }
  1679. elseif (isset($row[$field]))
  1680. {
  1681. $showfields[$field] = 1;
  1682. $map = $section.'.'.$field;
  1683. if (isset($namemap[$map]))
  1684. $showhead[$namemap[$map]] = 1;
  1685. else
  1686. $showhead[$field] = 1;
  1687. }
  1688. }
  1689. }
  1690. if (count($showfields) > 0)
  1691. {
  1692. if ($shownsomething)
  1693. otherrow('<td>&nbsp;</td>');
  1694. newtable();
  1695. showhead('', array('Rig'=>1)+$showhead, true);
  1696. $total = array();
  1697. $add = array('total' => array());
  1698. foreach ($rigresults as $num => $result)
  1699. $total = customset($showfields, $sum, $section, $num, true, $result, $total);
  1700. if (count($total) > 0)
  1701. customset($showfields, $sum, $section, '&Sigma;', false, $add, $total);
  1702. $first = false;
  1703. endtable();
  1704. $shownsomething = true;
  1705. }
  1706. }
  1707. }
  1708. }
  1709. if (count($errors) > 0)
  1710. {
  1711. if (count($results) > 0)
  1712. otherrow('<td>&nbsp;</td>');
  1713. foreach ($errors as $err)
  1714. otherrow("<td colspan=100>$err</td>");
  1715. }
  1716. }
  1717. #
  1718. function showcustompage($pagename)
  1719. {
  1720. global $customsummarypages;
  1721. global $placebuttons;
  1722. htmlhead(false, null, $pagename);
  1723. if ($placebuttons == 'top' || $placebuttons == 'both')
  1724. pagebuttons(null, $pagename);
  1725. if (!isset($customsummarypages[$pagename]))
  1726. {
  1727. otherrow("<td colspan=100>Unknown custom summary page '$pagename'</td>");
  1728. return;
  1729. }
  1730. if (count($customsummarypages[$pagename]) != 2)
  1731. {
  1732. $rw = "<td colspan=100>Invalid custom summary page '$pagename' (";
  1733. $rw .= count($customsummarypages[$pagename]).')</td>';
  1734. otherrow($rw);
  1735. return;
  1736. }
  1737. $page = $customsummarypages[$pagename][0];
  1738. $namemap = array();
  1739. foreach ($page as $name => $fields)
  1740. {
  1741. if ($fields === null)
  1742. $page[$name] = array();
  1743. else
  1744. foreach ($fields as $num => $field)
  1745. {
  1746. $pos = strpos($field, '=');
  1747. if ($pos !== false)
  1748. {
  1749. $names = explode('=', $field, 2);
  1750. if (strlen($names[1]) > 0)
  1751. $namemap[$name.'.'.$names[0]] = $names[1];
  1752. $page[$name][$num] = $names[0];
  1753. }
  1754. }
  1755. }
  1756. $sum = $customsummarypages[$pagename][1];
  1757. if ($sum === null)
  1758. $sum = array();
  1759. // convert them to searchable via isset()
  1760. foreach ($sum as $section => $fields)
  1761. {
  1762. $newfields = array();
  1763. foreach ($fields as $field)
  1764. $newfields[$field] = 1;
  1765. $sum[$section] = $newfields;
  1766. }
  1767. if (count($page) <= 1)
  1768. {
  1769. otherrow("<td colspan=100>Invalid custom summary page '$pagename' no content </td>");
  1770. return;
  1771. }
  1772. processcustompage($pagename, $page, $sum, $namemap);
  1773. if ($placebuttons == 'bot' || $placebuttons == 'both')
  1774. pagebuttons(null, $pagename);
  1775. }
  1776. #
  1777. function display()
  1778. {
  1779. global $miner, $port;
  1780. global $readonly, $notify, $rigs;
  1781. global $ignorerefresh, $autorefresh;
  1782. global $allowcustompages;
  1783. global $placebuttons;
  1784. if ($ignorerefresh == false)
  1785. {
  1786. $ref = trim(getparam('ref', true));
  1787. if ($ref != null && $ref != '')
  1788. $autorefresh = intval($ref);
  1789. }
  1790. $rig = trim(getparam('rig', true));
  1791. $arg = trim(getparam('arg', true));
  1792. $preprocess = null;
  1793. if ($arg != null and $arg != '')
  1794. {
  1795. $num = null;
  1796. if ($rig != null and $rig != '')
  1797. {
  1798. if ($rig >= 0 and $rig < count($rigs))
  1799. $num = $rig;
  1800. }
  1801. else
  1802. if (count($rigs) == 0)
  1803. $num = 0;
  1804. if ($num != null)
  1805. {
  1806. $parts = explode(':', $rigs[$num], 3);
  1807. if (count($parts) >= 2)
  1808. {
  1809. $miner = $parts[0];
  1810. $port = $parts[1];
  1811. if ($readonly !== true)
  1812. $preprocess = $arg;
  1813. }
  1814. }
  1815. }
  1816. if ($rigs == null or count($rigs) == 0)
  1817. {
  1818. otherrow("<td>No rigs defined</td>");
  1819. return;
  1820. }
  1821. if ($allowcustompages === true)
  1822. {
  1823. $pg = trim(getparam('pg', true));
  1824. if ($pg != null && $pg != '')
  1825. {
  1826. showcustompage($pg);
  1827. return;
  1828. }
  1829. }
  1830. if (count($rigs) == 1)
  1831. {
  1832. $parts = explode(':', $rigs[0], 3);
  1833. if (count($parts) >= 2)
  1834. {
  1835. $miner = $parts[0];
  1836. $port = $parts[1];
  1837. doOne(0, $preprocess);
  1838. }
  1839. else
  1840. otherrow('<td>Invalid "$rigs" array</td>');
  1841. return;
  1842. }
  1843. if ($rig != null and $rig != '' and $rig >= 0 and $rig < count($rigs))
  1844. {
  1845. $parts = explode(':', $rigs[$rig], 3);
  1846. if (count($parts) >= 2)
  1847. {
  1848. $miner = $parts[0];
  1849. $port = $parts[1];
  1850. doOne($rig, $preprocess);
  1851. }
  1852. else
  1853. otherrow('<td>Invalid "$rigs" array</td>');
  1854. return;
  1855. }
  1856. htmlhead(false, null);
  1857. if ($placebuttons == 'top' || $placebuttons == 'both')
  1858. pagebuttons(null, null);
  1859. if ($preprocess != null)
  1860. process(array($preprocess => $preprocess), $rig);
  1861. newtable();
  1862. doforeach('version', 'rig summary', array(), array(), true);
  1863. $sum = array('MHS av', 'Getworks', 'Found Blocks', 'Accepted', 'Rejected', 'Discarded', 'Stale', 'Utility', 'Local Work', 'Total MH', 'Work Utility', 'Diff1 Shares', 'Diff1 Work');
  1864. doforeach('summary', 'summary information', $sum, array(), false);
  1865. endtable();
  1866. otherrow('<td><br><br></td>');
  1867. newtable();
  1868. doforeach('devs', 'device list', $sum, array(''=>'','ID'=>'','Name'=>''), false);
  1869. endtable();
  1870. otherrow('<td><br><br></td>');
  1871. newtable();
  1872. doforeach('pools', 'pool list', $sum, array(''=>''), false);
  1873. endtable();
  1874. if ($placebuttons == 'bot' || $placebuttons == 'both')
  1875. pagebuttons(null, null);
  1876. }
  1877. #
  1878. display();
  1879. #
  1880. ?>
  1881. </table></td></tr></table>
  1882. </body></html>