= '4.3.0') { $string = mysql_real_escape_string($string); } else { $string = mysql_escape_string($string); } return $string; } function make_seed() { list($usec, $sec) = explode(' ', microtime()); return (float) $sec + ((float) $usec * 100000); } function byteConvert($bytes) { $s = array('Byte', 'Kb', 'MB', 'GB', 'TB', 'PB'); $e = floor(log($bytes)/log(1024)); return sprintf('%.2f '.$s[$e], ($bytes/pow(1024, floor($e)))); } function remove_newline($document){ $pat[0] = "/^\s+/"; $pat[1] = "/\s{2,}/"; $pat[2] = "/\s+\$/"; $rep[0] = ""; $rep[1] = " "; $rep[2] = ""; if (stristr($_SERVER['HTTP_USER_AGENT'], 'WIN')) { $document = str_replace("\r\n", "
", $document); } else { $document = str_replace("\n", "
", $document); } $document = preg_replace($pat,$rep,$document); return $document; } function limit_text ( $str, $n ) { if ( strlen ( $str ) <= $n ) { return $str; } else { return substr ( $str, 0, $n ) . '...'; } } function curPageURL() { $pageURL = 'http'; if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";} $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; } else { $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; } return $pageURL; } function reArrayFiles($file_post) { $file_ary = array(); $file_count = count($file_post['name']); $file_keys = array_keys($file_post); for ($i=0; $i<$file_count-1; $i++) { foreach ($file_keys as $key) { $file_ary[$i][$key] = $file_post[$key][$i]; } } return $file_ary; } function iconv2($Var1, $Var2, $str) { //return iconv("$Var1", "$Var2", $str); return tis620_to_utf8($str); // not support iconv } function tis620_to_utf8 ( $string ) { for( $i=0 ; $i< strlen ( $string ) ; $i++ ){ $s = substr ( $string, $i, 1); $val = ord ( $s ); if ( $val < 0x80 ) { $utf8 .= $s; } elseif ( ( 0xA1 <= $val and $val <= 0xDA ) or ( 0xDF <= $val and $val <= 0xFB ) ){ $unicode = 0x0E00 + $val - 0xA0; $utf8 .= chr ( 0xE0 | ($unicode >> 12) ); $utf8 .= chr ( 0x80 | ( ($unicode >> 6) & 0x3F) ); $utf8 .= chr ( 0x80 | ($unicode & 0x3F) ); } } return $utf8; } function utf8_to_tis620 ( $string ) { $str = $string; $res = ''; for ( $i = 0; $i < strlen ( $str ); $i++ ) { if ( ord ( $str[$i] ) == 224 ) { $unicode = ord ( $str[$i+2] ) & 0x3F; $unicode |= ( ord ( $str[$i+1] ) & 0x3F ) << 6; $unicode |= ( ord ( $str[$i] ) & 0x0F ) << 12; $res .= chr ( $unicode - 0x0E00 + 0xA0 ); $i += 2; } else { $res .= $str[$i]; } } return $res; } function getPHPVersion($int='full'){ if($int=='short'){ return (int)phpversion(); }else{ return phpversion(); } } function getDBVersion(){ $t=mysql_query("select version() as ve"); echo mysql_error(); $r=mysql_fetch_object($t); $iArray = explode('.', $r->ve); $iVersion = $iArray[0].$iArray[1]; return (int)$iVersion; } function getCreator($ID){ return $ID; } ############################################ function DateAdd($interval, $date) { ############################################ return date("Y-m-d H:i:s", strtotime(date("Y-m-d H:i:s", strtotime($date)) . " $interval")); } function getDateFull($myDate, $Lang='th'){ if($Lang=='th'){ $myDateArray=explode("-",$myDate); $myDay = sprintf("%d",$myDateArray[2]); switch($myDateArray[1]) { case "01" : $myMonth = "Ҥ"; break; case "02" : $myMonth = "Ҿѹ"; break; case "03" : $myMonth = "չҤ"; break; case "04" : $myMonth = "¹"; break; case "05" : $myMonth = "Ҥ"; break; case "06" : $myMonth = "Զع¹"; break; case "07" : $myMonth = "áҤ"; break; case "08" : $myMonth = "ԧҤ"; break; case "09" : $myMonth = "ѹ¹"; break; case "10" : $myMonth = "Ҥ"; break; case "11" : $myMonth = "Ȩԡ¹"; break; case "12" : $myMonth = "ѹҤ"; break; } $myYear = sprintf("%d",$myDateArray[0])+543; return($myDay . " " . $myMonth . " " . $myYear); }else{ $myDateArray=explode("-",$myDate); $myDay = sprintf("%d",$myDateArray[2]); $myDay2 = ""; if($myDay==1){ $myDay2=st; } else if($myDay==2){ $myDay2=nd; } else if($myDay==3){ $myDay2=rd; } else{ $myDay2=th; } switch($myDateArray[1]) { case "01" : $myMonth = "January"; break; case "02" : $myMonth = "February"; break; case "03" : $myMonth = "March"; break; case "04" : $myMonth = "April"; break; case "05" : $myMonth = "May"; break; case "06" : $myMonth = "June"; break; case "07" : $myMonth = "July"; break; case "08" : $myMonth = "August"; break; case "09" : $myMonth = "September"; break; case "10" : $myMonth = "October"; break; case "11" : $myMonth = "November"; break; case "12" : $myMonth = "December"; break; } $myYear = sprintf("%d",$myDateArray[0]); return($myMonth . " " . $myDay.$myDay2 .",". " " . $myYear); } } function getDateShort($myDate, $Lang='th'){ if($Lang=='th'){ $myDateArray=explode(" ",$myDate); $myTime = $myDateArray[1]; $myDateArray=explode(" ",$myDate); $myDateArray=explode("-",$myDate); $myDay = sprintf("%d",$myDateArray[2]); $myMonth = sprintf("%d",$myDateArray[1]); $myYear = sprintf("%d",$myDateArray[0])+543; return($myDay . "." . $myMonth . "." . $myYear); }else{ $myDateArray=explode(" ",$myDate); $myTime = $myDateArray[1]; $myDateArray=explode(" ",$myDate); $myDateArray=explode("-",$myDate); $myDay = sprintf("%d",$myDateArray[2]); $myMonth = sprintf("%d",$myDateArray[1]); $myYear = sprintf("%d",$myDateArray[0]); return($myDay . "." . $myMonth . "." . $myYear); } } function getDateShort2($myDate, $Lang='th'){ $myDate = DateAdd(IntervalTime, $myDate); if($Lang=='th'){ $myDateArray=explode(" ",$myDate); $myTime = $myDateArray[1]; $myDateArray=explode(" ",$myDate); $myDateArray=explode("-",$myDate); $myDay = sprintf("%d",$myDateArray[2]); $myMonth = sprintf("%d",$myDateArray[1]); $myYear = sprintf("%d",$myDateArray[0])+543; return($myDay . "-" . $myMonth . "-" . $myYear); //return($myTime); }else{ $myDateArray=explode(" ",$myDate); $myTime = $myDateArray[1]; $myDateArray=explode(" ",$myDate); $myDateArray=explode("-",$myDate); $myDay = sprintf("%d",$myDateArray[2]); $myMonth = sprintf("%d",$myDateArray[1]); $myYear = sprintf("%d",$myDateArray[0]); return($myDay . "-" . $myMonth . "-" . $myYear); //return($myTime); } } function getDateMiddle($myDate, $Lang='th'){ $myDateArray=explode("-",$myDate); $myDay = sprintf("%d",$myDateArray[2]); if($Lang=='th'){ switch($myDateArray[1]) { case "01" : $myMonth = ".."; break; case "02" : $myMonth = ".."; break; case "03" : $myMonth = ".."; break; case "04" : $myMonth = ".."; break; case "05" : $myMonth = ".."; break; case "06" : $myMonth = ".."; break; case "07" : $myMonth = ".."; break; case "08" : $myMonth = ".."; break; case "09" : $myMonth = ".."; break; case "10" : $myMonth = ".."; break; case "11" : $myMonth = ".."; break; case "12" : $myMonth = ".."; break; } $myYear = sprintf("%d",$myDateArray[0])+543; return($myDay . " " . $myMonth . " " . substr($myYear,-2)); }else{ switch($myDateArray[1]) { case "01" : $myMonth = "Jan"; break; case "02" : $myMonth = "Feb"; break; case "03" : $myMonth = "Mar"; break; case "04" : $myMonth = "Apr"; break; case "05" : $myMonth = "May"; break; case "06" : $myMonth = "Jun"; break; case "07" : $myMonth = "Jul"; break; case "08" : $myMonth = "Aug"; break; case "09" : $myMonth = "Sep"; break; case "10" : $myMonth = "Oct"; break; case "11" : $myMonth = "Nov"; break; case "12" : $myMonth = "Dec"; break; } $myYear = sprintf("%d",$myDateArray[0]); return($myDay . " " . $myMonth . " " .substr($myYear,-2)); } } function getDateTime($myDate, $Lang='th'){ $myDate = DateAdd(IntervalTime, $myDate); if($Lang=='th'){ $myDateArray=explode(" ",$myDate); $myTime = $myDateArray[1]; $myDateArray=explode(" ",$myDate); $myDateArray=explode("-",$myDate); $myDay = sprintf("%d",$myDateArray[2]); $myMonth = sprintf("%d",$myDateArray[1]); $myYear = sprintf("%d",$myDateArray[0])+543; return($myDay . "-" . $myMonth . "-" . $myYear." ".$myTime); }else{ $myDateArray=explode(" ",$myDate); $myTime = $myDateArray[1]; $myDateArray=explode(" ",$myDate); $myDateArray=explode("-",$myDate); $myDay = sprintf("%d",$myDateArray[2]); $myMonth = sprintf("%d",$myDateArray[1]); $myYear = sprintf("%d",$myDateArray[0]); return($myTime.", ".$myDay . "-" . $myMonth . "-" . $myYear); } } function getTimeShort($myDate, $Lang='th'){ $date = DateAdd(IntervalTime, $myDate); $datetime = date('Y-m-d H:i:s', strtotime($date)); $datetimenow = DateAdd(IntervalTime, date("Y-m-d H:i:s")); list ( $date, $time ) = explode ( ' ', $datetime ); $time = substr( $time, 0, 5); list ( $hour, $minute, $second ) = explode (':', $time); list ($year, $month, $day) = explode ( '-', $date); list ($year2, $month2, $day2) = explode ('-', $datetimenow); if ($year == $year2 && $month == $month2 && $day == $day2){ return $hour . ':' . $minute; }elseif ($year == $year2 && $month == $month2 && $day == $day2 - 1){ return 'ҹ'; }elseif ($year == $year2 && $month == $month2 && $day == $day2 - 2){ return '2 ѹ'; }elseif ($year == $year2 && $month == $month2 && $day == $day2 - 3){ return '3 ѹ'; }else{ return getDateShort2($date." ".$hour.":".$minute.":".$second); } } function getDateTimeFull($myDate, $Lang='th'){ $date = DateAdd(IntervalTime, $myDate); $datetime = date('Y-m-d H:i:s', strtotime($date)); list ( $date, $time ) = explode ( ' ', $datetime ); $time = substr( $time, 0, 5); list ( $hour, $minute ) = explode (':', $time); $return = ', ' . $hour . ':' . $minute; list ($year, $month, $day) = explode ( '-', $date ); list ($year2, $month2, $day2) = explode (' ', date('Y m d')); if ($year == $year2 && $month == $month2 && $day == $day2){ return 'ѹ ' . $return; } if ($year == $year2 && $month == $month2 && $day == $day2 - 1){ return 'ҹ ' . $return; } if ($year == $year2 && $month == $month2 && $day == $day2 - 2){ return '2 ѹ ' . $return; } if ($year == $year2 && $month == $month2 && $day == $day2 - 3){ return '3 ѹ ' . $return; } return getDateFull($date) . ' ' . $return; } function getAge($myDate) { if($myDate != "0000-00-00"){ $myDateArray=explode(" ",$myDate); $myDate = $myDateArray[0]; $myDateArray=explode("-",$myDate); $bMonth = $myDateArray[1]; $bDay = $myDateArray[2]; $bYear = $myDateArray[0]; $cMonth = date('n'); $cDay = date('j'); $cYear = date('Y'); if(($cMonth >= $bMonth && $cDay >= $bDay) || ($cMonth > $bMonth)) { return ($cYear - $bYear); } else { return ($cYear - $bYear - 1); } }else{ return "-"; } } ############################################ function getSubject($myTable, $myID) { ############################################ global $DataBase_Name; $sql = "SELECT ".$myTable."_Subject FROM ".$myTable." WHERE ".$myTable."_ID=".(int)$myID; $Query=MYSQL_DB_QUERY($DataBase_Name,$sql) OR DIE(mysql_error()); $TotalRecord = mysql_num_rows($Query); if($TotalRecord>0){ $Row=MYSQL_FETCH_ARRAY($Query); return $Row[0]; }else{ return 0; } } ############################################ function getSubjectName($myID) { ############################################ global $DataBase_Name,$Module_Table; $sql = "SELECT * FROM $Module_Table WHERE ".$Module_Table."_ID=".(int)$myID; $Query=MYSQL_DB_QUERY($DataBase_Name,$sql) OR DIE(mysql_error()); $TotalRecord = mysql_num_rows($Query); if($TotalRecord>0){ $Row=MYSQL_FETCH_ARRAY($Query); return $Row[$Module_Table."_Subject"]; }else{ return 0; } } ############################################ function getSubject_by_lang($myTable, $myID, $lang) { ############################################ global $DataBase_Name; $sql = "SELECT ".$myTable."_Subject_".$lang." FROM ".$myTable." WHERE ".$myTable."_ID=".(int)$myID; $Query=MYSQL_DB_QUERY($DataBase_Name,$sql) OR DIE(mysql_error()); $TotalRecord = mysql_num_rows($Query); if($TotalRecord>0){ $Row=MYSQL_FETCH_ARRAY($Query); return $Row[0]; }else{ return 0; } } ############################################ function getParent($myTable, $myID) { ############################################ global $DataBase_Name; $sql = "SELECT ".$myTable."_ParentID FROM ".$myTable." WHERE ".$myTable."_ID=".(int)$myID; $Query=MYSQL_DB_QUERY($DataBase_Name,$sql) OR DIE(mysql_error()); $TotalRecord = mysql_num_rows($Query); if($TotalRecord>0){ $Row=MYSQL_FETCH_ARRAY($Query); return $Row[0]; }else{ return 0; } } ############################################ function genOptionSelect($myTable, $Lang='th', $Order='Order DESC') { ############################################ global $DataBase_Name; $sql = "SELECT * FROM ".$myTable." ORDER BY ".$myTable."_$Order"; $Query=MYSQL_DB_QUERY($DataBase_Name,$sql) OR DIE(mysql_error()); $Html = ""; while($Row=MYSQL_FETCH_ARRAY($Query)){ $Html .= '\n'; } return($Html ); } ############################################ function getOption($myTable, $myID, $Lang='th') { ############################################ global $DataBase_Name; $sql = "SELECT * FROM ".$myTable." WHERE ".$myTable."_ID=".$myID; $Query=MYSQL_DB_QUERY($DataBase_Name,$sql) OR DIE(mysql_error()); $TotalRecord = mysql_num_rows($Query); if($TotalRecord>0){ $Row=MYSQL_FETCH_ARRAY($Query); return $Row[$myTable."_Subject_".$Lang]; }else{ return "not found."; } } ############################################ function getSelectID($myTable, $myChar, $Lang='th') { ############################################ global $DataBase_Name; $sql = "SELECT ".$myTable."_ID FROM ".$myTable." WHERE ".$myTable."_Code='".trim($myChar)."'"; $Query=MYSQL_DB_QUERY($DataBase_Name,$sql) OR DIE(mysql_error()); $TotalRecord = mysql_num_rows($Query); if($TotalRecord>0){ $Row=MYSQL_FETCH_ARRAY($Query); return $Row[$myTable."_ID"]; }else{ return 0; } } ############################################ function getSelectCode($myTable, $myID, $Lang='th') { ############################################ global $DataBase_Name; $sql = "SELECT ".$myTable."_Code FROM ".$myTable." WHERE ".$myTable."_ID=".(int)$myID; $Query=MYSQL_DB_QUERY($DataBase_Name,$sql) OR DIE(mysql_error()); $TotalRecord = mysql_num_rows($Query); if($TotalRecord>0){ $Row=MYSQL_FETCH_ARRAY($Query); return $Row[$myTable."_Code"]; }else{ return 0; } } ############################################ function getLevelAdmin($myID) { ############################################ global $DataBase_Name, $System_Table_Staff; $sql = "SELECT * FROM ".$System_Table_Staff." WHERE ".$System_Table_Staff."_ID=".(int)$myID; $Query=MYSQL_DB_QUERY($DataBase_Name,$sql) OR DIE(mysql_error()); $Row=MYSQL_FETCH_ARRAY($Query); if($myID==9999){ return "Super Admin"; }else{ return $Row[$System_Table_Staff."_Level"]; } } ############################################ function getNameAdmin($myID) { ############################################ global $DataBase_Name, $System_Table_Staff; $sql = "SELECT * FROM ".$System_Table_Staff." WHERE ".$System_Table_Staff."_ID=".(int)$myID; $Query=MYSQL_DB_QUERY($DataBase_Name,$sql) OR DIE(mysql_error()); $Row=MYSQL_FETCH_ARRAY($Query); if($myID==9999){ return "Super Admin"; }else{ return $Row[$System_Table_Staff."_Name"]; } } ############################################ function getPermissionAccess($UserID, $MenuID) { ############################################ global $DataBase_Name, $System_Table_UserOnMenu; $ReccordCount =0; $sql = "SELECT * FROM ".$System_Table_UserOnMenu." WHERE ".$System_Table_UserOnMenu."_UserID=".(int)$UserID; $sql .= " AND ".$System_Table_UserOnMenu."_MenuID=".(int)$MenuID; $Query=MYSQL_DB_QUERY($DataBase_Name,$sql) OR DIE(mysql_error()); $ReccordCount = mysql_num_rows($Query); if($ReccordCount>0) { return "True"; }else{ return "False"; } } function getStatusColor($myStatus, $myString){ if($myStatus=='0'){ return ''.$myString.''; }else{ return ''.$myString.''; } } ############################################ function getMenuID($ModuleKey) { ############################################ global $DataBase_Name, $System_Table_Menu; $ReccordCount =0; $sql = "SELECT ".$System_Table_Menu."_ID FROM ".$System_Table_Menu." WHERE ".$System_Table_Menu."_ModuleKey='$ModuleKey'"; $Query=MYSQL_DB_QUERY($DataBase_Name,$sql) OR DIE(mysql_error()); $ReccordCount = mysql_num_rows($Query); if($ReccordCount>0) { $Row=MYSQL_FETCH_ARRAY($Query); return $Row[0]; }else{ return 0; } } ############################################ function getMenuName($MID, $Lang="th") { ############################################ global $DataBase_Name, $System_Table_Menu; $myArray=explode("_",$MID); $MID = (int)$myArray[1]; $ReccordCount =0; $sql = "SELECT ".$System_Table_Menu."_Name_".$Lang." FROM ".$System_Table_Menu." WHERE ".$System_Table_Menu."_ID=$MID"; $Query=MYSQL_DB_QUERY($DataBase_Name,$sql) OR DIE(mysql_error()); $ReccordCount = mysql_num_rows($Query); if($ReccordCount>0) { $Row=MYSQL_FETCH_ARRAY($Query); return $Row[0]; }else{ return 0; } } ############################################ function getMenuKey($MID) { ############################################ global $DataBase_Name, $System_Table_Menu; $ReccordCount =0; $sql = "SELECT ".$System_Table_Menu."_ModuleKey FROM ".$System_Table_Menu." WHERE ".$System_Table_Menu."_ID=$MID"; $Query=MYSQL_DB_QUERY($DataBase_Name,$sql) OR DIE(mysql_error()); $ReccordCount = mysql_num_rows($Query); if($ReccordCount>0) { $Row=MYSQL_FETCH_ARRAY($Query); return $Row[0]; }else{ return 0; } } ############################################ function CreateLog($myAction) { ############################################ global $DataBase_Name, $System_Table_Log; $sql = "INSERT INTO ".$System_Table_Log."(". $System_Table_Log."_SessionID,". $System_Table_Log."_IP,". $System_Table_Log."_Action,". $System_Table_Log."_LastUpdate) VALUES('".session_id( )."', '".$_SERVER['REMOTE_ADDR']."','".trim($myAction)."',NOW())"; $Query=MYSQL_DB_QUERY($DataBase_Name,$sql) OR DIE("$sql
".mysql_error()."
\n"); } ############################################ function getEmailAdmin($myID) { ############################################ global $DataBase_Name, $System_Table_Staff; $sql = "SELECT * FROM ".$System_Table_Staff." WHERE ".$System_Table_Staff."_ID=".(int)$myID; $Query=MYSQL_DB_QUERY($DataBase_Name,$sql) OR DIE(mysql_error()); $Row=MYSQL_FETCH_ARRAY($Query); return $Row[$System_Table_Staff."_Email"]; } function setObjectWH($mSrc, $mW="320", $mH="240"){ $pattern = "/width=\"[0-9]*\"/"; $content = preg_replace($pattern, 'width="'.$mW.'"', $mSrc); $pattern = "/height=\"[0-9]*\"/"; $content = preg_replace($pattern, 'height="'.$mH.'"', $content); $pattern = "/width=\'[0-9]*\'/"; $content = preg_replace($pattern, "width='".$mW."'", $content); $pattern = "/height=\'[0-9]*\'/"; $content = preg_replace($pattern, "height='".$mH."'", $content); return $content; } ############################################ function getFirstID($myTable) { ############################################ global $DataBase_Name; $sql = "SELECT ".$myTable."_ID FROM ".$myTable." WHERE ".$myTable."_Status='1' ORDER BY ".$myTable."_Order DESC "; $Query=MYSQL_DB_QUERY($DataBase_Name,$sql) OR DIE(mysql_error()); $TotalRecord = mysql_num_rows($Query); if($TotalRecord>0){ $Row=MYSQL_FETCH_ARRAY($Query); return $Row[0]; }else{ return 0; } } ############################################ function getMember($Object="Username", $myID) { ############################################ global $DataBase_Name, $System_Home, $System_Path_Upload ; $Module_Table = 'tz_mod_member'; $Module_Path_Member = $System_Home.$System_Path_Upload ."/member/photo"; //$Module_Path_Member = "upload/member/picture"; $RecordCount=0; $sql = "SELECT * FROM ".$Module_Table." WHERE ".$Module_Table."_ID=".(int)$myID; $Query=MYSQL_DB_QUERY($DataBase_Name,$sql) OR DIE(mysql_error()); $RecordCount = MYSQL_NUM_ROWS($Query); if($RecordCount>0){ $Row=MYSQL_FETCH_ARRAY($Query); /* $_SESSION["session_Picture"]=$Row[$Module_Table."_PictureFile"]; $_SESSION["session_MemberLevel"] = $Row[$Module_Table."_Status"]; $_SESSION["session_ExpireDate"] = $Row[$Module_Table."_ExpireDate"]; */ switch($Object) { case "Username" : return $Row[$Module_Table."_Username"]; break; case "Name" : return $Row[$Module_Table."_Name"]; break; case "Level" : return $Row[$Module_Table."_Status"]; break; case "Email" : return $Row[$Module_Table."_Email"]; break; case "DisplaySmall" : if($Row[$Module_Table."_PictureFile"]==""){ return "images/blank-user.jpg"; }else{ return $Module_Path_Member ."/thm-".$Row[$Module_Table."_PictureFile"]; } break; case "DisplayNormal" : if($Row[$Module_Table."_PictureFile"]==""){ return "images/blank-user.jpg"; }else{ return $Module_Path_Member ."/".$Row[$Module_Table."_PictureFile"]; } break; default: return $Row[$Module_Table."_Name"]; break; } }else{ return ''; } } ############################################ function countLableMember($myTable, $myID) { ############################################ global $DataBase_Name; $sql = "SELECT ".$myTable."_ID FROM ".$myTable." WHERE ".$myTable."_LabelID=".(int)$myID; $Query=MYSQL_DB_QUERY($DataBase_Name,$sql) OR DIE(mysql_error()); $TotalRecord = mysql_num_rows($Query); if($TotalRecord>0){ $Row=MYSQL_FETCH_ARRAY($Query); return $TotalRecord; }else{ return 0; } } ############################################ function CountPageView($myTable, $myID) { ############################################ global $DataBase_Name; $sql = "UPDATE ".$myTable." SET ".$myTable."_View=".$myTable."_View+1 WHERE ".$myTable."_ID=".(int)$myID; $Query=MYSQL_DB_QUERY($DataBase_Name,$sql) OR DIE(mysql_error()); } ############################################ function CountDownload($myTable, $myID) { ############################################ global $DataBase_Name; $sql = "UPDATE ".$myTable." SET ".$myTable."_DLCount=".$myTable."_DLCount+1 WHERE ".$myTable."_ID=".(int)$myID; $Query=MYSQL_DB_QUERY($DataBase_Name,$sql) OR DIE(mysql_error()); } ############################################ function CountComment($myTable, $myID) { ############################################ global $DataBase_Name; $sql = "UPDATE ".$myTable." SET ".$myTable."_Comment=".$myTable."_Comment+1 WHERE ".$myTable."_ID=".(int)$myID; $Query=MYSQL_DB_QUERY($DataBase_Name,$sql) OR DIE(mysql_error()); } ############################################ function CountItem($myTable, $myID) { ############################################ global $DataBase_Name; $sql = "SELECT ".$myTable."_ID FROM ".$myTable." WHERE ".$myTable."_GroupID=".(int)$myID; $Query=MYSQL_DB_QUERY($DataBase_Name,$sql) OR DIE(mysql_error()); $TotalRecord = mysql_num_rows($Query); if($TotalRecord>0){ $Row=MYSQL_FETCH_ARRAY($Query); return $TotalRecord; }else{ return 0; } } function checkUserInfo($UID){ if(trim($_SESSION["session_Picture"])==""){ //echo $_SESSION["session_Picture"]; echo ''; }elseif(trim($_SESSION["session_IDCard"])==""){ //echo $_SESSION["session_IDCard"]; echo ''; } } ############################################ function getTag() { ############################################ global $DataBase_Name, $System_Table_Tag; $sql = "SELECT ".$System_Table_Tag."_Name FROM ".$System_Table_Tag; $Query=MYSQL_DB_QUERY($DataBase_Name,$sql) OR DIE(mysql_error()); $mTag=""; while($Row=MYSQL_FETCH_ARRAY($Query)){ $mTag .= $Row[0].","; } $mTag = substr($mTag, 0, -1); return $mTag ; } ############################################ function getGroup($myID) { ############################################ global $DataBase_Name,$Module_Table_Group; $sql = "SELECT * FROM $Module_Table_Group WHERE ".$Module_Table_Group."_ID=".(int)$myID; $Query=MYSQL_DB_QUERY($DataBase_Name,$sql) OR DIE(mysql_error()); $TotalRecord = mysql_num_rows($Query); if($TotalRecord>0){ $Row=MYSQL_FETCH_ARRAY($Query); return $Row[$Module_Table_Group."_Subject"]; }else{ return 0; } } ############################################ function getGroupPicture($myID) { ############################################ global $DataBase_Name,$Module_Table_Group; $sql = "SELECT ".$Module_Table_Group."_Feature FROM $Module_Table_Group WHERE ".$Module_Table_Group."_ID=".(int)$myID; $Query=MYSQL_DB_QUERY($DataBase_Name,$sql) OR DIE(mysql_error()); $TotalRecord = mysql_num_rows($Query); if($TotalRecord>0){ $Row=MYSQL_FETCH_ARRAY($Query); return $Row[$Module_Table_Group."_Feature"]; }else{ return ''; } } function generate_calendar($year, $month, $days = array(), $day_name_length = 3, $month_href = NULL, $first_day = 0, $pn = array() , $Lang = "th", $Style = "s"){ if($Lang=="th"){ $month_name_short = array("..", "..", "..", "..", "..", "..", "..", "..", "..", "..", "..", ".."); $day_name_short = array(".", ".", ".", ".", ".", ".", "."); $month_name = array("Ҥ", "Ҿѹ", "չҤ", "¹", "Ҥ", "Զع¹", "áҤ", "ԧҤ", "ѹ¹", "Ҥ", "Ȩԡ¹", "ѹҤ"); $day_name = array("ҷԵ", "ѹ", "ѧ", "ظ", "ʺ", "ء", ""); $thyear = 543; }else{ $month_name_short = array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); $day_name_short = array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"); $month_name = array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); $day_name = array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"); $thyear = 0; } $first_of_month = gmmktime(0,0,0,$month,1,$year); $day_names = array(); #generate all the day names according to the current locale for($n=0,$t=(3+$first_day)*86400; $n<7; $n++,$t+=86400) #January 4, 1970 was a Sunday $day_names[$n] = $day_name_short[$n]; //ucfirst(gmstrftime('%A',$t)); #%A means full textual day name list($month, $year, $month_names, $weekday) = explode(',',gmstrftime('%m,%Y,%B,%w',$first_of_month)); $weekday = ($weekday + 7 - $first_day) % 7; #adjust for $first_day $title = $month_name[(int)$month-1].' '.($year+$thyear); #note that some locales don't capitalize month and day names #Begin calendar. Uses a real . See http://diveintomark.org/archives/2002/07/03 @list($p, $pl) = each($pn); @list($n, $nl) = each($pn); #previous and next links, if applicable if($p) $p = ''.($pl ? ''.$p.'' : $p).' '; if($n) $n = ' '.($nl ? ''.$n.'' : $n).''; $calendar = ''."\n". '\n"; if($day_name_length){ #if the day names should be shown ($day_name_length > 0) #if day_name_length is >3, the full name of the day will be printed foreach($day_names as $d) $calendar .= ''; $calendar .= "\n"; } if($weekday > 0) $calendar .= ''; #initial 'empty' days for($day=1,$days_in_month=gmdate('t',$first_of_month); $day<=$days_in_month; $day++,$weekday++){ if($weekday == 7){ $weekday = 0; #start a new week $calendar .= "\n"; } if(isset($days[$day]) and is_array($days[$day])){ @list($link, $classes, $content) = $days[$day]; if(is_null($content)) $content = $day; $calendar .= '' : '>'). ($link ? ''.$content.'' : $content).''; } else $calendar .= ""; } if($weekday != 7) $calendar .= ''; #remaining "empty" days return $calendar."\n
'.$p.($month_href ? ''.$title.'' : $title).$n."
'.($day_name_length < 4 ? substr($d,0,$day_name_length) : $d).'
 
$day 
\n"; } ############################################ function getGroupName($myTable,$myID) { ############################################ global $DataBase_Name; $sql = "SELECT * FROM ".$myTable." WHERE ".$myTable."_ID=".$myID; $Query=MYSQL_DB_QUERY($DataBase_Name,$sql) OR DIE(mysql_error()); $TotalRecord = mysql_num_rows($Query); if($TotalRecord>0){ $Row=MYSQL_FETCH_ARRAY($Query); return $Row[$myTable."_Subject"]; }else{ return ""; } } function set_date_input($value_date, $type=1) { if($value_date !='' && $value_date !='0000-00-00 00:00:00') { //for add edit if($type==1){ list($d, $m, $y) = explode("-", $value_date); return $y.'-'.$m.'-'.$d; //for view }elseif($type==2){ list($date, $time) = explode(" ", $value_date); list($y, $m, $d) = explode("-", $date); return $d.'-'.$m.'-'.$y; } } } ############################################ function countMember($myTable, $myID) { ############################################ global $DataBase_Name; $sql = "SELECT ".$myTable."_ID FROM ".$myTable." WHERE ".$myTable."_GalleryID=".(int)$myID; $Query=MYSQL_DB_QUERY($DataBase_Name,$sql) OR DIE(mysql_error()); $TotalRecord = mysql_num_rows($Query); if($TotalRecord>0){ $Row=MYSQL_FETCH_ARRAY($Query); return $TotalRecord; }else{ return 0; } } ############################################ function char_limiter($var,$num) ############################################ { if (mb_strlen($var, "UTF-8") >= $num) { $result = mb_substr($var,0,$num, "UTF-8").'..'; } else { $result = $var; } return $result; } ############################################ function getGroupInfo($myTable,$myID) { ############################################ global $DataBase_Name; $sql = "SELECT ".$myTable."_ID, ".$myTable."_Subject, ".$myTable."_Link FROM ".$myTable." WHERE ".$myTable."_ID=".$myID; $Query=MYSQL_DB_QUERY($DataBase_Name,$sql) OR DIE(mysql_error()); $TotalRecord = mysql_num_rows($Query); if($TotalRecord>0){ $Row=MYSQL_FETCH_ARRAY($Query); return $Row[$myTable."_ID"]."@".$Row[$myTable."_Subject"]."@".$Row[$myTable."_Link"]; }else{ return ""; } } ############################################ function get_navigator($myTable, $menu_id, $n=0) { ############################################ global $DataBase_Name; $sql = "SELECT * FROM ".$myTable." WHERE ".$myTable."_ID=".(int)$menu_id; $children=MYSQL_DB_QUERY($DataBase_Name,$sql) OR DIE(mysql_error()); $items = array(); $n = $n+1; while($row = MYSQL_FETCH_ARRAY($children)) { if($n==1){ $items[] = get_navigator($myTable, $row[$myTable."_ParentID"], $n).' / '.$row[$myTable."_Subject"].' '; }else{ $items[] = ' '.get_navigator($myTable, $row[$myTable."_ParentID"], $n).' / '.$row[$myTable."_Subject"].''; } } if(count($items)) { return implode('', $items); } else { return ''; } } ############################################ function get_rootgroup($myTable, $menu_id, $html ) { ############################################ global $DataBase_Name; $sql = "SELECT * FROM ".$myTable." WHERE ".$myTable."_ID=".(int)$menu_id; $children=MYSQL_DB_QUERY($DataBase_Name,$sql) OR DIE(mysql_error()); $items = array(); while($row = MYSQL_FETCH_ARRAY($children)) { if($row[$myTable."_ParentID"]>0){ $html = getGroupInfo($myTable."_group", $row[$myTable."_GroupID"]); get_rootgroup($myTable, $row[$myTable."_ParentID"], $html); }else{ $html = getGroupInfo($myTable."_group", $row[$myTable."_GroupID"]); } } return $html; } ############################################ function get_firstmenu($myTable, $group_id) { ############################################ global $DataBase_Name; $sql = "SELECT * FROM ".$myTable." WHERE ".$myTable."_GroupID=".(int)$group_id; $sql .= " ORDER BY ".$myTable."_Order ASC LIMIT 0,1"; $Query=MYSQL_DB_QUERY($DataBase_Name,$sql) OR DIE(mysql_error()); $Row = MYSQL_FETCH_ARRAY($Query); if(trim($Row[$myTable."_Type"])=="Page"){ return $Row[$myTable."_ID"]."@".$Row[$myTable."_Type"]."@".$Row[$myTable."_Page"]; } if(trim($Row[$myTable."_Type"])=="Module"){ return $Row[$myTable."_ID"]."@".$Row[$myTable."_Type"]."@".$Row[$myTable."_Module"]; } if(trim($Row[$myTable."_Type"])=="URL"){ return $Row[$myTable."_ID"]."@".$Row[$myTable."_Type"]."@".$Row[$myTable."_Link"]."@".$Row[$myTable."_Target"]; } } ############################################ function FriendlyURL($var) { ############################################ $var = trim($var); $var = preg_replace('/\s+/', ' ', $var); $var = preg_replace('/\s+/', '-', $var); #ŧ Space - return $var; } ?> array("th" =>"","en" =>"Disable"), 1 => array("th"=>"","en" =>"Enable"), ); ?>You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE _Status<>'0' AND _ModuleKey='projects' AND _Language = 'en' ORDER BY _O' at line 1