blessing-skin-server/get.php

55 lines
1.9 KiB
PHP
Raw Normal View History

2016-02-02 21:22:53 +08:00
<?php
/**
2016-03-19 10:28:18 +08:00
* @Author: printempw
2016-02-02 21:22:53 +08:00
* @Date: 2016-02-02 20:56:42
2016-03-12 18:48:10 +08:00
* @Last Modified by: printempw
2016-04-23 13:03:39 +08:00
* @Last Modified time: 2016-04-23 13:02:24
*
* All textures requests of legacy link will be handle here.
2016-02-02 21:22:53 +08:00
*/
$dir = dirname(__FILE__);
2016-03-26 18:50:47 +08:00
require "$dir/libraries/autoloader.php";
2016-02-02 21:22:53 +08:00
if (isset($_GET['type']) && isset($_GET['uname'])) {
// Use for checking rewrite rules when install
if ($_GET['uname'] == "check_for_rewrite_rules") exit;
2016-02-06 23:18:07 +08:00
$user = new User($_GET['uname']);
if (!$user->is_registered) {
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
2016-03-27 11:38:27 +08:00
throw new E('Non-existent user.', 1);
}
// Cache friendly
2016-02-10 15:20:13 +08:00
$if_modified_since = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ?
strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) : null;
2016-03-13 09:31:33 +08:00
// Image bin data
2016-02-03 13:27:13 +08:00
if ($_GET['type'] == "skin" || $_GET['type'] == "cape") {
2016-04-23 13:03:39 +08:00
$model_preference = ($user->getPreference() == "default") ? "steve" : "alex";
$model = (isset($_GET['model']) && $_GET['model'] == "") ? $model_preference : $_GET['model'];
2016-02-03 13:27:13 +08:00
if ($if_modified_since >= $user->getLastModified()) {
header('HTTP/1.0 304 Not Modified');
} else {
if ($_GET['type'] == "cape") {
echo $user->getBinaryTexture('cape');
} else {
echo $user->getBinaryTexture($model);
}
2016-02-03 13:27:13 +08:00
}
2016-03-13 09:31:33 +08:00
// JSON profile
2016-02-02 21:34:07 +08:00
} else if ($_GET['type'] == "json") {
if (isset($_GET['api'])) {
echo $user->getJsonProfile(($_GET['api'] == 'csl') ? 0 : 1);
} else {
2016-03-26 22:29:45 +08:00
echo $user->getJsonProfile(Option::get('api_type'));
}
} else if ($_GET['type'] == "avatar") {
$size = (isset($_GET['size']) && $_GET['size'] != "") ? (int)$_GET['size'] : 128;
2016-03-26 20:39:55 +08:00
$user->getAvatar($size);
2016-02-02 21:34:07 +08:00
} else {
2016-03-27 11:38:27 +08:00
throw new E('Illegal parameters.', 1);
2016-02-02 21:22:53 +08:00
}
} else {
2016-03-27 11:38:27 +08:00
throw new E('Illegal parameters.', 1);
2016-02-02 21:22:53 +08:00
}