private function doTb($tid, $cid = 0) { if ($tid == 2610) { //彩票部分 $cacheId = 'doTb_' . $tid; $fcurl = cacheGet($cacheId); if (empty($fcurl)) { $url = 'http://www.114la.com/icai.json'; $fcurl = XUtils::fcurl($url); cacheSet($cacheId, $fcurl, 3600); } $fcurl = substr($fcurl, 17, -1); $data_arr = json_decode($fcurl, TRUE); if (!empty($data_arr)) { //对应关系 $dy = array('ssq' => array(220, 221, 222), 'dlt' => array(223, 224, 225), 'fc3d' => array(226, 227, 228), 'jx_11x5' => array(229, 230, 231)); foreach ($data_arr as $tp => $v) { $va = $v[0]; $fdata[$dy[$tp][0]] = array(0 => array('title' => '上期开奖号码', 'link' => $va['url'][0], 'opt_a' => implode(',', $va['result']), 'opt_b' => $va['phase'], 'opt_c' => $va['date'])); $fdata[$dy[$tp][1]] = array(0 => array('title' => '立即投注', 'link' => $va['url'][1]), 1 => array('title' => $va['chain'][0], 'link' => $va['chain'][1])); foreach ($va['link'] as $vl => $tu) { $tu['link'] = $tu['url']; unset($tu['url']); $va['link'][$vl] = $tu; } $fdata[$dy[$tp][2]] = $va['link']; } } if (!empty($fdata)) { foreach ($fdata as $cid => $cinfo) { Links::model()->deleteAll("catalog_id=:cid", array(':cid' => $cid)); foreach ($cinfo as $info) { try { $model = new Links(); $info['catalog_id'] = $cid; $info['title'] = empty($info['title']) ? '待定' : $info['title']; $info['link'] = empty($info['link']) || $info['link'] == '#' ? 'http://www.114la.com/' : $info['link']; $info['mix'] = empty($info['mix']) ? null : base64_decode($info['mix']); $info = array_filter($info); $model->attributes = $this->_form($info); // ppr($model->attributes); $model->save(); } catch (Exception $exc) { return 'error1caipiao'; } } } } return 'ok'; // ppr($fdata,1); } elseif ($tid == 1114) { //实时热点部分 $cacheId = 'doTb_' . $tid; $fcurl = cacheGet($cacheId); if (empty($fcurl)) { $url = 'http://api4.114la.com/1114_2.json'; $fcurl = XUtils::fcurl($url); cacheSet($cacheId, $fcurl, 3600); } $fcurl = substr($fcurl, 20, -1); // ppr($fcurl,1); if (!empty($fcurl) && ($fcurl = json_decode($fcurl, 1))) { //先将对应的旧数据处理 $old = reqPost('old'); if (empty($old)) { Links::model()->updateAll(array('status_is' => 'N'), "`catalog_id`='{$cid}'"); } else { Links::model()->deleteAll("catalog_id=:cid", array(':cid' => $cid)); } // ppr(Links::model()->findAll("`catalog_id`='$cid'")); foreach ($fcurl as $info) { try { $model = new Links(); $info['catalog_id'] = $cid; $info['title'] = empty($info['title']) ? '待定' : $info['title']; $info['link'] = empty($info['url']) || $info['url'] == '#' ? 'http://www.114la.com/' : $info['url']; unset($info['url']); $info = array_filter($info); $model->attributes = $this->_form($info); // ppr($model->attributes); $model->save(); } catch (Exception $exc) { return 'error1'; } } $cacheId = '_catalogAllNum'; $catalogAllNum = XXcache::refresh($cacheId); return empty($catalogAllNum[$cid]) ? 0 : $catalogAllNum[$cid] . ' ok'; } else { return 'error2'; } ppr($data_arr, 1); } elseif ($tid > 1000 && $tid < 10000) { $tid = (int) $tid; $data = $re = 0; $cacheId = 'doTb_' . $tid; $fcurl = cacheGet($cacheId); if (empty($fcurl)) { $url = 'http://www.114la.com/api/ky.php?id=' . $tid . '&' . time(); // $url = 'http://www.114la.com/api/ky.php?id='.$tid; $fcurl = XUtils::fcurl($url); cacheSet($cacheId, $fcurl, 3600); } if (!empty($fcurl) && ($fcurl = json_decode($fcurl, 1))) { //先将对应的旧数据处理 $old = reqPost('old'); if (empty($old)) { Links::model()->updateAll(array('status_is' => 'N'), "`catalog_id`='{$cid}'"); } else { Links::model()->deleteAll("catalog_id=:cid", array(':cid' => $cid)); } // ppr(Links::model()->findAll("`catalog_id`='$cid'")); foreach ($fcurl as $info) { try { $model = new Links(); $info['catalog_id'] = $cid; $info['title'] = empty($info['title']) ? '待定' : $info['title']; $info['link'] = empty($info['link']) || $info['link'] == '#' ? 'http://www.114la.com/' : $info['link']; $info['mix'] = empty($info['mix']) ? null : base64_decode($info['mix']); $info = array_filter($info); $model->attributes = $this->_form($info); // ppr($model->attributes); $model->save(); } catch (Exception $exc) { return 'error1'; } } $cacheId = '_catalogAllNum'; $catalogAllNum = XXcache::refresh($cacheId); return empty($catalogAllNum[$cid]) ? 0 : $catalogAllNum[$cid] . ' ok'; } else { return 'error2'; } } else { return 'error3'; } }