"; if($i==$cPage)echo " "; echo $i." "; if($i==$cPage)echo ""; echo " "; } } ################################################ function clearMailBoxData($MemID,$boxID){ $query="UPDATE IGNORE tbl_mailbox SET member_id = '' , box_status='empty' WHERE member_id = '".$MemID."' AND id = '".$boxID."' "; mysql_query($query); $query="UPDATE IGNORE tbl_member SET userStatus='new' WHERE id = '".$MemID."' "; mysql_query($query); $query="SELECT * FROM `tbl_mail_data` WHERE memID= '".$MemID."' "; $result =mysql_query($query); while($data=mysql_fetch_assoc($result)){ if($data['mailPicuture']!=''){ @unlink("../uploadfile/thb/".$data['mailPicuture']); } if($data['mailPicuture']!=''){ @unlink("../uploadfile/".$data['mailPicuture']); } //----------------------dell po------------------- $query="DELETE IGNORE FROM tbl_mailpo_number WHERE mailID='".$data['id']."' "; mysql_query($query); $query="SELECT * FROM tbl_mailpo_data WHERE mailID = '".$data['id']."' "; $result2=mysql_query($query); while($file=mysql_fetch_assoc($result2)){ if($file['fileUpload']!=''){ @unlink("../uploadfile/".$file['fileUpload']); } } $query="DELETE IGNORE FROM tbl_mailpo_data WHERE mailID='".$data['id']."'"; mysql_query($query); } $query="DELETE IGNORE FROM `tbl_mail_data` WHERE memID= '".$MemID."' "; mysql_query($query); } ################################################ function GetNewFileName($uploadFile,&$uploadFileName,$fileExt){ $info = pathinfo($uploadFileName); $dayFile=date("YmdHis"); $uploadFileName = $fileExt.$dayFile.".".$info[extension]; $fileExt=$info[extension]; } ################################################ function getID($numID){ $PrintID= strlen($numID); if($PrintID==1){ echo "00".$numID; } if($PrintID==2){ echo "0".$numID; } if($PrintID==3){ echo "".$numID; } } ################################################ function ArrangeDateThai($date){ $DateArray = explode("-",$date); $DateArray[0]=$DateArray[0]+543; echo $DateArray[2]."-".$DateArray[1]."-".$DateArray[0]; } ################################################ function ArrangeDateEng($date){ $DateArray = explode("-",$date); echo $DateArray[2]."-".$DateArray[1]."-".$DateArray[0]; } ################################################ function DisplayNumberFormat($num){ $priceArray = explode(".",$num); if($priceArray[1]==""){ $priceArray[1]="00";} echo number_format($priceArray[0]).".".$priceArray[1]; } ################################################ function CheckService($MailID){ $query="SELECT COUNT(id) NumService FROM tbl_mailpo_data WHERE mailID = '".$MailID."' "; $result=mysql_query($query); $data=mysql_fetch_assoc($result); if($data['NumService'] > 0 ){ echo "View "; }else{ echo "-"; } } ################################################ function sumPoSevice($poID){ $query="SELECT SUM(totalUnit*rate) totalPrice FROM tbl_mailpo_data WHERE mailID='".$poID."' "; $result=mysql_query($query); $data=mysql_fetch_assoc($result); DisplayNumberFormat($data['totalPrice']); } ################################################ function CountDataInCategory($cateID){ $query="SELECT COUNT(id) NumID FROM tbl_home_reserv WHERE home_code_id='".$cateID."' "; $result=mysql_query($query); $data=mysql_fetch_assoc($result); echo $data['NumID']; } ################################################ function CountDataInCategory2($cateID){ $query="SELECT COUNT(id) NumID FROM tbl_product_data WHERE MainGroup='".$cateID."' "; $result=mysql_query($query); $data=mysql_fetch_assoc($result); echo $data['NumID']; } ################################################ function create_thub($impath,$img,$fix_width,$fix_height){ $source = $impath.$img; $cache_dir =$impath."thb/"; $tsrc=$impath."thb/".$img; $imgType = substr($img,-3,3); $days = 1; //---- make scale width and height $imgsize = @getImageSize($source); $x_ratio = $fix_width / $imgsize[0]; $y_ratio = $fix_height / $imgsize[1]; //IF width and high < MAX if ( ($imgsize[0] <= $max_x) && ($imgsize[1] <= $max_y) ) { $new_x = $imgsize[0]; $new_y = $imgsize[1]; } else if ( ($x_ratio * $imgsize[1]) < $fix_height){ $new_x = $fix_width; $new_y = ceil($x_ratio * $imgsize[1]); } else { $new_x = ceil($y_ratio * $imgsize[0]); $new_y = $fix_height; } $n_width=$new_x; $n_height=$new_y; //----start make thumb------ //----start make thumb------ if(($imgType=='jpg')||($imgType=='JPG')){ $im=ImageCreateFromJPEG($source); $width=ImageSx($im); // Original picture width is stored $height=ImageSy($im); // Original picture height is stored $newimage=imagecreatetruecolor($n_width,$n_height); //imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height); imagecopyresampled($newimage, $im, 0, 0, 0, 0, $n_width,$n_height,$width,$height); ImageJpeg($newimage,$tsrc); }else if(($imgType=='gif')||($imgType=='GIF')){ $im=ImageCreateFromGIF($source); $width=ImageSx($im); // Original picture width is stored $height=ImageSy($im); // Original picture height is stored $newimage=imagecreatetruecolor($n_width,$n_height); //imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height); imagecopyresampled($newimage, $im, 0, 0, 0, 0, $n_width,$n_height,$width,$height); if (function_exists("imagegif")) { //Header("Content-type: image/gif"); ImageGIF($newimage,$tsrc); } elseif (function_exists("imagejpeg")) { //Header("Content-type: image/jpeg"); ImageJPEG($newimage,$tsrc); } }else if(($imgType=='png')||($imgType=='PNG')){ $im = @imagecreatefrompng($source); $width=ImageSx($im); // Original picture width is stored $height=ImageSy($im); // Original picture height is stored $newimage=imagecreatetruecolor($n_width,$n_height); //imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height); imagecopyresampled($newimage, $im, 0, 0, 0, 0, $n_width,$n_height,$width,$height); imagepng($newimage,$tsrc); } //---------------Clear cache-------------------------------------- if($dp = @opendir($cache_dir)) { while($file = readdir($dp)) { if(preg_match('/^img_/', $file)) { $mtime = @filemtime("$cache_dir/$file"); if($mtime < time() - 3600 * 24 * $days) @unlink("$cache_dir/$file"); } } closedir($dp); } } ################################################ function create_thub2($impath,$img,$fix_width,$fix_height){ $source = $impath.$img; $cache_dir =$impath."tempx/"; $tsrc=$impath."tempx/".$img; $imgType = substr($img,-3,3); $days = 1; //---- make scale width and height $imgsize = @getImageSize($source); $x_ratio = $fix_width / $imgsize[0]; $y_ratio = $fix_height / $imgsize[1]; //IF width and high < MAX if ( ($imgsize[0] <= $max_x) && ($imgsize[1] <= $max_y) ) { $new_x = $imgsize[0]; $new_y = $imgsize[1]; } else if ( ($x_ratio * $imgsize[1]) < $fix_height){ $new_x = $fix_width; $new_y = ceil($x_ratio * $imgsize[1]); } else { $new_x = ceil($y_ratio * $imgsize[0]); $new_y = $fix_height; } $n_width=$new_x; $n_height=$new_y; //----start make thumb------ //----start make thumb------ if(($imgType=='jpg')||($imgType=='JPG')){ $im=ImageCreateFromJPEG($source); $width=ImageSx($im); // Original picture width is stored $height=ImageSy($im); // Original picture height is stored $newimage=imagecreatetruecolor($n_width,$n_height); //imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height); imagecopyresampled($newimage, $im, 0, 0, 0, 0, $n_width,$n_height,$width,$height); ImageJpeg($newimage,$tsrc); }else if(($imgType=='gif')||($imgType=='GIF')){ $im=ImageCreateFromGIF($source); $width=ImageSx($im); // Original picture width is stored $height=ImageSy($im); // Original picture height is stored $newimage=imagecreatetruecolor($n_width,$n_height); //imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height); imagecopyresampled($newimage, $im, 0, 0, 0, 0, $n_width,$n_height,$width,$height); if (function_exists("imagegif")) { //Header("Content-type: image/gif"); ImageGIF($newimage,$tsrc); } elseif (function_exists("imagejpeg")) { //Header("Content-type: image/jpeg"); ImageJPEG($newimage,$tsrc); } }else if(($imgType=='png')||($imgType=='PNG')){ $im = @imagecreatefrompng($source); $width=ImageSx($im); // Original picture width is stored $height=ImageSy($im); // Original picture height is stored $newimage=imagecreatetruecolor($n_width,$n_height); //imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height); imagecopyresampled($newimage, $im, 0, 0, 0, 0, $n_width,$n_height,$width,$height); imagepng($newimage,$tsrc); } //---------------Clear cache-------------------------------------- if($dp = @opendir($cache_dir)) { while($file = readdir($dp)) { if(preg_match('/^img_/', $file)) { $mtime = @filemtime("$cache_dir/$file"); if($mtime < time() - 3600 * 24 * $days) @unlink("$cache_dir/$file"); } } closedir($dp); } } ############################################### function ShowNewHotSale($product_status){ if($product_status==1){ $imageShow=""; } if($product_status==2){ $imageShow=""; } if($product_status==3){ $imageShow=""; } if($product_status==4){ $imageShow=""; } echo $imageShow; } ############################################### function getFirstImage($productID,&$FirstImageName){ $query="SELECT * FROM tbl_product_img WHERE product_ID= '".$productID."' ORDER BY id DESC "; $result=mysql_query($query); $data=mysql_fetch_assoc($result); $FirstImageName=$data['file_name']; return $FirstImageName; } ############################################### function checkBox($codeID, $homeID){ if($homeID) { $query="SELECT COUNT(home_code_id) Num FROM tbl_home_data_code WHERE home_code_id='".$codeID."' AND home_id= '".$homeID."' "; $result=mysql_query($query); $data=mysql_fetch_assoc($result); if($data['Num'] =='1') { echo "checked";} } } ################################################ function GetNewIcon($day,$icon){ $today = date("Y-m-d"); $dateDiff = ( strtotime($today) - strtotime($day) ) / ( 60 * 60 * 24 ); if($dateDiff < 7){ echo $icon; } } ################################################ function GetThaiDate2($day){ $dateArray = explode("-",$day); $date= $dateArray[2]; $mon= $dateArray[1]; $year= $dateArray[0]+543; $monthArray = array("01"=>"มกราคม","02"=>"กุมภาพันธ์","03"=>"มีนาคม","04"=>"เมษายน", "05"=>"พฤษภาคม","06"=>"มิถุนายน","07"=>"กรกฏาคม","08"=>"สิงหาคม","09"=>"กันยายน","10"=>"ตุลาคม","11"=>"พฤศจิกายน","12"=>"ธันวาคม"); if($date < 10){ $date = str_replace("0", "", $date); } echo $date."/".$mon."/".$year; } ?>