File: /home/pengthai/domains/pengthaicurry.com/public_html/admin/dashboard.php
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php
include("include/title.php");
include("include/chksession.php");
include("include/connect.php");
?>
<link rel="stylesheet" type="text/css" href="css/style.css" />
<link rel="stylesheet" type="text/css" href="css/bootstrap-theme.css"/>
<link rel="stylesheet" type="text/css" href="css/bootstrap.css"/>
<link rel="stylesheet" type="text/css" href="css/font-awesome.css">
<link rel="stylesheet" type="text/css" href="css/component.css"/>
<link rel="stylesheet" type="text/css" href="css/datepicker.css" />
<script src="js/jquery-1.8.3.js" type="text/javascript"></script>
<script src="js/bootstrap.js" type="text/javascript"></script>
<script src="js/jquery.easing.1.3.js"></script>
<script src="js/modernizr.custom.js" type="text/javascript"></script>
<script src="js/jquery-ui-1.9.2.custom.js"></script>
<script src="js/bootstrap-datepicker.js"></script>
</head>
<body>
<div id="header" class="row">
<div class="col-xs-12 col-sm-6 col-md-6">
<?php
$current_page=1;
include 'include/header-left-menu.inc.php';
include 'include/function.php';
?>
</div>
</div>
<div class="h20"></div>
<div id="main-content">
<div class="welcome">
<h2 class="font26">ยินดีต้อนรับ</h2>
<h2>เข้าสู่ระบบจัดการของ "<span class="orange">บ้าน</span>เว็บไซต์"</h2>
<br/>
<?php
function smart_ip_detect_crawler($agent)
{
$bot_identifiers = array(
'bot',
'slurp',
'crawler',
'spider',
'curl',
'facebook',
'fetch',
);
// See if one of the identifiers is in the UA string.
foreach ($bot_identifiers as $identifier)
{
if (strpos($agent, $identifier) !== FALSE)
{
return TRUE;
}
}
return FALSE;
}
$MD5ID = "0dbe8560086a8c52a982b12e265a40dd";
$url_connected = $_SERVER['SERVER_NAME'];
//$REMOTE_ADDR = $_SERVER['REMOTE_ADDR'];
if (getenv(HTTP_X_FORWARDED_FOR))
$REMOTE_ADDR=getenv('HTTP_X_FORWARDED_FOR');
else
$REMOTE_ADDR=getenv('REMOTE_ADDR');
$user_agent = strtolower($_SERVER['HTTP_USER_AGENT']);
$IsBot = 0;
if( smart_ip_detect_crawler($user_agent) == true )
$IsBot = 1;
if( strlen($MD5ID) != 32 ){exit();}
$opt_connected_cfgbase = $dbname;
$opt_connected_cfguser = $User;
$opt_connected_cfgpass = $Password;
$opt_connected_cfghote = $ServerName;
$nb_connected_connexion=300; // 5 minutes สำหรับ User Online
$nb_connected_uip=3600; // 60 minutes สำหรับ UIP
$update_uip = 1;
$user_online = 1;
$uip_today = 1;
$pv_today = 1;
$uip_month = 1;
$pv_month = 1;
$uip_all = 1;
$pv_all = 1;
$base_connected=mysql_connectx($opt_connected_cfghote, $opt_connected_cfguser,$opt_connected_cfgpass);
if (!$base_connected)
{
exit();
}
if(!mysql_select_dbx("$opt_connected_cfgbase",$base_connected))
{
mysql_closex($base_connected);
exit();
}
$time_connected=date("U");
$ip_connected=$REMOTE_ADDR;
$query_connected="SELECT * FROM hits_useronline WHERE id='$MD5ID' AND ip='$ip_connected'";
$result_connected=@mysql_queryx($query_connected,$base_connected);
if (!$result_connected)
{
mysql_closex($base_connected);
exit();
}
$nb_connected=@mysql_num_rowsx($result_connected);
if ($nb_connected)
{
$time_max_uip=$time_connected-$nb_connected_uip;
$r= mysql_fetch_arrayx($result_connected);
if( $r[time] > $time_max_uip )
{
$update_uip = 0; // เคยเข้ามาแล้ว และยังอยู่ในเวลาที่กำหนด
}
if( $IsBot==0 )
{
$query_connected="UPDATE hits_useronline SET time='$time_connected' WHERE id='$MD5ID' AND ip='$ip_connected'";
$result_connected=@mysql_queryx($query_connected,$base_connected);
}
}
else
{
if( $IsBot==0 )
{
$query_connected="INSERT INTO hits_useronline (id, ip, time) VALUES ('";
$query_connected.=$MD5ID;
$query_connected.="', '";
$query_connected.=$ip_connected;
$query_connected.="', '";
$query_connected.=$time_connected;
$query_connected.="')";
$result_connected=@mysql_queryx($query_connected,$base_connected);
}
}
$time_max_connected=$time_connected-$nb_connected_connexion;
$query_connected="DELETE FROM hits_useronline WHERE time<'$time_max_connected'";
$result_connected=@mysql_queryx($query_connected,$base_connected);
$query_connected="SELECT * from hits_useronline WHERE id='$MD5ID'";
$result_connected=@mysql_queryx($query_connected,$base_connected);
$user_online=@mysql_num_rowsx($result_connected);
$today=(integer)date("d");
$month=(integer)date("m");
$today_full = date("Y-m-d");
$query_connected="SELECT * FROM hits_counter WHERE id='$MD5ID'";
$result_connected=@mysql_queryx($query_connected,$base_connected);
if (mysql_num_rowsx($result_connected)==0)
{
$query_connected="INSERT INTO hits_counter (id, today_date, this_month, uip_today, pv_today, uip_month, pv_month, uip_all, pv_all) VALUES ('";
$query_connected.=$MD5ID;
$query_connected.="', '";
$query_connected.=$today_full;
$query_connected.="', '";
$query_connected.=$month;
$query_connected.="', '";
$query_connected.=1; //uip_today
$query_connected.="', '";
$query_connected.=1; //pv_today
$query_connected.="', '";
$query_connected.=1; //uip_month
$query_connected.="', '";
$query_connected.=1; //pv_month
$query_connected.="', '";
$query_connected.=1; //uip_all
$query_connected.="', '";
$query_connected.=1; //pv_all
$query_connected.="')";
if( $IsBot==0 )
$result_connected=@mysql_queryx($query_connected,$base_connected);
}
else
{
$r= mysql_fetch_arrayx($result_connected);
$uip_today = (integer)$r[uip_today];
$uip_month = (integer)$r[uip_month];
$uip_all = (integer)$r[uip_all];
$pv_today = (integer)($r[pv_today]+1);
$pv_month = (integer)($r[pv_month]+1);
$pv_all = (integer)($r[pv_all]+1);
// อัพเดต UIP
if( $update_uip==1 )
{
$uip_today++;
$uip_month++;
$uip_all++;
}
// วันนี้
if( $today_full != $r[today_date] )
{
// reset today
$uip_today = 1;
$pv_today = 1;
}
// เดือนนี้
if( $month != $r[this_month] )
{
// reset month
$uip_month = 1;
$pv_month = 1;
}
// $query_connected = "UPDATE hits_counter SET uip_today='$uip_today', pv_today='$pv_today', uip_month='$uip_month', pv_month='$pv_month', uip_all='$uip_all', pv_all='$pv_all', url='$url_connected', ip='$ip_connected'";
// วันนี้
if($today_full != $r[today_date]){
$query_connected .= ", today_date='$today_full'";
}
// เดือนนี้
if($month != $r[this_month]){
$query_connected .= ", this_month='$month'";
}
$query_connected .= " WHERE id='$MD5ID' ";
if( $IsBot==0 )
$result_connected=@mysql_queryx($query_connected,$base_connected);
//Update hits_counter2
$query2="INSERT INTO hits_counter2(date,uip)
VALUE ('$today_full','$uip_today')
ON DUPLICATE KEY UPDATE uip='$uip_today' ";
if( $IsBot==0 )
$result2=@mysql_queryx($query2,$base_connected);
}
// Close connexion to DB
//mysql_closex($base_connected);
$disp_online = number_format($user_online);
$disp_today = number_format($uip_today);
$disp_total = number_format($uip_all);
?>
<h2>สถิติ ประจำวันที่ : <span class="orange"><?=displaydate_enshort($today_full)?></span></h2>
<strong class="font12">Online : <span class="orange"><?=$disp_online?></span> l Today : <span class="orange"><?=$disp_today?></span> l Total : <span class="orange"><?=$disp_total?></span></strong>
<div class="h20"></div>
<?php
$today=(integer)date("d");
$month=(integer)date("m");
$year=(integer)date("Y");
$today_full = date("Y-m-d");
$stat_month = $_GET['stat_month'];
$dateStart = $_GET['date-start'];
$dateEnd = $_GET['date-end'];
$sql_his2 = "SELECT SUM(uip) AS sum_uip FROM hits_counter2 ";
if (!empty($stat_month)) { // เดือนเฉพาะปีปัจจุบัน
$sql_his2 .= "WHERE date LIKE '$year-$stat_month-%' ";
$result_his2=@mysql_queryx($sql_his2,$base_connected);
$r2= mysql_fetch_arrayx($result_his2);
$sum_uip_month = $r2['sum_uip'];
}
?>
<div class="font12">สถิติ ประจำเดือน :
<select name="stat_month" class="stat_month">
<option value="0">--- เลือกเดือน ---</option>
<?php
$thMonth = array("มกราคม","กุมภาพันธ์","มีนาคม","เมษายน","พฤษภาคม","มิถุนายน","กรกฏาคม","สิงหาคม","กันยายน","ตุลาคม","พฤศจิกายน","ธันวาคม");
$count_month = 0;
while ($count_month <12) {
?>
<option value="<?=sprintf('%02d', $count_month+1)?>" <?php if($stat_month==$count_month+1) echo "selected"; ?> ><?=$thMonth[$count_month]?></option>
<?php
$count_month ++;
}
?>
</select>
ปี พ.ศ. <?=date("Y")+ 543?>
<h2 class="orange"><?php if (!empty($stat_month)) { ?><?=number_format($sum_uip_month)?><?php } ?></h2>
<div class="h20"></div>
<form action="dashboard.php" method="get" id="Form" enctype="multipart/form-data">
<?php
if($dateStart!=""&&$dateEnd!="")
{
$dateStart = new DateTime($dateStart);
$dateStart=date_format($dateStart,"Y-m-d");
$dateEnd = new DateTime($dateEnd);
$dateEnd=date_format($dateEnd,"Y-m-d");
$sql_his3 = "SELECT SUM(uip) AS sum_uip FROM hits_counter2 WHERE date BETWEEN '$dateStart' AND '$dateEnd' "; //kk ช่วงระหว่าง 2015-05-13 AND 2015-05-15 อย่างนี้
$result_his3=@mysql_queryx($sql_his3,$base_connected);
$r3= mysql_fetch_arrayx($result_his3);
$sum_uip_range = $r3['sum_uip'];
}
?>
<div class="input-daterange">
<i class="fa-calendar"></i> ช่วงวันที่ : <input type="text" name="date-start" value="<?=$dateStart?>" class=" date-picker dateStart " readonly placeholder="วันที่เริ่ม" required/> |
<strong>วันที่สิ้นสุด </strong> : <input type="text" id="checkout" name="date-end" value="<?=$dateEnd?>" class=" date-picker dateEnd " readonly placeholder="วันที่สิ้นสุด" required/>
</div>
<div class="h20"></div>
<input type="hidden" name="stat_month" value="<?=$stat_month?>">
<button type="submit" class="bt-search"><strong><i class="fa-search"></i> ค้นหา</strong></button>
<h2 class="orange"><?php if($dateStart!=""&&$dateEnd!="") { ?><?=number_format($sum_uip_range)?><?php } ?></h2>
</form>
</div>
<div class="h20"></div>
<?php
$mainFolder = "../album";
if( decoct(fileperms($mainFolder) & 0777) != 777)
{
echo "<span style='color:red;'>ยังไม่ได้เซต 777 ($mainFolder)</span><br>";
}
?>
<div align="center" class="font12 orange">
ระบบหลังร้านของบ้านเว็บไซต์ มีฟังก์ชั่นการทำงานที่ support กับ browser ของ <strong>Google Chrome</strong> เป็นหลัก<br>
ดังนั้น จึงอยากจะขอรบกวนลูกค้าใช้งานกับ browser ตัวนี้<br>
โดยดาวน์โหลดได้ที่ https://www.google.com/intl/th/chrome/browser/desktop/index.html<br>
</div>
<div class="h20"></div>
<div align="center">
<div class="h30"></div>
<img src="images/logo.png" width="48"/>
<span class="font10 orange" lang="en">baan</span><span class="font10" lang="en">website</span>
</div>
<div align="center" class="font10">บ้านเว็บไซต์ สายด่วน : 094-326-6524 , 094-326-6552 </div>
<div align="center" class="font10">Copyright 2015 © บ้านเว็บไซต์.com [Vesion 4.0]</div>
</div>
</div>
</body>
<script>
$(function() {
$('.stat_month').change(function() {
var stat_month = $(this).val();
var stat_date_start = $('input[name=date-start]').val();
var stat_date_end = $('input[name=date-end]').val();
// alert(stat_date_start +"-"+ stat_date_end);
var staturl = 'dashboard.php?stat_month='+stat_month+'&date-start='+stat_date_start+'&date-end='+stat_date_end ;
var xmlhttp = new XMLHttpRequest();
window.location.href = staturl;
return false;
});
//DATE PICKER
/*$('.date-picker').datepicker({
dateFormat: "yy-mm-dd",
maxDate:0,
nextText: "",
prevText: ""
});*/
$('.input-daterange').datepicker({
format: "yyyy-mm-dd",
autoclose: true,
todayHighlight: true,
toggleActive: true/*,
startDate: new Date(),*/ /*เลือกวันปัจจุบัน*/
});
$('.dateStart').datepicker().on('changeDate', function(e) {
var newDate = new Date(e.date)
var data_null ="";
newDate.setDate(newDate.getDate() + 1);
$('.dateEnd').datepicker('update', newDate);
});
/***************************************************/
});
</script>
</html>