<?php
ob_start();
if(!(is_readable(realpath(dirname(__FILE__).'/../').'/include/includesroutines.inc'))) {
	die('Error - Could not open or read file '.realpath(dirname(__FILE__).'/../').'/include/includesroutines.inc');
} else {
	include_once(realpath(dirname(__FILE__).'/../').'/include/includesroutines.inc');
}
$cn = db_connect();
if ( getSetting('portal','useRights',0) == 1 && IsUserLogin() ){
	if (isset($_REQUEST['user_idlanguageinterface']) && (trim($_REQUEST['user_idlanguageinterface']) <> '') && isset($_REQUEST['user_idlanguagecontent']) && (trim($_REQUEST['user_idlanguagecontent']) <> '')){
		db_saveUserLangsByID($cn, getUserMainID(), db_checkInterfaceLangByID($cn, $_REQUEST['user_idlanguageinterface']), db_checkContentLangByID($cn, $_REQUEST['user_idlanguagecontent']));
	}
} else {
	$_SESSION['user_idlanguageinterface'] = db_checkInterfaceLangByID($cn, $_REQUEST['user_idlanguageinterface']);
}
db_disconnect($cn);
echo'ok';
session_write_close();
ob_end_flush();
exit;
?>