View sourcecode

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

stop_match.php

43 lines UTF-8 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
<?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['challengerId'] == (int)$a['playerId'] && $match['status'] == 'request'){
            
$exit FALSE;
            
validateladdertime($match['defenderId'], 'yes');
        }
    }
    if (
$exit == TRUE){
        
header('location: home.php');
        exit();
    }
    
//Sätter statusen till 'stopped'
    
$sql "UPDATE Matches SET status = :status WHERE matchId = :matchId;";
    
$stm $pdo->prepare($sql);
    
$stm->execute([
        
':status'          => 'stopped',
        
':matchId'         => $match['matchId']]);

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

?>