Server IP : 103.233.192.212 / Your IP : 18.223.158.66 Web Server : Apache/2 System : Linux sv1.inde.co.th 3.10.0-1160.36.2.el7.x86_64 #1 SMP Wed Jul 21 11:57:15 UTC 2021 x86_64 User : sumpatuan ( 1058) PHP Version : 5.5.38 Disable Function : symlink,shell_exec,exec,proc_close,proc_open,popen,system,dl,putenv,passthru,escapeshellarg,escapeshellcmd,pcntl_exec,proc_get_status,proc_nice,proc_terminate,pclose,ini_alter,virtual,openlog,ini_restore MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/sumpatuan/domains/sumpatuan.go.th/public_html/admin/top/action/ |
Upload File : |
<?php require_once('session_backend_administrator.php'); header('Content-Type: text/html; charset=UTF-8'); date_default_timezone_set("Asia/Bangkok"); $datetime = date('d/m/Y H.i'); //// function Transparency BG function setTransparency($new_image,$image_source){ $transparencyIndex = imagecolortransparent($image_source); $transparencyColor = array('red' => 255, 'green' => 255, 'blue' => 255); if ($transparencyIndex >= 0) { $transparencyColor = imagecolorsforindex($image_source, $transparencyIndex); } $transparencyIndex = imagecolorallocate($new_image, $transparencyColor['red'], $transparencyColor['green'], $transparencyColor['blue']); imagefill($new_image, 0, 0, $transparencyIndex); imagecolortransparent($new_image, $transparencyIndex); } if($STT_login=="admin_login_true"){ if(!isset($_POST['txt_name']) or !isset($_POST['txt_type']) or !isset($_POST['txt_subtype']) ){ echo "<SCRIPT type='text/javascript'> alert('กรุณากรอกข้อมูลให้ครบ'); window.location.replace(document.referrer); </SCRIPT>"; exit; }else{ $data_nametop = trim($con_db_administrator->real_escape_string($_POST['txt_name'])); $data_typetop = $con_db_administrator->real_escape_string($_POST['txt_type']); $data_subtypetop = $con_db_administrator->real_escape_string($_POST['txt_subtype']); $data_stttop = $con_db_administrator->real_escape_string($_POST['statusshow']); $data_linktop = $con_db_administrator->real_escape_string($_POST['linktop']); $date = $_POST['txt_date']; $lastupdate_top = date("d/m/Y",strtotime($date)); $total_filedoc = count($_FILES['uploadFile']['name']); /////// insert DATA to SQL $insert_top = " INSERT INTO `data_top`(`name_top`, `type_top`, `subtype_top`, `stt_top`, `lastupdate_top`) VALUES ( '$data_nametop', '$data_typetop', '$data_subtypetop', '$data_stttop', '$lastupdate_top' )"; $action_top = $con_db_administrator->query($insert_top); if(!$action_top){ echo "<SCRIPT type='text/javascript'> alert('เพิ่มข้อมูลไม่สำเร็จ กรุณาลองใหม่อีกครั้ง'); window.location.replace('../$data_linktop'); </SCRIPT>"; exit; }else{ if($total_filedoc==0){ echo "<SCRIPT type='text/javascript'> alert('เพิ่มข้อมูลใหม่ สำเร็จ [non-file]'); window.location.replace('../$data_linktop'); </SCRIPT>"; exit; }else{ $sql_data = " SELECT `id_top` FROM `data_top` WHERE `name_top`='$data_nametop' AND `lastupdate_top`='$lastupdate_top' ORDER BY `id_top` DESC LIMIT 1 "; $qr_data = mysqli_query($con_db_administrator, $sql_data); $rs_data = mysqli_fetch_assoc($qr_data); $id_tbdata_filedoc = $rs_data['id_top']; if($id_tbdata_filedoc !="" or isset($id_tbdata_filedoc) ){ $dt_addfile = date('YmdHis'); for($i=0;$i<$total_filedoc;$i++){ $filedoc = $_FILES["uploadFile"]["tmp_name"][$i]; $oldname_filedoc = trim($_FILES['uploadFile']['name'][$i]); $type_filedoc = pathinfo($_FILES['uploadFile']['name'][$i],PATHINFO_EXTENSION); $newname_filedoc = "FILET".$id_tbdata_filedoc."_".$dt_addfile."_".$i.".".$type_filedoc; $keep_filedoc = "../../../doc/t/"; $move_filedoc = $keep_filedoc.$newname_filedoc; $path_filedoc = "doc/t/".$newname_filedoc; $width=900; if( exif_imagetype($filedoc) == IMAGETYPE_JPEG ) { $size=GetimageSize($filedoc); if($size[0]>=$width){ $height=round($width*$size[1]/$size[0]); $filedoc_orig = ImageCreateFromJPEG($filedoc); $photoX = ImagesX($filedoc_orig); $photoY = ImagesY($filedoc_orig); $filedoc_fin = ImageCreateTrueColor($width, $height); setTransparency($filedoc_fin,$filedoc_orig); ImageCopyResampled($filedoc_fin, $filedoc_orig, 0, 0, 0, 0, $width+1, $height+1, $photoX, $photoY); ImageJPEG($filedoc_fin, $move_filedoc); ImageDestroy($filedoc_orig); ImageDestroy($filedoc_fin); }else{ move_uploaded_file($_FILES['uploadFile']['tmp_name'][$i],$move_filedoc); } }elseif( exif_imagetype($filedoc) == IMAGETYPE_PNG ){ $size=GetimageSize($filedoc); if($size[0]>=$width){ $height=round($width*$size[1]/$size[0]); $filedoc_orig = ImageCreateFromPNG($filedoc); $photoX = ImagesX($filedoc_orig); $photoY = ImagesY($filedoc_orig); $filedoc_fin = ImageCreateTrueColor($width, $height); setTransparency($filedoc_fin,$filedoc_orig); ImageCopyResampled($filedoc_fin, $filedoc_orig, 0, 0, 0, 0, $width+1, $height+1, $photoX, $photoY); imagepng($filedoc_fin, $move_filedoc); ImageDestroy($filedoc_orig); ImageDestroy($filedoc_fin); }else{ move_uploaded_file($_FILES['uploadFile']['tmp_name'][$i],$move_filedoc); } }elseif( exif_imagetype($filedoc) == IMAGETYPE_GIF ){ $size=GetimageSize($filedoc); if($size[0]>=$width){ $height=round($width*$size[1]/$size[0]); $filedoc_orig = ImageCreateFromGIF($filedoc); $photoX = ImagesX($filedoc_orig); $photoY = ImagesY($filedoc_orig); $filedoc_fin = ImageCreateTrueColor($width, $height); setTransparency($filedoc_fin,$filedoc_orig); ImageCopyResampled($filedoc_fin, $filedoc_orig, 0, 0, 0, 0, $width+1, $height+1, $photoX, $photoY); imagegif($filedoc_fin,$move_filedoc); ImageDestroy($filedoc_orig); ImageDestroy($filedoc_fin); }else{ move_uploaded_file($_FILES['uploadFile']['tmp_name'][$i],$move_filedoc); } }else{ move_uploaded_file($_FILES['uploadFile']['tmp_name'][$i],$move_filedoc); } $insert_filedoc = " INSERT INTO `data_filedoc_top`(`name_filedoc_top`, `type_filedoc_top`, `path_filedoc_top`, `id_tbdata_filedoc_top`,`tbdata_filedoc_top` ) VALUES ('$oldname_filedoc', '$type_filedoc', '$path_filedoc', '$id_tbdata_filedoc', '$data_typetop' ) "; $action_filedoc = $con_db_administrator->query($insert_filedoc); if(!$action_filedoc){ echo "<SCRIPT type='text/javascript'> alert('เพิ่มข้อมูลไม่สำเร็จ กรุณาลองใหม่อีกครั้ง [insert_filedoc]'); window.location.replace('../$data_linktop'); </SCRIPT>"; exit; } } echo "<SCRIPT type='text/javascript'> alert('เพิ่มข้อมูลใหม่ สำเร็จ'); window.location.replace('../$data_linktop'); </SCRIPT>"; exit; }else{ echo "<SCRIPT type='text/javascript'> alert('เพิ่มข้อมูลไม่สำเร็จ กรุณาลองใหม่อีกครั้ง [2]'); window.location.replace('../$data_linktop'); </SCRIPT>"; exit; } } } } }else{ echo "<SCRIPT type='text/javascript'> alert('กรุณาเข้าสู่ระบบ'); window.location.replace('../../index'); </SCRIPT>"; exit; } mysqli_close($con_db_administrator); ?>