|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Klass MatchdataAjax. |
|
5
|
|
|
* @author Niklas Dougherty |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
declare(strict_types=1); |
|
9
|
|
|
|
|
10
|
|
|
namespace Tips\Ajax; |
|
11
|
|
|
|
|
12
|
|
|
use Tips\Klasser\Preludium; |
|
13
|
|
|
use Tips\Klasser\Spel; |
|
14
|
|
|
use Tips\Klasser\Speltyp; |
|
15
|
|
|
use Tips\Klasser\Tips; |
|
16
|
|
|
use Tips\Klasser\Sekvenser; |
|
17
|
|
|
use Tips\Egenskaper\Ajax; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Ajaxanrop ligger utanför ordinarie ordning. |
|
21
|
|
|
*/ |
|
22
|
1 |
|
require_once dirname(__FILE__) . '/../../vendor/autoload.php'; |
|
23
|
1 |
|
new Preludium(); |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Klass MatchdataAjax. |
|
27
|
|
|
* @SuppressWarnings("PHPMD.UnusedPrivateMethod", "PHPMD.UnusedPrivateField") |
|
28
|
|
|
*/ |
|
29
|
|
|
final class MatchdataAjax extends Nedbrytning { |
|
30
|
|
|
use Ajax; |
|
|
|
|
|
|
31
|
|
|
|
|
32
|
|
|
private Spel $spel; |
|
33
|
|
|
private Tips $tips; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Inititiera. |
|
37
|
|
|
*/ |
|
38
|
1 |
|
public function __construct() { |
|
39
|
1 |
|
$this->spel = new Spel(); |
|
40
|
1 |
|
$this->tips = new Tips($this->spel); |
|
41
|
1 |
|
$this->förgrena(); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* Spara matchdata. |
|
46
|
|
|
* js/funktioner.js: spara_matchdata |
|
47
|
|
|
*/ |
|
48
|
1 |
|
private function spara_matchdata(): void { |
|
|
|
|
|
|
49
|
1 |
|
$_REQUEST['spara_matchdata'] = (string) filter_var($_REQUEST['spara_matchdata'], FILTER_SANITIZE_URL); |
|
50
|
1 |
|
parse_str($_REQUEST['spara_matchdata'], $matchdata); |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Omgångsdata. |
|
54
|
|
|
*/ |
|
55
|
1 |
|
$this->tips->spel->omgång = (int) $matchdata['omgång']; |
|
56
|
1 |
|
$this->tips->utdelning->år = (int) $matchdata['år']; |
|
57
|
1 |
|
$this->tips->utdelning->vecka = (int) $matchdata['vecka']; |
|
58
|
|
|
|
|
59
|
1 |
|
$this->tips->utdelning->tipsrad = (string) filter_var($matchdata['tipsrad'], FILTER_SANITIZE_SPECIAL_CHARS); |
|
60
|
1 |
|
$this->tips->utdelning->tipsrad_012 = symboler_till_siffror($this->tips->utdelning->tipsrad); |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* Utdelning och antal vinnare i respektive vinstkategori. |
|
64
|
|
|
*/ |
|
65
|
1 |
|
foreach (range(0, 2) as $i) { |
|
66
|
1 |
|
$this->tips->utdelning->utdelning[$i] = (int) filter_var($matchdata['utdelning'][$i], FILTER_VALIDATE_INT); |
|
67
|
1 |
|
$this->tips->utdelning->vinnare[$i] = (int) filter_var($matchdata['vinnare'][$i], FILTER_VALIDATE_INT); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* Matchstatus. |
|
72
|
|
|
*/ |
|
73
|
1 |
|
$this->tips->matcher->matchstatus = array_map(fn ($i): int => |
|
74
|
1 |
|
(int) filter_var($matchdata['matchstatus'][$i], FILTER_VALIDATE_INT), range(0, MATCHANTAL - 1)); |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* Odds och streck. |
|
78
|
|
|
*/ |
|
79
|
1 |
|
$this->bryt_ned_prediktioner($matchdata['odds'], $this->tips->odds->prediktioner); |
|
80
|
1 |
|
$this->bryt_ned_prediktioner($matchdata['streck'], $this->tips->streck->prediktioner); |
|
81
|
|
|
|
|
82
|
1 |
|
$this->tips->matcher->spelstopp = (string) filter_var($matchdata['spelstopp'], FILTER_SANITIZE_SPECIAL_CHARS); |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* Matcher. |
|
86
|
|
|
*/ |
|
87
|
1 |
|
$this->bryt_ned_vektor($matchdata['lag'], $this->tips->matcher->match); |
|
88
|
1 |
|
$this->bryt_ned_vektor($matchdata['resultat'], $this->tips->matcher->resultat); |
|
89
|
|
|
|
|
90
|
1 |
|
$this->tips->spara_tips(); |
|
91
|
1 |
|
(new Sekvenser($this->tips->spel))->traversera_sekvenser(); |
|
92
|
|
|
|
|
93
|
1 |
|
$this->spel->db->spara_backup(); |
|
94
|
|
|
} |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
new MatchdataAjax(); |
|
98
|
|
|
|