Jump to content
MakeWebGames

Count down timer


-BRAIDZ-

Recommended Posts

  • Replies 66
  • Created
  • Last Reply

Top Posters In This Topic

 

Just like...

 

  var _seconds = <?= $infed['fj_time'] - time() ?>; 

 

Or did you mean something else?

Yeah that's what I meant.

But it's still returning In federal jail for -16808 days -15 hours -5 minutes and -24 seconds

Reason: Multi accounts

Any idea why it would be doing that?

Link to comment
Share on other sites

Just a question, how will I convert the mysql? I have tried just changing it to mysqli, but nothing..

You can not just change the file to mysqli you need to change the whole game to mysqli and the connection, I advise you read up a bit on mysqli and then when you have done your research then try again

Link to comment
Share on other sites

You can not just change the file to mysqli you need to change the whole game to mysqli and the connection, I advise you read up a bit on mysqli and then when you have done your research then try again

Thanks, I found a conversion tool

Check it, dunno if it works or not, but do you reckon this will if I convert all my code by this converter?

brain_file.php:

http://pastebin.com/fHx1gCG5

Link to comment
Share on other sites

  • 1 month later...

Okay I have found a timer that runs off the gettimeleft function in includes/brain_file.php

The timer is in this file

<?php
/*------------includes--------------*/
include('./includes/connections.php');
include('./includes/brain_file.php');
include('./includes/style_top.php');
/*------------includes--------------*/
echo "<center><main>Auction House</main><hr width = '75%'>You begin viewing the auctions and hope of find something of interest.<hr width = '75%'>";

if ($pl['my_jail'] > gmtime() || $pl['my_hosp'] > gmtime()) {
   echo "<center><hr width='75%'/>Sorry this page is not viewable while in jail or hospital!<hr width='75%'/></center>";
   include('./includes/style_bottom.php');
   exit();
}


switch ($_GET['action']) {

   case "bid":
       auction_bid();
       break;

   case "add":
       auction_add();
       break;

   case "add_item":
       auction_add_item();
       break;

   default:
       auction_index();
       break;
}

function auction_index()
{


   echo "<a href='auction.php?action=add_item'>> Add Listing</a><hr width = '75%'>";
   $item_c = mysql_query("SELECT * FROM `item_classes`");
   $item_c = mysql_num_rows($item_c);


   $settime = array();
   For ($i = 1; $i <= $item_c; $i++) {
       $auctions = mysql_query("SELECT a.*,i.* FROM `auctions` a LEFT JOIN `items` i ON a.item = i.item_id WHERE i.item_class = " . $i);
       If (mysql_num_rows($auctions)) {
           $itm_class = mysql_fetch_assoc(mysql_query("SELECT * FROM `item_classes` WHERE `item_classid` = " . $i));

           echo "<h3>" . $itm_class['item_classname'] . "</h3>
  <table class = 'rounded' width = '75%'>
  <tr bgcolor = '#999999' align='left'>
  <th>#</th>
  <th>Item</th>
  <th>Seller</th>
  <th>Current Bid</th>
  <th>Top Bidder</th>
  <th width='37%'>Hours Left</th>
  <th>Action</th>
  </tr>";
           $color = 'odds';
           While ($au = mysql_fetch_assoc($auctions)) {
               $owner = mysql_fetch_assoc(mysql_query("SELECT `playername` FROM `members` WHERE `playerid` = " . $au['owner']));
               $owner = $owner['playername'];

               if ($au['bidder']) {
                   $bidder = mysql_fetch_assoc(mysql_query("SELECT `playername` FROM `members` WHERE `playerid` = " . $au['bidder']));
                   $bidder = $bidder['playername'];
               } else if (!$au['bidder']) {
                   $bidder = 'N/A';
               }

               $settime[] = $au['id'] . ":" . $au['time'];

               if ($color == "evens") {
                   $color = "odds";
               } else if ($color == "odds") {
                   $color = "evens";
               }
               echo "<tr class = '" . $color . "'>
            <td>" . $au['id'] . "</td>
            <td>" . $au['item_name'] . "</td>
            <td><a href='profile.php?XID=" . $au['owner'] . "'>" . $owner . "</a></td>
            <td>$" . number_format($au['bid']) . "</td>
            <td><a href='profile.php?XID=" . $au['bidder'] . "'>" . $bidder . "</a></td>
            <td><div id = 'time" . $au['id'] . "'><b>" . gettimeleft($au['time']) . "</b></div></td>
            <td><a href='iinfo.php?XID=" . $au['item'] . "'>[info]</a> | <a href='auction.php?action=bid&id=" . $au['id'] . "'>[bid]</a></td></tr>";
               $owner  = '';
               $bidder = '';
           }
           echo "</table>";
       }
   }



?>


  <script type = 'text/javascript'>
  window.onload=function() {
  setInterval("<?php
   $array = count($settime);
   for ($i = 0; $i < $array; $i++) {
       $thitime = explode(":", $settime[$i]);
       echo "timeleft(" . $thitime[1] . ", " . $thitime[0] . "); ";
   }
?>", 1000);
  }
  function timeleft(string, id)
  {
     var xmlhttp=GetXmlHttpObject();
     if(xmlhttp==null) { alert("Sorry, Your browser doesnt support HTTP Requests");
     return;
     }
     var elem = "time" + id;
     var load = "time_left.php?string=" + string;
     xmlhttp.onreadystatechange=function() {
        if(xmlhttp.readyState==4) {
           document.getElementById(elem).innerHTML = xmlhttp.responseText;
        }
     }
     xmlhttp.open("GET", load, true);
     xmlhttp.send(null);
  }
  function GetXmlHttpObject() {
  var xmlhttp=null;
  try {
       xmlhttp=new XMLHttpRequest();
      }
       catch (e) {
                  try {
                       xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
                      }
                       catch (e) {
                                  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
                                 }
                  }
  return xmlhttp;
  }
  </script>


<?php

}


function auction_bid()
{
   global $pl;

   if (isset($_POST['submit']) AND ctype_digit($_POST['bid']) AND ctype_digit($_POST['id'])) {

       $_POST['id'] = mysql_real_escape_string($_POST['id']);
       $bid         = mysql_real_escape_string($_POST['bid']);

       $auction_check = mysql_query("SELECT * FROM `auctions` WHERE `id` = " . $_POST['id']);

       if (!mysql_num_rows($auction_check)) {
           echo "No such auction.";
           include('./includes/style_bottom.php');
           exit();
       }

       $au_check = mysql_fetch_array($auction_check);

       if ($bid > $pl['wallet']) {
           echo "Error - You do not have enough money to bid that much.";
       } else if ($bid <= $au_check['bid']) {
           echo "Error - You cannot bid equal to or below the current bid.";
       } else if ($au_check['owner'] == $_SESSION['playerid']) {
           echo "Error - You cannot bid on Your own auction.";
       } else if ($au_check['bidder'] == $_SESSION['playerid']) {
           echo "Error - You cannot outbid Yourself.";
       } else {

           mysql_query("UPDATE `members` SET `wallet` = `wallet` - $bid WHERE `playerid` = " . $_SESSION['playerid']);
           mysql_query("UPDATE `members` SET `wallet` = `wallet` + " . $au_check['bid'] . " WHERE `playerid` = " . $au_check['bidder']);
           mysql_query("UPDATE `auctions` SET `bids` = `bids` + 1, `lastbid` = `bid`, `lastbidder` = `bidder`, `bidder` = " . $_SESSION['playerid'] . ", `bid` = " . $bid . " WHERE `id` = " . $_POST['id']);

           $left = gettimeleft($au_check['time']);
           $itm  = mysql_fetch_assoc(mysql_query("SELECT `item_name` FROM `items` WHERE `item_id` = " . $au_check['item']));

           event_add($au_check['bidder'], $pl['playername'] . ' outbid you on the ' . $itm['item_name'] . ' with a bid of $' . number_format($bid) . '. This auction still has ' . gettimeleft($au_check['time']) . ' left to go!');
           event_add($au_check['owner'], $pl['playername'] . ' bid $' . number_format($bid) . ' on Your ' . $itm['item_name'] . '. The auction still has ' . $left . ' left to go!');
           Echo "You have bidded on this auction!";

       }
   } else if (isset($_GET['id'])) {
       $auction = mysql_query("SELECT * FROM `auctions` WHERE `id` = " . $_GET['id']);
       If (mysql_num_rows($auction)) {
           $a       = mysql_fetch_array($auction);
           $current = $a['bid'] + 1;

           echo "
<form method='POST'>
Bid: $<input type='text' name='bid' value='" . $current . "' /><br /><br />
<input type='hidden' name='id' value='" . $_GET['id'] . "' /><br /><br />
<input type='submit' name='submit' value='Bid' />
</form><br /><br />";


       } else {
           echo "Error.";
       }
   } else {
       echo "Error.";
   }
}






function auction_add()
{
   global $pl;

   if (isset($_POST['add']) AND ctype_digit($_POST['price']) AND ctype_digit($_POST['length']) AND ctype_digit($_POST['item'])) {

       $_POST['item']   = mysql_real_escape_string($_POST['item']);
       $_POST['price']  = mysql_real_escape_string($_POST['price']);
       $_POST['length'] = mysql_real_escape_string($_POST['length']);

       $item_check = mysql_query("SELECT * FROM `members_items` WHERE `it_itemid` = " . $_POST['item'] . " AND `it_playerid` = " . $_SESSION['playerid']);
       if (!mysql_num_rows($item_check)) {
           echo "You do not own this item.";
       } else if ($_POST['length'] > 48 || $_POST['length'] < 1) {
           Echo "Length must be 48 hours or less.";
       } else {

           $itm = mysql_fetch_array($item_check);
           If ($itm['it_qty'] > 1) {
               mysql_query("UPDATE `members_items` SET `it_qty` = `it_qty` - 1 WHERE `it_itemid` = " . $_POST['item'] . " AND `it_playerid` = " . $_SESSION['playerid']);
           } else {
               mysql_query("DELETE FROM `members_items` WHERE `it_itemid` = " . $_POST['item'] . " AND `it_playerid` = " . $_SESSION['playerid']);
           }

           $time = time() + (60 * 60 * $_POST['length']);

           mysql_query("INSERT INTO `auctions` (id, owner, item, bid, bidder, bids, lastbidder, lastbid, time) VALUES ('', " . $_SESSION['playerid'] . ", " . $_POST['item'] . ", " . $_POST['price'] . ", '', '', '', '', " . $time . ")");


           echo "Item added to auction!<hr width = '75%'>> <a href=auction.php> Back</a><hr width = '75%'>";

       }
   } else if (isset($_GET['id'])) {

       echo "
<form method='POST'>
Starting Bid: $<input type='text' name='price' /><br /><br />
Hours to keep on auction: <input type='text' name='length' size='small' /> (Max: 48)
<input type='hidden' name='item' value='" . $_GET['id'] . "' /><br /><br />
<input type='submit' name='add' value='Add To Auction' />
</form><br /><br />";



   } else {
       echo "Error.";
   }
}


function auction_add_item()
{

   $items = mysql_query("SELECT m.*,i.* FROM `members_items` m LEFT JOIN `items` i ON m.it_itemid = i.item_id WHERE m.it_playerid = " . $_SESSION['playerid'] . " ORDER BY i.item_class ASC");

   if (mysql_num_rows($items)) {
       echo "<table class = 'rounded' width = '75%'>
<tr bgcolor = '#999999' align='left'>
<th width='50%'>Name</th>
<th width='20%'>Type</th>
<th width='5%'>Add</th>
</tr>";
       $color = '#D8D8D8';

       while ($i = mysql_fetch_assoc($items)) {
           $ic = mysql_fetch_assoc(mysql_query("SELECT `item_classname` FROM `item_classes` WHERE `item_classid` = " . $i['item_class']));



           if ($i['it_qty'] > 1) {
               For ($j = $i['it_qty']; $j > 0; $j--) {

                   if ($color == "#e3e3e3") {
                       $color = "#D8D8D8";
                   } Else If ($color == "#D8D8D8") {
                       $color = "#e3e3e3";
                   }

                   echo "<tr bgcolor = '" . $color . "'>
         <td>" . $i['item_name'] . "</td>
         <td>" . $ic['item_classname'] . "</td>
         <td><a href='auction.php?action=add&id=" . $i['item_id'] . "'>[Add]</a></td>
        </tr>";

               }
           } else {

               If ($color == "#e3e3e3") {
                   $color = "#D8D8D8";
               } Else If ($color == "#D8D8D8") {
                   $color = "#e3e3e3";
               }

               echo "<tr bgcolor = '" . $color . "'>
         <td>" . $i['item_name'] . "</td>
         <td>" . $ic['item_classname'] . "</td>
         <td><a href='auction.php?action=add&id=" . $i['item_id'] . "'>[Add]</a></td>
        </tr>";

           }
       }

       echo "</table>";
   } else {
       echo "You have no items.";
   }

}


include('./includes/style_bottom.php');
?>

And I want to put it in this file.. I have tried, but can't seem to get it to work....

<?php    
  /*------------includes--------------*/
  include ('./includes/connections.php');
  include ('./includes/brain_file.php');
  include ('./includes/style_top.php');
  /*------------includes--------------*/
if($pl['my_tuts_on'] == 'yes')
   {

     echo "<hr/ width=95%><table class='hyd-tuttable' width='95%' cellspacing='1' cellpadding='4' align='center'>
<th align=left>Tutorials<a href='preferences.php?action=tutchange'><img src='http://www.torn.com/images/on-off.png' width='15' height='15' alt='Off Switch' align='right'></a></th>
<tr bgcolor=#E6E6E6><td>
            Here you can view all the inmates at murder city jail. You may attempt to bust/bail them, Bailing them costs a fee, Busting them uses 10 energy and is not a garantee you will bust them, Just be carefull not to get caught and end up in jail yourself.
            </td></td></tr></table></center><hr/ width=95%>";
  }

  echo "<center><main>Jail</main><hr width='95%'/>";



   if($pl['my_hosp'] > gmtime())
   {
   echo "Sorry this page is not viewable while in hospital!<hr width='85%'/>";
   include ('./includes/style_bottom.php');
   exit();
   }
  $_GET['page'] = abs(intval($_GET['page']));
  $min = ($_GET['page']>'1') ? (($_GET['page']-1)*25) : $min = 0;
  $q_ry = array();
  $q_ry = "SELECT `playerid` FROM `members`
           WHERE `my_jail` > '".mysql_real_escape_string(gmtime())."'";
  $tot = array();
  $tot = mysql_query($q_ry);

  if($joh['my_jail'] > gmtime())
  {
   echo "<br><font size=2><b>",stripslashes($pl['jail_reason']),"</b>
         <br>You will be in jail for another ".gettimeleft($pl[my_jail])." yet!</font><br><br><hr width='85%'>";
  }

   if($pl['my_jail'] > gmtime())
   {
   echo "<b>><a href='bust.php'>Try and escape for ".abs(intval($pl['my_maxnerve'] / 2))." nerve!</a></b>
         <hr width='85%'>";
   }

  echo "<b></b> ";
  if(mysql_num_rows($tot)<='25')
  {
    echo "";
  }
  else
  {
  if($_GET['page'] > '1')
  {
  echo "<a href='jail.php?page=".($_GET['page']-1)."'><<</a> ";
  }
  for($i = 0; $i<(mysql_num_rows($tot)/25); $i++)
  {
     echo "<a href='jail.php?page=".($i+1)."'>";
     if(($i+1) == $_GET['page'])
     {
      echo "<b>".($i+1)."</b>";
     }
     else
     {
      echo "<font color = '#999999'>".($i+1)."</font>";
     }
     echo "</a> ";
  }
  if($_GET['page'] < $i)
  {
  echo " <a href='jail.php?page=".($_GET['page']+1)."'>>></a>";
  }
  }


  echo "<table class='sidebarLink' border='0' width=95% class='rounded'><tr bgcolor=#151515>
        <td height='20'><font color = '#FFFFFF'><b>ID#</b></font></td>
        <td height='20'><font color = '#FFFFFF'><b>Player</b></font></td>
        <td width=25%><font color = '#FFFFFF'><b>Time</b></font></td>
        <td height='20'><font color = '#FFFFFF'><b>Level</b></font></td>
        <td height='20'><font color = '#FFFFFF'><b>Reason</b></font></td>
        <td height='20'><font color = '#FFFFFF'><b>Bust Reward</b></font></td>
        <td height='20'><font color = '#FFFFFF'><b>Release</b></font></td></tr>";
        $num=0;

        $q_ry = array();
        $q_ry = "SELECT `playerid`,`playername`,`my_level`,`jail_offer`,`my_jail`,`jail_reason`
                 FROM `members`
                 WHERE `my_jail` > '".mysql_real_escape_string(gmtime())."'
                 ORDER BY `my_jail` DESC
                 LIMIT $min,25";
        $hopl = array();
        $hopl = mysql_query($q_ry);
        if(mysql_num_rows($hopl))
        {
          $hp = array();
          while ($hp = mysql_fetch_array($hopl))
          {
           $num++;
           if ($num % 2) { $color="#E6E6E6"; } else { $color="#E6E6E6"; }
        $q_ry = array();
        $q_ry = "SELECT `my_bustreward`
                 FROM `members_extra`
                 WHERE `playerid` = '".$hp['playerid']."'";
        $du = array();
        $du = mysql_fetch_array(mysql_query($q_ry));
           echo "<tr bgcolor=#E6E6E6>
           <td><a href = 'messages.php?action=send&XID=".$hp['playerid']."'>".$hp['playerid']."</a></td>
           <td><a href = 'profile.php?XID=".$hp['playerid']."'>".htmlentities($hp['playername'])."</a></td>
           <td>".gettimeleft($hp['my_jail'])."</td>
           <td>".$hp['my_level']."</td>
           <td>".stripslashes($hp['jail_reason'])."</td>
           <td>".money_alter($du['my_bustreward'])."</td>
           <td>[<a href='release.php?action=bail&XID=".$hp['playerid']."'>Bail</a>]
               [<a href='release.php?action=bust&XID=".$hp['playerid']."'>Bust</a>]</td></tr>";
       }
    }
    else
       {
        echo "<tr>
              <td colspan = '7' align = 'center'>
              You walk into the jail to tease some inmates, but there are no inmates to tease!
              </td></tr>";
       }
        echo "</table>
              <hr width = '95%'>";
if($pl['my_jail']>gmtime() || $pl['am_i_staff']>4)
{
if($pl['am_i_staff'] > 4)
   {
       echo '<table width="95%" align="center" border="0" bgcolor="#E6E6E6">
       <b>Clear the current shoutbox.</b>
       <form method="post" action="#"><tr>
       <td><input type="hidden" name="clear"></td>
       </tr><tr>
       <td colspan="2" valign="middle" align="center"><input class="hospchat" type="submit" value="Clear ALL Shouts"></td>
       <td></td>
       </tr></form></table><br />';
   }
if(isset($_POST['clear']))
   {
   if($pl['am_i_staff'] < 5)
   {
   print "Sorry, staff only. <a href=jail.php>> back</a>.";
   exit();
   }
   else
   {
       mysql_query("TRUNCATE table `jailshoutsbox`");
       print "All of the jail shouts have been <b>cleared</b> <a href=jail.php>> back</a>.";
   }
   }
if(isset($_POST['shout']))
   {
       if($pl['lastShoutj'] == date("i") && $pl['am_i_staff'] < 5 && $pl['my_dondays'] < 1)
           {
               echo "<div style='background: #DFDFDF;' width='85%'>Sorry, non donators can only post once per minute. <br /> <a href=jail.php> > back</a></div><br />";
               exit();
           }
       if($pl['my_jail'] <= 0 && $pl['am_i_staff'] < 5)
       {
       echo "You are not in the jail. <a href=jail.php>> Back</a>";
       exit ();
       }
       echo "<div style='background: #E6E6E6;' width='85%'>You've shouted<br /><a href=jail.php>Refresh</a></div><br />";

       $_POST['shout'] = htmlspecialchars(($_POST['shout']));

$not = array("'", "/", "<", ">", ";");
$_POST['shout'] = str_replace($not, "", $_POST['shout']);


       mysql_query("INSERT INTO `jailshoutsbox` VALUES ('NULL', {$_SESSION['playerid']}, '{$_POST['shout']}', ".date("d").")");
   }


   echo '    <hr width=95% /> Post a message on the shoutbox.
       <table width="95%" align="center" border="0" bgcolor="#E6E6E6">
       <form method="post" action="#"><tr>
       <td>Your Message: (max 155) </td>
       <td><input class="hospchat" type="text" name="shout" maxlength="155"></td>
       </tr><tr>
       <td colspan="2" valign="middle" align="center"><input class="hospchat" type="submit" value="Shout"></td>
       <td></td>
       </tr></form></table><br /><table width="95%" style=text-align:left class="table2" border="0" cellspacing="2">
       <tr bgcolor="#151515" style="font-style:bold; text-align:center;"><td style="font-style:bold;" width=55%><b><font color="#FFFFFF">Posted By:</b></td><td style="font-style:bold;" width="44%"><b><font color="#FFFFFF">Messsage:</b></td></tr>
       ';

   $get = mysql_query("SELECT * FROM `jailshoutsbox` ORDER BY `ID` DESC LIMIT 10");
   while($r = mysql_fetch_array($get))    
       {
       $num9=$num9+1;
           $odd9="#CCCCCC";
           $even9="#e3e3e3";
           if ($num9 % 2) {
           $color9="$even9";
           } else {
           $color9="$odd9";
           }
           if($r['User']==1)
           {
           $r['Shout']="<font color='blue'>".$r['Shout']."</font>";
           }
           $user = mysql_query("SELECT `playername` FROM `members` WHERE `playerid`={$r['User']}");
                       while($user1 = mysql_fetch_array($user))
           $player = ($r['User'] == 0) ? "SYSTEM" : "<a href='profile.php?XID={$r['User']}'>[{$r['User']}] {$user1['playername']}</a>";
           echo "<tr height='50px' bgcolor=#E6E6E6><td>$player</td><td style='text-align:center;'>{$r['Shout']}</td></tr>";
       }
       echo "</table>";
}


  include ('./includes/style_bottom.php');
?>

 

Link to comment
Share on other sites

  • 5 months later...

I have got a new timer problem, I have had it working, there is two timers on the one script though, so one will run but the other won't, then when I delete the one that works the one that wasn't working will then work..

The first timer is the one that isn't working starting at line 34 ending on line 81, and the second which is working starts on line 142 and ends on line 195.

Would anyone be able to kindly lead me in the right direction to get them both going at the same time?

Thank you

 

<?php
/*------------includes--------------*/
include('./includes/connections.php');
include('./includes/brain_file.php');
include('./includes/style_top.php');
/*------------includes--------------*/

echo "<center><main>Jail</main><hr width='95%'/>";



if ($pl['my_hosp'] > gmtime()) {
   echo "Sorry this page is not viewable while in hospital!<hr width='85%'/>";
   include('./includes/style_bottom.php');
   exit();
}
$_GET['page'] = abs(intval($_GET['page']));
$min          = ($_GET['page'] > '1') ? (($_GET['page'] - 1) * 25) : $min = 0;
$q_ry         = array();
$q_ry         = "SELECT `playerid` FROM `members`
           WHERE `my_jail` > '" . mysql_real_escape_string(gmtime()) . "'";
$tot          = array();
$tot          = mysql_query($q_ry);

if ($joh['my_jail'] > gmtime()) {
   $settime[] = $pl['playerid'] . ":" . $pl['my_jail'];
   echo "<br><font size=2><b>", stripslashes($pl['jail_reason']), "</b>
         <br>You will be in jail for another <span id = 'time" . $pl['playerid'] . "'><b>" . gettimeleft($pl['my_jail']) . "</b></span> yet!</font><br><br><hr width='85%'>";
}
?>
  <script type = 'text/javascript'>
  window.onload=function() {
  setInterval("<?php
$array = count($settime);
for ($i = 0; $i < $array; $i++) {
   $thitime = explode(":", $settime[$i]);
   echo "timeleft(" . $thitime[1] . ", " . $thitime[0] . "); ";
}
?>", 1000);
  }
  function timeleft(string, id)
  {
     var xmlhttp=GetXmlHttpObject();
     if(xmlhttp==null) { alert("Sorry, Your browser doesnt support HTTP Requests");
     return;
     }
     var elem = "time" + id;
     var load = "time_left.php?string=" + string;
     xmlhttp.onreadystatechange=function() {
        if(xmlhttp.readyState==4) {
           document.getElementById(elem).innerHTML = xmlhttp.responseText;
        }
     }
     xmlhttp.open("GET", load, true); 
     xmlhttp.send(null);
  }
  function GetXmlHttpObject() {
  var xmlhttp=null;
  try {
       xmlhttp=new XMLHttpRequest();
      }
       catch (e) {
                  try {
                       xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
                      }
                       catch (e) {
                                  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
                                 }
                  }
  return xmlhttp;
  }
  </script>
  <?php

if ($pl['my_jail'] > gmtime()) {
   echo "<b>><a href='bust.php'>Try and escape for " . abs(intval($pl['my_maxnerve'] / 2)) . " nerve</a></b>
         <hr width='85%'>";
}

echo "<b></b> ";
if (mysql_num_rows($tot) <= '25') {
   echo "";
} else {
   if ($_GET['page'] > '1') {
       echo "<a href='jail.php?page=" . ($_GET['page'] - 1) . "'><<</a> ";
   }
   for ($i = 0; $i < (mysql_num_rows($tot) / 25); $i++) {
       echo "<a href='jail.php?page=" . ($i + 1) . "'>";
       if (($i + 1) == $_GET['page']) {
           echo "<b>" . ($i + 1) . "</b>";
       } else {
           echo "<font color = '#999999'>" . ($i + 1) . "</font>";
       }
       echo "</a> ";
   }
   if ($_GET['page'] < $i) {
       echo " <a href='jail.php?page=" . ($_GET['page'] + 1) . "'>>></a>";
   }
}


echo "<table class='sidebarLink' border='0' width=95% class='rounded'><tr bgcolor=#151515>
        <td height='20'><font color = '#FFFFFF'><b>ID#</b></font></td>
        <td height='20'><font color = '#FFFFFF'><b>Player</b></font></td>
        <td width=25%><font color = '#FFFFFF'><b>Time</b></font></td>
        <td height='20'><font color = '#FFFFFF'><b>Level</b></font></td>
        <td height='20'><font color = '#FFFFFF'><b>Reason</b></font></td>
        <td height='20'><font color = '#FFFFFF'><b>Release</b></font></td></tr>";
$num = 0;

$q_ry = array();
$q_ry = "SELECT `playerid`,`playername`,`my_level`,`jail_offer`,`my_jail`,`jail_reason` 
                 FROM `members` 
                 WHERE `my_jail` > '" . mysql_real_escape_string(gmtime()) . "'
                 ORDER BY `my_jail` DESC
                 LIMIT $min,25";
$hopl = array();
$hopl = mysql_query($q_ry);
if (mysql_num_rows($hopl)) {
   $hp = array();
   while ($hp = mysql_fetch_array($hopl)) {
       $num++;
       if ($num % 2) {
           $color = "#E6E6E6";
       } else {
           $color = "#E6E6E6";
       }
       $q_ry       = array();
       $q_ry       = "SELECT `my_bustreward` 
                 FROM `members_extra` 
                 WHERE `playerid` = '" . $hp['playerid'] . "'";
       $du         = array();
       $du         = mysql_fetch_array(mysql_query($q_ry));
       $settime2[] = $hp['playerid'] . ":" . $hp['my_jail'];

       echo "<tr bgcolor=#E6E6E6>
           <td><a href = 'messages.php?action=send&XID=" . $hp['playerid'] . "'>" . $hp['playerid'] . "</a></td>
           <td><a href = 'profile.php?XID=" . $hp['playerid'] . "'>" . htmlentities($hp['playername']) . "</a></td>
           <td><span id = 'time2" . $hp['playerid'] . "'><b>" . gettimeleft($hp['my_jail']) . "</b></span></td>
           <td>" . $hp['my_level'] . "</td>
           <td>" . stripslashes($hp['jail_reason']) . "</td>
           <td>[<a href='release.php?action=bail&XID=" . $hp['playerid'] . "'>Bail</a>] 
               [<a href='release.php?action=bust&XID=" . $hp['playerid'] . "'>Bust</a>]</td></tr>";
?>
               <script type = 'text/javascript'>
  window.onload=function() {
  setInterval("<?php
       $array = count($settime2);
       for ($i = 0; $i < $array; $i++) {
           $thitime = explode(":", $settime2[$i]);
           echo "timeleft(" . $thitime[1] . ", " . $thitime[0] . "); ";
       }
?>", 1000);
  }
  function timeleft(string, id)
  {
     var xmlhttp=GetXmlHttpObject();
     if(xmlhttp==null) { alert("Sorry, Your browser doesnt support HTTP Requests");
     return;
     }
     var elem = "time2" + id;
     var load = "time_left.php?string=" + string;
     xmlhttp.onreadystatechange=function() {
        if(xmlhttp.readyState==4) {
           document.getElementById(elem).innerHTML = xmlhttp.responseText;
        }
     }
     xmlhttp.open("GET", load, true); 
     xmlhttp.send(null);
  }
  function GetXmlHttpObject() {
  var xmlhttp=null;
  try {
       xmlhttp=new XMLHttpRequest();
      }
       catch (e) {
                  try {
                       xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
                      }
                       catch (e) {
                                  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
                                 }
                  }
  return xmlhttp;
  }
  </script>
  <?php

   }
} else {
   echo "<tr>
              <td colspan = '7' align = 'center'>
              You walk into the jail to tease some inmates, but there are no inmates to tease!
              </td></tr>";
}
echo "</table>
              <hr width = '95%'>";
if ($pl['my_jail'] > gmtime() || $pl['am_i_staff'] > 4) {
   if ($pl['am_i_staff'] > 4) {
       echo '<table width="95%" align="center" border="0" bgcolor="#E6E6E6">
       <b>Clear the current shoutbox.</b>
       <form method="post" action="#"><tr>
       <td><input type="hidden" name="clear"></td>
       </tr><tr>
       <td colspan="2" valign="middle" align="center"><input class="hospchat" type="submit" value="Clear ALL Shouts"></td>
       <td></td>
       </tr></form></table><br />';
   }
   if (isset($_POST['clear'])) {
       if ($pl['am_i_staff'] < 5) {
           print "Sorry, staff only. <a href=jail.php>> back</a>.";
           exit();
       } else {
           mysql_query("TRUNCATE table `jailshoutsbox`");
           print "All of the jail shouts have been <b>cleared</b> <a href=jail.php>> back</a>.";
       }
   }
   if (isset($_POST['shout'])) {
       if ($pl['lastShoutj'] == date("i") && $pl['am_i_staff'] < 5 && $pl['my_dondays'] < 1) {
           echo "<div style='background: #DFDFDF;' width='85%'>Sorry, non donators can only post once per minute. <br /> <a href=jail.php> > back</a></div><br />";
           exit();
       }
       if ($pl['my_jail'] <= 0 && $pl['am_i_staff'] < 5) {
           echo "You are not in the jail. <a href=jail.php>> Back</a>";
           exit();
       }
       echo "<div style='background: #E6E6E6;' width='85%'>You've shouted<br /><a href=jail.php>Refresh</a></div><br />";

       $_POST['shout'] = htmlspecialchars(($_POST['shout']));

       $not            = array(
           "'",
           "/",
           "<",
           ">",
           ";"
       );
       $_POST['shout'] = str_replace($not, "", $_POST['shout']);


       mysql_query("INSERT INTO `jailshoutsbox` VALUES ('NULL', {$_SESSION['playerid']}, '{$_POST['shout']}', " . date("d") . ")");
   }


   echo '    <hr width=95% /> Post a message on the shoutbox.
       <table width="95%" align="center" border="0" bgcolor="#E6E6E6">
       <form method="post" action="#"><tr>
       <td>Your Message: (max 155) </td>
       <td><input class="hospchat" type="text" name="shout" maxlength="155"></td>
       </tr><tr>
       <td colspan="2" valign="middle" align="center"><input class="hospchat" type="submit" value="Shout"></td>
       <td></td>
       </tr></form></table><br /><table width="95%" style=text-align:left class="table2" border="0" cellspacing="2">
       <tr bgcolor="#151515" style="font-style:bold; text-align:center;"><td style="font-style:bold;" width=55%><b><font color="#FFFFFF">Posted By:</b></td><td style="font-style:bold;" width="44%"><b><font color="#FFFFFF">Messsage:</b></td></tr>
       ';

   $get = mysql_query("SELECT * FROM `jailshoutsbox` ORDER BY `ID` DESC LIMIT 10");
   while ($r = mysql_fetch_array($get)) {
       $num9  = $num9 + 1;
       $odd9  = "#CCCCCC";
       $even9 = "#e3e3e3";
       if ($num9 % 2) {
           $color9 = "$even9";
       } else {
           $color9 = "$odd9";
       }
       if ($r['User'] == 1) {
           $r['Shout'] = "<font color='blue'>" . $r['Shout'] . "</font>";
       }
       $user = mysql_query("SELECT `playername` FROM `members` WHERE `playerid`={$r['User']}");
       while ($user1 = mysql_fetch_array($user))
           $player = ($r['User'] == 0) ? "SYSTEM" : "<a href='profile.php?XID={$r['User']}'>[{$r['User']}] {$user1['playername']}</a>";
       echo "<tr height='50px' bgcolor=#E6E6E6><td>$player</td><td style='text-align:center;'>{$r['Shout']}</td></tr>";
   }
   echo "</table>";
}


include('./includes/style_bottom.php');
?>
Link to comment
Share on other sites

There are a couple of things you need to consider here:

  1. You cannot simply copy/paste these JS functions and expect them to work multiple times over. Just like PHP functions, you can't have the same function name written multiple times throughout the course of your program without causing inconsistent results. This includes the onload function, the setInterval function, etc.
  2. window.onload is a base JavaScript DOM function that can only be called once, unless you are running multiple threads, which JS does not support "out of the box". Doing so is far beyond the scope of this forum - if others would like to elaborate on that they can do so. This again brings me back to point 1 that you cannot do a copy/paste of JS code - you have to actually dig into what it's doing.

In terms of a solution to your issue, it won't be an "easy fix" - it will require quite a lot of rework, but the best suggestion is to lead more towards something like this: http://stackoverflow.com/questions/22796620/multiple-countdown-timers-on-one-page but instead activating those timers on load rather than via a click of a button.

~G7470

Link to comment
Share on other sites

There are a couple of things you need to consider here:
  1. You cannot simply copy/paste these JS functions and expect them to work multiple times over. Just like PHP functions, you can't have the same function name written multiple times throughout the course of your program without causing inconsistent results. This includes the onload function, the setInterval function, etc.
  2. window.onload is a base JavaScript DOM function that can only be called once, unless you are running multiple threads, which JS does not support "out of the box". Doing so is far beyond the scope of this forum - if others would like to elaborate on that they can do so. This again brings me back to point 1 that you cannot do a copy/paste of JS code - you have to actually dig into what it's doing.

In terms of a solution to your issue, it won't be an "easy fix" - it will require quite a lot of rework, but the best suggestion is to lead more towards something like this: http://stackoverflow.com/questions/22796620/multiple-countdown-timers-on-one-page but instead activating those timers on load rather than via a click of a button.

~G7470

Thank you, I will have a look at that soon

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...