<?php


function GetMicroTime() { list($usec, $sec) = explode(" ",microtime()); return ((float)$usec + (float)$sec); }
$time = GetMicroTime();


require_once("library/YakkaCookieHandler.php");
require_once("library/YakkaSessionHandler.php");
require_once("library/YakkaEngine.php");

class Yakka {
	var $cookieHandler;
	var $sessionHandler;

	var $cookie;
	var $session;

	var $engine;

	function Yakka() {
		$this->cookieHandler = new YakkaCookieHandler();
		$this->cookie = &$this->cookieHandler->loadCookie();

		$this->sessionHandler = new YakkaSessionHandler($this->cookie);
		$this->session = &$this->sessionHandler->loadSession();

		if (!$this->cookie) {
			$this->cookie = $this->session->id;
			$this->cookieHandler->saveCookie();
		}

		$this->engine = new YakkaEngine("yakka-settings.xml", $this->session);
	}

	function run() {
		echo $this->engine->run();
		$this->sessionHandler->saveSession();
	}
}

$yakka = new Yakka();
$yakka->run();


$endtime = GetMicroTime();
echo $endtime - $time;


?>
