Advertisement
Guest User

Untitled

a guest
Dec 6th, 2015
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 9.17 KB | None | 0 0
  1. <?php
  2. include('./includes/connections.php');
  3. include('./includes/brain_file.php');
  4. include('./includes/style_top.php');
  5. echo "<center><main>City Bank</main><hr width = '80%'>";
  6. $time = mysql_fetch_array(mysql_query("SELECT `a_time` FROM `bank_accounts` WHERE `a_playerid` = ".$pl['playerid']));
  7. ?>
  8. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
  9. <script type="text/javascript">
  10.     var count = <?= $time['a_time'] ?>;
  11.     var counter = setInterval(timer, 1000); //1000 will* run it every 1 second
  12.     function timer() {
  13.         count = count - 1;
  14.         if(count == -1) {
  15.             clearInterval(counter);
  16.             return;
  17.         }
  18.         var seconds = count % 60;
  19.         var minutes = Math.floor(count / 60);
  20.         var hours = Math.floor(minutes / 60);
  21.         minutes %= 60;
  22.         hours %= 60;
  23.         document.getElementById("clock").innerHTML = hours + "hours " + minutes + "minutes and " + seconds + " seconds left";
  24.     }
  25. </script>
  26. <?php
  27. $q_ry  = array();
  28. $q_ry  = "SELECT * FROM `bank_accounts` WHERE `a_playerid` = ".$_SESSION['playerid'];
  29. $myacc = array();
  30. $myacc = mysql_query($q_ry);
  31. if(mysql_num_rows($myacc)) {
  32.     $ma = array();
  33.     $ma = mysql_fetch_array($myacc);
  34.     if(($ma['a_time'] - time()) <= 0) {
  35.         if(!$_GET['step']) {
  36.             echo "Your investment time is now over, You have ".money_alter($ma['a_ammount'])." to withdraw.
  37.             Would you like to withdraw it now? &gt; <a href='bank.php?step=1'>Yes</a>";
  38.         }
  39.         else {
  40.             $q_ry = array();
  41.             $q_ry = "UPDATE `members` SET `wallet` = `wallet` + ".$ma['a_ammount'])." WHERE `playerid` = ".$_SESSION['playerid'];
  42.             mysql_query($q_ry);
  43.             stock_remove(2, 1);
  44.             $q_ry = array();
  45.             $q_ry = "DELETE FROM `bank_accounts` WHERE `a_playerid` = ".$_SESSION['playerid'];
  46.             mysql_query($q_ry);
  47.             echo "You have withdrawn ".money_alter($ma['a_ammount'])." from the bank, You may now start a new investment!";
  48.            // echo "<script>var origm = " . $pl['wallet'] . "; var newm = origm + " . $ma['a_ammount'] . "; timer = setInterval('addCash();', 100);</script>";
  49.         }
  50.     }
  51.     else {
  52.         echo "<b>You have an investment running for another <span id='clock'></span></b>
  53.        At the end of this investment you will recieve " . money_alter($ma['a_ammount']) . "
  54.        You will then be able to start a new investment, Interest rates may vary each time you invest.";
  55.         echo "<hr width = '80%'>&gt;<a href='city.php'>Back</a><hr width = '80%'>";
  56.         exit;
  57.     }
  58. }
  59. else {
  60.     $q_ry  = array();
  61.     $q_ry  = "SELECT `my_interest` FROM `members_extra` WHERE `playerid` = ".$_SESSION['playerid'];
  62.     $extra = array();
  63.     $extra = mysql_fetch_array(mysql_query($q_ry));
  64.     if(!$_POST['submit']) {
  65.         echo "<b>Please choose from a investment period that best suits you.</b>
  66.        <b><u>NOTE:</u></b> The longer you invest for the more you will gain at the end of the period.
  67.        The maximum investment is 2 billion!
  68.         <form action='bank.php' method='post'>
  69.             <table width='80%' class='rounded'>
  70.                 <tr>
  71.                     <td align='center'>
  72.                         <table width='80%' border='0'>
  73.                             <tr>
  74.                                 <td align='center' width='50%'>
  75.                                     <table width='100%' class='rounded'>
  76.                                         <tr>
  77.                                             <td align = 'left'>
  78.                                                 <select name='period'>
  79.                                                     <option value='1wk'>One Week(".(0.96 + ($extra['my_interest'] * 0.1))."% Profit)</option>
  80.                                                     <option value='2wk'>Two Weeks(".(2.21 + ($extra['my_interest'] * 0.3))."% Profit)</option>
  81.                                                     <option value='1mt'>One Month(".(4.08 + ($extra['my_interest'] * 0.9))."% Profit)</option>
  82.                                                     <option value='2mt'>Two Months(".(10.56 + ($extra['my_interest'] * 0.20))."% Profit)</option>
  83.                                                     <option value='3mt'>Three Months(".(15.36 + ($extra['my_interest'] * 0.35))."% Profit)</option>
  84.                                                 </select>
  85.                                             </td>
  86.                                         </tr>
  87.                                     </table>
  88.                                 </td>
  89.                                 <td align='center'>
  90.                                     <table width='100%' class='rounded'>
  91.                                         <tr><td align='left' width='50%'><input type='text' name='amount' value='".$pl['wallet']."'></td></tr>
  92.                                     </table>
  93.                                 </td>
  94.                             </tr>
  95.                         </table>
  96.                         <input type='submit' name='submit' value='Invest'>
  97.                     </td>
  98.                 </tr>
  99.             </table>
  100.         </form>";
  101.     }
  102.     else {
  103.         $_POST['amount'] = abs(@intval($_POST['amount']));
  104.         if(!in_array($_POST['period'], array('1wk','2wk','1mt','2mt','3mt'))) {
  105.             echo "Error, Invalid time period!<hr width = '80%'>&gt;<a href='city.php'>Back</a><hr width = '80%'>";
  106.             include('./includes/style_bottom.php');
  107.             exit();
  108.         }
  109.         else if(!$_POST['amount'] || $_POST['amount'] > 2000000000) {
  110.             echo "Error, Either you dfidnt select an amount to invest or you entered more than 2 billion!<hr width = '80%'>&gt;<a href='city.php'>Back</a><hr width = '80%'>";
  111.             include('./includes/style_bottom.php');
  112.             exit();
  113.         }
  114.         else {
  115.             $q_ry  = array();
  116.             $q_ry  = "SELECT * FROM `bank_accounts` WHERE `a_playerid` = ".$_SESSION['playerid'];
  117.             $myacc = array();
  118.             $myacc = mysql_query($q_ry);
  119.             if(mysql_num_rows($myacc)) {
  120.                 echo "Error, You already have an investment running!
  121.                <hr width = '80%'>&gt;<a href='city.php'>Back</a><hr width = '80%'>";
  122.                 include('./includes/style_bottom.php');
  123.                 exit();
  124.             }
  125.             else {
  126.                 if($_POST['amount'] > $pl['wallet']) {
  127.                     echo "Sorry, You dont have enough money for this investment!<hr width = '80%'>&gt;<a href='city.php'>Back</a><hr width = '80%'>";
  128.                     include('./includes/style_bottom.php');
  129.                     exit();
  130.                 }
  131.                 else {
  132.                     $week  = 86400 * 7;
  133.                     $month = 86400 * 31;
  134.                     if($_POST['period'] == "1wk") {
  135.                         $newbal  = $_POST['amount'] + ($_POST['amount'] / 100 * (0.96 + ($extra['my_interest'] * 0.1)));
  136.                         $newtime = time() + $week;
  137.                     }
  138.                     if($_POST['period'] == "2wk") {
  139.                         $newbal  = $_POST['amount'] + ($_POST['amount'] / 100 * (2.21 + ($extra['my_interest'] * 0.3)));
  140.                         $newtime = time() + ($week * 2);
  141.                     }
  142.                     if ($_POST['period'] == "1mt") {
  143.                         $newbal  = $_POST['amount'] + ($_POST['amount'] / 100 * (4.08 + ($extra['my_interest'] * 0.9)));
  144.                         $newtime = time() + $month;
  145.                     }
  146.                     if ($_POST['period'] == "2mt") {
  147.                         $newbal  = $_POST['amount'] + ($_POST['amount'] / 100 * (10.56 + ($extra['my_interest'] * 0.20)));
  148.                         $newtime = time() + ($month * 2);
  149.                     }
  150.                     if ($_POST['period'] == "3mt") {
  151.                         $newbal  = $_POST['amount'] + ($_POST['amount'] / 100 * (15.36 + ($extra['my_interest'] * 0.35)));
  152.                         $newtime = time() + ($month * 3);
  153.                     }
  154.                     if (!$_POST['confirm']) {
  155.                         $intime = array('1wk' => '1 week','2wk' => '2 weeks','1mt' => '1 month','2mt' => '2 months','3mt' => '3 months');
  156.                         echo "
  157.                         <form action='bank.php' method='post'>
  158.                             Are you sure you wish to invest ".money_alter($_POST['amount'])." for ".$intime[$_POST['period']].".
  159.                             At the end of this investment you will get ".money_alter($newbal)."?
  160.                             <input type='hidden' name='amount' value='".$_POST['amount']."'>
  161.                             <input type='hidden' name='period' value='".$_POST['period']."'>
  162.                             <input type='hidden' name='submit' value='Invest'>
  163.                             <input type='submit' name='confirm' value='Invest'>
  164.                         </form>";
  165.                     }
  166.                     else {
  167.                         $q_ry = array();
  168.                         $q_ry = "INSERT INTO `bank_accounts` VALUES (NULL,".$_SESSION['playerid'].",".$newbal.",".$newtime.")";
  169.                         mysql_query($q_ry);
  170.                         $q_ry = array();
  171.                         $q_ry = "UPDATE `members` SET `wallet` = `wallet` - ".$_POST['amount']." WHERE `playerid` = ".$_SESSION['playerid'];
  172.                         mysql_query($q_ry);
  173.                         $profit = $newbal - $_POST['amount'];
  174.                         p_stats_add('tot_invest', $_POST['amount'], $_SESSION['playerid']);
  175.                         p_stats_add('tot_profit', $profit, $_SESSION['playerid']);
  176.                         echo "You have started an investment.It will take another ".gettimeleft($newtime)." before you can withdraw it.
  177.                         At the end of this time you will recieve ".money_alter($newbal)." You will then be able to start a new investment.";
  178.                         echo "<script>var origm = ".$pl['wallet']."; var newm = origm - " . $_POST['amount'] . "; timer = setInterval('minCash();', 100);</script>";
  179.                         stock_credit(2, 1);
  180.                     }
  181.                 }
  182.             }
  183.         }
  184.     }
  185. }
  186. echo "<hr width = '80%'>&gt;<a href='city.php'>Back</a><hr width = '80%'>";
  187. include('./includes/style_bottom.php');
  188. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement