2015-04-01 15:46:10 +00:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* Sakura user image serving
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Declare Namespace
|
|
|
|
namespace Sakura;
|
|
|
|
|
|
|
|
// Include components
|
2015-04-06 16:15:20 +00:00
|
|
|
require_once str_replace(basename(__DIR__), '', dirname(__FILE__)) .'_sakura/sakura.php';
|
2015-04-01 15:46:10 +00:00
|
|
|
|
|
|
|
// Set Content type
|
|
|
|
header('Content-Type: application/octet-stream');
|
|
|
|
|
|
|
|
// Check if the m(ode) GET request is set
|
|
|
|
if(isset($_GET['m'])) {
|
|
|
|
switch($_GET['m']) {
|
|
|
|
case 'avatar':
|
|
|
|
// Set path to no avatar picture
|
2015-04-27 16:30:31 +00:00
|
|
|
$noAvatar = ROOT .'content/images/no-av.png';
|
|
|
|
$deactiveAvatar = ROOT .'content/images/deactivated-av.png';
|
|
|
|
$bannedAvatar = ROOT .'content/images/banned-av.png';
|
|
|
|
$avatarDirPath = ROOT .'content/images/avatars/';
|
2015-04-01 15:46:10 +00:00
|
|
|
|
|
|
|
// If ?u= isn't set or if it isn't numeric
|
|
|
|
if(!isset($_GET['u']) || !is_numeric($_GET['u'])) {
|
|
|
|
$serveImage = $noAvatar;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-04-27 16:30:31 +00:00
|
|
|
// Get user data
|
|
|
|
$user = Users::getUser($_GET['u']);
|
|
|
|
|
|
|
|
// If user is deactivated use deactive avatar
|
|
|
|
if(Users::checkIfUserHasRanks([0, 1], $user, true)) {
|
|
|
|
$serveImage = $deactiveAvatar;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if user is banned
|
|
|
|
if(false) { // [Flashwave 2015-04-27] Banning isn't implemented yet
|
|
|
|
$serveImage = $bannedAvatar;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if user has an avatar set
|
|
|
|
if(empty($user['avatar_url']) || !file_exists($avatarDirPath . $user['avatar_url'])) {
|
|
|
|
$serveImage = $noAvatar;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-04-01 15:46:10 +00:00
|
|
|
// Check if the avatar exist and assign it to a value
|
2015-04-27 16:30:31 +00:00
|
|
|
$serveImage = $avatarDirPath . $user['avatar_url'];
|
|
|
|
break;
|
2015-04-01 15:46:10 +00:00
|
|
|
|
|
|
|
case 'background':
|
|
|
|
// Set path to no avatar picture
|
|
|
|
$noBackground = ROOT .'content/pixel.png';
|
|
|
|
|
|
|
|
// If ?u= isn't set or if it isn't numeric
|
|
|
|
if(!isset($_GET['u']) || !is_numeric($_GET['u'])) {
|
|
|
|
$serveImage = $noBackground;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if the avatar exist and assign it to a value
|
|
|
|
$serveImage = empty(Users::getUser($_GET['u'])['profilebg']) ? $noBackground : Users::getUser($_GET['u'])['profilebg'];
|
2015-04-27 16:30:31 +00:00
|
|
|
break;
|
2015-04-01 15:46:10 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
$serveImage = ROOT .'content/pixel.png';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$serveImage = ROOT .'content/pixel.png';
|
|
|
|
}
|
|
|
|
|
|
|
|
$serveImage = file_get_contents($serveImage);
|
|
|
|
|
|
|
|
header('Content-Type: ' .getimagesizefromstring($serveImage)['mime']);
|
|
|
|
|
|
|
|
print $serveImage;
|