Advertisement
sp3sh

Untitled

May 17th, 2018
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.07 KB | None | 0 0
  1. <?php
  2.  
  3. $user = getuserparam(getparam('address'));
  4. if(!$user) return;
  5.  
  6. $userid = intval($user->id);
  7. $coinid = intval($user->coinid);
  8. if ($coinid) {
  9. $coin = getdbo('db_coins', $coinid);
  10. }
  11.  
  12. echo "<div class='main-left-box'>";
  13. echo "<div class='main-left-title'>Miners: {$user->username}</div>";
  14. echo "<div class='main-left-inner'>";
  15.  
  16. echo '<table class="dataGrid2">';
  17. echo "<thead>";
  18. echo "<tr>";
  19. echo "<th align=left>Summary</th>";
  20. echo "<th align=right>Miners</th>";
  21. echo "<th align=right>Shares</th>";
  22. echo "<th align=right width=80>Hashrate*</th>";
  23. echo "<th align=right width=60>Reject*</th>";
  24. echo "</tr>";
  25. echo "</thead>";
  26.  
  27. foreach(yaamp_get_algos() as $algo)
  28. {
  29. if (!YAAMP_ALLOW_EXCHANGE && isset($coin) && $coin->algo != $algo) continue;
  30.  
  31. $user_rate1 = yaamp_user_rate($userid, $algo);
  32. $user_rate1_bad = yaamp_user_rate_bad($userid, $algo);
  33.  
  34. $percent_bad = ($user_rate1 + $user_rate1_bad)? $user_rate1_bad * 100 / ($user_rate1 + $user_rate1_bad): 0;
  35. $percent_bad = $percent_bad? round($percent_bad, 1).'%': '';
  36.  
  37. $user_rate1 = $user_rate1? Itoa2($user_rate1).'h/s': '-';
  38. $minercount = getdbocount('db_workers', "userid=$userid AND algo=:algo", array(':algo'=>$algo));
  39.  
  40. if (YAAMP_ALLOW_EXCHANGE || !$user->coinid) {
  41.  
  42. $user_shares = controller()->memcache->get_database_scalar("wallet_user_shares-$userid-$algo",
  43. "SELECT SUM(difficulty) FROM shares WHERE valid AND userid=$userid AND algo=:algo", array(':algo'=>$algo));
  44. if(!$user_shares && !$minercount) continue;
  45.  
  46. $total_shares = controller()->memcache->get_database_scalar("wallet_total_shares-$algo",
  47. "SELECT SUM(difficulty) FROM shares WHERE valid AND algo=:algo", array(':algo'=>$algo));
  48.  
  49. } else {
  50. // we know the single currency mined if auto exchange is disabled
  51. $user_shares = controller()->memcache->get_database_scalar("wallet_user_shares-$algo-$coinid-$userid",
  52. "SELECT SUM(difficulty) FROM shares WHERE valid AND userid=$userid AND coinid=$coinid AND algo=:algo", array(':algo'=>$algo));
  53. if(!$user_shares) continue;
  54.  
  55. $total_shares = controller()->memcache->get_database_scalar("wallet_coin_shares-$coinid",
  56. "SELECT SUM(difficulty) FROM shares WHERE valid AND coinid=$coinid AND algo=:algo", array(':algo'=>$algo));
  57. }
  58.  
  59.  
  60. if(!$total_shares) continue;
  61. $percent_shares = round($user_shares * 100 / $total_shares, 4);
  62.  
  63. echo '<tr class="ssrow">';
  64. echo '<td><b>'.$algo.'</b></td>';
  65. echo '<td align="right">'.$minercount.'</td>';
  66. echo '<td align="right" width="100">'.$percent_shares.'%</td>';
  67. echo '<td align="right" width="100"><b>'.$user_rate1.'</b></td>';
  68. echo '<td align="right">'.$percent_bad.'</td>';
  69. echo '</tr>';
  70. }
  71.  
  72. echo "</table>";
  73.  
  74. ////////////////////////////////////////////////////////////////////////////////
  75.  
  76. $workers = getdbolist('db_workers', "userid=$user->id order by password");
  77. if(count($workers))
  78. {
  79. echo "<br>";
  80. echo "<table class='dataGrid2'>";
  81. echo "<thead>";
  82. echo "<tr>";
  83. echo "<th align=left>Software</th>";
  84. echo "<th align=left>Worker</th>";
  85. if ($this->admin) echo "<th>IP</th>";
  86. echo "<th align=left>Extra</th>";
  87. echo "<th align=left>Algo</th>";
  88. echo "<th align=right>Diff</th>";
  89. echo "<th align=right title='extranonce.subscribe'>ES**</th>";
  90. echo "<th align=right width=60>Shares</th>";
  91. echo "<th align=right width=80>Hashrate*</th>";
  92. echo "<th align=right width=60>Reject*</th>";
  93. echo "</tr>";
  94. echo "</thead>";
  95.  
  96. $total_rate = 0.0;
  97. foreach($workers as $worker)
  98. {
  99. $total_rate += yaamp_worker_rate($worker->id);
  100. }
  101.  
  102. foreach($workers as $worker)
  103. {
  104. $user_rate1 = yaamp_worker_rate($worker->id, $worker->algo);
  105. $user_rate1_bad = yaamp_worker_rate_bad($worker->id, $worker->algo);
  106. $user_rejects = yaamp_worker_shares_bad($worker->id, $worker->algo);
  107.  
  108. $percent2 = 0.0;
  109. if ($total_rate) $percent2 = ($percent_shares * $user_rate1) / $total_rate;
  110.  
  111.  
  112.  
  113. if (!$user_rejects) $user_rejects = '';
  114. $name = $worker->worker;
  115. $percent = ($user_rate1 + $user_rate1_bad)? $user_rate1_bad * 100 / ($user_rate1 + $user_rate1_bad): 0;
  116. $percent = $percent? round($percent, 2).'%': '';
  117.  
  118. $user_rate1 = $user_rate1? Itoa2($user_rate1).'h/s': '';
  119.  
  120. $version = substr($worker->version, 0, 20);
  121. $password = substr($worker->password, 0, 32);
  122.  
  123. $subscribe = Booltoa($worker->subscribe);
  124.  
  125. echo '<tr class="ssrow">';
  126. echo '<td title="'.$worker->version.'">'.$version.'</td>';
  127. echo '<td>'.$name.'</td>';
  128. if ($this->admin) echo "<td>{$worker->ip}</td>";
  129. echo '<td title="'.$worker->password.'">'.$password.'</td>';
  130. echo '<td>'.$worker->algo.'</td>';
  131. echo '<td align="right">'.$worker->difficulty.'</td>';
  132. echo '<td align="right">'.$subscribe.'</td>';
  133. echo '<td align="right">'.number_format($percent2,1,'.','').'%</td>';
  134. echo '<td align="right">'.$user_rate1.'</td>';
  135. echo '<td align="center" title="'.$percent.'">'.$user_rejects.'</td>';
  136. echo '</tr>';
  137. }
  138.  
  139. echo "</table>";
  140. }
  141.  
  142. echo "</div>";
  143.  
  144. echo "<p style='font-size: .8em'>
  145. &nbsp;* approximate from the last 5 minutes submitted shares<br>
  146. &nbsp;** extranonce.subscribe<br>
  147. </p>";
  148.  
  149. echo "</div><br>";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement