Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $_GET['print'] = array_key_exists('print', $_GET) ? $_GET['print'] : null;
- if(!$_GET['print']) {
- require('globals.php');
- echo "<h3><u>Bank</u></h3>";
- } else {
- require_once('globals_nonauth.php');
- $bankprice = 50000;
- $file = basename(__FILE__);
- $_POST['amount'] = array_key_exists('amount', $_POST) && ctype_digit(str_replace(',', '', $_POST['amount'])) ? str_replace(',', '', $_POST['amount']) : null;
- if(isset($_GET['get_bank'])) {
- echo (isset($_GET['simple']) ? $ir['bankmoney'] : money_formatter($ir['bankmoney']));
- exit;
- }
- if(isset($_GET['get_hand'])) {
- echo (isset($_GET['simple']) ? $ir['money'] : money_formatter($ir['money']));
- exit;
- }
- if($ir['bankmoney'] > 0) {
- new_account();
- if(!$_GET['print']) {
- $h->endpage();
- }
- exit;
- }
- if(!isset($_GET['a'])) {
- $_GET['a'] = null;
- }
- switch($_GET['a']) {
- case 'deposit':
- deposit();
- break;
- case 'withdraw':
- withdraw();
- break;
- default:
- index();
- break;
- }
- }
- function new_account() {
- global $db, $ir, $userid, $notl;
- if(!$_GET['print']) {
- ?>
- <script type = "text/javascript">
- function openAccount() {
- var c = confirm("Are you sure you want to open an account for <?php echo money_formatter($bankprice); ?>?");
- if (c) {
- $('#main_text').html('Opening you an account...<br/>');
- $('#main_text').append('Checking if you have the correct funds...<br/>');
- if(<?php echo $ir['money']; ?> < <?php echo $bankprice; ?>) {
- $('#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/>');
- } else {
- $.POST('<?php echo $file; ?>?open=true&print=1', function(data) {
- if(data == 'not_enough_money') {
- $('#main_text').append('<span style = "color:red;">Not enough money...</span><br/>');
- } else if (data == 'opened') {
- $('#main_text').append('<span style = "green;">You have successfully opened your bank account.</span><br/><br/>> <a href = "javascript:void(0);" onlick = "showBank();">View Account</a>');
- }
- });
- }
- }
- }
- function showBank() {
- global $db, $ir, $userid, $notl;
- $.GET('<?php echo $file; ?>?print=1', function(data) {
- $('#main_text').html(data);
- });
- }
- </script>
- <?php
- }
- if(isset($_GET['open'])) {
- if($ir['money'] < $bankprice) {
- exit('not_enough_money');
- } else {
- $db->query("UPDATE `users` SET `money` = `money` - $bankprice, `bankmoney` = 0 WHERE `userid` = {$ir['userid']}");
- exit('opened');
- }
- } else {
- 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/>
- <a href = 'javascript:void(0);' onclick = 'openAccount();'>>Open an account</a></span>";
- }
- }
- function index() {
- global $db, $ir, $userid, $notl;
- ?>
- <script type = "text/javascript">
- function makeTrans(type) {
- if(type != 'withdraw' && != 'desposit') {
- alert('Script error!');
- } else {
- var data = $('[name = '+type+']');
- $.POST('<?php echo $file; ?>?print=true&a=' + type, { 'amount' : data.val() }, function(data) {
- $('#' + type + '_callback').html(data);
- $.POST('<?php echo $file; ?>?print=true&get_bank=true', function(data) {
- $('#bank_money').html(data); });
- $.POST('<?php echo $file; ?>?a=deposit&print=true&get_bank=true&simple=true', function(data) {
- $('[name=withdraw]').val(data); });
- $.POST('<?php echo $file; ?>?a=withdraw&print=true&get_bank=true&simple=true', function(data) {
- $('[name=deposit]').val(data); });
- });
- }
- }
- </script>
- <?php
- echo "You currently have in your back account <i><span id = 'bank_money'>" . money_formatter($ir['bankmoney']) . "</span></i> in your bank account.<br/>";
- echo $ir['donatordays'] ? 'You are earning 5% interest this week.<br/><br/>' : '<br/><br/>';
- }
- if(!$_GET['print']) {
- $h->endpage();
- }
Add Comment
Please, Sign In to add comment