hajime/public/imageserve.php

70 lines
1.9 KiB
PHP
Raw Permalink Normal View History

2023-08-11 22:16:32 +00:00
<?php
// avatar.php
// Last update: 2015-01-22
// Require core components
require_once __DIR__ . '/../startup.php';
// 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
$noAvatar = __DIR__ . '/assets/img/no-av.png';
// If ?u= isn't set or if it isn't numeric
if(!isset($_GET['u']) || !is_numeric($_GET['u'])) {
$serveImage = $noAvatar;
break;
}
$userInfo = $flashii->getUserdata($_GET['u']);
if(!empty($userInfo['avatar_url'])) {
$avatarPath = FII_ASS_AV . '/' . $userInfo['avatar_url'];
if(is_file($avatarPath))
$serveImage = $avatarPath;
}
if(empty($serveImage))
$serveImage = $noAvatar;
break;
case 'background':
// Set path to no avatar picture
$noBackground = __DIR__ . '/assets/pixel.png';
// If ?u= isn't set or if it isn't numeric
if(!isset($_GET['u']) || !is_numeric($_GET['u'])) {
$serveImage = $noBackground;
break;
}
$userInfo = $flashii->getUserdata($_GET['u']);
if(!empty($userInfo['profilebg'])) {
$bgPath = FII_ASS_BG . '/' . $userInfo['profilebg'];
if(is_file($bgPath))
$serveImage = $bgPath;
}
if(empty($serveImage))
$serveImage = $noBackground;
break;
default:
$serveImage = __DIR__ . '/assets/pixel.png';
}
} else {
$serveImage = __DIR__ . '/assets/pixel.png';
}
$serveImage = file_get_contents($serveImage);
header('Content-Type: ' .getimagesizefromstring($serveImage)['mime']);
print $serveImage;