Use server map for signature links.
This commit is contained in:
parent
9dd7cc9bb6
commit
ab0968ed35
1 changed files with 20 additions and 44 deletions
|
@ -15,23 +15,13 @@ if($reqMethod !== 'HEAD' && $reqMethod !== 'GET') {
|
|||
return;
|
||||
}
|
||||
|
||||
if($reqPath === '/np' || $reqPath === '/redir.php') {
|
||||
http_response_code(302);
|
||||
header('Location: ' . ($nowPlaying ? $npInfo->url : 'https://flash.moe'));
|
||||
return;
|
||||
}
|
||||
|
||||
if($reqPath === '/source' || $reqPath === '/sig-src.php') {
|
||||
http_response_code(301);
|
||||
header('Location: https://patchii.net/flash/signature');
|
||||
return;
|
||||
}
|
||||
|
||||
if(in_array($reqPath, [
|
||||
'/', '/index.php', '/signature.php', '/signature.png',
|
||||
'/album.png', '/album1.png', '/album2.png',
|
||||
'/body.png', '/body1.png', '/body2.png',
|
||||
])) {
|
||||
if($reqPath === '/signature.png') {
|
||||
$ip_000 = new ImagickPixel('#000');
|
||||
$ip_444 = new ImagickPixel('#444');
|
||||
$ip_fff = new ImagickPixel('#fff');
|
||||
|
@ -116,46 +106,32 @@ if(in_array($reqPath, [
|
|||
$imagick->annotateImage($imagickDraw, 10, SIG_HEIGHT - 4, 0, "If it ain't broke, I'll break it");
|
||||
}
|
||||
|
||||
$fileName = pathinfo($reqPath, PATHINFO_FILENAME);
|
||||
|
||||
switch($fileName) {
|
||||
case 'album':
|
||||
$imagick->cropImage(SIG_HEIGHT, SIG_HEIGHT, SIG_WIDTH - SIG_HEIGHT, 0);
|
||||
break;
|
||||
|
||||
case 'album1':
|
||||
$imagick->cropImage(SIG_HEIGHT, SIG_HEIGHT - $footerHeight, SIG_WIDTH - SIG_HEIGHT, 0);
|
||||
break;
|
||||
|
||||
case 'album2':
|
||||
$imagick->cropImage(SIG_HEIGHT, $footerHeight, SIG_WIDTH - SIG_HEIGHT, SIG_HEIGHT - $footerHeight);
|
||||
break;
|
||||
|
||||
case 'body':
|
||||
$imagick->cropImage(SIG_WIDTH - SIG_HEIGHT, SIG_HEIGHT, 0, 0);
|
||||
break;
|
||||
|
||||
case 'body1':
|
||||
$imagick->cropImage(SIG_WIDTH - SIG_HEIGHT, SIG_HEIGHT - $footerHeight, 0, 0);
|
||||
break;
|
||||
|
||||
case 'body2':
|
||||
$imagick->cropImage(SIG_WIDTH - SIG_HEIGHT, $footerHeight, 0, SIG_HEIGHT - $footerHeight);
|
||||
break;
|
||||
|
||||
default:
|
||||
$fileName = 'signature';
|
||||
break;
|
||||
}
|
||||
|
||||
header('Content-Type: image/png');
|
||||
header('Cache-Control: max-age=' . SIG_AGE . ', public');
|
||||
header('Content-Disposition: inline; filename="' . $fileName . '.png"');
|
||||
header('Content-Disposition: inline; filename="signature.png"');
|
||||
echo $imagick->getImageBlob();
|
||||
|
||||
$imagick->destroy();
|
||||
return;
|
||||
}
|
||||
|
||||
if($reqPath === '/') {
|
||||
$coords = explode(',', (string)filter_input(INPUT_SERVER, 'QUERY_STRING'), 3);
|
||||
if(count($coords) === 2) {
|
||||
$x = max(0, min(SIG_WIDTH, (int)$coords[0]));
|
||||
$y = max(0, min(SIG_HEIGHT, (int)$coords[1]));
|
||||
} else $x = $y = 0;
|
||||
|
||||
http_response_code(302);
|
||||
|
||||
if($x >= (SIG_WIDTH - SIG_HEIGHT) && $nowPlaying) {
|
||||
header('Location: ' . $npInfo->url);
|
||||
return;
|
||||
}
|
||||
|
||||
header('Location: https://flash.moe');
|
||||
return;
|
||||
}
|
||||
|
||||
http_response_code(404);
|
||||
echo '404';
|
||||
|
|
Loading…
Reference in a new issue