<?php

//////////////////////////////////////////////////////////////
//===========================================================
// iplogs_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 iplogs_theme(){

global $theme, $globals, $kernel, $user, $l, $error, $current_status, $iplogs;

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', 'lm_logs', 'lms_iplogs'];

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

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

	<div id="showsearch" style="display:'.(optREQ('search') || (!empty($iplogs) && !empty($globals['showsearch'])) ? "" : "none").';">
<form accept-charset="'.$globals['charset'].'" name="iplogs" method="get" action="" class="form-horizontal">
<input type="hidden" name="act" value="iplogs">
		
<div class="form-group_head">
  <div class="row mx-auto w-100">
    <div class="col-sm-3"></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 class="col-sm-3">
		<label>'.__('VPSID').'</label>
		<input type="text" class="form-control" name="vpsid" id="vpsid" size="30" value="'.REQval('vpsid','').'"/>
	</div>
  </div>
  <div class="row mt-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(count($current_status) == 1){
	
	$current = current($current_status);
	
	$str = (empty($current['vpsid']) ? __('<b>{{ip}}</b> is free') : __('<b>{{ip}}</b> is in use by VPSID : {{vpsid}}'));
	
	echo '<div class="notice"><b>NOTE : </b>&nbsp; '.lang_vars_name($str, array('vpsid' => $current['vpsid'], 
		'ip' => $current['ip'])
	).'</div>';
}

if(empty($iplogs)){
	optREQ('search') ? show_alert(__('No results were found for your search query !'), "2") : "";
	echo '<div class="notice"><b>NOTE : </b>&nbsp; '.(optREQ('search') ? __('No results were found for your search query !') : __('There are no IP 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 iplog_table common-table">
	<tr class="table_heading">
		<th class="min_width" align="center">'.__('ID').'</th>
		<th class="min_width text-nowrap" align="center">'.__('IP ID').'</th>
		<th width="130" align="center">'.__('IP').'</th>
		<th class="min_width" align="center">'.__('VPSID').'</th>
		<th width="75" align="center">'.__('User ID').'</th>
		<th align="center">'.__('Email').'</th>
		<th width="85">'.__('Cloud UID').'</th>
		<th align="center">'.__('Cloud Email').'</th>
		<th align="center">'.__('Time').'</th>
		<th class="min_width" align="center">'.__('Date').'</th>
	</tr>';
	$i = 0;
	foreach($iplogs as $k => $v){
		
	echo '<tr>
			<td align="left">'.$v['iplid'].'</td>
			<td align="left">'.$v['ipid'].'</td>
			<td>'.$v['ip'].'</td>
			<td>'.$v['vpsid'].'</td>
			<td>'.$v['uid'].'</td>
			<td><span class="userflare">'.$v['email'].'</span></td>
			<td>'.$v['cloud_uid'].'</td>
			<td>'.$v['cloud_email'].'</td>
			<td>'.datify($v['time'], 0, 1, "h:i:s A").'</td>
			<td>'.datify($v['date'], 0, 1, "Y-m-d").'</td>
		<tr>';
		$i++;
	}
	
	echo '</table></div>
	<div class="row mx-auto w-100 mt-5">
		<div class="col-sm-8 col-lg-8 col-md-6 mb-3 p-0">';
			page_links($globals['num_res'], $globals['cur_page'], $globals['reslen']);
		echo'
		</div>
	</div>
	<form id="delete" accept-charset="'.$globals['charset'].'" name="iplogs" 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();

}

?>