<?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");
}

if(!(is_readable(realpath(dirname(__FILE__))."/include/bsservice.inc"))) {
    die("Error - Could not open or read file ".realpath(dirname(__FILE__))."/include/bsservice.inc");
} else {
    include_once(realpath(dirname(__FILE__))."/include/bsservice.inc");
}

$lng = ( isset($_REQUEST['lang']) ? 'lang='.$_REQUEST['lang'] : '');
$cn = db_connect();
$ticket = getAuthTicket();
$call = sendLogout($cn, $ticket);
setAuthTicket('');
setCookieHash('');
LogOut();
$sspiauth = '';
if (getSetting('portal','useSSPIAuth', 0) == 1) {
	$sspiauth = 'sspiauth=off&';
}
$url = getCurPageURLWO()."/login.php?".$sspiauth."lang=".getLanguage();
header("Location: ".$url);
db_disconnect($cn);
ob_end_flush();
exit;
?>