public function matchapiAction() { //set header header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow-Methods: GET'); //set cache $this->_request->setParam('cache_file', 1); //Disable layout $this->_helper->layout->disableLayout(true); //Set no render view $this->_helper->viewRenderer->setNoRender(true); //get param limit $intLimit = $this->_request->getParam('limit', 2); //get param league, defaul 18-worldcup $intLeague = $this->_request->getParam('league', 18); //init response $respose = array('data' => '', 'error' => 0); $matchModel = Thethao_Model_Match::getInstance(); $modelObject = Fpt_Data_Materials_Object::getInstance(); $beginHappenDateTime = time() - 100 * 60; //lay truoc do 100p $endHappenDateTime = 1405382400; // ngay 15-7-2014 // Get list match id by league id with time happened from current -> 15/7 $arrMatchIDs = $matchModel->getMatchIDsByLeague($intLeague, $beginHappenDateTime, $endHappenDateTime, false); // Count future $count = count($arrMatchIDs); if ($count > $intLimit) { $arrMatchIDs = array_slice($arrMatchIDs, 0, $intLimit, true); } if (!empty($arrMatchIDs)) { $modelObject->getMatch()->setId(array_keys($arrMatchIDs)); $respose['data'] = $arrMatchIDs; } $jsonData = Zend_Json::encode($respose); # JSON if no callback if (!isset($_GET['callback'])) { echo $jsonData; exit; } //init model new $modelNew = Thethao_Model_News::getInstance(); # JSONP if valid callback if ($modelNew->isValidCallback($_GET['callback'])) { echo "{$_GET['callback']}({$jsonData})"; exit; } }
public function predictAction() { //get common info of match $this->_getInfoMatch(); // Disable render layout $this->_helper->layout->disableLayout(true); $this->_helper->viewRenderer->setNoRender(true); // Get user login $session = new Zend_Session_Namespace(SESSION_NAMESPACE); $arrParams = $this->_request->getParams(); $intMatchID = (int) $arrParams['matchid'] ? $arrParams['matchid'] : 0; $intGoalTeam1 = (int) $arrParams['goalteam1'] ? $arrParams['goalteam1'] : 0; $intGoalTeam2 = (int) $arrParams['goalteam2'] ? $arrParams['goalteam2'] : 0; //get site id $client_ip = isset($_SERVER['HTTP_X_FORWARDED_FOR']) && !empty($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR']; // Prepare for reading cache $memcacheInstance = Thethao_Global::getCache(); $keyCache = vsprintf(CACHING_PREFIX . 'client_ip:%s:%s', array($intMatchID, $client_ip)); //get memcache $predict = $memcacheInstance->read($keyCache); if ($predict === false) { //Check matchID if (!$intMatchID) { echo -1; return; } //Check input data if ($intGoalTeam1 < 0 || $intGoalTeam2 < 0) { echo -2; return; } $params = array('match_id' => $intMatchID, 'mobile' => NULL, 'userid' => (int) $session->userid, 'goal_team1' => (int) $arrParams['goalteam1'], 'goal_team2' => (int) $arrParams['goalteam2'], 'numpeople' => NULL, 'codepre' => NULL, 'type' => 1); //Insert predict $matchModel = Thethao_Model_Match::getInstance(); $arrReponse = $matchModel->pushJobInsertMatchPredict($params); // Write to cache if ($arrReponse) { $memcacheInstance->write($keyCache, $arrReponse, 60); Thethao_Global::writeMemcache($keyCache, $arrReponse, 'all', NULL, 60); } echo Zend_Json::encode($arrReponse); } else { echo -1; return; } }
/** * @todo - Worldcup BoxLichThiDau * @author ThuyNT */ public function indexAction() { // Disable render layout $this->_helper->layout->disableLayout(true); $this->_helper->viewRenderer->setNoRender(true); // Get params $intScore = (int) $this->_request->getParam('score', NULL); $strType = $this->_request->getParam('type', NULL); $dataEx = $this->_request->getParam('exclude', NULL); $objMatch = $this->view->objObject->getMatch(); $matchModel = Thethao_Model_Match::getInstance(); // Default response $response = array('error' => 0, 'msg' => 'Success', 'html' => NULL, 'type' => $strType); $past = false; $future = false; $sort = false; if ($intScore) { $strType = strip_tags($strType); $strType = $strType != 'next' && $strType != 'prev' ? 'next' : $strType; if ($strType == 'next') { $past = true; $endHappenDateTime = 1405382400; // ngay 15-7-2014 $beginHappenDateTime = $intScore; } else { $future = true; $endHappenDateTime = $intScore; // $beginHappenDateTime = 1401667200; //ngay 2-6-2014 $beginHappenDateTime = NULL; } // Get fixture $arrMatchIDs = $matchModel->getMatchIDsByLeague(LEAGUE_ID, $beginHappenDateTime, $endHappenDateTime, $sort); //print_r($arrMatchIDs); die; if (!empty($arrMatchIDs)) { if (!empty($dataEx)) { $arrMatchIDs = array_diff_key($arrMatchIDs, $dataEx); } if ($strType == 'prev') { arsort($arrMatchIDs); //sap xep tu lon den nho } if (count($arrMatchIDs) > LIMIT_FIXTURE) { $past = true; $future = true; $arrMatchIDs = array_slice($arrMatchIDs, 0, LIMIT_FIXTURE, true); } else { if ($strType == 'next') { $future = false; } else { $past = false; } } asort($arrMatchIDs); } } else { /*******BOX LICH THI DAU*********** */ $arrMatchIDs = array(); $sort = false; // Get list match id by league with time happened ago 90days $beginHappenDateTime = time() - 18 * 60 * 60; $pastToCurrentMatchIDs = array(); $endHappenDateTime = 1405382400; // ngay 15-7-2014 $pastToCurrentMatchIDs = $matchModel->getMatchIDsByLeague(LEAGUE_ID, $beginHappenDateTime - 1296000, $beginHappenDateTime, $sort); //Get list match id by team with time happened from current -> 15/7 $currentToFutureMatchIDs = $matchModel->getMatchIDsByLeague(LEAGUE_ID, $beginHappenDateTime, $endHappenDateTime, $sort); // Count future $countFuture = count($currentToFutureMatchIDs); $countPast = count($pastToCurrentMatchIDs); $future = false; $past = false; if ($countFuture > LIMIT_FIXTURE) { $future = true; $offset = 0; $arrMatchIDs = array_slice($currentToFutureMatchIDs, $offset, LIMIT_FIXTURE, true); } else { $arrTmp = $pastToCurrentMatchIDs + $currentToFutureMatchIDs; $future = false; arsort($arrTmp); //sort by happen date time desc $arrMatchIDs = array_slice($arrTmp, 0, LIMIT_FIXTURE, true); asort($arrMatchIDs); } if ($countPast > 0) { $past = true; } } if (!empty($arrMatchIDs)) { $objMatch->setId(array_keys($arrMatchIDs)); } /*******END BOX LICH THI DAU*********** */ // Assign to view $this->view->assign(array('arrMatchIDs' => $arrMatchIDs, 'future' => $future, 'past' => $past, 'pastScore' => current($arrMatchIDs), 'futureScore' => end($arrMatchIDs))); // Render html $response['html'] = $this->view->render('common/box_lich_thi_dau.phtml'); echo Zend_Json::encode($response); exit; }
/** * @todo - Worldcup LichThiDau * @author PhongTX */ public function indexAction() { $arrTemp = array(); //Default array graoup name $arrGroupName = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'); //Default array date & array detail match $arrDate = $arrDetailMatch = array('vong_bang' => array(), 'vong_16' => array(), 'tu_ket' => array(), 'ban_ket' => array(), 'tranh_giai_ba' => array(), 'chung_ket' => array()); //Init date $beginHappenDateTime = strtotime('2014/06/13'); $endHappenDateTime = strtotime('2014/07/15'); //Get instance $matchModel = Thethao_Model_Match::getInstance(); //Get list match id $arrListMatchIds = $matchModel->getMatchIDsByLeague(LEAGUE_ID, $beginHappenDateTime, $endHappenDateTime, false); if (!empty($arrListMatchIds)) { // Models instance $objMatch = $this->view->objObject->getMatch(); //Set id $objMatch->setId(array_keys($arrListMatchIds)); //get match extend $extend = $matchModel->getDetailMatchExtend(array_keys($arrListMatchIds)); foreach (array_keys($arrListMatchIds) as $intMatchId) { /* End dien bien tran dau */ $arrTemp = $objMatch->getDetailObjectBasic($intMatchId); $arrTemp['scoreCard'] = isset($extend[$intMatchId]['scoreCard']) ? $extend[$intMatchId]['scoreCard'] : array(); $arrTemp['formGuide'] = isset($extend[$intMatchId]['formGuide']) ? $extend[$intMatchId]['formGuide'] : array(); if (in_array($arrTemp['round'], $arrGroupName)) { $arrDetailMatch['vong_bang'][] = $arrTemp; } else { switch ($arrTemp['round']) { case 2: $arrDetailMatch['vong_16'][] = $arrTemp; break; case 3: $arrDetailMatch['tu_ket'][] = $arrTemp; break; case 4: $arrDetailMatch['ban_ket'][] = $arrTemp; break; case 5: $arrDetailMatch['tranh_giai_ba'][] = $arrTemp; break; case 6: $arrDetailMatch['chung_ket'][] = $arrTemp; break; } } } } //Define array date $arrDate['vong_bang'] = array(13 => 2, 14 => 3, 15 => 4, 16 => 3, 17 => 3, 18 => 3, 19 => 3, 20 => 3, 21 => 3, 22 => 3, 23 => 4, 24 => 4, 25 => 4, 26 => 4, 27 => 2); $arrDate['vong_16'] = array(28 => 1, 29 => 2, 30 => 2, 1 => 2, 2 => 1); $arrDate['tu_ket'] = array(4 => 1, 5 => 2, 6 => 1); $arrDate['ban_ket'] = array(9 => 1, 10 => 1); $arrDate['tranh_giai_ba'] = array(13 => 1); $arrDate['chung_ket'] = array(14 => 1); //Get currTimeGmt $currTimeGmt = time() - 110 * 60; //Get date now $dateNow = date('dmY', time()); $this->view->assign(array('dateNow' => $dateNow, 'arrDetailMatch' => $arrDetailMatch, 'arrDate' => $arrDate, 'currTime' => $currTimeGmt, 'strCateCode' => $this->_request->getParam('controller'), 'ogType' => 'website', 'ogTitle' => 'Lịch thi đấu World Cup 2014 - VnExpress', 'ogUrl' => $this->view->configView['url'] . '/lich-thi-dau', 'ogImage' => 'http://m.f9.img.vnexpress.net/2014/01/10/fa68f81afe10b727852361b1894ccc74.jpg', 'ogDescription' => 'Fifa World Cup 2014 - tin nhanh , hình ảnh , video clip bóng đá, lịch thi đấu WC 2014 tại Brazil, tường thuật bình luận bóng đá World Cup 2014')); //gan meta data $titleMeta = 'Lịch thi đấu World Cup 2014 - VnExpress'; $keywords = 'World cup 2014, tin tuc , bong da'; $description = 'Fifa World Cup 2014 - tin nhanh , hình ảnh , video clip bóng đá, lịch thi đấu WC 2014 tại Brazil, tường thuật bình luận bóng đá World Cup 2014'; $this->view->headTitle($titleMeta); $this->view->headMeta()->setName('description', $description); $this->view->headMeta()->setName('keywords', $keywords); //set cateid to show active in menu $this->_request->setParam('cateid', WORLD_CUP); if (DEVICE_ENV == 1) { //Append css $this->view->headLink()->appendStylesheet($this->view->configView['css'] . '/m_lichthidau.css'); } else { $this->view->headScript()->appendFile($this->view->configView['js'] . '/lichthidau.js'); } }
public function getFixtureAffAction() { // Disable render view $this->_helper->layout->disableLayout(true); $this->_helper->viewRenderer->setNoRender(true); // Get param of Aff Cup 2014 $intLeagueID = 14; $intSeasonID = 154; $unixTimeStart = $this->_request->getParam('startDate', NULL); $unixTimeEnd = $this->_request->getParam('endDate', NULL); $type = $this->_request->getParam('type', NULL); // Default response $response = array('error' => 0, 'html' => NULL, 'msg' => 'Success'); $unixTimeEnd = $unixTimeEnd + 23 * 60 * 60; //echo date('d/m/Y H:i', $unixTimeEnd); // Get model match $matchModel = Thethao_Model_Match::getInstance(); // Geta match of AffCup $arrData = $matchModel->getMatchInWeek($intSeasonID, $intLeagueID, $unixTimeStart, $unixTimeEnd); //echo '<pre>'; //print_r($arrData);die; if ($type == 'prev') { krsort($arrData); } //print_r($arrData);die; // Assign to view $this->view->assign(array('arrData' => $arrData, 'type' => $type)); $response['html'] = $this->view->render('lich-thi-dau/list_fixtures_aff.phtml'); // Output response echo Zend_Json::encode($response); exit; }
/** * @author HungNT * @return report Match */ public function reportAction() { //set cache $this->_request->setParam('cache_file', 1); //Set param $this->_request->setParam('block_cate', SITE_ID); //get param view app $viewApp = $this->_request->getParam('view', ''); //get common info of match $this->_getInfoMatch(); $strLinkTuongThuat = $this->view->ShareurlWorldcup($this->_matchDetail['share_url']); if (!$this->_matchDetail['isReport']) { $this->_matchDetail['share_url'] = str_replace('/report/', '/tuong-thuat/', $strLinkTuongThuat); $this->_redirect($this->_matchDetail['share_url'] . ($viewApp == 'app' ? '?view=app' : ''), array('code' => 301)); } // Get models' instance $modelMatch = Thethao_Model_Match::getInstance(); $modelArticle = $this->view->objArticle; // Get tuong-thuat data $arrData = $modelMatch->getTuongThuat($this->_matchID); $arrData['relate_id'] = intval($arrData['relate_id']); //str link $strLink = $this->_request->getPathInfo(); $strLinkTuongThuat = $this->view->ShareurlWorldcup($this->_matchDetail['share_url']); $this->_matchDetail['share_url'] = str_replace('/tuong-thuat/', '/report/', $this->_matchDetail['share_url']); $this->_matchDetail['share_url'] = $this->view->ShareurlWorldcup($this->_matchDetail['share_url']); //check link if (strpos($this->_matchDetail['share_url'], $strLink) === FALSE && APPLICATION_ENV != 'development') { $this->_redirect($this->_matchDetail['share_url'], array('code' => 301)); } if ($arrData['relate_id'] > 0) { $modelArticle->setIdBasic($arrData['relate_id']); //get detail article $tuongThuat = $modelArticle->getArticleFull($arrData['relate_id']); if (intval($tuongThuat['publish_time']) <= time()) { $tuongThuat['relate_id'] = $arrData['relate_id']; } } else { $tuongThuat['relate'] = $arrData['relate']; } $intCateIdPolyAds = isset($tuongThuat['category_id']) ? $tuongThuat['category_id'] : WORLD_CUP; $articleTrackingId = isset($tuongThuat['article_id']) ? $tuongThuat['article_id'] : WORLD_CUP; // Assign to view $this->view->assign(array('tuongThuat' => $tuongThuat, 'intCategoryId' => WORLD_CUP, 'strCateCode' => $this->_request->getParam('action'), 'intCateIdPolyAds' => $intCateIdPolyAds, 'articleTrackingId' => $articleTrackingId, 'strLinkTuongThuat' => $strLinkTuongThuat, 'ogType' => 'website', 'ogTitle' => $tuongThuat['title_format'] . ' - VnExpress World Cup', 'ogUrl' => $this->_matchDetail['share_url'], 'ogImage' => !empty($tuongThuat['thumbnail_url']) ? $this->view->ImageurlArticle($tuongThuat, 'size2') : 'http://m.f9.img.vnexpress.net/2014/01/10/fa68f81afe10b727852361b1894ccc74.jpg', 'ogDescription' => trim(strip_tags(html_entity_decode($tuongThuat['lead'], ENT_COMPAT, 'UTF-8'))))); //gan meta data $titleMeta = 'Tổng thuật trận đấu ' . $this->_metaTitle; $keywords = 'World cup 2014, tin tuc , bong da'; $description = ''; //add js $this->view->headScript()->appendFile($this->view->configView['vnecdn']['js'] . '/require.min.js'); //set cateid to show active in menu $this->_request->setParam('cateid', WORLD_CUP); $this->view->headMeta()->setName('object_id', $this->_matchID); $this->view->headTitle($titleMeta); $this->view->headMeta()->setName('description', $description); $this->view->headMeta()->setName('keywords', $keywords); //check view app if (!empty($viewApp) && $viewApp == 'app') { //Disable layout $this->_helper->layout->disableLayout(true); echo $this->view->render('match/appreport.phtml'); exit; } }
/** * Function get list match id by league, get list team by season id & league id, get list player * @param array */ public function boxPredicted($params) { try { $matchModel = Thethao_Model_Match::getInstance(); $modelObject = Fpt_Data_Materials_Object::getInstance(); $beginHappenDateTime = time() - 100 * 60; //lay truoc do 100p $endHappenDateTime = 1405382400; // ngay 15-7-2014 $sort = false; // Get list match id by league id with time happened from current -> 15/7 $arrMatchIDs = $matchModel->getMatchIDsByLeague(LEAGUE_ID, $beginHappenDateTime, $endHappenDateTime, $sort); // Count future $count = count($arrMatchIDs); if (is_array($arrMatchIDs) && $count > $params['limit']) { $arrMatchIDs = array_slice($arrMatchIDs, 0, $params['limit'], true); } if (!empty($arrMatchIDs)) { $modelObject->getMatch()->setId(array_keys($arrMatchIDs)); } //get list team id $arrTeamId = $this->getListTableRanking(); } catch (Exception $ex) { //log error Thethao_Global::sendLog($ex); } //return array result return array('arrMatchIDs' => $arrMatchIDs, 'arrTeamId' => $arrTeamId); }