<?php
@session_start();
if((isset($_SESSION['beroari_time']))&&(($_SESSION['beroari_time']+1200)<time())){
	@session_unset();
	@session_destroy();
	echo "<script>window.opener.location='../index.php?m=sip'</script>";
	echo "<script>this.window.close();</script>";
}else{
	$_SESSION['beroari_time']=time();

	exec("/bin/sync");
	if ($_GET['option']=='isgw'){
		if (file_exists("/tmp/debug-info.tar.gz")) {

			$file ="/tmp/debug-info.tar.gz";
			if (file_exists("/tmp/core")) $file.=" /tmp/core";
			//$file2 = implode("", $file);
			header("Content-Type: application/force-download");
			header("Content-Disposition: attachment; filename=debug-info.tar\r\n\r\n");
			passthru("tar -f - -c ".$file);
		}
	}elseif ($_GET['option']=='error'){
		if (file_exists("/tmp/isgw.err")) {
			$file = file("/tmp/isgw.err");
			$file2 = implode("", $file);
			header("Content-Type: application/force-download");
			header("Content-Disposition: attachment; filename=isgw.err\r\n\r\n");
			header("Content-Length: " . strlen($file2) . "\n\n");
			echo $file2;
		}
	}else{
		if (file_exists("/tmp/DebugFiles.tar.gz")){
			$file = file("/tmp/DebugFiles.tar.gz");
		$file2 = implode("", $file);
		header("Content-Type: application/force-download");
		header("Content-Disposition: attachment; filename=DebugFiles.tar.gz\r\n\r\n");
		header("Content-Length: " . strlen($file2) . "\n\n");
		echo $file2;
		exit;
		}
	}
}
?>
