private function getProject($bind = ['Base']) { if (I("get.project_id")) { $this->project_id = I("get.project_id"); if (!M('ProjectBase')->where(['user_id' => $this->user_id, 'project_id' => $this->project_id])->find()) { $this->error("非法操作"); } else { $this->projectDetail = get_pro_detail($this->project_id, "project_id", $bind); if (!$this->__isset('projectDetail')) { $this->assign('projectDetail', $this->projectDetail); } } } else { $this->error("非法操作"); } }
/** * 提取关键信息 * @param $id int[产品id] */ function get_product_info($id, $flag) { $folder = (int) ($id / 16 + 1); $file = "{$folder}/{$id}"; $detail_file = $file . "_detail"; $pro_content = file_get_contents($file); //公司名称 $pro_tmp_result = array(); $pro_parse = array('>' => 1, '<' => 0); preg_match(PREG_PRO_COM, $pro_content, $pro_tmp_result); $pro_com = parse_html($pro_parse, $pro_tmp_result[0]); check($pro_com); //echo "pro_company:$pro_com\n"; //产品名称 $pro_parse = array('>' => 1, '<' => 0); preg_match(PREG_PRO_NAME, $pro_content, $pro_tmp_result); $pro_name = parse_html($pro_parse, $pro_tmp_result[0]); check($pro_name); //echo "pro_name:$pro_name\n"; stripos($pro_name, "GeForce") !== false ? $pro_chipset = "Invida" : ($pro_chipset = "AMD"); stripos($pro_name, "dvi") !== false ? $pro_dvi = 1 : ($pro_dvi = 0); stripos($pro_name, "hdmi") !== false ? $pro_hdmi = 1 : ($pro_hdmi = 0); //echo "chipset:$pro_chipset\n"; //echo "dvi:$pro_dvi\n"; //echo "hdmi:$pro_hdmi\n"; //价格 $pro_parse = array('>' => 1, '<' => 0); preg_match(PREG_PRO_PRICE, $pro_content, $pro_tmp_result); $pro_price = parse_html($pro_parse, $pro_tmp_result[0]); check($pro_price); //echo "price:$pro_price\n"; //上市时间 $pro_parse = array('</b>' => 1, '<' => 0); preg_match(PREG_PRO_DATE, $pro_content, $pro_tmp_result); $pro_date = parse_html($pro_parse, $pro_tmp_result[0]); check($pro_date); //echo "date:$pro_date\n"; //排名 $pro_parse = array('>' => 1, '<' => 0, '#' => 1); preg_match(PREG_PRO_RANK, $pro_content, $pro_tmp_result); $pro_rank = parse_html($pro_parse, $pro_tmp_result[0]); check($pro_rank); //echo "rank:$pro_rank\n"; $pro_parse = array('>' => 1, '<' => 0, ' ' => 0); preg_match(PREG_PRO_STAR, $pro_content, $pro_tmp_result); $pro_star = parse_html($pro_parse, $pro_tmp_result[0]); check($pro_star); //echo "star:$pro_star\n"; //总评分人数 $pro_parse = array(' ' => 0); preg_match(PREG_PRO_TOTAL, $pro_content, $pro_tmp_result); $pro_total = parse_html($pro_parse, $pro_tmp_result[0]); check($pro_total); //echo "total:$pro_total\n"; //评五星人数 $pro_parse = array('>' => 1, '<' => 0); preg_match(PREG_PRO_FIVE, $pro_content, $pro_tmp_result); $pro_five = parse_html($pro_parse, $pro_tmp_result[0]); check($pro_parse); //echo "five:$pro_five\n"; //忽略没有detail的产品 if (!file_exists($detail_file)) { echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!No detail file of {$id}!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"; echo "####################################Product {$id} is over#################################\n\n"; return; } $details = get_pro_detail($detail_file); output($pro_name, $pro_com, $pro_price, $pro_date, $pro_rank, $pro_star, $pro_total, $pro_five, $pro_chipset, $details['clock'], $details['mem_inter'], $details['style'], $details['bit'], $details['gra_memory'], $pro_dvi, $pro_hdmi, 1); echo "####################################Product {$id} is over#################################\n\n"; }