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;
     }
 }
Beispiel #2
0
 public function install()
 {
     $this->setLevel(GlobalParameters::START_LEVEL);
     $this->setExperience(0);
     $this->setMoney(GlobalParameters::START_MONEY);
     $this->setRealMoney(GlobalParameters::START_REAL_MONEY);
     $this->setEnergy(LevelsGrid::getInstance()->getBaseEnergy(GlobalParameters::START_LEVEL));
     $this->setMaxEnergy(LevelsGrid::getInstance()->getBaseEnergy(GlobalParameters::START_LEVEL));
     $this->setParameterSum($this->getParameterForward() + $this->getParameterHalf() + $this->getParameterSafe());
     $this->trainerId = 0;
     $this->inTeam = 0;
     $this->isInstalled = 1;
     $this->counterWon = 0;
     $this->counterChoose = 0;
     $this->counterLose = 0;
     $this->counterTie = 0;
     $this->isAbleToChoose = $this->getActiveCount() == GlobalParameters::MAX_TEAM ? 1 : 0;
     $sql_template = "INSERT INTO teams (\n    date_reg,\n\n    vk_id,\n    team_name,\n    team_logo_id,\n    auth_key,\n    energy,\n    \n    level,\n    money,\n    money_real,\n    stady_point,\n    in_team,\n    \n    able_to_choose,\n    param_forward,\n    param_half,\n    param_safe,\n    energy_max,\n\n    user_photo,\n    user_year,\n    user_country,\n    user_name,\n\n    stadium_id,\n\n    `country`,\n    `city`,\n    `university`,\n    `param_sum`,\n    `tour_notify`\n\n) VALUES (\n    NOW(),\n\n    %d,\n    '%s',\n    %d,\n    '%s',\n    %d,\n\n    %d,\n    %d,\n    %d,\n    %d,\n    %d,\n\n    %d,\n    " . $this->getParameterForward() . ",\n    " . $this->getParameterHalf() . ",\n    " . $this->getParameterSafe() . ",\n    " . $this->getEnergyMax() . ",\n\n    '" . SQL::getInstance()->real_escape_string($this->userPhoto) . "',\n    %d,\n    %d,\n    '" . SQL::getInstance()->real_escape_string($this->userName) . "',\n\n    " . $this->getStadiumId() . ",\n\n    " . $this->getUserCountry() . ",\n    " . $this->getUserCity() . ",\n    " . $this->getUserUniversity() . ",\n    " . $this->getParameterSum() . ",\n    %d\n     \n)";
     $periodType = RAM::getInstance()->getPeriodType();
     if (empty($periodType)) {
         $tourTimer = TourSatellite::getTimerDate();
         $periodType = $tourTimer->periodType;
         RAM::getInstance()->setPeriodType($periodType);
     }
     $sql = sprintf($sql_template, UserParameters::getUserId(), SQL::getInstance()->real_escape_string($this->teamName), $this->teamLogoId, SQL::getInstance()->real_escape_string(UserParameters::getAuthKey()), $this->getCurrentEnergy(), $this->getLevel(), $this->getMoney(), $this->getRealMoney(), $this->getStudyPoints(), $this->getStudyPointsViaPrize(), 0, $this->isAbleToChoose, $this->userYear, $this->userCountry, $periodType);
     RAM::getInstance()->setTeam($this);
     $result = SQL::getInstance()->query($sql);
     if ($result instanceof ErrorPoint) {
         return $result;
     }
     $sql_template = "INSERT INTO user_actions (\n    date,\n    date_sing_in,\n    vk_id,\n    command\n) VALUES (\n    NOW(),\n    NOW(),\n    %d,\n    '%s') ";
     $sql = sprintf($sql_template, UserParameters::getUserId(), SQL::getInstance()->real_escape_string(GlobalParameters::getCommand()));
     $result = SQL::getInstance()->query($sql);
     if ($result instanceof ErrorPoint) {
         return $result;
     }
 }
 public static function setGroupId($value)
 {
     GlobalParameters::$groupId = $value;
 }
Beispiel #4
0
 if ($serverCheckSum != $checkSum) {
     $actionResult = new ErrorPoint(ErrorPoint::CODE_BAD_MD5, "WFT", ErrorPoint::TYPE_USER);
 }
 $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);
function logUsersActivity($output)
{
    $logFile = SuperPath::get(UserParameters::getUserId(), LOG_COMMAND_PATH) . ".xml";
    $log = "<request>\n    <date>" . date("Y-m-d H:i:m") . "</date>\n    <uid>" . UserParameters::getUserId() . "</uid>\n    <command>" . GlobalParameters::getCommand() . "</command>\n    <body><![CDATA[\n" . json_encode($_POST) . "\n        ]]></body>\n    <responce><![CDATA[\n" . $output . "\n        ]]></responce>\n</request>" . PHP_EOL;
    fwrite(fopen($logFile, 'a+'), $log);
}