real_escape_string($_GET['u']);
$userQuery = $database->query("SELECT * FROM `flashii_users` WHERE `username_clean`='".$user."' OR `id`='".$user."' AND `userrole`!='0' LIMIT 1");
$userArray = $userQuery->fetch_array(MYSQLI_ASSOC);
$groupQuery = $database->query("SELECT * FROM `flashii_groups` WHERE `gid`='".$userArray['userrole']."' LIMIT 1");
$groupArray = $groupQuery->fetch_array(MYSQLI_ASSOC);
$warnQuery = $database->query("SELECT * FROM `flashii_warnings` WHERE `userid`='".$userArray['id']."'");
$warnArray = $warnQuery->fetch_all(MYSQLI_ASSOC);
// Check if the user exists
$userExists = $userArray ? true : false;
// Check if profile markdown is set
$userPage = $userArray['profilemarkdown'] ? true : false;
// Check the standing of the account
$standing = $warnArray ? true : false;
// Assign certain data to their own variable
$userVar = array();
$userVar['title'] = $userExists ? 'Profile of '.$userArray['username'] : 'User does not exist.';
$userVar['avatar'] = '/a/' . $userArray['id'];
$userVar['uTitle'] = $userArray['usertitle'] ? $userArray['usertitle'] : $groupArray['name'] ;
$userVar['profileBg'] = empty($userArray['profilebg']) ? null : '';
$userVar['sideBar'] = '';
// Set sideBar values
if($flashii->loggedIn()) {
if(!empty($userArray['birthdate'])) {
$userVar['sideBar'] .= '
Age | '
. date_diff(date_create(date('Y-m-d', $userArray['birthdate'])), date_create(date('Y-m-d')))->format('%Y')
. ' |
';
}
if(!empty($userArray['gender'])) {
$userVar['sideBar'] .= 'Gender | '
. ($gaytumblrshit[$userArray['gender']] ?? 'Undiscovered')
. ' |
';
}
if(!empty($userArray['website'])) {
$website = preg_match("~^(?:f|ht)tps?://~i", $userArray['website']) ? $userArray['website'] : 'http://' . $userArray['website'];
$userVar['sideBar'] .= 'Website | '
. $userArray['website']
. ' |
';
}
if(!empty($userArray['twitter'])) {
$userVar['sideBar'] .= 'Twitter | @'
. $userArray['twitter']
. ' |
';
}
if(!empty($userArray['github'])) {
$userVar['sideBar'] .= 'GitHub | '
. $userArray['github']
. ' |
';
}
if(!empty($userArray['skype'])) {
$userVar['sideBar'] .= 'Skype | '
. $userArray['skype']
. ' |
';
}
if(!empty($userArray['youtube'])) {
$userVar['sideBar'] .= 'YouTube | ' . ($userArray['youtube_type'] ? $userArray['username'] . '\'s Channel' : $userArray['youtube'])
. ' |
';
}
if(!empty($userArray['soundcloud'])) {
$userVar['sideBar'] .= 'SoundCloud | '
. $userArray['soundcloud']
. ' |
';
}
if(!empty($userArray['steam'])) {
$userVar['sideBar'] .= 'Steam | '
. $userArray['steam']
. ' |
';
}
if(!empty($userArray['osu'])) {
$userVar['sideBar'] .= 'osu! | '
. $userArray['osu']
. ' |
';
}
if(!empty($userArray['eaorigin'])) { // Fuck this one
$userVar['sideBar'] .= 'Origin | '
. $userArray['eaorigin']
. ' |
';
}
if(!empty($userArray['xboxlive'])) {
$userVar['sideBar'] .= 'Xbox live | '
. $userArray['xboxlive']
. ' |
';
}
if(!empty($userArray['playstation'])) {
$userVar['sideBar'] .= 'PSN | '
. $userArray['playstation']
. ' |
';
}
if($flashii->checkRank($fwSettings['staffRanks'])) {
if(!empty($userArray['register_ip'])) {
$userVar['sideBar'] .= 'Registered from IP | '
. $userArray['register_ip']
. ' |
';
}
if(!empty($userArray['last_ip'])) {
$userVar['sideBar'] .= 'Last seen on IP | '
. $userArray['last_ip']
. ' |
';
}
if(!empty($userArray['email'])) {
$userVar['sideBar'] .= 'E-mail Address | '
. $userArray['email']
. ' |
';
}
}
} else {
$userVar['sideBar'] = 'Please login to view the full profile of this user. |
';
}
// Profile Read-Only "API"
if(isset($_GET['data'])) {
header('Content-Type: text/plain; charset=utf-8');
header('Access-Control-Allow-Origin: *');
$userData = array();
if($userExists) {
$userData['userID'] = $userArray['id'];
$userData['userName'] = $userArray['username'];
$userData['userAvatar'] = 'http://' . $_SERVER['HTTP_HOST'] . '/a/'. $userArray['id'];
$userData['userBackground'] = 'http://' . $_SERVER['HTTP_HOST'] . '/bg/'. $userArray['id'];
$userData['userTitle'] = $userVar['uTitle'];
$userData['groupID'] = $groupArray['gid'];
$userData['groupName'] = $groupArray['name'];
$userData['groupColour'] = $groupArray['colour'];
$userData['joinTimeStamp'] = $userArray['join_date'];
$userData['lastTimeStamp'] = $userArray['last_seen'] ? $userArray['last_seen'] : 0;
$userData['markdown'] = base64_encode(strip_tags($userArray['profilemarkdown']));
$userData['error'] = false;
} else {
$userData['error'] = true;
}
print_r(json_encode($userData));
exit;
}
// Initialise Markdown parser
$mdparser = new Parsedown();
require_once fiiSwitch_path();