function hgpxgcp($ziduan, $urlstr, $name, $num, $nums, $connum) { global $Db, $db_prefix, $web_wshtml; $ziduanstr = implode("`,`", $ziduan); $ziduanstr = "`" . $ziduanstr . "`"; $yldcpsql = "select " . $ziduanstr . ",`id` from `" . $db_prefix . "chanpin` where `ifxianshi`=1 and `gongyings`='" . $name . "'"; $yldcpsql .= " order by `id` desc"; $yldcpsql .= " limit " . $num . "," . $nums . ""; $yldcp = $Db->ThisQuery($yldcpsql); while ($yldcpone = $Db->Fetch($yldcp)) { $yldcpone['urlstr'] = $web_wshtml == "open" ? $urlstr . "_" . $yldcpone['id'] . ".htm" : $urlstr . ".php?id=" . $yldcpone['id'] . ""; if (!empty($connum)) { $yldcpone['name'] = cut(clhtml($yldcpone['name']), $connum); } if (empty($yldcpone['cpimg'])) { $yldcpone['cpimg'] = "img/none.jpg"; } $yldcparray[] = $yldcpone; } return $yldcparray; }
function Get_weather($wurl) { global $Db, $db_prefix, $Base, $provinceid, $cityid, $areaid, $smarty; $wcurl = "http://www.weather.com.cn/weather/" . $wurl . ".shtml"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $wcurl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_NOBODY, false); $rs = curl_exec($ch); curl_close($ch); $rs = str_replace("<!--", "", $rs); $rs = str_replace("-->", "", $rs); $tongyi = "<table class=\"tableTop\" width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">||</div>"; $tongyi = $this->getrole($tongyi, 'utf-8'); preg_match("/" . $tongyi . "/iU", $rs, $tyrs); $mystr = $tyrs[1]; $tongyi1 = "<table class=\"yuBaoTable\" width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">||</table>"; $tongyi1 = $this->getrole($tongyi1, 'utf-8'); preg_match_all("/" . $tongyi1 . "/iU", $mystr, $tyrs2); $mystrtd = $tyrs2[1]; $tody1 = $mystrtd[0]; $tody2 = $mystrtd[1]; //读取日期 $riqistr = "<td width=\"15%\" rowspan=\"2\" class=\"t0\" style=\"background:#f4f7fc;\">||</td>"; $riqistr = $this->getrole($riqistr, 'utf-8'); preg_match("/" . $riqistr . "/iU", $tody1, $riqi2); $todyday = $riqi2[1]; $mday = date("d", time()); $mystr2 = $tody1; //最高低和最低温 if (eregi('低温 <strong>', $mystr2) && eregi('高温 <strong>', $mystr2)) { $diqiwen = "<strong>||</strong>"; $diqiwen = $this->getrole($diqiwen, 'utf-8'); preg_match_all("/" . $diqiwen . "/iU", $mystr2, $diqiwen2); $gdwendu = $diqiwen2[1]; $zuigao = $gdwendu[0]; $zuiti = $gdwendu[1]; } //天气图片 $tugz = "<img src=\"/m2/i/icon_weather/29x20/||.gif\" />"; $tugz = $this->getrole($tugz, 'utf-8'); preg_match("/" . $tugz . "/iU", $mystr2, $tqtu); //天气现象 $tqxx = "<td width=\"18%\">||</td>"; $tqxx = $this->getrole($tqxx, 'utf-8'); preg_match("/" . $tqxx . "/iU", $mystr2, $tqxx2); //气温,风向,风力 $qiwen = "<td width=\"15%\">||</td>"; $qiwen = $this->getrole($qiwen, 'utf-8'); preg_match_all("/" . $qiwen . "/iU", $mystr2, $qiwen2); $qiwenstr = $qiwen2[1]; //echo $tqtu[1];//图标 $tupian = $tqtu[1]; $tupian = str_replace("n", "", $tupian); $tupian = str_replace("d", "", $tupian); $tupian = str_replace("n0", "", $tupian); $tupian = str_replace("d0", "", $tupian); $tupian = intval($tupian); $tianqi = clhtml($tqxx2[1]); //天气现象 $qiwen = clhtml($qiwenstr[0]); //温度 $qiwen = str_replace("高温", "", $qiwen); $qiwen = str_replace("低温", "", $qiwen); $fengxiang = clhtml($qiwenstr[1]); //风向 $fengli = clhtml($qiwenstr[2]); //风力 $vhip = $Base->GetIp(); $vhtime = time(); if ($zuigao && $zuiti) { $Db->ThisQuery("insert into `" . $db_prefix . "tianqi` (`pid`,`cid`,`aid`,`wimg`,`wtxt`,`wgaowen`,`wdiwen`,`wfengxiang`,`wfengli`,`addip`,`addtime`) values (" . intval($provinceid) . "," . intval($cityid) . "," . intval($areaid) . ",'" . $tupian . "','" . $tianqi . "','" . $zuigao . "','" . $zuiti . "','" . $fengxiang . "','" . $fengli . "','" . $vhip . "'," . $vhtime . ")"); } else { $Db->ThisQuery("insert into `" . $db_prefix . "tianqi` (`pid`,`cid`,`aid`,`wimg`,`wtxt`,`wdiwen`,`wfengxiang`,`wfengli`,`addip`,`addtime`) values (" . intval($provinceid) . "," . intval($cityid) . "," . intval($areaid) . ",'" . $tupian . "','" . $tianqi . "','" . $qiwen . "','" . $fengxiang . "','" . $fengli . "','" . $vhip . "'," . $vhtime . ")"); } $zuigao ? $qiwen = $zuiti . "~" . $zuigao : ($qiwen = $zuiti); $smarty->assign("tupian", $tupian); $smarty->assign("tianqi", $tianqi); $smarty->assign("qiwen", $qiwen); $smarty->assign("fengli", $fengli); $smarty->assign("fengxiang", $fengxiang); }