<?php session_start();
						include ('scripts/classes.php'); //Connect Classes
						$array = getGlobalSettings();//Get global settings

						$lang = mysqli_real_escape_string($mysqli, $_POST['txtLanguage']);
						$user = mysqli_real_escape_string($mysqli, $_POST['txtUsername']);
						$password = mysqli_real_escape_string($mysqli, $_POST['txtPassword']);
						$query = mysqli_query($mysqli, "SELECT * FROM users WHERE username='$user' AND password=password('$password') AND active=1");
						
						if (mysqli_num_rows($query) !=0) {
						$row = mysqli_fetch_array($query, MYSQLI_ASSOC);
						$default_printer = $row['default_printer'];
						$_SESSION['user'] = $user;
						$_SESSION['logged'] = "yes";
						$_SESSION['lang'] = $lang;
						$_SESSION['default_printer'] = $default_printer; //added for pos module
						header ('location:frameset.php');
						exit();
						}else{
						?>
<!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>Webnail CLS System</title>
<link href="cms1.css" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" href="img/favicon.png" />
</head>
<body>
	<div class="div-center-align width-300-px">
	<table width="200" class="login align-center"><tr>
	<td height="20" class="login3 align-center">Logged Out</td></tr>
	<tr><td height="20" class="align-center"><font><img src="img/webnail_logo.jpg" alt="Webnail Independent Team" /></font></td></tr>
	<tr><td height="30" class="login_version align-center">
			<?php 	
			foreach ($array as $settings){
				extract($settings);	
				}
			echo $cms_version;
			?>
	</td></tr>
	<tr><td height="40" class="align-center"><font color="#FF9900">
			<?php 	
			foreach ($array as $settings){
				extract($settings);	
				}
			echo $owner;
			?>
	</font></td></tr>
	<form name="loginform" method="post" action="loginerror.php">
    <tr><td class="align-center"><input type="text" id="this" title="Enter Username" name="txtUsername" class="textbox"  value="USERNAME" tabindex="1" onclick="javascript:getElementById('this').value=''"/></td></tr>
    <tr ><td class="align-center"><input type="password"  id="that" title="Enter Password" name="txtPassword"  class="password" value="PASSWORD"tabindex="2" onfocus="javascript:getElementById('that').value=''"/></td></tr>
    <tr ><td class="align-center"><select name="txtLanguage" class="textlang" id="lang" tabindex="3">
	<?php 
				foreach ($array as $settings){
				extract($settings);	
				}
				$lang =$default_lang;
	 	if ($lang=='GR'){
		echo "<option value=\"GR\">Ελληνικά</option>";
		echo "<option value=\"EN\">English</option>";
		}else if ($lang=='EN'){
		echo "<option value=\"EN\">English</option>";		
		echo "<option value=\"GR\">Ελληνικά</option>";
		}else {
		echo "<option value=\"EN\">English</option>";		
		echo "<option value=\"GR\">Ελληνικά</option>";
		}
			?>
	</select></td></tr>	
    <tr><td class="align-center"><input type="submit" name="Submit" value=" Log In " class="buttons" /> </form></td></tr>
	<tr ><td class="login1 align-center">
	<a href="	<?php foreach ($array as $settings){
				extract($settings);	
				}
				echo $domain;
				?>"> Go To Homepage</a></td></tr>
	</table>
	</div>
					<?php
						}
					?>	
</body>
					
					<?php 
					mysqli_close($mysqli); ?>
</html>
