<?php
if (!defined("root")) {
	define("root", $_SERVER['DOCUMENT_ROOT']);
}
require(root."/___simple_config.php");
session_start();
$pageSubOf = "users";
$pageName = "user_visitors";
$pageTitle = "User Visitors";
$thisUrl = "users/visitors";
$pageUrl = "/".adminFolder."/$thisUrl";
$coutSpecs = array('nl'=>"n");
require(root."/".adminFolder."/_common.php");
require(root."/".adminFolder."/_lib/db.php");
require(root."/".adminFolder."/_lib/main.php");
### auth cara 2
#require(root."/".adminFolder."/_lib/auth.php");
$stgl = cekpost(cleanQuery($_REQUEST["fil_stgl"]), date('d-m-Y', time()));
$etgl = cekpost(cleanQuery($_REQUEST["fil_etgl"]), date('d-m-Y', time()));
$q_stgl = strtotime($stgl);
$q_etgl = strtotime($etgl)+86400;
$fil_stgl = strtotime($stgl);
$fil_etgl = strtotime($etgl);

$a = cekpost(cleanQuery($_GET["a"]), "");
require(root."/".adminFolder."/_tpl/tag_html_a.php");
cout('
<style type="text/css">
</style>
');
require(root."/".adminFolder."/_tpl/openbody.php");
require(root."/".adminFolder."/_tpl/header.php");
cout('<div class="page-header">');
	cout('<h1>'.$pageTitle.'</h1>');
cout('</div>');
# MAIN
###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ######
if ($a=="" || $a=="main") {
	cout('<div class="section_submenus">');
		cout('<ul class="nav nav-tabs" role="tablist">');
			cout('<li role="presentation" class="active"><a href="'.$pageUrl.'/" title="Main List"><span class="glyphicon glyphicon-list"></span> Main</a></li>');
		cout('</ul>');
	cout('</div>');
	cout('<nav class="navbar navbar-default">
		<div class="container-fluid">
			<!-- Brand and toggle get grouped for better mobile display -->
			<div class="navbar-header">
				<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-2" aria-expanded="false">
					<span class="sr-only">Toggle navigation</span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
				</button>
				<a class="navbar-brand" href="#">Filter</a>
			</div>
			<!-- Collect the nav links, forms, and other content for toggling -->
			<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-2">
				<form class="navbar-form navbar-left" role="search" method="post" target="filter_iframe" action="/'.adminFolder.'/_ajax/ajax_members.php?a=section_main">');
					cout('<div class="form-group">
						<div class="controls"><label for="fil_stgl">From</label>
							<div class="input-group">
								<input id="fil_stgl" type="text" class="fil_stgl form-control" placeholder="Start Date" value="'.date('d-m-Y', $fil_stgl).'" />
								<label for="fil_stgl" class="input-group-addon btn">
									<span class="glyphicon glyphicon-calendar"></span>
								</label>
							</div>
						</div>
					</div>');
					cout('<div class="form-group">
						<div class="controls"><label for="fil_etgl">To</label>
							<div class="input-group">
								<input id="fil_etgl" type="text" class="fil_etgl form-control" placeholder="End Date" value="'.date('d-m-Y', $fil_etgl).'" />
								<label for="fil_etgl" class="input-group-addon btn">
									<span class="glyphicon glyphicon-calendar"></span>
								</label>
							</div>
						</div>
					</div>');
					cout('<div class="form-group">
						<label for="fil_limit">Show Limit</label>
						<select name="fil_limit" id="fil_limit" class="form-control">
							<option value="20">20</option>');
							$alimit=array(0=>100, 300, 1000, 2000, 2500, 3000, 3500, 4000, 4500, 5000);
							for ($j=0;$j<count($alimit);$j++) {
								cout('<option value="'.$alimit[$j].'">'.$alimit[$j].'</option>');
							}
						cout('
						</select>
					</div>');
					cout('
					<button type="button" class="btn btn-primary" onclick="filterReload(\''.$pageName.'\', 1);return false;">Search</button>
				</form>
			</div><!-- /.navbar-collapse -->
		</div><!-- /.container-fluid -->
	</nav>');
	#cout('<div>Upload: <span id="progress-upload"></span></div>');
	#cout('<div>Download: <span id="progress-download"></span></div>');
	
	#cout('<div class="bar-upload"><div class="progress-upload">Uploaded</div>Upload</div>');
	#cout('<div class="bar-download"><div class="progress-download">Downloaded</div>Download</div>');
	cout('<div class="ajax_resp"></div>');
	cout('<script>
		function checkIP(parIP) {
			$(".modal-title").html("Check IP: <strong>"+ parIP +"</strong>");
			$(".modal-body").html("<img src=\"/'.adminFolder.'/img/ajax-loader.gif\" /> <div>or</div><div><a href=\"http://ipinfo.io/"+parIP+"/json\" target=\"_blank\">http://ipinfo.io/"+parIP+"/json</a></div>");
			$(".modal-footer").html("<button type=\"button\" class=\"btn btn-danger\" data-dismiss=\"modal\">Close</button>");
			$("#myModal").modal("show");
			$.ajax({
				type: "GET",
				url: "/'.adminFolder.'/_ajax/ajax_user_visitors.php",
				data: "a=checkip&ip="+ parIP +"",
				success: function(resp){
					$(".modal-body").html(resp);
				}
			});
			
		}
		function getRefDet(parKD) {
			$(".modal-title").html("Referer Details");
			//alert(escape($(".ref"+parKD+"").html()));
			$(".modal-body").html($(".ref"+parKD+"").html());
			$(".modal-footer").html("<button type=\"button\" class=\"btn btn-danger\" data-dismiss=\"modal\">Close</button>");
			$("#myModal").modal("show");
		}
		$(".fil_stgl, .fil_etgl").datepicker({
			inline: true,
			autosize: true,
			yearRange: "'.(date('Y', time())-5).':'.(date('Y', time())+1).'",
			changeMonth: true,
			changeYear: true,
			dateFormat: "dd-mm-yy"
		});
		filterReload(\''.$pageName.'\', 1);
	</script>');
}
###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ######
/*
cout('<div class="container">');
	#require(root."/".adminFolder."/_tpl/menu.php");
	cout('<div id="contentPanel">');
		cout('<div class="bigTitle">'.$pageTitle.'</div>');
		#if (!authorizedModule("user_act_main", $_SESSION["user"]["kduser"])) {
		#	unAuthorizedAccess("user_act_main");
		#} else {
			# MAIN
			###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ######
			if ($a=="" || $a=="main") {
				cout('<div class="contentMenu">');
					cout(adminSubMenu(''.$pageUrl.'/', "main", "Main"));
					#cout(textSeparator());
					#cout(adminSubMenu(''.$pageUrl.'/add/', "add", "Add"));
				cout('</div>');
				cout('<div class="contentContainer">');
					cout('<div class="helper">');
						
						cout('<div style="padding:10px;border:1px #ccc solid;border-radius:5px;">');
							cout('<form method="post">');
								cout('<div style="display:inline-block;width:100%;">');
									cout('<div class="filter-panel">');
										cout('<div class="sect">');
											#if (!authorizedModule("user_act_search_date", $_SESSION["user"]["kduser"])) {
											#	unAuthorizedAccess("user_act_search_date", 1);
											#} else {
												cout('<div class="label"><label for="fil_stgl">Start Date</label>:</div>');
												cout('<div><input type="text" id="fil_stgl" name="fil_stgl" value="'.date('d-m-Y', $fil_stgl).'" /></div>');
											#}
										cout('</div>');
										cout('<div class="sect">');
											#if (!authorizedModule("user_act_search_date", $_SESSION["user"]["kduser"])) {
											#	unAuthorizedAccess("user_act_search_date", 1);
											#} else {
												cout('<div class="label"><label for="fil_etgl">End Date</label>:</div>');
												cout('<div><input type="text" id="fil_etgl" name="fil_etgl" value="'.date('d-m-Y', $fil_etgl).'" /></div>');
											#}
										cout('</div>');
										cout('<div class="sect">');
											#if (!authorizedModule("user_act_search_username", $_SESSION["user"]["kduser"])) {
											#	unAuthorizedAccess("user_act_search_username", 1);
											#} else {
												cout('<div class="label"><label for="fil_kduser">Users</label>:</div>');
												cout('<div>');
													cout('<select class="input" name="fil_kduser" id="fil_kduser">');
														cout('<option value=""></option>');
														$rsp=array(); $qp="SELECT * FROM _users";
														callRS($rsp, $qp);
														for ($j=0;$j<count($rsp);$j++) {
															if ($fil_userid!="") {
																$selp = intval($rsp[$j]["kduser"])==intval($fil_userid)?' selected="selected" ':'';
															}
															cout('<option value="'.$rsp[$j]["kduser"].'" '.$selp.'>'.$rsp[$j]["username"].' ['.$rsp[$j]["inisial"].']</option>');
														}
													cout('</select>');
												cout('</div>');
											#}
										cout('</div>');
										cout('<div class="sect">');
											#if (!authorizedModule("user_act_search_limit", $_SESSION["user"]["kduser"])) {
											#	unAuthorizedAccess("user_act_search_limit", 1);
											#} else {
												cout('<div class="label"><label for="fil_limit">Show Limit</label>:</div>');
												cout('<div>');
													cout('<select class="input" name="fil_limit" id="fil_limit">');
														cout('<option value="20">20</option>');
														$alimit=array(0=>100, 300, 1000, 2000);
														for ($j=0;$j<count($alimit);$j++) {
															$sell = intval($fil_limit)==intval($alimit[$j])?' selected="selected" ':'';
															cout('<option value="'.$alimit[$j].'" '.$sell.'>'.$alimit[$j].'</option>');
														}
													cout('</select>');
												cout('</div>');
											#}
										cout('</div>');
									cout('</div>');
								cout('</div>');
								
								cout('<div>');
									cout('<div><input class="formButton" type="button" id="submit_filter" value="Submit" onclick="loadall();return false;" /></div>');
								cout('</div>');
								
							cout('</form>
							
							
							<script>
								$(window).load(function(){
									$("#fil_stgl, #fil_etgl").datepicker({
										inline: true,
										autosize: true,
										yearRange: "'.(date('Y', time())-5).':'.(date('Y', time())+1).'",
										changeMonth: true,
										changeYear: true,
										dateFormat: "dd-mm-yy"
									});
								});
							</script>
						</div>');
						cout('
						<div class="main-ajax-content"></div>');
						cout('
						<script>
							loadall();
							function loadall() {
								var fil_stgl = $("#fil_stgl").val();
								var fil_etgl = $("#fil_etgl").val();
								var fil_kduser = $("#fil_kduser").val();
								var fil_limit = $("#fil_limit").val();
								var adata = "a=loadall";
								adata += "&fil_stgl="+ fil_stgl +"";
								adata += "&fil_etgl="+ fil_etgl +"";
								adata += "&fil_kduser="+ fil_kduser +"";
								adata += "&fil_limit="+ fil_limit +"";
								$(".main-ajax-content").html("<img src=\"/'.adminFolder.'/img/ajax-loader.gif\" alt />");
								$.ajax({
									type: "GET",
									url: "/'.adminFolder.'/_ajax/ajax_user_activities.php",
									data: adata,
									success: function(resp){
										$(".main-ajax-content").html(resp);
									}
								});
							}
						</script>
						');
					cout('</div>');
				cout('</div>');
			}
			###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ######
		#}
	cout('</div>');
cout('</div>');
*/
require(root."/".adminFolder."/_tpl/footer.php");
require(root."/".adminFolder."/_tpl/tag_html_b.php");
?>