예제 #1
0
function get_single_article($content, $url, $args = array())
{
    global $_G;
    extract($args);
    if (strlen(trim($content)) < 1) {
        return;
    }
    d_s('evo');
    $get_type = $_GET['get_type'] ? intval($_GET['get_type']) : $get_type;
    $get_type = $get_type ? $get_type : 1;
    $milu_set = pick_common_get();
    $rules_info = match_rules($url, $content, $get_type, 0);
    if (is_array($rules_info)) {
        pload('F:fastpick');
        $data = rules_get_article($content, $rules_info);
        write_evo_errlog($data, $url, $rules_info);
    } else {
        $data = (array) cloud_match_rules($get_type, $url, $content);
        //从云端下载规则 这里应该做点优化,暂时没想到方法。
        if (!$data['content'] && $milu_set['fp_open_auto'] == 1) {
            //开启智能获取
            pload('C:HtmlExtractor');
            pload('F:article');
            $he = new HtmlExtractor($content, $url);
            $data = (array) $he->get_text();
            $data['content'] = dz_attach_format($url, $data['content']);
            $arr = format_article_imgurl($url, $data['content']);
            $data['content'] = $arr['message'];
            $del_dom_rules = array('div[id*=share]', 'div[class*=page]');
            foreach ($del_dom_rules as $k => $v) {
                $data['content'] = dom_filter_something($data['content'], $v, 2);
            }
            unset($data['evo_title_info']);
        }
    }
    if ($_GET['type'] == 'bbs') {
        $data['content'] = media_htmlbbcode($data['content'], $url);
        $data['content'] = img_htmlbbcode($data['content'], $url);
    }
    $data['evo_time'] = d_e(0, 'evo');
    return $data;
}
예제 #2
0
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;
}
예제 #3
0
 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;
 }