-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathprofile_model.php
More file actions
84 lines (75 loc) · 2.62 KB
/
profile_model.php
File metadata and controls
84 lines (75 loc) · 2.62 KB
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
<?php
class profile_model extends BaseModel{
public function getPlayerData($playerUUID){
return new PlayerData($playerUUID, $this->database);
}
public function getPlayersStartingWith($prefix){
$query = $this->database->prepare( "SELECT BAT_player FROM BAT_players comments WHERE BAT_player LIKE :prefix;" );
$query->execute(array("prefix" => $prefix . "%"));
$players = array();
while($data = $query->fetch()){
$players[] = $data['BAT_player'];
}
return $players;
}
public function getPlayersByIp($ip){
$query = $this->database->prepare( "SELECT BAT_player FROM BAT_players comments WHERE lastip = :ip;" );
$query->execute(array("ip" => $ip ));
$players = array();
while($data = $query->fetch()){
$players[] = $data['BAT_player'];
}
return $players;
}
}
class PlayerData{
// Basic informations
private $player;
private $uuid;
// Additionals stats
private $firstlogin;
private $lastlogin;
private $lastip;
// Entries of all the modules
private $banEntries;
private $muteEntries;
private $watchEntries;
private $kickEntries;
private $commentEntries;
public function __construct($playerUUID, $database){
$this->uuid = $playerUUID;
// Gather additionals stats
$query = $database->prepare( "SELECT * FROM BAT_players WHERE UUID = :uuid;" );
$query->execute(array(":uuid" => $this->uuid));
$data = $query->fetch();
if($data != false){
$this->player = $data['BAT_player'];
$this->firstlogin = $data['firstlogin'];
$this->lastlogin = $data['lastlogin'];
$this->lastip = $data['lastip'];
}else{
die("Player not found !");
}
// Gather different modules stats
$banModel = new ban_model(); $this->banEntries = $banModel->getPlayerBans($this->uuid);
$muteModel = new mute_model(); $this->muteEntries = $muteModel->getPlayerMutes($this->uuid);
$watchModel = new watch_model(); $this->watchEntries = $watchModel->getPlayerWatches($this->uuid);
$kickModel = new kick_model(); $this->kickEntries = $kickModel->getPlayerKicks($this->uuid);
$commentModel = new comment_model(); $this->commentEntries = $commentModel->getPlayerComments($this->uuid);
}
public function getData(){
return array(
"headUrl" => "https://cravatar.eu/head/".$this->player."/192",
"player" => $this->player,
"uuid" => $this->uuid,
"firstlogin" => $this->firstlogin,
"lastlogin" => $this->lastlogin,
"lastip" => $this->lastip,
"bans" => $this->banEntries,
"mutes" => $this->muteEntries,
"watches" => $this->watchEntries,
"kicks" => $this->kickEntries,
"comments" => $this->commentEntries
);
}
}