function verificaUsuario($name) { $sql = "SELECT id FROM tblusuario WHERE login like 'vininewday';"; $query = mysql_query($sql) or die("Não foi possível realizar a Query"); $id = mysql_fetch_assoc($query); if ($id["id"] == null) { $sql = "INSERT INTO tblusuario (creditos, login) VALUES (0,'vininewday');"; executeQuery_NR($sql); } }
function fechaPartidaUltimaPergunta($partida, $situacao) { $creditos = (int) $partida["creditosaida"]; $_SESSION["partida"]["creditosaida"] = $creditos; $tela = ""; if ($situacao == "errou") { /* Verifica se o usuário apostou tudo que tinha */ if ($creditos >= 0) { $tela = "Errou"; } else { $creditos = 0; $tela = "PerdeuTudo"; } } else { $tela = "Parabens"; } $creditoEntrada = executeQuery_OR("SELECT creditos FROM tblusuario WHERE id = " . $partida["idusuario"] . ";", "creditos"); $creditos += $creditoEntrada; executeQuery_NR("UPDATE tblusuario SET creditos = " . $creditos . " WHERE id = " . $partida["idusuario"] . ";"); /* Fecha a partida setando seu status com 0 */ executeQuery_NR("UPDATE tblpartida SET status = 0 WHERE id = " . $partida["id"] . ";"); pagina($tela); exit; }
$idfase = $_POST["dados"]; executeQuery_NR("UPDATE tblfase SET pergunta='" . $pergunta . "',resposta1='" . $resposta1 . "',resposta2='" . $resposta2 . "',numrespostacorreta=" . $respostacorreta . " WHERE id = " . $idfase . ";"); require "pages/pagBonus.php"; } else { if (isset($_POST["btnexcperguntas"])) { $idPergunta = $_POST["dados"]; $SQL = "SELECT id FROM interperguntafase WHERE idpergunta = " . $idPergunta . ";"; $idInterPerguntaFase = executeQuery_OR($SQL, "id"); executeQuery_NR("DELETE FROM tblperguntas WHERE id = " . $idPergunta . ";"); executeQuery_NR("DELETE FROM interperguntafase WHERE id = " . $idInterPerguntaFase . ";"); require "pages/pagPerguntas.php"; } else { if (isset($_POST["btnaltcreditos"])) { $idUsuario = $_POST["dados"]; $creditos = $_POST["txtcredins"]; executeQuery_NR("UPDATE tblusuario SET creditos = " . $creditos . " WHERE id = " . $idUsuario . ";"); require "pages/pagInserirCreditos.php"; } else { if (isset($_POST["btnadmpergbonus"])) { require "pages/pagBonus.php"; } else { if (isset($_POST["btnadmfechamento"])) { $_SESSION["data"] = ""; if (isset($_POST["dados"])) { $_SESSION["data"] = $_POST["dados"]; } else { $_SESSION["data"] = date("Y-m-d"); } require "pages/pagFechamento.php"; } else { require "pages/pagPrincipal.php";
} else { if ($_SESSION["numquestao"] >= 16 && $_SESSION["numquestao"] <= 19) { $_SESSION["creditosfinais"] = (int) ($_SESSION["partida"]["creditosaida"] * 0.75); } } } } /*Redireciona para a página parar */ pagina("Parar"); exit; } /* Captura uma pergunta aleatória com base na fase do usuário */ $_SESSION["partida"]["idperguntafase"] = executeQuery_OR("SELECT interperguntafase.id FROM interperguntafase, tblfase, tblperguntas WHERE tblfase.id = interperguntafase.idfase AND tblperguntas.id = interperguntafase.idpergunta AND numfase = " . $_SESSION["fase"]["numfase"] . " ORDER BY RAND() LIMIT 1", "id"); /* Atualiza este id(Id da tabela que contém a referência para tabela fase e para tabela pergunta) na partida do usuário*/ executeQuery_NR("UPDATE tblpartida SET idperguntafase=" . $_SESSION["partida"]["idperguntafase"] . " WHERE id = " . $_SESSION["partida"]["id"] . ";"); /* Obtém as perguntas e respostas do jogo da base de dados */ $idPergunta = executeQuery_OR("SELECT tblperguntas.id FROM tblperguntas, interperguntafase, tblpartida WHERE tblpartida.idperguntafase = interperguntafase.id AND interperguntafase.idpergunta = tblperguntas.id AND tblpartida.idperguntafase = " . $_SESSION["partida"]["idperguntafase"], "id"); $_SESSION["pergunta"] = executeQuery_AR("SELECT * FROM tblperguntas WHERE id = " . $idPergunta); /* Configura o número de aposta máxima conforme a correção Pois caso o usuário acertar a questão, o seu número automaticamente mudará, logo a correção se perpetuará para aposta máxima Aposta Maxima = Aposta Minima + 20% da Aposta Minima * Numero da Fase */ $_SESSION["partida"]["apostamaxima"] = 28 + 8 * $_SESSION["partida"]["questao"] * $_SESSION["fase"]["numfase"]; /* Caso o usuário deseje comprar mais tempo */ if (isset($_SESSION["bonus"]) && $_SESSION["bonus"] != null) { pagina("Bonus"); exit; } else { if (isset($_POST["btncomprar"])) {