/** * insert post article * @param array $arrParams * @return int * @author Phongtx */ public function insertPostArticle($arrParams) { $intResult = false; try { // Get DB Object $db = Thethao_Global::getDB('sport', 'master'); // Prepare SQL $stmt = $db->prepare('CALL sp_ent_insertShareMusic(:p_userid, :p_fullname, :p_email, :p_title, :p_lead, :p_content, :p_status, :p_sharetype, :p_categoryid, @p_id);'); // Bind params $stmt->bindParam('p_userid', $arrParams['intUserId'], PDO::PARAM_INT); $stmt->bindParam('p_fullname', $arrParams['txtName'], PDO::PARAM_STR); $stmt->bindParam('p_email', $arrParams['txtEmail'], PDO::PARAM_STR); $stmt->bindParam('p_title', $arrParams['txtTitle'], PDO::PARAM_STR); $stmt->bindParam('p_lead', $arrParams['txtLead'], PDO::PARAM_STR); $stmt->bindParam('p_content', $arrParams['txtContent'], PDO::PARAM_STR); $stmt->bindParam('p_status', $arrParams['intStatus'], PDO::PARAM_INT); $stmt->bindParam('p_sharetype', $arrParams['type'], PDO::PARAM_INT); $stmt->bindParam('p_categoryid', $arrParams['cateid'], PDO::PARAM_INT); // Execute $stmt->execute(); // Close cursor $stmt->closeCursor(); $stmt = $db->query("SELECT @p_id"); //Fetch Result $intResult = $stmt->fetchColumn(); // Release unset($stmt); } catch (Exception $ex) { //log error Thethao_Global::sendLog($ex); } // Return result return $intResult; }
public function updateMatchByFan($params) { // Default response $response = NULL; try { // Get config application $config = Thethao_Global::getApplicationIni(); // Get team_match object $matchMysqlObj = $this->factory('Match', $config['database']['default']['adapter']); // Get match infos fan $arrMatchFan = $matchMysqlObj->getFanByMatch($params['matchId']); //Update if (isset($arrMatchFan['match_id']) && is_numeric($arrMatchFan['match_id']) && $arrMatchFan['match_id'] > 0) { if ($params['likeType'] == 0) { $score = -1; } else { $score = 1; } // Params update $paramUpdate = array('matchId' => $params['matchId'], 'fanteam_1' => $params['fanLikeTeam'] == 1 ? $arrMatchFan['fan_team1'] + $score : $arrMatchFan['fan_team1'], 'fanteam_2' => $params['fanLikeTeam'] == 2 ? $arrMatchFan['fan_team2'] + $score : $arrMatchFan['fan_team2']); if ($matchMysqlObj->updateMatchByFan($paramUpdate)) { $keyCache = Thethao_Global::makeCacheKey(Thethao_Model_Match::EURO2012_MATCH_LIKE, array($params['matchId'])); Thethao_Global::deleteMemcache(array($keyCache)); } //end if } //end if } catch (Exception $ex) { Thethao_Global::sendLog($ex); } return $response; }
/** * Clear cache top player * @param array $params * @return array * @author QuangTM */ public function clearCacheTopPlayer($params) { // Get params $seasonID = $params['seasonID']; try { $keyCache = Thethao_Global::makeCacheKey(Thethao_Model_PlayerChampion::PLAYER_CHAMPION_BY_SEASON, $seasonID); Thethao_Global::deleteMemcache(array($keyCache)); } catch (Exception $ex) { Thethao_Global::sendLog($ex); } return; }
/** * call job clear cache file * @param array $articleDetail * @param string $action * @return boolean|array */ public function clearCacheFile($action = 'file') { try { //set secret key $secret_key = 'e146b700f216df93a2dd5ca6e26c7c2c'; //get app config $config = Thethao_Global::getApplicationIni(); $arrServer = $config['ipserver']['thethao']; $host = $config['view']['host']; $headers = array("Host: " . $host); //init curl $arrCurl = array(); //$arrServer = array('180.148.142.92', '180.148.142.171'); foreach ($arrServer as $i => $server) { $arrCurl[$i] = curl_init(); curl_setopt($arrCurl[$i], CURLOPT_HTTPHEADER, $headers); curl_setopt($arrCurl[$i], CURLOPT_TIMEOUT, 5); curl_setopt($arrCurl[$i], CURLOPT_RETURNTRANSFER, true); curl_setopt($arrCurl[$i], CURLOPT_URL, "http://{$server}/clear_file.php?action={$action}&sck={$secret_key}"); } //create the multiple cURL handle $mh = curl_multi_init(); foreach ($arrCurl as $ch) { curl_multi_add_handle($mh, $ch); } //execute the handles $running = null; do { curl_multi_exec($mh, $running); } while ($running > 0); // get content and remove handles to debug if fall /*foreach($arrCurl as $id => $c) { $result[$id] = curl_multi_getcontent($c); }*/ foreach ($arrCurl as $ch) { curl_multi_remove_handle($mh, $ch); } //close the handles curl_multi_close($mh); //var_dump( $result); return true; } catch (Exception $ex) { //log error Thethao_Global::sendLog($ex); } return false; }
/** * Send mail function * @param <array> $params * @return <array> * @author HungNT1 */ public function sendMail($params) { // Default return $response = true; // Include config send mail include APPLICATION_PATH . '/configs/mail.php'; if (is_array($configsender) && !empty($configsender)) { // Create transport $transport = new Zend_Mail_Transport_Smtp($smtpServer['default'], $configmail); $transportLB = new Zend_Mail_Transport_Smtp($smtpServer['balancing'], $configmail); foreach ($params['reciever'] as $receiver) { $email = $receiver['email']; $alias = $receiver['alias']; //init zend mail $mail = new Zend_Mail('UTF-8'); //set from $mail->setFrom($configsender['message']['email'], $params['name']); //receivers $mail->addTo($email, $alias); //set content mail $mail->setSubject($params['subject']); $mail->setBodyHtml($params['body']); try { //send mail if (!$mail->send($transport)) { $response = false; } } catch (Exception $ex) { // Log error Thethao_Global::sendLog($ex); try { //send mail if (!$mail->send($transportLB)) { $response = false; } } catch (Exception $ex1) { // Log error Thethao_Global::sendLog($ex1); } } } } else { $response = false; } return $response; }
/** * Get data from site Ngoisao and update to redis * @param array $params - array (article_id, original_url) * @return Boolean */ public function updateShareUrl($params) { // Default response $response = NULL; try { $article_id = intval($params['article_id']); $article_url = $params['original_url']; //get config key $config = Thethao_Global::getApplicationIni(); // Get redis instance $redisInstance = Thethao_Global::getRedis('article'); //make key $keyCache = Thethao_Global::makeCacheKey($config['view']['keyReis']['ngoisao']); //set redis $response = $redisInstance->hSet($keyCache, $article_id, $article_url); } catch (Exception $ex) { Thethao_Global::sendLog($ex); } return $response; }
/** * get all category detail * @param int $intCategoryID * @return array * @author PhuongTN */ public function getFullCategoryByParentId($intCategoryID) { $arrArticleInfo = array(); try { $sport_m = Thethao_Global::getDB('sport', 'slave'); // Get user activeation key $objStmt = $sport_m->prepare('CALL sp_getCategoryFullByParentID(:p_parentid)'); // Bind param $objStmt->bindParam('p_parentid', $intCategoryID, PDO::PARAM_INT); // Fetch result $objStmt->execute(); while ($row = $objStmt->fetch()) { $arrArticleInfo[$row['category_id']] = $row; } // Close cursor $objStmt->closeCursor(); // Release unset($objStmt); } catch (Zend_Db_Exception $ex) { Thethao_Global::sendLog($ex); } return $arrArticleInfo; }
/** * Get matches id which player attends * @param int $playerID * @param int $fromDate unix timestamp * @param int $toDate unix timestamp * @param boolean $reverse * @param int $limit * @param int $offset * @return array|boolean * @author QuangTM */ public function getMatchesPlayerAttend($playerID, $fromDate, $toDate, $reverse = TRUE, $limit = 20, $offset = 0) { try { // Get redis instance $redisInstance = Thethao_Global::getRedis('article'); // Get key redis for adding match by team // Get key cache $keyTennisMatches = vsprintf($this->_tennis_player_matches, $playerID); // Get array match id $arrMatchesID = array(); if ($reverse === TRUE) { $arrMatchesID = $redisInstance->zRevRangeByScore($keyTennisMatches, $toDate, $fromDate, array('withscores' => TRUE, 'limit' => array($offset, $limit))); } else { $arrMatchesID = $redisInstance->zRangeByScore($keyTennisMatches, $fromDate, $toDate, array('withscores' => TRUE, 'limit' => array($offset, $limit))); } // Return result return $arrMatchesID; } catch (Exception $ex) { Thethao_Global::sendLog($ex); } }
/** * @author : PhongTX - 29/01/2013 * call job update caching FE * @param : string $strPageCode * @name : delBlockByPage * @copyright : FPT Online * @todo : delBlockByPage */ public function delBlockByPage($strPageCode, $device) { try { $redisInstance = Thethao_Global::getRedis('article'); //get key cache mobile $keyCache = vsprintf($this->_key_block_detail, array($strPageCode, $device)); return $redisInstance->delete($keyCache); } catch (Exception $ex) { //log error Thethao_Global::sendLog($ex); } }
/** * Insert match predict * @param array $arrMatchPredict * @return bool * @author HungNT1 */ public function insertMatchPredict($params) { try { // Get DB Obj $dbObj = Thethao_Global::getDB('sport', 'master'); // Prepare SQL $stmt = $dbObj->prepare('CALL sp_sport_insertPredictMatch(:p_matchid, :p_mobile, :p_userid, :p_goalteam1, :p_goalteam2, :p_numpeople,:p_codepre,:p_type);'); // Bind param $stmt->bindParam('p_matchid', $params['match_id'], PDO::PARAM_INT); $stmt->bindParam('p_mobile', $params['mobile'], PDO::PARAM_STR); $stmt->bindParam('p_userid', $params['userid'], PDO::PARAM_INT); $stmt->bindParam('p_goalteam1', $params['goal_team1'], PDO::PARAM_INT); $stmt->bindParam('p_goalteam2', $params['goal_team2'], PDO::PARAM_INT); $stmt->bindParam('p_numpeople', $params['numpeople'], PDO::PARAM_INT); $stmt->bindParam('p_codepre', $params['codepre'], PDO::PARAM_STR); $stmt->bindParam('p_type', $params['type'], PDO::PARAM_INT); $stmt->execute(); $result = $stmt->fetch(); $stmt->closeCursor(); //Return return $result['result']; } catch (Exception $ex) { Thethao_Global::sendLog($ex); } }
/** * Get Article Id By Product Id * @param int $intId * @return $articleId * @author HungNT1 * @todo Thethao */ public function getArticleIdByProductId($intId) { try { //get memcache instance $memcached = Thethao_Global::getCache('all'); //make key cache $keyCache = vsprintf($this->_map_article, array($intId)); //get cache $articleId = $memcached->read($keyCache); if ($articleId == false) { //get config $config = Thethao_Global::getApplicationIni(); //get db instance $newsMysql = $this->factory('News', $config['database']['default']['adapter']); //call sp to get article id by product id, return array $articleId = $newsMysql->getArticleIdByProductId($intId); if (count($articleId) > 0) { //Wire question answer cache here! $memcached->write($keyCache, $articleId, 43200); } else { $memcached->write($keyCache, -1, 43200); } } //end check if miss cache return $articleId; } catch (Exception $ex) { //log error Thethao_Global::sendLog($ex); } }
/** * Get full information about tennis match.<br /> * Consist of tennis sets in matches, league, and season * @param array $arrMatchIDs list id of matches * @return array|boolean * @author QuangTM */ public function getTennisMatches($arrMatchIDs) { // Get result $result = array(); try { // Validate input paramter if (!is_array($arrMatchIDs) || !count($arrMatchIDs)) { return FALSE; } // Convert array match id into string $strMatchID = implode(',', $arrMatchIDs); // Get DB Obj $dbObj = Thethao_Global::getDB('sport', 'slave'); // Prepare SQL to get tennis matches detail $stmt = $dbObj->prepare('CALL sp_tennis_getDetailTennisMatch(:p_matchid);'); // Bind param $stmt->bindParam('p_matchid', $strMatchID, PDO::PARAM_STR); // Execute $stmt->execute(); $arrLeagues = array(); $arrSeasons = array(); while ($row = $stmt->fetch()) { // Get match detail $result[$row['match_id']] = $row; // Default set in match $result[$row['match_id']]['set'] = array(); // Default league and season name for this match $result[$row['match_id']]['league_name'] = NULL; $result[$row['match_id']]['season_name'] = NULL; // Push array league and season array_push($arrSeasons, $row['season_id']); array_push($arrLeagues, $row['league_id']); } // Unique league and season and convert them into string $strSeasons = implode(',', array_unique($arrSeasons)); $strLeagues = implode(',', array_unique($arrLeagues)); // Close $stmt->closeCursor(); // Prepare SQL to get tennis sets by match $stmt = $dbObj->prepare('CALL sp_tennis_getTennisSet(:p_matchid);'); // Bind param $stmt->bindParam('p_matchid', $strMatchID, PDO::PARAM_STR); // Execute $stmt->execute(); while ($row = $stmt->fetch()) { $result[$row['match_id']]['set'][$row['set_id']] = $row; } // Close $stmt->closeCursor(); $strLeagues = !empty($strLeagues) ? $strLeagues : null; // Prepare SQL to get tennis leagues $stmt = $dbObj->prepare('CALL sp_tennis_getTennisLeague(:p_leagueid);'); // Bind param $stmt->bindParam('p_leagueid', $strLeagues, PDO::PARAM_STR); // Execute $stmt->execute(); // Default result league has got $arrLeagues = array(); while ($row = $stmt->fetch()) { $arrLeagues[$row['league_id']] = $row['league_name']; } // Close $stmt->closeCursor(); // Prepare SQL to get tennis leagues $stmt = $dbObj->prepare('CALL sp_tennis_getTennisLeague(:p_leagueid);'); // Bind param $stmt->bindParam('p_leagueid', $strLeagues, PDO::PARAM_STR); // Execute $stmt->execute(); // Default result league has got $arrLeagues = array(); while ($row = $stmt->fetch()) { $arrLeagues[$row['league_id']] = $row['league_name']; } // Close $stmt->closeCursor(); // Default result league has got $arrSeasons = array(); if (!empty($strSeasons)) { // Prepare SQL to get tennis leagues $stmt = $dbObj->prepare('CALL sp_tennis_getTennisSeasonByID(:p_seasonid);'); // Bind param $stmt->bindParam('p_seasonid', $strSeasons, PDO::PARAM_STR); // Execute $stmt->execute(); while ($row = $stmt->fetch()) { $arrSeasons[$row['season_id']] = $row['name_season']; } } // Close $stmt->closeCursor(); // Release variables unset($stmt); // By league name into match info foreach ($result as $matchId => $matchInfo) { $result[$matchId]['league_name'] = $arrLeagues[$result[$matchId]['league_id']]; $result[$matchId]['season_name'] = $arrSeasons[$result[$matchId]['season_id']]; } } catch (Exception $ex) { Thethao_Global::sendLog($ex, 1); } return $result; }
/** * @author : TrangNT30 * call job update caching FE * @param : string $strDate * @name : updateCache * @copyright : FPT Online * @todo : updateCache */ public function updateAward($arrParams) { try { //default response $return = array('update_award' => 0); //new instance object $modelNews = new Thethao_Model_News(); $response = array(); if (!empty($arrParams)) { if ($arrParams['award'] == AWARD_DOVUI) { $response[] = $modelNews->getListEndAward(array('isGearman' => true, 'object_type' => OBJECT_TYPE_DOVUI, 'award' => AWARD_DOVUI, 'fromdate' => $arrParams['fromdate'], 'todate' => $arrParams['todate'])); } else { $response[] = $modelNews->getListAward(array('isGearman' => true, 'object_type' => OBJECT_TYPE_DOVUI, 'award' => $arrParams['award'], 'fromdate' => $arrParams['fromdate'], 'todate' => $arrParams['todate'])); } self::clearApcFile(); } $return['update_award'] = $response; } catch (Exception $ex) { //log error Thethao_Global::sendLog($ex); } return $return; }
/** * 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); }
/** * @author : VinhNT * @name : ajaxsendmailAction * @copyright : FPT Online * @todo : ajaxsendmail Action * @return : array('error' => 0, 'message' => '', 'body' => '') */ public function ajaxsendmailAction() { //Disable layout $this->_helper->layout->disableLayout(true); //Set no render view $this->_helper->viewRenderer->setNoRender(true); //default return $response = array('error' => 0, 'message' => ''); /* ----------------------------------------------------------------- Get param sent to job send mail */ try { $arrParams = $this->_request->getPost(); //Trim captcha id $arrCaptcha['id'] = trim($arrParams['captchaID']); $arrCaptcha['input'] = trim($arrParams['txtCode']); // Creating a Zend_Captcha_Image instance $captcha = new Zend_Captcha_Image(); // would be key/value array: id => captcha ID, input => captcha value if ($captcha->isValid($arrCaptcha)) { // Include config send mail include APPLICATION_PATH . '/configs/mail.php'; //Check config sender if (is_array($configsender) && !empty($configsender)) { // Get Url to send $url_send = $arrParams['url']; $url_send = addslashes(str_replace(array('=', '(', ')'), '', trim(strip_tags($url_send)))); $url_send = str_replace('http://thethao.vnexpress.net', 'http://seagames.vnexpress.net', $url_send); // Get name of the sender $sender_name = $arrParams['sender_name']; $sender_name = addslashes(str_replace(array('=', '(', ')'), '', trim(strip_tags($sender_name)))); if (empty($sender_name)) { $response['error'] = 1; $response['message'] = 'Xin hãy nhập họ tên người gửi.'; echo Zend_Json::encode($response); exit; } // Get user email $email_user = $arrParams['email_user']; $email_user = addslashes(str_replace(array('=', '(', ')'), '', trim(strip_tags($email_user)))); //Check email user if (empty($email_user)) { $response['error'] = 1; $response['message'] = 'Xin hãy nhập email người gửi.'; echo Zend_Json::encode($response); exit; } // Get title of send mail $title_email = urldecode($arrParams['title_email']); $title_email = addslashes(str_replace(array('=', '(', ')'), '', trim(strip_tags($title_email)))); //Set parrams email sender $sender_email = $configsender['message']['email']; // Get email of the reciever $reciever_mail = $arrParams['receiver_mail']; $reciever_mail = addslashes(str_replace(array('=', '(', ')'), '', trim(strip_tags($reciever_mail)))); //Check reciever mail if (empty($reciever_mail)) { $response['error'] = 1; $response['message'] = 'Xin hãy nhập email người nhận.'; echo Zend_Json::encode($response); exit; } // Get message mail $message_mail = $arrParams['message_mail']; $message_mail = trim(strip_tags($message_mail)); //Get body message $body_message = '<strong>' . $sender_name . '(' . $email_user . ')</strong><br/>Đã gửi cho bạn bài báo tại link: <a href="' . $url_send . '" title="' . $title_email . '">' . $url_send . '</a>'; //Check message mail if (!empty($message_mail)) { $body_message .= '<br/>Với nội dung: </br>' . $message_mail; } $body_message .= '<hr><br/>Email này được gửi bằng tiện ích "Gửi cho bạn bè" của <b>SEAGames.VnExpress.net<b>'; //Get array mail $arrEmail = explode(';', $reciever_mail); $arrEmailReciever = array(); //Check array email if (!empty($arrEmail)) { foreach ($arrEmail as $email) { $email = trim($email); //If email is NOT valid if (@(!eregi("^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)+\$", (string) $email))) { //if (@!Fpt_Valid::isEmail($email)) continue; } //Put data to arrReciever $arrEmailReciever[] = array('email' => $email, 'alias' => $email); } if (!empty($arrEmailReciever)) { //push job call send mail $jobParams = array('class' => 'Job_Thethao_JobMessage', 'function' => 'sendMail', 'args' => array('sender' => $sender_email, 'name' => 'VNE SEA Games', 'reciever' => $arrEmailReciever, 'subject' => $title_email, 'body' => $body_message)); //get application config $config = Thethao_Global::getApplicationIni(); //To array $jobConfiguration = $config['job']['task']['sport']['send_mail']; //get job send mail instance $jobClient = Thethao_Global::getJobClientInstance('sport'); //Register job $result = $jobClient->doBackgroundTask($jobConfiguration, $jobParams); if (!$result) { $response['error'] = 1; $response['message'] = 'Không gửi được email. Xin vui lòng thử lại sau.'; echo Zend_Json::encode($response); exit; } else { $response['error'] = 0; $response['message'] = 'Gửi email thành công.'; echo Zend_Json::encode($response); exit; } } else { $response['error'] = 1; $response['message'] = 'Email gửi đến không hợp lệ'; echo Zend_Json::encode($response); exit; } } } else { $response['error'] = 1; $response['message'] = 'Empty recipient.'; echo Zend_Json::encode($response); exit; } } else { $response['error'] = 2; $response['message'] = 'Mã xác nhận không đúng.'; echo Zend_Json::encode($response); exit; } } catch (Exception $ex) { // Log error Thethao_Global::sendLog($ex); } echo Zend_Json::encode($response); exit; }
public function getListAward($arrParams) { //default return $arrResult = array(); try { //get db slave $db_s = Thethao_Global::getDB('interaction', 'slave'); // Call sp get detail book $stmt = $db_s->prepare('CALL sp_getListAwardResult(:p_object_type, :p_award , :p_fromdate , :p_todate)'); // Bind param $stmt->bindParam('p_object_type', $arrParams['object_type'], PDO::PARAM_INT); $stmt->bindParam('p_award', $arrParams['award'], PDO::PARAM_INT); $stmt->bindParam('p_fromdate', $arrParams['fromdate'], PDO::PARAM_INT); $stmt->bindParam('p_todate', $arrParams['todate'], PDO::PARAM_INT); // Execute sp $stmt->execute(); //fetch result $arrResult = $stmt->fetchAll(); // Close cursor $stmt->closeCursor(); // Release unset($stmt); } catch (Zend_Db_Exception $ex) { //log error Thethao_Global::sendLog($ex); } return $arrResult; }
Zend_Controller_Front::getInstance()->setParam('bootstrap', $application); //unset applicaion unset($application); //Try execute $result = array(); try { //get model news $modelNews = Thethao_Model_News::getInstance(); //get model category $modelCategory = Thethao_Model_Category::getInstance(); //get full array cate $arrCate = $modelCategory->getFullCategoryByParentId(); //only get id $arrCate = array_keys($arrCate); //add site_id $arrCate[] = SITE_ID; //clear cache $result['interaction'] = $modelNews->clearCacheTop('all', $arrCate); //get top view 24h all Site $result['top_view_all_site'] = $modelNews->getTopView24hAllSite(); //Closed all resource Thethao_Global::closeResource(); Fpt_Data_Model::_destruct(); } catch (Exception $ex) { //send log Thethao_Global::sendLog($ex); //Closed all resource Thethao_Global::closeResource(); Fpt_Data_Model::_destruct(); echo $ex->getMessage(); }
/** * Get article by category code * @param string $strCode * @return <array> Article information * @author: phongtx@fpt.net */ public function getCategoryByCode($strCode) { try { $cateID = $this->getIdByCode($strCode); if ($cateID > 0) { $arrInfo = $this->getDetailbyCateId($cateID); return $arrInfo; } } catch (Exception $ex) { Thethao_Global::sendLog($ex); } return false; }
/** * Get list season by ids * @param array $arrSeasonIDs * @return array|bool * @author QuangTM */ public function getListSeasonByIDs($arrSeasonIDs) { try { // Convert from array to string $strSeasonIds = implode(',', $arrSeasonIDs); // Get DB Obj $dbObj = Thethao_Global::getDB('sport', 'slave'); // Prepare SQL $stmt = $dbObj->prepare('CALL sp_fesport_getListSeasonByIDs(:p_seasonids);'); // Bind param $stmt->bindParam('p_seasonids', $strSeasonIds, PDO::PARAM_STR); // Execute $stmt->execute(); // Get result $result = array(); // Get format data $formatInstance = new Thethao_Business_Football_Metadata_Season(); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { array_push($result, $formatInstance->init($row)->getFormatedData()); } // Close $stmt->closeCursor(); // Release variables unset($stmt, $strSeasonIds, $formatInstance); return $result; } catch (Exception $ex) { Thethao_Global::sendLog($ex); } }
/** * Get job client * @param string $strFarmName * @param string $zoneName * @return Fpt_Job_Client * @author LamTX */ public static function getJobClientInstance($strFarmName = 'sport', $zoneName = ZONE_ENV) { try { //Get caching instance if (!isset(self::$_jobClient[$strFarmName])) { //get array conf $arrConf = Thethao_Global::getApplicationIni(); //get job client instance self::$_jobClient[$strFarmName] = Fpt_Job_Client::factory($arrConf['job'][$zoneName][$strFarmName]['adapter'], $arrConf['job'][$zoneName][$strFarmName]); unset($arrConf); } //Return jobclient return self::$_jobClient[$strFarmName]; } catch (Exception $ex) { //log error Thethao_Global::sendLog($ex); return false; } }
/** * get data from table keybox with key id * @param int $intKeyId * @return array */ public function getKeyBox($arrKey = NULL) { $arrReturn = array(); try { //get db slave $sport_m = Thethao_Global::getDB('sport', 'slave'); // Get user activeation key $objStmt = $sport_m->prepare('CALL sp_getKeyBox(:p_keyid)'); // Bind param $objStmt->bindParam('p_keyid', $arrKey, PDO::PARAM_STR); // Fetch result $objStmt->execute(); //fetch result while ($row = $objStmt->fetch()) { $arrReturn[$row['key_id']] = $row['values']; } // Close cursor $objStmt->closeCursor(); // Release unset($objStmt); } catch (Zend_Db_Exception $ex) { Thethao_Global::sendLog($ex); } return $arrReturn; }
/** * delete article from BE Editor by arr info * @param array $arrArticle * @return boolean|array * @author PhuongTN */ public function deleteArticle($arrArticle) { try { //default return $arrReturn = false; //get instance redis $redisInstance = Thethao_Global::getRedis('article'); //check can get redis instance if ($redisInstance) { //Rule1:Add list folder news if (!empty($arrArticle['cate_rule1'])) { //loop category rule1 foreach ($arrArticle['cate_rule1'] as $cateId) { //generate key cache with all article (text, video, photo) cate original $keyCache = vsprintf($this->_list_article_ids_by_rule_1, array($cateId, 0)); $redisInstance->zAdd($keyCache, -1, $arrArticle['article_id']); $rs = $redisInstance->zDelete($keyCache, $arrArticle['article_id']); if ($rs) { $totalRule1 = $redisInstance->get($keyCache . ':total'); if ($totalRule1 > 0) { $redisInstance->set($keyCache . ':total', $totalRule1 - 1); } } //generate key cache with all article (text, video, photo) cate original $keyCache = vsprintf($this->_list_article_ids_by_rule_1, array($cateId, $arrArticle['article_type'])); $redisInstance->zAdd($keyCache, -1, $arrArticle['article_id']); $rs = $redisInstance->zDelete($keyCache, $arrArticle['article_id']); if ($rs) { $totalRule1 = $redisInstance->get($keyCache . ':total'); if ($totalRule1 > 0) { $redisInstance->set($keyCache . ':total', $totalRule1 - 1); } } } } //Rule2:Add list folder + list on news if (!empty($arrArticle['cate_list_on'])) { //loop cate foreach ($arrArticle['cate_list_on'] as $cateId) { //generate key cache $keyCache = sprintf($this->_list_article_ids_by_rule_2, $cateId); $redisInstance->zAdd($keyCache, -1, $arrArticle['article_id']); $rs = $redisInstance->zDelete($keyCache, $arrArticle['article_id']); if ($rs) { $total = $redisInstance->get($keyCache . ':total'); if ($total > 0) { $redisInstance->set($keyCache . ':total', $total - 1); } } } } //Rule3:Latest news if (!empty($arrArticle['cate_rule3'])) { //loop cate rule 3 foreach ($arrArticle['cate_rule3'] as $cateId) { $keyCache = vsprintf($this->_list_article_ids_by_rule_3, array($cateId, 0)); $redisInstance->zAdd($keyCache, -1, $arrArticle['article_id']); $rs = $redisInstance->zDelete($keyCache, $arrArticle['article_id']); if ($rs) { $total = intval($redisInstance->get($keyCache . ':total')); if ($total > 0) { $redisInstance->set($keyCache . ':total', $total - 1); } } $keyCache = vsprintf($this->_list_article_ids_by_rule_3, array($cateId, $arrArticle['article_type'])); $redisInstance->zAdd($keyCache, -1, $arrArticle['article_id']); $rs = $redisInstance->zDelete($keyCache, $arrArticle['article_id']); if ($rs) { $total = intval($redisInstance->get($keyCache . ':total')); if ($total > 0) { $redisInstance->set($keyCache . ':total', $total - 1); } } } $keyCache = vsprintf($this->_list_article_ids_by_rule_3, array(SITE_ID, 0)); $redisInstance->zAdd($keyCache, -1, $arrArticle['article_id']); $rs = $redisInstance->zDelete($keyCache, $arrArticle['article_id']); if ($rs) { $total = intval($redisInstance->get($keyCache . ':total')); if ($total > 0) { $redisInstance->set($keyCache . ':total', $total - 1); } } $keyCache = vsprintf($this->_list_article_ids_by_rule_3, array(SITE_ID, $arrArticle['article_type'])); $redisInstance->zAdd($keyCache, -1, $arrArticle['article_id']); $rs = $redisInstance->zDelete($keyCache, $arrArticle['article_id']); if ($rs) { $total = intval($redisInstance->get($keyCache . ':total')); if ($total > 0) { $redisInstance->set($keyCache . ':total', $total - 1); } } } // end rule 3 $arrReturn = true; } //end check redis instance } catch (Exception $ex) { //writelog error Thethao_Global::sendLog($ex); } return $arrReturn; }
/** * delete related list news when delete article from BE editor * @param array $arrArticleDetail old detail article * @return array * @author PhuongTN * @todo thethao */ public function deleteArticle($arrArticleDetail) { try { $arrResponse = array(); //get app conf $config = Thethao_Global::getApplicationIni(); //get list rule category $this->getArticleForJob($arrArticleDetail); //get news nosql instance $newsNosql = $this->factory('Article', $config['database']['nosql']['adapter']); //call deletea list $arrResponse['nosql_article'] = $newsNosql->deleteArticle($arrArticleDetail); //init model news $modelNews = Thethao_Model_News::getInstance(); //precache rule 3 cho site seagames $param_rule3 = array('category_id' => SEA_GAMES, 'offset' => 0, 'limit' => 1); $arrResponse['rule3'] = $modelNews->getListArticleIdsByRule3($param_rule3); } catch (Exception $ex) { Thethao_Global::sendLog($ex); } //return data return $arrResponse; }
public function setListEndAward($arrParams, $data) { $arrReturn = true; try { //get instance redis $redisInstance = Thethao_Global::getRedis('article'); if ($redisInstance) { if (empty($data)) { $keyCache = vsprintf($this->_end_list_award, $arrParams['fromdate']); $redisInstance->delete($keyCache); //$redisInstance->zAdd($keyCache, '0', null); } else { $i = 1; foreach ($data as $key => $item) { $keyCache = vsprintf($this->_end_list_award, $arrParams['fromdate']); if ($i == 1 && !empty($item)) { $redisInstance->delete($keyCache); } //echo $json_encode($item); $item['display_order'] = 100 - $item['display_order']; $redisInstance->zAdd($keyCache, $item['display_order'], json_encode($item)); $i++; } } } } catch (Exception $ex) { Thethao_Global::sendLog($ex); } return $arrReturn; }