Exemplo n.º 1
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;
}
Exemplo n.º 2
0
function get_other_info($content, $args)
{
    if (!$content) {
        return false;
    }
    extract($args);
    if (!$from_get_rules && !$author_get_rules && !$dateline_get_rules) {
        return false;
    }
    $html = get_htmldom_obj($content);
    if (!$html) {
        return false;
    }
    if ($from_get_rules) {
        if ($from_get_type == 1) {
            $re['from'] = dom_get_str($html, $from_get_rules);
        } else {
            $re['from'] = str_get_str($content, $from_get_rules, 'data');
        }
    }
    if ($author_get_rules) {
        if ($author_get_type == 1) {
            $re['author'] = dom_get_str($html, $author_get_rules);
        } else {
            $re['author'] = str_get_str($content, $author_get_rules, 'data');
        }
    }
    if ($dateline_get_rules) {
        if ($dateline_get_type == 1) {
            $re['article_dateline'] = dom_get_str($html, $dateline_get_rules);
            unset($div);
        } else {
            $re['article_dateline'] = str_get_str($content, $dateline_get_rules, 'data');
        }
    }
    foreach ((array) $re as $k => $v) {
        $re[$k] = format_html($v);
    }
    $html->clear();
    unset($html);
    return $re;
}
Exemplo n.º 3
0
 function get_article($content, $url = '')
 {
     global $_G;
     $url = $url ? $url : $this->now_url;
     $pick_config = $_G['cache']['evn_milu_pick']['pick_config'];
     require_once libfile('function/home');
     if ($this->temp_arr['have_page'] != 1) {
         $this->a++;
         $this->pick_cache_data['a'] = $this->a;
     }
     if ($this->p_arr['rules_type'] == 3) {
         //一键采集
         $article_info = get_single_article($content, $url);
     } else {
         //先取标题
         if ($this->p_arr['theme_get_type'] == 3) {
             //智能识别
             $article_info = get_single_article($content, $url);
         } else {
             if ($this->p_arr['theme_get_type'] == 1) {
                 //dom获取
                 $article_info = dom_single_article($content, array('title' => $this->p_arr['theme_rules']));
             } else {
                 if ($this->p_arr['theme_get_type'] == 2) {
                     //字符串
                     $re = pregmessage($content, '<title>[title]</title>', 'title', -1);
                     $article_info['other']['old_title'] = $re[0];
                     $article_info['title'] = str_get_str($content, $this->p_arr['theme_rules'], 'title', -1);
                 }
             }
         }
         //标题要做额外的工作,清理掉多余的html
         $article_info['title'] = format_html($article_info['title']);
         if (!trim($article_info['title'])) {
             return $article_info;
         }
         //如果标题都取不到,不必浪费时间获取内容
         //再取内容
         if ($this->p_arr['content_get_type'] == 3) {
             //智能识别
             if ($this->p_arr['theme_get_type'] != 3) {
                 $info_arr = get_single_article($content, $url);
                 $article_info['content'] = $info_arr['content'];
             }
         } else {
             if ($this->p_arr['content_get_type'] == 1) {
                 //dom获取
                 $info_arr = dom_single_article($content, array('content' => $this->p_arr['content_rules']));
                 $article_info['content'] = $info_arr['content'];
             } else {
                 if ($this->p_arr['content_get_type'] == 2) {
                     //字符串
                     $article_info['content'] = str_get_str($content, $this->p_arr['content_rules'], 'body', -1);
                 }
             }
         }
         if (!$article_info['content'] && $pick_config['ask_mode'] == 1) {
             $article_info['content'] = $article_info['title'];
         }
         //取其他内容
         $other_arr = $this->get_article_other($content);
         $other_arr = $other_arr ? $other_arr : array();
         $article_info = array_merge($article_info, $other_arr);
     }
     //附件
     if ($this->p_arr['is_download_file'] == 1) {
         $article_info['content'] = attach_format($url, $article_info['content']);
     }
     //需要回复才能看到的内容
     if (VIP) {
         $article_info['content'] = post($article_info['content'], array('cookie' => $this->p_arr['login_cookie'], 'page_url' => $url));
     }
     $article_info['content'] = format_html($article_info['content']);
     $article_info['content'] = unhtmlentities($article_info['content']);
     $article_info['url'] = $url;
     $article_info['content'] = clear_ad_html($article_info['content']);
     $article_info['content'] = getstr($article_info['content'], 0, 1, 1, 0, 1);
     return $article_info;
 }