Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include('./includes/connections.php');
- include('./includes/brain_file.php');
- include('./includes/style_top.php');
- echo "<center><main>City Bank</main><hr width = '80%'>";
- $time = mysql_fetch_array(mysql_query("SELECT `a_time` FROM `bank_accounts` WHERE `a_playerid` = ".$pl['playerid']));
- ?>
- <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
- <script type="text/javascript">
- var count = <?= $time['a_time'] ?>;
- var counter = setInterval(timer, 1000); //1000 will* run it every 1 second
- function timer() {
- count = count - 1;
- if(count == -1) {
- clearInterval(counter);
- return;
- }
- var seconds = count % 60;
- var minutes = Math.floor(count / 60);
- var hours = Math.floor(minutes / 60);
- minutes %= 60;
- hours %= 60;
- document.getElementById("clock").innerHTML = hours + "hours " + minutes + "minutes and " + seconds + " seconds left";
- }
- </script>
- <?php
- $q_ry = array();
- $q_ry = "SELECT * FROM `bank_accounts` WHERE `a_playerid` = ".$_SESSION['playerid'];
- $myacc = array();
- $myacc = mysql_query($q_ry);
- if(mysql_num_rows($myacc)) {
- $ma = array();
- $ma = mysql_fetch_array($myacc);
- if(($ma['a_time'] - time()) <= 0) {
- if(!$_GET['step']) {
- echo "Your investment time is now over, You have ".money_alter($ma['a_ammount'])." to withdraw.
- Would you like to withdraw it now? > <a href='bank.php?step=1'>Yes</a>";
- }
- else {
- $q_ry = array();
- $q_ry = "UPDATE `members` SET `wallet` = `wallet` + ".$ma['a_ammount'])." WHERE `playerid` = ".$_SESSION['playerid'];
- mysql_query($q_ry);
- stock_remove(2, 1);
- $q_ry = array();
- $q_ry = "DELETE FROM `bank_accounts` WHERE `a_playerid` = ".$_SESSION['playerid'];
- mysql_query($q_ry);
- echo "You have withdrawn ".money_alter($ma['a_ammount'])." from the bank, You may now start a new investment!";
- // echo "<script>var origm = " . $pl['wallet'] . "; var newm = origm + " . $ma['a_ammount'] . "; timer = setInterval('addCash();', 100);</script>";
- }
- }
- else {
- echo "<b>You have an investment running for another <span id='clock'></span></b>
- At the end of this investment you will recieve " . money_alter($ma['a_ammount']) . "
- You will then be able to start a new investment, Interest rates may vary each time you invest.";
- echo "<hr width = '80%'>><a href='city.php'>Back</a><hr width = '80%'>";
- exit;
- }
- }
- else {
- $q_ry = array();
- $q_ry = "SELECT `my_interest` FROM `members_extra` WHERE `playerid` = ".$_SESSION['playerid'];
- $extra = array();
- $extra = mysql_fetch_array(mysql_query($q_ry));
- if(!$_POST['submit']) {
- echo "<b>Please choose from a investment period that best suits you.</b>
- <b><u>NOTE:</u></b> The longer you invest for the more you will gain at the end of the period.
- The maximum investment is 2 billion!
- <form action='bank.php' method='post'>
- <table width='80%' class='rounded'>
- <tr>
- <td align='center'>
- <table width='80%' border='0'>
- <tr>
- <td align='center' width='50%'>
- <table width='100%' class='rounded'>
- <tr>
- <td align = 'left'>
- <select name='period'>
- <option value='1wk'>One Week(".(0.96 + ($extra['my_interest'] * 0.1))."% Profit)</option>
- <option value='2wk'>Two Weeks(".(2.21 + ($extra['my_interest'] * 0.3))."% Profit)</option>
- <option value='1mt'>One Month(".(4.08 + ($extra['my_interest'] * 0.9))."% Profit)</option>
- <option value='2mt'>Two Months(".(10.56 + ($extra['my_interest'] * 0.20))."% Profit)</option>
- <option value='3mt'>Three Months(".(15.36 + ($extra['my_interest'] * 0.35))."% Profit)</option>
- </select>
- </td>
- </tr>
- </table>
- </td>
- <td align='center'>
- <table width='100%' class='rounded'>
- <tr><td align='left' width='50%'><input type='text' name='amount' value='".$pl['wallet']."'></td></tr>
- </table>
- </td>
- </tr>
- </table>
- <input type='submit' name='submit' value='Invest'>
- </td>
- </tr>
- </table>
- </form>";
- }
- else {
- $_POST['amount'] = abs(@intval($_POST['amount']));
- if(!in_array($_POST['period'], array('1wk','2wk','1mt','2mt','3mt'))) {
- echo "Error, Invalid time period!<hr width = '80%'>><a href='city.php'>Back</a><hr width = '80%'>";
- include('./includes/style_bottom.php');
- exit();
- }
- else if(!$_POST['amount'] || $_POST['amount'] > 2000000000) {
- echo "Error, Either you dfidnt select an amount to invest or you entered more than 2 billion!<hr width = '80%'>><a href='city.php'>Back</a><hr width = '80%'>";
- include('./includes/style_bottom.php');
- exit();
- }
- else {
- $q_ry = array();
- $q_ry = "SELECT * FROM `bank_accounts` WHERE `a_playerid` = ".$_SESSION['playerid'];
- $myacc = array();
- $myacc = mysql_query($q_ry);
- if(mysql_num_rows($myacc)) {
- echo "Error, You already have an investment running!
- <hr width = '80%'>><a href='city.php'>Back</a><hr width = '80%'>";
- include('./includes/style_bottom.php');
- exit();
- }
- else {
- if($_POST['amount'] > $pl['wallet']) {
- echo "Sorry, You dont have enough money for this investment!<hr width = '80%'>><a href='city.php'>Back</a><hr width = '80%'>";
- include('./includes/style_bottom.php');
- exit();
- }
- else {
- $week = 86400 * 7;
- $month = 86400 * 31;
- if($_POST['period'] == "1wk") {
- $newbal = $_POST['amount'] + ($_POST['amount'] / 100 * (0.96 + ($extra['my_interest'] * 0.1)));
- $newtime = time() + $week;
- }
- if($_POST['period'] == "2wk") {
- $newbal = $_POST['amount'] + ($_POST['amount'] / 100 * (2.21 + ($extra['my_interest'] * 0.3)));
- $newtime = time() + ($week * 2);
- }
- if ($_POST['period'] == "1mt") {
- $newbal = $_POST['amount'] + ($_POST['amount'] / 100 * (4.08 + ($extra['my_interest'] * 0.9)));
- $newtime = time() + $month;
- }
- if ($_POST['period'] == "2mt") {
- $newbal = $_POST['amount'] + ($_POST['amount'] / 100 * (10.56 + ($extra['my_interest'] * 0.20)));
- $newtime = time() + ($month * 2);
- }
- if ($_POST['period'] == "3mt") {
- $newbal = $_POST['amount'] + ($_POST['amount'] / 100 * (15.36 + ($extra['my_interest'] * 0.35)));
- $newtime = time() + ($month * 3);
- }
- if (!$_POST['confirm']) {
- $intime = array('1wk' => '1 week','2wk' => '2 weeks','1mt' => '1 month','2mt' => '2 months','3mt' => '3 months');
- echo "
- <form action='bank.php' method='post'>
- Are you sure you wish to invest ".money_alter($_POST['amount'])." for ".$intime[$_POST['period']].".
- At the end of this investment you will get ".money_alter($newbal)."?
- <input type='hidden' name='amount' value='".$_POST['amount']."'>
- <input type='hidden' name='period' value='".$_POST['period']."'>
- <input type='hidden' name='submit' value='Invest'>
- <input type='submit' name='confirm' value='Invest'>
- </form>";
- }
- else {
- $q_ry = array();
- $q_ry = "INSERT INTO `bank_accounts` VALUES (NULL,".$_SESSION['playerid'].",".$newbal.",".$newtime.")";
- mysql_query($q_ry);
- $q_ry = array();
- $q_ry = "UPDATE `members` SET `wallet` = `wallet` - ".$_POST['amount']." WHERE `playerid` = ".$_SESSION['playerid'];
- mysql_query($q_ry);
- $profit = $newbal - $_POST['amount'];
- p_stats_add('tot_invest', $_POST['amount'], $_SESSION['playerid']);
- p_stats_add('tot_profit', $profit, $_SESSION['playerid']);
- echo "You have started an investment.It will take another ".gettimeleft($newtime)." before you can withdraw it.
- At the end of this time you will recieve ".money_alter($newbal)." You will then be able to start a new investment.";
- echo "<script>var origm = ".$pl['wallet']."; var newm = origm - " . $_POST['amount'] . "; timer = setInterval('minCash();', 100);</script>";
- stock_credit(2, 1);
- }
- }
- }
- }
- }
- }
- echo "<hr width = '80%'>><a href='city.php'>Back</a><hr width = '80%'>";
- include('./includes/style_bottom.php');
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement