Example #1
0
function import_evo_data($arr)
{
    global $_G;
    $arr = paddslashes($arr);
    $check = DB::result(DB::query("SELECT COUNT(*) FROM " . DB::table('strayer_evo') . " WHERE domain_hash='{$arr['domain_hash']}' AND detail_ID_hash='{$arr['detail_ID_hash']}' AND status='1'"), 0);
    if ($check) {
        return;
    }
    //删除之前的一些记录
    DB::query('DELETE FROM ' . DB::table('strayer_evo') . " WHERE domain_hash='{$arr['domain_hash']}' AND detail_ID_hash='{$arr['detail_ID_hash']}' AND status='0'");
    $arr['dateline'] = $_G['timestamp'];
    $arr['hit_num'] = 1;
    $arr['status'] = 1;
    $arr = get_table_field_name('strayer_evo', $arr);
    unset($arr['id']);
    //去掉主键
    del_search_index(3);
    return DB::insert('strayer_evo', $arr, TRUE);
}
Example #2
0
 function evo_set($info)
 {
     global $_G;
     if (!$info) {
         return;
     }
     if (strlen($info['text']['html']) < 200 || strlen($info['title']['html']) < 10) {
         return;
     }
     //标题和内容太短都不行
     $link_count = own_link_count($info['text']['html'], $this->url);
     if ($link_count > 10) {
         return FALSE;
     }
     //有10个指向自己的链接,就不行
     $milu_set = pick_common_get();
     if ($milu_set['fp_open_evo'] != 1) {
         return FALSE;
     }
     $text_info = $this->dom_info_arr[$info['text']['key']];
     $title_info = $this->dom_info_arr[$info['title']['key']];
     $text_info['html'] = $info['text']['html'];
     $title_info['html'] = $info['title']['html'];
     $info['title_split_arr'] = $this->get_split_arr($title_info);
     $info['text_split_arr'] = $split_arr = $this->get_split_arr($text_info);
     unset($text_info['outertext'], $text_info['parent']['outertext'], $title_info['outertext'], $title_info['parent']['outertext'], $text_info['html'], $title_info['html']);
     if (strlen($split_arr[0]) < 14) {
         return FALSE;
     }
     pload('F:copyright');
     $host_info = GetHostInfo($this->url);
     $domain = $host_info['host'];
     $domain_hash = md5($domain);
     if (preg_match('/\\d+/', $split_arr[0])) {
         $s_arr = preg_split("/[\\d]+/", $split_arr[0]);
         $split_arr[0] = $s_arr[0];
         foreach ((array) $s_arr as $k => $v) {
             if (strlen($v) > strlen($split_arr[0])) {
                 $split_arr[0] = $v;
             }
         }
     }
     if (!$title_info) {
         return FALSE;
     }
     $result_info['evo_title_info'] = $title_info;
     $setarr = array('content_get_type' => 0, 'detail_ID' => $split_arr[0], 'detail_ID_hash' => md5($split_arr[0]), 'detail_ID_test' => $this->url, 'content_rules' => '', 'evo_text_info' => serialize($text_info), 'evo_title_info' => serialize($title_info), 'domain_hash' => $domain_hash, 'domain' => $domain, 'status' => 0, 'dateline' => $_G['timestamp']);
     $setarr = paddslashes($setarr);
     $base_sql = "SELECT * FROM " . DB::table('strayer_evo') . " WHERE domain_hash='{$domain_hash}' AND detail_ID_hash='" . $setarr['detail_ID_hash'] . "' AND status=0";
     $data_info = DB::fetch_first($base_sql . " AND detail_ID_test!='{$this->url}'");
     $data_info = pstripslashes($data_info);
     if (!$data_info) {
         //还没有资料
         if (!($check = DB::result(DB::query("SELECT COUNT(*) FROM " . DB::table('strayer_evo') . " WHERE domain_hash='{$domain_hash}' AND detail_ID_hash='" . $setarr['detail_ID_hash'] . "' AND status=0 AND detail_ID_test='{$this->url}'"), 0))) {
             DB::insert('strayer_evo', $setarr, TRUE);
         }
         $result_info['status'] = 'no';
         return $result_info;
     } else {
         //有了资料
         $title_rules = $this->get_rules($info, $title_info, $data_info, 'title');
         $text_rules = $this->get_rules($info, $text_info, $data_info, 'text');
         //删除之前的一些记录,防止没有索引的情况下重复生成规则
         $check_info = DB::fetch_first("SELECT * FROM " . DB::table('strayer_evo') . " WHERE domain_hash='{$domain_hash}' AND detail_ID_hash='" . $setarr['detail_ID_hash'] . "' AND status=1");
         DB::query('DELETE FROM ' . DB::table('strayer_evo') . " WHERE id='{$check_info['id']}'");
         DB::query('DELETE FROM ' . DB::table('strayer_searchindex') . " WHERE id='{$check_info['id']}' AND type='34'");
         if ($text_rules) {
             $setarr = array('content_get_type' => $text_rules['get_type'], 'content_rules' => $text_rules['rules'], 'theme_get_type' => $title_rules['get_type'], 'theme_rules' => $title_rules['rules'], 'status' => 1);
             DB::update("strayer_evo", $setarr, array("id" => $data_info['id']));
             $pash_hash = get_path_hash($this->url);
             add_search_index($domain_hash, $path_hash, 34, $data_info['id']);
             //添加索引 4是本地缓存
             $pick_set = get_pick_set();
             if ($pick_set['open_cloud_pick'] == 1) {
                 //开启云采集,将规则上传到服务端
                 $rpcClient = rpcClient();
                 unset($setarr['status']);
                 $data_info['content_get_type'] = $setarr['content_get_type'];
                 $data_info['content_rules'] = $setarr['content_rules'];
                 $data_info['theme_get_type'] = $setarr['theme_get_type'];
                 $data_info['theme_rules'] = $setarr['theme_rules'];
                 $client_info = get_client_info();
                 $re = $rpcClient->upload_evo_data($data_info, $client_info);
             }
             del_search_index(3);
             $result_info['status'] = 'ok';
             return $result_info;
         }
     }
 }
Example #3
0
function pick_match_rules()
{
    $url = format_url($_GET['url']);
    d_s();
    $content = get_contents($url);
    $v = match_rules($url, $content, 2, 0);
    if (!$v || !is_array($v)) {
        $v = pick_match_coloud_rules($url);
        if ($v['data_type'] == 1) {
            pload('F:rules');
            $v = $v['data'];
            rules_add($v);
            del_search_index(2);
        }
    }
    if (!$v || !is_array($v)) {
        return 'no';
    }
    $re_arr = array($v['rules_type'], $v['rules_hash']);
    return json_encode($re_arr);
}
Example #4
0
function rules_import()
{
    global $_G, $header_config, $head_url;
    $data['header'] = pick_header_output($header_config, $head_url);
    $submit = $_GET['addsubmit'];
    $update_flag = $_GET['update_flag'];
    num_limit('strayer_rules', 3000, 's_num_limit');
    if ($submit) {
        $rules_code = $_GET['rules_code'];
        if ($rules_code) {
            $data = $rules_code;
        } else {
            $file_name = str_iconv($_FILES['rules_file']['tmp_name']);
            $fp = fopen($file_name, 'r');
            $data = fread($fp, $_FILES['rules_file']['size']);
        }
        $arr = pimportfile($data);
        //采集器名称为空,则对将当前的时间戳做为采集器文件名
        if (empty($arr['rules_name'])) {
            $arr['rules_name'] = $_G['timestamp'];
        }
        unset($arr['rid'], $arr['version']);
        //销毁采集器记录的ID与 版本号
        $arr = daddslashes($arr);
        //对值重新addslashes操作
        if ($arr['pick']['pid']) {
            cpmsg_error(milu_lang('import_error2', array('url' => PICK_GO)));
        }
        if (!$arr['rules_hash']) {
            cpmsg_error(milu_lang('rules_error_data'));
        }
        $check = DB::result(DB::query("SELECT COUNT(*) FROM " . DB::table('strayer_rules') . " WHERE rules_hash='{$arr['rules_hash']}'"), 0);
        if ($check && !$update_flag) {
            if (!$rules_code) {
                $rules_code = $data;
            }
            cpmsg(milu_lang('cover_notice') . '?<input type="hidden" value="' . dstripslashes($data) . '" name="rules_code">', PICK_GO . 'system_rules&myac=rules_import&pid=' . $pid . '&addsubmit=1&update_flag=1', 'form');
        }
        $arr = get_table_field_name('strayer_rules', $arr);
        unset($arr['rid']);
        //去掉主键
        if ($update_flag) {
            $rules_hash = $arr['rules_hash'];
            rules_update($rules_hash);
            unset($arr['rules_hash']);
            DB::update('strayer_rules', $arr, array('rules_hash' => $rules_hash));
        } else {
            DB::insert('strayer_rules', $arr, TRUE);
        }
        del_search_index(2);
        cpmsg(milu_lang('import_finsh'), PICK_GO . "system_rules&myac=rules_list", 'succeed');
    }
    return $data;
}