View sourcecode

The following files exists in this folder. Click to view.

answer_match.php

54 lines ASCII Unix (LF)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
    session_start
();
    require_once(
'databaseconnection.php');
    include(
'functions.php');
    include(
'check_login.php');


    
$sql "SELECT * FROM Matches WHERE matchId = :matchId;";
    
$stm $pdo->prepare($sql);
    
$stm->execute(array('matchId' => $_GET['matchId']));
    
$match $stm->fetch(PDO::FETCH_ASSOC);

    
//Validating player
    
$sql "SELECT playerId FROM Players WHERE userId = :userId;";
    
$stm $pdo->prepare($sql);
    
$stm->execute(array('userId' => $_SESSION['userId']));
    
$res $stm->fetchAll(PDO::FETCH_ASSOC);
    
$exit TRUE;
    foreach(
$res as $a){
        if ((int)
$match['defenderId'] == (int)$a['playerId']){
            if (
$match['defenderpoints'] <= playerpoints($match['defenderId'])){
                
$exit FALSE;
                
validateladdertime($match['defenderId'], 'yes'); //Validating the time of the ladder
            
}
        }
    }
    if (
$exit == TRUE){
        
header('location: home.php');
        exit();
    }

    if (isset(
$match['matchdate'])){
        
$matchdate $match['matchdate'];
    }
    else{
        
$matchdate date('Y-m-d H:i:s');
    }
    
//Uppdating database
    
$sql "UPDATE Matches SET responsedate = :responsedate, status = :status, matchdate = :matchdate WHERE matchId = :matchId;";
    
$stm $pdo->prepare($sql);
    
$stm->execute([
        
':responsedate'    => date('Y-m-d H:i:s'),
        
':status'          => $_POST['answer'],
        
':matchdate'       => $matchdate,
        
':matchId'         => $match['matchId']]);

    if(isset(
$_GET['openladder'])){
        
header('location: home.php?openladder='.$_GET['openladder'].'');
        exit();
    }
    
header('location: home.php?');
    exit();

?>