miner.php 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123
  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 'GPU.Diff1 Work':
  751. case 'PGA.Diff1 Work':
  752. case 'POOL.Diff1 Work':
  753. case 'total.Diff1 Work':
  754. case 'POOL.Diff1 Shares': // old name
  755. case 'total.Diff1 Shares': // old name
  756. $parts = explode('.', $value, 2);
  757. if (count($parts) == 1)
  758. $dec = '';
  759. else
  760. $dec = '.'.$parts[1];
  761. $ret = number_format((float)$parts[0]).$dec;
  762. break;
  763. case 'GPU.Status':
  764. case 'PGA.Status':
  765. case 'DEVS.Status':
  766. case 'POOL.Status':
  767. if ($value != 'Alive')
  768. $class = $errorclass;
  769. break;
  770. case 'GPU.Enabled':
  771. case 'PGA.Enabled':
  772. case 'DEVS.Enabled':
  773. if ($value != 'Y')
  774. $class = $warnclass;
  775. break;
  776. case 'STATUS.When':
  777. case 'COIN.Current Block Time':
  778. $ret = date($dfmt, $value);
  779. break;
  780. case 'BUTTON.Rig':
  781. case 'BUTTON.Pool':
  782. case 'BUTTON.GPU':
  783. $ret = $value;
  784. break;
  785. }
  786. if ($section == 'NOTIFY' && substr($name, 0, 1) == '*' && $value != '0')
  787. $class = $errorclass;
  788. if ($class == '' && $section != 'POOL')
  789. $class = classlastshare($when, $alldata, $lstclass, $lstclass);
  790. if ($class == '' && $section == 'total')
  791. $class = $totclass;
  792. if ($class == '' && ($rownum % 2) == 0)
  793. $class = $c2class;
  794. if ($ret === '')
  795. $ret = $b;
  796. return array($ret, $class);
  797. }
  798. #
  799. global $poolcmd;
  800. $poolcmd = array( 'Switch to' => 'switchpool',
  801. 'Enable' => 'enablepool',
  802. 'Disable' => 'disablepool',
  803. 'Remove' => 'removepool' );
  804. #
  805. function showhead($cmd, $values, $justnames = false)
  806. {
  807. global $poolcmd, $readonly;
  808. newrow();
  809. foreach ($values as $name => $value)
  810. {
  811. if ($name == '0' or $name == '')
  812. $name = '&nbsp;';
  813. echo "<td valign=bottom class=h>$name</td>";
  814. }
  815. if ($justnames === false && $cmd == 'pools' && $readonly === false)
  816. foreach ($poolcmd as $name => $pcmd)
  817. echo "<td valign=bottom class=h>$name</td>";
  818. endrow();
  819. }
  820. #
  821. function showdatetime()
  822. {
  823. global $dfmt;
  824. otherrow('<td class=sta>Date: '.date($dfmt).'</td>');
  825. }
  826. #
  827. global $singlerigsum;
  828. $singlerigsum = array(
  829. 'devs' => array('MHS av' => 1, 'MHS 5s' => 1, 'Accepted' => 1, 'Rejected' => 1,
  830. 'Hardware Errors' => 1, 'Utility' => 1, 'Total MH' => 1),
  831. 'pools' => array('Getworks' => 1, 'Accepted' => 1, 'Rejected' => 1, 'Discarded' => 1,
  832. 'Stale' => 1, 'Get Failures' => 1, 'Remote Failures' => 1,
  833. 'Diff1 Work' => 1),
  834. 'notify' => array('*' => 1));
  835. #
  836. function showtotal($total, $when, $oldvalues)
  837. {
  838. global $rigtotals;
  839. list($showvalue, $class) = fmt('total', '', 'Total:', $when, null);
  840. echo "<td$class align=right>$showvalue</td>";
  841. $skipfirst = true;
  842. foreach ($oldvalues as $name => $value)
  843. {
  844. if ($skipfirst === true)
  845. {
  846. $skipfirst = false;
  847. continue;
  848. }
  849. if (isset($total[$name]))
  850. $newvalue = $total[$name];
  851. else
  852. $newvalue = '';
  853. list($showvalue, $class) = fmt('total', $name, $newvalue, $when, null);
  854. echo "<td$class";
  855. if ($rigtotals === true)
  856. echo ' align=right';
  857. echo ">$showvalue</td>";
  858. }
  859. }
  860. #
  861. function details($cmd, $list, $rig)
  862. {
  863. global $dfmt, $poolcmd, $readonly, $showndate;
  864. global $rownum, $rigtotals, $forcerigtotals, $singlerigsum;
  865. $when = 0;
  866. $stas = array('S' => 'Success', 'W' => 'Warning', 'I' => 'Informational', 'E' => 'Error', 'F' => 'Fatal');
  867. newtable();
  868. if ($showndate === false)
  869. {
  870. showdatetime();
  871. endtable();
  872. newtable();
  873. $showndate = true;
  874. }
  875. if (isset($list['STATUS']))
  876. {
  877. newrow();
  878. echo '<td>Computer: '.$list['STATUS']['Description'].'</td>';
  879. if (isset($list['STATUS']['When']))
  880. {
  881. echo '<td>When: '.date($dfmt, $list['STATUS']['When']).'</td>';
  882. $when = $list['STATUS']['When'];
  883. }
  884. $sta = $list['STATUS']['STATUS'];
  885. echo '<td>Status: '.$stas[$sta].'</td>';
  886. echo '<td>Message: '.$list['STATUS']['Msg'].'</td>';
  887. endrow();
  888. }
  889. if ($rigtotals === true && isset($singlerigsum[$cmd]))
  890. $dototal = $singlerigsum[$cmd];
  891. else
  892. $dototal = array();
  893. $total = array();
  894. $section = '';
  895. $oldvalues = null;
  896. foreach ($list as $item => $values)
  897. {
  898. if ($item == 'STATUS')
  899. continue;
  900. $sectionname = preg_replace('/\d/', '', $item);
  901. // Handle 'devs' possibly containing >1 table
  902. if ($sectionname != $section)
  903. {
  904. if ($oldvalues != null && count($total) > 0
  905. && ($rownum > 2 || $forcerigtotals === true))
  906. showtotal($total, $when, $oldvalues);
  907. endtable();
  908. newtable();
  909. showhead($cmd, $values);
  910. $section = $sectionname;
  911. }
  912. newrow();
  913. foreach ($values as $name => $value)
  914. {
  915. list($showvalue, $class) = fmt($section, $name, $value, $when, $values);
  916. echo "<td$class";
  917. if ($rigtotals === true)
  918. echo ' align=right';
  919. echo ">$showvalue</td>";
  920. if (isset($dototal[$name])
  921. || (isset($dototal['*']) and substr($name, 0, 1) == '*'))
  922. {
  923. if (isset($total[$name]))
  924. $total[$name] += $value;
  925. else
  926. $total[$name] = $value;
  927. }
  928. }
  929. if ($cmd == 'pools' && $readonly === false)
  930. {
  931. reset($values);
  932. $pool = current($values);
  933. foreach ($poolcmd as $name => $pcmd)
  934. {
  935. list($ignore, $class) = fmt('BUTTON', 'Pool', '', $when, $values);
  936. echo "<td$class>";
  937. if ($pool === false)
  938. echo '&nbsp;';
  939. else
  940. {
  941. echo "<input type=button value='Pool $pool'";
  942. echo " onclick='prc(\"$pcmd|$pool&rig=$rig\",\"$name Pool $pool\")'>";
  943. }
  944. echo '</td>';
  945. }
  946. }
  947. endrow();
  948. $oldvalues = $values;
  949. }
  950. if ($oldvalues != null && count($total) > 0
  951. && ($rownum > 2 || $forcerigtotals === true))
  952. showtotal($total, $when, $oldvalues);
  953. endtable();
  954. }
  955. #
  956. global $devs;
  957. $devs = null;
  958. #
  959. function gpubuttons($count, $rig)
  960. {
  961. global $devs;
  962. $basic = array( 'GPU', 'Enable', 'Disable', 'Restart' );
  963. $options = array( 'intensity' => 'Intensity',
  964. 'fan' => 'Fan Percent',
  965. 'engine' => 'GPU Clock',
  966. 'mem' => 'Memory Clock',
  967. 'vddc' => 'GPU Voltage' );
  968. newtable();
  969. newrow();
  970. foreach ($basic as $head)
  971. echo "<td class=h>$head</td>";
  972. foreach ($options as $name => $des)
  973. echo "<td class=h nowrap>$des</td>";
  974. $n = 0;
  975. for ($c = 0; $c < $count; $c++)
  976. {
  977. endrow();
  978. newrow();
  979. foreach ($basic as $name)
  980. {
  981. list($ignore, $class) = fmt('BUTTON', 'GPU', '', 0, null);
  982. echo "<td$class>";
  983. if ($name == 'GPU')
  984. echo $c;
  985. else
  986. {
  987. echo "<input type=button value='$name $c' onclick='prs(\"gpu";
  988. echo strtolower($name);
  989. echo "|$c\",$rig)'>";
  990. }
  991. echo '</td>';
  992. }
  993. foreach ($options as $name => $des)
  994. {
  995. list($ignore, $class) = fmt('BUTTON', 'GPU', '', 0, null);
  996. echo "<td$class>";
  997. if (!isset($devs["GPU$c"][$des]))
  998. echo '&nbsp;';
  999. else
  1000. {
  1001. $value = $devs["GPU$c"][$des];
  1002. echo "<input type=button value='Set $c:' onclick='prs2(\"gpu$name|$c\",$n,$rig)'>";
  1003. echo "<input size=7 type=text name=gi$n value='$value' id=gi$n>";
  1004. $n++;
  1005. }
  1006. echo '</td>';
  1007. }
  1008. }
  1009. endrow();
  1010. endtable();
  1011. }
  1012. #
  1013. function processgpus($rig)
  1014. {
  1015. global $error;
  1016. global $warnfont, $warnoff;
  1017. $gpus = api($rig, 'gpucount');
  1018. if ($error != null)
  1019. otherrow("<td>Error getting GPU count: $warnfont$error$warnoff</td>");
  1020. else
  1021. {
  1022. if (!isset($gpus['GPUS']['Count']))
  1023. {
  1024. $rw = '<td>No GPU count returned: '.$warnfont;
  1025. $rw .= $gpus['STATUS']['STATUS'].' '.$gpus['STATUS']['Msg'];
  1026. $rw .= $warnoff.'</td>';
  1027. otherrow($rw);
  1028. }
  1029. else
  1030. {
  1031. $count = $gpus['GPUS']['Count'];
  1032. if ($count == 0)
  1033. otherrow('<td>No GPUs</td>');
  1034. else
  1035. gpubuttons($count, $rig);
  1036. }
  1037. }
  1038. }
  1039. #
  1040. function showpoolinputs($rig, $ans)
  1041. {
  1042. global $readonly, $poolinputs;
  1043. if ($readonly === true || $poolinputs === false)
  1044. return;
  1045. newtable();
  1046. newrow();
  1047. $inps = array('Pool URL' => array('purl', 20),
  1048. 'Worker Name' => array('pwork', 10),
  1049. 'Worker Password' => array('ppass', 10));
  1050. $b = '&nbsp;';
  1051. echo "<td align=right class=h> Add a pool: </td><td>";
  1052. foreach ($inps as $text => $name)
  1053. echo "$text: <input name='".$name[0]."' id='".$name[0]."' value='' type=text size=".$name[1]."> ";
  1054. echo "</td><td align=middle><input type=button value='Add' onclick='pla($rig)'></td>";
  1055. endrow();
  1056. if (count($ans) > 1)
  1057. {
  1058. newrow();
  1059. echo '<td align=right class=h> Set pool priorities: </td>';
  1060. echo "<td> Comma list of pool numbers: <input type=text name=prio id=prio size=20>";
  1061. echo "</td><td align=middle><input type=button value='Set' onclick='psp($rig)'></td>";
  1062. endrow();
  1063. }
  1064. endtable();
  1065. }
  1066. #
  1067. function process($cmds, $rig)
  1068. {
  1069. global $error, $devs;
  1070. global $warnfont, $warnoff;
  1071. $count = count($cmds);
  1072. foreach ($cmds as $cmd => $des)
  1073. {
  1074. $process = api($rig, $cmd);
  1075. if ($error != null)
  1076. {
  1077. otherrow("<td colspan=100>Error getting $des: $warnfont$error$warnoff</td>");
  1078. break;
  1079. }
  1080. else
  1081. {
  1082. details($cmd, $process, $rig);
  1083. if ($cmd == 'devs')
  1084. $devs = $process;
  1085. if ($cmd == 'pools')
  1086. showpoolinputs($rig, $process);
  1087. # Not after the last one
  1088. if (--$count > 0)
  1089. otherrow('<td><br><br></td>');
  1090. }
  1091. }
  1092. }
  1093. #
  1094. function rigbutton($rig, $rigname, $when, $row)
  1095. {
  1096. global $rigs;
  1097. if (isset($rigs[$rig]))
  1098. {
  1099. $parts = explode(':', $rigs[$rig], 3);
  1100. if (count($parts) == 3)
  1101. $rigname = $parts[2];
  1102. }
  1103. list($value, $class) = fmt('BUTTON', 'Rig', '', $when, $row);
  1104. $button = "<td align=middle$class><input type=button value='$rigname'";
  1105. $button .= " onclick='pr(\"&rig=$rig\",null)'></td>";
  1106. return $button;
  1107. }
  1108. #
  1109. function showrigs($anss, $headname, $rigname)
  1110. {
  1111. $dthead = array($headname => 1, 'STATUS' => 1, 'Description' => 1, 'When' => 1, 'API' => 1, 'CGMiner' => 1);
  1112. showhead('', $dthead);
  1113. foreach ($anss as $rig => $ans)
  1114. {
  1115. if ($ans == null)
  1116. continue;
  1117. newrow();
  1118. $when = 0;
  1119. if (isset($ans['STATUS']['When']))
  1120. $when = $ans['STATUS']['When'];
  1121. foreach ($ans as $item => $row)
  1122. {
  1123. if ($item != 'STATUS' && $item != 'VERSION')
  1124. continue;
  1125. foreach ($dthead as $name => $x)
  1126. {
  1127. if ($item == 'STATUS' && $name == $headname)
  1128. echo rigbutton($rig, $rigname.$rig, $when, null);
  1129. else
  1130. {
  1131. if (isset($row[$name]))
  1132. {
  1133. list($showvalue, $class) = fmt('STATUS', $name, $row[$name], $when, null);
  1134. echo "<td$class align=right>$showvalue</td>";
  1135. }
  1136. }
  1137. }
  1138. }
  1139. endrow();
  1140. }
  1141. }
  1142. #
  1143. # $head is a hack but this is just a demo anyway :)
  1144. function doforeach($cmd, $des, $sum, $head, $datetime)
  1145. {
  1146. global $miner, $port;
  1147. global $error, $readonly, $notify, $rigs;
  1148. global $warnfont, $warnoff, $dfmt;
  1149. global $rigerror;
  1150. $when = 0;
  1151. $header = $head;
  1152. $anss = array();
  1153. $count = 0;
  1154. $preverr = count($rigerror);
  1155. foreach ($rigs as $num => $rig)
  1156. {
  1157. $anss[$num] = null;
  1158. if (isset($rigerror[$rig]))
  1159. continue;
  1160. $parts = explode(':', $rig, 3);
  1161. if (count($parts) >= 2)
  1162. {
  1163. $miner = $parts[0];
  1164. $port = $parts[1];
  1165. if (count($parts) > 2)
  1166. $name = $parts[2];
  1167. else
  1168. $name = $num;
  1169. $ans = api($name, $cmd);
  1170. if ($error != null)
  1171. {
  1172. $rw = "<td colspan=100>Error on rig $name getting ";
  1173. $rw .= "$des: $warnfont$error$warnoff</td>";
  1174. otherrow($rw);
  1175. $rigerror[$rig] = $error;
  1176. $error = null;
  1177. }
  1178. else
  1179. {
  1180. $anss[$num] = $ans;
  1181. $count++;
  1182. }
  1183. }
  1184. }
  1185. if ($count == 0)
  1186. {
  1187. $rw = '<td>Failed to access any rigs successfully';
  1188. if ($preverr > 0)
  1189. $rw .= ' (or rigs had previous errors)';
  1190. $rw .= '</td>';
  1191. otherrow($rw);
  1192. return;
  1193. }
  1194. if ($datetime)
  1195. {
  1196. showdatetime();
  1197. endtable();
  1198. newtable();
  1199. showrigs($anss, '', 'Rig ');
  1200. endtable();
  1201. otherrow('<td><br><br></td>');
  1202. newtable();
  1203. return;
  1204. }
  1205. $total = array();
  1206. foreach ($anss as $rig => $ans)
  1207. {
  1208. if ($ans == null)
  1209. continue;
  1210. foreach ($ans as $item => $row)
  1211. {
  1212. if ($item == 'STATUS')
  1213. continue;
  1214. if (count($row) > count($header))
  1215. {
  1216. $header = $head;
  1217. foreach ($row as $name => $value)
  1218. if (!isset($header[$name]))
  1219. $header[$name] = '';
  1220. }
  1221. if ($sum != null)
  1222. foreach ($sum as $name)
  1223. {
  1224. if (isset($row[$name]))
  1225. {
  1226. if (isset($total[$name]))
  1227. $total[$name] += $row[$name];
  1228. else
  1229. $total[$name] = $row[$name];
  1230. }
  1231. }
  1232. }
  1233. }
  1234. if ($sum != null)
  1235. $anss['total']['total'] = $total;
  1236. showhead('', $header);
  1237. foreach ($anss as $rig => $ans)
  1238. {
  1239. if ($ans == null)
  1240. continue;
  1241. $when = 0;
  1242. if (isset($ans['STATUS']['When']))
  1243. $when = $ans['STATUS']['When'];
  1244. foreach ($ans as $item => $row)
  1245. {
  1246. if ($item == 'STATUS')
  1247. continue;
  1248. newrow();
  1249. $section = preg_replace('/\d/', '', $item);
  1250. foreach ($header as $name => $x)
  1251. {
  1252. if ($name == '')
  1253. {
  1254. if ($rig === 'total')
  1255. {
  1256. list($ignore, $class) = fmt($rig, '', '', $when, $row);
  1257. echo "<td align=right$class>Total:</td>";
  1258. }
  1259. else
  1260. echo rigbutton($rig, "Rig $rig", $when, $row);
  1261. }
  1262. else
  1263. {
  1264. if (isset($row[$name]))
  1265. $value = $row[$name];
  1266. else
  1267. $value = null;
  1268. list($showvalue, $class) = fmt($section, $name, $value, $when, $row);
  1269. echo "<td$class align=right>$showvalue</td>";
  1270. }
  1271. }
  1272. endrow();
  1273. }
  1274. }
  1275. }
  1276. #
  1277. function refreshbuttons()
  1278. {
  1279. global $readonly;
  1280. global $ignorerefresh, $changerefresh, $autorefresh;
  1281. if ($ignorerefresh == false && $changerefresh == true)
  1282. {
  1283. echo '&nbsp;&nbsp;&nbsp;&nbsp;';
  1284. echo "<input type=button value='Auto Refresh:' onclick='prr(true)'>";
  1285. echo "<input type=text name='refval' id='refval' size=2 value='$autorefresh'>";
  1286. echo "<input type=button value='Off' onclick='prr(false)'>";
  1287. }
  1288. }
  1289. #
  1290. function pagebuttons($rig, $pg)
  1291. {
  1292. global $readonly, $rigs;
  1293. global $allowcustompages, $customsummarypages;
  1294. if ($rig === null)
  1295. {
  1296. if ($pg === null)
  1297. $refresh = '';
  1298. else
  1299. $refresh = "&pg=$pg";
  1300. }
  1301. else
  1302. $refresh = "&rig=$rig";
  1303. echo '<tr><td><table cellpadding=0 cellspacing=0 border=0><tr><td nowrap>';
  1304. echo "<input type=button value='Refresh' onclick='pr(\"$refresh\",null)'>&nbsp;";
  1305. if (count($rigs) > 1)
  1306. echo "<input type=button value='Summary' onclick='pr(\"\",null)'>&nbsp;";
  1307. if ($allowcustompages === true)
  1308. foreach ($customsummarypages as $pagename => $data)
  1309. echo "<input type=button value='$pagename' onclick='pr(\"&pg=$pagename\",null)'>&nbsp;";
  1310. echo '</td><td width=100%>&nbsp;</td><td nowrap>';
  1311. if ($rig !== null && $readonly === false)
  1312. {
  1313. $rg = '';
  1314. if (count($rigs) > 1)
  1315. $rg = " Rig $rig";
  1316. echo "<input type=button value='Restart' onclick='prc(\"restart&rig=$rig\",\"Restart CGMiner$rg\")'>";
  1317. echo "&nbsp;<input type=button value='Quit' onclick='prc(\"quit&rig=$rig\",\"Quit CGMiner$rg\")'>";
  1318. }
  1319. refreshbuttons();
  1320. echo "</td></tr></table></td></tr>";
  1321. }
  1322. #
  1323. function doOne($rig, $preprocess)
  1324. {
  1325. global $haderror, $readonly, $notify, $rigs;
  1326. global $placebuttons;
  1327. htmlhead(true, $rig);
  1328. if ($placebuttons == 'top' || $placebuttons == 'both')
  1329. pagebuttons($rig, null);
  1330. if ($preprocess != null)
  1331. process(array($preprocess => $preprocess), $rig);
  1332. $cmds = array( 'devs' => 'device list',
  1333. 'summary' => 'summary information',
  1334. 'pools' => 'pool list');
  1335. if ($notify)
  1336. $cmds['notify'] = 'device status';
  1337. $cmds['config'] = 'cgminer config';
  1338. process($cmds, $rig);
  1339. if ($haderror == false && $readonly === false)
  1340. processgpus($rig);
  1341. if ($placebuttons == 'bot' || $placebuttons == 'both')
  1342. pagebuttons($rig, null);
  1343. }
  1344. #
  1345. global $sectionmap;
  1346. # map sections to their api command
  1347. # DEVS is a special case that will match GPU or PGA
  1348. # so you can have a single table with both in it
  1349. # DATE is hard coded so not in here
  1350. $sectionmap = array(
  1351. 'RIGS' => 'version',
  1352. 'SUMMARY' => 'summary',
  1353. 'POOL' => 'pools',
  1354. 'DEVS' => 'devs',
  1355. 'GPU' => 'devs', // You would normally use DEVS
  1356. 'PGA' => 'devs', // You would normally use DEVS
  1357. 'NOTIFY' => 'notify',
  1358. 'DEVDETAILS' => 'devdetails',
  1359. 'STATS' => 'stats',
  1360. 'CONFIG' => 'config',
  1361. 'COIN' => 'coin');
  1362. #
  1363. function joinfields($section1, $section2, $join, $results)
  1364. {
  1365. global $sectionmap;
  1366. $name1 = $sectionmap[$section1];
  1367. $name2 = $sectionmap[$section2];
  1368. $newres = array();
  1369. // foreach rig in section1
  1370. foreach ($results[$name1] as $rig => $result)
  1371. {
  1372. $status = null;
  1373. // foreach answer section in the rig api call
  1374. foreach ($result as $name1b => $fields1b)
  1375. {
  1376. if ($name1b == 'STATUS')
  1377. {
  1378. // remember the STATUS from section1
  1379. $status = $result[$name1b];
  1380. continue;
  1381. }
  1382. // foreach answer section in the rig api call (for the other api command)
  1383. foreach ($results[$name2][$rig] as $name2b => $fields2b)
  1384. {
  1385. if ($name2b == 'STATUS')
  1386. continue;
  1387. // If match the same field values of fields in $join
  1388. $match = true;
  1389. foreach ($join as $field)
  1390. if ($fields1b[$field] != $fields2b[$field])
  1391. {
  1392. $match = false;
  1393. break;
  1394. }
  1395. if ($match === true)
  1396. {
  1397. if ($status != null)
  1398. {
  1399. $newres[$rig]['STATUS'] = $status;
  1400. $status = null;
  1401. }
  1402. $subsection = $section1.'+'.$section2;
  1403. $subsection .= preg_replace('/[^0-9]/', '', $name1b.$name2b);
  1404. foreach ($fields1b as $nam => $val)
  1405. $newres[$rig][$subsection]["$section1.$nam"] = $val;
  1406. foreach ($fields2b as $nam => $val)
  1407. $newres[$rig][$subsection]["$section2.$nam"] = $val;
  1408. }
  1409. }
  1410. }
  1411. }
  1412. return $newres;
  1413. }
  1414. #
  1415. function joinall($section1, $section2, $results)
  1416. {
  1417. global $sectionmap;
  1418. $name1 = $sectionmap[$section1];
  1419. $name2 = $sectionmap[$section2];
  1420. $newres = array();
  1421. // foreach rig in section1
  1422. foreach ($results[$name1] as $rig => $result)
  1423. {
  1424. // foreach answer section in the rig api call
  1425. foreach ($result as $name1b => $fields1b)
  1426. {
  1427. if ($name1b == 'STATUS')
  1428. {
  1429. // copy the STATUS from section1
  1430. $newres[$rig][$name1b] = $result[$name1b];
  1431. continue;
  1432. }
  1433. // foreach answer section in the rig api call (for the other api command)
  1434. foreach ($results[$name2][$rig] as $name2b => $fields2b)
  1435. {
  1436. if ($name2b == 'STATUS')
  1437. continue;
  1438. $subsection = $section1.'+'.$section2;
  1439. $subsection .= preg_replace('/[^0-9]/', '', $name1b.$name2b);
  1440. foreach ($fields1b as $nam => $val)
  1441. $newres[$rig][$subsection]["$section1.$nam"] = $val;
  1442. foreach ($fields2b as $nam => $val)
  1443. $newres[$rig][$subsection]["$section2.$nam"] = $val;
  1444. }
  1445. }
  1446. }
  1447. return $newres;
  1448. }
  1449. #
  1450. function joinsections($sections, $results, $errors)
  1451. {
  1452. global $sectionmap;
  1453. #echo "results['pools']=".print_r($results['pools'],true)."<br>";
  1454. // GPU's don't have Name,ID fields - so create them
  1455. foreach ($results as $section => $res)
  1456. foreach ($res as $rig => $result)
  1457. foreach ($result as $name => $fields)
  1458. {
  1459. $subname = preg_replace('/[0-9]/', '', $name);
  1460. if ($subname == 'GPU' and isset($result[$name]['GPU']))
  1461. {
  1462. $results[$section][$rig][$name]['Name'] = 'GPU';
  1463. $results[$section][$rig][$name]['ID'] = $result[$name]['GPU'];
  1464. }
  1465. }
  1466. foreach ($sections as $section => $fields)
  1467. if ($section != 'DATE' && !isset($sectionmap[$section]))
  1468. {
  1469. $both = explode('+', $section, 2);
  1470. if (count($both) > 1)
  1471. {
  1472. switch($both[0])
  1473. {
  1474. case 'SUMMARY':
  1475. switch($both[1])
  1476. {
  1477. case 'POOL':
  1478. case 'DEVS':
  1479. case 'CONFIG':
  1480. case 'COIN':
  1481. $sectionmap[$section] = $section;
  1482. $results[$section] = joinall($both[0], $both[1], $results);
  1483. break;
  1484. default:
  1485. $errors[] = "Error: Invalid section '$section'";
  1486. break;
  1487. }
  1488. break;
  1489. case 'DEVS':
  1490. $join = array('Name', 'ID');
  1491. switch($both[1])
  1492. {
  1493. case 'NOTIFY':
  1494. case 'DEVDETAILS':
  1495. $sectionmap[$section] = $section;
  1496. $results[$section] = joinfields($both[0], $both[1], $join, $results);
  1497. break;
  1498. default:
  1499. $errors[] = "Error: Invalid section '$section'";
  1500. break;
  1501. }
  1502. break;
  1503. default:
  1504. $errors[] = "Error: Invalid section '$section'";
  1505. break;
  1506. }
  1507. }
  1508. else
  1509. $errors[] = "Error: Invalid section '$section'";
  1510. }
  1511. return array($results, $errors);
  1512. }
  1513. #
  1514. function secmatch($section, $field)
  1515. {
  1516. if ($section == $field)
  1517. return true;
  1518. if ($section == 'DEVS'
  1519. && ($field == 'GPU' || $field == 'PGA'))
  1520. return true;
  1521. return false;
  1522. }
  1523. #
  1524. function customset($showfields, $sum, $section, $rig, $isbutton, $result, $total)
  1525. {
  1526. foreach ($result as $sec => $row)
  1527. {
  1528. $secname = preg_replace('/\d/', '', $sec);
  1529. if ($sec != 'total')
  1530. if (!secmatch($section, $secname))
  1531. continue;
  1532. newrow();
  1533. $when = 0;
  1534. if (isset($result['STATUS']['When']))
  1535. $when = $result['STATUS']['When'];
  1536. if ($isbutton)
  1537. echo rigbutton($rig, $rig, $when, $row);
  1538. else
  1539. {
  1540. list($ignore, $class) = fmt('total', '', '', $when, $row);
  1541. echo "<td align=middle$class>$rig</td>";
  1542. }
  1543. foreach ($showfields as $name => $one)
  1544. {
  1545. if (isset($row[$name]))
  1546. {
  1547. $value = $row[$name];
  1548. if (isset($sum[$section][$name]))
  1549. {
  1550. if (isset($total[$name]))
  1551. $total[$name] += $value;
  1552. else
  1553. $total[$name] = $value;
  1554. }
  1555. }
  1556. else
  1557. {
  1558. if ($sec == 'total' && isset($total[$name]))
  1559. $value = $total[$name];
  1560. else
  1561. $value = null;
  1562. }
  1563. if (strpos($secname, '+') === false)
  1564. list($showvalue, $class) = fmt($secname, $name, $value, $when, $row);
  1565. else
  1566. {
  1567. $parts = explode('.', $name, 2);
  1568. list($showvalue, $class) = fmt($parts[0], $parts[1], $value, $when, $row);
  1569. }
  1570. echo "<td$class align=right>$showvalue</td>";
  1571. }
  1572. endrow();
  1573. }
  1574. return $total;
  1575. }
  1576. #
  1577. function processcustompage($pagename, $sections, $sum, $namemap)
  1578. {
  1579. global $sectionmap;
  1580. global $miner, $port;
  1581. global $rigs, $error;
  1582. global $warnfont, $warnoff;
  1583. global $dfmt;
  1584. global $readonly, $showndate;
  1585. $cmds = array();
  1586. $errors = array();
  1587. foreach ($sections as $section => $fields)
  1588. {
  1589. $all = explode('+', $section);
  1590. foreach ($all as $section)
  1591. {
  1592. if (isset($sectionmap[$section]))
  1593. {
  1594. $cmd = $sectionmap[$section];
  1595. if (!isset($cmds[$cmd]))
  1596. $cmds[$cmd] = 1;
  1597. }
  1598. else
  1599. if ($section != 'DATE')
  1600. $errors[] = "Error: unknown section '$section' in custom summary page '$pagename'";
  1601. }
  1602. }
  1603. $results = array();
  1604. foreach ($rigs as $num => $rig)
  1605. {
  1606. $parts = explode(':', $rig, 3);
  1607. if (count($parts) >= 2)
  1608. {
  1609. $miner = $parts[0];
  1610. $port = $parts[1];
  1611. if (count($parts) > 2)
  1612. $name = $parts[2];
  1613. else
  1614. $name = $rig;
  1615. foreach ($cmds as $cmd => $one)
  1616. {
  1617. $process = api($name, $cmd);
  1618. if ($error != null)
  1619. {
  1620. $errors[] = "Error getting $cmd for $name $warnfont$error$warnoff";
  1621. break;
  1622. }
  1623. else
  1624. $results[$cmd][$num] = $process;
  1625. }
  1626. }
  1627. }
  1628. $shownsomething = false;
  1629. if (count($results) > 0)
  1630. {
  1631. list($results, $errors) = joinsections($sections, $results, $errors);
  1632. $first = true;
  1633. foreach ($sections as $section => $fields)
  1634. {
  1635. if ($section === 'DATE')
  1636. {
  1637. if ($shownsomething)
  1638. otherrow('<td>&nbsp;</td>');
  1639. newtable();
  1640. showdatetime();
  1641. endtable();
  1642. // On top of the next table
  1643. $shownsomething = false;
  1644. continue;
  1645. }
  1646. if ($section === 'RIGS')
  1647. {
  1648. if ($shownsomething)
  1649. otherrow('<td>&nbsp;</td>');
  1650. newtable();
  1651. showrigs($results['version'], 'Rig', '');
  1652. endtable();
  1653. $shownsomething = true;
  1654. continue;
  1655. }
  1656. if (isset($results[$sectionmap[$section]]))
  1657. {
  1658. $rigresults = $results[$sectionmap[$section]];
  1659. $showfields = array();
  1660. $showhead = array();
  1661. foreach ($fields as $field)
  1662. foreach ($rigresults as $result)
  1663. foreach ($result as $sec => $row)
  1664. {
  1665. $secname = preg_replace('/\d/', '', $sec);
  1666. if (secmatch($section, $secname))
  1667. {
  1668. if ($field === '*')
  1669. {
  1670. foreach ($row as $f => $v)
  1671. {
  1672. $showfields[$f] = 1;
  1673. $map = $section.'.'.$f;
  1674. if (isset($namemap[$map]))
  1675. $showhead[$namemap[$map]] = 1;
  1676. else
  1677. $showhead[$f] = 1;
  1678. }
  1679. }
  1680. elseif (isset($row[$field]))
  1681. {
  1682. $showfields[$field] = 1;
  1683. $map = $section.'.'.$field;
  1684. if (isset($namemap[$map]))
  1685. $showhead[$namemap[$map]] = 1;
  1686. else
  1687. $showhead[$field] = 1;
  1688. }
  1689. }
  1690. }
  1691. if (count($showfields) > 0)
  1692. {
  1693. if ($shownsomething)
  1694. otherrow('<td>&nbsp;</td>');
  1695. newtable();
  1696. showhead('', array('Rig'=>1)+$showhead, true);
  1697. $total = array();
  1698. $add = array('total' => array());
  1699. foreach ($rigresults as $num => $result)
  1700. $total = customset($showfields, $sum, $section, $num, true, $result, $total);
  1701. if (count($total) > 0)
  1702. customset($showfields, $sum, $section, '&Sigma;', false, $add, $total);
  1703. $first = false;
  1704. endtable();
  1705. $shownsomething = true;
  1706. }
  1707. }
  1708. }
  1709. }
  1710. if (count($errors) > 0)
  1711. {
  1712. if (count($results) > 0)
  1713. otherrow('<td>&nbsp;</td>');
  1714. foreach ($errors as $err)
  1715. otherrow("<td colspan=100>$err</td>");
  1716. }
  1717. }
  1718. #
  1719. function showcustompage($pagename)
  1720. {
  1721. global $customsummarypages;
  1722. global $placebuttons;
  1723. htmlhead(false, null, $pagename);
  1724. if ($placebuttons == 'top' || $placebuttons == 'both')
  1725. pagebuttons(null, $pagename);
  1726. if (!isset($customsummarypages[$pagename]))
  1727. {
  1728. otherrow("<td colspan=100>Unknown custom summary page '$pagename'</td>");
  1729. return;
  1730. }
  1731. if (count($customsummarypages[$pagename]) != 2)
  1732. {
  1733. $rw = "<td colspan=100>Invalid custom summary page '$pagename' (";
  1734. $rw .= count($customsummarypages[$pagename]).')</td>';
  1735. otherrow($rw);
  1736. return;
  1737. }
  1738. $page = $customsummarypages[$pagename][0];
  1739. $namemap = array();
  1740. foreach ($page as $name => $fields)
  1741. {
  1742. if ($fields === null)
  1743. $page[$name] = array();
  1744. else
  1745. foreach ($fields as $num => $field)
  1746. {
  1747. $pos = strpos($field, '=');
  1748. if ($pos !== false)
  1749. {
  1750. $names = explode('=', $field, 2);
  1751. if (strlen($names[1]) > 0)
  1752. $namemap[$name.'.'.$names[0]] = $names[1];
  1753. $page[$name][$num] = $names[0];
  1754. }
  1755. }
  1756. }
  1757. $sum = $customsummarypages[$pagename][1];
  1758. if ($sum === null)
  1759. $sum = array();
  1760. // convert them to searchable via isset()
  1761. foreach ($sum as $section => $fields)
  1762. {
  1763. $newfields = array();
  1764. foreach ($fields as $field)
  1765. $newfields[$field] = 1;
  1766. $sum[$section] = $newfields;
  1767. }
  1768. if (count($page) <= 1)
  1769. {
  1770. otherrow("<td colspan=100>Invalid custom summary page '$pagename' no content </td>");
  1771. return;
  1772. }
  1773. processcustompage($pagename, $page, $sum, $namemap);
  1774. if ($placebuttons == 'bot' || $placebuttons == 'both')
  1775. pagebuttons(null, $pagename);
  1776. }
  1777. #
  1778. function display()
  1779. {
  1780. global $miner, $port;
  1781. global $readonly, $notify, $rigs;
  1782. global $ignorerefresh, $autorefresh;
  1783. global $allowcustompages;
  1784. global $placebuttons;
  1785. if ($ignorerefresh == false)
  1786. {
  1787. $ref = trim(getparam('ref', true));
  1788. if ($ref != null && $ref != '')
  1789. $autorefresh = intval($ref);
  1790. }
  1791. $rig = trim(getparam('rig', true));
  1792. $arg = trim(getparam('arg', true));
  1793. $preprocess = null;
  1794. if ($arg != null and $arg != '')
  1795. {
  1796. $num = null;
  1797. if ($rig != null and $rig != '')
  1798. {
  1799. if ($rig >= 0 and $rig < count($rigs))
  1800. $num = $rig;
  1801. }
  1802. else
  1803. if (count($rigs) == 0)
  1804. $num = 0;
  1805. if ($num != null)
  1806. {
  1807. $parts = explode(':', $rigs[$num], 3);
  1808. if (count($parts) >= 2)
  1809. {
  1810. $miner = $parts[0];
  1811. $port = $parts[1];
  1812. if ($readonly !== true)
  1813. $preprocess = $arg;
  1814. }
  1815. }
  1816. }
  1817. if ($rigs == null or count($rigs) == 0)
  1818. {
  1819. otherrow("<td>No rigs defined</td>");
  1820. return;
  1821. }
  1822. if ($allowcustompages === true)
  1823. {
  1824. $pg = trim(getparam('pg', true));
  1825. if ($pg != null && $pg != '')
  1826. {
  1827. showcustompage($pg);
  1828. return;
  1829. }
  1830. }
  1831. if (count($rigs) == 1)
  1832. {
  1833. $parts = explode(':', $rigs[0], 3);
  1834. if (count($parts) >= 2)
  1835. {
  1836. $miner = $parts[0];
  1837. $port = $parts[1];
  1838. doOne(0, $preprocess);
  1839. }
  1840. else
  1841. otherrow('<td>Invalid "$rigs" array</td>');
  1842. return;
  1843. }
  1844. if ($rig != null and $rig != '' and $rig >= 0 and $rig < count($rigs))
  1845. {
  1846. $parts = explode(':', $rigs[$rig], 3);
  1847. if (count($parts) >= 2)
  1848. {
  1849. $miner = $parts[0];
  1850. $port = $parts[1];
  1851. doOne($rig, $preprocess);
  1852. }
  1853. else
  1854. otherrow('<td>Invalid "$rigs" array</td>');
  1855. return;
  1856. }
  1857. htmlhead(false, null);
  1858. if ($placebuttons == 'top' || $placebuttons == 'both')
  1859. pagebuttons(null, null);
  1860. if ($preprocess != null)
  1861. process(array($preprocess => $preprocess), $rig);
  1862. newtable();
  1863. doforeach('version', 'rig summary', array(), array(), true);
  1864. $sum = array('MHS av', 'Getworks', 'Found Blocks', 'Accepted', 'Rejected', 'Discarded', 'Stale', 'Utility', 'Local Work', 'Total MH', 'Work Utility', 'Diff1 Work');
  1865. doforeach('summary', 'summary information', $sum, array(), false);
  1866. endtable();
  1867. otherrow('<td><br><br></td>');
  1868. newtable();
  1869. doforeach('devs', 'device list', $sum, array(''=>'','ID'=>'','Name'=>''), false);
  1870. endtable();
  1871. otherrow('<td><br><br></td>');
  1872. newtable();
  1873. doforeach('pools', 'pool list', $sum, array(''=>''), false);
  1874. endtable();
  1875. if ($placebuttons == 'bot' || $placebuttons == 'both')
  1876. pagebuttons(null, null);
  1877. }
  1878. #
  1879. display();
  1880. #
  1881. ?>
  1882. </table></td></tr></table>
  1883. </body></html>