coinlist.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <!DOCTYPE html>
  2. <?php
  3. require_once "mdie/meekrodb.php";
  4. ini_set('display_errors', '0');
  5. ?>
  6. <html>
  7. <head>
  8. <script src="jquery.min.js"></script>
  9. <link rel="stylesheet" href="bootstrap/bootstrap.min.css" media="screen">
  10. <meta http-equiv="Pragma" content="no-cache">
  11. <meta http-equiv="Expires" content="-1">
  12. </head>
  13. <body>
  14. <?php
  15. include "header.php";
  16. // update coin shares
  17. $update = $_GET["stotal"];
  18. $slug = $_GET["slug"];
  19. $sell = $_GET["sell"];
  20. $sellslug = $_GET["sellslug"];
  21. if (!$sell) {
  22. // ...
  23. } else {
  24. DB::$throw_exception_on_error = "true";
  25. try {
  26. $dbcoin = str_ireplace("-", "_", $sellslug);
  27. $mysqli_price = DB::queryRaw("SELECT priceusd from exchange_$dbcoin order by id desc limit 1");
  28. $sellprice = $mysqli_price->fetch_assoc();
  29. $sellprice_output = $sellprice["priceusd"];
  30. $sell_now = $sellprice_output * $sell;
  31. $mysqli_owned = DB::queryRaw("SELECT owned,cash from coinlist where slug=%s", $sellslug);
  32. $owned = $mysqli_owned->fetch_assoc();
  33. $cash_output = $owned["cash"];
  34. $owned_now = $owned["owned"];
  35. $owned_final = $owned_now - $sell;
  36. $cash_now = $cash_output + $sell_now;
  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. } catch(MeekroDBException $e) {
  50. echo "||Failed||";
  51. }
  52. }
  53. // buy
  54. $buy = $_GET["buy"];
  55. $buyslug = $_GET["buyslug"];
  56. if (!$buy) {
  57. // ...
  58. } else {
  59. try {
  60. $dbcoin = str_ireplace("-", "_", $buyslug);
  61. $mysqli_price = DB::queryRaw("SELECT priceusd from exchange_$dbcoin order by id desc limit 1");
  62. $buyprice = $mysqli_price->fetch_assoc();
  63. $buyprice_output = $buyprice["priceusd"];
  64. $buy_now = $buyprice_output * $buy;
  65. $mysqli_owned = DB::queryRaw("SELECT owned,cash from coinlist where slug=%s", $buyslug);
  66. $owned = $mysqli_owned->fetch_assoc();
  67. $owned_now = $owned["owned"];
  68. $cash_output = $owned["cash"];
  69. $cash_now = $cash_output - $buy_now;
  70. $owned_final = $owned_now + $buy;
  71. $mysqli_owned_update = DB::query("UPDATE coinlist SET owned=%i WHERE slug=%s", $owned_final, $buyslug);
  72. $mysqli_cash_update = DB::query("UPDATE coinlist SET cash=%i WHERE slug=%s", $cash_now, $buyslug);
  73. ?>
  74. <br /><center>
  75. <div class="card border-success mb-3" style="max-width: 90%;">
  76. <div class="card-header"><p class="text-info">Purchased at market value <?php echo $buyprice_output; ?></p></div>
  77. <div class="card-body">
  78. <h4 class="card-title"><?php echo $owned_name; ?></h4>
  79. <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>
  80. </div>
  81. </div></center>
  82. <?php
  83. } catch(MeekroDBException $e) {
  84. echo "||Failed||";
  85. }
  86. }
  87. ?>
  88. <!-- <div id="coinlist">Loading ...</div>
  89. <script>
  90. setInterval(function(){
  91. $('#coinlist').load('mdie/coinshow.php');
  92. }, 3600)
  93. </script>-->
  94. <?php include "mdie/coinshow.php"; ?>
  95. </body>
  96. </html>