index.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <!DOCTYPE html>
  2. <?php
  3. ini_set('display_errors', '0');
  4. if (file_exists("prep.php")) { header("Location: prep.php"); die(); }
  5. require_once "mdie/meekrodb.php";
  6. //include "refresh.php";
  7. ?>
  8. <html>
  9. <head>
  10. <script src="jquery.min.js"></script>
  11. <link rel="stylesheet" href="bootstrap/bootstrap.min.css" media="screen">
  12. <meta http-equiv="Pragma" content="no-cache">
  13. <meta http-equiv="Expires" content="-1">
  14. </head>
  15. <body>
  16. <?php include "header.php"; ?>
  17. <?php
  18. $sell = $_GET["sell"];
  19. $sellslug = $_GET["sellslug"];
  20. if (!$sell) {
  21. // ...
  22. } else {
  23. DB::$throw_exception_on_error = "true";
  24. try {
  25. $dbcoin = str_ireplace("-", "_", $sellslug);
  26. $mysqli_price = DB::queryRaw("SELECT priceusd from exchange_$dbcoin order by id desc limit 1");
  27. $sellprice = $mysqli_price->fetch_assoc();
  28. $sellprice_output = $sellprice["priceusd"];
  29. $sell_now = $sellprice_output * $sell;
  30. $mysqli_owned = DB::queryRaw("SELECT owned,name,cash from coinlist where slug=%s", $sellslug);
  31. $owned = $mysqli_owned->fetch_assoc();
  32. $owned_now = $owned["owned"];
  33. $name_now = $owned["name"];
  34. $cash_output = $owned["cash"];
  35. $cash_now = $cash_output + $sell_now;
  36. $owned_final = $owned_now - $sell;
  37. $mysqli_owned_update = DB::query("UPDATE coinlist SET owned=%i WHERE slug=%s", $owned_final, $sellslug);
  38. $mysqli_cash_update = DB::query("UPDATE coinlist SET cash=%i WHERE slug=%s", $cash_now, $sellslug);
  39. ?>
  40. <br /><center>
  41. <div class="card border-success mb-3" style="max-width: 90%;">
  42. <div class="card-header"><p class="text-info">Sold at market value <?php echo $sellprice_output; ?></p></div>
  43. <div class="card-body">
  44. <h4 class="card-title"><?php echo $name_now; ?></h4>
  45. <p class="card-text"><?php echo "$sell_now ($sell shares) of $name_now purchased."; ?><br /><br />Cash now: $<?php echo number_format($cash_now); ?></p>
  46. </div>
  47. </div></center>
  48. <?php
  49. // insert adjustment
  50. } catch(MeekroDBException $e) {
  51. echo "<font color=\"red\">||Failed||</font>";
  52. }
  53. }
  54. // buy
  55. $buy = $_GET["buy"];
  56. $buyslug = $_GET["buyslug"];
  57. if (!$buy) {
  58. // ...
  59. } else {
  60. try {
  61. $dbcoin = str_ireplace("-", "_", $buyslug);
  62. $mysqli_price = DB::queryRaw("SELECT priceusd from exchange_$dbcoin order by id desc limit 1");
  63. $buyprice = $mysqli_price->fetch_assoc();
  64. $buyprice_output = $buyprice["priceusd"];
  65. $buy_now = $buyprice_output * $buy;
  66. $mysqli_owned = DB::queryRaw("SELECT owned,name,cash from coinlist where slug=%s", $buyslug);
  67. $owned = $mysqli_owned->fetch_assoc();
  68. $owned_now = $owned["owned"];
  69. $owned_name = $owned["name"];
  70. $cash_output = $owned["cash"];
  71. $cash_now = $cash_output - $buy_now;
  72. $owned_final = $owned_now + $buy;
  73. $mysqli_owned_update = DB::query("UPDATE coinlist SET owned=%i WHERE slug=%s", $owned_final, $buyslug);
  74. $mysqli_cash_update = DB::query("UPDATE coinlist SET cash=%i WHERE slug=%s", $cash_now, $buyslug);
  75. ?><br /><center>
  76. <div class="card border-success mb-3" style="max-width: 90%;">
  77. <div class="card-header"><p class="text-info">Purchased at market value <?php echo $buyprice_output; ?></p></div>
  78. <div class="card-body">
  79. <h4 class="card-title"><?php echo $owned_name; ?></h4>
  80. <p class="card-text"><?php echo "$buy_now ($buy shares) of $owned_name purchased."; ?><br /><br />Cash now: $<?php echo number_format($cash_now); ?></p>
  81. </div>
  82. </div></center>
  83. <?php
  84. // insert adjustment
  85. } catch(MeekroDBException $e) {
  86. echo "||Failed||";
  87. }
  88. }?>
  89. <br />
  90. <div id="list"></div>
  91. <br />
  92. <div align="center" id="output">
  93. <div
  94. class="progress-bar progress-bar-striped progress-bar-animated"
  95. role="progressbar"
  96. aria-valuenow="95"
  97. aria-valuemin="0"
  98. aria-valuemax="100"
  99. style="width: 75%">
  100. Loading ... Please allow a few minutes to populate after any changes.</div>
  101. </div>
  102. <script>
  103. setInterval(function(){
  104. $('#output').load('mdie/show.php');
  105. }, 2000)
  106. </script>
  107. </body>
  108. </html>