public static function updateGbbq() { self::$log->debugLog("Begin Update Gbbq"); /* $url = "http://stockdata.stock.hexun.com/2009_fhzzgb_000001.shtml"; $json = DayKeeper::curlXueqiuJson($url, self::$tmp->getTmpFile('day.duty.cookie')); $json = DayKeeper::parseXueqiuJson($json); var_dump($json); */ $p = -1; $list = Refer::getStock(); //得到进度 $content = self::$tmp->getTmpContent('gbbq.step.process'); $content = explode('===', $content); $lastProcess = $content && $content[0] ? $content[0] : -1; foreach ($list as $item) { $p++; //if ($p >= 3 ) break; if ($p < $lastProcess) { continue; } self::$tmp->putTmpContent('gbbq.step.process', $p . '===' . $item['code'] . ' ' . $item['name']); $numCode = substr($item['code'], 2); $url = "http://stockdata.stock.hexun.com/2009_fhzzgb_" . $numCode . ".shtml"; self::$log->debugLog($item['name'], $item['code'], $url); $html = GbbqKeeper::fetchSingleGbbq($url, $numCode); if ($html) { self::$log->debugLog($item['name'], $item['code'], "Fetch Gbbq Success"); $now = GbbqKeeper::parseGbbqHtml($html); if ($now) { $gd = new GbbqData($item['code']); $last = $gd->getGbbqData(); if ($last) { $updata = GbbqKeeper::mergeUpdate($last, $now); GbbqKeeper::addGbbq($gd->getDataFile(), $updata); } else { $updata = $now; GbbqKeeper::putGbbq($gd->getDataFile(), $updata); } self::$log->noticeLog($item['name'], $item['code'], "Update Gbbq Success"); self::$tmp->putTmpContent('gbbq.step.success', join(":", $item) . "|", FILE_APPEND); } else { self::$log->errorLog($item['name'], $item['code'], "Parse Gbbq Failed"); self::$tmp->putTmpContent('gbbq.step.failed', join(":", $item) . "|", FILE_APPEND); } } else { self::$log->errorLog($item['name'], $item['code'], "Fetch Gbbq Failed"); self::$tmp->putTmpContent('gbbq.step.failed', join(":", $item) . "|", FILE_APPEND); } } self::$log->debugLog("Finish Update Gbbq"); self::$tmp->putTmpContent('gbbq.step.process', ''); }
public static function show() { parent::show(); $stockInfo = array(); $stockInfo["code"] = $_GET["code"]; $i = Refer::searchCode($stockInfo["code"]); if (!$i) { exit(0); } $stockInfo["name"] = $i['name']; $stockInfo["spell"] = $i['spell']; $stockInfo["period"] = null; /* * $stockInfo["period"] = array('start'=>strtotime("Thu May 28 00:00:00 +0800 2015")*1000, 'end'=>strtotime("Mon Dec 23 00:00:00 +0800 2015")*1000); */ $stockInfo["right"] = "before"; $gd = new GbbqData($stockInfo["code"]); $gbbq = $gd->getGbbqLabel(); $stockInfo['gbbq'] = $gbbq; $dd = new DdeData($stockInfo["code"]); $dde = $dd->getDdeData(); $stockInfo['dde'] = $dde; $tdd = new ThsDoctorData($stockInfo["code"]); $ths = $tdd->getThsDoctorData(); $stockInfo['ths'] = $ths; $ld = new LhbData($stockInfo["code"]); $lhb = $ld->getLhbData(); $stockInfo['lhb'] = $lhb; $rd = new RateData($stockInfo["code"]); $rate = RateData::filterBuy($rd->getRateData()); $stockInfo['rate'] = $rate; $stockInfo['day'] = array(); $typeRight = array("normal", "before", "after"); foreach ($typeRight as $aTypeRight) { $dd = new DayData($stockInfo["code"], $aTypeRight); if ($dd->prepareData()) { $stockInfo['day'][$aTypeRight] = $dd->getStockData(); } else { $stockInfo['day'][$aTypeRight] = null; } } self::setTitle($stockInfo['name'] . '(' . $stockInfo['code'] . ') - Stock -- ForeShadow (Alpha)'); self::$smarty->assign('historyUrl', Url::getBasePhp('History')); self::$smarty->assign('favoriteUrl', Url::getBasePhp('Favorite')); self::$smarty->assign('rawData', json_encode($stockInfo)); self::$smarty->display('Chart.tpl'); }