<?php session_start();
		if (isset($_SESSION['logged']) && $_SESSION['logged'] == 'yes') {
				//get mode
				$mode = $_GET['mod'];
				//echo $mode;
					if ($mode == ''){
					exit();
					}
					elseif ($mode == 'show'){
						//show roufianos logs
						$filename = "logs/roufianos.log";
						$fileToOpen = fopen($filename,"r");
						$content = fread($fileToOpen, filesize($filename));
						$content = nl2br($content);
						fclose($fileToOpen);
					?>
					<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
					<html>
					<head>
					<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
					<title>CLS - Logs</title>
					<link href="cms1.css" rel="stylesheet" type="text/css" />
					<style type="text/css">
<!--
body,td,th {
	color: #006699;
}
-->
</style></head>
					<body>						
					<?php echo "<div>".$content."<br />";	
					?>
					</body>
					</html>
					<?php }elseif ($mode == 'clear'){
						//clear roufianos logs
						$filename = "logs/roufianos.log";
						$fp = fopen($filename,"w+") or die ("Error opening file in write mode!");
						$content="Cleared on ".date("d-m-Y H:i:s")." by #$user# - Initialize...";
						fputs($fp,$content);
						fclose($fp) or die ("Error closing log file!");
						header ('Location:logs.php');
					}
} else {
    header('Location: login.php');
}
?>