supported both CustomSkinLoader API and UniSkinAPI
This commit is contained in:
parent
f113876f1b
commit
01bf32d8ed
@ -17,5 +17,5 @@ define('SALT', '9tvsh55d*s');
|
||||
/* Max amount of accounts per IP */
|
||||
define('REGS_PER_IP', 2);
|
||||
|
||||
/* Do not change this */
|
||||
define('DIR', dirname(__FILE__));
|
||||
/* Which API to use, 0 for CustomSkinLoader API, 1 for UniSkinAPI */
|
||||
define('API_TYPE', 0);
|
||||
|
13
get.php
13
get.php
@ -3,17 +3,18 @@
|
||||
* @Author: prpr
|
||||
* @Date: 2016-02-02 20:56:42
|
||||
* @Last Modified by: prpr
|
||||
* @Last Modified time: 2016-02-03 13:37:33
|
||||
* @Last Modified time: 2016-02-04 22:06:20
|
||||
*
|
||||
* All textures requests of legacy link will be handle here.
|
||||
*/
|
||||
|
||||
$dir = dirname(__FILE__);
|
||||
require "$dir/includes/autoload.inc.php";
|
||||
require "$dir/config.php";
|
||||
|
||||
if (isset($_GET['type']) && isset($_GET['uname'])) {
|
||||
$user = new user($_GET['uname']);
|
||||
if (!$user->is_registered) utils::raise(1, 'Non-existent user.');
|
||||
|
||||
// Cache friendly
|
||||
$if_modified_since = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) : null;
|
||||
|
||||
if ($_GET['type'] == "skin" || $_GET['type'] == "cape") {
|
||||
@ -23,7 +24,11 @@ if (isset($_GET['type']) && isset($_GET['uname'])) {
|
||||
echo $user->getBinaryTexture($_GET['type']);
|
||||
}
|
||||
} else if ($_GET['type'] == "json") {
|
||||
echo $user->getJsonProfile();
|
||||
if (isset($_GET['api'])) {
|
||||
echo $user->getJsonProfile(($_GET['api'] == 'csl') ? 0 : 1);
|
||||
} else {
|
||||
echo $user->getJsonProfile(API_TYPE);
|
||||
}
|
||||
} else {
|
||||
utils::raise(1, 'Illegal parameters.');
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
* @Author: printempw
|
||||
* @Date: 2016-01-16 23:01:33
|
||||
* @Last Modified by: prpr
|
||||
* @Last Modified time: 2016-02-04 13:48:48
|
||||
* @Last Modified time: 2016-02-04 20:38:42
|
||||
*/
|
||||
|
||||
class user
|
||||
@ -121,15 +121,23 @@ class user
|
||||
return $this->db->select('username', $this->uname)['preference'];
|
||||
}
|
||||
|
||||
public function getJsonProfile() {
|
||||
public function getJsonProfile($api_type) {
|
||||
header('Content-type: application/json');
|
||||
if ($this->is_registered) {
|
||||
$json['player_name'] = $this->uname;
|
||||
$json['last_update'] = $this->getLastModified();
|
||||
$preference = $this->getPreference();
|
||||
$json['model_preference'] = [$preference];
|
||||
$json['skins'][$preference] = $this->getTexture('skin');
|
||||
$json['cape'] = $this->getTexture('cape');
|
||||
if ($api_type == 0 || $api_type == 1) {
|
||||
$json[($api_type == 0) ? 'username' : 'player_name'] = $this->uname;
|
||||
$model = $this->getPreference();
|
||||
$sec_model = ($model == 'default') ? 'slim' : 'default';
|
||||
if ($api_type == 1) {
|
||||
$json['last_update'] = $this->getLastModified();
|
||||
$json['model_preference'] = [$model, $sec_model];
|
||||
}
|
||||
$json['skins'][$model] = $this->getTexture('skin');
|
||||
$json['skins'][$sec_model] = $this->getTexture('skin');
|
||||
$json['cape'] = $this->getTexture('cape');
|
||||
} else {
|
||||
utils::raise(-1, 'Configuration error. Non-supported API_TYPE.');
|
||||
}
|
||||
} else {
|
||||
$json['errno'] = 1;
|
||||
$json['msg'] = "Non-existent user.";
|
||||
|
Loading…
Reference in New Issue
Block a user