Esempio n. 1
0
function pick_get_user_info($args)
{
    extract($args);
    $url = $get_url;
    $content = get_contents($url, array('cookie' => $login_cookie, 'cache' => -1));
    if ($content == -1) {
        return -1;
    }
    //获取不到网页内容
    if (strexists($content, 'AccessDenied by limit')) {
        return -6;
    }
    $info_arr = dom_get_manytext($content, 'div#ct div.mn li');
    //获取用户名
    preg_match_all('/<title>(.*)' . milu_lang('the_user_info') . '/i', $content, $matchs);
    $username = str_iconv(trim($matchs[1][0]));
    if (!$info_arr) {
        if (strexists($content, 'alert_error')) {
            return -4;
        }
        return -2;
        //获取不到任何资料
    }
    if ($username && $username_chinese == 1) {
        $check_re = ischinese($username);
        if ($check_re != 'allcn' && $username_chinese == 1) {
            return -5;
        }
        //用户名不是中文
    }
    $info_field_arr = $member_field ? get_member_field($member_field, 2) : array();
    $all_field_arr = get_member_field(array(), 3);
    $i = 0;
    $ip_arr = array('regip', 'lastip');
    //ip字段
    foreach ((array) $info_arr as $k => $v) {
        preg_match('/<em>(.*)<\\/em>/is', $v, $v_arr);
        $v_name = $v_arr[1];
        $search_re = array_search($v_name, $all_field_arr);
        if (!$search_re) {
            continue;
        }
        $v = str_replace($v_arr[0], '', $v);
        $v = trim($v);
        $re_arr[$search_re] = $v;
        if ($info_field_arr) {
            $must_search_re = array_search($v_name, $info_field_arr);
            if ($must_search_re) {
                $must_arr[$must_search_re] = $v;
            }
        }
        if (in_array($search_re, $ip_arr)) {
            //IP字段
            $re_arr[$search_re] = str_replace(' -', '', $re_arr[$search_re]);
            $re_arr[$search_re] = trim($re_arr[$search_re]);
        }
    }
    if ($info_field_arr && (count($must_arr) != count($info_field_arr) || !$matchs[1][0])) {
        return -3;
    }
    //取不到所有必须资料
    $re_arr['username'] = $matchs[1][0];
    $re_arr = $must_arr ? array_merge($re_arr, $must_arr) : $re_arr;
    if (!$re_arr) {
        return -2;
    }
    return $re_arr;
}
Esempio n. 2
0
function dom_single_article($content = '', $dom_arr = '')
{
    $content = jammer_replace($content);
    if (!$content) {
        return;
    }
    $html = get_htmldom_obj($content);
    if (!$html) {
        return false;
    }
    if ($dom_arr['title']) {
        $div2 = $html->find('title');
        $re['other']['old_title'] = str_iconv($div2[0]->innertext);
        $re['title'] = dom_get_str($html, $dom_arr['title']);
        $re['other']['old_title'] = jammer_replace($re['other']['old_title'], 1);
        $re['title'] = jammer_replace($re['title'], 1);
        unset($div2);
    }
    $re['content'] = dom_get_str($html, $dom_arr['content']);
    $re['content'] = jammer_replace($re['content'], 1);
    $re['content'] = clear_ad_html($re['content']);
    $html->clear();
    unset($html);
    return $re;
}
Esempio n. 3
0
function fastpick_import()
{
    global $head_url, $header_config;
    if (!submitcheck('submit')) {
        $info['header'] = pick_header_output($header_config, $head_url);
        num_limit('strayer_fastpick', 3000, 'f_num_limit');
        return $info;
    } else {
        $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']);
        }
        //print_r($data);
        $arr = pimportfile($data);
        if (empty($arr['rules_name'])) {
            $arr['rules_name'] = $_G['timestamp'];
        }
        unset($arr['id'], $arr['version']);
        //销毁采集器记录的ID与 版本号
        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_fastpick') . " WHERE id='{$arr['id']}'"), 0);
        if ($check && !$update_flag) {
            if (!$rules_code) {
                $rules_code = $data;
            }
            cpmsg(milu_lang('cover_notice') . '?<input type="hidden" value="' . dstripslashes($rules_code) . '" name="rules_code">', PICK_GO . 'picker_manage&myfunc=rules_import&pid=' . $pid . '&addsubmit=1&update_flag=1', 'form');
        }
        $arr = get_table_field_name('strayer_fastpick', $arr);
        unset($arr['rid']);
        //去掉主键
        $arr = paddslashes($arr);
        if ($update_flag) {
            $rules_hash = $arr['rules_hash'];
            unset($arr['rules_hash']);
            DB::update('strayer_fastpick', $arr, array('rules_hash' => $rules_hash));
        } else {
            DB::insert('strayer_fastpick', $arr, TRUE);
        }
        del_search_index(1);
        cpmsg(milu_lang('import_finsh'), PICK_GO . "fast_pick&myac=fastpick_import", 'succeed');
    }
}
Esempio n. 4
0
function import_article()
{
    global $_G;
    $file_name = PICK_CACHE . '/temp_im.zip';
    if (!$_GET['checking']) {
        $tmp_name = str_iconv($_FILES['file']['tmp_name']);
        $fp = fopen($tmp_name, 'r');
        $data = fread($fp, $_FILES['file']['size']);
        $flag = file_put_contents($file_name, $data);
        cpmsg(milu_lang('import_article_loading'), PICK_GO . 'picker_manage&myac=import_article&checking=1&pid=' . $_GET['pid'], 'loading', '', false);
    }
    require_once libfile('class/zip');
    $zip_obj = new SimpleUnzip($file_name);
    $total = 0;
    foreach ($zip_obj->Entries as $k => $v) {
        $data = unserialize(base64_decode(dstripslashes($v->Data)));
        //print_r($data);exit();
        $total += import_article_data($data);
    }
    @unlink($file_name);
    cpmsg(milu_lang('import_article_success', array('c' => $total)), PICK_GO . "picker_manage", 'succeed');
}
Esempio n. 5
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;
}
Esempio n. 6
0
function pick_check()
{
    global $_G;
    if (!$_GET['checking']) {
        cpmsg(milu_lang('upgrade_checking'), PICK_GO . 'pick_info&ac=pick_check&checking=1', 'loading', '', false);
    }
    $zend_check = is_zend();
    if ($zend_check == -1) {
        cpmsg_error(lang('plugin/milu_pick', 'http_visit', array('file' => 'source/plugin/milu_pick/zend/zendcheck.php')));
    } else {
        if ($zend_check == -2) {
            cpmsg_error(lang('plugin/milu_pick', 'zend_enable'));
        }
    }
    $key_file = PICK_PATH . '/data/key.php';
    file_put_contents($key_file, $_G['timestamp']);
    if (!file_exists($key_file)) {
        cpmsg_error(milu_lang('dir_no_write', array('dir' => PICK_PATH . '/data')));
    }
    $get_site = GET_URL;
    $client_info = get_client_info();
    if (!$client_info || !$client_info['domain']) {
        cpmsg_error(milu_lang('lan_upgrage'));
    }
    $url = GET_URL . 'plugin.php?id=pick_user:upgrade&myac=upgrade_check&tpl=no&get_type=1&php_version=' . phpversion() . '&domain=' . urlencode($client_info['domain']) . '&dxc_version=' . $client_info['dxc_version'] . '&dxc_release=' . $client_info['dxc_release'] . '&siteurl=' . urlencode($client_info['siteurl']);
    $msg_arr = get_contents($url, array('cache' => -1));
    @unlink($key_file);
    if ($msg_arr < 0) {
        cpmsg_error(milu_lang('no_conn_up'));
    }
    $msg_arr = json_decode(base64_decode($msg_arr));
    $status = $msg_arr->status;
    if (!$status) {
        cpmsg_error(milu_lang('up_no_err'));
    }
    if ($status == -1) {
        cpmsg_error(milu_lang('up_no_free'));
    } else {
        if ($status == -2) {
            cpmsg_error(milu_lang('up_no_set_err'));
        } else {
            if ($status == -3) {
                cpmsg_error(milu_lang('up_newed'));
            } else {
                if ($status == -4 || !$msg_arr->key) {
                    cpmsg_error(milu_lang('no_normal_up'));
                } else {
                    $version_desc = base64_decode(dstripslashes($msg_arr->version_desc));
                    $msg_arr->version_filename = base64_decode(dstripslashes($msg_arr->version_filename));
                }
            }
        }
    }
    echo '<link href="' . PICK_URL . 'static/style.css?v=' . PICK_VERSION . '" rel="stylesheet" type="text/css" />';
    echo '<table class="tb tb2 ">
<tbody><tr class="header hover"><td>' . milu_lang('check_have_new') . '</td><td></td><td></td></tr>
<tr class="hover"><td>DXC ' . $msg_arr->version . milu_lang('version') . ' [Release ' . $msg_arr->version_dateline . ']</td><td><input type="button" class="btn" onclick="confirm(\'' . milu_lang('cofirm_up') . '\') ? window.location.href=\'?' . PICK_GO . 'pick_info&ac=pick_download&tpl=no&md5_total=' . $msg_arr->version_md5total . '&key=' . $msg_arr->key . '\' : \'\';" value="' . milu_lang('auto_up') . '"></td><td><a href="' . $msg_arr->version_filename . '" target="_blank">' . milu_lang('no_auto_up') . '</a></td></tr></tbody></table>';
    if ($version_desc) {
        $version_desc = $version_desc ? $version_desc : milu_lang('no_have');
        echo '<p class="partition">' . milu_lang('up_notice') . '</p><div id="show_upgrade_info" class="showmess"><p>' . str_iconv($version_desc) . '</p></div>';
    }
    exit;
}
Esempio n. 7
0
 function parse_page($type = 'content', $content = '')
 {
     $this->now_url = cnurl($this->now_url);
     if ($this->cache_time > 0 && ($message = load_cache($this->now_url)) || $content) {
         if ($content) {
             $message = $content;
         }
         $this->base_url = get_base_url($message);
         if (!$this->base_url) {
             $this->base_url = $this->now_url;
         }
         if ($type == 'content') {
             return $message;
         } else {
             if ($type == 'link') {
                 return _striplinks($message, $this->base_url);
             }
         }
     } else {
         $time_out = $this->pick_set['time_out'] ? $this->pick_set['time_out'] : 15;
         $error = milu_lang('unable_pick');
         if (!function_exists('fsockopen') && !function_exists('pfsockopen') && !function_exists('file_get_contents')) {
             show_pick_info($error, 'exit', $this->msg_args);
             return;
         }
         if (!function_exists('fsockopen') && !function_exists('pfsockopen')) {
             if (!function_exists('file_get_contents')) {
                 show_pick_info($error, 'exit', $this->msg_args);
                 return;
             }
             $content = file_get_contents($this->now_url);
             $content = str_iconv($content);
             return $content;
         }
         if (!$this->snoopy) {
             require_once PICK_DIR . '/lib/Snoopy.class.php';
             //这些配置摆列顺序不可以随意
             $this->snoopy = new Snoopy();
             $this->snoopy->maxredirs = $this->p_arr['max_redirs'] ? $this->p_arr['max_redirs'] : 3;
             $this->snoopy->expandlinks = TRUE;
             $this->snoopy->offsiteok = TRUE;
             //是否允许向别的域名重定向
             $this->snoopy->maxframes = 3;
             $this->snoopy->agent = $_SERVER['HTTP_USER_AGENT'];
             //不设置这里,有些网页没法获取
             $this->snoopy->referer = $this->now_url;
             $this->snoopy->rawheaders["COOKIE"] = $this->p_arr['login_cookie'];
             $this->snoopy->read_timeout = $time_out;
         }
         if ($type == 'content') {
             $this->snoopy->results = get_contents($this->now_url, array('cookie' => $this->p_arr['login_cookie'], 'max_redirs' => $this->p_arr['max_redirs'], 'time_out' => $time_out, 'cache' => $this->cache_time));
         } else {
             if ($type == 'link') {
                 if ($this->snoopy->fetchlinks($this->now_url)) {
                 }
             }
         }
         $this->base_url = get_base_url($this->snoopy->results);
         if (!$this->base_url) {
             $this->base_url = $this->now_url;
         }
         if ($this->snoopy->results) {
             cache_data($this->now_url, $this->snoopy->results, $this->cache_time);
         }
         return $this->snoopy->results;
     }
 }