fix some bugs

This commit is contained in:
printempw 2016-02-02 21:52:53 +08:00
parent 844e67b4bc
commit b323675bdf
7 changed files with 34 additions and 174 deletions

View File

@ -3,35 +3,22 @@
* @Author: printempw * @Author: printempw
* @Date: 2016-01-16 23:01:33 * @Date: 2016-01-16 23:01:33
* @Last Modified by: prpr * @Last Modified by: prpr
* @Last Modified time: 2016-01-21 18:20:46 * @Last Modified time: 2016-02-02 21:50:54
* *
* All ajax requests will be handled here * All ajax requests will be handled here
*/ */
header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow-Origin: *');
session_start(); session_start();
function __autoload($classname) {
$dir = dirname(__FILE__); $dir = dirname(__FILE__);
$filename = "$dir/includes/". $classname .".class.php"; require "$dir/includes/autoload.inc.php";
include_once($filename);
}
function getValue($key, $array) { if (isset($_POST['uname'])) {
if (array_key_exists($key, $array)) {
return $array[$key];
}
return false;
}
if ($uname = getValue('uname', $_POST)) {
$user = new user($uname); $user = new user($uname);
} else { } else {
utils::raise('1', 'Empty username.'); utils::raise('1', 'Empty username.');
} }
if (!($action = getValue('action', $_GET))) { $action = isset($_GET['action']) ? $_GET['action'] : "login";
$action = "login";
}
$json = null; $json = null;
if ($action == "login") { if ($action == "login") {
@ -84,7 +71,7 @@ if ($action == "login") {
} else if ($action == "upload") { } else if ($action == "upload") {
if ($_SESSION['token'] == $user->getToken()) { if ($_SESSION['token'] == $user->getToken()) {
if (checkFile()) { if (checkFile()) {
if ($file = getValue('skin_file', $_FILES)) { if ($file = utils::getValue('skin_file', $_FILES)) {
if ($user->setTexture('skin', $file)) { if ($user->setTexture('skin', $file)) {
$json[0]['errno'] = 0; $json[0]['errno'] = 0;
$json[0]['msg'] = "Skin uploaded successfully."; $json[0]['msg'] = "Skin uploaded successfully.";
@ -93,7 +80,7 @@ if ($action == "login") {
$json[0]['msg'] = "Uncaught error."; $json[0]['msg'] = "Uncaught error.";
} }
} }
if ($file = getValue('cape_file', $_FILES)) { if ($file = utils::getValue('cape_file', $_FILES)) {
if ($user->setTexture('cape', $file)) { if ($user->setTexture('cape', $file)) {
$json[1]['errno'] = 0; $json[1]['errno'] = 0;
$json[1]['msg'] = "Cape uploaded successfully."; $json[1]['msg'] = "Cape uploaded successfully.";
@ -108,7 +95,7 @@ if ($action == "login") {
$json['msg'] = "Invalid token."; $json['msg'] = "Invalid token.";
} }
} else if ($action == "logout") { } else if ($action == "logout") {
if (getValue('token', $_SESSION)) { if (utils::getValue('token', $_SESSION)) {
session_destroy(); session_destroy();
$json['errno'] = 0; $json['errno'] = 0;
$json['msg'] = 'Session destroyed.'; $json['msg'] = 'Session destroyed.';
@ -136,7 +123,7 @@ function checkInput() {
function checkFile() { function checkFile() {
global $json; global $json;
if (!(getValue('skin_file', $_FILES) || getValue('cape_file', $_FILES))) { if (!(utils::getValue('skin_file', $_FILES) || utils::getValue('cape_file', $_FILES))) {
$json['errno'] = 1; $json['errno'] = 1;
$json['msg'] = "No input file selected."; $json['msg'] = "No input file selected.";
return false; return false;
@ -144,15 +131,15 @@ function checkFile() {
/** /**
* Check for skin_file * Check for skin_file
*/ */
if ((getValue('skin_file', $_FILES)["type"] == "image/png") || (getValue('skin_file', $_FILES)["type"] == "image/x-png")) { if ((utils::getValue('skin_file', $_FILES)["type"] == "image/png") || (utils::getValue('skin_file', $_FILES)["type"] == "image/x-png")) {
// if error occured while uploading file // if error occured while uploading file
if (getValue('skin_file', $_FILES)["error"] > 0) { if (utils::getValue('skin_file', $_FILES)["error"] > 0) {
$json['errno'] = 1; $json['errno'] = 1;
$json['msg'] = getValue('skin_file', $_FILES)["error"]; $json['msg'] = utils::getValue('skin_file', $_FILES)["error"];
return false; return false;
} }
} else { } else {
if (getValue('skin_file', $_FILES)) { if (utils::getValue('skin_file', $_FILES)) {
$json['errno'] = 1; $json['errno'] = 1;
$json['msg'] = 'Skin file type error.'; $json['msg'] = 'Skin file type error.';
return false; return false;
@ -165,15 +152,15 @@ function checkFile() {
/** /**
* Check for cape_file * Check for cape_file
*/ */
if ((getValue('cape_file', $_FILES)["type"] == "image/png") || (getValue('cape_file', $_FILES)["type"] == "image/x-png")) { if ((utils::getValue('cape_file', $_FILES)["type"] == "image/png") || (utils::getValue('cape_file', $_FILES)["type"] == "image/x-png")) {
// if error occured while uploading file // if error occured while uploading file
if (getValue('cape_file', $_FILES)["error"] > 0) { if (utils::getValue('cape_file', $_FILES)["error"] > 0) {
$json['errno'] = 1; $json['errno'] = 1;
$json['msg'] = getValue('cape_file', $_FILES)["error"]; $json['msg'] = utils::getValue('cape_file', $_FILES)["error"];
return false; return false;
} }
} else { } else {
if (getValue('cape_file', $_FILES)) { if (utils::getValue('cape_file', $_FILES)) {
$json['errno'] = 1; $json['errno'] = 1;
$json['msg'] = 'Cape file type error.'; $json['msg'] = 'Cape file type error.';
return false; return false;

View File

@ -2,7 +2,7 @@
* @Author: prpr * @Author: prpr
* @Date: 2016-01-21 20:07:47 * @Date: 2016-01-21 20:07:47
* @Last Modified by: prpr * @Last Modified by: prpr
* @Last Modified time: 2016-01-21 21:09:54 * @Last Modified time: 2016-02-02 21:44:58
*/ */
.home-menu-blur { .home-menu-blur {
position: absolute; position: absolute;
@ -17,7 +17,7 @@
background-color: rgba(255,255,255,0.4); background-color: rgba(255,255,255,0.4);
} }
.home-menu-bg { .home-menu-bg {
background-image: url("http://ww4.sinaimg.cn/large/823186a6gw1enwts09sbrj21hc0u016u.jpg"); background-image: url("../images/bg.jpg");
background-position: center 0; background-position: center 0;
background-size: auto 800px; background-size: auto 800px;
position: absolute; position: absolute;
@ -34,8 +34,7 @@
.container { .container {
background-image: background-image:
url("http://ww4.sinaimg.cn/large/823186a6gw1enwts09sbrj21hc0u016u.jpg"); url("../images/bg.jpg");
/* background-size: cover; */
background-size: auto 800px; background-size: auto 800px;
background-repeat: no-repeat; background-repeat: no-repeat;
background-position: center 0; background-position: center 0;

View File

@ -1,123 +0,0 @@
@font-face {
font-family: 'Minecraft';
src: url('../fonts/minecraft.eot');
src: url('../fonts/minecraft.eot') format('embedded-opentype'),
url('../fonts/minecraft.woff2') format('woff2'),
url('../fonts/minecraft.woff') format('woff'),
url('../fonts/minecraft.ttf') format('truetype'),
url('../fonts/minecraft.svg#minecraft') format('svg');
}
body {
background-image: url(../images/bg_stone.png);
background-repeat: repeat;
}
.copy {
color: #FFFFFF;
}
img.l {
width: 44%;
margin-left: 10%;
}
.navbar {
border-radius: 0;
}
.navbar-default {
background-color: rgba(255,255,255,.9);
border-color: transparent;
box-shadow: rgba(0,0,0,0.1) 0 1px 2px;
}
.l {
float: left;
}
.r {
float: right;
margin-top: 20px;
}
.login-container, .upload-container {
margin-top: 8%;
margin-right: 10%;
border: #989898 1px solid;
border-radius: 4px;
width: 300px;
padding: 40px 40px 40px 40px;
background: rgba(255,255,255,.9);
}
.input-group {
margin: 20px 0 20px 0;
}
.login-group {
height: 40px;
}
div .keep {
float: left;
}
#login {
float: right;
}
#login-form {
margin-top: 10px;
}
.login-title, .upload-title {
font-family: Minecraft;
margin: 5px 0 30px 0;
}
.checkbox-wrapper {
float: left;
position: relative;
top: 15%;
}
.checkbox {
display: none;
}
label {
width: 18px;
height: 18px;
background: #fff;
border: 1px solid #e5e6e7;
margin-bottom: -3px;
border-radius: 2px;
cursor: pointer;
display: inline-block;
}
.checkbox:checked+label {
background: url(../images/check.png);
}
footer {
text-align: center;
color: #FFFFFF;
position: absolute;
width: 100%;
top: 95%;
}
.hide {
display: none;
}
.alert {
margin-bottom: 0px;
margin-top: 10px;
}
#canvas3d {
margin-left: 30%;
}

BIN
assets/images/bg.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 518 KiB

View File

@ -2,7 +2,7 @@
* @Author: prpr * @Author: prpr
* @Date: 2016-01-21 13:55:44 * @Date: 2016-01-21 13:55:44
* @Last Modified by: prpr * @Last Modified by: prpr
* @Last Modified time: 2016-01-22 15:03:08 * @Last Modified time: 2016-02-02 21:41:26
*/ */
'use strict'; 'use strict';
@ -66,6 +66,7 @@ $("body").on("click", "#register-button", function(){
$('[data-remodal-id=register-modal]').remodal().close(); $('[data-remodal-id=register-modal]').remodal().close();
showMsg('hide', ""); showMsg('hide', "");
} else { } else {
showMsg('hide', "");
showAlert(json.msg); showAlert(json.msg);
} }
} }

View File

@ -3,7 +3,7 @@
* @Author: printempw * @Author: printempw
* @Date: 2016-01-16 23:01:33 * @Date: 2016-01-16 23:01:33
* @Last Modified by: prpr * @Last Modified by: prpr
* @Last Modified time: 2016-02-02 21:31:36 * @Last Modified time: 2016-02-02 21:38:22
*/ */
class user { class user {
@ -73,6 +73,7 @@ class user {
$data = fread(fopen($filename, 'r'), filesize($filename)); $data = fread(fopen($filename, 'r'), filesize($filename));
return $data; return $data;
} else { } else {
header('Content-type: application/json');
utils::raise(-1, 'Texture no longer exists.'); utils::raise(-1, 'Texture no longer exists.');
} }
} }

View File

@ -7,12 +7,7 @@
*/ */
session_start(); session_start();
$dir = dirname(dirname(__FILE__)); $dir = dirname(dirname(__FILE__));
require "$dir/includes/autoload.inc.php";
function __autoload($classname) {
global $dir;
$filename = "$dir/includes/". $classname .".class.php";
include_once($filename);
}
$action = utils::getValue('action', $_GET); $action = utils::getValue('action', $_GET);