-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuserdata.php
44 lines (34 loc) · 1.15 KB
/
userdata.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
<?php
require_once("configuration/mysql.php");
if(!$_GET['displayname'])
{
exit;
}
$mQuery = $mysql->query("SELECT `id`, `usertitle`, `avatar` FROM `accounts` WHERE `displayname` = '" . escape($_GET['displayname']) . "'");
if($mQuery->num_rows)
{
$mData = $mQuery->fetch_assoc();
if(!$mData['usertitle'])
{
$userTitleQuery = $mysql->query("SELECT `usergroup` FROM `usergroup_tracker` WHERE `user` = '" . $mData['id'] . "' ORDER BY `primary` DESC");
if($userTitleQuery->num_rows)
{
while($userTitleData = $userTitleQuery->fetch_assoc())
{
$userGroupQuery = $mysql->query("SELECT `title` FROM `usergroups` WHERE `id` = '" . $userTitleData['usergroup'] . "'");
$userGroupData = $userGroupQuery->fetch_assoc();
if($mData['usertitle'] && $userGropuData['title'])
{
$mData['usertitle'] .= "<br>";
}
$mData['usertitle'] .= $userGroupData['title'];
}
}
}
echo json_encode(array("id" => $mData['id'], "title" => $mData['usertitle'], "avatar" => $mData['avatar']));
}
else
{
echo json_encode(array("id" => 0, "title" => "Invalid user specified", "avatar" => "images/defaultavatar.jpg"));
}
?>