Menu

Login

Username
Password
 

จำนวนบุคลากร

',"\\(","\\)","'","eval\\((.*)\\)","[\\\"\\\'][\\s]*javascript:(.*)[\\\"\\\']") ; $place = array('<','>',"(",")","'","","\"\"") ; $str2 = str_replace($regx,$place , $str) ; return $str2; } function thai_utf8($str) { if(function_exists('iconv')) { $out = iconv( 'TIS-620','UTF-8',$str) ; } else { for ($i = 0; $i < strlen($str); $i++) $out .= ord($str[$i]) <= 126 ? $str[$i] : "&#" . (ord($str[$i]) - 161 + 3585) . ";"; } return $out; } function utf8_thai($str) { $res = ""; if(function_exists('iconv')) { $res = iconv('UTF-8', 'TIS-620',$str) ; } else { $strlens = strlen($str) ; for ($i = 0; $i < $strlens ; $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 ThaiDate() { global $ThDay ,$ThMonth ; $a=date("w"); $b=date("n")-1; $c=date("j"); $d=date("Y")+543; return "วัน$ThDay[$a] ที่ $c เดือน $ThMonth[$b] พ.ศ. $d"; } function list_select($name,$sql,$value,$list,$select,$first_list,$type='list',$return='',$max_len=100) { // name , sql ,field value ,field list , select value , list ,radio if($name !='' && $sql !=''){ $db1 = new Mysqldb() ; $db1->sql = $sql ; $db1->selectquery() ; echo mysql_error() ; switch($type) { case 'list' : echo ' ' ; break ; case 'radio' : if ($db1->numrows > 0 ){ reset($db1->row) ; while(list($x,$y) = each($db1->row)){ echo '' ,$y[$list]," " ; } } break ; } } } function tep_image($src, $alt = '', $width = '', $height = '', $parameters = '') { if ( empty($src) || ! file_exists($src) || ! is_file($src) ) { return false; } $image = '' . tep_output_string($alt) . ' $image_size[0] ) { $width = $image_size[0]; } if ($height =='' ) { $height = $image_size[1]; } if ($height > $image_size[1]) { $height = $image_size[1]; } $ratio = $image_size[0] / $image_size[1]; if ( $ratio > 1 ) { $height = ( $width/$image_size[0] ) * $image_size[1] ; } else{ $width = ( $height /$image_size[1]) * $image_size[0] ; } } if ( $width !='' && $height !='' ) { $image .= ' width="' . tep_output_string($width) . '" height="' . tep_output_string($height) . '"'; } if (tep_not_null($parameters)) $image .= ' ' . $parameters; $image .= '>'; return $image; } function tep_parse_input_field_data($data, $parse) { return strtr(trim($data), $parse); } function tep_output_string($string, $translate = false, $protected = false) { if ($protected == true) { return htmlspecialchars($string); } else { if ($translate == false) { return tep_parse_input_field_data($string, array('"' => '"')); } else { return tep_parse_input_field_data($string, $translate); } } } function tep_not_null($value) { if (is_array($value)) { if (sizeof($value) > 0) { return true; } else { return false; } } else { if ( (is_string($value) || is_int($value)) && ($value != '') && ($value != 'NULL') && (strlen(trim($value)) > 0)) { return true; } else { return false; } } } function printpage($page,$totalpage,$paramiter =''){ global $gotarget,$target ; $page =(( $page == 0)?1:$page) ; $n = $page + 1 ; $p = $page - 1 ; $gotarget = (($target !='')?" target='".$target."'":"") ; $first = (($page != 1 && $totalpage > 1)?"First" :"First") ; $last = (($page != $totalpage && $totalpage !=0)?"Last" :"Last") ; $next = (( $n <= $totalpage)?"Next" :"Next") ; $prev = (( $p >= 1)?"Prev" :"Prev") ; $totalpage =(( $totalpage == 0)?1:$totalpage) ; $body = '
 PAGE '.$page.' / '.$totalpage.' |  '.$first.' |  '.$prev.' |  '.$next.' |  '.$last.' |
' ; return $body; } //************************************************************* function array_select($name,$array,$select=0,$type,$return ='',$first_list ='') { // , list ,radio if($name !='' && is_array($array) !=''){ switch($type) { case 'list' : echo ' ' ; break ; case 'radio' : while(list($x,$y) = each($array)) { echo '' ,$y," " ; } break ; } } } function dis_msg($msg,$error){ if($error *1 == 0 ){ $dis_msg = tep_image('images/error.gif', '','','','align="absmiddle"') .' '. $msg .'' ; } else{ $dis_msg = tep_image('images/success.gif', '','','','align="absmiddle"') . $msg ; } return '
'. $dis_msg .'
' ; } function mkpath($path) { $mode = 0 ; $dirs = explode("/",$path); $path = $dirs[0]; for($i = 1;$i < count($dirs);$i++) { $path .= "/".$dirs[$i]; if(!is_dir($path)) mkdir($path,0777); //mkdir($path); } } function totalpage($NRow=1 ,$list_page=1){ if($NRow !=0 && $list_page !=0){ $rt = $NRow%$list_page; if($rt !=0) { $totalpage = floor($NRow/$list_page)+1; } else { $totalpage = floor($NRow/$list_page); } } else { $totalpage = 0 ; } return $totalpage ; } function getfilesize($bytes) { if ($bytes >= 1099511627776) { $return = round($bytes / 1024 / 1024 / 1024 / 1024, 2); $suffix = "tb"; } elseif ($bytes >= 1073741824) { $return = round($bytes / 1024 / 1024 / 1024, 2); $suffix = "gb"; } elseif ($bytes >= 1048576) { $return = round($bytes / 1024 / 1024, 2); $suffix = "mb"; } elseif ($bytes >= 1024) { $return = round($bytes / 1024, 2); $suffix = "kb"; } else { $return = $bytes; $suffix = "b"; } if ($return == 1) { $return .= " " . $suffix; } else { $return .= " " . $suffix . "s"; } return $return; } function deldir($dir){ if($dir != '' && is_dir($dir) ){ $current_dir = opendir($dir); while($entryname = readdir($current_dir)){ if(is_dir("$dir/$entryname") && ($entryname != "." and $entryname!="..")){ deldir("${dir}/${entryname}"); }elseif($entryname != "." && $entryname!=".."){ unlink("${dir}/${entryname}"); } } closedir($current_dir); rmdir(${dir}); } } function type_file($file ,$name='' ) { if($file !=''){ $ch_type_pic = explode('.',$file) ; if($name !=''){ return $type_file = $name .'.' . $ch_type_pic[count($ch_type_pic)-1] ; } else{ return $type_file = $ch_type_pic[count($ch_type_pic)-1] ; } } } function file_exist($path) { if($path != '' && file_exists($path) && is_file($path) ){ return true ; } else{ return false ; } } function show_date($date){ // เวลา timestamp global $ThMonth ; if($date !=0){ $d = date('d',strtotime($date))*1 ; $m = date('m',strtotime($date))*1 ; $m = $ThMonth[$m -1] ; $y = date('Y',strtotime($date)) *1 + 543 ; return $ss =$d . " ". $m ." " . $y ; } else{ return '-' ; } } function day_display($start,$end) { global $shot_month ; $d = date('d',strtotime($start))*1 ; $m = date('m',strtotime($start))*1 ; $m = $shot_month[$m -1] ; $y = date('Y',strtotime($start)) *1 + 543 ; $d2 = date('d',strtotime($end)) *1; $m2 = date('m',strtotime($end))*1 ; $m2 = $shot_month[$m2 -1] ; $y2 = date('Y',strtotime($end)) *1 + 543 ; if($m == $m2 && $y == $y2 ) { if($d == $d2) { $msg = $d . " " .$m . " " .$y ; } else { $msg = $d . " - " .$d2 . " " .$m . " " .$y ; } } else { $msg = $d . " " .$m . " " .$y . " - " .$d2 . " " .$m2 . " " .$y2 ; } return $msg ; } function del_file($pic) { $path = $pic ; if(file_exist($path) ){ unlink($path) ; } } function str_input($str){ return htmlspecialchars($str) ; } function str_msg($str,$num=0){ if($str != ""){ if($num==1){ $str = number_format($str, 2, '.', ',') ; } else{ $str = str_input($str) ; $str = eregi_replace("([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])","\\1://\\2\\3",$str); $str = eregi_replace("\[q\](.*)\[/q\]",'"\\1"',$str) ; $str = eregi_replace("\[b\](.*)\[/b\]",'\\1',$str) ; $str = nl2br($str) ; } return $str ; } else{ return " - " ; } } ?>host; } function sethost($req_host) { $this->host = $req_host; } function getdb() { return $this->db; } function setdb($req_db) { $this->db = $req_db; } function getdbuser() { return $this->dbuser; } function setdbuser($req_user) { $this->dbuser = $req_user; } function getdbpassword() { return $this->dbpassword; } function setdbpassword($req_password) { $this->dbpassword = $req_password; } function getsql() { return $this->sql; } function setsql($req_sql) { $this->sql = $req_sql; } function getnumrows() { return $this->numrows; } function setnumrows($req_numberresults) { $this->numberesults = $req_numberresults; } function setdbconnect($req_dbconnect) { $this->dbconnect = $req_dbconnect; } function getdbconnect() { return $this->dbconnect; } // Constructor function Mysqldb() { global $host, $db, $dbuser, $pass_db; global $TRUE, $FALSE; $this->sethost($host); $this->setdb($db); $this->setdbuser($dbuser); $this->setdbpassword($pass_db); $this->setdbconnect($FALSE); } // Methods function opendbconnect() { global $TRUE, $FALSE; $this->dbconnect = mysql_connect($this->host, $this->dbuser, $this->dbpassword); if ($this->dbconnect == $TRUE) { $this->setdbconnect($TRUE); } else { $this->setdbconnect($FALSE); return false; } return true; } function closedbconnect() { if ($this->dbconnect = $TRUE) { mysql_close($this->dbconnect); } } function selectquery() { global $TRUE, $FALSE; if ($this->dbconnect == $FALSE) { $this->opendbconnect(); } $this->rs = mysql_db_query($this->db,$this->sql); if ($this->rs) { $this->row = '' ; $this->numrows = mysql_num_rows($this->rs); if (mysql_num_rows($this->rs) > 0) { for($x = 0; $x < $this->numrows; $x++) { $this->row[$x] = mysql_fetch_array($this->rs); } } return true; } else { return false; } } function query() { global $TRUE, $FALSE; if ($this->dbconnect == $FALSE) { $this->opendbconnect(); } $this->rs = mysql_db_query($this->db,$this->sql); return $this->rs ; } } ///// end class // last update 17/04/50 ?>No Connection Database