function cloud_match_rules($get_type, $url, $content) { global $_G; pload('F:fastpick'); $setting = get_pick_set(); $pick_config = $_G['cache']['evn_milu_pick']['pick_config']; $server_cache_time = $pick_config['index_server_cache_time']; if ($get_type == '3') { //智能学习规则索引过期时间比较短 $server_cache_time = $pick_config['evo_index_server_cache_time']; } $milu_set = pick_common_get(); if ($setting['open_cloud_pick'] != 1) { return FALSE; } pload('F:copyright'); $host_info = GetHostInfo($url); $domain = $host_info['host']; $domain_hash = md5($domain); $url_temp = preg_replace('/\\d+/', '', $url); $arr_temp = parse_url($url_temp); $path_hash = md5($arr_temp['path']); $over_dateline = $_G['timestamp'] - $server_cache_time; $count = DB::result(DB::query("SELECT COUNT(*) FROM " . DB::table('strayer_searchindex') . " WHERE domain_hash='" . $domain_hash . "' AND path_hash='" . $path_hash . "' AND type='" . $get_type . "3' AND dateline > {$over_dateline}"), 0); //3是服务端 4是本地的缓存 if ($count) { return FALSE; } $args = array('get_type' => $get_type, 'url' => $url); $rpcClient = rpcClient(); $client_info = get_client_info(); $re = $rpcClient->cloud_match_rules($args, $client_info); if (is_object($re) || $re->Number == 0) { if ($re->Message) { return milu_lang('phprpc_error', array('msg' => $re->Message)); } $re = (array) $re; } $data = array(); if ($re['data_type'] == 1) { //返回规则 $rules_info = $re['data']; if ($get_type == 3) { $data = evo_rules_get_article($content, $rules_info); } else { $data = rules_get_article($content, $rules_info); } if ($data || $data['content'] && $get_type == 3) { //规则验证有效,下载到本地 if ($get_type == 3) { $data_id = import_evo_data($rules_info); } else { $data_id = import_fastpick_data($rules_info); } if ($data_id) { //先清除之前的索引 DB::query('DELETE FROM ' . DB::table('strayer_searchindex') . " WHERE domain_hash='" . $domain_hash . "' AND path_hash='" . $path_hash . "'"); add_search_index($domain_hash, $path_hash, $get_type . '4', $data_id); //添加索引 } } } else { if ($re['data_type'] == 2) { //返回内容 $data = $re['data']; } else { //一无所获,那也要告诉客户端,别再骚扰服务端了 add_search_index($domain_hash, $path_hash, $get_type . '3', 0); } } return $data; }
function download_fast_pick_data() { $id = intval($_GET['id']); $rpcClient = rpcClient(); $client_info = get_client_info(); $re = $rpcClient->download_data('fastpick', $id, $client_info); if (is_object($re) || $re->Number == 0) { if ($re->Message) { return milu_lang('phprpc_error', array('msg' => $re->Message)); } $re = (array) $re; } $re = serialize_iconv($re); import_fastpick_data($re); return 'ok'; }