include("../../kcontrol/lib/session.php");
include("../../kcontrol/lib/config.php");
include("../../kcontrol/lib/connect.php");
include("../../kcontrol/lib/function.php");
$CounterKey="blog";
$CounterID=2;
?>
if ($Member_Session_User_ID>0) { ?>
} else { ?>
$CurrentURL = "http://".$_SERVER['HTTP_HOST'].str_replace("&&","&",str_replace("AlertStr=".str_replace(" ","%20",$AlertStr),"",$_SERVER['REQUEST_URI']));
if (substr($CurrentURL,(strlen($CurrentURL)-1),1)=="?") $CurrentURL = substr($CurrentURL,0,strlen($CurrentURL)-1);
?>
if ($AlertStr<>"") echo ""; ?>
} ?>
$SystemModuleKey = "blog";
## Load Module Configuration Variable ############################################
include("../../kcontrol/blog/config.php");
#########################################################
?>
## Default Value ############################################
$SystemModule_defaultPageSize =10;
$SystemModule_defaultPageShow = 1;
# Check to set default value #########################
if($PageSize=="") { $PageSize = $SystemModule_defaultPageSize; }
if($PageShow=="") { $PageShow = $SystemModule_defaultPageShow; }
$sql_Diary="SELECT * FROM ".$myModule_Table." WHERE 1";
if ($uid>0) $sql_Diary.=" AND ".$myModule_Table."_CreateByID=".$uid;
$sql_Diary.=" AND ".$myModule_Table."_ModuleKey='".$SystemModuleKey."' AND ".$myModule_Table."_Status='Enable'";
/*
$sql_Diary.=" AND ((".
$myModule_Table."_StartDate='0000-00-00 00:00:00' AND ".
$myModule_Table."_ExpireDate='0000-00-00 00:00:00' ".
" ) OR ( ".
$myModule_Table."_StartDate='0000-00-00 00:00:00' AND ".
$myModule_Table."_ExpireDate >= NOW() ".
" ) OR ( ".
$myModule_Table."_StartDate<=NOW() AND ".
$myModule_Table."_ExpireDate='0000-00-00 00:00:00' ".
" ) OR ( ".
$myModule_Table."_StartDate<=NOW() AND ".
$myModule_Table."_ExpireDate>=NOW() ".
"))";
*/
if($GroupID>0){
$sql_Diary.=" AND ".$myModule_Table."_GroupID=".$GroupID;
}
$Search = trim($Search);
if($Search<>""){
$sql_Diary.=" AND (".
$myModule_Table."_ID =".intval($Search).
" OR ".
$myModule_Table."_Subject LIKE '%".$Search."%'".
" OR ".
$myModule_Table."_Title LIKE '%".$Search."%'".
" OR ".
$myModule_Table."_Tags LIKE '%".$Search."%'".
" OR ".
$myModule_Table."_HTMLCode LIKE '%".$Search."%'".
")";
}
$Query_Diary=mysql_query($sql_Diary);
$TotalRecordCount = MYSQL_NUMROWS($Query_Diary);
# Find max page size #########################
if($TotalRecordCount>$PageSize) {
$NoOfPage= ceil($TotalRecordCount/$PageSize);
} else {
$NoOfPage=1;
}
# Recover page show into range #########################
if($PageShow>$NoOfPage) { $PageShow=$NoOfPage; }
# Select only paging range #########################
$RecordStart = ($PageShow-1)*$PageSize;
if ($Order=="") $Order = "Order";
$sql_Diary.=" ORDER BY ".$myModule_Table."_".$Order." DESC LIMIT $RecordStart , $PageSize";
$Query_Diary=mysql_query($sql_Diary);
$RecordCount=MYSQL_NUMROWS($Query_Diary);
if($RecordCount>0){
$BgColor="#fbf8db";
?>
while($Row_Diary=mysql_fetch_array($Query_Diary)){
if($Row_Diary[$myModule_Table."_PictureFile"]!="") $picture_path=$myModule_FullPath_ThumbnailPicture."/".$Row_Diary[$myModule_Table."_PictureFile"];
else $picture_path=$System_FullPath."/images/default.gif";
$sql_Comment="SELECT Count(*) FROM ".$myModule_Table_Comment." WHERE ".$myModule_Table_Comment."_BlogID=".$Row_Diary[$myModule_Table."_ID"];
$Query_Comment=mysql_query($sql_Comment);
$Row_Comment = mysql_fetch_array($Query_Comment);
?>
if($BgColor=="#fdfafa"){
$BgColor="#fbf8db";
}else{
$BgColor="#fdfafa";
}
}
?>
if ($NoOfPage>1) { ?>
หน้าที่ =$PageShow?> จากทั้งหมด =$NoOfPage?> หน้า
if ($NoOfPage>1) { ?>
if ($PageShow>1) { ?><< } ?>
//$starti = ((($PageShow-1)%10)*10)+1;
//$endi = ((($PageShow-1)%10)*10)+10;
$starti = (floor($PageShow/10)*10)+1;
$endi = (floor($PageShow/10)*10)+10;
if ($endi>$NoOfPage) $endi = $NoOfPage;
?>
for ($i=$starti;$i<=$endi;$i++) { ?>
if ($i>1) { ?>
,
} ?>
if ($PageShow==$i) { ?>
=$i?>
} else { ?>
=$i?>
} ?>
} ?>
if ($PageShow<$NoOfPage) { ?> >> } ?>
} ?>
} ?>
}?>
$sql="SELECT ".$myModule_Table_Counter."_Counter FROM ".$myModule_Table_Counter." WHERE ".$myModule_Table_Counter."_Key='".$CounterKey."' ";
$Query_Counter=mysql_query($sql);
$Row_Counter=mysql_fetch_array($Query_Counter);
?>
จำนวนผู้เข้าชม : =$Row_Counter[$myModule_Table_Counter."_Counter"]?>
$MySession=session_id();
$sql="SELECT count(*) FROM ".$myModule_Table_Counter_Check." WHERE ".$myModule_Table_Counter_Check."_Session='".$MySession."' AND ".$myModule_Table_Counter_Check."_CreateDate='".date('Y-m-d')."' AND ".$myModule_Table_Counter_Check."_CID=".$CounterID;
$Query_Counter=mysql_query($sql);
$Row_Counter=mysql_fetch_row($Query_Counter);
if($Row_Counter[0]==0){
$sql="UPDATE ".$myModule_Table_Counter." SET ".$myModule_Table_Counter."_Counter=".$myModule_Table_Counter."_Counter+1 WHERE ".$myModule_Table_Counter."_Key='".$CounterKey."' ";
$Query=mysql_query($sql);
$sql="INSERT INTO ".$myModule_Table_Counter_Check." ( ".$myModule_Table_Counter_Check."_CID,".$myModule_Table_Counter_Check."_Session,".$myModule_Table_Counter_Check."_CreateDate )VALUES( ".$CounterID.",'".$MySession."',NOW()) ";
$Query=mysql_query($sql);
}
$sql="DELETE FROM ".$myModule_Table_Counter_Check." WHERE ".$myModule_Table_Counter_Check."_CreateDate < '".date('Y-m-d')."'";
$Query=mysql_query($sql);
?>