fixed support for sub directory

This commit is contained in:
printempw 2016-09-10 17:52:33 +08:00
parent 11d08b9545
commit 5e3e1e64d4
7 changed files with 66 additions and 41 deletions

View File

@ -260,7 +260,8 @@ class AdminController extends Controller
} elseif ($action == "owner") {
$this->validate($request, [
'tid' => 'required|integer'
'pid' => 'required|integer',
'uid' => 'required|integer'
]);
$user = new User($request->input('uid'));

View File

@ -25,6 +25,7 @@ class Kernel extends HttpKernel
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\App\Http\Middleware\RemoveSlashMiddleware::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,

View File

@ -0,0 +1,21 @@
<?php
namespace App\Http\Middleware;
class RemoveSlashMiddleware
{
public function handle($request, \Closure $next)
{
if (substr($request->getRequestUri(), -1) == "/") {
$base_url = $request->getBaseUrl();
// try to remove slash at the end of current url
$new_url = substr($request->getRequestUri(), 0, -1);
if ($new_url != $base_url) {
return redirect(str_replace($base_url, '', $new_url));
}
}
return $next($request);
}
}

View File

@ -2,7 +2,7 @@
* @Author: printempw
* @Date: 2016-07-22 14:02:44
* @Last Modified by: printempw
* @Last Modified time: 2016-08-06 18:49:18
* @Last Modified time: 2016-09-10 17:04:04
*/
'use strict';
@ -23,7 +23,7 @@ $('#layout-skins-list [data-skin]').click(function(e) {
$('#color-submit').click(function() {
$.ajax({
type: "POST",
url: "../admin/users?action=color",
url: "./users?action=color",
dataType: "json",
data: { "color_scheme": current_skin },
success: function(json) {
@ -56,7 +56,7 @@ function changeUserEmail(uid) {
$.ajax({
type: "POST",
url: "../admin/users?action=email",
url: "./users?action=email",
dataType: "json",
data: { 'uid': uid, 'email': email },
success: function(json) {
@ -78,7 +78,7 @@ function changeUserNickName(uid) {
$.ajax({
type: "POST",
url: "../admin/users?action=nickname",
url: "./users?action=nickname",
dataType: "json",
data: { 'uid': uid, 'nickname': nickname },
success: function(json) {
@ -100,7 +100,7 @@ function changeUserPwd(uid) {
$.ajax({
type: "POST",
url: "../admin/users?action=password",
url: "./users?action=password",
dataType: "json",
data: { 'uid': uid, 'password': password },
success: function(json) {
@ -116,7 +116,7 @@ function changeUserPwd(uid) {
function changeUserScore(uid, score) {
$.ajax({
type: "POST",
url: "../admin/users?action=score",
url: "./users?action=score",
dataType: "json",
data: { 'uid': uid, 'score': score },
success: function(json) {
@ -134,7 +134,7 @@ function changeUserScore(uid, score) {
function changeBanStatus(uid) {
$.ajax({
type: "POST",
url: "../admin/users?action=ban",
url: "./users?action=ban",
dataType: "json",
data: { 'uid': uid },
success: function(json) {
@ -157,7 +157,7 @@ function changeBanStatus(uid) {
function changeAdminStatus(uid) {
$.ajax({
type: "POST",
url: "../admin/users?action=admin",
url: "./users?action=admin",
dataType: "json",
data: { 'uid': uid },
success: function(json) {
@ -182,7 +182,7 @@ function deleteUserAccount(uid) {
$.ajax({
type: "POST",
url: "../admin/users?action=delete",
url: "./users?action=delete",
dataType: "json",
data: { 'uid': uid },
success: function(json) {
@ -207,7 +207,7 @@ $('.score').on('keypress', function(event){
$('body').on('change', '#preference', function() {
$.ajax({
type: "POST",
url: "../admin/players?action=preference",
url: "./players?action=preference",
dataType: "json",
data: { 'pid': $(this).parent().parent().attr('id'), 'preference': $(this).val() },
success: function(json) {
@ -252,7 +252,7 @@ function ajaxChangeTexture(pid) {
$.ajax({
type: "POST",
url: "../admin/players?action=texture",
url: "./players?action=texture",
dataType: "json",
data: { 'pid': pid, 'model': model, 'tid': tid },
success: function(json) {
@ -275,7 +275,7 @@ function changeOwner(pid) {
$.ajax({
type: "POST",
url: "../admin/players?action=owner",
url: "./players?action=owner",
dataType: "json",
data: { 'pid': pid, 'uid': uid },
success: function(json) {
@ -295,7 +295,7 @@ function deletePlayer(pid) {
$.ajax({
type: "POST",
url: "../admin/players?action=delete",
url: "./players?action=delete",
dataType: "json",
data: { 'pid': pid },
success: function(json) {

View File

@ -2,7 +2,7 @@
* @Author: printempw
* @Date: 2016-07-19 10:46:38
* @Last Modified by: printempw
* @Last Modified time: 2016-09-03 21:48:17
* @Last Modified time: 2016-09-10 17:07:04
*/
'use strict';
@ -36,7 +36,7 @@ $('#type-skin').on('ifToggled', function() {
});
function addToCloset(tid) {
$.getJSON('../skinlib/info/'+tid, function(json) {
$.getJSON('./info/'+tid, function(json) {
swal({
title: '给你的皮肤起个名字吧~',
inputValue: json.name,
@ -212,7 +212,7 @@ function upload() {
} else {
$.ajax({
type: "POST",
url: "../skinlib/upload",
url: "./upload",
contentType: false,
dataType: "json",
data: form_data,
@ -264,7 +264,7 @@ function changeTextureName(tid) {
}).then(function(new_name) {
$.ajax({
type: "POST",
url: "../skinlib/rename",
url: "./rename",
dataType: "json",
data: { 'tid': tid, 'new_name': new_name },
success: function(json) {
@ -295,7 +295,7 @@ $('.private-label').click(function() {
function changePrivacy(tid) {
$.ajax({
type: "POST",
url: "../skinlib/privacy/" + tid,
url: "./privacy/" + tid,
dataType: "json",
success: function(json) {
if (json.errno == 0) {
@ -320,7 +320,7 @@ function deleteTexture(tid) {
}).then(function() {
$.ajax({
type: "POST",
url: "../skinlib/delete",
url: "./delete",
dataType: "json",
data: { 'tid': tid },
success: function(json) {

View File

@ -2,7 +2,7 @@
* @Author: printempw
* @Date: 2016-07-16 10:02:24
* @Last Modified by: printempw
* @Last Modified time: 2016-08-26 13:21:23
* @Last Modified time: 2016-09-10 17:07:55
*/
'use strict';
@ -605,7 +605,7 @@ $('#version-select').change(showConfig);
function sign() {
$.ajax({
type: "POST",
url: "../user/sign",
url: "./sign",
dataType: "json",
success: function(json) {
if (json.errno == 0) {

View File

@ -2,7 +2,7 @@
* @Author: printempw
* @Date: 2016-07-16 09:02:32
* @Last Modified by: printempw
* @Last Modified time: 2016-08-23 17:58:40
* @Last Modified time: 2016-09-10 17:10:08
*/
function showModal(msg, title, type, callback) {
@ -49,27 +49,29 @@ function logout(with_out_confirm, callback) {
confirmButtonText: '确定',
cancelButtonText: '取消'
}).then(function() {
$.ajax({
type: "POST",
url: "../auth/logout",
dataType: "json",
success: function(json) {
swal({
type: 'success',
html: json.msg
});
window.setTimeout('window.location = "../"', 1000);
}
do_logout(function(json) {
swal({
type: 'success',
html: json.msg
});
window.setTimeout('window.location = "../"', 1000);
});
});
} else {
$.ajax({
type: "POST",
url: "../auth/logout",
dataType: "json",
success: function(json) {
if (callback) callback(json);
}
do_logout(function(json) {
if (callback) callback(json);
});
}
}
function do_logout(callback) {
$.ajax({
type: "POST",
url: "../auth/logout",
dataType: "json",
success: function(json) {
if (callback) callback(json);
},
error: showAjaxError
});
}