Jump to content
MakeWebGames

Crons


AdamHull

Recommended Posts

i am having problem implementing crons on my site i have done the command on the cpanel as below

[ATTACH=CONFIG]1432[/ATTACH]

 

<?php
session_start();

if (!isset($_SESSION['id'])){
   include('home.php');
   die();
}

include 'dbcon.php';

if (isset($_POST['clean_sb'])) {

   if (isset($_POST['token']) && $_POST['token'] == $_SESSION['token']) {
       $soc = mysql_query("SELECT admin FROM grpgusers WHERE id=". mysql_real_escape_string($_SESSION['id']));
$f = mysql_fetch_assoc($soc);
if($f['admin'] != 1)
{
 //Do nothing
}
else
{
 mysql_query("TRUNCATE table shoutbox_kyle");
}
   } else {
       echo 'The request expired.';
   }

}


include 'classes.php';
$profile_class = new User($_GET['id']);

if ($_GET['action'] == "logout"){
session_destroy();
die('<style type="text/css">
<!--

body {

background-color: #000000;
}
-->
</style><meta http-equiv="refresh" content="0;url=index.php"><center><img src=logoutpic.gif></center>');
}
function microtime_float()

{

$time = microtime();

return (double)substr( $time, 11 ) + (double)substr( $time, 0, 8 );
}
$user_class = new User($_SESSION['id']);

// get style info
$cresult = mysql_query("SELECT `value` FROM `styles` WHERE `style`='". mysql_real_escape_string($user_class->style) ."'");
$i = 0;
while($line = mysql_fetch_array($cresult, MYSQL_ASSOC)) {
$color[$i] = $line['value'];
$i++;
}
/* Finding items */
$fia=(int) rand(1,1000); /* not sure why this says this item is on rand.satan...Anything that is buyable from id 1 to 105 */
$fib=(int) rand(20,1000); /* not sure why this says this item is on rand.satan...Anything that is buyable from id 1 to 105 */
if($fia == $fib)
{
$iq = mysql_query("SELECT id,itemname FROM `items` WHERE `buyable` = 1 ORDER BY rand() LIMIT 1");
$r = mysql_fetch_array($iq);
$item = $r['id'];
$userid = $user_class->id;

mysql_query("INSERT INTO inventory VALUES ($userid, $item, 1)");
Send_Event($userid,"While Playing The Game You Found A {$r['itemname']} Think Of It As A Present For Playing The Game.");
}

//get style info
$result = mysql_query("SELECT * FROM `serverconfig`");
$worked = mysql_fetch_array($result);
if($worked['serverdown'] != "" && $user_class->admin != 1){
die("<h1><font color='red'>SERVER DOWN<br><br>".$worked['serverdown']."</font></h1>");
}
$resultrelation = mysql_query("SELECT * FROM `rel_requests` WHERE `player` = '$user_class->id'");
$time = date(F." ".d.", ".Y." ".g.":".i.":".sa,time());
$result = mysql_query("UPDATE `grpgusers` SET `lastactive` = '".time()."', `ip` = '".$_SERVER['REMOTE_ADDR']."' WHERE `id`='". mysql_real_escape_string($_SESSION['id']) ."'");

function callback($buffer){ 
 $user_class = new User($_SESSION['id']);

 $checkhosp = mysql_query("SELECT * FROM `grpgusers` WHERE `hospital`!='0'");
 $nummsgs = mysql_num_rows($checkhosp);
 $hospital = "[".$nummsgs."]";

 $checkjail = mysql_query("SELECT * FROM `grpgusers` WHERE `jail`!='0'");
 $nummsgs = mysql_num_rows($checkjail);
 $jail = "[".$nummsgs."]";

 $checknews = mysql_query("SELECT * FROM `news` WHERE `to`='" . mysql_real_escape_string($user_class->username) . "' and `viewed`='1'");
 $numnews = mysql_num_rows($checknews);
 $news = "[".$numnews."]";

 $checkmail = mysql_query("SELECT * FROM `mail` WHERE `to`='$user_class->id' and `viewed`='1'");
 $nummsgs = mysql_num_rows($checkmail);
 $mail = "[".$nummsgs."]";

 $checkmail = mysql_query("SELECT * FROM `events` WHERE `to`='$user_class->id' and `viewed` = '1'");
 $numevents = mysql_num_rows($checkmail);
 $events = "[".$numevents."]";

$result = mysql_query("SELECT * from `effects` WHERE `userid`='".$user_class->id."'");
if (mysql_num_rows($result) != 0){
 $effects = '<div class="headbox">Current Effects</div>';
 while($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
         $effects .= '<a class="leftmenu" href="effects?view='.$line['effect'].'">'.$line['effect']." (".floor($line['timeleft']).")".'</a></ul><br />';
 }
}

 $out = $buffer;
 $out = str_replace("<!_-money-_!>", prettynum($user_class->money,1), $out);
 $out = str_replace("<!_-formhp-_!>", $user_class->formattedhp, $out);
 $out = str_replace("<!_-hpperc-_!>", $user_class->hppercent, $out);
 $out = str_replace("<!_-formenergy-_!>", $user_class->formattedenergy, $out);
 $out = str_replace("<!_-energyperc-_!>", $user_class->energypercent, $out);
 $out = str_replace("<!_-formawake-_!>", $user_class->formattedawake, $out);
 $out = str_replace("<!_-awakeperc-_!>", $user_class->awakepercent, $out);
 $out = str_replace("<!_-formnerve-_!>", $user_class->formattednerve, $out);
 $out = str_replace("<!_-nerveperc-_!>", $user_class->nervepercent, $out);
 $out = str_replace("<!_-points-_!>", prettynum($user_class->points), $out);
 $out = str_replace("<!_-credits-_!>", prettynum($user_class->credits), $out);
 $out = str_replace("<!_-level-_!>", $user_class->level, $out);
 $out = str_replace("<!_-hospital-_!>", $hospital, $out);
 $out = str_replace("<!_-jail-_!>", $jail, $out);
 $out = str_replace("<!_-mail-_!>", $mail, $out);
 $out = str_replace("<!_-news-_!>", $news, $out);
 $out = str_replace("<!_-events-_!>", $events, $out);
 $out = str_replace("<!_-effects-_!>", $effects, $out);
 $out = str_replace("<!_-cityname-_!>", $user_class->cityname, $out);  
 $out = str_replace("<!_-formexp-_!>", $user_class->formattedexp, $out);
 $out = str_replace("<!_-expperc-_!>", $user_class->exppercent, $out);
 $out = str_replace("<!_-countryname-_!>", $user_class->countryname, $out);
 $out = str_replace("<!_-hosp-_!>", $hospital, $out);
 $out = str_replace("<!_-ota;-_!>", $hospital, $out);

 return $out;
}
ob_start("callback");
?><?php

$stats = new User_Stats("bang");

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
<title>Wiscrime</title>
<link href="WCCSS/css/style.css" rel="stylesheet" type="text/css" />


<body>
<table class='container' border='0' cellpadding='0' cellspacing='0'>
 <tr class="header">
 <td colspan='2' width='100%'><table width='100%' cellspacing='0' cellpadding='0'>
<td width='50%' border='0' valign='top'>	<table width='100%'>
  <tr><td><div class="menu">

    <ul>
	  <li><a href="/mail.php"><img src="../img/mail.PNG"></a></li>
	  <li><a href="/events.php"><img src="../img/event.PNG"></a></li>
	  <li><a href="/forums.php"><img src="../img/forum.PNG"></a></li>
	  <li><a href="/help.php"><img src="../img/help.PNG"></a></li>
	</ul></div</div>
  </td></tr>


<tr class="menu1">
<td>
    <ul>
      <li><a style="text-decoration:none;" href="/hospital.php"><img src="../img/hospital.PNG"><label><!_-hosp-_!></label></a></li>
	  <li><a style="text-decoration:none;" href="/jail.php"><img src="../img/hospital1.PNG"><label><!_-jail-_!></label></a></li>
	  <li><a style="text-decoration:none;" href="/news.php"><label><img src="../img/hospital2.PNG"></label><span style="color:#FF0000; text-decoration:none;">  (1)</span></a></li>
	  <li><a style="text-decoration:none;" href="online.php"><img src="../img/hospital3.PNG"><span style="color:#009933; text-decoration:none;">[<?php echo $stats->playersonlineinlastday; ?>]</span></a></li>

    </ul></td>
  </tr></table></div>
</td><td width='20%' valign='top'><img src='WCCSS/img/header_logo.png' /></td>

<td width='30%' valign='top' align='right'><div class="header_c">
 <div class="top_header_box">
 <table align="center" border="0" cellpadding="0" cellspacing="2" width="220">
 <tbody><tr>
   <td><img src="../img/f1.PNG" height="18px" width="100%"></td>
   <td title="<!_-formenergy-_!>"><img src="../img/f2.PNG" height="18px" width="80%"></td>
    <td><img src="../img/f5.PNG"></td>
   <td title="<!_-formhp-_!>"><img src="../img/f6.PNG" height="18px" width="80%"></td>
 </tr>
 <tr>
  <td><img src="../img/f3.PNG"></td>
   <td title="<!_-formawake-_!>"><img src="../img/f4.PNG" height="18px" width="80%"></td>
     </tr>
  <tr>
  <td><img src="../img/f8.PNG"></td>
   <td title="<!_-formnerve-_!>"><img src="../img/f9.PNG" height="18px" width="80%"></td>
     </tr>



</tbody></table>

 </div>
</div>
</td></tr></table></td>
 </tr>

<tr class="section">
<td class="aside">
<div class="user_box">
<table width="206" border="0">
 <tr>
<td width="83"><table width="83" border="0">
 <tr>
   <td width="77"><img src="img/user.PNG" /></td>
 </tr>
 <tr>
   <td><a href="rmstore.php"><img src="img/up.PNG" /></a></td>
 </tr>
</table>
</td>
   <td width="113"><table width="106" border="0" cellspacing="0" cellpadding="0">
 <tr>
   <td> </td>
<font color=#DDDDDD> <span style="font-size: 10pt;">[<? echo $user_class->id; ?>] <a href='profiles.php?id=<? echo $_SESSION['id'] ?>'><span style="font-size: 10pt;"><? echo $user_class->formattedname; ?></span>  </a></span><br />
           <span style="font-size: 10pt;"><img src="img/star.PNG" /></span>  
           <span style="font-size: 10pt;"><A href="/levelguide.php"><span class="hotspot" onmouseover="tooltip.show('<B>EXP: <?php echo prettynum($user_class->formattedexp,1); ?></B>');" onmouseout="tooltip.hide();"><!_-level-_!></span></a></span>  
           <br />
           <span style="font-size: 10pt;"><a href='bank.php'><img src="img/dollors.PNG"/></span>   
           <span style="font-size: 10pt;"><?php echo number_format($user_class->money); ?><span style="font-size: 8pt;"><span class="hotspot" onmouseover="tooltip.show('<B>Bank: <?php echo prettynum($user_class->bank,1); ?></B>');" onmouseout="tooltip.hide();"></a></span> 
<br />
           <span style="font-size: 10pt;"><a href='rmstoreoffers.php'><img src="img/circle.PNG" /></span>  
            <span style="font-size: 10pt;"><?php echo number_format($user_class->credits); ?><span style="font-size: 8pt;"><span class="hotspot" onmouseover="tooltip.show('<B>Bank: <?php echo prettynum($user_class->bank,1); ?></B>');" onmouseout="tooltip.hide();"></a></span>
           <br />
           <span style="font-size: 10pt;"><a href='spendpoints.php'><img src="img/diamond.PNG" /></span>  
           <span style="font-size: 10pt;"><?php echo number_format($user_class->points); ?><span style="font-size: 8pt;"><span class="hotspot" onmouseover="tooltip.show('<B>Bank: <?php echo prettynum($user_class->bank,1); ?></B>');" onmouseout="tooltip.hide();"></a></span>
 </tr>
</table>
</td>
 </tr>
</table>
</div>
<div class="main_menu">
<ul>
<li><a class="home" href="index.php">HOME</a></li>
<li><a class="explode" href="city.php">EXPLORE</a></li>
<li><a class="items" href="inventory.php">ITEMS</a></li>
<li><a class="crimes" href="crime.php">CRIMES</a></li>
<li><a class="gym" href="gym.php">GYM</a></li>
<li><a class="yourgang" href="gang.php">YOUR GANG</a></li>
<li><a class="settings" href="preferences.php">SETTINGS</a></li>
<li><a class="logout" href="index.php?action=logout">LOGOUT</a></li>
</ul>
</div>

<td valign='top' align='center' class="bside">

<div class="top_main_area">
<ul id="ul">
<li><a href="cropsrm.php"><img src="img/1.PNG" /></a></li>
<li><a href="lottery.php"><img src="img/2.PNG" /></a></li>
<li><a href="bank.php"><img src="img/3.PNG" /></a></li>
<li><a href="creditmarket.php"><img src="img/4.PNG" /></a></li>
</ul>
<div id="content">
<table><div id="cpanel">

<?= ($user_class->admin == 1) ? '

   <a  href="spheader.php">-Staff Panel-</a>

  ' : "" ?>
<?= ($user_class->admin == 2) ? '

   <a  href="gmheader1001.php"><center>-Staff Panel-</center></a>

  ' : "" ?>
<?php

	$result252 = mysql_query("SELECT * FROM `ganginvites` WHERE `username` = '$user_class->username'");
	//$invites_exist = mysql_num_rows($result252);




	if (mysql_num_rows($result252) > 0){
		$invite_class = New Gang($line['gangid']);
                echo "<center><a href='ganginvites.php'>View Gang Invites</a></center>";

	}

		 	if ($user_class->jail > 0){
		echo "<marquee scrolldelay=120><img src=/images/pref_img3.jpg>You are currenty in jail for " . floor($user_class->jail)/60 . " more minutes.</marquee>";


	}

	if ($user_class->hospital > 0){
		echo "<marquee scrolldelay=180><font color=red><img src='/image/hossy.gif' width='40' height='30' style='border: 1px solid #333333'>You are in the ward for " . floor($user_class->hospital)/60 . " more minutes.</font></marquee>";

	}            
               if ($user_class->votemtl == 0){
		echo "<font color=red><center><tr><td class='contenthead'><A STYLE='text-decoration:none' HREF='vote.php'>You Have Not Voted Today</a></center></font>";
	}
$resultm = mysql_query("SELECT * FROM `effect4` WHERE `userid` = '".$user_class->id."'");
$worked2m = mysql_fetch_array($resultm);
$etime = $worked2m['timeleft'];

if ($worked2m > 0){
echo "<center><font color=red>You have Coke effect on you for " . floor($etime) . " more minutes.<img src='/image/cocaine.png' width='30' height='20' style='border: 1px solid #333333'></font></center>";
}
$result = mysql_query("SELECT * FROM `effects` WHERE `userid` = '".$user_class->id."'");
$worked2 = mysql_fetch_array($result);
$etime = $worked2['timeleft'];

if ($worked2 > 0){
echo "<center>You have nodoze effect on you for " . floor($etime) . " more minutes.<img src='/images/nodo-1.jpg' width='30' height='20' style='border: 1px solid #333333'></center>";
}
$resultbla = mysql_query("SELECT * FROM `effect3` WHERE `userid` = '".$user_class->id."'");
$worked2212 = mysql_fetch_array($resultbla);
$etime = $worked2212['timeleft'];

if ($worked2212 > 0){
echo "<center>You have LSD effect on you for " . floor($etime) . " more minutes.<img src='/images/lsd1.jpg' width='30' height='20' style='border: 1px solid #333333'></center>";
}
$resultbl = mysql_query("SELECT * FROM `effect2` WHERE `userid` = '".$user_class->id."'");
$worked221 = mysql_fetch_array($resultbl);
$etime = $worked221['timeleft'];

if ($worked221 > 0){
echo "<center>You have METH effect on you for " . floor($etime) . " more minutes.<img src='/images/meth1.jpg' width='30' height='20' style='border: 1px solid #333333'></center>";
}
$resultbl14 = mysql_query("SELECT * FROM `effect5` WHERE `userid` = '".$user_class->id."'");
$worked22165 = mysql_fetch_array($resultbl14);
$etime = $worked22165['timeleft'];
if ($worked22165 > 0){
echo "<center>You have awake boost effect on you for " . floor($etime) . " more minutes.</center>";
}


               if ($user_class->timeout > 0){
		echo "<marquee scrolldelay=180><font color=red>You are on a boat for " . floor($user_class->timeout) . " more minutes.</marquee>";

	}
	if ($user_class->bguard > 0){
		echo "<center><img src='/image/protector.jpg' width='40' height='30' style='border: 1px solid #333333'>You have " . floor($user_class->bguard) . " minutes left of hit protection.<a href='spendpoints.php?spend=bguard'>Remove</a></center>";

}
               if ($user_class->mguard > 0){
		echo "<center><img src='/image/protector.jpg' width='40' height='30' style='border: 1px solid #333333'>You have " . floor($user_class->mguard) . " minutes left of mug protection. <a href='spendpoints.php?spend=mguard'>Remove</a></center>";

}
                  if ($user_class->hguard > 0){
		echo "<center><img src='/images/pref_img4.jpg' width='40' height='30' style='border: 1px solid #333333'>You have " . floor($user_class->hguard) . " minutes left of 1 day hit protector. <a href='spendpoints.php?spend=hguard'>Remove</a></center>";

}
                 if ($user_class->mmguard > 0){
		echo "<center><img src='/image/protector.jpg' width=40' height='30' style='border: 1px solid #333333'>You have " . floor($user_class->mmguard) . " minutes left of 1 day mug protector. <a href='spendpoints.php?spend=mmguard'>Remove</a></center>";

}
	if ($user_class->newnews == 1){
		echo "<center><a href='news.php'>You have unread news!</a></center>";


	}
	if ($user_class->banned == 1){
		echo "<center>You Have Been Banned!</center>";
die();
}
require_once('ajax_chat/chat_globals.php');
?>

header code

any ideas on why these will not be working?

Untitled.thumb.png.74b68ced00b11fddf8e8a48453d93d91.png

Link to comment
Share on other sites

the cron is working but the timing is out any ideas? i have got the out puts showing the cron is working now but it is still going very quick

 

<?



//Updates



$updates_sql = mysql_query("SELECT * FROM `updates` WHERE `name` = 'trevor'");



while ($line = mysql_fetch_array($updates_sql, MYSQL_ASSOC)) {



$update = $line['lastdone'];



}



$timesinceupdate = time() - $update;



if ($timesinceupdate>=300) {



$num_updates = floor($timesinceupdate / 300);



//stock market stuff

$result = mysql_query("SELECT * FROM `stocks`");

while($line = mysql_fetch_assoc($result)) {

	$amount = rand (strlen($line['cost']) * -1, strlen($line['cost']));

	$newamount = $line['cost'] + $amount;

	if ($newamount < 1){

		$newamount = 1;

	}

	$result2 = mysql_query("UPDATE `stocks` SET `cost`='".$newamount."' WHERE `id`='".$line['id']."'");

}

//stock market stuff



$result = mysql_query("SELECT * FROM `grpgusers`");



while($line = mysql_fetch_assoc($result)) {



	$updates_user = new User($line['id']);



	if ($updates_user->rmdays > 0) {



		$multiplier = 2;



	} else {



		$multiplier = 1;



	}



	$username = $updates_user->username;



	$newawake = $updates_user->awake + (5 * $num_updates) * $multiplier;



	$newawake = ($newawake > $updates_user->maxawake) ? $updates_user->maxawake : $newawake;



	$newhp = $updates_user->hp + (10 * $num_updates) * $multiplier;



	$newhp = ($newhp > $updates_user->maxhp) ? $updates_user->maxhp : $newhp;



	$newenergy = $updates_user->energy + (2 * $num_updates) * $multiplier;



	$newenergy = ($newenergy > $updates_user->maxenergy) ? $updates_user->maxenergy : $newenergy;



	$newnerve = $updates_user->nerve + (2 * $num_updates) * $multiplier;



	$newnerve = ($newnerve > $updates_user->maxnerve) ? $updates_user->maxnerve : $newnerve;



	$result2 = mysql_query("UPDATE `grpgusers` SET `awake` = '".$newawake."', `energy` = '".$newenergy."', `nerve` = '".$newnerve."', `hp` = '".$newhp."' WHERE `username` = '".$username."'");



}



//update the timer and db



$thetime = time();



$result2 = mysql_query("UPDATE `updates` SET `lastdone` = '".$thetime."' WHERE `name` = 'trevor'");



$leftovertime = $timesinceupdate - (floor($timesinceupdate / 300) * 300);



if ($leftovertime>0) {



	$newupdate =  time() - $leftovertime;



	$setleftovertime = mysql_query("UPDATE `updates` SET `lastdone` = '".$newupdate."' WHERE `name` = 'trevor'");



}



}



















$updates_sql = mysql_query("SELECT * FROM `updates` WHERE `name` = 'hospital'");



while ($line = mysql_fetch_array($updates_sql, MYSQL_ASSOC)) {



$update = $line['lastdone'];



}



$timesinceupdate = time() - $update;



if ($timesinceupdate>=60) {



$num_updates = floor($timesinceupdate / 60);



$result = mysql_query("SELECT * FROM `grpgusers`");



//DO STUFF



while($line = mysql_fetch_assoc($result)) {



	$result_user = mysql_query("SELECT * FROM `grpgusers` WHERE `id`='".$line['id']."'");



	$updates_user = mysql_fetch_array($result_user);







	$newhospital = $updates_user['hospital'] - (60 * $num_updates);



	$newhospital = ($newhospital < 0) ? 0 : $newhospital;



	$newjail = $updates_user['jail'] - (60 * $num_updates);



	$newjail = ($newjail < 0) ? 0 : $newjail;



	$result2 = mysql_query("UPDATE `grpgusers` SET `hospital` = '".$newhospital."', `jail` = '".$newjail."' WHERE `id` = '".$line['id']."'");



}







$result = mysql_query("SELECT * FROM `effects`");



while($line = mysql_fetch_assoc($result)) {



	if($line['timeleft'] > 0){



	$newamount = $line['timeleft'] - (1 * $num_updates);



	$result2 = mysql_query("UPDATE `effects` SET `timeleft` = '".$newamount."' WHERE `id` = '".$line['id']."'");



	}



}



$result2 = mysql_query("DELETE FROM `effects` WHERE `timeleft` < 1");







//update the timer and db



$thetime = time();



$result2 = mysql_query("UPDATE `updates` SET `lastdone` = '".$thetime."' WHERE `name` = 'hospital'");



$leftovertime = $timesinceupdate - (floor($timesinceupdate / 60) * 60);



if ($leftovertime>0) {



	$newupdate =  time() - $leftovertime;



	$setleftovertime = mysql_query("UPDATE `updates` SET `lastdone` = '".$newupdate."' WHERE `name` = 'hospital'");



}



}



?>

 

this is the cron

Link to comment
Share on other sites

the cron is working but the timing is out any ideas? i have got the out puts showing the cron is working now but it is still going very quick

 

What do you mean by "timing is out"?

 

  • Cron is triggered at the wrong time
  • The file should execute and finish under x seconds
  • ...
Link to comment
Share on other sites

I trigger the cron and the lets say jail timer goes from 70 mins, to getting out as soon as its triggered

 

  • Tidy the code up
  • Make an attempt at solving it yourself
  • Show your attempt
  • If decent enough try, I'll help

I'll give you the rod, but not the fish.

Link to comment
Share on other sites

grpg uses updates.php which is loaded in the header.php which will update jail and other stuff via timestamps

rollover.php is the only file that needs to be linked to the cron manager.

unless you stripped out updates and put it into crons files

 

Yes thanks I realised that the other day that's where I was going wrong and there was a error in the syntax stopping the timestamps from working it may of took me three days to figure it out but I got it working lol

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...