mirror of
https://github.com/bs-community/blessing-skin-server.git
synced 2024-12-21 06:19:38 +08:00
183 lines
11 KiB
PHP
183 lines
11 KiB
PHP
<?php
|
|
/*
|
|
* @Author: prpr
|
|
* @Date: 2016-01-21 13:56:40
|
|
* @Last Modified by: prpr
|
|
* @Last Modified time: 2016-01-21 20:40:04
|
|
*/
|
|
session_start();
|
|
$dir = dirname(dirname(__FILE__));
|
|
|
|
function __autoload($classname) {
|
|
global $dir;
|
|
$filename = "$dir/includes/". $classname .".class.php";
|
|
include_once($filename);
|
|
}
|
|
|
|
$action = utils::getValue('action', $_GET);
|
|
|
|
if(isset($_COOKIE['uname']) && isset($_COOKIE['token'])) {
|
|
$_SESSION['uname'] = $_COOKIE['uname'];
|
|
$_SESSION['token'] = $_COOKIE['token'];
|
|
}
|
|
|
|
if (isset($_SESSION['uname'])) {
|
|
$user = new user($_SESSION['uname']);
|
|
if ($_SESSION['token'] != $user->getToken()) {
|
|
header('Location: ../index.php?msg=Invalid token. Please login.');
|
|
}
|
|
} else {
|
|
header('Location: ../index.php?msg=Illegal access. Please login.');
|
|
}
|
|
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Upload - Blessing Skin Server</title>
|
|
<link rel="stylesheet" href="../libs/pure/pure-min.css">
|
|
<link rel="stylesheet" href="../libs/pure/grids-responsive-min.css">
|
|
<link rel="stylesheet" href="../libs/glyphicon/glyphicon.css">
|
|
<link rel="stylesheet" href="../assets/css/style.css">
|
|
<link rel="stylesheet" href="../assets/css/user.style.css">
|
|
<link rel="stylesheet" href="../libs/ply/ply.css">
|
|
<link rel="stylesheet" href="../libs/remodal/remodal.css">
|
|
<link rel="stylesheet" href="../libs/remodal/remodal-default-theme.css">
|
|
</head>
|
|
<body>
|
|
<div class="header">
|
|
<div class="home-menu pure-menu pure-menu-horizontal pure-menu-fixed">
|
|
<a class="pure-menu-heading" href="../index.php">Blessing Skin Server</a>
|
|
<a href="javascript:;" title="Movements"><span class="glyphicon glyphicon-pause"></span></a>
|
|
<a href="javascript:;" title="Running"><span class="glyphicon glyphicon-forward"></span></a>
|
|
<a href="javascript:;" title="Rotation"><span class="glyphicon glyphicon-repeat"></span></a>
|
|
<ul class="pure-menu-list">
|
|
<li class="pure-menu-item">
|
|
<a href="javascript:;" class="pure-menu-link">Welcome, <?php echo $_SESSION['uname']; ?>!</a>
|
|
</li>
|
|
<li class="pure-menu-item">
|
|
<a class="pure-menu-link" id="logout" href="javascript:;">Log out?</a>
|
|
</li>
|
|
</ul>
|
|
<div class="home-menu-blur">
|
|
<div class="home-menu-wrp">
|
|
<div class="home-menu-bg"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<?php if ($action == "preview") { ?>
|
|
<div class="container">
|
|
<div id="skinpreview"></div>
|
|
</div>
|
|
<style>
|
|
#canvas3d {
|
|
margin: 8% auto;
|
|
}
|
|
</style>
|
|
<?php } else if ($action == "upload") { ?>
|
|
<div class="container">
|
|
<div class="upload-container">
|
|
<h2 class="upload-title">Upload</h2>
|
|
<div id="upload-form">
|
|
<p>Select a skin:</p>
|
|
<input type=file id="skininput" name="skininput" accept="image/png">
|
|
<br />
|
|
<p>Select a cape:</p>
|
|
<input type=file id="capeinput" name="capeinput" accept="image/png">
|
|
<br /><br />
|
|
<button id="upload" class="pure-button pure-button-primary">Upload</button>
|
|
<a href="?action=preview" class="pure-button">Preview</a>
|
|
</div>
|
|
<div id="msg" class="alert hide" role="alert" />
|
|
</div>
|
|
</div>
|
|
<style>
|
|
.upload-container {
|
|
width: 70%;
|
|
height: 50%;
|
|
margin: 100px auto;
|
|
}
|
|
</style>
|
|
<?php } else { ?>
|
|
<div class="container pure-g">
|
|
<div class="pure-u-2-3">
|
|
<div id="skinpreview"></div>
|
|
</div>
|
|
<div class="pure-u-1-3">
|
|
<div class="upload-container">
|
|
<h2 class="upload-title">Upload</h2>
|
|
<div id="upload-form">
|
|
<p>Select a skin:</p>
|
|
<input type=file id="skininput" name="skininput" accept="image/png">
|
|
<br />
|
|
<p>Select a cape:</p>
|
|
<input type=file id="capeinput" name="capeinput" accept="image/png">
|
|
<br /><br />
|
|
<button id="upload" class="pure-button pure-button-primary">Upload</button>
|
|
<a id="preview" href="?action=preview" class="pure-button">Preview</a>
|
|
</div>
|
|
<div id="msg" class="alert hide" role="alert" />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<style>
|
|
#preview {
|
|
display: none;
|
|
}
|
|
@media (max-width: 800px) {
|
|
#skinpreview {
|
|
display: none;
|
|
}
|
|
#preview {
|
|
display: inline-block;
|
|
}
|
|
.pure-u-2-3 {
|
|
width: 0%;
|
|
}
|
|
.pure-u-1-3 {
|
|
width: 100%;
|
|
}
|
|
.upload-container {
|
|
width: 70%;
|
|
height: 50%;
|
|
margin: 100px auto;
|
|
}
|
|
}
|
|
</style>
|
|
<?php } ?>
|
|
|
|
<div class="footer">
|
|
© <a class="copy" href="https://prinzeugen.net">Blessing Studio</a> 2016
|
|
</div>
|
|
|
|
</body>
|
|
<script type="text/javascript" src="../libs/jquery/jquery-2.1.1.min.js"></script>
|
|
<script type="text/javascript" src="../libs/cookie.js"></script>
|
|
<script type="text/javascript" src="../libs/three.js"></script>
|
|
<script type="text/javascript" src="../libs/three.msp.js"></script>
|
|
<script type="text/javascript" src="../libs/ply/ply.min.js"></script>
|
|
<script type="text/javascript" src="../assets/js/user.utils.js"></script>
|
|
<?php
|
|
// get and set texture for preview
|
|
$skin_file = $user->getTexture('skin');
|
|
if ($skin_file) {
|
|
echo "<script>var dskin ='../textures/".$skin_file."';</script>";
|
|
} else {
|
|
echo '<script>/* 设置默认图像 */ var dskin = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAgCAYAAACinX6EAAAACXBIWXMAAAsTAAALEwEAmpwYAAAKTWlDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVN3WJP3Fj7f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/h0A5u0k/Y+H8kQAAAAASUVORK5CYII=";</script>';
|
|
}
|
|
echo "<script>MSP.changeSkin(dskin);</script>";
|
|
|
|
$cape_file = "./uploads/cape/".$_COOKIE['uname'].".png";
|
|
$cape_file = $user -> getTexture('cape');
|
|
if ($cape_file) {
|
|
echo "<script>var dcape ='../textures/".$cape_file."';</script>";
|
|
echo "<script>MSP.changeCape(dcape);</script>";
|
|
}
|
|
|
|
?>
|
|
</html>
|