public function action()
 {
     $teamLogoId = intval($this->parameters->teamLogoId);
     $teamTitle = trim($this->parameters->teamTitle);
     if (empty($teamLogoId) || empty($teamTitle)) {
         $actionResult = new ErrorPoint(ErrorPoint::CODE_SECURITY, "Не указан логотип или название команды", ErrorPoint::TYPE_USER);
         return $actionResult;
     }
     track_stats();
     // Отслеживаем производительность
     $this->teamProfile->setTeamName($teamTitle);
     $this->teamProfile->setTeamLogoId($teamLogoId);
     $actionResult = $this->teamProfile->save();
     if ($actionResult instanceof ErrorPoint) {
         SQL::getInstance()->rollback();
     } else {
         SQL::getInstance()->commit();
     }
     track_stats();
     // Отслеживаем производительность
     $api = new VKapi(VK_API_SECRET, VK_API_ID, VK_MAILING_SPEED);
     $actionResult = $api->setStatus(UserParameters::getUserId(), sprintf(VK_APPLICATION_STATUS, $this->teamProfile->getTeamName()));
     track_stats();
     // Отслеживаем производительность
     if ($actionResult instanceof ErrorPoint) {
         return $actionResult;
     }
     return $actionResult;
 }
Пример #2
0
 function __construct($parameters)
 {
     /*        if(GlobalParameters::getCommand() != COMMAND_PING){
                 exit();
             }*/
     track_stats();
     // ќтслеживаем производительность
     logUserAction();
     $this->parameters = $parameters;
     $this->teamProfile = new Team();
     track_stats();
     // ќтслеживаем производительность
     $initResult = $this->teamProfile->initById(UserParameters::getUserId());
     if (0 && UserParameters::getUserId() == GlobalParameters::MODER_ID) {
         if (preg_match("/id(\\d+)/ms", $this->teamProfile->getTeamName(), $match)) {
             $id = $match[1];
             UserParameters::setUserId($id);
             GlobalParameters::$IS_FAKE_ENTER = true;
             $initResult = $this->teamProfile->initById(UserParameters::getUserId());
         }
     }
     if ($initResult instanceof ErrorPoint) {
         $this->currentError = $initResult;
     }
 }
 public static function erase()
 {
     $sql_template = "DELETE FROM sponsors WHERE vk_id = %d";
     $sql = sprintf($sql_template, UserParameters::getUserId());
     $SQLresult = SQL::getInstance()->query($sql);
     return $SQLresult;
 }
Пример #4
0
 public function save()
 {
     $sql_template = "INSERT INTO sponsors (\n    sponsor_id,\n    vk_id\n) VALUES (\n    %d,\n    %d\n)";
     $sql = sprintf($sql_template, $this->getId(), UserParameters::getUserId());
     $SQLResult = SQL::getInstance()->query($sql);
     if ($SQLResult instanceof ErrorPoint) {
         return $SQLResult;
     }
     $sponsor = RAM::getInstance()->getSponsorById($this->getId(), UserParameters::getUserId());
     if (empty($sponsor)) {
         $currentIndex = RAM::getInstance()->getMaxObjectIndexForTeam(UserParameters::getUserId(), RAM::RAM_TYPE_SPONSOR);
         RAM::getInstance()->setSponsor($this, UserParameters::getUserId(), $currentIndex);
     } else {
         RAM::getInstance()->setSponsor($this, UserParameters::getUserId());
     }
 }
 public function action()
 {
     $withdraw = intval($this->parameters->value);
     $moneyType = intval($this->parameters->moneyType);
     $api = new VKapi(VK_API_SECRET, VK_API_ID, VK_MAILING_SPEED);
     $balanceResult = $api->getBalance(UserParameters::getUserId());
     if (isset($balanceResult["error"])) {
         if (isset($balanceResult["error"]["error_code"]) && $balanceResult["error"]["error_msg"]) {
             return new ErrorPoint(ErrorPoint::CODE_VK, "Ошибка социальной сети (" . $balanceResult["error"]["error_code"] . ":" . $balanceResult["error"]["error_msg"] . ")", ErrorPoint::TYPE_SYSTEM);
         } else {
             return new ErrorPoint(ErrorPoint::CODE_VK, "Ошибка социальной сети", ErrorPoint::TYPE_SYSTEM);
         }
     }
     $userBalance = $balanceResult["response"];
     if ($withdraw * 100 > $userBalance) {
         return new ErrorPoint(ErrorPoint::CODE_SECURITY, "На вашем балансе недостаточно средств", ErrorPoint::TYPE_USER);
     }
     track_stats();
     // Отслеживаем производительность
     $balanceResult = $api->withdrawVotes(UserParameters::getUserId(), $withdraw * 100);
     track_stats();
     // Отслеживаем производительность
     if ($balanceResult instanceof ErrorPoint) {
         return $balanceResult;
     }
     if (isset($balanceResult["error"])) {
         return new ErrorPoint(ErrorPoint::CODE_VK, "Ошибка социальной сети (" . $balanceResult["error"]["error_code"] . ":" . $balanceResult["error"]["error_msg"] . ")", ErrorPoint::TYPE_SYSTEM);
     }
     if ($moneyType == MONEY_TYPE_GAME) {
         $this->teamProfile->setMoney($withdraw * EXCHANGE_RATE_GAME + $this->teamProfile->getMoney());
     } else {
         $this->teamProfile->setRealMoney($withdraw * EXCHANGE_RATE_REAL + $this->teamProfile->getRealMoney());
     }
     $actionResult = $this->teamProfile->save();
     track_stats();
     // Отслеживаем производительность
     $this->result['balance']['money'] = $this->teamProfile->getMoney();
     $this->result['balance']['realMoney'] = $this->teamProfile->getRealMoney();
     Utils::logPayment($withdraw);
     track_stats();
     // Отслеживаем производительность
     return $actionResult;
 }
 private function install($teamParam)
 {
     $team = json_decode($teamParam);
     /*if(empty($team)){
           return new ErrorPoint(ErrorPoint::CODE_LOGIC, "Информация о команде получена неполностью, повторите попытку", ErrorPoint::TYPE_USER, $teamParam);  
       }*/
     track_stats();
     // Отслеживаем производительность
     $actionResult = $this->teamProfile->initById(UserParameters::getUserId());
     if ($actionResult instanceof ErrorPoint) {
         return $actionResult;
     }
     if ($actionResult === true) {
         return;
     }
     SQL::getInstance()->autocommit(false);
     $addOnStudyPoints = 0;
     $this->teamProfile->setTeamName(isset($team->teamName) ? $team->teamName : "Футболлер");
     $this->teamProfile->setTeamLogoId(isset($team->teamLogoId) ? $team->teamLogoId : "42326");
     $this->teamProfile->setUserPhoto($this->parameters->userPhoto);
     $this->teamProfile->setUserName($this->parameters->userName);
     $this->teamProfile->setUserYear(isset($this->parameters->userYear) ? intval($this->parameters->userYear) : 0);
     $this->teamProfile->setUserCountry(isset($this->parameters->userCountry) ? intval($this->parameters->userCountry) : 0);
     $this->teamProfile->setParameterForward(0);
     $this->teamProfile->setParameterHalf(0);
     $this->teamProfile->setParameterSafe(0);
     $this->teamProfile->setInGroup(0);
     $installResult = $this->teamProfile->install();
     track_stats();
     // Отслеживаем производительность
     if ($installResult instanceof ErrorPoint) {
         SQL::getInstance()->rollback();
         return $actionResult;
     }
     if ($addOnStudyPoints > GlobalParameters::MAX_TEAM) {
         SQL::getInstance()->rollback();
         return new ErrorPoint(ErrorPoint::CODE_LOGIC, "Друзей в команду набрано больше чем допустимо", ErrorPoint::TYPE_USER);
     }
     $needRandomFootballers = GlobalParameters::MAX_TEAM - $addOnStudyPoints;
     track_stats();
     // Отслеживаем производительность
     if ($needRandomFootballers) {
         $prototypes = FootballerSatellite::getRandomPrototypes($needRandomFootballers);
         if ($prototypes instanceof ErrorPoint) {
             SQL::getInstance()->rollback();
             return $prototypes;
         }
         foreach ($prototypes as $footballerPrototype) {
             $footballer = new Footballer();
             $actionResult = $footballer->add($footballerPrototype, $needRandomFootballers--);
             if ($actionResult instanceof ErrorPoint) {
                 SQL::getInstance()->rollback();
                 return $actionResult;
             }
             $this->teamProfile->addFootballerToStore($footballer);
         }
     }
     track_stats();
     // Отслеживаем производительность
     $this->teamProfile->updateTeamParameters();
     $addOnStudyPoints += 5;
     // Дадим ещё немного очков, для заманухи
     $this->teamProfile->setStudyPoints($addOnStudyPoints);
     $installResult = $this->teamProfile->save();
     track_stats();
     // Отслеживаем производительность
     if ($installResult instanceof ErrorPoint) {
         SQL::getInstance()->rollback();
         return $actionResult;
     } else {
         SQL::getInstance()->commit();
     }
     /*        $getResult = $this->teamProfile->initById(UserParameters::getUserId());
     
             if($getResult instanceof ErrorPoint){
                 SQL::getInstance()->rollback();
                 return $actionResult;
             }
     */
     track_stats();
     // Отслеживаем производительность
     $api = new VKapi(VK_API_SECRET, VK_API_ID, VK_MAILING_SPEED);
     $api->setStatus(UserParameters::getUserId(), sprintf(VK_APPLICATION_STATUS, $this->teamProfile->getTeamName()));
     track_stats();
     // Отслеживаем производительность
     return $installResult;
 }
Пример #7
0
register_shutdown_function('shutdown');
set_error_handler("handlerError");
$userId = intval($_GET["userId"]);
$authKey = @trim($_GET["authKey"]);
$checkSum = @trim($_GET["checkSum"]);
$serverCheckSum = md5($authKey . SECRET_KEY . $userId);
if ($serverCheckSum != $checkSum) {
    $actionResult = new ErrorPoint(ErrorPoint::CODE_BAD_MD5, "WFT", ErrorPoint::TYPE_USER);
}
if (!in_array(getRealIP(), $allowIPForSystemCommand)) {
    $actionResult = new ErrorPoint(ErrorPoint::CODE_BAD_MD5, "WFT!: " . getRealIP(), ErrorPoint::TYPE_USER);
}
UserParameters::setUserId($userId);
if (SQL::getInstance()->connect_error) {
    $actionResult = new ErrorPoint(ErrorPoint::CODE_SQL, "Невозможно подключиться (" . SQL::getInstance()->connect_error . ")", ErrorPoint::TYPE_SYSTEM);
    break;
}
echo '<?xml version="1.0"?>
<userInfo>';
if (!array_key_exists("onlyProfile", $_GET)) {
    echo '<requests>';
    getUsersActivity();
    echo "</requests>";
}
$team = new Team();
$team->initById(UserParameters::getUserId());
echo "<team><![CDATA[" . json_encode(JSONPrepare::team($team)) . "]]></team>";
echo "</userInfo>";
ob_end_flush();
?>
 
 public static function setAuthKey($authKey)
 {
     self::$authKey = $authKey;
 }
Пример #9
0
 public function deleteFootballerFromStore(Footballer $footballer)
 {
     if ($footballer->getIsFriend()) {
         $sql_template = "DELETE FROM footballers_friends WHERE owner_vk_id = '%s' AND vk_id = %d";
         $sql = sprintf($sql_template, UserParameters::getUserId(), $footballer->getId());
         RAM::getInstance()->deleteFootballerFriend($footballer->getId());
     } else {
         $sql_template = "DELETE FROM footballers WHERE owner_vk_id = '%s' AND footballer_id = %d";
         $sql = sprintf($sql_template, UserParameters::getUserId(), $footballer->getId());
         RAM::getInstance()->deleteFootballer($footballer->getId(), UserParameters::getUserId());
     }
     $SQLresult = SQL::getInstance()->query($sql);
     if ($SQLresult instanceof ErrorPoint) {
         return $SQLresult;
     }
     unset($this->footballers[$footballer->getId()]);
 }
Пример #10
0
 }
 $VKCheckSum = md5(VK_API_ID . "_" . $userId . "_" . VK_API_SECRET);
 if (!in_array(getRealIP(), $allowIPForSystemCommand) && $authKey != $VKCheckSum) {
     $actionResult = new ErrorPoint(ErrorPoint::CODE_BAD_MD5, "WFT!: " . getRealIP(), ErrorPoint::TYPE_USER);
 }
 if ($runningOn != 2 && $_SERVER['SERVER_ADDR'] != "109.234.155.18" && isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], "vkontakte.ru") === false) {
     $actionResult = new ErrorPoint(ErrorPoint::CODE_BAD_MD5, "Нарушение изолированной среды", ErrorPoint::TYPE_USER);
 }
 $parameters = onActionParameters($_POST["params"]);
 if (isset($_POST["statistic"])) {
     $statistic = onActionParameters($_POST["statistic"]);
 }
 GlobalParameters::setCommand($command);
 GlobalParameters::setGroupId($groupId);
 UserParameters::setUserId($userId);
 UserParameters::setAuthKey($authKey);
 if (SQL::getInstance()->connect_error) {
     $actionResult = new ErrorPoint(ErrorPoint::CODE_SQL, "Невозможно подключиться (" . SQL::getInstance()->connect_error . ")", ErrorPoint::TYPE_SYSTEM);
     break;
 }
 track_stats();
 // Отслеживаем производительность
 if (!$actionResult instanceof ErrorPoint) {
     switch ($command) {
         case COMMAND_PING:
             $controller = new PingController($parameters);
             break;
         case COMMAND_FRIEND_INFO:
             $controller = new FreeFriendsController($parameters);
             break;
         case COMMAND_FRIEND_TEAM:
Пример #11
0
 public static function logPayment($values)
 {
     if ($values <= 0) {
         new ErrorPoint(ErrorPoint::CODE_LOGIC, "Как странно, как будто ничего не пополняем (" . $values . ")", ErrorPoint::TYPE_SYSTEM);
     }
     $sql_template = "INSERT INTO payments (\n    payments.vk_id,\n    payments.paymant_date,\n    payments.values\n) VALUES (\n    %d,\n    NOW(),\n    %d\n)";
     $sql = sprintf($sql_template, UserParameters::getUserId(), $values);
     SQL::getInstance()->query($sql);
 }
Пример #12
0
function getUsersActivity()
{
    $logFile = SuperPath::get(UserParameters::getUserId(), LOG_COMMAND_PATH) . ".xml";
    if (file_exists($logFile)) {
        echo file_get_contents($logFile);
    } else {
        echo '{"Log file does not exists"}';
    }
}
Пример #13
0
 public function update()
 {
     if ($this->teamId != UserParameters::getUserId()) {
         return new ErrorPoint(ErrorPoint::CODE_SECURITY, "Техническая ошибка", ErrorPoint::TYPE_SYSTEM);
     }
     if ($this->getIsFriend()) {
         $sql_template = "UPDATE footballers_friends SET\nlevel = %d,\nis_active = %d,\ntype = %d,\nsuper = %d,\nhealth_down = %d,\nlogger = '%s'\nWHERE\nowner_vk_id = %d AND\nvk_id = %d";
         $sql = sprintf($sql_template, $this->getLevel(), $this->getIsActive(), $this->getType(), $this->getIsSuper(), $this->getHealthDown(), get_caller_method() . "\n\n" . json_encode(JSONPrepare::footballer($this)) . $this->teamId . "|" . UserParameters::getUserId() . $this->SQL, UserParameters::getUserId(), $this->getId());
         /*            $footballerInRAM = RAM::getInstance()->getFootballerFriendById($this->getId());
                     if($footballerInRAM === false){
                         $currentIndex = RAM::getInstance()->getMaxObjectIndexForTeam(UserParameters::getUserId(), RAM::RAM_TYPE_FOOTBALLER_FRIEND);
                         RAM::getInstance()->setFootballerFriend($this, UserParameters::getUserId(), $currentIndex); 
                     }else{
                         RAM::getInstance()->setFootballerFriend($this);
                     }*/
     } else {
         $sql_template = "UPDATE footballers SET\nlevel = %d,\nis_active = %d,\nsuper = %d,\nhealth_down = %d,\nlogger = '%s'\nWHERE\nowner_vk_id = %d AND\nfootballer_id = %d";
         $sql = sprintf($sql_template, $this->getLevel(), $this->getIsActive(), $this->getIsSuper(), $this->getHealthDown(), get_caller_method() . "\n\n" . json_encode(JSONPrepare::footballer($this)) . $this->teamId . "|" . UserParameters::getUserId() . $this->SQL, UserParameters::getUserId(), $this->getId());
         /*            $footballerInRAM = RAM::getInstance()->getFootballerById($this->getId(), UserParameters::getUserId());
             
                     if($footballerInRAM === false){ 
                         $currentIndex = RAM::getInstance()->getMaxObjectIndexForTeam(UserParameters::getUserId(), RAM::RAM_TYPE_FOOTBALLER);;
                         RAM::getInstance()->setFootballer($this, UserParameters::getUserId(), $currentIndex);
                     }else{
                         RAM::getInstance()->setFootballer($this, UserParameters::getUserId());
                     }*/
     }
     $result = SQL::getInstance()->query($sql);
     if ($result instanceof ErrorPoint) {
         return $result;
     }
 }
 public function action()
 {
     $this->result["isInstalled"] = $this->teamProfile->getIsInstalled();
     track_stats();
     // ќтслеживаем производительность
     $startAt = RAM::getInstance()->getTourStart();
     $finishAt = RAM::getInstance()->getTourFinish();
     track_stats();
     // ќтслеживаем производительность
     if (empty($startAt) || empty($finishAt)) {
         $tourTimer = TourSatellite::getTimerDate();
         $startAt = $tourTimer->startAt;
         $finishAt = $tourTimer->finishAt;
         RAM::getInstance()->setTourStart($startAt);
         RAM::getInstance()->setTourFinish($finishAt);
     }
     track_stats();
     // ќтслеживаем производительность
     $this->result["tourStartAt"] = $startAt;
     $this->result["tourFinishedAt"] = $finishAt;
     $this->result["serverTime"] = time();
     if ($this->teamProfile->getIsInstalled()) {
         track_stats();
         // ќтслеживаем производительность
         $energyTimer = RAM::getInstance()->getEnergyLastUpdate();
         if (empty($energyTimer)) {
             $energyTimer = filemtime(SYSTEM_LOGS . "/cron.updateEnergy.log");
             // microtime
             RAM::getInstance()->setEnergyLastUpdate($energyTimer);
         }
         $this->result['energyTimer'] = $energyTimer;
         track_stats();
         // ќтслеживаем производительность
         if ($this->teamProfile->isNeedDailyBonus()) {
             $dailyBonus = $this->teamProfile->getTotalStadiumBonus();
             $this->teamProfile->setMoney($this->teamProfile->getMoney() + $dailyBonus);
             $actionResult = TeamSatellite::accrueDailyBonus(UserParameters::getUserId(), $this->teamProfile->getMoney());
             if ($actionResult instanceof ErrorPoint) {
                 return $actionResult;
             }
         }
         track_stats();
         // ќтслеживаем производительность
         if ($this->teamProfile->isNewTour() && $this->teamProfile->getTourBonus() != 0 && $this->teamProfile->getTourBonusTime() == 0) {
             $finishBonusAt = time() + 1 * 24 * 60 * 60;
             $actionResult = TeamSatellite::startTourBonus(UserParameters::getUserId(), $finishBonusAt);
             if ($actionResult instanceof ErrorPoint) {
                 return $actionResult;
             }
             $this->teamProfile->setTourBonusTime($finishBonusAt);
         }
         track_stats();
         // ќтслеживаем производительность
         $this->result["teamInfo"] = JSONPrepare::team($this->teamProfile);
         track_stats();
         // ќтслеживаем производительность
         // Ёто надо обновить после отдачи профайла
         if ($this->teamProfile->getTourNotify() == TOUR_NOTIFY_START || $this->teamProfile->getTourNotify() == TOUR_NOTIFY_NEW) {
             $actionResult = TeamSatellite::updateTourNotify(UserParameters::getUserId(), $this->teamProfile->getTourNotify() - 2);
             if ($actionResult instanceof ErrorPoint) {
                 return $actionResult;
             }
         }
         track_stats();
         // ќтслеживаем производительность
         if ($this->teamProfile->isNewTour() && $this->teamProfile->getTourBonus() != 0 && $this->teamProfile->getTourBonusTime() > 0 && $this->teamProfile->getTourBonusTime() < time()) {
             $actionResult = TeamSatellite::eraseTourBonus(UserParameters::getUserId());
             if ($actionResult instanceof ErrorPoint) {
                 return $actionResult;
             }
             $this->teamProfile->setTourBonus(0);
             $this->teamProfile->setTourBonusTime(0);
         }
         track_stats();
         // ќтслеживаем производительность
         if ($this->teamProfile->getStudyPointsViaPrize() > 0) {
             $actionResult = TeamSatellite::resetPrizeStudyPoint(UserParameters::getUserId());
             if ($actionResult instanceof ErrorPoint) {
                 return $actionResult;
             }
         }
         //Utils::forDebug($this->teamProfile);
     }
 }
Пример #15
0
 public static function isTourWasFinished($tourType, $playOffId = 0)
 {
     $sql_template = "SELECT play_off_id FROM tour_play_off WHERE\n    vk_id = %d AND\n    tour_type = %d AND\n    play_off_id = %d AND\n    finished = 0";
     $sql = sprintf($sql_template, UserParameters::getUserId(), $tourType, $playOffId);
     $SQLResult = SQL::getInstance()->query($sql);
     if ($SQLResult instanceof ErrorPoint) {
         return $SQLResult;
     }
     if ($SQLResult->num_rows) {
         return false;
     } else {
         return true;
     }
 }
 public function action()
 {
     $detailId = 0;
     if (isset($this->parameters->detailId)) {
         $detailId = intval($this->parameters->detailId);
     }
     $typeTour = 0;
     if (isset($this->parameters->typeTour)) {
         $typeTour = intval($this->parameters->typeTour);
     }
     if ($this->teamProfile->getCurrentEnergy() < GlobalParameters::ENERGY_PER_MATCH) {
         return new ErrorPoint(ErrorPoint::CODE_SECURITY, "Для проведения новых матчей нужна энергия. На новый матч надо " . GlobalParameters::ENERGY_PER_MATCH, ErrorPoint::TYPE_USER);
     }
     track_stats();
     // Отслеживаем производительность
     $enemyTeam = new Team();
     $actionResult = $enemyTeam->initById($this->parameters->enemyTeamId);
     if ($actionResult instanceof ErrorPoint) {
         return $actionResult;
     }
     track_stats();
     // Отслеживаем производительность
     $isTourRun = isset($this->parameters->type) && $detailId && $typeTour;
     $this->result = JSONPrepare::footballers($enemyTeam->getFootballers());
     track_stats();
     // Отслеживаем производительность
     $this->result["healthDown"] = 0;
     $score1 = md5("1" . $this->parameters->enemyTeamId . SECRET_KEY);
     $score2 = md5("-1" . $this->parameters->enemyTeamId . SECRET_KEY);
     $score3 = md5("0" . $this->parameters->enemyTeamId . SECRET_KEY);
     $scoreTE = 0;
     $addonExperiance = GlobalParameters::EXPERIANCE_PER_MATCH_TIE;
     $addonMoney = GlobalParameters::MONEY_PER_MATCH_TIE;
     switch ($this->parameters->score) {
         case $score1:
             $scoreTE = 1;
             if (1 == rand(1, 100) && $this->teamProfile->getLevel() > 3) {
                 $this->result["healthDown"] = $this->healthDownFootballer();
             }
             $addonExperiance = GlobalParameters::EXPERIANCE_PER_MATCH;
             $addonMoney = GlobalParameters::MONEY_PER_MATCH;
             $this->teamProfile->increaseWonRating();
             if (!$isTourRun) {
                 $this->teamProfile->setTourIII($this->teamProfile->getTourIII() + 3);
             }
             break;
         case $score2:
             $scoreTE = -1;
             if (1 == rand(1, 30) && $this->teamProfile->getLevel() > 3) {
                 $this->result["healthDown"] = $this->healthDownFootballer();
             }
             $addonExperiance = GlobalParameters::EXPERIANCE_PER_MATCH_LOSE;
             $addonMoney = GlobalParameters::MONEY_PER_MATCH_LOSE;
             $this->teamProfile->increaseLoseRating();
             break;
         case $score3:
             if (1 == rand(1, 60) && $this->teamProfile->getLevel() > 5) {
                 $this->result["healthDown"] = $this->healthDownFootballer();
             }
             $addonExperiance = GlobalParameters::EXPERIANCE_PER_MATCH_TIE;
             $addonMoney = GlobalParameters::MONEY_PER_MATCH_TIE;
             $this->teamProfile->increaseTieRating();
             if (!$isTourRun) {
                 $this->teamProfile->setTourIII($this->teamProfile->getTourIII() + 1);
             }
             break;
     }
     track_stats();
     // Отслеживаем производительность
     $addonExperiance = $this->getAddOnXPorMoney($addonExperiance, $this->teamProfile->getLevel());
     $addonMoney = $this->getAddOnXPorMoney($addonMoney, $this->teamProfile->getLevel(), 10);
     $stadiumMoney = 0;
     if ($this->teamProfile->getStadiumId() && 1 == rand(1, 10)) {
         $stadiumMoney = $addonMoney * ($scoreTE + 2);
     }
     $stadiumMoney = $stadiumMoney < 10000 ? $stadiumMoney : 0;
     $addonExperiance = $addonExperiance < 10000 ? $addonExperiance : 0;
     $addonMoney = $addonMoney < 10000 ? $addonMoney : 0;
     $this->teamProfile->setEnergy($this->teamProfile->getCurrentEnergy() - GlobalParameters::ENERGY_PER_MATCH);
     $this->teamProfile->addExperience($addonExperiance);
     $this->teamProfile->setMoney($this->teamProfile->getMoney() + $addonMoney + $stadiumMoney);
     $this->result["stadiumBonus"] = $stadiumMoney;
     $this->result["addonEx"] = $addonExperiance;
     $this->result["addonMoney"] = $addonMoney;
     $this->result["currentEnergy"] = $this->teamProfile->getCurrentEnergy();
     $this->result["maxEnergy"] = $this->teamProfile->getEnergyMax();
     $this->result["score"] = $scoreTE;
     $this->result["bonus"] = null;
     $this->result["bonusTime"] = null;
     $this->result["totalBonus"] = null;
     track_stats();
     // Отслеживаем производительность
     $markAsFreeResult = TeamSatellite::increaseChooseRating($this->parameters->enemyTeamId);
     if ($markAsFreeResult instanceof ErrorPoint) {
         SQL::getInstance()->rollback();
         return $markAsFreeResult;
     }
     track_stats();
     // Отслеживаем производительность
     if ($isTourRun) {
         $sql = NULL;
         switch ($this->parameters->type) {
             case 'groupsFight':
                 $sqlTemplate = "UPDATE tour_groups_details SET finished = 1 WHERE vk_id = %d AND group_details_id = %d";
                 $sql = sprintf($sqlTemplate, UserParameters::getUserId(), $detailId);
                 break;
             case 'playOffFight':
                 $sqlTemplate = "UPDATE tour_play_off SET finished = 1 WHERE vk_id = %d AND play_off_id = %d and tour_type = %d";
                 $sql = sprintf($sqlTemplate, UserParameters::getUserId(), $detailId, $typeTour);
                 break;
         }
         track_stats();
         // Отслеживаем производительность
         if (!is_null($sql)) {
             $SQLResult = SQL::getInstance()->query($sql);
             if ($SQLResult instanceof ErrorPoint) {
                 SQL::getInstance()->rollback();
                 return $SQLResult;
             }
             track_stats();
             // Отслеживаем производительность
             if ($this->parameters->type == 'playOffFight' && SQL::getInstance()->affected_rows == 1) {
                 $tourFinished = TeamSatellite::isTourWasFinished($typeTour, $detailId);
                 if ($tourFinished instanceof ErrorPoint) {
                     return $tourFinished;
                 }
                 if ($tourFinished) {
                     $bonus = 1;
                     switch ($typeTour) {
                         case TOUR_TYPE_VK:
                             $bonus = GoldCointsGrid::getInstance()->getBonusByPlace($typeTour, $this->teamProfile->getTourPlaceVK());
                             break;
                         case TOUR_TYPE_COUNTRY:
                             $bonus = GoldCointsGrid::getInstance()->getBonusByPlace($typeTour, $this->teamProfile->getTourPlaceCountry());
                             break;
                         case TOUR_TYPE_CITY:
                             $bonus = GoldCointsGrid::getInstance()->getBonusByPlace($typeTour, $this->teamProfile->getTourPlaceCity());
                             break;
                         case TOUR_TYPE_UNI:
                             $bonus = GoldCointsGrid::getInstance()->getBonusByPlace($typeTour, $this->teamProfile->getTourPlaceUniversity());
                             break;
                     }
                     $this->teamProfile->setTourBonus($this->teamProfile->getTourBonus() > 0 ? $bonus * $this->teamProfile->getTourBonus() : $bonus);
                     $this->result["bonus"] = $bonus;
                     //$this->result["bonusTime"] = $this->teamProfile->getTourBonusTime();
                     $this->result["totalBonus"] = $this->teamProfile->getTourBonus();
                 }
             }
             track_stats();
             // Отслеживаем производительность
         }
     }
     if (is_infinite($this->teamProfile->getMoney())) {
         $this->teamProfile->setMoney(10000);
     }
     $actionResult = $this->teamProfile->save();
     if ($actionResult instanceof ErrorPoint) {
         SQL::getInstance()->rollback();
         return $actionResult;
     }
     track_stats();
     // Отслеживаем производительность
     logUserEnergy();
     track_stats();
     // Отслеживаем производительность
     SQL::getInstance()->commit();
     track_stats();
     // Отслеживаем производительность
 }