Esempio n. 1
0
 /**
  * Pre-caching for tennis player information.<br />
  * 2 case in this function.<br />
  * Clear cache after that read from model to write new data into cache.
  * @param array $params Must has key arrPlayerIds. That is array player id
  * @author QuangTM
  */
 public static function preCachingTennisPlayer($params)
 {
     //set array player id
     $arrPlayerIds = $params['arrPlayerIds'];
     //set array player id to NULL
     $params['arrPlayerIds'] = array();
     //array chunk
     $arrChunk = array_chunk($arrPlayerIds, 10);
     //loop
     foreach ($arrChunk as $listId) {
         //new object framework
         $modelObject = new Fpt_Data_Materials_Object();
         // Get tennis model
         $tennisModel = new Thethao_Model_Tennis();
         $model = $modelObject->getTennis();
         foreach ($listId as $playerID) {
             $model->updateObject($playerID);
         }
         //end foreach
         //precache
         $params['arrPlayerIds'] = $listId;
         $tennisModel->preCachingTennisPlayer($params);
         //close resource
         Thethao_Global::closeResource();
         Fpt_Data_Model::_destruct();
     }
     //end foreach
 }
Esempio n. 2
0
 /**
  * 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;
 }
Esempio n. 3
0
 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;
 }
Esempio n. 4
0
 /**
  * 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;
 }
Esempio n. 5
0
 /**
  * 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;
 }
Esempio n. 6
0
 /**
  * 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;
 }
function function_reduce($job)
{
    ini_set('memory_limit', '1G');
    ini_set('display_errors', 1);
    global $objWorker;
    $arrData = $objWorker->getNotifyData($job);
    //Get class
    $className = $arrData['class'];
    //Get function
    $function = $arrData['function'];
    if (!($className && $function)) {
        echo 'not class or function 1"' . $className . '", "' . $function . '"';
        return true;
    }
    //check params
    $args = $arrData['args'];
    try {
        Fpt_Data_Model::_destruct();
        //close resource cache central
        $result = call_user_func_array(array($className, $function), array($args));
        if ($result === NULL) {
            echo 'not class or function return null"' . $className . '", "' . $function . '"';
        }
        var_dump('===Result===', Zend_Json::encode($result), '______________________________________');
        Thethao_Global::closeResource();
        Fpt_Data_Model::_destruct();
        //close resource cache central
        /*
        		$logfile = realpath(dirname(__FILE__)) . '/logs/crawler-' . $function . '-' . date("Y-m-d") . '.log';
                $logger  = new Zend_Log();
                $writer  = new Zend_Log_Writer_Stream($logfile);
                $logger->addWriter($writer);
                $logdata = "\n";
                $logdata .= "Result execute :" . Zend_Json::encode($result);
                $logdata .= "\n";
                $logdata .= "Execute function: '" . $function . "' at class : '" . $className . "' with params :" . Zend_Json::encode($args) . "\n";
                $logger->log($logdata, Zend_Log::INFO);*/
    } catch (Exception $ex) {
        print_r($ex);
        return false;
    }
    return true;
}
Esempio n. 8
0
 /**
  * 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;
 }
function function_reduce($job)
{
    global $objWorker;
    $arrData = $objWorker->getNotifyData($job);
    //Get class
    $className = $arrData['class'];
    //Get function
    $function = $arrData['function'];
    if (!($className && $function)) {
        var_dump($className, $function);
        echo 'not class and function 1';
        return true;
    }
    //check params
    $args = $arrData['args'];
    try {
        Thethao_Global::closeResource();
        //close resource cache central
        $result = call_user_func_array(array($className, $function), array($args));
        if ($result === NULL) {
            var_dump($className, $function);
            echo 'not class, function or return null ';
        }
        Thethao_Global::closeResource();
        $logfile = realpath(dirname(__FILE__)) . '/logs/fontend-' . $function . '-' . date("Y-m-d") . '.log';
        $logger = new Zend_Log();
        $writer = new Zend_Log_Writer_Stream($logfile);
        $logger->addWriter($writer);
        $logdata = "\n";
        $logdata .= "Result execute :" . Zend_Json::encode($result);
        $logdata .= "\n";
        $logdata .= "Execute function: '" . $function . "' at class : '" . $className . "' with params :" . Zend_Json::encode($args) . "\n";
        echo "====>Result execute :" . Zend_Json::encode($result);
        $logger->log($logdata, Zend_Log::INFO);
    } catch (Exception $ex) {
        print_r($ex);
        return false;
    }
    return true;
}
Esempio n. 10
0
 /**
  * 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;
 }
Esempio n. 11
0
 /**
  * Get list league and season by team attend
  * @param int $teamID
  * @return array|boolean
  * @author QuangTM
  */
 public function getListLeagueAndSeasonTeamAttend($teamID)
 {
     $result = array();
     try {
         // Get redis instance
         $redisInstance = Thethao_Global::getRedis('article');
         // Get key cache
         $pattern = vsprintf($this->_team_match_league, array($teamID, '*'));
         // Get array key
         $arrKeys = $redisInstance->keys($pattern);
         // Pattern for get league
         $pattern = '/' . str_replace('*', '(\\d+)', $pattern) . '/';
         $match = null;
         foreach ($arrKeys as $key) {
             if (preg_match($pattern, $key, $match)) {
                 $result[$match[1]] = $redisInstance->sMembers($key);
             }
         }
     } catch (Exception $ex) {
         Thethao_Global::sendlog($ex);
     }
     return $result;
 }
Esempio n. 12
0
 /**
  * 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;
 }
Esempio n. 13
0
 /**
  * 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;
 }
Esempio n. 14
0
 /**
  * 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);
     }
 }
Esempio n. 15
0
 /**
  * Get search instance
  * @author HungNT1
  * @return <Fpt_Search>
  */
 public static function getSearch()
 {
     //Get search instance
     if (self::$_searchObject == null) {
         $configs = self::getApplicationIni('search');
         //Get search instance
         self::$_searchObject = Fpt_Search::factory('solr', $configs['object']['solr']);
     }
     //Return caching
     return self::$_searchObject;
 }
Esempio n. 16
0
function function_reduce($job)
{
    $time_start = microtime(true);
    global $objWorker;
    $arrData = $objWorker->getNotifyData($job);
    echo "\n ************" . date('Y/m/d H:i:s') . "**************\n";
    var_dump($arrData);
    //Get class
    $className = $arrData['class'];
    //Get function
    $function = $arrData['function'];
    if (!($className && $function)) {
        echo 'not class and function';
        return true;
    }
    //check params
    $args = $arrData['args'];
    try {
        Fpt_Data_Model::_destruct();
        //close resource cache central
        $result = call_user_func_array(array($className, $function), array($args));
        if ($result === NULL) {
            $result = array('success' => 0, 'return null / not class or function');
        } else {
            $returnCode = $result != false ? 1 : 0;
            $result = array('success' => $returnCode, $result);
        }
        //Closed all resource
        Thethao_Global::closeResource();
        Fpt_Data_Model::_destruct();
        //close resource cache central
        $logfile = realpath(dirname(__FILE__)) . '/logs/backend-' . $function . '-' . date("Y-m-d") . '.log';
        $logger = new Zend_Log();
        $writer = new Zend_Log_Writer_Stream($logfile);
        $logger->addWriter($writer);
        $logdata = "\n";
        $logdata .= "Result execute :" . Zend_Json::encode($result);
        $logdata .= "\n";
        $logdata .= "Execute function: '" . $function . "' at class : '" . $className . "' with params :" . Zend_Json::encode($args) . "\n";
        $logger->log($logdata, Zend_Log::INFO);
    } catch (Exception $ex) {
        $result = array('success' => 0, $ex->getMessage());
    }
    $end = microtime(true) - $time_start;
    echo "\n Time:" . $end . ' - ' . date("Y/m/d H:i:s");
    echo "\n Memory:" . round(memory_get_usage(true) / 1048576, 2) . " megabytes";
    echo "\n Result:";
    var_dump($result);
}
Esempio n. 17
0
 /**
  * @author      : HungNT
  * call job clear cache keybox fe
  * @todo        : clearCacheKeybox
  * @param type $arrParams
  */
 public function clearCacheKeybox($params)
 {
     // Delete cache
     $keyCache = Thethao_Global::makeCacheKey($params['key_id']);
     if (!$keyCache) {
         $keyCache = $params['key_id'];
     }
     Thethao_Global::deleteMemcache(array($keyCache));
     // Get player model
     $model = new Thethao_Model_Block();
     $arrReturn = $model->getKeyBox($params);
     //init news instance
     $caching = Thethao_Model_Caching::getInstance();
     $caching->clearCacheFile();
     //return
     return $arrReturn;
 }
Esempio n. 18
0
 /**
  * @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);
     }
 }
 /**
  * cate folder page
  * @author HungNT1
  */
 public function indexAction()
 {
     //set cache
     $this->_request->setParam('cache_file', 1);
     //get instance Cate
     $objCate = Thethao_Model_Category::getInstance();
     //get cate id by cate code
     $intCateId = $objCate->getIdByCode($this->_request->getParam('cate_code', SITE_ID));
     //get page of cate
     $intPage = $this->_request->getParam('page', 1);
     //check cate id is not exists
     if ($intCateId < 1) {
         $this->_redirect("/");
     }
     // Get Category detail
     $cateDetail = $objCate->getDetailByCateId($intCateId);
     //str link
     $strLink = $this->_request->getPathInfo();
     if (strpos(rtrim($strLink, '/'), $cateDetail['link']) === FALSE) {
         $this->_redirect($this->view->configView['url'] . $cateDetail['link'], array('code' => 301));
     }
     //init param to get list data with rule 2
     $arrParamNews = array('category_id' => $intCateId, 'article_type' => NULL, 'limit' => LIMIT_LIST, 'offset' => ($intPage - 1) * LIMIT_LIST);
     //init model news
     $objNews = Thethao_Model_News::getInstance();
     //get list article with rule 2 list on Thethao
     $arrListData = $objNews->getListArticleIdsByRule2($arrParamNews);
     $arrArticleExclude = array();
     $arrHotNews = array();
     //get Instance Block
     $objBlock = Thethao_Plugin_Block::getInstance();
     if (1 == $intPage && !empty($arrListData['data'])) {
         //check bai thuong mai, chi so sanh o trang 1 ma thoi
         $zoneID = Thethao_Global::getZoneByCateId($intCateId);
         if ($zoneID != 0) {
             $modelBlock = Fpt_Data_News_Block::getInstance();
             $modelBlock->setZoneId($zoneID);
             $arrListData['data'] = $modelBlock->getNewsByZone($zoneID, $arrListData['data']);
         }
         $arrArticleExclude = $arrListData['data'];
         // set exclude article id from arrData
         $objBlock->setExclude($arrListData['data']);
         $arrHotNews = array_slice($arrListData['data'], 0, LIMIT_TOP);
         $arrListData['data'] = array_diff($arrListData['data'], $arrHotNews);
         // set id from $arrListPaging to get article
         $this->view->objArticle->setIdBasic($arrHotNews);
     }
     // set id from $arrListPaging to get article
     $this->view->objArticle->setIdBasic($arrListData['data']);
     //check if page > max page then return to max page
     if ($arrListData['total'] > 0) {
         $maxPage = ceil($arrListData['total'] / LIMIT_LIST);
         if ($intPage > $maxPage) {
             $this->_redirect($this->configView['url'] . $cateDetail['link'] . '/page/' . $maxPage . '.html');
         }
     }
     //InitParam Paging
     $arrParamPaging = array('total' => $arrListData['total'], 'page' => $intPage, 'url' => $this->view->configView['url'] . $cateDetail['link'] . '/page', 'perpage' => LIMIT_LIST, 'classPagination' => 'pagination_news right', 'extEnd' => '.html', 'separate' => '/');
     //Set param
     $this->_request->setParam('block_cate', $intCateId);
     //Param calendar
     $parserParent = SITE_ID;
     $parserChild = $intCateId;
     $parserChildRecursive = 0;
     if (!empty($cateDetail['full_parent']) && DEVICE_ENV != 1) {
         $nParser = count($cateDetail['full_parent']);
         switch ($nParser) {
             case 1:
                 $parserChild = $cateDetail['full_parent'][0];
                 $parserChildRecursive = $intCateId;
                 break;
             case 2:
             default:
                 $parserChild = $cateDetail['full_parent'][0];
                 $parserChildRecursive = $cateDetail['full_parent'][1];
                 break;
         }
         //end switch
     }
     //end if
     //gan meta data
     $titleMenta = $keywords = $cateDetail['catename'] . ' - VnExpress Thể Thao';
     $description = $cateDetail['catename'] . ' - VnExpress Thể Thao';
     switch ($intCateId) {
         case CATE_ID_BONGDA:
             $titleMenta = 'Lưu trữ tin tức bóng đá thể thao – Bóng đá thể thao';
             $description = 'Lưu trữ tin tức hình ảnh các ngôi sao thể thao,bóng đá,hậu trường thể thao';
             $keywords = 'Bong da,the thao,tin tuc bong đá, bóng đá 24h';
             break;
         case CATE_ID_BONGDATRONGNUOC:
             $titleMenta = 'Tin tức, bình luận, Tin tức thể thao trong nước mới nhất, V-League, VFF – Bóng đá trong nước';
             $description = 'Thông tin mới nhất về THỂ THAO TRONG NƯỚC, Liên đoàn Bóng Đá Việt Nam, các giải đấu, lịch thi đấu V League, VFF, ĐTQG, Cúp Quốc Gia, Giải Hạng Nhất, U19, U23';
             $keywords = 'Tin tức, bong da, bóng đá việt nam,V-League, VFF bóng đá trong nước';
             break;
         case CATE_ID_NGOAIHANGANH:
             $titleMenta = 'Tin tức, bình luận, video, lịch thi đấu bóng đá giải - Ngoại hạng Anh';
             $description = 'Ngoại hạng Anh - Tin tức giải Premier League , Video bàn thắng, bảng xếp hạng, lịch thi đấu Ngoại hạng Anh, liên tục trên thể thao vnexpress';
             $keywords = 'Giải ngoại hạng Anh , ngoai hang anh , bong da ngoai hang anh , bong da anh , tin bong da , bong da quoc te , bao bong da';
             break;
         case CATE_ID_BEHINDS_SCENES:
             $titleMenta = 'Lưu trữ tin tức hậu trường thể thao';
             $description = 'Lưu trữ tin tức hình ảnh các ngôi sao thể thao,bóng đá,hậu trường thể thao';
             $keywords = 'Hau truong,the thao,bong da';
             break;
         case CATE_ID_CACMONKHAC:
             $titleMenta = 'Tin nhanh,hình ảnh,video kết quả thi đấu các môn thể thao khác';
             $description = 'Tin tức,hình ảnh,video các môn thể thao khác';
             $keywords = 'Bong da,the thao,tin tuc';
             break;
         case CATE_ID_TENNIS:
             $titleMenta = 'Tin tức quần vợt, tennis, lịch thi đấu, video trực tuyến - Tennis';
             $description = 'Cập nhật nhanh tin tức Quần vợt mới nhất hôm nay. Xem kết quả, lịch thi đấu, video clip thể thao Tennis trực tuyến Online tại Việt Nam & Thế giới.';
             $keywords = 'tennis 24h, quan vot, tennis truc tuyen , tennis online, tin tuc tennis, lich thi dau tennis';
             break;
         case CATE_ID_RACING:
             $titleMenta = 'Đua xe - Thể thao VnExpress';
             $description = 'Cập nhật nhanh tin tức, video các giải đua xe trong và ngoài nước.';
             $keywords = 'Đua xe, tay dua, cong thuc 1 , du axe F1';
             break;
         case CATE_ID_AFFCUP:
             $titleMenta = 'Aff Cup 2012 - Tin tức, hình ảnh ,video mới nhất về AFF Cup 2012 - VnExpress';
             $description = 'Cập nhật liên tục tin tức mới nhất về giải bóng đá Đông Nam Á - AFF cup 2012 tổ chức tại Malaysia và Thái Lan';
             $keywords = 'aff cup 2012,bong da,the thao';
             break;
         case CATE_ID_CHESS:
             $titleMenta = 'Cờ Vua: Lịch thi đấu, giải thi đấu cờ vua - VnExpress Thể Thao';
             $description = 'Tin tức nhanh về thông tin các giải thi đấu cờ vua Quốc tế, giải thi đấu tại Việt Nam cùng các cờ thủ xuất sắc nhất';
             $keywords = 'Tin tức nhanh về thông tin các giải thi đấu cờ vua Quốc tế, giải thi đấu tại Việt Nam cùng các cờ thủ xuất sắc nhất';
             break;
         case CATE_ID_GOLF:
             $titleMenta = 'Tin Golf Việt Nam: Giải đấu và lịch thi đấu môn đánh Golf – Golf thể thao';
             $description = 'Tin tức, video đánh giá bình luận về Golf, nhận xét các giải đấu trong nước, quốc tế cùng hướng dẫn các kỹ năng chơi Golf dành cho giới kinh doanh, Golf thủ Việt Nam..';
             $keywords = 'Golf thủ, tay golf,tin tức golf, giải golf, Presidents Cup, FLC Golf Championship 2015';
             break;
         default:
             $titleMenta = 'Tin tức, bình luận, video, lịch thi đấu bóng đá giải - ' . $cateDetail['catename'];
             $description = 'Tin nhanh,tin tức với hình ảnh,Video clip,bình luận về các giải bóng đá: ' . $cateDetail['catename'];
             $keywords = 'Tin tức, bong da, the gioi';
     }
     //Assign to view
     $this->view->assign(array('intCategoryId' => $intCateId, 'arrHotNews' => $arrHotNews, 'arrParamPaging' => $arrParamPaging, 'arrData' => $arrListData['data'], 'parserParent' => $parserParent, 'parserChild' => $parserChild, 'parserChildRecursive' => $parserChildRecursive, 'arrArticleExclude' => $arrArticleExclude, 'paramsBlock' => Zend_Json::encode(array('pagecode' => 'default_category_index_' . $intCateId, 'exclude' => implode(',', $objBlock->getExclude()))), 'ogType' => 'website', 'ogTitle' => $titleMenta, 'ogUrl' => $this->view->configView['url'] . $cateDetail['link'], 'ogImage' => 'http://m.f9.img.vnexpress.net/2014/01/10/fa68f81afe10b727852361b1894ccc74.jpg', 'ogDescription' => $description));
     //init cate for set menu
     $idCateMenu = $cateDetail['parent_id'] == SITE_ID ? $intCateId : $cateDetail['parent_id'];
     //set cate active
     $this->_request->setParam('cateActiveId', $intCateId);
     //set cateid to show active in menu
     $this->_request->setParam('cateid', $idCateMenu);
     // Set metadata tags
     $this->view->headTitle()->prepend($titleMenta);
     $this->view->headMeta()->setName('description', $description)->setName('keywords', $keywords);
     if (DEVICE_ENV != 1) {
         //ad js
         $this->view->headScript()->appendFile($this->view->configView['vnecdn']['js'] . '/utils/calendar/calendar.js');
     } else {
         //Set no render view
         $this->_helper->viewRenderer->setNoRender(true);
         echo $this->view->render('mobile/index.phtml');
     }
 }
Esempio n. 20
0
 /**
  * Get list match ids by league
  * @param int $teamID
  * @param int $beginHappenDateTime
  * @param int $endHappenDateTime
  * @param boolean - asort array
  * @return array|boolean
  * @author ThuyNT
  */
 public function getMatchIDsByLeague($leagueID, $beginHappenDateTime = NULL, $endHappenDateTime = NULL, $rev = TRUE)
 {
     // Default result to return
     $result = FALSE;
     $flag = TRUE;
     try {
         // Get application config
         $config = Thethao_Global::getApplicationIni();
         //get object redis
         $matchNosqlInstance = $this->factory('Match', $config['database']['nosql']['adapter']);
         // Read from redis first
         $result = $matchNosqlInstance->getListMatchesByHappenTime($leagueID, $beginHappenDateTime, $endHappenDateTime);
         // If miss cache redis => read from DB
         if (empty($result['data']) && FROM_JOB == 1) {
             //get mysql instance
             $matchMysqlInstance = $this->factory('Match', $config['database']['default']['adapter']);
             // Read data from MySQL
             $result = $matchMysqlInstance->getListMatchesByHappenTime($beginHappenDateTime, $endHappenDateTime, $leagueID, $gmt = 0, $flag);
             //check to set redis
             if (!empty($result)) {
                 $matchNosqlInstance->setMatchIDsByLeague($leagueID, $result);
             }
             $intTotal = count($result);
             $arrTest = array_values($result);
             if ($beginHappenDateTime) {
                 for ($i = $intTotal - 1; $i > 0; $i--) {
                     if ($arrTest[$i] >= $beginHappenDateTime) {
                         $result = array_slice($result, 0, $i + 1, true);
                         $i = 0;
                     }
                 }
             }
             if ($endHappenDateTime) {
                 for ($i = 0; $i < $intTotal; $i++) {
                     if ($arrTest[$i] <= $endHappenDateTime) {
                         $result = array_slice($result, $i, NULL, true);
                         $i = $intTotal;
                     }
                 }
             }
         } else {
             $result = $result['data'];
         }
         if (!$rev && !empty($result)) {
             asort($result);
         }
     } catch (Exception $ex) {
         Fpt_Data_Model::sendLog($ex);
     }
     return $result;
 }
Esempio n. 21
0
 /**
  * @todo - VnE Thethao home page
  * @author HungNT1
  */
 public function indexAction()
 {
     //set cache
     $this->_request->setParam('cache_file', 1);
     // Get block cate
     $intCateId = $this->_request->getParam('cateid', SITE_ID);
     //get page
     $intPage = $this->_request->getParam('page', 1);
     //get Instance New
     $objNews = Thethao_Model_News::getInstance();
     //get Instance News
     $objArticle = $this->view->objArticle;
     //init params to get list article with rule 2, list on folder Thethao
     $arrParamNews = array('category_id' => $intCateId, 'limit' => LIMIT_LIST, 'offset' => ($intPage - 1) * LIMIT_LIST, 'article_type' => NULL);
     //get list article with rule 2 list on Thethao
     $arrListData = $objNews->getListArticleIdsByRule2($arrParamNews);
     //check if page > max page then return to max page
     if ($arrListData['total'] > 0) {
         $maxPage = ceil($arrListData['total'] / LIMIT_LIST);
         if ($intPage > $maxPage) {
             $this->_redirect($this->configView['url'] . '/page/' . $maxPage . '.html');
         }
     }
     //set data exclude
     $arrArticleExclude = array();
     $arrHotNews = array();
     //get Instance Block
     $objBlock = Thethao_Plugin_Block::getInstance();
     if (1 == $intPage && !empty($arrListData['data'])) {
         //check bai thuong mai, chi so sanh o trang 1 ma thoi
         $zoneID = Thethao_Global::getZoneByCateId(SITE_ID);
         if ($zoneID != 0) {
             $modelBlock = Fpt_Data_News_Block::getInstance();
             $modelBlock->setZoneId($zoneID);
             $arrListData['data'] = $modelBlock->getNewsByZone($zoneID, $arrListData['data']);
         }
         //set data exclude
         $arrArticleExclude = $arrListData['data'];
         // set exclude article id from arrData
         $objBlock->setExclude($arrListData['data']);
         $arrHotNews = array_slice($arrListData['data'], 0, LIMIT_TOP);
         $arrListData['data'] = array_diff($arrListData['data'], $arrHotNews);
         $objArticle->setIdBasic($arrHotNews);
     }
     // set id from $arrListPaging to get article
     $objArticle->setIdBasic($arrListData['data']);
     //InitParam Paging
     $arrParamPaging = array('total' => $arrListData['total'], 'page' => $intPage, 'url' => $this->view->configView['url'] . '/page', 'perpage' => LIMIT_LIST, 'classPagination' => 'pagination_news right', 'extEnd' => '.html', 'separate' => '/');
     //Set param
     $this->_request->setParam('block_cate', $intCateId);
     //Assign to view
     $this->view->assign(array('intCategoryId' => SITE_ID, 'arrHotNews' => $arrHotNews, 'arrParamPaging' => $arrParamPaging, 'arrData' => $arrListData['data'], 'arrDiffNews' => "", 'offsetMore' => LIMIT_LIST, 'arrArticleExclude' => $arrArticleExclude, 'paramsBlock' => Zend_Json::encode(array('pagecode' => 'default_index_index_' . SITE_ID, 'exclude' => implode(',', $objBlock->getExclude()))), 'ogType' => 'website', 'ogTitle' => 'Thể thao - Tin thể thao 24h, lịch thi đấu, kết quả, video clip - VnExpress', 'ogUrl' => $this->view->configView['url'], 'ogImage' => 'http://m.f9.img.vnexpress.net/2014/01/10/fa68f81afe10b727852361b1894ccc74.jpg', 'ogDescription' => 'Tin nhanh video clip hình ảnh các môn thể thao: bóng đá quyền anh đua xe bóng chuyền cầu lông… đang diễn ra ở VN & thế giới.'));
     // Set metadata tags
     $this->view->headTitle()->prepend('Thể thao - Tin thể thao 24h, lịch thi đấu, kết quả, video clip - VnExpress');
     $this->view->headMeta()->setName('description', 'Tin nhanh video clip hình ảnh các môn thể thao: bóng đá quyền anh đua xe bóng chuyền cầu lông… đang diễn ra ở VN & thế giới.');
     $this->view->headMeta()->setName('keywords', 'Thể thao,tin tức,bóng đá');
     if (DEVICE_ENV != 1) {
         //ad js
         $this->view->headScript()->appendFile($this->view->configView['vnecdn']['js'] . '/utils/calendar/calendar.js');
     } else {
         //Set no render view
         $this->_helper->viewRenderer->setNoRender(true);
         echo $this->view->render('mobile/index.phtml');
     }
 }
Esempio n. 22
0
 /**
  * Get list league and season by team attend
  * @param int $teamID
  * @return array|boolean
  * @author QuangTM
  */
 public function getListLeagueAndSeasonTeamAttend($teamID)
 {
     // Default result
     $result = array();
     try {
         // Get DB Obj
         $dbObj = Thethao_Global::getDB('sport', 'slave');
         // Prepare SQL
         $stmt = $dbObj->prepare('CALL sp_sport_getLeagueSeasonByTeam(:p_teamid);');
         // Bind param
         $stmt->bindParam('p_teamid', $teamID, PDO::PARAM_INT);
         // Execute
         $stmt->execute();
         while ($row = $stmt->fetch()) {
             if (!isset($result[$row['league_id']])) {
                 $result[$row['league_id']] = array();
             }
             array_push($result[$row['league_id']], $row['season_id']);
         }
         // Close cursor
         $stmt->closeCursor();
         // Release
         unset($stmt);
     } catch (Exception $ex) {
         Thethao_Global::sendlog($ex, 1);
     }
     // Return result
     return $result;
 }
Esempio n. 23
0
 /**
  * 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;
 }
Esempio n. 24
0
 /**
  * rewrite player champion
  * @param type $seasonId
  * @return array|boolean
  * @author PhongTX
  */
 public function rewritePlayerChampion($seasonId)
 {
     try {
         $keyCache = vsprintf($this->_player_champion_by_season, array($seasonId));
         //Delete memcache
         Thethao_Global::deleteMemcache(array($keyCache));
         $this->getListTopPlayers($seasonId);
     } catch (Exception $ex) {
         Thethao_Global::sendlog($ex, 1);
     }
 }
Esempio n. 25
0
 public function __construct()
 {
     $config = Thethao_Global::getApplicationIni();
     $this->iconmore = ' <img src="' . $config['view']['images'] . '/graphics/icon_lead_more.gif" />';
 }
Esempio n. 26
0
 /**
  * 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;
 }
Esempio n. 27
0
    }
    exit;
}
//difened application path
defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
// Define application environment
defined('ZONE_ENV') || define('ZONE_ENV', getenv('ZONE_ENV') ? getenv('ZONE_ENV') : 'hn');
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array('/home/hungnt1/phpgiaitri', APPLICATION_PATH, realpath(APPLICATION_PATH . '/../library'))));
//print_r(get_include_path());die;
//include defined configs
require_once APPLICATION_PATH . '/configs/defined.php';
//include file Autoload for Zend
require_once 'Zend/Loader/Autoloader.php';
//include file Autoload for Fpt framwork
require_once 'Fpt/Autoloader.php';
//getInstance Autoload
$Autoloader = Zend_Loader_Autoloader::getInstance();
//set default Autoload to Fpt framework
$Autoloader->setDefaultAutoloader(array(new Fpt_Autoloader(), 'loadClass'));
//regis name space for giaitri
$Autoloader->registerNamespace('Thethao_');
//get config from application
$config = Thethao_Global::getConfig('application');
//get Application Zend
$application = new Zend_Application(APPLICATION_ENV, $config);
//Zend application execute
$application->bootstrap()->run();
//$end = microtime(true) - $time_start;
//echo "\n Time:" . $end.' - '.date("Y/m/d H:i:s");
//echo "\n Memory:" . round(memory_get_usage(true) / 1048576, 2) . " megabytes";
Esempio n. 28
0
 public function getListAward11($arrParams)
 {
     $arrReturn = false;
     $config = Thethao_Global::getApplicationIni();
     $nosql = $this->factory('News', $config['database']['nosql']['adapter']);
     if ($arrParams['isGearman'] == false) {
         $arrReturn = $nosql->getListAward($arrParams);
         //var_dump($arrReturn);
     }
     if (empty($arrReturn) || $arrReturn == false) {
         $config = Thethao_Global::getApplicationIni();
         //init mysql instance
         $newsMysql = $this->factory('News', $config['database']['default']['adapter']);
         //get db list
         $arrReturn = $newsMysql->getListAward($arrParams);
         $nosql->setListAward($arrParams, $arrReturn);
     }
     return $arrReturn;
 }
Esempio n. 29
0
 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;
     }
 }
Esempio n. 30
0
 public function __construct()
 {
     $config = Thethao_Global::getApplicationIni();
     $this->_image_url = $config['view']['images'];
 }