-
Notifications
You must be signed in to change notification settings - Fork 0
/
matchprocess.php
139 lines (119 loc) · 3.27 KB
/
matchprocess.php
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<?php
/**
* MatchProcess.php
* Quick match report process
*
*/
require_once("../../class2.php");
require_once(e_PLUGIN.'ebattles/include/main.php');
require_once(e_PLUGIN.'ebattles/include/match.php');
require_once(e_PLUGIN.'ebattles/include/event.php');
if(isset($_POST['qrsubmitloss']))
{
$event_id = $_POST['eventid'];
$reported_by = $_POST['reported_by'];
$pwinnerID = $_POST['Player'];
$event = new Event($event_id);
// Attention here, we use user_id, so there has to be 1 user for 1 player
$plooserUser = $reported_by;
$q = "SELECT *"
." FROM ".TBL_PLAYERS
." WHERE (Event = '$event_id')"
." AND (User = '$plooserUser')";
$result = $sql->db_Query($q);
$row = mysql_fetch_array($result);
$plooserID = $row['PlayerID'];
// Create Match ------------------------------------------
$comments = '';
$q =
"INSERT INTO ".TBL_MATCHS."(Event,ReportedBy,TimeReported, Comments, Status)
VALUES ($event_id,'$reported_by',$time, '$comments', 'pending')";
$result = $sql->db_Query($q);
$last_id = mysql_insert_id();
$match_id = $last_id;
$match = new Match($match_id);
// Create Scores ------------------------------------------
$q =
"INSERT INTO ".TBL_SCORES."(MatchID,Player,Player_MatchTeam,Player_Rank)
VALUES ($match_id,$pwinnerID,1,1)
";
$result = $sql->db_Query($q);
$q =
"INSERT INTO ".TBL_SCORES."(MatchID,Player,Player_MatchTeam,Player_Rank)
VALUES ($match_id,$plooserID,2,2)
";
$result = $sql->db_Query($q);
// Update scores stats
$match->match_scores_update();
// Automatically Update Players stats only if Match Approval is Disabled
if ($event->getField('MatchesApproval') == eb_UC_NONE)
{
switch($event->getMatchPlayersType())
{
case 'Players':
$match->match_players_update();
break;
case 'Teams':
$match->match_teams_update();
break;
default:
}
if($event->getField('FixturesEnable') == TRUE)
{
$event->brackets(true);
}
}
$event->setFieldDB('IsChanged', 1);
header("Location: matchinfo.php?matchid=$match_id");
exit;
}
if (isset($_POST['approvematch']))
{
$event_id = $_POST['eventid'];
$match_id = $_POST['matchid'];
$event = new Event($event_id);
$match = new Match($match_id);
switch($event->getMatchPlayersType())
{
case 'Players':
$match->match_players_update();
break;
case 'Teams':
$match->match_teams_update();
break;
default:
}
if($event->getField('FixturesEnable') == TRUE)
{
$event->brackets(true);
}
$event->setFieldDB('IsChanged', 1);
header("Location: eventinfo.php?eventid=$event_id");
exit;
}
if (isset($_POST['addmedia']))
{
$event_id = $_POST['eventid'];
$match_id = $_POST['matchid'];
$match = new Match($match_id);
$media_type = $_POST['mediatype'];
$media_path = $_POST['mediapath'];
$submitter = USERID;
if (preg_match("/http:\/\//", $media_path))
{
$match->add_media($submitter, $media_path, $media_type);
}
header("Location: matchinfo.php?matchid=$match_id");
exit;
}
if (isset($_POST['del_media']) && $_POST['del_media']!="")
{
$match_id = $_POST['matchid'];
$media = $_POST['del_media'];
delete_media($media);
header("Location: matchinfo.php?matchid=$match_id");
exit;
}
// should not be here -> redirect
header("Location: events.php");
?>