Guest User

Untitled

a guest
Nov 10th, 2015
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.92 KB | None | 0 0
  1. <?php
  2. $_GET['print'] = array_key_exists('print', $_GET) ? $_GET['print'] : null;
  3.  
  4. if(!$_GET['print']) {
  5. require('globals.php');
  6. echo "<h3><u>Bank</u></h3>";
  7. } else {
  8. $bankprice = 50000;
  9. $file = basename(__FILE__);
  10. $_POST['amount'] = array_key_exists('amount', $_POST) && ctype_digit(str_replace(',', '', $_POST['amount'])) ? str_replace(',', '', $_POST['amount']) : null;
  11. if(isset($_GET['get_bank'])) {
  12. echo (isset($_GET['simple']) ? $ir['bankmoney'] : money_formatter($ir['bankmoney']));
  13. exit;
  14. }
  15. if(isset($_GET['get_hand'])) {
  16. echo (isset($_GET['simple']) ? $ir['money'] : money_formatter($ir['money']));
  17. exit;
  18. }
  19. if($ir['bankmoney'] > 0) {
  20. new_account();
  21. if(!$_GET['print']) {
  22. $h->endpage();
  23. }
  24. exit;
  25. }
  26. if(!isset($_GET['a'])) {
  27. $_GET['a'] = null;
  28. }
  29. switch($_GET['a']) {
  30. case 'deposit':
  31. deposit();
  32. break;
  33.  
  34. case 'withdraw':
  35. withdraw();
  36. break;
  37.  
  38. default:
  39. index();
  40. break;
  41. }
  42. }
  43. function new_account() {
  44. global $db, $ir, $userid, $notl;
  45. if(!$_GET['print']) {
  46. ?>
  47. <script type = "text/javascript">
  48. function openAccount() {
  49. var c = confirm("Are you sure you want to open an account for <?php echo money_formatter($bankprice); ?>?");
  50. if (c) {
  51. $('#main_text').html('Opening you an account...<br/>');
  52. $('#main_text').append('Checking if you have the correct funds...<br/>');
  53. if(<?php echo $ir['money']; ?> < <?php echo $bankprice; ?>) {
  54. $('#main_text').append('<span style = "color:red;">You do not have enough money to open a bank, you need <?php echo money_formatter($bankprice - $ir['money']); ?>...</span><br/>');
  55. } else {
  56. $.POST('<?php echo $file; ?>?open=true&print=1', function(data) {
  57. if(data == 'not_enough_money') {
  58. $('#main_text').append('<span style = "color:red;">Not enough money...</span><br/>');
  59. } else if (data == 'opened') {
  60. $('#main_text').append('<span style = "green;">You have successfully opened your bank account.</span><br/><br/>&gt; <a href = "javascript:void(0);" onlick = "showBank();">View Account</a>');
  61. }
  62.  
  63. });
  64.  
  65. }
  66.  
  67. }
  68. function showBank() {
  69. global $db, $ir, $userid, $notl;
  70. $.GET('<?php echo $file; ?>?print=1', function(data) {
  71. $('#main_text').html(data);
  72. });
  73. }
  74. </script>
  75. <?php
  76. }
  77. if(isset($_GET['open'])) {
  78. if($ir['money'] < $bankprice) {
  79. exit('not_enough_money');
  80. } else {
  81. $db->query("UPDATE `users` SET `money` = `money` - $bankprice, `bankmoney` = 0 WHERE `userid` = {$ir['userid']}");
  82. exit('opened');
  83. }
  84. } else {
  85. echo "<spand id = 'main_text'>You currently do not have a bank account with us, would you like to open an account for only <i>" . money_formatter($bankprice) . "</i>?<br/><br/>
  86. <a href = 'javascript:void(0);' onclick = 'openAccount();'>&gt;Open an account</a></span>";
  87. }
  88. }
  89. function index() {
  90. global $db, $ir, $userid, $notl;
  91. ?>
  92. <script type = "text/javascript">
  93. function makeTrans(type) {
  94. if(type != 'withdraw' && != 'desposit') {
  95. alert('Script error!');
  96. } else {
  97. var data = $('[name = '+type+']');
  98. $.POST('<?php echo $file; ?>?print=true&a=' + type, { 'amount' : data.val() }, function(data) {
  99. $('#' + type + '_callback').html(data);
  100. $.POST('<?php echo $file; ?>?print=true&get_bank=true', function(data) {
  101. $('#bank_money').html(data); });
  102. $.POST('<?php echo $file; ?>?a=deposit&print=true&get_bank=true&simple=true', function(data) {
  103. $('[name=withdraw]').val(data); });
  104. $.POST('<?php echo $file; ?>?a=withdraw&print=true&get_bank=true&simple=true', function(data) {
  105. $('[name=deposit]').val(data); });
  106. }
  107. }
  108. }
  109. </script>
  110. <?php
  111. echo "You currently have in your back account <i><span id = 'bank_money'>" . money_formatter($ir['bankmoney']) . "</span></i> in your bank account.<br/>";
  112. echo $ir['donatordays'] ? 'You are earning 5% interest this week.<br/><br/>' : '<br/><br/>';
  113. }
  114.  
  115.  
  116.  
  117.  
  118. if(!$_GET['print']) {
  119. $h->endpage();
  120. }
Advertisement
Add Comment
Please, Sign In to add comment