Сообщений: 189
Регистрация: Апр 2012
|
#20
19 Декабря 2012 15:31
перестал парсить скрины и большой постер. Все попытки как-то подобрать правильную ссылку увенчались провалом((( может всем миром одолеем его? сейчас выложу код, который нужно как то доработать. Цитата |
---|
<?php /* ============================================== PKinoPois 1.8.15.1 for DLE ---------------------------------------------- 2012 ============================================== */ @session_start(); @error_reporting(7); @ini_set('display_errors', true); @ini_set('html_errors', false); @ini_set('max_execution_time', '300'); @set_time_limit(300);
define('DATALIFEENGINE', true); define('ENGINE_DIR', dirname(__FILE__).'/..'); define('ROOT_DIR', dirname(__FILE__).'/../..');
require_once ENGINE_DIR.'/data/config.php'; require_once ENGINE_DIR.'/classes/mysql.php'; require_once ENGINE_DIR.'/data/dbconfig.php'; require_once ENGINE_DIR.'/modules/functions.php'; require_once ENGINE_DIR.'/modules/sitelogin.php'; require_once ENGINE_DIR.'/data/config_pkinopoisk.php';
if (!$is_logged || !in_array($member_id['user_group'], $conf_pk['group_ap'])) { @header("Content-type: text/html; charset=".$config['charset']); die('Вам не разрешено пользоваться данным модулем!'); }
require_once ENGINE_DIR.'/classes/thumb.class.php'; define('FOLDER_PREFIX', date("Y-m")); $config['allow_cache'] = "yes";
$news_id = intval($_POST['news_id']); $author = $member_id['name']; $time_s = time();
if (get_magic_quotes_gpc()) { $_POST['film_name'] = stripslashes($_POST['film_name']); } $film_name = urlencode(trim(convert_unicode($_POST['film_name'], $config['charset'])));
if ($film_name == "") die();
//if (isset($_SERVER['HTTP_USER_AGENT']) && strlen($_SERVER['HTTP_USER_AGENT']) > 25) { // $us_agent = $_SERVER['HTTP_USER_AGENT']; //} else { $us_agent = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11'; //}
if ($conf_pk['jpeg_quality'] <= 0) { $conf_pk['jpeg_quality'] = $config['jpeg_quality']; }
function load_page($url, $refer = 'http://www.kinopoisk.ru/', $file_img = false, $post = false, $init = false, $redir = false) { global $conf_pk, $us_agent; static $time = 0; static $curl_redir = 0; static $curl_redir_max = 5;
if ($curl_redir >= $curl_redir_max) { $curl_redir = 0; return false; }
$conf_pk['sleep'] = intval($conf_pk['sleep']); if ($conf_pk['sleep'] > 0) { if ($time + $conf_pk['sleep'] > time()) sleep($conf_pk['sleep']); $time = time(); }
if ($init == false) { $ch = curl_init($url); } else { $ch = $init; } curl_setopt($ch, CURLOPT_USERAGENT, $us_agent); @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 120); curl_setopt($ch, CURLOPT_REFERER, $refer); curl_setopt($ch, CURLOPT_COOKIEJAR, ENGINE_DIR.'/cache/cookie_pk.php'); curl_setopt($ch, CURLOPT_COOKIEFILE, ENGINE_DIR.'/cache/cookie_pk.php'); if ($conf_pk['proxy_type'] == '1' && $conf_pk['proxy'] != '') { curl_setopt($ch, CURLOPT_PROXY, $conf_pk['proxy']); } elseif ($conf_pk['proxy_type'] == '2' && $conf_pk['proxy'] != '') { curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5); curl_setopt($ch, CURLOPT_PROXY, $conf_pk['proxy']); } if ($redir) { curl_setopt($ch, CURLOPT_HEADER, 1); } else { curl_setopt($ch, CURLOPT_HEADER, 0); } if ($post) { curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $post); } if ($file_img && !$redir) { $fp = fopen($file_img, 'w'); curl_setopt($ch, CURLOPT_FILE, $fp); } $page = curl_exec($ch);
if ($file_img && !$redir) { fclose($fp); } if ($redir) { list($header, $page) = explode("\r\n\r\n", $page, 2); } $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if (($http_code == 301 || $http_code == 302) && !$redir) { return load_page($url, $refer, $file_img, $post, $ch, true); } elseif ($http_code == 301 || $http_code == 302) { $matches = array(); preg_match('/Location:(.*?)(\n|$)/is', $header, $matches); $url = @parse_url(trim($matches[1])); if (!$url) { $curl_redir = 0; return $page; } $last_url = parse_url(curl_getinfo($ch, CURLINFO_EFFECTIVE_URL)); if (!$url['scheme']) $url['scheme'] = $last_url['scheme']; if (!$url['host']) $url['host'] = $last_url['host']; if (!$url['path']) $url['path'] = $last_url['path']; $new_url = $url['scheme'].'://'.$url['host'].$url['path'].($url['query'] ? '?'.$url['query'] : ''); curl_setopt($ch, CURLOPT_URL, $new_url); $curl_redir++; return load_page($new_url, $refer, $file_img, $post, $ch); } else { $curl_redir = 0; @curl_close($ch); if ($file_img && !$redir) { if (is_array(@getimagesize($file_img))) { return true; } else { @unlink($file_img); return false; } } return $page; } }
function uploads_pic($urlcopy, $name, $refer, $tumb = '', $tumb_t = '', $wmo = '', $ico = '') { global $author, $news_id, $db, $conf_pk, $config;
if (!is_dir(ROOT_DIR."/uploads/posts/".FOLDER_PREFIX)) { @mkdir(ROOT_DIR."/uploads/posts/".FOLDER_PREFIX, 0777); @chmod(ROOT_DIR."/uploads/posts/".FOLDER_PREFIX, 0777); @mkdir(ROOT_DIR."/uploads/posts/".FOLDER_PREFIX."/thumbs", 0777); @chmod(ROOT_DIR."/uploads/posts/".FOLDER_PREFIX."/thumbs", 0777); }
$image_name_full = FOLDER_PREFIX."/".$name; $image_name_thumb = FOLDER_PREFIX."/thumbs/".$name;
if (!load_page($urlcopy, $refer, ROOT_DIR."/uploads/posts/".$image_name_full)) return false;
if ($ico == 'on_r' || $ico == 'on_b' || $ico == 'on_wh') { $imag_info = @getimagesize(ROOT_DIR."/uploads/posts/".$image_name_full); if ($imag_info[2] == 2) $imag_src = @imagecreatefromjpeg(ROOT_DIR."/uploads/posts/".$image_name_full); elseif ($imag_info[2] == 1) $imag_src = @imagecreatefromgif(ROOT_DIR."/uploads/posts/".$image_name_full); else $imag_src = @imagecreate($imag_info[0], $imag_info[1]);
if ($ico == 'on_r') { $imag_des = @imagecreatetruecolor($imag_info[0] - 155, $imag_info[1]); @imagecopy($imag_des, $imag_src, 0, 0, 0, 0, $imag_info[0] - 155, $imag_info[1]); } if ($ico == 'on_b') { $imag_des = @imagecreatetruecolor($imag_info[0], $imag_info[1] - 37); @imagecopy($imag_des, $imag_src, 0, 0, 0, 0, $imag_info[0], $imag_info[1] - 37); } if ($ico == 'on_wh') { if ($imag_info[0] <= $imag_info[1]) { $imag_des = @imagecreatetruecolor($imag_info[0], $imag_info[1] - 37); @imagecopy($imag_des, $imag_src, 0, 0, 0, 0, $imag_info[0], $imag_info[1] - 37); } else { $imag_des = @imagecreatetruecolor($imag_info[0] - 155, $imag_info[1]); @imagecopy($imag_des, $imag_src, 0, 0, 0, 0, $imag_info[0] - 155, $imag_info[1]); } } @imagejpeg($imag_des, ROOT_DIR."/uploads/posts/".$image_name_full, 100); @imagedestroy($imag_des); @imagedestroy($imag_src); }
if ($conf_pk['max_up_side'] != 0) { $imag = new thumbnail(ROOT_DIR."/uploads/posts/".$image_name_full); $imag->size_auto($conf_pk['max_up_side'], 0); $imag->jpeg_quality($conf_pk['jpeg_quality']); $imag->save(ROOT_DIR."/uploads/posts/".$image_name_full); }
if ($tumb != 0) { if (!isset($imag)) $imag = new thumbnail(ROOT_DIR."/uploads/posts/".$image_name_full); else $imag->thumbnail(ROOT_DIR."/uploads/posts/".$image_name_full); $imag->size_auto($tumb, $tumb_t); $imag->jpeg_quality($conf_pk['jpeg_quality']); $imag->save(ROOT_DIR."/uploads/posts/".$image_name_thumb); }
if ($wmo == 'on') { if (!isset($imag)) $imag = new thumbnail(ROOT_DIR."/uploads/posts/".$image_name_full); else $imag->thumbnail(ROOT_DIR."/uploads/posts/".$image_name_full); $imag->insert_watermark($config['max_watermark']); $imag->save(ROOT_DIR."/uploads/posts/".$image_name_full); }
@chmod(ROOT_DIR."/uploads/posts/".$image_name_full, 0666);
$row = $db->super_query("SELECT COUNT(*) as count FROM ".PREFIX."_images where author='$author' AND news_id='$news_id'"); if (!$row['count']) { $added_time = time() + ($config['date_adjust'] * 60); $inserts = $image_name_full; $db->query("INSERT INTO ".PREFIX."_images (images, author, news_id, date) values ('$inserts', '$author', '$news_id', '$added_time')"); } else { $row = $db->super_query("SELECT images FROM ".PREFIX."_images where author = '$author' AND news_id = '$news_id'"); if ($row['images'] == "") $listimages = array(); else $listimages = explode("|||", $row['images']); $listimages[] = $image_name_full; $row['images'] = implode("|||", $listimages); $db->query("UPDATE ".PREFIX."_images set images='{$row['images']}' where author = '$author' AND news_id = '$news_id'"); $db->free(); }
return "/uploads/posts/".$image_name_full; }
if ($_POST['id'] == 'list') {
$cooke_pk_time = @filemtime(ENGINE_DIR.'/cache/cookie_pk.tmp') + 60 * 60 * 24; if ($conf_pk['user'] != '' && $conf_pk['pass'] != '' && (time() >= $cooke_pk_time || !($coockeF = file_get_contents(ENGINE_DIR.'/cache/cookie_pk.php')) || strstr($coockeF, $conf_pk['user']) == false)) { $page = load_page('http://www.kinopoisk.ru/level/30/', 'http://www.kinopoisk.ru/level/30/', false, 'shop_user[login]='.$conf_pk['user'].'&shop_user[pass]='.$conf_pk['pass'].'&shop_user[mem]=on&auth=%E2%EE%E9%F2%E8+%ED%E0+%F1%E0%E9%F2'); }
if (!($refer = dle_cache('pkp_ref_'.$author))) $refer = 'http://www.kinopoisk.ru/'; $pars_list = load_page('http://www.kinopoisk.ru/index.php?first=no&what=&kp_query='.$film_name, $refer); create_cache('pkp_ref_'.$author, 'http://www.kinopoisk.ru/index.php?first=no&what=&kp_query='.$film_name); preg_match_all('#<p class="name">([^<]+)[^<]+<span class="year">([0-9]+)</span></p>#is', $pars_list, $link_film, PREG_SET_ORDER);
@header("Content-type: text/html; charset=".$config['charset']); echo "<div style=\"background: #ffc;border:1px solid #9E9E9E;padding: 5px;margin-top: 7px;margin-right: 10px;\">";
$list_film = ''; foreach ($link_film as $value) { $list_film .= '<li>'.$value[2].' ('.$value[3].') <img src="uploads/pkinopoisk/kinopoisk.ru.png" alt="Посмотреть на КиноПоиск" width="16" height="16" border="0"></li>'; } if ($list_film == '') { $filano = preg_match('/<script type="text\/javascript"> id_film = ([0-9]*?); <\/script>/si', $pars_list, $mach); if ($filano && $mach[1] != '') { $list_film = '<li>'.trim(convert_unicode($_POST['film_name'], $config['charset'])).' <img src="uploads/pkinopoisk/kinopoisk.ru.png" alt="Посмотреть на КиноПоиск" width="16" height="16" border="0"></li>'; } else { $list_film = 'По Вашему запросу фильмы не найдены'; } }
echo $list_film; echo "</div>"; } elseif ($_POST['idf'] == 'on' && is_numeric($_POST['id']) && $_POST['id'] > 0) { if ($conf_pk['user'] != '' && $conf_pk['pass'] != '' && (!($coockeF = file_get_contents(ENGINE_DIR.'/cache/cookie_pk.php')) || strstr($coockeF, $conf_pk['user']) == false)) { load_page('http://www.kinopoisk.ru/level/30/', 'http://www.kinopoisk.ru/level/30/', false, 'shop_user[login]='.$conf_pk['user'].'&shop_user[pass]='.$conf_pk['pass'].'&shop_user[mem]=on&auth=%E2%EE%E9%F2%E8+%ED%E0+%F1%E0%E9%F2'); }
if (!($refer = dle_cache('pkp_ref_'.$author))) $refer = 'http://www.kinopoisk.ru/'; if ($conf_pk['pars_trivia'] == 'on') { $url_p = 'http://www.kinopoisk.ru/level/1/film/'.$_POST['id'].'/view_info/ok/'; } else { $url_p = 'http://www.kinopoisk.ru/level/1/film/'.$_POST['id'].'/'; } $pars_film = load_page($url_p, $refer); create_cache('pkp_ref_'.$author, $url_p);
$pars_data = array( 'name_f' => '#<h1 style="margin: 0; padding: 0" class="moviename-big" itemprop="name">(.*?)</h1>#si', 'name_orig' => '#<span style="color: \#666; font-size: 13px" itemprop="alternativeHeadline">(.*?)</span>#si', 'year' => '#год</td>.*?<td class="[^>]+>.*?<div style="position: relative">(.*?)</div>#si', 'country' => '#страна</td>.*?<td class="[^>]+>.*?<div style="position: relative">(.*?)</div>#si', 'slogon' => '#слоган</td>.*?<td style="color: \#555">(.*?)</td>#si', 'director' => '#режиссер</td><td itemprop="director">(.*?)</td>#si', 'screenwriter' => '#сценарий</td><td>(.*?)</td>#si', 'producer' => '#продюсер</td><td itemprop="producer">(.*?)</td>#si', 'operator' => '#оператор</td><td>(.*?)</td>#si', 'composer' => '#композитор</td><td itemprop="musicBy">(.*?)</td>#si', 'genre' => '#жанр</td><td itemprop="genre">(.*?)</td>#si', 'budget' => '#бюджет</td>.*?<td class="[^>]+>.*?<div style="position: relative">(.*?)</div>#si', 'fees_use' => '#сборы в США</td>.*?<div style="position: relative">(.*?)</div>#si', 'fees_world' => '#сборы в мире</td>.*?<div style="position: relative">(.*?)</div>#si', 'fees_rus' => '#сборы в России</td>.*?<div style="position: relative">(.*?)</div>#si', 'premier' => '#премьера \(мир\)</td>.*?<div style="position: relative">(.*?)</div>#si', 'premier_rus' => '#премьера \(РФ\)</td>.*?<div style="position: relative">(.*?)</div>#si', 'reliz_dvd' => '#релиз на DVD</td>.*?<div style="position: relative">(.*?)</div>#si', 'time_film' => '#время</td><td class="time" id="runtime">(.*?)</td>#si', 'poster_film' => '#<td valign="top">.*?<img[^>]+src="((http://st.kinopoisk.ru)?/images/film/[0-9]+\.jpg)"[^>]+>.*?</td>#si', 'link_kadr' => '##si', 'description' => '#<span class="_reachbanner_">(.*?)</span>#si', 'kp_rating' => '#text-decoration: none">.*?<span>(.*?)</span>#si', 'kp_rating_num' => '#<span class="ratingCount" itemprop="ratingCount">(.*?)</span>#si', 'imdb' => '#IMDB:\s(.*?)\s.*?</div>#si', 'imdb_num' => '#IMDB:.*?\((.*?)\).*?</div>#si', 'reliz_bluray' => '#релиз на Blu-Ray</td>.*?<div style="position: relative">(.*?)</div>#si', 'trailer' => '#"trailerFile":[^"]{0,3}?"([^"]+)",#si', 'trivia' => '#Знаете ли вы, что...</td></tr>.*?<ul class="trivia">.*?<li class=\'trivia\'>(.*?)</ul>#si', 'poster_film_big' => '#<a.*?href="/film/([0-9]+)/posters/">#si', 'actors' => '#<span class="title">В главных ролях:</span>(.*?)(<span class="title">|</td>)#is', 'actors_dubl' => '#<span class="title">Роли дублировали:</span>(.*?)(<span class="title">|</td>)#is', 'rate_pg' => '#рейтинг MPAA</td><td class="rate_[^>]+>.*?<img src=[\'"]?[^>]+?/images/mpaa/(.*?)[\'"]? height=11 alt=[\'"]?рейтинг (.*?)[\'"]? border=0>.*?</td>#si', 'audience' => '#зрители</td>.*?<div style="position: relative">.*?<div style="margin-left: -20px;">(.*?)</div>#si' );
$rpl_s = array(' ', '<br>', '<br />'); $rpl_r = array(' ', '\n', '\n'); $prpl_s = array('##is', '#([\n]*|[\r]*|[\t]*)#is', '#[\s]+#is'); $prpl_r = array('</a>,', '', ' '); foreach ($pars_data as $name => $value) { @preg_match($value, $pars_film, $matches); if ($name == 'rate_pg' && count($matches) == 3) { $post_data[$name]['img'] = $matches[1]; $post_data[$name]['text'] = $matches[2]; continue; } elseif ($name == 'rate_pg') { $post_data[$name] = ''; continue; } elseif ($name == 'audience') { $post_data[$name] = trim($matches[1]); continue; } // elseif ($name == 'trailer') { // $post_data[$name] = $matches; // continue; // } $matches[1] = str_replace($rpl_s, $rpl_r, $matches[1]); // $matches[1] = html_entity_decode($matches[1], ENT_QUOTES); if ($name == 'actors' || $name == 'actors_dubl') { $matches[1] = preg_replace($prpl_s, $prpl_r, $matches[1]); } elseif ($name == 'trivia') { $matches[1] = str_replace('</li><li class=\'trivia\'>', '</li>\n<li class=\'trivia\'>', $matches[1]); } elseif ($name == 'premier' || $name == 'premier_rus') { $matches[1] = preg_replace('#([\n]*|[\r]*|[\t]*)#is', '', $matches[1]); $matches[1] = preg_replace('#([\s]{2,})#is', ' ', $matches[1]); } $matches[1] = strip_tags($matches[1]); if ($name == 'trivia' && $conf_pk['pars_trivia'] != 'on') { $matches[1] = preg_replace('#\(.{1,5}читать всё\)#is', '', $matches[1]); } $matches[1] = trim($matches[1]); if ($name == 'director' || $name == 'screenwriter' || $name == 'producer' || $name == 'operator' || $name == 'composer' || $name == 'genre' || $name == 'actors' || $name == 'actors_dubl' || $name == 'reliz_dvd' || $name == 'reliz_bluray') { $matches[1] = trim($matches[1], ' .,'); } $post_data[$name] = $matches[1]; unset($matches); }
//@header( "Content-type: text/html; charset=" . $config['charset'] ); //foreach ( $post_data as $kay => $val ) { // if ( $kay == 'rate_pg' && $val != '' ) echo $kay.' = "'.var_dump($val).'"<br />'."\n"; // else echo $kay.' = "'.$val.'"<br />'."\n"; //} //$post_data = array();
if ($conf_pk['pars_com'] > 0 && $conf_pk['sort_com'] == 'off') { $data_com_c = @preg_match_all('#<p id="ext_text_[0-9]+"><span class="_reachbanner_" onmouseup="getSelect.[0-9]+.">(.*?)</span></p>#is', $pars_film, $matches, PREG_SET_ORDER); $i = 0; foreach ($matches as $value) { $patt = array('/(\n\r|\n)?/im', '/<br.*?>/is', '/<b>/is', '/<\/b>/is', '/<i>/is', '/<\/i>/is'); $replac = array('', '\n', '[b]', '[/b]', '[i]', '[/i]'); $value[1] = preg_replace($patt, $replac, $value[1]); $value[1] = trim($value[1], " \t\n\r,"); $value[1] = strip_tags($value[1]);
$data_com[] = $value[1];
$i++; if ($i >= $conf_pk['pars_com']) { break; } } } elseif ($conf_pk['pars_com'] > 0 && $conf_pk['sort_com'] == 'on') { $data_com_c = @preg_match_all('#<p id="ext_text_[0-9]+"><span class="_reachbanner_" onmouseup="getSelect\([0-9]+\)">(.*?)</span></p>.{500,1100}<li id="comment_num_vote_[0-9]+">([0-9]+) / ([0-9]+)</li>#is', $pars_film, $matches, PREG_SET_ORDER);
$i = 0; foreach ($matches as $value) { $matches_sv['s'.$i] = $value[1]; if ($value[3] == 0) $value[3] = 1; $matches_ss['s'.$i] = $value[2] / $value[3];
$i++; } if (is_array($matches_ss)) { arsort($matches_ss); reset($matches_ss); $i = 0; foreach ($matches_ss as $kay => $value) { $patt = array('/(\n\r|\n)?/im', '/<br.*?>/is', '/<b>/is', '/<\/b>/is', '/<i>/is', '/<\/i>/is'); $replac = array('', '\n', '[b]', '[/b]', '[i]', '[/i]'); $matches_sv[$kay] = preg_replace($patt, $replac, $matches_sv[$kay]); $matches_sv[$kay] = trim($matches_sv[$kay], " \t\n\r,"); $matches_sv[$kay] = strip_tags($matches_sv[$kay]);
$data_com[] = $matches_sv[$kay];
$i++; if ($i >= $conf_pk['pars_com']) { break; } } } } else $post_data['comment'] = '';
if ($post_data['poster_film'] != '' && $conf_pk['pars_poster_film'] == 'on') { if (stripos($post_data['poster_film'], 'kinopoisk.ru') === false) $poster_film = 'http://www.kinopoisk.ru'.$post_data['poster_film']; else $poster_film = $post_data['poster_film']; $file_name = 'poster-'.$_POST['id'].'.jpg'; $file_name = time()."_".$file_name; if (!($poster_film_s = uploads_pic($poster_film, $file_name, $url_p) )) $poster_film_s = ''; }
function pars_imag($idfilm, $type, $col_imag = '', $tumb = '', $tumb_t = '', $wmo = '', $ico = '') { global $conf_pk, $url_p; static $url_p_i = '';
if ($url_p_i == '') $url_p_i = $url_p;
if ($type == 'screen') { $size_l_oboi = '/'; $url_link = 'http://www.kinopoisk.ru/level/13/film/'.$idfilm.'/adv_type/still/'; $sear_f = '<img[^>]+>'; } elseif ($type == 'poster') { $size_l_oboi = '/'; $url_link = 'http://www.kinopoisk.ru/level/17/film/'.$idfilm.'/'; $sear_f = '<img[^>]+>'; } elseif ($type == 'kadr') { $size_l_oboi = '/'; $url_link = 'http://www.kinopoisk.ru/level/13/film/'.$idfilm.'/'; $sear_f = '<img[^>]+>'; }
if (is_numeric($idfilm) && $col_imag > 0) {
$pars_oboi = load_page($url_link, $url_p_i); $url_p_i = $url_link; if (preg_match('|'.$sear_f.'|is', $pars_oboi, $matches_if)) {
$pars_img = load_page('http://www.kinopoisk.ru/picture/'.$matches_if[1].$size_l_oboi, $url_p_i); $url_p_fi = 'http://www.kinopoisk.ru/picture/'.$matches_if[1].$size_l_oboi; // preg_match('|<tr>.*?<td valign="top">.*?.*?<img.*?src="(.*?)"[^>]+>.*?.*?</td>.*?</tr>|is', $pars_img, $matches_l); preg_match('|<tr>.*?<td valign="top">.*?<img.*?src="(.*?)"[^>]+>.*?</td>.*?</tr>|is', $pars_img, $matches_l); $file_name = time()."_".$matches_if[1].'.jpg'; if ($ff = uploads_pic('http://st.kinopoisk.ru'.$matches_l[1], $file_name, $url_p_fi, $tumb, $tumb_t, $wmo, $ico)) $film_data[$matches_if[1]] = $ff; if (preg_match_all('|[0-9]+|is', $pars_img, $matches_ar, PREG_SET_ORDER)) {
if ($col_imag > 1) { $i = 2; foreach ($matches_ar as $link_n_img) { unset($matches_l); $pars_img = load_page('http://www.kinopoisk.ru/picture/'.$link_n_img[1].$size_l_oboi, $url_p_fi); $url_p_fi = 'http://www.kinopoisk.ru/picture/'.$link_n_img[1].$size_l_oboi; //preg_match('|<tr>.*?<td valign="top">.*?.*?<img.*?src="(.*?)"[^>]+>.*?.*?</td>.*?</tr>|is', $pars_img, $matches_l); preg_match('|<tr>.*?<td valign="top">.*?<img.*?src="(.*?)"[^>]+>.*?</td>.*?</tr>|is', $pars_img, $matches_l); $file_name = time()."_".$link_n_img[1].'.jpg'; if ($ff = uploads_pic('http://st.kinopoisk.ru'.$matches_l[1], $file_name, $url_p_fi, $tumb, $tumb_t, $wmo, $ico)) $film_data[$link_n_img[1]] = $ff; if ($i >= $col_imag) break; $i++; } } } } } else { return false; } return $film_data; }
if ($post_data['poster_film_big'] != '' && $conf_pk['pars_poster_film_big'] == 'on') { $data_bposter = pars_imag($_POST['id'], 'poster', 1, $conf_pk['tumb_poster'], $conf_pk['tumb_poster_type']); if (count($data_kadr_s) < 1) { $post_data['poster_film_big'] = $conf_pk['poster_film_alter']; } } else { $post_data['poster_film_big'] = ''; }
if ($post_data['link_kadr'] != '' && $conf_pk['kol_kadr'] > 0) { $data_kadr = pars_imag($_POST['id'], 'kadr', $conf_pk['kol_kadr'], $conf_pk['tumb_kadr'], $conf_pk['tumb_kadr_type'], $conf_pk['watermark_on'], $conf_pk['imag_cut']); }
if ($post_data['link_kadr'] != '' && $conf_pk['kol_scrin'] > 0) { $data_scrin = pars_imag($_POST['id'], 'screen', $conf_pk['kol_scrin'], $conf_pk['tumb_kadr'], $conf_pk['tumb_kadr_type'], $conf_pk['watermark_on'], $conf_pk['imag_cut']); }
$link_tags = $config["http_home_url"].'tags/';
function pkp_get_tags($text) { global $link_tags; $tags_l = array(); $tags = array(); if ($text != '') { $tags_array = explode(', ', $text); foreach ($tags_array as $value) { $value = trim($value); if (preg_match( "/[\||\'|\<|\>|\"|\!|\?|\$|\@|\/|\\\|\&\~\*\+]/", $value)) { $tags_l[] = $value; } else { $tags_l[] = '[url='.$link_tags.urlencode($value).'/]'.$value.'[/url]'; $tags[] = $value; } } $tags_l = implode(', ', $tags_l); $tags = implode(', ', $tags); } return array($tags_l, $tags); }
// $templ_title = str_replace('"', '"', $templ_title); // $templ_show = str_replace('"', '"', $templ_show); // $templ_full = str_replace('"', '"', $templ_full);
$templ_show = stripslashes($templ_show); $templ_full = stripslashes($templ_full); $templ_title = stripslashes($templ_title); if (count($templ_xfields)) { foreach ($templ_xfields as $name_x => $value_x) { $templ_xfields[$name_x][0] = stripslashes($value_x[0]); } }
$post_data['id_film'] = $_POST['id'];
if ($post_data['poster_film'] != '') $post_data['poster_film'] = $poster_film_s;
$post_data['screen_film'] = ''; if (count($data_kadr) > 0) { foreach ($data_kadr as $value) { $post_data['screen_film'] = $post_data["screen_film"].'[thumb]'.$value.'[/thumb] '; } }
$post_data['screen_film_scr'] = ''; if (count($data_scrin) > 0) { foreach ($data_scrin as $value) { $post_data['screen_film_scr'] = $post_data["screen_film_scr"].'[thumb]'.$value.'[/thumb] '; } }
if (count($data_bposter)) { foreach ($data_bposter as $value) { $post_data['poster_film_big'] = $value; } } if (!isset($post_data['poster_film_big'])) $post_data['poster_film_big'] = '';
if ($post_data['audience'] != '') { if ($conf_pk['aud_type'] == 'on') { $post_data['audience'] = preg_replace('#<img src="(http://st.kinopoisk.ru)?/images/flags/(.*?)" width=16 height=11[^>]+>#i', '[img=none]/uploads/pkinopoisk/flags/$2[/img]', $post_data['audience']); } else { $post_data['audience'] = preg_replace('/ /i', '', $post_data['audience']); $post_data['audience'] = preg_replace('#<img src="(http://st.kinopoisk.ru)?/images/flags/.*? title="(.*?)"[^>]+>#i', ' $2 - ', $post_data['audience']); } $post_data['audience'] = rtrim(strip_tags($post_data['audience']), ' .,'); }
if (is_array($post_data['rate_pg'])) { if ($conf_pk['rate_pg_type'] == 'on') { $post_data['rate_pg'] = '[img=none]/uploads/pkinopoisk/mpaa/'.$post_data['rate_pg']['img'].'[/img]'; } else { $post_data['rate_pg'] = $post_data['rate_pg']['text']; } }
if (!empty($post_data['trailer'])) { // if (!empty($post_data['trailer'][3])) // $post_data['trailer'][3] = $post_data['trailer'][3].'.kinopoisk.ru/'; // else // $post_data['trailer'][3] = 'tr.kinopoisk.ru/'; // if (!empty($post_data['trailer'][4])) // $post_data['trailer'][2] = $post_data['trailer'][4]; $post_data['trailer_link'] = 'http://tr.kinopoisk.ru/'.$post_data['trailer']; $post_data['trailer'] = '[video=http://tr.kinopoisk.ru/'.$post_data['trailer'].']'; } else { $post_data['trailer_link'] = ''; $post_data['trailer'] = ''; }
if (isset($data_com)) { $post_data['comment'] = ''; foreach ($data_com as $value) { $post_data['comment'] .= $value.'\n-------------------------------------------------------------------------------------\n'; } $post_data['comment'] = rtrim($post_data['comment'], '\n-'); } else $post_data['comment'] = '';
if ($conf_pk['imag_separ'] == 'on') { $ni = 1; if (count($data_kadr) > 0) { foreach ($data_kadr as $value) { $arrSear = array('[pkpgiven_screen_film_'.$ni.']', '[pkpvalue_screen_film_'.$ni.']', '[/pkpvalue_screen_film_'.$ni.']'); $arrRepl = array($value, '', ''); $templ_show = str_replace($arrSear, $arrRepl, $templ_show); $templ_full = str_replace($arrSear, $arrRepl, $templ_full); if (count($templ_xfields)) { foreach ($templ_xfields as $name_x => $value_x) { $templ_xfields[$name_x][0] = str_replace($arrSear, $arrRepl, $value_x[0]); } } $ni++; } } $ni = 1; if (count($data_scrin) > 0) { foreach ($data_scrin as $value) { $arrSear = array('[pkpgiven_screen_film_scr_'.$ni.']', '[pkpvalue_screen_film_scr_'.$ni.']', '[/pkpvalue_screen_film_scr_'.$ni.']'); $arrRepl = array($value, '', ''); $templ_show = str_replace($arrSear, $arrRepl, $templ_show); $templ_full = str_replace($arrSear, $arrRepl, $templ_full); if (count($templ_xfields)) { foreach ($templ_xfields as $name_x => $value_x) { $templ_xfields[$name_x][0] = str_replace($arrSear, $arrRepl, $value_x[0]); } } $ni++; } } $arrSear = array('#\[pkpgiven_screen_film_(scr_)?[0-9]+\]#i', '#\[pkpvalue_screen_film_(scr_)?[0-9]+\].*?\[/pkpvalue_screen_film_(scr_)?[0-9]+\]#i',); $arrRepl = array('', '', '', ''); $templ_show = preg_replace($arrSear, $arrRepl, $templ_show); $templ_full = preg_replace($arrSear, $arrRepl, $templ_full); if (count($templ_xfields)) { foreach ($templ_xfields as $name_x => $value_x) { $templ_xfields[$name_x][0] = preg_replace($arrSear, $arrRepl, $value_x[0]); } } }
$catSootSel = ''; if (count($catSoot) > 0) { $catSootSel = $post_data['genre']; foreach ($catSoot as $kay => $val) { $catSootSel = str_ireplace($kay, $val, $catSootSel); } $catSootSel = preg_replace('#[^0-9,]+#is', '', $catSootSel); if ($catSootSel != '') { $catSootSel = 'catSootSel(['.$catSootSel.']); '; } }
$tags = ''; $templ_xfields_sc = ''; foreach ($post_data as $name => $value) { // echo '"'.$name.'" => "'.htmlspecialchars($value).'"<br />'; $value = preg_replace('/\$/is', '\\\$', $value);
if ($conf_pk['del_tir'] == 'on') { if ($value == '-') $value = ''; }
$templ_title = preg_replace('/\[pkpgiven_'.$name.'\]/is', $value, $templ_title); if ($value != '') { $templ_title = preg_replace('/\[pkpvalue_'.$name.'\](.*?)\[\/pkpvalue_'.$name.'\]/is', '$1', $templ_title); } else { $templ_title = preg_replace('/\[pkpvalue_'.$name.'\].*?\[\/pkpvalue_'.$name.'\](\n|\r\n|)?/is', '', $templ_title); }
if ($conf_pk['t_'.$name] == 'on' && $value != '') { $value = preg_replace('/‘|’|(1(45|46)|39)[;]?|\'|'/', ' ', $value); $value = pkp_get_tags($value); if (!empty($value[1])) { $tags = $tags.$value[1].', '; } $value = $value[0]; }
$templ_show = preg_replace('/\[pkpgiven_'.$name.'\]/is', $value, $templ_show); if ($value != '') { $templ_show = preg_replace('/\[pkpvalue_'.$name.'\](.*?)\[\/pkpvalue_'.$name.'\]/is', '$1', $templ_show); } else { $templ_show = preg_replace('/\[pkpvalue_'.$name.'\].*?\[\/pkpvalue_'.$name.'\](\n|\r\n|)?/is', '', $templ_show); }
$templ_full = preg_replace('/\[pkpgiven_'.$name.'\]/is', $value, $templ_full); if ($value != '') { $templ_full = preg_replace('/\[pkpvalue_'.$name.'\](.*?)\[\/pkpvalue_'.$name.'\]/is', '$1', $templ_full); } else { $templ_full = preg_replace('/\[pkpvalue_'.$name.'\].*?\[\/pkpvalue_'.$name.'\](\n|\r\n|)?/is', '', $templ_full); } if (count($templ_xfields)) { foreach ($templ_xfields as $name_x => $value_x) { $value_x[0] = preg_replace('/\[pkpgiven_'.$name.'\]/is', $value, $value_x[0]); if ($value != '') { $value_x[0] = preg_replace('/\[pkpvalue_'.$name.'\](.*?)\[\/pkpvalue_'.$name.'\]/is', '$1', $value_x[0]); } else { $value_x[0] = preg_replace('/\[pkpvalue_'.$name.'\].*?\[\/pkpvalue_'.$name.'\](\n|\r\n|)?/is', '', $value_x[0]); } $templ_xfields[$name_x][0] = $value_x[0]; } } }
$tags = rtrim($tags, ' ,'); $patt = array( "/\n/im", '/\r/im', "/‘|’|(1(45|46)|39)[;]?|'|'|\"/im" ); $replac = array( '\n', '', "\\\'" );
$templ_title = preg_replace($patt, $replac, $templ_title); $templ_show = preg_replace($patt, $replac, $templ_show); $templ_full = preg_replace($patt, $replac, $templ_full);
if (count($templ_xfields)) { foreach ($templ_xfields as $name_x => $value_x) { $value_x = preg_replace($patt, $replac, $value_x); if ($value_x[1] == 'text') $templ_xfields_sc .= "post_xfield( '$name_x', '1', '$value_x[0]' ); "; elseif ($value_x[1] == 'textarea') $templ_xfields_sc .= "post_xfield( '$name_x', '2', '$value_x[0]' ); "; } }
$time_e = time() - $time_s;
@header("Content-type: text/html; charset=".$config['charset']); echo "<div style=\"background: #ffc;border:1px solid #9E9E9E;padding: 5px;margin-top: 7px;margin-right: 10px;\"><div style=\"display:none;\"><a href=\"http://partnertraffic.ru/\" title=\"Arttse (partnertraffic.ru)\">Partner Traffic</a></div>"; echo "Фильм загружен (заняло ".$time_e." сек.). Нажмите сюда чтобы оформить пост."; echo "</div>"; } ?> |
|