Location: PHPKode > projects > Gefallenes Reich > GR-holocaust.1/game/update.php
<?php          

#This works out the score on every page load. This is also done by the ticker script every 15 minutes. The second part is used to update the Game table and the accounts table so that they have an up-to-date last login time (used by the ticker)

$factscore = (($factorys * $f_px) / 4);
$score = round(((($ss * $ss_px) + ($bs * $bs_px) + ($t * $t_px) + ($p * $p_px) + ($sm * $sm_px) + ($s* $s_px) + ($cash / 8)) + $factscore) / 30.7);
 
$ntm = date("m");
$ntd = date("d");
$nth = date("H");
$ntmin = date("i");
 
$oldturn = explode(":", $oldtime); 
$otm = $oldturn[0];
$otd = $oldturn[1];
$oth = $oldturn[2];
$otmin = $oldturn[3];

#echo "old month time = $otm <br>";
#echo "old day time = $otd <br>";
#echo "old hour time = $oth <br>";
#echo "old minute time = $otmin <br>";

$m_dif = ($ntm - $otm);
$d_dif = ($ntd - $otd);
$h_dif = ($nth - $oth);
$min_dif = ($ntmin - $otmin);
 
$sec_in_month = (((60 * 60) * 24 )* 30);
$sec_in_day = ((60 * 60) * 24);
$sec_in_hour = (60 * 60);
$sec_in_min = 60;
 
$secs_from_month = ($m_dif * $sec_in_month);
$secs_from_day = ($d_dif * $sec_in_day);
$secs_from_hour = ($h_dif * $sec_in_hour);
$secs_from_minute = ($min_dif * $sec_in_min);
 
$total_seconds = ($secs_from_month + $secs_from_day + $secs_from_hour + $secs_from_minute);

 
$newtimearray = array($ntm, $ntd, $nth, $ntmin);
$newnow = implode(":",$newtimearray);
 
 
mysql_query("UPDATE `$G_TABLE` SET score = '$score' WHERE PUIN = '$PUIN'")
	or die (mysql_error());
 
mysql_query("UPDATE `$G_TABLE` SET lastlogin = '$newnow' WHERE PUIN = '$PUIN'")
	or die (mysql_error());
mysql_query("UPDATE `$P_TABLE` SET lastlogin = '$newnow' WHERE PUIN = '$PUIN'")
	or die (mysql_error());									
 
?>
Return current item: Gefallenes Reich