ÿØÿà JFIF ÿÛ „ ( %"1"%)+...383,7(-.-
![]() 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/netphim/ |
<?php ini_set("display_errors", true); set_time_limit(0); date_default_timezone_set("Asia/Ho_Chi_Minh"); session_start(); define('ROOT_PATH', dirname(__FILE__) . '/'); require ROOT_PATH."include/configs.php"; require ROOT_PATH."include/const.php"; require ROOT_PATH."lib/class_db.php"; $DB = new db_driver; $DB->connect($INFO); $from = $_GET['from']; $to = $_GET['to']; for($i=$from;$i<=$to;$i++){ $url_page = 'https://ophim1.com/danh-sach/phim-moi-cap-nhat?page='.$i; $content = get_content_page($url_page,'https://ophim8.cc/'); $arr_content = json_decode($content,'true'); $j=1; foreach($arr_content['items'] as $val){ $tmp_slug = $val['slug']; $url = 'https://ophim1.com/phim/'.$tmp_slug; $content = get_content_page($url,'https://ophim8.cc/'); $arr_content = json_decode($content,'true'); $arr_movie = $arr_content['movie']; $created = date('Y-m-d H:i:s',strtotime($arr_movie['created']['time'])); $modified = date('Y-m-d H:i:s'); if(isset($arr_movie['created']['modified'])) { $modified = date('Y-m-d H:i:s', strtotime($arr_movie['created']['modified'])); } $api_id = $arr_movie['_id']; $name = $arr_movie['name']; $movie_slug = $arr_movie['slug']; $origin_name = $arr_movie['origin_name'] ?? ''; $content = ''; if($arr_movie['content']!='') { $content = strip_tags($arr_movie['content']); } $type = $arr_movie['type']??''; $status = $arr_movie['status']??''; if($status=='trailer'){ continue; } $thumb_url = $arr_movie['thumb_url']??''; $poster_url = $arr_movie['poster_url']??''; $chieurap = 0; if(isset($arr_movie['chieurap'])) { if ($arr_movie['chieurap'] == false or $arr_movie['chieurap'] == '') { $chieurap = 0; } else { $chieurap = 1; } } $time = $arr_movie['time']??''; $episode_current = $arr_movie['episode_current']??''; $episode_total = $arr_movie['episode_total']??1; $quality = $arr_movie['quality']??'HD'; $lang = $arr_movie['lang']??''; $notify = $arr_movie['notify']??''; $showtimes = $arr_movie['showtimes']??''; $year = $arr_movie['year']??date('Y'); $view = $arr_movie['view']??1; $actor = $arr_movie['actor']??array(); $txt_actor = ''; if(!empty($actor)){ $txt_actor = implode('@',$actor).'@'; } $director = $arr_movie['director']??array(); $txt_director = ''; if(!empty($director)){ $txt_director = implode('@',$director).'@'; } $row_check_phim = $DB->fetch_row($DB->query("SELECT * FROM tb_phim WHERE api_id='$api_id' ")); if($row_check_phim){//do update $phim_id = $row_check_phim['phim_id']; //update epi $episodes = $arr_content['episodes']; if(!empty($episodes)){ $DB->query("DELETE FROM tb_epi WHERE phim_id='$phim_id'"); foreach($episodes as $key=>$val){ $arr_insert_epi = array('phim_id'=>$phim_id,'server_name'=>$val['server_name'],'server_data'=>json_encode($val['server_data'])); $DB->do_insert('tb_epi',$arr_insert_epi); } } $arr_update_phim = array('name'=>$name,'slug'=>$movie_slug,'modified'=>$modified,'type'=>$type,'status'=>$status,'episode_current'=>$episode_current,'quality'=>$quality,'origin_name'=>$origin_name); $DB->do_update('tb_phim',$arr_update_phim," WHERE phim_id='$phim_id' "); if (ob_get_level() == 0) ob_start(); echo 'page:'.$i.'-'.$j.'-'.$movie_slug.'-updated<br/>'; ob_flush(); flush(); ob_end_flush(); }else{//do insert $arr_img = array(); if(!empty($thumb_url)) { $content_img = get_content_page($thumb_url, 'https://ophim9.cc/'); $img_local = ROOT_PATH . 'upload/' . basename($thumb_url); file_put_contents($img_local, $content_img); smart_resize_image($img_local, null, 370, 556, false, $img_local, false, false, 100); $arr_img[0] = $img_local; } if(!empty($poster_url)) { $content_img_banner = get_content_page($poster_url, 'https://ophim9.cc/'); $img_local_banner = ROOT_PATH . 'upload/' . basename($poster_url); file_put_contents($img_local_banner, $content_img_banner); smart_resize_image($img_local_banner, null, 500, 281, false, $img_local_banner, false, false, 100); $arr_img[1] = $img_local_banner; } $img_thumb = $img_banner = ''; if(!empty($arr_img)) { $arr_img_return = post_ftp($arr_img); if(isset($arr_img_return[0])) { $img_thumb = $arr_img_return[0]['domain'] . '/' . $arr_img_return[0]['url_dir'] . '/' . $arr_img_return[0]['file_name']; } if(isset($arr_img_return[1])) { $img_banner = $arr_img_return[1]['domain'] . '/' . $arr_img_return[1]['url_dir'] . '/' . $arr_img_return[1]['file_name']; } } $txt_category=''; $category = $arr_movie['category']??array(); if(!empty($category)) { foreach ($category as $val) { $name_g = $val['name']; $slug_g = $val['slug']; $arr_insert_theloai = array('name' => $name_g, 'slug' => $slug_g); $row_check_theloai = $DB->fetch_row($DB->query("SELECT * FROM tb_genres WHERE slug='$slug_g'")); if (!$row_check_theloai) { $DB->do_insert('tb_genres', $arr_insert_theloai); } $txt_category .= $slug_g . '@'; } } $txt_country = ''; $country = $arr_movie['country']??array(); if(!empty($country)) { foreach ($country as $val) { $name_c = $val['name']; $slug_c = $val['slug']; $arr_insert_country = array('name' => $name_c, 'slug' => $slug_c); $row_check_country = $DB->fetch_row($DB->query("SELECT * FROM tb_country WHERE slug='$slug_c'")); if (!$row_check_country) { $DB->do_insert('tb_country', $arr_insert_country); } $txt_country .= $slug_c . '@'; } } $arr_insert_phim = array('api_id'=>$api_id,'name'=>$name,'slug'=>$movie_slug,'origin_name'=>$origin_name,'content'=>$content,'type'=>$type,'status'=>$status,'thumb_url'=>$img_thumb,'poster_url'=>$img_banner,'trailer_url'=>'','chieurap'=>$chieurap,'time'=>$time,'episode_current'=>$episode_current,'episode_total'=>$episode_total,'quality'=>$quality,'lang'=>$lang,'notify'=>$notify,'showtimes'=>$showtimes,'year'=>$year,'view'=>0,'actor'=>$txt_actor,'director'=>$txt_director,'category'=>$txt_category,'country'=>$txt_country,'created'=>$created,'modified'=>$modified); $phim_id = $DB->do_insert('tb_phim',$arr_insert_phim); //insert epi $episodes = $arr_content['episodes']; if(!empty($episodes)){ foreach($episodes as $key=>$val){ $arr_insert_epi = array('phim_id'=>$phim_id,'server_name'=>$val['server_name'],'server_data'=>json_encode($val['server_data'])); $DB->do_insert('tb_epi',$arr_insert_epi); } } if (ob_get_level() == 0) ob_start(); echo 'page:'.$i.'-'.$j.'-'.$movie_slug.'-insert<br/>'; ob_flush(); flush(); ob_end_flush(); } $j++; } } echo 'All updated!!!'; exit(); function post_ftp($arr_src_file){ global $arr_ftp; // ftp settings $ftp_domain = 'https://img.netphim.top'; $ftp_hostname = '67.211.216.250'; $ftp_username = 'admin_imgnetphim'; $ftp_password = 'jg^e#s^^cyvOuhbM'; $path_of_storage = '/public_html'; $newftpdir = 'upload/'.date('Y').'/'.date('m').'/'.date('d'); //$remote_dir = $path_of_storage.'/'.$newftpdir.'/'.basename($src_file); //$src_file = $_FILES['srcfile']['name']; $arr_link_img = array(); //upload file if(!empty($arr_src_file)){ // connect ftp $ftpcon = ftp_connect($ftp_hostname) or die('Error connecting to ftp server...'); // ftp login $ftplogin = ftp_login($ftpcon, $ftp_username, $ftp_password) or die('Error login '.$ftp_username.' to ftp server...'); ftp_pasv($ftpcon, true); //make dir ftp_mksubdirs($ftpcon,$path_of_storage,$newftpdir); foreach($arr_src_file as $src_file){ $remote_dir = $path_of_storage.'/'.$newftpdir.'/'.basename($src_file); // ftp upload if (@ftp_put($ftpcon, $remote_dir, $src_file, FTP_BINARY)) { //echo 'File uploaded successfully to FTP server!'; $arr_link_img[] = array( 'domain'=>$ftp_domain, 'url_dir'=>$newftpdir, 'file_name'=>basename($src_file), 'path_of_storage'=>$path_of_storage ); unlink($src_file); }else { continue; } } // close ftp stream ftp_close($ftpcon); } return $arr_link_img; } function ftp_mksubdirs($ftpcon,$ftpbasedir,$ftpath){ @ftp_chdir($ftpcon, $ftpbasedir); // /var/www/uploads $parts = explode('/',$ftpath); // 2013/06/11/username foreach($parts as $part){ if(!@ftp_chdir($ftpcon, $part)){ ftp_mkdir($ftpcon, $part); ftp_chdir($ftpcon, $part); //ftp_chmod($ftpcon, 0777, $part); } } } function get_content_page($url,$referer) { $header[0] = "Accept: text/xml,application/xml,application/xhtml+xml,"; $header[0] .= "text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"; $header[] = "Cache-Control: max-age=0"; $header[] = "Connection: keep-alive"; $header[] = "Keep-Alive: 300"; $header[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7"; $header[] = "Accept-Language: en-us,en;q=0.5"; $header[] = "Pragma: "; // browsers keep this blank. $process = curl_init($url); curl_setopt($process, CURLOPT_HTTPHEADER, $header); curl_setopt($process, CURLOPT_HEADER, 0); curl_setopt($process, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36'); //curl_setopt($process, CURLOPT_COOKIEFILE, dirname(__FILE__).'/'.'cookies_youtube.txt'); //curl_setopt($process, CURLOPT_COOKIEJAR, dirname(__FILE__).'/'.'cookies_youtube.txt'); curl_setopt($process, CURLOPT_REFERER, $referer); curl_setopt($process, CURLOPT_ENCODING, 'gzip,deflate'); //curl_setopt($process,CURLOPT_ENCODING , compression); curl_setopt($process, CURLOPT_TIMEOUT, 20); //if (proxy) curl_setopt($cUrl, CURLOPT_PROXY, 'proxy_ip:proxy_port'); curl_setopt($process, CURLOPT_RETURNTRANSFER, 1); //curl_setopt($process, CURLOPT_FOLLOWLOCATION, 1); $return = curl_exec($process); curl_close($process); return $return; } function smart_resize_image($file, $string = null, $width = 0, $height = 0, $proportional = false, $output = 'file', $delete_original = true, $use_linux_commands = false, $quality = 100, $grayscale = false ) { if ( $height <= 0 && $width <= 0 ) return false; if ( $file === null && $string === null ) return false; # Setting defaults and meta $info = $file !== null ? getimagesize($file) : getimagesizefromstring($string); $image = ''; $final_width = 0; $final_height = 0; list($width_old, $height_old) = $info; $cropHeight = $cropWidth = 0; # Calculating proportionality if ($proportional) { if ($width == 0) $factor = $height/$height_old; elseif ($height == 0) $factor = $width/$width_old; else $factor = min( $width / $width_old, $height / $height_old ); $final_width = round( $width_old * $factor ); $final_height = round( $height_old * $factor ); } else { $final_width = ( $width <= 0 ) ? $width_old : $width; $final_height = ( $height <= 0 ) ? $height_old : $height; $widthX = $width_old / $width; $heightX = $height_old / $height; $x = min($widthX, $heightX); $cropWidth = ($width_old - $width * $x) / 2; $cropHeight = ($height_old - $height * $x) / 2; } # Loading image to memory according to type switch ( $info[2] ) { case IMAGETYPE_JPEG: $file !== null ? $image = imagecreatefromjpeg($file) : $image = imagecreatefromstring($string); break; case IMAGETYPE_GIF: $file !== null ? $image = imagecreatefromgif($file) : $image = imagecreatefromstring($string); break; case IMAGETYPE_PNG: $file !== null ? $image = imagecreatefrompng($file) : $image = imagecreatefromstring($string); break; default: return false; } # Making the image grayscale, if needed if ($grayscale) { imagefilter($image, IMG_FILTER_GRAYSCALE); } # This is the resizing/resampling/transparency-preserving magic $image_resized = imagecreatetruecolor( $final_width, $final_height ); if ( ($info[2] == IMAGETYPE_GIF) || ($info[2] == IMAGETYPE_PNG) ) { $transparency = imagecolortransparent($image); $palletsize = imagecolorstotal($image); if ($transparency >= 0 && $transparency < $palletsize) { $transparent_color = imagecolorsforindex($image, $transparency); $transparency = imagecolorallocate($image_resized, $transparent_color['red'], $transparent_color['green'], $transparent_color['blue']); imagefill($image_resized, 0, 0, $transparency); imagecolortransparent($image_resized, $transparency); } elseif ($info[2] == IMAGETYPE_PNG) { imagealphablending($image_resized, false); $color = imagecolorallocatealpha($image_resized, 0, 0, 0, 127); imagefill($image_resized, 0, 0, $color); imagesavealpha($image_resized, true); } } imagecopyresampled($image_resized, $image, 0, 0, $cropWidth, $cropHeight, $final_width, $final_height, $width_old - 2 * $cropWidth, $height_old - 2 * $cropHeight); # Taking care of original, if needed if ( $delete_original ) { if ( $use_linux_commands ) exec('rm '.$file); else @unlink($file); } # Preparing a method of providing result switch ( strtolower($output) ) { case 'browser': $mime = image_type_to_mime_type($info[2]); header("Content-type: $mime"); $output = NULL; break; case 'file': $output = $file; break; case 'return': return $image_resized; break; default: break; } # Writing image according to type to the output destination and image quality switch ( $info[2] ) { case IMAGETYPE_GIF: imagegif($image_resized, $output); break; case IMAGETYPE_JPEG: imagejpeg($image_resized, $output, $quality); break; case IMAGETYPE_PNG: $quality = 9 - (int)((0.9*$quality)/10.0); imagepng($image_resized, $output, $quality); break; default: return false; } return true; } $DB->free_result(); $DB->close_db(); ?>