Esempio n. 1
0
function evo_rules_get_article($str, $rules_info)
{
    $rules_info['theme_get_type'] = $rules_info['theme_get_type'] ? $rules_info['theme_get_type'] : 1;
    $get = 0;
    if ($rules_info['theme_get_type'] == 1 && $rules_info['content_get_type'] == 1) {
        $re = dom_single_article($str, array('title' => $rules_info['theme_rules'], 'content' => $rules_info['content_rules']));
        $data['title'] = $re['title'];
        $data['content'] = $re['content'];
        $get = 1;
    }
    if ($get != 1) {
        if ($rules_info['theme_get_type'] == 1) {
            $re = dom_single_article($str, array('content' => $rules_info['content_rules']));
            $data['title'] = $re['title'];
        } else {
            if ($rules_info['theme_get_type'] == 2) {
                $re = pregmessage($str, $rules_info['theme_rules'], 'title', -1);
                $data['title'] = $re[0];
            }
        }
        if ($rules_info['content_get_type'] == 1) {
            $re = dom_single_article($str, array('content' => $rules_info['content_rules']));
            $data['content'] = $re['content'];
        } else {
            if ($rules_info['content_get_type'] == 2) {
                $data['content'] = str_get_str($str, $rules_info['content_rules'], 'body', -1);
            }
        }
    }
    //过滤
    if ($rules_info['is_fiter_title'] == 1 && $data['title']) {
        $format_args = array('is_fiter' => $rules_info['is_fiter_title'], 'show_type' => 'title', 'result_data' => $data['title'], 'replace_rules' => $rules_info['title_replace_rules'], 'filter_data' => dunserialize($rules_info['title_filter_rules']), 'test' => 2, 'filter_html' => '');
        $data['title'] = filter_article($format_args);
    }
    if ($rules_info['is_fiter_content'] == 1 && $data['content']) {
        $format_args = array('is_fiter' => $rules_info['is_fiter_content'], 'show_type' => 'body', 'result_data' => $data['content'], 'replace_rules' => $rules_info['content_replace_rules'], 'filter_data' => dunserialize($rules_info['content_filter_rules']), 'test' => 2, 'filter_html' => dunserialize($rules_info['content_filter_html']));
        $data['content'] = filter_article($format_args);
    }
    return $data;
}
Esempio n. 2
0
         if ($page_get_type == 'dom') {
             $link_arr = dom_page_link($range_arr[0], $arr);
         } else {
             $link_arr = regexp_page_link($range_arr[0], $arr['page_link_rules']);
         }
     } else {
         $auto = $auto == 'yes' ? true : false;
         $link_arr = get_url_range($arr['url_page_range'], $auto);
     }
 }
 $url = url_auto($link_arr[0]);
 if ($arr['url']) {
     $url = $arr['url'];
 }
 if ($arr['article_get_type'] == 'dom') {
     $a_info = dom_single_article($url, array('title' => $arr['title'], 'content' => $arr['content']));
 } else {
     if ($arr['article_get_type'] == 'regexp') {
         $a_info = regexp_single_article($url, array('title' => $arr['title'], 'content' => $arr['content']));
     } else {
         $a_info = get_single_article($url);
     }
 }
 if ($a_info['content'] || $a_info['title']) {
     if ($a_info['content'] == 'list') {
         $a_info['content'] = milu_lang('article_too_many_link');
     }
     $html = '<h3><strong>' . milu_lang('article_link') . ':</strong></h3><a target="_blank"  href="' . $url . '">' . $url . '</a><br><br><h3><strong>' . milu_lang('article_title') . ':</strong></h3>' . $a_info['title'] . '<br><br><h3><strong>' . milu_lang('article_body') . ':</strong><br></h3>' . $a_info['content'] . '<br>';
 } else {
     $html = milu_lang('no_get_content');
 }
Esempio n. 3
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;
}
Esempio n. 4
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;
 }