PageRenderTime 40ms CodeModel.GetById 32ms RepoModel.GetById 0ms app.codeStats 0ms

/index.php

https://github.com/d3c0n808/MiningFarm
PHP | 276 lines | 231 code | 19 blank | 26 comment | 21 complexity | f82cb227c098d73718290c90e41571c3 MD5 | raw file
  1. <?php
  2. // Load Linkage Variables //
  3. $dir = dirname(__FILE__);
  4. $req = $dir."/req/";
  5. $functions = $req."functions.php";
  6. //Include hashing functions
  7. include($functions);
  8. //Include bitcoind functions
  9. include($bitcoind);
  10. //Set user details for userInfo box
  11. $rawCookie = "";
  12. if(isSet($_COOKIE[$cookieName])){
  13. $rawCookie = $_COOKIE[$cookieName];
  14. }
  15. $getCredientials = new getCredientials;
  16. $loginValid = $getCredientials->checkLogin($rawCookie);
  17. ?>
  18. <!--?xml version="1.0" encoding="iso-8859-1"?-->
  19. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  20. <html xmlns="http://www.w3.org/1999/xhtml">
  21. <head>
  22. <title><?php echo outputPageTitle();?> - <?php echo gettext("Main Page");?></title>
  23. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  24. <link href="/css/mainstyle.css" rel="stylesheet" type="text/css">
  25. </head>
  26. <body>
  27. <br/><br/>
  28. <div id="content">
  29. <?php
  30. //Include the header & slogan
  31. include($header);
  32. ////////////////////////////
  33. ?>
  34. <div id="mainbox">
  35. <?php
  36. //Get credentials
  37. $getCredientials->getStats();
  38. $getCredientials->getAdminSettings();
  39. //generate graph information
  40. //Get this individuals mhash
  41. $fifteenMinutesAgo = time();
  42. $fifteenMinutesAgo -= 60*15;
  43. $userHashHistoryQ = mysql_query("SELECT DISTINCT `timestamp` FROM `stats_userMHashHistory` WHERE `username` LIKE '".$getCredientials->username.".%' AND `timestamp` >= '$fifteenMinutesAgo' AND `mhashes` > 0 ORDER BY `timestamp` ASC");
  44. $numRows = mysql_num_rows($userHashHistoryQ);
  45. //Go through every time stamp and average out all the workers per timestamp
  46. $userHashArray = "";
  47. $timeHashArray = "";
  48. $poolHashArray = "";
  49. $poolTotalHashArray = "";
  50. //Show this graph if logged in
  51. if($numRows > 0){
  52. $i=0;
  53. while($time = mysql_fetch_array($userHashHistoryQ)){
  54. $tmpHashAverage = 0;
  55. $tmpTotalHash = 0;
  56. //Get all mhash results with this timestamp and average them up
  57. $getAllWorkerHash = mysql_query("SELECT `mhashes` FROM `stats_userMHashHistory` WHERE `username` LIKE '".$getCredientials->username.".%' AND `timestamp` = '".$time["timestamp"]."' AND `mhashes` > 0");
  58. $numWorkersThisTime = mysql_num_rows($getAllWorkerHash);
  59. while($workerHash = mysql_fetch_array($getAllWorkerHash)){
  60. $tmpHashAverage += $workerHash["mhashes"];
  61. $tmpTotalHash += $workerHash["mhashes"];
  62. }
  63. $tmpHashAverage = $tmpHashAverage/$numWorkersThisTime;
  64. //Get pool average results
  65. $getPoolAverageResult = mysql_query("SELECT `averageMhash`, `totalMhash` FROM `stats_poolMHashHistory` WHERE `timestamp` = '".$time["timestamp"]."' LIMIT 0,1");
  66. $poolAverageQ = mysql_fetch_object($getPoolAverageResult);
  67. $poolAverage = $poolAverageQ->averageMhash;
  68. $tmpTotalHash = $poolAverageQ->totalMhash;
  69. //Pool average comes up null sometimes this will prevent a break in the graph
  70. if(!isSet($poolAverage)){
  71. $poolAverage = 0;
  72. }
  73. //Add points to graph
  74. if($i > 0){
  75. $userHashArray .= ",";
  76. $timeHashArray .= ",";
  77. $poolHashArray .= ",";
  78. $poolTotalHashArray .= ",";
  79. }
  80. $i++;
  81. $timeHashArray .= "'".date("G:i:s", $time["timestamp"])."'";
  82. $userHashArray .= $tmpHashAverage;
  83. $poolHashArray .= $poolAverage;
  84. $poolTotalHashArray .= $tmpTotalHash;
  85. }
  86. }else if($numRows == 0){
  87. //Show this graph when not logged in
  88. $i=0;
  89. //Go through the pool history and display that
  90. $poolHistory = mysql_query("SELECT `averageMhash`, `totalMhash`, `timestamp` FROM `stats_poolMHashHistory` WHERE `timestamp` >= '".$fifteenMinutesAgo."' ORDER BY `timestamp` ASC");
  91. while($poolHash = mysql_fetch_array($poolHistory)){
  92. if($i > 0){
  93. $poolHashArray .=",";
  94. $timeHashArray .=",";
  95. $poolTotalHashArray .=",";
  96. }
  97. $i++;
  98. $poolHashArray .= $poolHash["averageMhash"];
  99. $timeHashArray .= "'".date("G:i:s", $poolHash["timestamp"])."'";
  100. $poolTotalHashArray .= $poolHash["totalMhash"];
  101. }
  102. }
  103. //If theres no data to be displayed even after the above display filler data
  104. if($poolHashArray == "" && $timeHashArray == "" && $poolTotalHashArray == ""){
  105. $timeHashArray = "'".date("G:i:s", time())."'";
  106. $poolHashArray = "0";
  107. $poolTotalHashArray = "0";
  108. }
  109. if($getCredientials->statsShowAllUsers == 1){
  110. //
  111. }
  112. ?>
  113. <script type="text/javascript">
  114. var chart1; // globally available
  115. $(document).ready(function() {
  116. chart1 = new Highcharts.Chart({
  117. chart: {
  118. renderTo: 'graph',
  119. defaultSeriesType: 'spline',
  120. width:750,
  121. height:250
  122. },
  123. title: {
  124. text: 'Overall Network Status'
  125. },
  126. xAxis: {
  127. categories: [<?php echo $timeHashArray;?>]
  128. },
  129. yAxis: {
  130. title: {
  131. text: 'Mega-Hashes'
  132. }
  133. },
  134. series: [{
  135. name: 'Pool Average',
  136. data: [<?php echo $poolHashArray; ?>]
  137. },
  138. {
  139. name: 'Pool Total',
  140. data: [<?php echo $poolTotalHashArray;?>]
  141. }
  142. <?php
  143. if($userHashArray != ""){
  144. ?>,
  145. {
  146. name: 'Your Average',
  147. data: [<?php echo $userHashArray?>]
  148. }
  149. <?php
  150. }
  151. ?>]
  152. });
  153. });
  154. </script>
  155. <div id="graph" align="center">
  156. <img src="/images/placeholder.jpg" alt="placeholder">
  157. </div><br/><br/>
  158. <?php
  159. //Display the all users graph?
  160. if($getCredientials->statsShowAllUsers == 1){
  161. ?>
  162. <div id="graphAllusers" align="center">
  163. <img src="/images/placeholder.jpg" alt="placeholder">
  164. </div><br/><br/>
  165. <?php
  166. }
  167. ?>
  168. <br/>
  169. <!-- quick bloging -->
  170. <table cellpadding="0" cellspacing="0" border="0" align="center" width="100%">
  171. <tbody>
  172. <tr>
  173. <td>
  174. <!-- start blogging -->
  175. <?php
  176. //retireve blogs
  177. $blogs = mysql_query("SELECT `title`, `timestamp`, `message` FROM `blogPosts` ORDER BY `timestamp` DESC");
  178. while($blog = mysql_fetch_array($blogs)){
  179. ?>
  180. <table align="center" cellpadding="0" cellspacing="0" class="bigContent" width="100%">
  181. <tbody>
  182. <tr>
  183. <td class="contTL">
  184. &nbsp;
  185. </td>
  186. <td class="contTC">
  187. Blog Heading
  188. </td>
  189. <td class="contTR">
  190. &nbsp;
  191. </td>
  192. </tr>
  193. <tr>
  194. <td colspan="3" class="contContent">
  195. BLOGGING CONTENT
  196. </td>
  197. </tr>
  198. </tbody>
  199. </table>
  200. <?php
  201. }
  202. ?>
  203. </td>
  204. <td valign="top">
  205. <!-- Quick worker stats -->
  206. <table align="center" cellpadding="0" cellspacing="0" class="bigContent" width="100%">
  207. <tbody>
  208. <tr>
  209. <td class="contTL">
  210. &nbsp;
  211. </td>
  212. <td class="contTC">
  213. Quick Server Status
  214. </td>
  215. <td class="contTR">
  216. &nbsp;
  217. </td>
  218. </tr>
  219. <tr>
  220. <td colspan="3" class="contContent">
  221. <?php
  222. try{
  223. //Open a bitcoind connection
  224. $bitcoinController = new BitcoinClient($rpcType, $rpcUsername, $rpcPassword, $rpcHost);
  225. }catch(Exception $e){
  226. echo "Connecting to bitcoin wallet failed | Please contact admin";
  227. }
  228. if($bitcoinController != false){
  229. //Show some quick stats
  230. //Get total workers working
  231. $fifteenMinutesAgo = time();
  232. $fifteenMinutesAgo -= 60*15;
  233. $totalWorkersQ = mysql_query("SELECT `id` FROM `stats_userMHashHistory` WHERE `timestamp` < $fifteenMinutesAgo");
  234. $totalWorkers = mysql_num_rows($totalWorkersQ);
  235. ?>
  236. <b>Current Difficulty:</b> <?php echo $bitcoinController->getDifficulty();?><br/>
  237. <b>Total Workers:</b> <?php echo $totalWorkers;?><br/>
  238. <?php
  239. }
  240. ?>
  241. </td>
  242. </tr>
  243. </tbody>
  244. </table>
  245. </td>
  246. </tr>
  247. </tbody>
  248. </table><br />
  249. <?php
  250. //Include Footer
  251. ////////////////////
  252. include($footer);
  253. ?>
  254. </div>
  255. <br/><Br/>
  256. </body>
  257. </html>