function test_window($get_type, $url_test, $is_fiter, $rules, $replace_rules, $filter_data, $show_type, $login_cookie, $filter_html_arr) { $url_test = rpc_str($url_test); $rules = rpc_str($rules); $replace_rules = rpc_str($replace_rules); $login_cookie = rpc_str(urlencode($login_cookie)); foreach ($filter_data as $k => $v) { if ($v) { $filter_data[$k][1] = rpc_str($v[1]); } } $filter_html_arr = sarray_unique($filter_html_arr); //去重 if ($show_type == 'title') { $show_name = milu_lang('title'); } else { if ($show_type == 'body') { $show_name = milu_lang('body'); } else { $show_name = milu_lang('reply'); } } $contents = get_contents($url_test, array('cookie' => $login_cookie)); $contents = dz_attach_format($url_test, $contents); $c_arr = format_article_imgurl($url_test, $contents); $contents = $c_arr['message']; if ($get_type == 1) { //dom if ($show_type == 'reply') { $result_data = dom_get_manytext($contents, $rules); } else { if ($show_type == 'title') { $dom_rules['title'] = $rules; } else { $dom_rules['content'] = $rules; } $re = dom_single_article($contents, $dom_rules); $result_data = $show_type == 'title' ? $re['title'] : $re['content']; } } else { if ($get_type == 2) { //字符串 if ($contents != -1) { if ($show_type == 'reply') { $rules = str_replace('[body]', '[reply]', $rules); $result_data = str_get_str($contents, $rules, $show_type, -1); unset($result_data[0]); } else { $result_data = str_get_str($contents, $rules, $show_type, 1); } } } else { //智能获取 if ($contents != -1) { $re = get_single_article($contents, $url_test); if ($show_type == 'title') { $result_data = $re['title']; } else { $result_data = $re['content']; } } } } if ($result_data == -1) { echo milu_lang('unable_pick'); return; } else { if ($result_data == -2) { echo milu_lang('get_time_out'); return; } } if (!$result_data) { echo milu_lang('no_get_data') . $show_name; return; } $format_args = array('is_fiter' => $is_fiter, 'show_type' => $show_type, 'result_data' => $result_data, 'replace_rules' => $replace_rules, 'filter_data' => $filter_data, 'test' => 1, 'filter_html' => $filter_html_arr); $result_data = filter_article($format_args); if ($show_type == 'reply') { $body = show_reply_output($result_data); } else { $body .= $result_data; } $body .= $notice; echo $body; }
function rules_get_article($content, $rules_info) { $url = $_GET['url']; $rules_info = pstripslashes($rules_info); $rules_info['title_filter_rules'] = dstripslashes(unserialize($rules_info['title_filter_rules'])); $rules_info['content_filter_rules'] = dstripslashes(unserialize($rules_info['content_filter_rules'])); require_once libfile('function/home'); //先取标题 if ($rules_info['theme_get_type'] == 3) { //智能识别 $data = get_single_article($content); } else { if ($rules_info['theme_get_type'] == 1) { //dom获取 $data = dom_single_article($content, array('title' => $rules_info['theme_rules'])); } else { if ($rules_info['theme_get_type'] == 2) { //字符串 $re = pregmessage($content, '<title>[title]</title>', 'title', -1); $data['other']['old_title'] = $re[0]; $re = pregmessage($content, $rules_info['theme_rules'], 'title', -1); $data['title'] = $re[0]; } } } if (!trim($data['title'])) { return $data; } //如果标题都取不到,不必浪费时间获取内容 $data['content'] = rules_get_contents($content, $rules_info); if ($rules_info['content_page_rules'] && $data['content']) { //分页文章 $content_page_arr = get_content_page($url, $content, $rules_info); if ($content_page_arr) { $args = array('oldurl' => array(), 'content_arr' => array(), 'content_page_arr' => $content_page_arr, 'page_hash' => array(), 'rules' => $rules_info, 'url' => $url); $data['content_arr'] = page_get_content($content, $args); foreach ((array) $data['content_arr'] as $k => $v) { $content_arr[] = $v['content']; } $data['content'] = implode('', $content_arr); } } $data['title'] = unhtmlentities(strip_tags($data['title'], ' ')); $data['content'] = unhtmlentities($data['content']); $data['title'] = getstr(trim($data['title']), 80, 1, 1, 0, 1); $data['content'] = getstr($data['content'], 0, 1, 1, 0, 1); //print_r($data); //处理文章标题和内容,包括替换和过滤 $format_args_title = array('is_fiter' => $rules_info['is_fiter_title'], 'show_type' => 'title', 'test' => 2, 'result_data' => $data['title'], 'replace_rules' => $rules_info['title_replace_rules'], 'filter_data' => $rules_info['title_filter_rules']); $data['title'] = filter_article($format_args_title); $data['content'] = dstripslashes($data['content']); $format_args_content = array('is_fiter' => $rules_info['is_fiter_content'], 'show_type' => 'title', 'test' => 2, 'filter_html' => dunserialize($rules_info['content_filter_html']), 'result_data' => $data['content'], 'replace_rules' => $rules_info['content_replace_rules'], 'filter_data' => $rules_info['content_filter_rules']); $data['content'] = filter_article($format_args_content); //$data['content'] = dz_attach_format($url, $data['content']); $format_arr = format_article_imgurl($url, $data['content']); $data['content'] = $format_arr['message']; //$data['content'] = media_htmlbbcode($data['content'], $url); unset($data['other']); return $data; }
function format_reply($reply_data) { if (!$this->base_url) { $this->base_url = $this->now_url; } foreach ($reply_data as $k => $v) { //附件 $v = dz_attach_format($this->base_url, $v); if ($this->p_arr['is_download_file'] == 1) { $v = attach_format($this->base_url, $v); } $v = media_format($v, $this->base_url); // $format_arr = format_article_imgurl($this->base_url, $v); //处理图片路径 $reply_data[$k] = $format_arr['message']; } $reply_filter_html = $this->p_arr['reply_filter_html']; if ($this->p_arr['is_download_file'] == 1) { $a_key = array_search('0', $reply_filter_html); if (!$a_key) { unset($reply_filter_html[$a_key]); } //如果要下载附件,不要去除a标签 } $format_args = array('is_fiter' => $this->p_arr['is_fiter_reply'], 'show_type' => 'reply', 'test' => 2, 'result_data' => $reply_data, 'replace_rules' => $this->p_arr['reply_replace_rules'], 'filter_html' => $reply_filter_html, 'filter_data' => $this->p_arr['reply_filter_rules']); $reply_data = filter_article($format_args); return $reply_data; }