Example #1
0
function pick_import()
{
    global $_G, $head_url, $header_config;
    if (!submitcheck('submit')) {
        num_limit('strayer_picker', 3000, 'p_num_limit');
        $info['header'] = pick_header_output($header_config, $head_url);
        return $info;
    } else {
        $rules_code = $_GET['rules_code'];
        $pick_cid = $_GET['pick_cid'];
        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 ($arr['rules_hash']) {
            cpmsg_error(milu_lang('import_error', array('url' => PICK_GO)));
        }
        if (!$arr['pick']['pid']) {
            cpmsg_error(milu_lang('rules_error_data', array('url' => PICK_GO)));
        }
        pick_import_data($arr, $pick_cid);
        cpmsg(milu_lang('import_finsh'), PICK_GO . "picker_manage", 'succeed');
    }
}
Example #2
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');
    }
}
Example #3
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;
}