<?php

header("X-Content-Type-Options: nosniff");
header("X-XSS-Protection: 1; mode=block");
header("X-Frame-Options: DENY");
header('Expires: Sun, 01 Jan 2000 00:00:00 GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', FALSE);
header('Pragma: no-cache');

ini_set('session.cookie_httponly', 'on');
ini_set('session.cookie_secure', 'on');

session_name("SIGNADMAUTH");
session_start();

include "common/config/config.php";
include "common/config/dbconfig.php";
include "common/functions/funcconnect.php";
openDB();


if (!isset($_SESSION['LOGINFAIL']))
{ 
	$_SESSION['LOGINFAIL']=0;
} 
else
{
	$_SESSION['LOGINFAIL']=$_SESSION['LOGINFAIL'];
} 

include "common/functions/funclogin.php";

//CONDITION
if (checklogintime())
{ 
	//MAIN CONTENT
	$content="<form action='loginprocess.php' method='post' autocomplete='off' style='padding:0; margin:0'>
					<table border='0' cellpadding='5px' cellspacing='0'>
						<tr>
							<td align='center' valign='middle' height='35px' colspan='3'>
								<b>LOGIN USER</b><br>
							</td>
						</tr>
						<tr>
							<td align='left' valign='middle' height='31'>Username</td>
							<td align='center' valign='middle'>:</td>
							<td align='left' valign='middle'>
								<input type='text' name='nama' size='28'>
							</td>
						</tr>
						<tr>
							<td align='left' valign='middle' height='31'>Password</td>
							<td align='center' valign='middle'>:</td>
							<td align='left' valign='middle'>
								<input type='password' id='randomKeyboard' name='katasandi' size='28'>
							</td>
						</tr>
						";

						//CONDITION 2 (if fail more than twice)
						if ($_SESSION['LOGINFAIL']>2)
						{
							include "common/include/captcha/captcha.php";
									$content.="<tr>
													<td align='left' valign='middle' height=31>Kode Pengaman</td>
													<td align='center' valign='middle'>:</td>
													<td align='left' valign='middle'>
														<img src='ver_code/verify".$string.".png' align='absbottom'>&nbsp;
														<input type='text' size='9' name='ver_code'>
													</td>
												</tr>
												";
						}										
						
						$content.="<tr>
										<td style='padding-bottom:15px'></td>
										<td style='padding-bottom:15px'></td>
										<td align='left' valign='middle' style='padding-bottom:15px'>
											<input type='submit' id='submit' name='submit' value=' Login '>
										</td>
									</tr>

					</table>
				</form>";
}
else
{ 
	include "common/config/config.php";

	$content="<b style='color:#ff0000'>LOGIN BERMASALAH</b><br><br>
	Aplikasi ini hanya dapat digunakan dari pukul ".$loginstarttime." hingga pukul ".$loginendtime.".<br><br>";
}


//TEMPLATE
include "common/include/template.php";
$temp=new template;
$temp->define_theme("themes/theme_notlogin.html");
$temp->define_tag("{PAGETITLE}", $namaaplikasi);
$temp->define_tag("{APPCONTENT}", $content);
$temp->parse();
$temp->printproses();

closeDB();

?>