<?php

	require_once("../../db_connect.php");
	
	$userid = (isset($_SERVER['persistent-id']) ? $_SERVER['persistent-id'] : null);
	$employeeType = (isset($_SERVER['employeeType']) ? $_SERVER['employeeType'] : null);


	if($employeeType == 'Ιατρικό'){

		$token = sha1(uniqid("encodedURL", true));
	
		$xml1=simplexml_load_file("../../include/memcached_config.xml") or die("Error: Cannot create object");
		
		$memcache = new Memcached(); // instantiating memcached extension class
		$memcache->addServer(htmlspecialchars($xml1->ip, ENT_QUOTES), htmlspecialchars($xml1->port, ENT_QUOTES)); 								
	 
		// we will create variables which will be stored in cache serialized		
		$mem_result = $memcache->set($token."_patid", $_POST['patid'], htmlspecialchars($xml1->expiration_time, ENT_QUOTES));
	 	$mem_result = $memcache->set($token."_patname", $_POST['db_patname'], htmlspecialchars($xml1->expiration_time, ENT_QUOTES));		
		$mem_result = $memcache->set($token."_accno", $_POST['accno'], htmlspecialchars($xml1->expiration_time, ENT_QUOTES));
		$mem_result = $memcache->set($token."_studyid", $_POST['studyid'], htmlspecialchars($xml1->expiration_time, ENT_QUOTES));
		$mem_result = $memcache->set($token."_studyuid", $_POST['studyuid'], htmlspecialchars($xml1->expiration_time, ENT_QUOTES));
		$mem_result = $memcache->set($token."_userid", $userid, htmlspecialchars($xml1->expiration_time, ENT_QUOTES));
		$mem_result = $memcache->set($token."_used", "0", htmlspecialchars($xml1->expiration_time, ENT_QUOTES));
		
		if($mem_result == true){
			print($token);
		}
		
	
	}
?>
