Beispiel #1
0
    header("Location: data.php?add_result=" . $game_id . "&baskets=" . $_GET["baskets_count"]);
}
//kas kasutaja tahab kustutada
//kas aadressireal on ?delete=???
if (isset($_GET["delete"])) {
    //saadan kaasa id, mida kustutada
    deleteGame($_GET["delete"]);
}
function cleanInput($data)
{
    $data = trim($data);
    $data = stripslashes($data);
    $data = htmlspecialchars($data);
    return $data;
}
$game_list = getGameData();
?>

<p>
	Tere, <?php 
echo $_SESSION["user_email"];
?>
	<a href="?logout=1"> Logi välja</a>
</p>

<h1>Discgolf</h1><br>
<h2>Mängu lisamine</h2><br>
  <form action="<?php 
echo htmlspecialchars($_SERVER["PHP_SELF"]);
?>
" method="post" >
Beispiel #2
0
                            if ($method == "start_game") {
                                $game_id = $_POST['game_id'];
                                $database->update("game", ["game_status" => "started"], ["game_id" => $game_id]);
                                $result = getGameData($database, $game_id, $user_id);
                                print json_encode($result);
                            } else {
                                if ($method == "join_game") {
                                    $game_id = $_POST['game_id'];
                                    $data = ["user_id" => $user_id, "game_id" => $game_id, "locked_in" => "N"];
                                    $database->insert("game_user", $data);
                                    $result = getGameData($database, $game_id, $user_id);
                                    print json_encode($result);
                                } else {
                                    if ($method == "select_role") {
                                        $game_id = $_POST['game_id'];
                                        $role = $_POST['role'];
                                        $database->update("game_user", ["role" => $role], ["game_id" => $game_id, "user_id" => $user_id]);
                                        $result = getGameData($database, $game_id, $user_id);
                                        print json_encode($result);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
} catch (Exception $e) {
    echo 'Caught exception: ', $e->getMessage(), "\n";
}
Beispiel #3
0
function endGame($win, $los, $gameId)
{
    if (!checkToken($_SERVER['REMOTE_ADDR'], $_COOKIE['token'])) {
        return "verification_error";
    } else {
        //check to make sure this hasn't been ended already
        $game = getGameData($gameId);
        foreach ($game as $player) {
            if ($player->gameOver == 1) {
                return -1;
            }
        }
        //end game in DB
        if (endGameData($gameId) > 0) {
            //update wins
            addWinData($win);
            //update loss
            addLossData($los);
        }
    }
}
<?php

//laen funktsiooni faili
require_once "../functions.php";
require_once "../header.php";
//kontrollin, kas kasutaja ei ole sisseloginud
if (!isset($_SESSION["id_from_db"])) {
    header("Location: login.php");
}
//login välja
if (isset($_GET["logout"])) {
    session_destroy();
    header("Location: login.php");
}
$results_list = getGameData($_SESSION["game_id"]);
?>


<p>Your game is over. Your results are here: <br></p>
<p>
total par =  <?php 
echo $_SESSION["sum_pars"];
?>
 <br>
total result =  <?php 
echo $_SESSION["sum_results"];
?>
 <br>
difference = <?php 
echo $_SESSION["difference"];
?>
<?php

$root = "/home/football/www/";
include $root . 'dbconnect_live_scores.php';
require_once $root . 'api/v1/api_functions.php';
global $dbconn_mysql;
$type = isset($_REQUEST['type']) && $_REQUEST['type'] != '' ? $_REQUEST['type'] : false;
$match_id = isset($_REQUEST['match_id']) && $_REQUEST['match_id'] != '' ? $_REQUEST['match_id'] : false;
$league_id = isset($_REQUEST['league_id']) && $_REQUEST['league_id'] != '' ? $_REQUEST['league_id'] : false;
if ($type == 'GET_GAMES') {
    getGames($league_id);
} else {
    if ($type == 'GET_GAME_DATA') {
        getGameData($match_id);
    }
}
function getGames($lid)
{
    global $dbconn_mysql;
    $array = array();
    $query = $dbconn_mysql->prepare("SELECT * FROM sub_league WHERE league_id={$lid}");
    $query->execute();
    $rowc = $query->fetchAll();
    if (count($rowc) == 0) {
        $filter = "";
        if ($_SERVER['REMOTE_ADDR'] != '62.30.95.25') {
            $filter = "\tAND lm.league_id = {$lid} ";
        }
        $query = $dbconn_mysql->prepare("SELECT lm.*, ls.type AS score, ls.score AS type, t.name AS team_home_name, t2.name AS team_away_name\n\t\t\t\t\t\t\t\t\tFROM teams t, teams t2, live_match lm\n\t\t\t\t\t\t\t\t\tLEFT OUTER JOIN live_scores ls ON (ls.match_id=lm.id AND ls.score='CURRENT')\n\t\t\t\t\t\t\t\t\tWHERE lm.game_status!='Canc'\n\t\t\t\t\t\t\t\t\tAND lm.team_home_id=t.id\n\t\t\t\t\t\t\t\t\tAND lm.team_away_id=t2.id\n\t\t\t\t\t\t\t\t\t{$filter}\n\t\t\t\t\t\t\t\t\tORDER BY lm.status_type='live' DESC");
        $query->execute();
        $row = $query->fetchAll();
        //käivitan funktsiooni
        $msg = commentRaama($raama_comment);
        if ($msg != "") {
            //salvestamine õnnestus
            echo $msg;
        }
    }
}
function cleanInput($data)
{
    $data = trim($data);
    $data = stripslashes($data);
    $data = htmlspecialchars($data);
    return $data;
}
$results_list = getGameData();
?>
<p>
	Sisse logitud kasutajaga <?php 
echo $_SESSION["user_email"];
?>
	<a href="?logout=1"> Logi välja</a>
</p>
<h1>Rääma Discgolf</h1>

<p>
Par =  <?php 
echo $total_par_raama;
?>
<br>
Sinu tulemus oli