<?php
///////////////////////////////////////////////////////////////////////////////////////
// PHPizabi 0.848b C1 [ALICIA]                               http://www.phpizabi.net //
///////////////////////////////////////////////////////////////////////////////////////
// Please read the license.txt file before using / modifying this software           //
// Original author:         Claude Desjardins, R - feedback@realitymedias.com        //
// Last modification date:  August 26th 2006                                         //
// Version:                 PHPizabi 0.848b C1                                       //
//                                                                                   //
// (C) 2005, 2006 Real!ty Medias / PHPizabi - All rights reserved                    //
///////////////////////////////////////////////////////////////////////////////////////

	/* Check Structure Availability */
	if (!defined("CORE_STRAP")) die("Out of structure call");
	

	// STAND UP FOR THE LANE! //
	// LIVE ACTIVITY NOTIFICATION ENGINE 0.100 //
	// 
	// THIS IS THE NOTIFICATION PART //
	
	// PREVENT USERS FROM ACCESSING THE LANE PAGE //////////////////////////////////////
	if (!isset($_GET["chromeless"])) die("You can't access the L.A.N.E. through a web browser.");
	
	// LANE CLEANUP ////////////////////////////////////////////////////////////////////
	/*
		If no lane token exist or that the lane
		token is older than 5 minutes ago, we will
		clear all the lane token for this user
	*/
	if (!isset($_SESSION["LANE_USTAMP"]) || $_SESSION["LANE_USTAMP"] < (date("U") - 300)) {

		if ($directoryHandle = opendir("system/cache/lane/")) {
			while (($file = readdir($directoryHandle)) !== false) {
				if (strpos($file, ".tk")) {
					
					/*
						Explode the token name at ".", we will get 3
						values, 0: User ID, 1: Token timestamp, 2: file extention
					*/
					$token = explode(".", $file);
					if ($token[0] == me("id")) unlink("system/cache/lane/{$file}");
				}
			}
			closedir($directoryHandle);
		}
		$_SESSION["LANE_USTAMP"] = date("U");
	} 
	
	else {
		
		if (!isset($_GET["pause"])) {
			
			if ($directoryHandle = opendir("system/cache/lane/")) {
				while (($file = readdir($directoryHandle)) !== false) {
					if (strpos($file, ".tk")) {
						
						/*
							Explode the token name at ".", we will get 3
							values, 0: User ID, 1: Token timestamp, 2: file extention
						*/
						$token = explode(".", $file);
						if ($token[0] == me("id")) {
							echo file_get_contents("system/cache/lane/{$file}");
							unlink("system/cache/lane/{$file}");
							break;
						}
					}
				}
				closedir($directoryHandle);
			}
			
		}

		$_SESSION["LANE_USTAMP"] = date("U");
	}


	
	
	// LOAD LANE TOKENS ////////////////////////////////////////////////////////////////
	
	
?>