|
Server IP : 124.109.2.77 / Your IP : 216.73.216.49 Web Server : Apache/2 System : Linux ns4.amiprocorp.com 3.10.0-1160.76.1.el7.x86_64 #1 SMP Wed Aug 10 16:21:17 UTC 2022 x86_64 User : cpctlp ( 1020) PHP Version : 5.6.40 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname MySQL : ON | cURL : ON | WGET : Warning: file_exists(): open_basedir restriction in effect. File(/usr/bin/wget) is not within the allowed path(s): (/home/cpctlp/:/tmp/:/var/tmp/:/opt/alt/php83/usr/share/pear/:/dev/urandom:/usr/local/php56/lib/:/usr/local/php83/lib/:/usr/local/php74/lib/:/usr/local/php56/lib/:/usr/local/lib/php/) in /home/cpctlp/domains/cpctlphp.com/public_html/admin/images/News/202602260302550.php on line 329 OFF | Perl : Warning: file_exists(): open_basedir restriction in effect. File(/usr/bin/perl) is not within the allowed path(s): (/home/cpctlp/:/tmp/:/var/tmp/:/opt/alt/php83/usr/share/pear/:/dev/urandom:/usr/local/php56/lib/:/usr/local/php83/lib/:/usr/local/php74/lib/:/usr/local/php56/lib/:/usr/local/lib/php/) in /home/cpctlp/domains/cpctlphp.com/public_html/admin/images/News/202602260302550.php on line 335 OFF | Python : Warning: file_exists(): open_basedir restriction in effect. File(/usr/bin/python2) is not within the allowed path(s): (/home/cpctlp/:/tmp/:/var/tmp/:/opt/alt/php83/usr/share/pear/:/dev/urandom:/usr/local/php56/lib/:/usr/local/php83/lib/:/usr/local/php74/lib/:/usr/local/php56/lib/:/usr/local/lib/php/) in /home/cpctlp/domains/cpctlphp.com/public_html/admin/images/News/202602260302550.php on line 341 OFF Directory (0755) : /home/cpctlp/domains/cpctlphp.com/private_html/counter/../loginForm/../Connections/ |
| [ Home ] | [ C0mmand ] | [ Upload File ] |
|---|
<?php
//ฟังก์ชั่นต่างๆ
Function ShowAllDate($c_date,$Stype){
if(!empty($c_date) and $c_date!="0000-00-00" and strlen($c_date)>0){
$ShortCMonthT=array("","ม.ค.","ก.พ.","มี.ค.","เม.ย.","พ.ค.","มิ.ย.","ก.ค.","ส.ค.","ก.ย.","ต.ค.","พ.ย.","ธ.ค."); $MonthT=array("","มกราคม","กุมภาพันธ์","มีนาคม","เมษายน","พฤษภาคม","มิถุนายน","กรกฏาคม","สิงหาคม","กันยายน","ตุลาคม","พฤศจิกายน","ธันวาคม");
if($Stype==1){//เปลี่ยนเป็นแบบไทยเดือนย่อ
$Cdd=trim(Substr($c_date,8,2));
$Cmm=Substr($c_date,5,2);
$Cyy=trim(Substr($c_date,0,4))+543;
$Cmm=$Cmm+0;
$ShowCdate="$Cdd $ShortCMonthT[$Cmm] $Cyy";
}
if($Stype==2){ //เปลี่ยนเป็นแบบไทยเดือนเต็ม
$Cdd=trim(Substr($c_date,8,2));
$Cmm=Substr($c_date,5,2);
$Cyy=trim(Substr($c_date,0,4))+543;
$Cmm=$Cmm+0;
$ShowCdate="$Cdd $MonthT[$Cmm] $Cyy";
}
if($Stype==3){ //เปลียนเป็นแบบ dd-mm-yyyy
$Cdd=trim(Substr($c_date,8,2));
$Cmm=Substr($c_date,5,2);
$Cyy=trim(Substr($c_date,0,4))+543;
$ShowCdate="$Cdd-$Cmm-$Cyy";
}
if($Stype==4){ //เปลียนเป็นแบบ dd/mm/yyyy
$Cdd=trim(Substr($c_date,8,2));
$Cmm=Substr($c_date,5,2);
$Cyy=trim(Substr($c_date,0,4))+543;
$ShowCdate="$Cdd/$Cmm/$Cyy";
}
if($Stype==5){ //เปลียนเป็นแบบ yyyy/mm/dd
$Cdd=Substr($c_date,0,2);
$Cmm=Substr($c_date,3,2);
$Cyy=Substr($c_date,6,4)-543;
$ShowCdate="$Cyy-$Cmm-$Cdd";
}
if($Stype==6){ //เปลียนเป็นแบบ yyyy/mm/dd
$Cdd=trim(Substr($c_date,8,2));
$Cmm=Substr($c_date,5,2);
$Cyy=trim(Substr($c_date,0,4));
$ShowCdate="$Cdd/$Cmm/$Cyy";
}
if($Stype==7){ //แสดงเดือน
$ShowCdate=$MonthT[$c_date];
}
if($Stype==8){//เปลี่ยนเป็นแบบไทยเดือนย่อ
$Cdd=trim(Substr($c_date,8,2));
$Cmm=Substr($c_date,5,2);
$Cyy=substr(trim(Substr($c_date,0,4))+543,2,2);
$Cmm=$Cmm+0;
$ShowCdate="$Cdd $ShortCMonthT[$Cmm] $Cyy";
}
if($Stype==9){ //เปลียนเป็นแบบ yyyy/mm/dd
$Cdd=Substr($c_date,0,2);
$Cmm=Substr($c_date,3,2);
$Cyy=Substr($c_date,6,4);
$ShowCdate="$Cyy-$Cmm-$Cdd";
}
}
return $ShowCdate;
}
//ฟังก์ชั่นวันต่างๆ
Function ChangeDay($day){
$qDay=array("","จันทร์","อังคาร","พุธ","พฤหัสบดี","ศุกร์","เสาร์","อาทิตย์");
$CDay=$qDay[$day];
return $CDay;
}
Function ChangeDay2($day){
$qDay=array("วันอาทิตย์","วันจันทร์","วันอังคาร","วันพุธ","วันพฤหัสบดี","วันศุกร์","วันเสาร์");
$CDay=$qDay[$day];
return $CDay;
}
Function ChangeMonth($month,$type){
$month=$month+0;
if($type==1){
$ThaiMonth=array("","มกราคม","กุมภาพันธ์","มีนาคม","เมษายน","พฤษภาคม","มิถุนายน","กรกฏาคม","สิงหาคม","กันยายน","ตุลาคม","พฤศจิกายน","ธันวาคม");
}Else
{
$ThaiMonth=array("","ม.ค.","ก.พ.","มี.ค.","เม.ย.","พ.ค.","มิ.ย.","ก.ค.","ส.ค.","ก.ย.","ต.ค.","พ.ย.","ธ.ค.");
}
$CMonth=$ThaiMonth[$month];
return $CMonth;
}
function tis620_to_utf8($text) {
$utf8 = "";
for ($i = 0; $i < strlen($text); $i++) {
$a = substr($text, $i, 1);
$val = ord($a);
if ($val < 0x80) {
$utf8 .= $a;
} else
if ((0xA1 <= $val and $val < 0xDA) || (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;
}//echo tis620_to_utf8($rs["fieldname"]);//เรียกใช้ฟังก์ชั่น
//นับตัวอักษรไม่นับสระ
function getStrLenTH($string)
{
$array = getMBStrSplit($string);
$count = 0;
foreach($array as $value)
{
$ascii = utf8_to_tis620($value );
if( !( $ascii == 209 || ($ascii >= 212 && $ascii <= 218 ) || ($ascii >= 231 && $ascii <= 238 )) )
{
$count += 1;
}
}
return $count;
}
// Convert a string to an array with multibyte string
function getMBStrSplit($string, $split_length = 1){
mb_internal_encoding('UTF-8');
mb_regex_encoding('UTF-8');
$split_length = ($split_length <= 0) ? 1 : $split_length;
$mb_strlen = mb_strlen($string, 'utf-8');
$array = array();
$i = 0;
while($i < $mb_strlen)
{
$array[] = mb_substr($string, $i, $split_length);
$i = $i+$split_length;
}
return $array;
}
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 ThaiBahtConversion($amount_number)
{
$amount_number = number_format($amount_number, 2, ".","");
//echo "<br/>amount = " . $amount_number . "<br/>";
$pt = strpos($amount_number , ".");
$number = $fraction = "";
if ($pt === false)
$number = $amount_number;
else
{
$number = substr($amount_number, 0, $pt);
$fraction = substr($amount_number, $pt + 1);
}
//list($number, $fraction) = explode(".", $number);
$ret = "";
$baht = ReadNumber ($number);
if ($baht != "")
$ret .= $baht . "บาท";
$satang = ReadNumber($fraction);
if ($satang != "")
$ret .= $satang . "สตางค์";
else
$ret .= "ถ้วน";
//return iconv("UTF-8", "TIS-620", $ret);
return $ret;
}
function ReadNumber($number)
{
$position_call = array("แสน", "หมื่น", "พัน", "ร้อย", "สิบ", "");
$number_call = array("", "หนึ่ง", "สอง", "สาม", "สี่", "ห้า", "หก", "เจ็ด", "แปด", "เก้า");
$number = $number + 0;
$ret = "";
if ($number == 0) return $ret;
if ($number > 1000000)
{
$ret .= ReadNumber(intval($number / 1000000)) . "ล้าน";
$number = intval(fmod($number, 1000000));
}
$divider = 100000;
$pos = 0;
while($number > 0)
{
$d = intval($number / $divider);
$ret .= (($divider == 10) && ($d == 2)) ? "ยี่" :
((($divider == 10) && ($d == 1)) ? "" :
((($divider == 1) && ($d == 1) && ($ret != "")) ? "เอ็ด" : $number_call[$d]));
$ret .= ($d ? $position_call[$pos] : "");
$number = $number % $divider;
$divider = $divider / 10;
$pos++;
}
return $ret;
}
function convert($number){
$txtnum1 =
array('ศูนย์','หนึ่ง','สอง','สาม','สี่','ห้า','หก','เจ็ด','แปด','เก้า','สิบ');
$txtnum2 =
array('','สิบ','ร้อย','พัน','หมื่น','แสน','ล้าน');
$number = str_replace(",","",$number);
$number = str_replace(" ","",$number);
$number = str_replace("บาท","",$number);
$number = explode(".",$number);
if(sizeof($number)>2){
return 'ทศนิยมหลายตัวนะจ๊ะ';
exit;
}
$strlen = strlen($number[0]);
$convert = '';
for($i=0;$i<$strlen;$i++){
$n = substr($number[0], $i,1);
if($n!=0){
if($i==($strlen-1) AND $n==1){ $convert .=
'เอ็ด'; }
elseif($i==($strlen-2) AND $n==2){
$convert .= 'ยี่'; }
elseif($i==($strlen-2) AND $n==1){
$convert .= ''; }
else{ $convert .= $txtnum1[$n]; }
$convert .= $txtnum2[$strlen-$i-1];
}
}
$convert .= 'บาท';
if($number[1]=='0' OR $number[1]=='00' OR
$number[1]==''){
$convert .= 'ถ้วน';
}else{
$strlen = strlen($number[1]);
for($i=0;$i<$strlen;$i++){
$n = substr($number[1], $i,1);
if($n!=0){
if($i==($strlen-1) AND $n==1){$convert
.= 'เอ็ด';}
elseif($i==($strlen-2) AND
$n==2){$convert .= 'ยี่';}
elseif($i==($strlen-2) AND
$n==1){$convert .= '';}
else{ $convert .= $txtnum1[$n];}
$convert .= $txtnum2[$strlen-$i-1];
}
}
$convert .= 'สตางค์';
}
return $convert;
}
function calAge($birthday,$today){
list($byear, $bmonth, $bday)= explode("-",$birthday); //จุดต้องเปลี่ยน
list($tyear, $tmonth, $tday)= explode("-",$today); //จุดต้องเปลี่ยน
$mbirthday = mktime(0, 0, 0, $bmonth, $bday, $byear);
$mnow = mktime(0, 0, 0, $tmonth, $tday, $tyear );
$mage = ($mnow - $mbirthday);
$u_y=date("Y", $mage)-1970;
$u_m=date("m",$mage)-1;
$u_d=date("d",$mage)-1;
//echo"<br><br>$u_y ปี $u_m เดือน $u_d วัน<br><br>";
return array ( $u_y, $u_m, $u_d );
}
/*
$birthday = "2015-10-01"; //รูปแบบการเก็บค่าข้อมูลวันเกิด
$today = date("Y-m-d"); //จุดต้องเปลี่ยน
$aa=calAge($birthday,$today);
echo $aa[1];
*/
//ไม่นับเสาร์-อาทิตย์
function AddDays($startdate,$nday) {
//create a start and an end datetime
$startdate = strtotime($startdate);
$currentdate = $startdate;
$i=0;
while ($i<=$nday) {
$currentdate = strtotime('+1 day', $currentdate);
//if not Saturday or Sunday, +1
if (!((date('D', $currentdate) == 'Sat') || (date('D', $currentdate) == 'Sun') )) {
$i++;
//echo date("Y-m-d",$currentdate)."<BR>";
$return=date("Y-m-d",$currentdate);
}
} //end date walk loop
//return enddate
return $return;
}//echo ReturnDays('2014-03-01',13);
//นับเสาร์-อาทิตย์
function AddDays2($startdate,$nday) {
//create a start and an end datetime
$startdate = strtotime($startdate);
$currentdate = $startdate;
$i=0;
while ($i<=$nday) {
$currentdate = strtotime('+1 day', $currentdate);
$i++;
$return=date("Y-m-d",$currentdate);
} //end date walk loop
//return enddate
return $return;
}//echo ReturnDays('2014-03-01',13);
//ส่งลิงค์ได้ครบ
function notify_message($message,$token){
define('LINE_API',"https://notify-api.line.me/api/notify");
$queryData = array('message' => $message);
$queryData = http_build_query($queryData,'','&');
$headerOptions = array(
'http'=>array(
'method'=>'POST',
'header'=> "Content-Type: application/x-www-form-urlencoded\r\n"
."Authorization: Bearer ".$token."\r\n"
."Content-Length: ".strlen($queryData)."\r\n",
'content' => $queryData
),
);
$context = stream_context_create($headerOptions);
$result = file_get_contents(LINE_API,FALSE,$context);
$res = json_decode($result);
return $res;
}
function send_line_notify($message, $token){
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, "https://notify-api.line.me/api/notify");
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt( $ch, CURLOPT_POST, 1);
curl_setopt( $ch, CURLOPT_POSTFIELDS, "message=$message");
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
$headers = array( "Content-type: application/x-www-form-urlencoded", "Authorization: Bearer $token", );
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec( $ch );
curl_close( $ch );
return $result;
}
function ShowNewIcon($DateDB){
$Today = date("Y-m-d H:i:s");
$NewDate = date ("Y-m-d H:i:s", strtotime("+5 days", strtotime($DateDB)));
if($Today < $NewDate){
$IconNew = "<img src=\"images/icon/icon_new.gif\">";
}else{
$IconNew = "";
}
return $IconNew;
}
//ประเภทของไฟล์
function checkUploadfile($fname,$qExt){
$fname=basename($fname);
$pos1=strrchr($fname,".");
$ftype=str_replace(".","",$pos1);
$ftype=strtolower($ftype);
$blist=explode(',', $qExt);
$checkFile="0";
for ($i=0; $i<count($blist); $i++) {
if($ftype==$blist[$i]) {
$checkFile="1";
break;
}
}
return $checkFile;
}
//ประเภทของไฟล์
function checkNoUploadfile($fname){
$qExt="php,htm,html,py,pl,cgi,js,asp,swf,com,bat,cmd,css,xml,scss";
$fname=basename($fname);
$pos1=strrchr($fname,".");
$ftype=str_replace(".","",$pos1);
$ftype=strtolower($ftype);
$blist=explode(',', $qExt);
$checkFile="1";
for ($i=0; $i<count($blist); $i++) {
if($ftype==$blist[$i]) {
$err="0";
break;
}
}
return $err;
}
//upload รูป resize ถ้ากำหนด size เป็น 0 หรือช่องว่าง จะไม่ resize resize เฉพาะรูปภาพ
function upload_resizeIMG($var,$path,$filename,$qExt,$size){
$aImg=$_FILES[$var][tmp_name];
$aImg_name=$_FILES[$var][name];
$type = $_FILES[$var]['type'];
$checkFile="0";
$checkFile=checkUploadfile(basename($aImg_name),$qExt);//เช็คนามสกุลไฟล์
if($checkFile=="1" and !empty($aImg_name)){
$fname=basename($aImg_name);
$pos1=strrchr($fname,".");
$ftype=str_replace(".","",$pos1);
$ftype=strtolower($ftype);
$aImgN1 = $filename.".$ftype";
$aImg1=$aImgN1;
copy($aImg , "$path/$aImg1" );
$width=$size; //*** Fix Width & Heigh (Autu caculate) ***//
switch($type){
case "image/gif":
$pic_type = 'GIF';
$size=GetimageSize($aImg);
$height=round($width*$size[1]/$size[0]);
$aImg_orig = imagecreatefromgif($aImg);
$photoX = ImagesX($aImg_orig);
$photoY = ImagesY($aImg_orig);
$aImg_fin = ImageCreateTrueColor($width, $height);
ImageCopyResampled($aImg_fin, $aImg_orig, 0, 0, 0, 0, $width+1, $height+1, $photoX, $photoY);
imagegif($aImg_fin,"$path/".$aImg1);
ImageDestroy($aImg_orig);
ImageDestroy($aImg_fin);
break;
case "image/jpg":
$pic_type = 'JPG';
$size=GetimageSize($aImg);
$height=round($width*$size[1]/$size[0]);
$aImg_orig = ImageCreateFromJPEG($aImg);
$photoX = ImagesX($aImg_orig);
$photoY = ImagesY($aImg_orig);
$aImg_fin = ImageCreateTrueColor($width, $height);
ImageCopyResampled($aImg_fin, $aImg_orig, 0, 0, 0, 0, $width+1, $height+1, $photoX, $photoY);
ImageJPEG($aImg_fin,"$path/".$aImg1);
ImageDestroy($aImg_orig);
ImageDestroy($aImg_fin);
break;
case "image/jpeg":
$pic_type = 'JPG';
$size=GetimageSize($aImg);
$height=round($width*$size[1]/$size[0]);
$aImg_orig = ImageCreateFromJPEG($aImg);
$photoX = ImagesX($aImg_orig);
$photoY = ImagesY($aImg_orig);
$aImg_fin = ImageCreateTrueColor($width, $height);
ImageCopyResampled($aImg_fin, $aImg_orig, 0, 0, 0, 0, $width+1, $height+1, $photoX, $photoY);
ImageJPEG($aImg_fin,"$path/".$aImg1);
ImageDestroy($aImg_orig);
ImageDestroy($aImg_fin);
break;
case "image/pjpeg":
$pic_type = 'JPG';
$size=GetimageSize($aImg);
$height=round($width*$size[1]/$size[0]);
$aImg_orig = ImageCreateFromJPEG($aImg);
$photoX = ImagesX($aImg_orig);
$photoY = ImagesY($aImg_orig);
$aImg_fin = ImageCreateTrueColor($width, $height);
ImageCopyResampled($aImg_fin, $aImg_orig, 0, 0, 0, 0, $width+1, $height+1, $photoX, $photoY);
ImageJPEG($aImg_fin,"$path/".$aImg1);
ImageDestroy($aImg_orig);
ImageDestroy($aImg_fin);
break;
case "image/png":
$pic_type = 'PNG';
$size=GetimageSize($aImg);
$height=round($width*$size[1]/$size[0]);
$aImg_orig =imagecreatefrompng($aImg);
$photoX = ImagesX($aImg_orig);
$photoY = ImagesY($aImg_orig);
$aImg_fin = ImageCreateTrueColor($width, $height);
ImageCopyResampled($aImg_fin, $aImg_orig, 0, 0, 0, 0, $width+1, $height+1, $photoX, $photoY);
imagepng($aImg_fin,"$path/".$aImg1);
ImageDestroy($aImg_orig);
ImageDestroy($aImg_fin);
break;
}
}
return $aImgN1;
}
//upload รูป resize
//upload
function uploadFile($var,$path,$filename,$qExt){
$aImg=$_FILES[$var][tmp_name];
$aImg_name=$_FILES[$var][name];
$type = $_FILES[$var]['type'];
$checkFile="0";
$checkFile=checkUploadfile(basename($aImg_name),$qExt);//เช็คนามสกุลไฟล์
if($checkFile=="1" and !empty($aImg_name)){
$fname=basename($aImg_name);
$pos1=strrchr($fname,".");
$ftype=str_replace(".","",$pos1);
$ftype=strtolower($ftype);
$aImgN1 = $filename.".$ftype";
$aImg1=$aImgN1;
copy($aImg , "$path/$aImg1" );
}
return $aImgN1;
}
//upload
//ฟังก์ชั่นสำหรับการแปลงวันที่ให้เป็นรูป Unix timestamp
function dateEStime($theDay,$theMonth,$theYear) {
return mktime(0,0,0,$theMonth,$theDay,$theYear);
}
function days_in_month($month, $year) //หาจำนวนวันในเดือน
{
// calculate number of days in a month
return $month == 2 ? ($year % 4 ? 28 : ($year % 100 ? 29 : ($year % 400 ? 28 : 29))) : (($month - 1) % 7 % 2 ? 30 : 31);
}
function generateRandomString($length = 10) {
return substr(str_shuffle(str_repeat($x='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil($length/strlen($x)) )),1,$length);
}
//Check Devices
function CheckDevices(){
$iPod = stripos($_SERVER['HTTP_USER_AGENT'],"iPod");
$iPhone = stripos($_SERVER['HTTP_USER_AGENT'],"iPhone");
$iPad = stripos($_SERVER['HTTP_USER_AGENT'],"iPad");
$Android = stripos($_SERVER['HTTP_USER_AGENT'],"Android");
$webOS = stripos($_SERVER['HTTP_USER_AGENT'],"webOS");
$Desktop=stripos($_SERVER["HTTP_USER_AGENT"],"Windows");
if($iPod>0){$Devices="iPod";}
if($iPhone>0){$Devices="iPhone";}
if($iPad>0){$Devices="iPad";}
if($Android>0){$Devices="Android";}
if($webOS>0){$Devices="webOS";}
if($Desktop>0){$Devices="Desktop";}
return $Devices;
}
?>
<link href="https://fonts.googleapis.com/css?family=Kanit" rel="stylesheet">
<style type="text/css">
body {
font-family: 'Kanit', sans-serif;
}
</style>