Example #1
0
     $info_mess = "Возможно игра для Вашей команды не началась!";
     $smarty->assign('info_mess', $info_mess);
     $smarty->assign('game', $game);
     $smarty->assign('game_id', $game_id);
     $smarty->assign('off_div', "style='display: none'");
     $smarty->assign('info_div', "style='display: block'");
     include "footer.php";
     die;
 }
 if (isset($_POST['action'])) {
     $action = $_POST['action'];
     if ($action == 'insert_pin') {
         $pin = isset($_POST['pin']) ? (int) $_POST['pin'] : 0;
         sleep(1);
         if ($command_model->check_pin($pin, $game_id)) {
             $pin_model = new se_gamepin();
             $pin_model->update_pin($pin, $user_id, $command_id, $game_id);
         } else {
             $error_message = "Неверно введен пин-код";
             $smarty->assign('error_message', $error_message);
             $smarty->assign('off_div', "style='display: none'");
             $smarty->assign('on_div', "style='display: block'");
             include "footer.php";
             die;
         }
     } elseif ($action == 'complete_game') {
         $game_model->complete_game($game_id, $command_id);
         header("Location: game.php?game_id=" . $game_id);
         exit;
     }
     /*else if($action == 'give_answer')
 if ($action == 'add_pin') {
     $pin_model = new se_gamepin();
     $game_id = isset($_POST['game_id']) ? (int) $_POST['game_id'] : null;
     if ($game_id != null) {
         $result = $pin_model->add_pin($game_id);
         if ($result != 0) {
             $messPin = $result;
         } else {
             $messPin = 0;
         }
     }
     echo $messPin;
     die;
 } else {
     if ($action == 'delete_pin') {
         $pin_model = new se_gamepin();
         $pin = isset($_POST['pin']) ? (int) $_POST['pin'] : null;
         if ($pin != null) {
             $result = $pin_model->delete_pin($pin);
             $result = array('success' => true);
         }
         echo $result;
         die;
     } else {
         if ($action == 'mark_game_as_ready') {
             header("Content-Type: application/json");
             $game_id = isset($_POST['game_id']) ? (int) $_POST['game_id'] : null;
             if ($game_id && $game_model->is_provider_game($provider_id, $game_id)) {
                 $game_model->update_game(null, null, null, null, null, null, null, null, GAME_READY, null, null, null, $game_id);
                 $result = array('success' => true, 'game_id' => $game_id);
             } else {