HT = $this->load->database('HT', TRUE); $this->load->model("IContent_model"); $this->load->model("IStructures_model"); $CI = &get_instance(); } /** * 获取信息平台的内容,所有信息,包含发布和没发布的 */ function getInfomationAll($guideurl) { // $sql = "select top 1 * from infoContents a inner join infoStructures b on a.ic_id=b.is_ic_id where ic_URL='".$guideurl."' and ic_status=1 and is_siteCode='ct'"; $sql = "select top 1 * from infoContents a inner join infoStructures b on a.ic_id=b.is_ic_id where ic_URL='" . $guideurl . "' and is_siteCode='" . Site_Code . "'"; $query = $this->HT->query($sql); if ($query->num_rows() > 0) { return $query->row(); } else { return null; } } /** * @description: 检查是否是新的bokun产品,根据infobokundata表的activityid记录 * @param {type} * @return: * @Date Changed: */ function checkActivityId($activityid) { $sql = "select top 1 * from infobokundata where ibd_itemname='ActivityID' and CONVERT(varchar(100),ibd_itemvalue)=?"; $query = $this->HT->query($sql, array($activityid)); if ($query->num_rows() > 0) { $result["return"] = "yes"; } else { $result["return"] = "no"; } return json_encode($result); } /** * @description: 根据城市名称获取城市ID * @param string $cityname:城市名称 * @return: * @Date Changed: */ function getCityIdByName($cityname) { $sql = "select top 1 CII2_CII_SN from CItyInfo2 where CII2_Name = '" . $cityname . "' and CII2_LGC=1"; $query = $this->HT->query($sql); if ($query->num_rows() > 0) { return $query->row(); } else { return null; } } /**-------------------抓取程序------------------------- */ var $is_topId = "278000665"; //产品的最高级父类 //ic_content表的字段 var $ic_url = ""; var $ic_url_title = "New Information"; var $ic_type = ""; var $ic_title = ""; var $ic_content = ""; var $ic_summary = ""; var $ic_seo_title = ""; var $ic_seo_description = ""; var $ic_seo_keywords = ""; var $ic_show_bread_crumbs = 0; var $ic_status = 0; var $ic_template = ""; var $ic_photo = ""; var $ic_photo_width = 0; var $ic_photo_height = 0; var $ic_recommend_tours = ""; var $ic_recommend_packages = ""; var $ic_ht_area_id = 0; var $ic_ht_area_type = ""; var $ic_ht_product_id = 0; var $ic_ht_product_type = ""; var $ic_author = ""; /** * @description: 添加一条信息平台信息 * @param string $PAG_Code 翰特产品的编码 * @return: * @Date Changed: */ public function addInfo($is_parent_id, $PAG_Code = "") { if ($is_parent_id == $this->is_topId) { //这个是城市级别的数据添加 } else { //产品添加 } //添加. $this->IContent_model->Add( $this->ic_url, $this->ic_url_title, $this->ic_type, $this->ic_title, $this->ic_content, $this->ic_summary, $this->ic_seo_title, $this->ic_seo_description, $this->ic_seo_keywords, $this->ic_show_bread_crumbs, $this->ic_status, $this->ic_template, $this->ic_photo, $this->ic_photo_width, $this->ic_photo_height, $this->ic_recommend_tours, $this->ic_recommend_packages, $this->ic_ht_area_id, $this->ic_ht_area_type, $this->ic_ht_product_id, $this->ic_ht_product_type, $this->ic_author ); $infocontent = $this->IContent_model->get_ic_contents($this->IContent_model->insert_id); if (!empty($infocontent) && $this->IStructures_model->Add($is_parent_id, $this->IContent_model->insert_id)) { $is_id = $this->IStructures_model->insert_id; $InfoStructures = $this->IStructures_model->Detail($is_id); $InfoStructures->is_id = $is_id; $InfoStructures->ic_id = $infocontent->ic_id; $data[] = array('name' => 'ok', 'value' => $InfoStructures); } else { $data[] = array('name' => 'no', 'value' => 'form_info_error'); } return json_encode($data); } /**---------Meta表的操作----------- */ function addMeta($im_ic_id, $im_key, $im_value) { $sql = "INSERT INTO infoMetas \n" . " ( \n" . " im_ic_id, im_key, im_value \n" . " ) \n" . "VALUES \n" . " ( \n" . " ?, ?, N? \n" . " )"; return $this->HT->query($sql, array($im_ic_id, $im_key, (string) $im_value)); } /**----------翰特入库--------------- */ var $pag_sn; var $PAG_CII_SN = 0; var $PAG_Code = ""; var $PAG_Scheme = "1,2,3,4,5,6,7"; var $PAG_Title = ""; var $PAG_DEI_SN = "34"; var $PAG_PPI_SN = 0; //存放activityid var $PAG2_LGC = 1; var $PAG2_Name = ""; var $PAG2_Title = ""; /** * @description: 添加产品信息到翰特 * @param {type} * @return: * @Date Changed: */ function AddProductToHT() { $sql = " INSERT INTO [BIZ_PackageInfo] ([PAG_CII_SN] ,[PAG_Code] ,[PAG_Scheme] ,[CreatTime] ,[PAG_Title] ,[PAG_DEI_SN] ,[PAG_PPI_SN] ) VALUES ( ?,?,?,GETDATE(),?,?,?) "; $query = $this->HT->query($sql, array( $this->PAG_CII_SN, $this->PAG_Code, $this->PAG_Scheme, $this->PAG_Title, $this->PAG_DEI_SN, $this->PAG_PPI_SN )); $this->pag_sn = $this->HT->query("select max(pag_sn) as pag_sn from BIZ_PackageInfo")->row("pag_sn"); //插入语种表 $sql2 = " INSERT INTO [BIZ_PackageInfo2] ([PAG2_PAG_SN] ,[PAG2_LGC] ,[PAG2_Name] ,[PAG2_Title] ) VALUES (?,?,?,?) "; //录入中,英两个语种 for ($i = 1; $i < 3; $i++) { $this->HT->query($sql2, array( $this->pag_sn, $i, $this->PAG2_Name, $this->PAG2_Title )); } return $this->pag_sn; } /**------其它一些公用函数--- */ /** * @description: 抓取页面程序 * @param string $url 抓取地址 * @param string $data 传递的参数 * @return: * @Date Changed: */ function getCrulData($url, $data = '', $method = 'GET') { $curl = curl_init(); // 启动一个CURL会话 curl_setopt($curl, CURLOPT_URL, $url); // 要访问的地址 curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); // 对认证证书来源的检查 curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); // 从证书中检查SSL加密算法是否存在 curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); // 模拟用户使用的浏览器 curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); // 使用自动跳转 curl_setopt($curl, CURLOPT_AUTOREFERER, 1); // 自动设置Referer if ($method == 'POST' && !empty($data)) { curl_setopt($curl, CURLOPT_POST, 1); // 发送一个常规的Post请求 curl_setopt($curl, CURLOPT_POSTFIELDS, $data); // Post提交的数据包 curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type:application/json')); } curl_setopt($curl, CURLOPT_TIMEOUT, 40); // 设置超时限制防止死循环 curl_setopt($curl, CURLOPT_TIMEOUT_MS, 40000); // 设置超时限制防止死循环 curl_setopt($curl, CURLOPT_HEADER, 0); // 显示返回的Header区域内容 curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // 获取的信息以文件流的形式返回 $tmpInfo = curl_exec($curl); // 执行操作 $errno = curl_errno($curl); if ($errno !== 0) { return false; echo $errno . curl_error($curl); //记录错误日志 } curl_close($curl); //关闭CURL会话 return $tmpInfo; //返回数据 } /** * @description: 过滤掉特殊字符 * @param {type} * @return: * @Date Changed: */ function match_chinese($chars,$encoding='utf8'){ $pattern =($encoding=='utf8')?'/[\x{4e00}-\x{9fa5}a-zA-Z0-9]/u':'/[\x80-\xFF]/'; preg_match_all($pattern,$chars,$result); return join('',$result[0]); } } /* End of file TpBokun_model.php */