<?php 
include_once("../../embedded/functions/site_functions.php");
$email=$_SESSION['email'];
$device_id=$_SESSION['device_id'];
$language=$_SESSION['language'];
db_open();
if ($language==1)
	{
	$head1="Eπιλέξατε να εξέλθετε. Συνέχεια?";
	}
else
	{
	$head1="You are about to exit. Continue?";
	}
if(isset($_GET['a']) && !empty($_GET['a']) && $_GET['a']<=4)
{

$a=$_GET['a'];
if( $a==1)
	{
echo<<<a
$head1
a;

	}
else if($a==2)
	{

	$time=time();
	$sql="UPDATE users SET live_login='$time' WHERE device_id='$device_id' AND email='$email'";
	@ $result=mysql_query($sql);
	if ($result!=0)
		{
		session_unset();
		session_destroy();
		session_start();
		session_regenerate_id();
		setcookie('email','',0);
		setcookie('userlevel','',0);
		setcookie('device_id','',0);
		setcookie('password','',0);
		unset($_COOKIE);
		}

	}
else if($a==3 || $a==4)
	{		
		if ($a==3)
			{
			$a=2;
			}
		else
			{
			$a=1;
			}			
		$sql="UPDATE users SET language='$a' WHERE device_id='$device_id' AND email='$email'";
		@ $result=mysql_query($sql);
		 if($result!=0)
			{			
			$_SESSION['language']=$a;
			}
	}
else
	{
	die();
	}
	
	
}
db_close();
?>