This repository has been archived on 2024-06-26. You can view files and clone it, but cannot push or open issues or pull requests.
sakura/main/profile.php

67 lines
2.6 KiB
PHP
Raw Normal View History

2015-04-25 20:08:44 +00:00
<?php
/*
* Sakura User Profiles
*/
// Declare Namespace
namespace Sakura;
// Include components
require_once str_replace(basename(__DIR__), '', dirname(__FILE__)) .'_sakura/sakura.php';
// Catch old profile API and return error
2015-04-27 00:41:59 +00:00
if(isset($_REQUEST['data'])) {
2015-04-25 20:08:44 +00:00
2015-04-27 00:41:59 +00:00
header('Content-Type: text/plain; charset=utf-8');
header('Access-Control-Allow-Origin: *');
print json_encode(['error' => true]);
exit;
}
// Get user data
if(isset($_GET['u'])) {
$renderData['profile'] = [
2015-06-04 12:41:55 +00:00
'notset' => false,
'user' => ($_PROFILE_USER_DATA = Users::getUser(($_USER_USERNAME_ID = Users::userExists($_GET['u'], false)) ? $_USER_USERNAME_ID : $_GET['u'])),
'rank' => ($_PROFILE_RANK_DATA = Users::getRank($_PROFILE_USER_DATA['rank_main'])),
'colour' => ($_PROFILE_USER_DATA['name_colour'] == null ? $_PROFILE_RANK_DATA['colour'] : $_PROFILE_USER_DATA['name_colour']),
'ranktitle' => ($_PROFILE_USER_DATA['usertitle'] == null ? $_PROFILE_RANK_DATA['title'] : $_PROFILE_USER_DATA['usertitle']),
'data' => ($_PROFILE_PROFILE_DATA = Users::getUserProfileData($_PROFILE_USER_DATA, true)),
'country' => Main::getCountryName($_PROFILE_USER_DATA['country']),
'istenshi' => Users::checkUserTenshi($_PROFILE_USER_DATA['id']),
'online' => Users::checkUserOnline($_PROFILE_USER_DATA['id']),
'profilePage' => Users::getProfilePage($_PROFILE_PROFILE_DATA, true),
'fields' => Users::getUserProfileFields($_PROFILE_PROFILE_DATA, true),
2015-06-20 16:06:07 +00:00
'warnings' => Users::getWarnings($_PROFILE_USER_DATA['id']),
'friend' => Users::checkFriend($_PROFILE_USER_DATA['id'])
2015-04-27 00:41:59 +00:00
];
2015-05-29 19:27:45 +00:00
2015-05-03 21:43:25 +00:00
$renderData['page'] = [
'title' => ($_PROFILE_USER_DATA['id'] < 1 || $_PROFILE_USER_DATA['password_algo'] == 'nologin' ? 'User not found!' : 'Profile of '. $_PROFILE_USER_DATA['username']),
2015-06-04 12:41:55 +00:00
'style' => (!empty($_PROFILE_PROFILE_DATA['profileBackground']) ? [
2015-05-05 03:47:58 +00:00
'#userBackground' => [
'background' => 'url("/bg/'. $_PROFILE_USER_DATA['id'] .'") no-repeat center center / cover transparent !important',
2015-05-04 20:08:53 +00:00
'position' => 'fixed',
'top' => '0',
'bottom' => '0',
'right' => '0',
'left' => '0',
'z-index' => '-1'
2015-05-03 21:43:25 +00:00
]
] : null)
];
2015-04-27 00:41:59 +00:00
} else {
$renderData['profile']['notset'] = true;
$renderData['page']['title'] = 'User not found!';
}
// Print page contents
print Templates::render('main/profile.tpl', $renderData);