<?php

//////////////////////////////////////////////////////////////
//===========================================================
// loginlogs_theme.php
//===========================================================
// SOFTACULOUS VIRTUALIZOR
// Version : 1.0
// Inspired by the DESIRE to be the BEST OF ALL
// ----------------------------------------------------------
// Started by: Alons
// Date:       8th Mar 2010
// Time:       23:00 hrs
// Site:       https://www.virtualizor.com/ (SOFTACULOUS VIRTUALIZOR)
// ----------------------------------------------------------
// Please Read the Terms of use at https://www.virtualizor.com
// ----------------------------------------------------------
//===========================================================
// (c)Softaculous Ltd.
//===========================================================
//////////////////////////////////////////////////////////////

if(!defined('VIRTUALIZOR')){

	die('Hacking Attempt');

}

function loginlogs_theme(){

global $theme, $globals, $kernel, $user, $l, $error, $loginlogs;

softheader($l['<title>']);
					
echo '
<script language="javascript" type="text/javascript">
	function confirm(){
		showalert("'.__J('Are you sure you want to delete the logs ?').'", "3", function(confirm){
			if(confirm == true){
				$("#delete").submit();
			}
		});
		return false;
	}
</script>';


$GLOBALS['breadcrumbs'] = ['dashboard', 'lms_loginlogs'];

echo page_header(__('Login Logs'), 'fas fa-clipboard-list', '', 1);

echo '<div class="card p-2 mx-3">

<div id="showsearch" class="mb-3" style="display:'.(optREQ('search') || (!empty($loginlogs) && !empty($globals['showsearch'])) ? "" : "none").';">
	<form accept-charset="'.$globals['charset'].'" name="loginlogs" method="get" action="" class="form-horizontal">
		<input type="hidden" name="act" value="loginlogs">
		<br>
		<div class="form-group_head">
			<div class="row mx-auto w-100">
				<div class="col-sm-3"></div>
				<div class="col-sm-3">
					<label>'.__('Username').'</label>
					<input type="text" class="form-control" name="username" id="username" size="30" value="'.REQval('username','').'"/>
				</div>
				<div class="col-sm-3">
					<label>'.__('IP').'</label>
					<input type="text" class="form-control" name="ip" id="ip" size="30" value="'.REQval('ip','').'"/>
				</div>
			</div>
			<div class="row my-2 mx-auto w-100">
				<div class="col-sm-12 text-center"><button type="submit" name="search" class="go_btn mt-2" value="Search"/>'.__('search').'</button></div> 
			</div>
		</div>
	</form>
</div>';

if(empty($loginlogs)){
	optREQ('search') ? show_alert(__('No results were found for your search query'), "2") : "";
	echo '<div class="notice"><b>NOTE : </b>&nbsp; '.__('There are no Login Logs').'</div>';
}
else{
	echo'<div class="row mx-auto w-100 mb-3">
		<div class="col-sm-4 col-lg-4 col-md-6 d-flex align-items-center p-0">
		</div>
		<div class="col-sm-8 col-lg-8 col-md-6 d-flex align-items-center justify-content-end p-0 mt-2 mt-md-0 mt-lg-0">';
			page_links($globals['num_res'], $globals['cur_page'], $globals['reslen']);
			echo get_num_records($globals['num_res']).'
		</div>
	</div>
	<div class="w-100 mx-auto sticky">
	
	<table class="table table-hover tablesorter common-table">
	<tr class="table_heading">
		<th align="center">'.__('Date').'</th>
		<th align="center">'.__('Username').'</th>
		<th align="center">'.__('IP').'</th>
		<th align="center">'.__('Status').'</th>
	</tr>';
	$i = 0;
	foreach($loginlogs as $k => $v){
		
	echo '<tr>
			<td>'.datify($v['time']).'</td>
			<td><span class="userflare">'.$v['username'].'</span></td>
			<td>'.$v['ip'].'</td>
			<td align="center">'.($v['status'] == 1 ? 'Successful' : '<font color="#FF0000">Failed</font>').'</td>
		<tr>';
		$i++;
	}
	
	echo '</table></div>
	<div class="row mx-auto w-100 mt-5">
		<div class="col-sm-4 col-lg-4 col-md-6 d-flex align-items-center p-0">
	</div>
		<div class="col-sm-8 col-lg-8 col-md-6 mb-3 p-0 d-flex align-items-center justify-content-end">';
			page_links($globals['num_res'], $globals['cur_page'], $globals['reslen']);
			echo'
		</div>
	</div>
	<form  id="delete" accept-charset="'.$globals['charset'].'" name="loginlogs" method="post" action="" class="form-horizontal">
	<input type="hidden" name="delete" value="1"></input> 
		<center><input type="button" value="'.__('Delete All Logs').'" class="btn" onclick="confirm();"></center>
	</form>';
}

echo '</div>';
softfooter();

}

?>