Location: PHPKode > projects > Zitro-Stats > include/update_expire.inc.php
<?php

	// ANTIHACK
	defined('INSTATS') AND defined('UPDATE') OR die();

	// EXPIRE-DATE
	if($options['STATS_EXPIRE_TIME']) {
		fecho("\n==[ CLEAN EXPIRED ]==================================\n");

		// MEMORY CLEANUP MANAGEMENT
		$event = 0;			// EVENT INCR
		$events = array();	// PLAYERS AND THEIR LAST EVENT

		$expiredate = date("Y-m-d H:i:s",time()-$options['STATS_EXPIRE_TIME']);
		fecho(" expiredate: $expiredate\n");
		// GET OLD KILLS
		$result = $sql->query("
			SELECT
				`server`,
				`date`,
				`player`,
				`opponent`,
				`weapon`,
				`points`
			FROM `$options[SQL_TABPREFIX]killlog`
			WHERE `date`<'$expiredate'
			");
		fecho(" events before deadline: ".$sql->numrows($result)."\n");
		if($sql->numrows($result)) {
			if(!count($weapons)) load_weapons();
			// UNCALC EACH KILL
			while(list($server,$date,$player,$opponent,$weapon,$elo) = $sql->fetchrow($result)) {
				checkplayer($player);
				$events[$player] = $event;

				// SELFKILL
				if($player == $opponent) {
					$options['UPDATE_OLD_SELFKILLS'] ++;

					// KILLER
					$players[$player]->selfkills --;

					// SERVERDAYS
					if(!$options['STATS_KEEP_DAYS'] && isset($serverdays[$server][$day=substr($date,0,10)]))
						$serverdays[$server][$day][1] --;

					// SERVERHOURS
					if(!$options['STATS_KEEP_HOURS'] && isset($serverhours[$server][$hour=substr($date,11,2)]))
						$serverhours[$server][$hour][1] --;
				// KILL
				} else {
					$options['UPDATE_OLD_KILLS'] ++;

					checkplayer($opponent);
					$events[$opponent] = $event;

					// PLAYERS
					$players[$player]->kills --;
					$players[$player]->points -= $elo;
					$players[$opponent]->deaths --;
					$players[$opponent]->points += $elo;
					if(isset($players[$player]->opponents[$opponent]))
						$players[$player]->opponents[$opponent][0] --;
					if(isset($players[$player]->killweapons[$weapon]))
						$players[$player]->killweapons[$weapon][0] --;
					if(isset($players[$opponent]->deathweapons[$weapon]))
						$players[$opponent]->deathweapons[$weapon][0] --;

					// WEAPON
					$weapons[$weapon]->kills --;

					// SERVERDAYS
					if(!$options['STATS_KEEP_DAYS'] && isset($serverdays[$server][$day=substr($date,0,10)]))
						$serverdays[$server][$day][0] --;

					// SERVERHOURS
					if(!$options['STATS_KEEP_HOURS'] && isset($serverhours[$server][$hour=substr($date,11,2)]))
						$serverhours[$server][$hour][0] --;
				}
				cleanmem($events);
				$event++;
			}
			// DELETE OLD KILLS
			$result = $sql->query("
				DELETE
				FROM `$options[SQL_TABPREFIX]killlog`
				WHERE `date`<'$expiredate'
				LIMIT ".$sql->numrows($result)."
				");
		}
	}

?>
Return current item: Zitro-Stats