add independent get entrance
This commit is contained in:
parent
ba35e2c193
commit
7c0592dbf8
27
get.php
Normal file
27
get.php
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @Author: prpr
|
||||||
|
* @Date: 2016-02-02 20:56:42
|
||||||
|
* @Last Modified by: prpr
|
||||||
|
* @Last Modified time: 2016-02-02 21:20:29
|
||||||
|
*/
|
||||||
|
|
||||||
|
$dir = dirname(__FILE__);
|
||||||
|
require "$dir/includes/autoload.inc.php";
|
||||||
|
|
||||||
|
if (isset($_GET['type']) && isset($_GET['uname'])) {
|
||||||
|
$user = new user($_GET['uname']);
|
||||||
|
if (!$user->is_registered) utils::raise(1, 'Non-existent user.');
|
||||||
|
if ($_GET['type'] == "skin") {
|
||||||
|
header('Content-Type: image/png');
|
||||||
|
echo $user->getBinaryTexture('skin');
|
||||||
|
} else if ($_GET['type'] == "cape") {
|
||||||
|
header('Content-Type: image/png');
|
||||||
|
echo $user->getBinaryTexture('cape');
|
||||||
|
} else {
|
||||||
|
header('Content-type: application/json');
|
||||||
|
echo $user->getJsonProfile();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
utils::raise(1, 'Illegal parameters.');
|
||||||
|
}
|
53
index.php
53
index.php
@ -3,47 +3,19 @@
|
|||||||
* @Author: printempw
|
* @Author: printempw
|
||||||
* @Date: 2016-01-17 13:55:20
|
* @Date: 2016-01-17 13:55:20
|
||||||
* @Last Modified by: prpr
|
* @Last Modified by: prpr
|
||||||
* @Last Modified time: 2016-01-22 16:17:40
|
* @Last Modified time: 2016-02-02 21:20:23
|
||||||
*/
|
*/
|
||||||
|
session_start();
|
||||||
$dir = dirname(__FILE__);
|
$dir = dirname(__FILE__);
|
||||||
|
require "$dir/includes/autoload.inc.php";
|
||||||
function __autoload($classname) {
|
// Auto load cookie value to session
|
||||||
global $dir;
|
if (isset($_COOKIE['uname']) && isset($_COOKIE['token'])) {
|
||||||
$filename = "$dir/includes/". $classname .".class.php";
|
$user = new user($_COOKIE['uname']);
|
||||||
include_once($filename);
|
if ($_COOKIE['token'] == $user->getToken()) {
|
||||||
}
|
$_SESSION['uname'] = $_COOKIE['uname'];
|
||||||
|
$_SESSION['token'] = $user->getToken();
|
||||||
if ($_GET['action'] == "get") {
|
|
||||||
if ($_GET['type'] && $_GET['uname']) {
|
|
||||||
$user = new user($_GET['uname']);
|
|
||||||
if ($_GET['type'] == "skin") {
|
|
||||||
header('Content-Type: image/png');
|
|
||||||
echo $user->getBinaryTexture('skin');
|
|
||||||
} else if ($_GET['type'] == "cape") {
|
|
||||||
header('Content-Type: image/png');
|
|
||||||
echo $user->getBinaryTexture('cape');
|
|
||||||
} else {
|
|
||||||
header('Content-type: application/json');
|
|
||||||
echo $user->getJsonProfile();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
utils::raise(1, 'Illegal parameters.');
|
|
||||||
}
|
}
|
||||||
} else {
|
} ?>
|
||||||
session_start();
|
|
||||||
if (utils::getValue('uname', $_COOKIE) && utils::getValue('token', $_COOKIE)) {
|
|
||||||
$user = new user($_COOKIE['uname']);
|
|
||||||
if ($_COOKIE['token'] == $user -> getToken()) {
|
|
||||||
$_SESSION['uname'] = $_COOKIE['uname'];
|
|
||||||
$_SESSION['token'] = $user -> getToken();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 越写越像 MVC 。。。路由了以后就不得不视图层分离了啊。。等有时间用模板吧
|
|
||||||
*
|
|
||||||
* 这个入口也是神 TM 丑(扶额
|
|
||||||
*/
|
|
||||||
?>
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
@ -68,8 +40,7 @@ if ($_GET['action'] == "get") {
|
|||||||
<a href="#" class="pure-menu-link">Home</a>
|
<a href="#" class="pure-menu-link">Home</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="pure-menu-item">
|
<li class="pure-menu-item">
|
||||||
<?php
|
<?php if ($uname = utils::getValue('uname', $_SESSION)) { ?>
|
||||||
if ($uname = utils::getValue('uname', $_SESSION)) { ?>
|
|
||||||
<a href="./user/index.php" class="pure-menu-link" style="color: #5e5e5e">Welcome, <?php echo $uname; ?></a>
|
<a href="./user/index.php" class="pure-menu-link" style="color: #5e5e5e">Welcome, <?php echo $uname; ?></a>
|
||||||
<?php } else { ?>
|
<?php } else { ?>
|
||||||
<a id="login" href="javascript:;" class="pure-button pure-button-primary">Sign In</a>
|
<a id="login" href="javascript:;" class="pure-button pure-button-primary">Sign In</a>
|
||||||
@ -144,5 +115,3 @@ if ($msg = utils::getValue('msg', $_GET)) { ?>
|
|||||||
<?php } ?>
|
<?php } ?>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
<?php } ?>
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user