initialize for laravel

This commit is contained in:
printempw 2016-08-28 10:05:21 +08:00
parent e4bd07f86a
commit 1e7030236e
106 changed files with 5970 additions and 2201 deletions

2
.gitattributes vendored Normal file
View File

@ -0,0 +1,2 @@
* text=auto
*.tpl linguist-language=php

View File

@ -0,0 +1,33 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Foundation\Inspiring;
class Inspire extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'inspire';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Display an inspiring quote';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$this->comment(PHP_EOL.Inspiring::quote().PHP_EOL);
}
}

30
app/Console/Kernel.php Normal file
View File

@ -0,0 +1,30 @@
<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
Commands\Inspire::class,
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
$schedule->command('inspire')
->hourly();
}
}

View File

@ -1,10 +0,0 @@
<?php
namespace App\Controllers;
/**
* 突然发现这个基类卵用没有 (;´Д`)
*/
class BaseController
{
}

View File

@ -1,78 +0,0 @@
<?php
namespace Blessing;
use \Illuminate\Database\Capsule\Manager as Capsule;
use \Blessing\Database\Schema;
use \App\Exceptions\E;
class Config
{
public static function getDbConfig()
{
return require BASE_DIR.'/config/database.php';
}
public static function getViewConfig()
{
return require BASE_DIR."/config/view.php";
}
public static function checkPHPVersion()
{
if (version_compare(PHP_VERSION, '5.5.9', '<'))
throw new E('Blessing Skin Server v3 要求 PHP 版本不低于 5.5.9,当前版本为 '.phpversion(), -1, true);
}
/**
* Check database config
*
* @param array $config
* @return \MySQLi
*/
public static function checkDbConfig(Array $config)
{
// use error control to hide shitty connect warnings
@$conn = new \mysqli($config['host'], $config['username'], $config['password'], $config['database'], $config['port']);
if ($conn->connect_error)
throw new E("无法连接至 MySQL 服务器,请检查你的配置:".$conn->connect_error, $conn->connect_errno, true);
$conn->query("SET names 'utf8'");
return true;
}
public static function checkTableExist()
{
$tables = ['users', 'closets', 'players', 'textures', 'options'];
foreach ($tables as $table_name) {
// prefix will be added automatically
if (!Schema::hasTable($table_name)) {
return false;
}
}
return true;
}
public static function checkCache()
{
$view_config = self::getViewConfig();
if (!is_dir($view_config['cache_path'])) {
if (!mkdir($view_config['cache_path']))
throw new E('缓存文件夹创建失败,请确认目录权限是否正确', -1);
}
return true;
}
public static function checkDotEnvExist()
{
if (!file_exists(BASE_DIR."/.env"))
exit('错误:.env 配置文件不存在');
return true;
}
}

View File

@ -1,30 +0,0 @@
<?php
namespace Blessing\Database;
use Blessing\Storage;
class Migration
{
/**
* Create tables, prefix will be added automatically
*
* @return void
*/
public static function creatTables()
{
require BASE_DIR."/setup/tables.php";
}
public static function __callStatic($method, $args)
{
if (strpos($method, 'import') !== false) {
$filename = BASE_DIR."/setup/migrations/".snake_case($method).".php";
if (Storage::exists($filename)) {
return require $filename;
}
}
throw new \InvalidArgumentException('Non-existent migration');
}
}

View File

@ -1,24 +0,0 @@
<?php
namespace Blessing\Database;
use Illuminate\Database\Capsule\Manager as Capsule;
class Schema
{
/**
* Facade for Illuminate\Database\Schema
*
* @param string $method
* @param array $args
* @return mixed
*/
public static function __callStatic($method, $args)
{
// the instance of capusle has been set as global
$instance = Capsule::schema();
return call_user_func_array([$instance, $method], $args);
}
}

View File

@ -1,21 +0,0 @@
<?php
namespace Blessing\Facades;
use \Illuminate\Support\Facades\Facade;
/**
* @see \Blessing\Foundation\Application
*/
class App extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'app';
}
}

View File

@ -1,69 +0,0 @@
<?php
namespace Blessing\Foundation;
use \Illuminate\Container\Container;
use \Blessing\Config;
class Application extends Container
{
private $version = null;
/**
* Start Application
*
* @return void
*/
public function run()
{
$this->boot();
// Register Error Handler
Boot::registerErrorHandler();
// Redirect if not installed
Boot::checkInstallation();
// Start Route Dispatching
Boot::bootRouter();
}
public function boot()
{
// Load Aliases
Boot::loadServices();
// Check Runtime Environment
Boot::checkRuntimeEnv();
// Register Facades
Boot::registerFacades($this);
// Set Default Timezone to UTC+8
Boot::setTimeZone();
// Load dotenv Configuration
Boot::loadDotEnv(BASE_DIR);
// Boot Eloquent ORM
Boot::bootEloquent(Config::getDbConfig());
// Start Session
Boot::startSession();
}
/**
* Get the version number of the application.
*
* @return string
*/
public function version()
{
if (is_null($this->version)) {
$config = require BASE_DIR."/config/app.php";
$this->version = $config['version'];
}
return $this->version;
}
}

View File

@ -1,136 +0,0 @@
<?php
namespace Blessing\Foundation;
use \Illuminate\Database\Capsule\Manager as Capsule;
use \Illuminate\Support\Facades\Facade;
use \Pecee\SimpleRouter\SimpleRouter as Router;
use \App\Exceptions\ExceptionHandler;
use \App\Exceptions\E;
use \Blessing\Config;
use \Blessing\Option;
use \Blessing\Http;
class Boot
{
public static function loadDotEnv($dir)
{
if (Config::checkDotEnvExist()) {
$dotenv = new \Dotenv\Dotenv($dir);
$dotenv->load();
}
}
public static function registerFacades(Application $app)
{
Facade::setFacadeApplication($app);
$app->instance('app', $app);
$app->bind('manager', \App\Services\PluginManager::class);
$app->bind('db', \Blessing\Database\Database::class);
}
public static function setTimeZone($timezone = 'Asia/Shanghai')
{
// set default time zone, UTC+8 for default
date_default_timezone_set($timezone);
}
public static function checkRuntimeEnv()
{
Config::checkPHPVersion();
Config::checkCache();
}
public static function checkInstallation($redirect_to = '../setup/index.php')
{
if (!Config::checkTableExist()) {
Http::redirect($redirect_to);
}
if (!is_dir(BASE_DIR.'/textures/')) {
throw new E("检测到 `textures` 文件夹已被删除,请重新运行 <a href='./setup'>安装程序</a>,或者手动放置一个。", -1, true);
}
if (\App::version() != Option::get('version', '')) {
Http::redirect(Http::getBaseUrl().'/setup/update.php');
exit;
}
return true;
}
public static function loadServices()
{
// Set Aliases for App\Services
$services = require BASE_DIR.'/config/services.php';
foreach ($services as $facade => $class) {
class_alias($class, $facade);
}
}
/**
* Register error handler
*
* @param object $handler Push specified whoops handler
* @return void
*/
public static function registerErrorHandler($handler = null)
{
if (!is_null($handler) && $handler instanceof \Whoops\Handler\HandlerInterface) {
$whoops = new \Whoops\Run;
$whoops->pushHandler($handler);
$whoops->register();
return;
}
if ($_ENV['APP_DEBUG'] !== "false") {
// whoops: php errors for cool kids
$whoops = new \Whoops\Run;
$handler = ($_SERVER['REQUEST_METHOD'] == "GET") ?
new \Whoops\Handler\PrettyPageHandler : new \Whoops\Handler\PlainTextHandler;
$whoops->pushHandler($handler);
$whoops->register();
} else {
// Register custom error handler
ExceptionHandler::register();
}
}
public static function bootEloquent(Array $config)
{
if (Config::checkDbConfig($config)) {
$capsule = new Capsule;
$capsule->addConnection($config);
$capsule->setAsGlobal();
$capsule->bootEloquent();
}
}
public static function startSession()
{
session_start();
}
public static function bootRouter()
{
/**
* URL ends with slash will cause many reference problems
*/
if (Http::getUri() != "/" && substr(Http::getUri(), -1) == "/") {
$url = substr(Http::getCurrentUrl(), 0, -1);
Http::redirect($url);
}
// Require Route Config
Router::group([
'exceptionHandler' => 'App\Exceptions\RouterExceptionHandler'
], function() {
require BASE_DIR.'/config/routes.php';
});
// Start Route Dispatching
Router::start('App\Controllers');
}
}

View File

@ -1,75 +0,0 @@
<?php
namespace Blessing;
use PHPMailer;
class Mail
{
/**
* Instance of PHPMailer
* @var object
*/
private $mail;
public function __construct()
{
$mail = new PHPMailer();
// $mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = $_ENV['MAIL_HOST']; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = $_ENV['MAIL_USERNAME']; // SMTP username
$mail->Password = $_ENV['MAIL_PASSWORD']; // SMTP password
$mail->SMTPSecure = $_ENV['MAIL_ENCRYPTION']; // Enable TLS encryption, `ssl` also accepted
$mail->Port = $_ENV['MAIL_PORT']; // TCP port to connect to
$mail->CharSet = 'UTF-8';
$this->mail = $mail;
}
/**
* Set sender name
*
* @param string $name [description]
*/
public function from($name)
{
$this->mail->setFrom($_ENV['MAIL_USERNAME'], $name);
return $this;
}
public function to($address)
{
$this->mail->addAddress($address);
return $this;
}
public function subject($subject)
{
$this->mail->Subject = $subject;
return $this;
}
public function getLastError()
{
return $this->mailer->ErrorInfo;
}
public function content($content)
{
$this->mail->isHTML(true);
$this->mail->Body = $content;
return $this;
}
/**
* Send a mail
*
* @return boolean
*/
public function send()
{
return $this->mail->send();
}
}

View File

@ -1,165 +0,0 @@
<?php
namespace Blessing;
class Storage
{
/**
* Read a file and return bin data
*
* @param string $filename
* @return string|bool
*/
public static function get($filename)
{
$result = file_get_contents($filename, 'r');
if (false === $result) {
throw new \Exception("Failed to read $filename.");
}
return $result;
}
public static function put($filename, $data)
{
return file_put_contents($filename, $data);
}
public static function exists($filename)
{
return file_exists($filename);
}
public static function hash($filename, $type = 'sha256')
{
return hash_file('sha256', $filename);
}
public static function rename($fname, $new_fname)
{
if (false === rename($fname, $new_fname)) {
throw new \Exception("Failed to rename $fname to $new_fname.");
}
return $new_fname;
}
public static function size($filename)
{
if (self::exists($filename)) {
return filesize($filename);
} else {
return 0;
}
}
/**
* Remove a file
*
* @param $filename
* @return $bool
*/
public static function remove($filename)
{
if (self::exists($filename)) {
return unlink($filename);
}
}
public static function removeDir($dir)
{
$resource = opendir($dir);
$size = 0;
while($filename = @readdir($resource)) {
if ($filename != "." && $filename != "..") {
$path = $dir.$filename;
if (is_dir($path)) {
// recursion
self::removeDir($path."/");
} else {
unlink($path);
}
}
}
closedir($resource);
return rmdir($dir);
}
/**
* Recursively count the size of specified directory
*
* @param string $dir
* @return int, total size in bytes
*/
public static function getDirSize($dir)
{
$resource = opendir($dir);
$size = 0;
while($filename = @readdir($resource)) {
if ($filename != "." && $filename != "..") {
$path = $dir.$filename;
if (is_dir($path)) {
// recursion
$size += self::getDirSize($path);
} else if (is_file($path)) {
$size += filesize($path);
}
}
}
closedir($resource);
return $size;
}
/**
* Recursively count files of specified directory
*
* @param string $dir
* @param $file_num
* @return int, total size in bytes
*/
public static function getFileNum($dir, $file_num = 0)
{
$resource = opendir($dir);
while($filename = readdir($resource)) {
if ($filename != "." && $filename != "..") {
$path = $dir.$filename;
if (is_dir($path)) {
// recursion
$file_num = self::getFileNum($path, $file_num);
} else {
$file_num++;
}
}
}
closedir($resource);
return $file_num;
}
/**
* Copy directory recursively
*
* @param string $source
* @param string $dest
* @return bool
*/
public static function copyDir($source, $dest)
{
if(!is_dir($source))
return false;
if(!is_dir($dest))
mkdir($dest, 0777, true);
$handle = dir($source);
while($entry = $handle->read()) {
if ($entry != "." && $entry != "..") {
if (is_dir($source.'/'.$entry)) {
// recursion
self::copyDir($source.'/'.$entry, $dest.'/'.$entry);
} else {
@copy($source.'/'.$entry, $dest.'/'.$entry);
}
}
}
return true;
}
}

8
app/Events/Event.php Normal file
View File

@ -0,0 +1,8 @@
<?php
namespace App\Events;
abstract class Event
{
//
}

View File

@ -1,70 +0,0 @@
<?php
namespace App\Exceptions;
class ExceptionHandler
{
public static function register()
{
if ($_SERVER['REQUEST_METHOD'] == "GET") {
// use closure to pass parameters
set_error_handler(function ($errno, $errstr, $errfile, $errline) {
self::handler(
new \ErrorException($errstr, $errno, $errno, $errfile, $errline)
);
});
}
}
public static function handler($e)
{
// do nothing if error reporting is turned off or suppressed with @
if (error_reporting() === 0) {
return;
}
switch ($e->getCode()) {
case E_PARSE:
case E_ERROR:
case E_CORE_ERROR:
case E_COMPILE_ERROR:
case E_USER_ERROR:
$level = 'Fatal Error';
break;
case E_WARNING:
case E_USER_WARNING:
case E_COMPILE_WARNING:
case E_RECOVERABLE_ERROR:
$level = 'Warning';
break;
case E_NOTICE:
case E_USER_NOTICE:
$level = 'Notice';
break;
case E_STRICT:
$level = 'Strict';
break;
case E_DEPRECATED:
case E_USER_DEPRECATED:
$level = 'Deprecated';
break;
default:
$level = 'Type Unknown';
break;
}
echo \View::make('errors.exception')->with('level', $level)
->with('message', $e->getMessage())
->with('file', $e->getFile())
->with('line', $e->getLine());
exit;
}
}

View File

@ -0,0 +1,75 @@
<?php
namespace App\Exceptions;
use Exception;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
class Handler extends ExceptionHandler
{
/**
* A list of the exception types that should not be reported.
*
* @var array
*/
protected $dontReport = [
HttpException::class,
ModelNotFoundException::class,
];
/**
* Report or log an exception.
*
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
* @param \Exception $e
* @return void
*/
public function report(Exception $e)
{
return parent::report($e);
}
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $e)
{
if ($e instanceof ModelNotFoundException) {
$e = new NotFoundHttpException($e->getMessage(), $e);
}
// if (config('app.debug')) {
// return $this->renderExceptionWithWhoops($e);
// }
return parent::render($request, $e);
}
/**
* Render an exception using Whoops.
*
* @param \Exception $e
* @return \Illuminate\Http\Response
*/
protected function renderExceptionWithWhoops(Exception $e)
{
$whoops = new \Whoops\Run;
$handler = ($_SERVER['REQUEST_METHOD'] == "GET") ?
new \Whoops\Handler\PrettyPageHandler : new \Whoops\Handler\PlainTextHandler;
$whoops->pushHandler($handler);
return new \Illuminate\Http\Response(
$whoops->handleException($e),
$e->getStatusCode(),
$e->getHeaders()
);
}
}

View File

@ -1,22 +0,0 @@
<?php
namespace App\Exceptions;
use Pecee\Http\Request;
use Pecee\SimpleRouter\RouterEntry;
use Pecee\Handler\IExceptionHandler;
class RouterExceptionHandler implements IExceptionHandler
{
public function handleError(Request $request, RouterEntry $router = null, \Exception $error)
{
if ($error->getCode() === 404) {
\Http::abort(404, $error->getMessage(), ($_SERVER['REQUEST_METHOD'] == "POST"));
} else {
throw $error;
}
}
}

View File

@ -1,7 +1,8 @@
<?php
namespace App\Controllers;
namespace App\Http\Controllers;
use Illuminate\Routing\Controller as BaseController;
use App\Models\User;
use App\Models\UserModel;
use App\Models\Player;
@ -17,22 +18,22 @@ class AdminController extends BaseController
public function index()
{
View::show('admin.index');
return view('admin.index');
}
public function customize()
{
View::show('admin.customize');
return view('admin.customize');
}
public function score()
{
View::show('admin.score');
return view('admin.score');
}
public function options()
{
View::show('admin.options');
return view('admin.options');
}
public function update()
@ -53,9 +54,9 @@ class AdminController extends BaseController
]);
}
} elseif ($action == "download") {
View::show('admin.download');
return view('admin.download');
} else {
View::show('admin.update');
return view('admin.update');
}
}
@ -131,7 +132,7 @@ class AdminController extends BaseController
$user = new User(Utils::getValue('uid', $_POST));
// current user
$cur_user = new User($_SESSION['uid']);
$cur_user = new User(session('uid'));
if (!$user->is_registered)
throw new E('用户不存在', 1);

View File

@ -1,7 +1,8 @@
<?php
namespace App\Controllers;
namespace App\Http\Controllers;
use Illuminate\Routing\Controller as BaseController;
use App\Models\User;
use App\Models\UserModel;
use App\Exceptions\E;
@ -11,23 +12,24 @@ use View;
use Utils;
use Option;
use Http;
use Session;
class AuthController extends BaseController
{
public function login()
{
View::show('auth.login');
return view('auth.login');
}
public function handleLogin()
{
// instantiate user
$user = ($_SESSION['auth_type'] == 'email') ?
$user = (session('auth_type') == 'email') ?
new User(null, ['email' => $_POST['email']]) :
new User(null, ['username' => $_POST['username']]);
if (Utils::getValue('login_fails', $_SESSION) > 3) {
if (strtolower(Utils::getValue('captcha', $_POST)) != strtolower($_SESSION['phrase']))
if (session('login_fails', 0) > 3) {
if (strtolower(Utils::getValue('captcha', $_POST)) != strtolower(session('phrase')))
View::json('验证码填写错误', 1);
}
@ -35,10 +37,10 @@ class AuthController extends BaseController
View::json('用户不存在哦', 2);
} else {
if ($user->checkPasswd($_POST['password'])) {
unset($_SESSION['login_fails']);
session()->forget('login_fails');
$_SESSION['uid'] = $user->uid;
$_SESSION['token'] = $user->getToken();
Session::put('uid' , $user->uid);
Session::put('token', $user->getToken());
$time = $_POST['keep'] == true ? 86400 : 3600;
@ -51,13 +53,13 @@ class AuthController extends BaseController
'token' => $user->getToken()
]);
} else {
$_SESSION['login_fails'] = isset($_SESSION['login_fails']) ?
$_SESSION['login_fails'] + 1 : 1;
$fails = session()->has('login_fails') ? session('login_fails') + 1 : 1;
Session::put('login_fails', $fails);
View::json([
'errno' => 1,
'msg' => '邮箱或密码不对哦~',
'login_fails' => $_SESSION['login_fails']
'login_fails' => session('login_fails')
]);
}
}
@ -65,11 +67,12 @@ class AuthController extends BaseController
public function logout()
{
if (isset($_SESSION['token'])) {
if (Session::has('token')) {
setcookie('uid', '', time() - 3600, '/');
setcookie('token', '', time() - 3600, '/');
session_destroy();
Session::flush();
Session::save();
View::json('登出成功~', 0);
} else {
@ -80,7 +83,7 @@ class AuthController extends BaseController
public function register()
{
if (Option::get('user_can_register') == 1) {
View::show('auth.register');
return view('auth.register');
} else {
throw new E('残念。。本皮肤站已经关闭注册咯 QAQ', 7, true);
}
@ -88,7 +91,7 @@ class AuthController extends BaseController
public function handleRegister()
{
if (strtolower(Utils::getValue('captcha', $_POST)) != strtolower($_SESSION['phrase']))
if (strtolower(Utils::getValue('captcha', $_POST)) != strtolower(session('phrase')))
View::json('验证码填写错误', 1);
$user = new User(null, ['email' => $_POST['email']]);
@ -132,7 +135,7 @@ class AuthController extends BaseController
public function forgot()
{
if ($_ENV['MAIL_HOST'] != "") {
View::show('auth.forgot');
return view('auth.forgot');
} else {
throw new E('本站已关闭重置密码功能', 8, true);
}
@ -140,13 +143,13 @@ class AuthController extends BaseController
public function handleForgot()
{
if (strtolower(Utils::getValue('captcha', $_POST)) != strtolower($_SESSION['phrase']))
if (strtolower(Utils::getValue('captcha', $_POST)) != strtolower(session('phrase')))
View::json('验证码填写错误', 1);
if ($_ENV['MAIL_HOST'] == "")
View::json('本站已关闭重置密码功能', 1);
if (isset($_SESSION['last_mail_time']) && (time() - $_SESSION['last_mail_time']) < 60)
if (session()->has('last_mail_time') && (time() - session('last_mail_time')) < 60)
View::json('你邮件发送得太频繁啦,过 60 秒后再点发送吧', 1);
$user = new User(null, ['email' => $_POST['email']]);
@ -170,7 +173,7 @@ class AuthController extends BaseController
if (!$mail->send()) {
View::json('邮件发送失败,详细信息:'.$mail->getLastError(), 2);
} else {
$_SESSION['last_mail_time'] = time();
Session::put('last_mail_time', time());
View::json('邮件已发送,一小时内有效,请注意查收.', 0);
}
@ -220,7 +223,7 @@ class AuthController extends BaseController
{
$builder = new \Gregwar\Captcha\CaptchaBuilder;
$builder->build($width = 100, $height = 34);
$_SESSION['phrase'] = $builder->getPhrase();
Session::put('phrase', $builder->getPhrase());
header('Content-type: image/jpeg');
$builder->output();
}

View File

@ -1,7 +1,8 @@
<?php
namespace App\Controllers;
namespace App\Http\Controllers;
use Illuminate\Routing\Controller as BaseController;
use App\Models\User;
use App\Models\Texture;
use App\Models\Closet;
@ -16,7 +17,7 @@ class ClosetController extends BaseController
public function __construct()
{
$this->closet = new Closet($_SESSION['uid']);
$this->closet = new Closet(session('uid'));
}
public function index()
@ -33,7 +34,7 @@ class ClosetController extends BaseController
->with('page', $page)
->with('category', $category)
->with('total_pages', $total_pages)
->with('user', (new User($_SESSION['uid'])))
->with('user', (new User(session('uid'))))
->render();
}

View File

@ -0,0 +1,13 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
abstract class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
}

View File

@ -1,8 +1,10 @@
<?php
namespace App\Controllers;
namespace App\Http\Controllers;
use Illuminate\Routing\Controller as BaseController;
use App\Models\User;
use Session;
class HomeController extends BaseController
{
@ -13,8 +15,8 @@ class HomeController extends BaseController
$user = new User($_COOKIE['uid']);
if ($_COOKIE['token'] == $user->getToken() && $user->getPermission() != "-1") {
$_SESSION['uid'] = $_COOKIE['uid'];
$_SESSION['token'] = $_COOKIE['token'];
Session::put('uid' , $_COOKIE['uid']);
Session::put('token', $_COOKIE['token']);
} else {
// delete cookies
setcookie("uid", "", time() - 3600, '/');
@ -22,7 +24,7 @@ class HomeController extends BaseController
}
}
$user = isset($_SESSION['uid']) ? new User($_SESSION['uid']) : null;
$user = session()->has('uid') ? new User(session('uid')) : null;
echo \View::make('index')->with('user', $user);
}

View File

@ -1,7 +1,8 @@
<?php
namespace App\Controllers;
namespace App\Http\Controllers;
use Illuminate\Routing\Controller as BaseController;
use App\Models\User;
use App\Models\Player;
use App\Models\PlayerModel;
@ -20,7 +21,7 @@ class PlayerController extends BaseController
public function __construct()
{
$this->user = new User($_SESSION['uid']);
$this->user = new User(session('uid'));
if (isset($_POST['pid'])) {
$this->player = new Player($_POST['pid']);
@ -31,7 +32,7 @@ class PlayerController extends BaseController
public function index()
{
echo View::make('user.player')->with('players', $this->user->getPlayers()->toArray())->with('user', $this->user);
return View::make('user.player')->with('players', $this->user->getPlayers()->toArray())->with('user', $this->user);
}
public function add()

View File

@ -1,7 +1,8 @@
<?php
namespace App\Controllers;
namespace App\Http\Controllers;
use Illuminate\Routing\Controller as BaseController;
use App\Models\User;
use App\Models\Texture;
use App\Exceptions\E;
@ -17,7 +18,7 @@ class SkinlibController extends BaseController
function __construct()
{
$this->user = isset($_SESSION['uid']) ? new User($_SESSION['uid']) : null;
$this->user = session()->has('uid') ? new User(session('uid')) : null;
}
public function index()

View File

@ -1,7 +1,8 @@
<?php
namespace App\Controllers;
namespace App\Http\Controllers;
use Illuminate\Routing\Controller as BaseController;
use App\Models\User;
use App\Models\Player;
use App\Models\Texture;

View File

@ -1,7 +1,8 @@
<?php
namespace App\Controllers;
namespace App\Http\Controllers;
use Illuminate\Routing\Controller as BaseController;
use App\Models\User;
use App\Models\Texture;
use App\Exceptions\E;
@ -16,12 +17,12 @@ class UserController extends BaseController
function __construct()
{
$this->action = isset($_GET['action']) ? $_GET['action'] : "";
$this->user = new User($_SESSION['uid']);
$this->user = new User(session('uid'));
}
public function index()
{
echo View::make('user.index')->with('user', $this->user)->render();
return View::make('user.index')->with('user', $this->user)->render();
}
public function sign()
@ -40,7 +41,7 @@ class UserController extends BaseController
public function profile()
{
echo View::make('user.profile')->with('user', $this->user);
return View::make('user.profile')->with('user', $this->user);
}
public function handleProfile()
@ -92,7 +93,8 @@ class UserController extends BaseController
if ($this->user->delete()) {
setcookie('uid', '', time() - 3600, '/');
setcookie('token', '', time() - 3600, '/');
session_destroy();
Session::flush();
Session::save();
View::json('账号已被成功删除', 0);
}
@ -102,7 +104,7 @@ class UserController extends BaseController
public function config()
{
echo View::make('user.config')->with('user', $this->user);
return View::make('user.config')->with('user', $this->user);
}
public function setAvatar()
@ -113,7 +115,7 @@ class UserController extends BaseController
if ($result) {
if ($result->type == "cape") throw new E('披风可不能设置为头像哦~', 1);
if ((new User($_SESSION['uid']))->setAvatar($_POST['tid'])) {
if ((new User(session('uid')))->setAvatar($_POST['tid'])) {
View::json('设置成功!', 0);
}
} else {

53
app/Http/Kernel.php Normal file
View File

@ -0,0 +1,53 @@
<?php
namespace App\Http;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
class Kernel extends HttpKernel
{
/**
* The application's global HTTP middleware stack.
*
* These middleware are run during every request to your application.
*
* @var array
*/
protected $middleware = [
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
];
/**
* The application's route middleware groups.
*
* @var array
*/
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
//\App\Http\Middleware\VerifyCsrfToken::class,
],
'api' => [
'throttle:60,1',
],
];
/**
* The application's route middleware.
*
* These middleware may be assigned to groups or used individually.
*
* @var array
*/
protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'can' => \Illuminate\Foundation\Http\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
];
}

View File

@ -0,0 +1,17 @@
<?php
namespace App\Http\Middleware;
class CheckAdminMiddleware
{
public function handle($request, \Closure $next)
{
$user = (new CheckAuthenticated)->handle($request, $next, true);
if (!$user->is_admin) {
\Http::redirect('../user', '看起来你并不是管理员哦');
}
return $next($request);
}
}

View File

@ -1,35 +1,35 @@
<?php
namespace App\Middlewares;
namespace App\Http\Middleware;
use Pecee\Http\Middleware\IMiddleware;
use Pecee\Http\Request;
use App\Models\User;
use App\Models\UserModel;
use App\Exceptions\E;
use View;
use Http;
use Session;
class CheckLoggedInMiddleware implements IMiddleware
class CheckAuthenticated
{
public function handle(Request $request)
public function handle($request, \Closure $next, $return_user = false)
{
if (isset($_COOKIE['uid']) && isset($_COOKIE['token'])) {
$_SESSION['uid'] = $_COOKIE['uid'];
$_SESSION['token'] = $_COOKIE['token'];
Session::put('uid' , $_COOKIE['uid']);
Session::put('token', $_COOKIE['token']);
}
if (isset($_SESSION['uid'])) {
$user = new User($_SESSION['uid']);
if (session()->has('uid')) {
$user = new User(session('uid'));
if ($_SESSION['token'] != $user->getToken())
if (session('token') != $user->getToken())
Http::redirect('../auth/login', '无效的 token请重新登录~');
if ($user->getPermission() == "-1") {
// delete cookies
setcookie('uid', '', time() - 3600, '/');
setcookie('token', '', time() - 3600, '/');
session_destroy();
Session::flush();
Session::save();
throw new E('你已经被本站封禁啦,请联系管理员解决', 5, true);
}
@ -41,24 +41,29 @@ class CheckLoggedInMiddleware implements IMiddleware
if (UserModel::where('email', $_POST['email'])->get()->isEmpty()) {
$user->setEmail($_POST['email']);
// refresh token
$_SESSION['token'] = $user->getToken(true);
setcookie('token', $_SESSION['token'], time() + 3600, '/');
Session::put('token', $user->getToken(true));
setcookie('token', session('token'), time() + 3600, '/');
return $user;
} else {
echo View::make('auth.bind')->with('msg', '该邮箱已被占用');
return View::make('auth.bind')->with('msg', '该邮箱已被占用');
}
} else {
echo View::make('auth.bind')->with('msg', '邮箱格式错误');
return View::make('auth.bind')->with('msg', '邮箱格式错误');
}
exit;
}
View::show('auth.bind');
return view('auth.bind');
exit;
}
return $user;
if ($return_user)
return $user;
return $next($request);
} else {
Http::redirect('../auth/login', '非法访问,请先登录');
}
return $next($request);
}
}

View File

@ -1,14 +1,12 @@
<?php
namespace App\Middlewares;
namespace App\Http\Middleware;
use Pecee\Http\Middleware\IMiddleware;
use Pecee\Http\Request;
use App\Models\PlayerModel;
class CheckPlayerExistMiddleware implements IMiddleware
class CheckPlayerExistMiddleware
{
public function handle(Request $request)
public function handle($request, \Closure $next)
{
if (stripos($request->getUri(), '.json') != false) {
preg_match('/\/([^\/]*)\.json/', $request->getUri(), $matches);
@ -28,5 +26,7 @@ class CheckPlayerExistMiddleware implements IMiddleware
\Http::abort(404, '角色不存在');
}
return $next($request);
}
}

View File

@ -1,36 +1,35 @@
<?php
namespace App\Middlewares;
namespace App\Http\Middleware;
use \Pecee\Http\Middleware\IMiddleware;
use \Pecee\Http\Request;
use App\Exceptions\E;
use Validate;
use Utils;
use View;
use Session;
class CheckPostMiddleware implements IMiddleware
class CheckPostMiddleware
{
public function handle(Request $request)
public function handle($request, \Closure $next)
{
if (Utils::getValue('email', $_POST) != "") {
if (!Validate::email($_POST['email'])) {
View::json('邮箱或角色名格式错误', 3);
}
$_SESSION['auth_type'] = 'email';
Session::put('auth_type', 'email');
} elseif (Utils::getValue('username', $_POST) != "") {
if (!Validate::playerName($_POST['username'])) {
View::json('邮箱或角色名格式错误', 3);
}
$_SESSION['auth_type'] = 'username';
Session::put('auth_type', 'username');
} else {
View::json('无效的参数', 3);
}
if ($request->getUri() == "/auth/forgot") return true;
if ($request->getUri() == "/auth/forgot") return $next($request);
if (isset($_POST['password']) && $_POST['password'] != "") {
return true;
return $next($request);
} else {
View::json('密码不能为空哦', 2);
}

View File

@ -0,0 +1,17 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Cookie\Middleware\EncryptCookies as BaseEncrypter;
class EncryptCookies extends BaseEncrypter
{
/**
* The names of the cookies that should not be encrypted.
*
* @var array
*/
protected $except = [
//
];
}

View File

@ -0,0 +1,28 @@
<?php
namespace App\Http\Middleware;
use App\Models\User;
use Session;
class RedirectIfAuthenticated
{
public function handle($request, \Closure $next)
{
if (isset($_COOKIE['uid']) && isset($_COOKIE['token'])) {
Session::put('uid' , $_COOKIE['uid']);
Session::put('token', $_COOKIE['token']);
}
if (session()->has('uid')) {
if (session('token') != (new User(session('uid')))->getToken())
{
Session::put('msg', '无效的 token请重新登录~');
} else {
\Http::redirect('../user');
}
}
return $next($request);
}
}

View File

@ -0,0 +1,17 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;
class VerifyCsrfToken extends BaseVerifier
{
/**
* The URIs that should be excluded from CSRF verification.
*
* @var array
*/
protected $except = [
//
];
}

View File

@ -0,0 +1,10 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
abstract class Request extends FormRequest
{
//
}

View File

@ -1,15 +1,16 @@
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
use Pecee\SimpleRouter\SimpleRouter as Route;
Route::get('/', 'HomeController@index');
Route::get('/index.php', 'HomeController@index');
@ -18,7 +19,7 @@ Route::get('/index.php', 'HomeController@index');
*/
Route::group(['prefix' => 'auth'], function()
{
Route::group(['middleware' => 'App\Middlewares\RedirectIfLoggedInMiddleware'], function()
Route::group(['middleware' => 'App\Http\Middleware\RedirectIfAuthenticated'], function()
{
Route::get ('/login', 'AuthController@login');
Route::get ('/register', 'AuthController@register');
@ -26,10 +27,10 @@ Route::group(['prefix' => 'auth'], function()
Route::get ('/reset', 'AuthController@reset');
});
Route::all('/logout', 'AuthController@logout');
Route::all('/captcha', 'AuthController@captcha');
Route::any('/logout', 'AuthController@logout');
Route::any('/captcha', 'AuthController@captcha');
Route::group(['middleware' => 'App\Middlewares\CheckPostMiddleware'], function()
Route::group(['middleware' => 'App\Http\Middleware\CheckPostMiddleware'], function()
{
Route::post('/login', 'AuthController@handleLogin');
Route::post('/register', 'AuthController@handleRegister');
@ -42,10 +43,10 @@ Route::group(['prefix' => 'auth'], function()
/**
* User Center
*/
Route::group(['middleware' => 'App\Middlewares\CheckLoggedInMiddleware', 'prefix' => 'user'], function()
Route::group(['middleware' => 'App\Http\Middleware\CheckAuthenticated', 'prefix' => 'user'], function()
{
Route::all ('', 'UserController@index');
Route::all ('/sign', 'UserController@sign');
Route::any ('', 'UserController@index');
Route::any ('/sign', 'UserController@sign');
// Profile
Route::get ('/profile', 'UserController@profile');
@ -54,7 +55,7 @@ Route::group(['middleware' => 'App\Middlewares\CheckLoggedInMiddlewar
Route::get ('/config', 'UserController@config');
// Player
Route::all ('/player', 'PlayerController@index');
Route::any ('/player', 'PlayerController@index');
Route::post('/player/add', 'PlayerController@add');
Route::post('/player/show', 'PlayerController@show');
Route::post('/player/preference', 'PlayerController@setPreference');
@ -76,11 +77,11 @@ Route::group(['middleware' => 'App\Middlewares\CheckLoggedInMiddlewar
Route::group(['prefix' => 'skinlib'], function()
{
Route::get ('', 'SkinlibController@index');
Route::all ('/info/{tid}', 'SkinlibController@info');
Route::all ('/show', 'SkinlibController@show');
Route::all ('/search', 'SkinlibController@search');
Route::any ('/info/{tid}', 'SkinlibController@info');
Route::any ('/show', 'SkinlibController@show');
Route::any ('/search', 'SkinlibController@search');
Route::group(['middleware' => 'App\Middlewares\CheckLoggedInMiddleware'], function()
Route::group(['middleware' => 'App\Http\Middleware\CheckAuthenticated'], function()
{
Route::get ('/upload', 'SkinlibController@upload');
Route::post('/upload', 'SkinlibController@handleUpload');
@ -94,14 +95,14 @@ Route::group(['prefix' => 'skinlib'], function()
/**
* Admin Panel
*/
Route::group(['middleware' => 'App\Middlewares\CheckAdminMiddleware', 'prefix' => 'admin'], function()
Route::group(['middleware' => 'App\Http\Middleware\CheckAdminMiddleware', 'prefix' => 'admin'], function()
{
Route::get('/', 'AdminController@index');
Route::all('/customize', 'AdminController@customize');
Route::all('/score', 'AdminController@score');
Route::all('/options', 'AdminController@options');
Route::all('/update', 'AdminController@update');
Route::any('/customize', 'AdminController@customize');
Route::any('/score', 'AdminController@score');
Route::any('/options', 'AdminController@options');
Route::any('/update', 'AdminController@update');
Route::get('/users', 'AdminController@users');
Route::get('/players', 'AdminController@players');
@ -113,7 +114,7 @@ Route::group(['middleware' => 'App\Middlewares\CheckAdminMiddl
/**
* Resources
*/
Route::group(['middleware' => 'App\Middlewares\CheckPlayerExistMiddleware'], function()
Route::group(['middleware' => 'App\Http\Middleware\CheckPlayerExistMiddleware'], function()
{
// Fix for fucking chinese player names
if (Option::get('allow_chinese_playername')) {

View File

@ -1,18 +0,0 @@
<?php
namespace App\Middlewares;
use Pecee\Http\Middleware\IMiddleware;
use Pecee\Http\Request;
class CheckAdminMiddleware implements IMiddleware
{
public function handle(Request $request)
{
$user = (new CheckLoggedInMiddleware)->handle($request);
if (!$user->is_admin) {
\Http::redirect('../user', '看起来你并不是管理员哦');
}
}
}

View File

@ -1,27 +0,0 @@
<?php
namespace App\Middlewares;
use Pecee\Http\Middleware\IMiddleware;
use Pecee\Http\Request;
use App\Models\User;
class RedirectIfLoggedInMiddleware implements IMiddleware
{
public function handle(Request $request)
{
if (isset($_COOKIE['uid']) && isset($_COOKIE['token'])) {
$_SESSION['uid'] = $_COOKIE['uid'];
$_SESSION['token'] = $_COOKIE['token'];
}
if (isset($_SESSION['uid'])) {
if ($_SESSION['token'] != (new User($_SESSION['uid']))->getToken())
{
$_SESSION['msg'] = "无效的 token请重新登录~";
} else {
\Http::redirect('../user');
}
}
}
}

View File

@ -1,26 +0,0 @@
<?php
namespace App\Middlewares;
use \Pecee\Http\Middleware\IMiddleware;
use \Pecee\Http\Request;
class RemoveUrlSlashMiddleware implements IMiddleware
{
public function handle(Request $request)
{
/**
* URL ends with slash will cause many reference problems
* so I deal it globally in this middleware :)
*/
if ($_SERVER["REQUEST_URI"] != "/" && substr($_SERVER["REQUEST_URI"], -1) == "/")
{
$url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? "https://" : "http://";
$url .= $_SERVER["SERVER_NAME"];
$url .= ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]);
$url .= substr($_SERVER["REQUEST_URI"], 0, -1);
\Http::redirect($url);
}
}
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,28 @@
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
\View::addExtension('tpl', 'blade');
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
$this->app->singleton('database', \App\Services\Database\Database::class);
}
}

View File

@ -0,0 +1,33 @@
<?php
namespace App\Providers;
use Illuminate\Contracts\Events\Dispatcher as DispatcherContract;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
class EventServiceProvider extends ServiceProvider
{
/**
* The event listener mappings for the application.
*
* @var array
*/
protected $listen = [
'App\Events\SomeEvent' => [
'App\Listeners\EventListener',
],
];
/**
* Register any other events for your application.
*
* @param \Illuminate\Contracts\Events\Dispatcher $events
* @return void
*/
public function boot(DispatcherContract $events)
{
parent::boot($events);
//
}
}

View File

@ -0,0 +1,61 @@
<?php
namespace App\Providers;
use Illuminate\Routing\Router;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
class RouteServiceProvider extends ServiceProvider
{
/**
* This namespace is applied to your controller routes.
*
* In addition, it is set as the URL generator's root namespace.
*
* @var string
*/
protected $namespace = 'App\Http\Controllers';
/**
* Define your route model bindings, pattern filters, etc.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function boot(Router $router)
{
//
parent::boot($router);
}
/**
* Define the routes for the application.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function map(Router $router)
{
$this->mapWebRoutes($router);
//
}
/**
* Define the "web" routes for the application.
*
* These routes all receive session state, CSRF protection, etc.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
protected function mapWebRoutes(Router $router)
{
$router->group([
'namespace' => $this->namespace, 'middleware' => 'web',
], function ($router) {
require app_path('Http/routes.php');
});
}
}

View File

@ -1,10 +1,10 @@
<?php
namespace Blessing\Facades;
namespace App\Services;
use \Illuminate\Support\Facades\Facade;
class DB extends Facade
class Database extends Facade
{
/**
* Get the registered name of the component.
@ -13,6 +13,6 @@ class DB extends Facade
*/
protected static function getFacadeAccessor()
{
return 'db';
return 'database';
}
}

View File

@ -1,6 +1,6 @@
<?php
namespace Blessing\Database;
namespace App\Services\Database;
use \App\Exceptions\E;
use \Blessing\Config;
@ -41,14 +41,12 @@ class Database
*/
public function __construct($config = null)
{
$this->config = is_null($config) ? Config::getDbConfig() : $config;
@$this->connection = new \mysqli(
$this->config['host'],
$this->config['username'],
$this->config['password'],
$this->config['database'],
$this->config['port']
config('database.connections.mysql.host'),
config('database.connections.mysql.username'),
config('database.connections.mysql.password'),
config('database.connections.mysql.database'),
config('database.connections.mysql.port')
);
if ($this->connection->connect_error)
@ -61,7 +59,7 @@ class Database
public function table($table_name, $no_prefix = false)
{
if ($this->connection->real_escape_string($table_name) == $table_name) {
$this->table_name = $no_prefix ? $table_name : $this->config['prefix'].$table_name;
$this->table_name = $no_prefix ? $table_name : config('database.connections.mysql.prefix').$table_name;
return $this;
} else {
throw new \InvalidArgumentException('Table name contains invalid characters', 1);

View File

@ -1,6 +1,8 @@
<?php
namespace Blessing;
namespace App\Services;
use Session;
class Http
{
@ -13,7 +15,10 @@ class Http
*/
public static function redirect($url, $msg = "")
{
if ($msg !== "") $_SESSION['msg'] = $msg;
if ($msg !== "") {
Session::flash('msg', $msg);
Session::save();
}
if (!headers_sent()) {
header('Location: '.$url);
@ -91,7 +96,7 @@ class Http
View::json($msg, $code);
} else {
$config = require BASE_DIR."/config/view.php";
if (file_exists($config['view_path']."/errors/".$code.".tpl")) {
if (View::exists("errors.$code")) {
echo View::make('errors.'.$code)->with('code', $code)->with('message', $msg);
} else {
echo View::make('errors.e')->with('code', $code)->with('message', $msg);

View File

@ -1,6 +1,6 @@
<?php
namespace Blessing;
namespace App\Services;
use \Illuminate\Database\Eloquent\Model;
use \Exception;

View File

@ -1,35 +1,17 @@
<?php
namespace Blessing;
namespace App\Services;
/**
* Just a wrapper for Blade template engine
* @see \Illuminate\Support\Facades\View
*/
class View
class View extends \Illuminate\Support\Facades\View
{
public static function show($view, $data = [], $mergeData = [])
{
echo self::make($view, $data, $mergeData)->render();
}
public static function make($view, $data = [], $mergeData = [])
{
$config = require BASE_DIR."/config/view.php";
$view_path = [$config['view_path']];
$cache_path = $config['cache_path'];
$compiler = new \Xiaoler\Blade\Compilers\BladeCompiler($cache_path);
$engine = new \Xiaoler\Blade\Engines\CompilerEngine($compiler);
$finder = new \Xiaoler\Blade\FileViewFinder($view_path);
$finder->addExtension('tpl');
$factory = new \Xiaoler\Blade\Factory($engine, $finder);
return $factory->make($view, $data, $mergeData);
}
// function reload
public static function json()
{

51
artisan Normal file
View File

@ -0,0 +1,51 @@
#!/usr/bin/env php
<?php
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader
| for our application. We just need to utilize it! We'll require it
| into the script here so that we do not have to worry about the
| loading of any our classes "manually". Feels great to relax.
|
*/
require __DIR__.'/bootstrap/autoload.php';
$app = require_once __DIR__.'/bootstrap/app.php';
/*
|--------------------------------------------------------------------------
| Run The Artisan Application
|--------------------------------------------------------------------------
|
| When we run the console application, the current CLI command will be
| executed in this console and the response sent back to a terminal
| or another output device for the developers. Here goes nothing!
|
*/
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
$status = $kernel->handle(
$input = new Symfony\Component\Console\Input\ArgvInput,
new Symfony\Component\Console\Output\ConsoleOutput
);
/*
|--------------------------------------------------------------------------
| Shutdown The Application
|--------------------------------------------------------------------------
|
| Once Artisan has finished running. We will fire off the shutdown events
| so that any final work may be done by the application before we shut
| down the process. This is the last thing to happen to the request.
|
*/
$kernel->terminate($input, $status);
exit($status);

File diff suppressed because one or more lines are too long

55
bootstrap/app.php Normal file
View File

@ -0,0 +1,55 @@
<?php
/*
|--------------------------------------------------------------------------
| Create The Application
|--------------------------------------------------------------------------
|
| The first thing we will do is create a new Laravel application instance
| which serves as the "glue" for all the components of Laravel, and is
| the IoC container for the system binding all of the various parts.
|
*/
$app = new Illuminate\Foundation\Application(
realpath(__DIR__.'/../')
);
/*
|--------------------------------------------------------------------------
| Bind Important Interfaces
|--------------------------------------------------------------------------
|
| Next, we need to bind some important interfaces into the container so
| we will be able to resolve them when needed. The kernels serve the
| incoming requests to this application from both the web and CLI.
|
*/
$app->singleton(
Illuminate\Contracts\Http\Kernel::class,
App\Http\Kernel::class
);
$app->singleton(
Illuminate\Contracts\Console\Kernel::class,
App\Console\Kernel::class
);
$app->singleton(
Illuminate\Contracts\Debug\ExceptionHandler::class,
App\Exceptions\Handler::class
);
/*
|--------------------------------------------------------------------------
| Return The Application
|--------------------------------------------------------------------------
|
| This script returns the application instance. The instance is given to
| the calling script so we can separate the building of the instances
| from the actual running of the application and sending responses.
|
*/
return $app;

34
bootstrap/autoload.php Normal file
View File

@ -0,0 +1,34 @@
<?php
define('LARAVEL_START', microtime(true));
/*
|--------------------------------------------------------------------------
| Register The Composer Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader
| for our application. We just need to utilize it! We'll require it
| into the script here so that we do not have to worry about the
| loading of any our classes "manually". Feels great to relax.
|
*/
require __DIR__.'/../vendor/autoload.php';
/*
|--------------------------------------------------------------------------
| Include The Compiled Class File
|--------------------------------------------------------------------------
|
| To dramatically increase your application's performance, you may use a
| compiled class file which contains all of the classes commonly used
| by a request. The Artisan "optimize" is used to create this file.
|
*/
$compiledPath = __DIR__.'/cache/compiled.php';
if (file_exists($compiledPath)) {
require $compiledPath;
}

2
bootstrap/cache/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore

View File

@ -1,24 +1,52 @@
{
"name": "blessing-skin-server",
"description": "Just a simple open-source Minecraft skin server written in PHP.",
"license": "GPL-3.0",
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.5.9",
"filp/whoops": "^2.1",
"illuminate/database": "^5.2",
"pecee/simple-router": "1.7.4.2",
"vlucas/phpdotenv": "^2.3",
"xiaoler/blade": "^0.2.2",
"gregwar/captcha": "^1.1",
"phpmailer/phpmailer": "^5.2"
"laravel/framework": "5.2.*",
"gregwar/captcha": "^1.1"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~4.0",
"symfony/css-selector": "2.8.*|3.0.*",
"symfony/dom-crawler": "2.8.*|3.0.*"
},
"autoload": {
"psr-4": {
"App\\": "app/",
"Blessing\\": "app/Core"
},
"classmap": [
"database",
"app/Models"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-root-package-install": [
"php -r \"copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
],
"post-install-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postInstall",
"php artisan optimize"
],
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
"php artisan optimize"
]
},
"config": {
"preferred-install": "dist"
}
}

2925
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +1,218 @@
<?php
/*
|--------------------------------------------------------------------------
| Application Configuration
|--------------------------------------------------------------------------
|
| Here is the configs about the application.
|
*/
return [
'version' => '3.0.4',
'locale' => 'zh-cn'
/*
|--------------------------------------------------------------------------
| Application Environment
|--------------------------------------------------------------------------
|
| This value determines the "environment" your application is currently
| running in. This may determine how you prefer to configure various
| services your application utilizes. Set this in your ".env" file.
|
*/
'env' => env('APP_ENV', 'production'),
/*
|--------------------------------------------------------------------------
| Application Debug Mode
|--------------------------------------------------------------------------
|
| When your application is in debug mode, detailed error messages with
| stack traces will be shown on every error that occurs within your
| application. If disabled, a simple generic error page is shown.
|
*/
'debug' => env('APP_DEBUG', false),
/*
|--------------------------------------------------------------------------
| Application URL
|--------------------------------------------------------------------------
|
| This URL is used by the console to properly generate URLs when using
| the Artisan command line tool. You should set this to the root of
| your application so that it is used when running Artisan tasks.
|
*/
'url' => env('APP_URL', 'http://localhost'),
/*
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| Here you may specify the default timezone for your application, which
| will be used by the PHP date and date-time functions. We have gone
| ahead and set this to a sensible default for you out of the box.
|
*/
'timezone' => 'UTC',
/*
|--------------------------------------------------------------------------
| Application Locale Configuration
|--------------------------------------------------------------------------
|
| The application locale determines the default locale that will be used
| by the translation service provider. You are free to set this value
| to any of the locales which will be supported by the application.
|
*/
'locale' => 'en',
/*
|--------------------------------------------------------------------------
| Application Fallback Locale
|--------------------------------------------------------------------------
|
| The fallback locale determines the locale to use when the current one
| is not available. You may change the value to correspond to any of
| the language folders that are provided through your application.
|
*/
'fallback_locale' => 'en',
/*
|--------------------------------------------------------------------------
| Encryption Key
|--------------------------------------------------------------------------
|
| This key is used by the Illuminate encrypter service and should be set
| to a random, 32 character string, otherwise these encrypted strings
| will not be safe. Please do this before deploying an application!
|
*/
'key' => env('APP_KEY'),
'cipher' => 'AES-256-CBC',
/*
|--------------------------------------------------------------------------
| Logging Configuration
|--------------------------------------------------------------------------
|
| Here you may configure the log settings for your application. Out of
| the box, Laravel uses the Monolog PHP logging library. This gives
| you a variety of powerful log handlers / formatters to utilize.
|
| Available Settings: "single", "daily", "syslog", "errorlog"
|
*/
'log' => env('APP_LOG', 'single'),
/*
|--------------------------------------------------------------------------
| Autoloaded Service Providers
|--------------------------------------------------------------------------
|
| The service providers listed here will be automatically loaded on the
| request to your application. Feel free to add your own services to
| this array to grant expanded functionality to your applications.
|
*/
'providers' => [
/*
* Laravel Framework Service Providers...
*/
Illuminate\Auth\AuthServiceProvider::class,
Illuminate\Broadcasting\BroadcastServiceProvider::class,
Illuminate\Bus\BusServiceProvider::class,
Illuminate\Cache\CacheServiceProvider::class,
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
Illuminate\Cookie\CookieServiceProvider::class,
Illuminate\Database\DatabaseServiceProvider::class,
Illuminate\Encryption\EncryptionServiceProvider::class,
Illuminate\Filesystem\FilesystemServiceProvider::class,
Illuminate\Foundation\Providers\FoundationServiceProvider::class,
Illuminate\Hashing\HashServiceProvider::class,
Illuminate\Mail\MailServiceProvider::class,
Illuminate\Pagination\PaginationServiceProvider::class,
Illuminate\Pipeline\PipelineServiceProvider::class,
Illuminate\Queue\QueueServiceProvider::class,
Illuminate\Redis\RedisServiceProvider::class,
Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
Illuminate\Session\SessionServiceProvider::class,
Illuminate\Translation\TranslationServiceProvider::class,
Illuminate\Validation\ValidationServiceProvider::class,
Illuminate\View\ViewServiceProvider::class,
/*
* Application Service Providers...
*/
App\Providers\AppServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
],
/*
|--------------------------------------------------------------------------
| Class Aliases
|--------------------------------------------------------------------------
|
| This array of class aliases will be registered when this application
| is started. However, feel free to register as many as you wish as
| the aliases are "lazy" loaded so they don't hinder performance.
|
*/
'aliases' => [
'App' => Illuminate\Support\Facades\App::class,
'Artisan' => Illuminate\Support\Facades\Artisan::class,
'Auth' => Illuminate\Support\Facades\Auth::class,
'Blade' => Illuminate\Support\Facades\Blade::class,
'Cache' => Illuminate\Support\Facades\Cache::class,
'Config' => Illuminate\Support\Facades\Config::class,
'Cookie' => Illuminate\Support\Facades\Cookie::class,
'Crypt' => Illuminate\Support\Facades\Crypt::class,
'DB' => Illuminate\Support\Facades\DB::class,
'Eloquent' => Illuminate\Database\Eloquent\Model::class,
'Event' => Illuminate\Support\Facades\Event::class,
'File' => Illuminate\Support\Facades\File::class,
'Gate' => Illuminate\Support\Facades\Gate::class,
'Hash' => Illuminate\Support\Facades\Hash::class,
'Lang' => Illuminate\Support\Facades\Lang::class,
'Log' => Illuminate\Support\Facades\Log::class,
'Mail' => Illuminate\Support\Facades\Mail::class,
'Password' => Illuminate\Support\Facades\Password::class,
'Queue' => Illuminate\Support\Facades\Queue::class,
'Redirect' => Illuminate\Support\Facades\Redirect::class,
'Redis' => Illuminate\Support\Facades\Redis::class,
'Request' => Illuminate\Support\Facades\Request::class,
'Response' => Illuminate\Support\Facades\Response::class,
'Route' => Illuminate\Support\Facades\Route::class,
'Schema' => Illuminate\Support\Facades\Schema::class,
'Session' => Illuminate\Support\Facades\Session::class,
'Storage' => Illuminate\Support\Facades\Storage::class,
'URL' => Illuminate\Support\Facades\URL::class,
'Validator' => Illuminate\Support\Facades\Validator::class,
'View' => Illuminate\Support\Facades\View::class,
/**
* Blessing Skin
*/
'View' => App\Services\View::class,
'Option' => App\Services\Option::class,
'Utils' => App\Services\Utils::class,
'Minecraft' => App\Services\Minecraft::class,
'Validate' => App\Services\Validate::class,
'Updater' => App\Services\Updater::class,
'Database' => App\Services\Database::class,
'Http' => App\Services\Http::class
],
];

107
config/auth.php Normal file
View File

@ -0,0 +1,107 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Authentication Defaults
|--------------------------------------------------------------------------
|
| This option controls the default authentication "guard" and password
| reset options for your application. You may change these defaults
| as required, but they're a perfect start for most applications.
|
*/
'defaults' => [
'guard' => 'web',
'passwords' => 'users',
],
/*
|--------------------------------------------------------------------------
| Authentication Guards
|--------------------------------------------------------------------------
|
| Next, you may define every authentication guard for your application.
| Of course, a great default configuration has been defined for you
| here which uses session storage and the Eloquent user provider.
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| Supported: "session", "token"
|
*/
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'token',
'provider' => 'users',
],
],
/*
|--------------------------------------------------------------------------
| User Providers
|--------------------------------------------------------------------------
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| If you have multiple user tables or models you may configure multiple
| sources which represent each model / table. These sources may then
| be assigned to any extra authentication guards you have defined.
|
| Supported: "database", "eloquent"
|
*/
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
],
// 'users' => [
// 'driver' => 'database',
// 'table' => 'users',
// ],
],
/*
|--------------------------------------------------------------------------
| Resetting Passwords
|--------------------------------------------------------------------------
|
| Here you may set the options for resetting passwords including the view
| that is your password reset e-mail. You may also set the name of the
| table that maintains all of the reset tokens for your application.
|
| You may specify multiple password reset configurations if you have more
| than one user table or model in the application and you want to have
| separate password reset settings based on the specific user types.
|
| The expire time is the number of minutes that the reset token should be
| considered valid. This security feature keeps tokens short-lived so
| they have less time to be guessed. You may change this as needed.
|
*/
'passwords' => [
'users' => [
'provider' => 'users',
'email' => 'auth.emails.password',
'table' => 'password_resets',
'expire' => 60,
],
],
];

52
config/broadcasting.php Normal file
View File

@ -0,0 +1,52 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Broadcaster
|--------------------------------------------------------------------------
|
| This option controls the default broadcaster that will be used by the
| framework when an event needs to be broadcast. You may set this to
| any of the connections defined in the "connections" array below.
|
*/
'default' => env('BROADCAST_DRIVER', 'pusher'),
/*
|--------------------------------------------------------------------------
| Broadcast Connections
|--------------------------------------------------------------------------
|
| Here you may define all of the broadcast connections that will be used
| to broadcast events to other systems or over websockets. Samples of
| each available type of connection are provided inside this array.
|
*/
'connections' => [
'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_KEY'),
'secret' => env('PUSHER_SECRET'),
'app_id' => env('PUSHER_APP_ID'),
'options' => [
//
],
],
'redis' => [
'driver' => 'redis',
'connection' => 'default',
],
'log' => [
'driver' => 'log',
],
],
];

81
config/cache.php Normal file
View File

@ -0,0 +1,81 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Cache Store
|--------------------------------------------------------------------------
|
| This option controls the default cache connection that gets used while
| using this caching library. This connection is used when another is
| not explicitly specified when executing a given caching function.
|
*/
'default' => env('CACHE_DRIVER', 'file'),
/*
|--------------------------------------------------------------------------
| Cache Stores
|--------------------------------------------------------------------------
|
| Here you may define all of the cache "stores" for your application as
| well as their drivers. You may even define multiple stores for the
| same cache driver to group types of items stored in your caches.
|
*/
'stores' => [
'apc' => [
'driver' => 'apc',
],
'array' => [
'driver' => 'array',
],
'database' => [
'driver' => 'database',
'table' => 'cache',
'connection' => null,
],
'file' => [
'driver' => 'file',
'path' => storage_path('framework/cache'),
],
'memcached' => [
'driver' => 'memcached',
'servers' => [
[
'host' => env('MEMCACHED_HOST', '127.0.0.1'),
'port' => env('MEMCACHED_PORT', 11211),
'weight' => 100,
],
],
],
'redis' => [
'driver' => 'redis',
'connection' => 'default',
],
],
/*
|--------------------------------------------------------------------------
| Cache Key Prefix
|--------------------------------------------------------------------------
|
| When utilizing a RAM based store such as APC or Memcached, there might
| be other applications utilizing the same cache. So, we'll specify a
| value to get prefixed to all our keys so we can avoid collisions.
|
*/
'prefix' => 'laravel',
];

35
config/compile.php Normal file
View File

@ -0,0 +1,35 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Additional Compiled Classes
|--------------------------------------------------------------------------
|
| Here you may specify additional classes to include in the compiled file
| generated by the `artisan optimize` command. These should be classes
| that are included on basically every request into the application.
|
*/
'files' => [
//
],
/*
|--------------------------------------------------------------------------
| Compiled File Providers
|--------------------------------------------------------------------------
|
| Here you may list service providers which define a "compiles" function
| that returns additional files that should be compiled, providing an
| easy way to get common files from any packages you are utilizing.
|
*/
'providers' => [
//
],
];

View File

@ -1,20 +1,120 @@
<?php
/*
|--------------------------------------------------------------------------
| Database Configuration
|--------------------------------------------------------------------------
|
| Load configuration from .env
|
*/
return [
'driver' => 'mysql',
'host' => $_ENV['DB_HOST'],
'port' => $_ENV['DB_PORT'],
'database' => $_ENV['DB_DATABASE'],
'username' => $_ENV['DB_USERNAME'],
'password' => $_ENV['DB_PASSWORD'],
'charset' => 'utf8',
'collation' => 'utf8_general_ci',
'prefix' => $_ENV['DB_PREFIX']
/*
|--------------------------------------------------------------------------
| PDO Fetch Style
|--------------------------------------------------------------------------
|
| By default, database results will be returned as instances of the PHP
| stdClass object; however, you may desire to retrieve records in an
| array format for simplicity. Here you can tweak the fetch style.
|
*/
'fetch' => PDO::FETCH_CLASS,
/*
|--------------------------------------------------------------------------
| Default Database Connection Name
|--------------------------------------------------------------------------
|
| Here you may specify which of the database connections below you wish
| to use as your default connection for all database work. Of course
| you may use many connections at once using the Database library.
|
*/
'default' => env('DB_CONNECTION', 'mysql'),
/*
|--------------------------------------------------------------------------
| Database Connections
|--------------------------------------------------------------------------
|
| Here are each of the database connections setup for your application.
| Of course, examples of configuring each database platform that is
| supported by Laravel is shown below to make development simple.
|
|
| All database work in Laravel is done through the PHP PDO facilities
| so make sure you have the driver for your particular database of
| choice installed on your machine before you begin development.
|
*/
'connections' => [
'sqlite' => [
'driver' => 'sqlite',
'database' => env('DB_DATABASE', database_path('database.sqlite')),
'prefix' => '',
],
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
'engine' => null,
],
'pgsql' => [
'driver' => 'pgsql',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '5432'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public',
],
],
/*
|--------------------------------------------------------------------------
| Migration Repository Table
|--------------------------------------------------------------------------
|
| This table keeps track of all the migrations that have already run for
| your application. Using this information, we can determine which of
| the migrations on disk haven't actually been run in the database.
|
*/
'migrations' => 'migrations',
/*
|--------------------------------------------------------------------------
| Redis Databases
|--------------------------------------------------------------------------
|
| Redis is an open source, fast, and advanced key-value store that also
| provides a richer set of commands than a typical key-value systems
| such as APC or Memcached. Laravel makes it easy to dig right in.
|
*/
'redis' => [
'cluster' => false,
'default' => [
'host' => env('REDIS_HOST', 'localhost'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => 0,
],
],
];

67
config/filesystems.php Normal file
View File

@ -0,0 +1,67 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Filesystem Disk
|--------------------------------------------------------------------------
|
| Here you may specify the default filesystem disk that should be used
| by the framework. A "local" driver, as well as a variety of cloud
| based drivers are available for your choosing. Just store away!
|
| Supported: "local", "ftp", "s3", "rackspace"
|
*/
'default' => 'local',
/*
|--------------------------------------------------------------------------
| Default Cloud Filesystem Disk
|--------------------------------------------------------------------------
|
| Many applications store files both locally and in the cloud. For this
| reason, you may specify a default "cloud" driver here. This driver
| will be bound as the Cloud disk implementation in the container.
|
*/
'cloud' => 's3',
/*
|--------------------------------------------------------------------------
| Filesystem Disks
|--------------------------------------------------------------------------
|
| Here you may configure as many filesystem "disks" as you wish, and you
| may even configure multiple disks of the same driver. Defaults have
| been setup for each driver as an example of the required options.
|
*/
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'visibility' => 'public',
],
's3' => [
'driver' => 's3',
'key' => 'your-key',
'secret' => 'your-secret',
'region' => 'your-region',
'bucket' => 'your-bucket',
],
],
];

112
config/mail.php Normal file
View File

@ -0,0 +1,112 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Mail Driver
|--------------------------------------------------------------------------
|
| Laravel supports both SMTP and PHP's "mail" function as drivers for the
| sending of e-mail. You may specify which one you're using throughout
| your application here. By default, Laravel is setup for SMTP mail.
|
| Supported: "smtp", "mail", "sendmail", "mailgun", "mandrill",
| "ses", "sparkpost", "log"
|
*/
'driver' => env('MAIL_DRIVER', 'smtp'),
/*
|--------------------------------------------------------------------------
| SMTP Host Address
|--------------------------------------------------------------------------
|
| Here you may provide the host address of the SMTP server used by your
| applications. A default option is provided that is compatible with
| the Mailgun mail service which will provide reliable deliveries.
|
*/
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
/*
|--------------------------------------------------------------------------
| SMTP Host Port
|--------------------------------------------------------------------------
|
| This is the SMTP port used by your application to deliver e-mails to
| users of the application. Like the host we have set this value to
| stay compatible with the Mailgun e-mail application by default.
|
*/
'port' => env('MAIL_PORT', 587),
/*
|--------------------------------------------------------------------------
| Global "From" Address
|--------------------------------------------------------------------------
|
| You may wish for all e-mails sent by your application to be sent from
| the same address. Here, you may specify a name and address that is
| used globally for all e-mails that are sent by your application.
|
*/
'from' => ['address' => null, 'name' => null],
/*
|--------------------------------------------------------------------------
| E-Mail Encryption Protocol
|--------------------------------------------------------------------------
|
| Here you may specify the encryption protocol that should be used when
| the application send e-mail messages. A sensible default using the
| transport layer security protocol should provide great security.
|
*/
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
/*
|--------------------------------------------------------------------------
| SMTP Server Username
|--------------------------------------------------------------------------
|
| If your SMTP server requires a username for authentication, you should
| set it here. This will get used to authenticate with your server on
| connection. You may also set the "password" value below this one.
|
*/
'username' => env('MAIL_USERNAME'),
/*
|--------------------------------------------------------------------------
| SMTP Server Password
|--------------------------------------------------------------------------
|
| Here you may set the password required by your SMTP server to send out
| messages from your application. This will be given to the server on
| connection so that the application will be able to send messages.
|
*/
'password' => env('MAIL_PASSWORD'),
/*
|--------------------------------------------------------------------------
| Sendmail System Path
|--------------------------------------------------------------------------
|
| When using the "sendmail" driver to send e-mails, we will need to know
| the path to where Sendmail lives on this server. A default path has
| been provided here, which will work well on most of your systems.
|
*/
'sendmail' => '/usr/sbin/sendmail -bs',
];

85
config/queue.php Normal file
View File

@ -0,0 +1,85 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Queue Driver
|--------------------------------------------------------------------------
|
| The Laravel queue API supports a variety of back-ends via an unified
| API, giving you convenient access to each back-end using the same
| syntax for each one. Here you may set the default queue driver.
|
| Supported: "null", "sync", "database", "beanstalkd", "sqs", "redis"
|
*/
'default' => env('QUEUE_DRIVER', 'sync'),
/*
|--------------------------------------------------------------------------
| Queue Connections
|--------------------------------------------------------------------------
|
| Here you may configure the connection information for each server that
| is used by your application. A default configuration has been added
| for each back-end shipped with Laravel. You are free to add more.
|
*/
'connections' => [
'sync' => [
'driver' => 'sync',
],
'database' => [
'driver' => 'database',
'table' => 'jobs',
'queue' => 'default',
'expire' => 60,
],
'beanstalkd' => [
'driver' => 'beanstalkd',
'host' => 'localhost',
'queue' => 'default',
'ttr' => 60,
],
'sqs' => [
'driver' => 'sqs',
'key' => 'your-public-key',
'secret' => 'your-secret-key',
'prefix' => 'https://sqs.us-east-1.amazonaws.com/your-account-id',
'queue' => 'your-queue-name',
'region' => 'us-east-1',
],
'redis' => [
'driver' => 'redis',
'connection' => 'default',
'queue' => 'default',
'expire' => 60,
],
],
/*
|--------------------------------------------------------------------------
| Failed Queue Jobs
|--------------------------------------------------------------------------
|
| These options configure the behavior of failed queue job logging so you
| can control which database and table are used to store the jobs that
| have failed. You may change them to any database / table you wish.
|
*/
'failed' => [
'database' => env('DB_CONNECTION', 'mysql'),
'table' => 'failed_jobs',
],
];

View File

@ -1,29 +1,38 @@
<?php
/*
|--------------------------------------------------------------------------
| Class Aliases
|--------------------------------------------------------------------------
|
| This array of class aliases will be registered when this application
| is started. However, feel free to register as many as you wish as
| the aliases are "lazy" loaded so they don't hinder performance.
|
*/
return [
'View' => 'Blessing\View',
'DB' => 'Blessing\Facades\DB',
'Option' => 'Blessing\Option',
'Utils' => 'App\Services\Utils',
'Validate' => 'App\Services\Validate',
'Http' => 'Blessing\Http',
'Mail' => 'Blessing\Mail',
'Storage' => 'Blessing\Storage',
'Minecraft' => 'App\Services\Minecraft',
'Updater' => 'App\Services\Updater',
'Config' => 'Blessing\Config',
'Schema' => 'Blessing\Database\Schema',
'Boot' => 'Blessing\Foundation\Boot',
'Migration' => 'Blessing\Database\Migration',
'App' => 'Blessing\Facades\App'
/*
|--------------------------------------------------------------------------
| Third Party Services
|--------------------------------------------------------------------------
|
| This file is for storing the credentials for third party services such
| as Stripe, Mailgun, Mandrill, and others. This file provides a sane
| default location for this type of information, allowing packages
| to have a conventional place to find your various credentials.
|
*/
'mailgun' => [
'domain' => env('MAILGUN_DOMAIN'),
'secret' => env('MAILGUN_SECRET'),
],
'ses' => [
'key' => env('SES_KEY'),
'secret' => env('SES_SECRET'),
'region' => 'us-east-1',
],
'sparkpost' => [
'secret' => env('SPARKPOST_SECRET'),
],
'stripe' => [
'model' => App\User::class,
'key' => env('STRIPE_KEY'),
'secret' => env('STRIPE_SECRET'),
],
];

166
config/session.php Normal file
View File

@ -0,0 +1,166 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Session Driver
|--------------------------------------------------------------------------
|
| This option controls the default session "driver" that will be used on
| requests. By default, we will use the lightweight native driver but
| you may specify any of the other wonderful drivers provided here.
|
| Supported: "file", "cookie", "database", "apc",
| "memcached", "redis", "array"
|
*/
'driver' => env('SESSION_DRIVER', 'file'),
/*
|--------------------------------------------------------------------------
| Session Lifetime
|--------------------------------------------------------------------------
|
| Here you may specify the number of minutes that you wish the session
| to be allowed to remain idle before it expires. If you want them
| to immediately expire on the browser closing, set that option.
|
*/
'lifetime' => 120,
'expire_on_close' => false,
/*
|--------------------------------------------------------------------------
| Session Encryption
|--------------------------------------------------------------------------
|
| This option allows you to easily specify that all of your session data
| should be encrypted before it is stored. All encryption will be run
| automatically by Laravel and you can use the Session like normal.
|
*/
'encrypt' => false,
/*
|--------------------------------------------------------------------------
| Session File Location
|--------------------------------------------------------------------------
|
| When using the native session driver, we need a location where session
| files may be stored. A default has been set for you but a different
| location may be specified. This is only needed for file sessions.
|
*/
'files' => storage_path('framework/sessions'),
/*
|--------------------------------------------------------------------------
| Session Database Connection
|--------------------------------------------------------------------------
|
| When using the "database" or "redis" session drivers, you may specify a
| connection that should be used to manage these sessions. This should
| correspond to a connection in your database configuration options.
|
*/
'connection' => null,
/*
|--------------------------------------------------------------------------
| Session Database Table
|--------------------------------------------------------------------------
|
| When using the "database" session driver, you may specify the table we
| should use to manage the sessions. Of course, a sensible default is
| provided for you; however, you are free to change this as needed.
|
*/
'table' => 'sessions',
/*
|--------------------------------------------------------------------------
| Session Sweeping Lottery
|--------------------------------------------------------------------------
|
| Some session drivers must manually sweep their storage location to get
| rid of old sessions from storage. Here are the chances that it will
| happen on a given request. By default, the odds are 2 out of 100.
|
*/
'lottery' => [2, 100],
/*
|--------------------------------------------------------------------------
| Session Cookie Name
|--------------------------------------------------------------------------
|
| Here you may change the name of the cookie used to identify a session
| instance by ID. The name specified here will get used every time a
| new session cookie is created by the framework for every driver.
|
*/
'cookie' => 'bs_session',
/*
|--------------------------------------------------------------------------
| Session Cookie Path
|--------------------------------------------------------------------------
|
| The session cookie path determines the path for which the cookie will
| be regarded as available. Typically, this will be the root path of
| your application but you are free to change this when necessary.
|
*/
'path' => '/',
/*
|--------------------------------------------------------------------------
| Session Cookie Domain
|--------------------------------------------------------------------------
|
| Here you may change the domain of the cookie used to identify a session
| in your application. This will determine which domains the cookie is
| available to in your application. A sensible default has been set.
|
*/
'domain' => null,
/*
|--------------------------------------------------------------------------
| HTTPS Only Cookies
|--------------------------------------------------------------------------
|
| By setting this option to true, session cookies will only be sent back
| to the server if the browser has a HTTPS connection. This will keep
| the cookie from being sent to you if it can not be done securely.
|
*/
'secure' => false,
/*
|--------------------------------------------------------------------------
| HTTP Access Only
|--------------------------------------------------------------------------
|
| Setting this value to true will prevent JavaScript from accessing the
| value of the cookie and the cookie will only be accessible through
| the HTTP protocol. You are free to modify this option if needed.
|
*/
'http_only' => true,
];

View File

@ -1,13 +1,33 @@
<?php
/*
|--------------------------------------------------------------------------
| View Paths
|--------------------------------------------------------------------------
|
| Change it if you have another set of views
|
*/
return [
'view_path' => BASE_DIR.'/resources/views',
'cache_path' => BASE_DIR.'/resources/cache'
/*
|--------------------------------------------------------------------------
| View Storage Paths
|--------------------------------------------------------------------------
|
| Most templating systems load templates from disk. Here you may specify
| an array of paths that should be checked for your views. Of course
| the usual Laravel view path has already been registered for you.
|
*/
'paths' => [
realpath(base_path('resources/views')),
],
/*
|--------------------------------------------------------------------------
| Compiled View Path
|--------------------------------------------------------------------------
|
| This option determines where all the compiled Blade templates will be
| stored for your application. Typically, this is within the storage
| directory. However, as usual, you are free to change this value.
|
*/
'compiled' => realpath(storage_path('framework/views')),
];

1
database/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.sqlite

View File

@ -0,0 +1,21 @@
<?php
/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| Here you may define all of your model factories. Model factories give
| you a convenient way to create models for testing and seeding your
| database. Just tell the factory how a default model should look.
|
*/
$factory->define(App\User::class, function (Faker\Generator $faker) {
return [
'name' => $faker->name,
'email' => $faker->safeEmail,
'password' => bcrypt(str_random(10)),
'remember_token' => str_random(10),
];
});

View File

@ -0,0 +1 @@

View File

@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('email')->unique();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('users');
}
}

View File

@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreatePasswordResetsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('password_resets', function (Blueprint $table) {
$table->string('email')->index();
$table->string('token')->index();
$table->timestamp('created_at');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('password_resets');
}
}

1
database/seeds/.gitkeep Normal file
View File

@ -0,0 +1 @@

View File

@ -0,0 +1,16 @@
<?php
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
// $this->call(UsersTableSeeder::class);
}
}

View File

@ -2,7 +2,7 @@
* @Author: prpr
* @Date: 2016-07-21 13:38:26
* @Last Modified by: printempw
* @Last Modified time: 2016-08-20 21:58:50
* @Last Modified time: 2016-08-28 09:54:19
*/
var gulp = require('gulp'),
@ -16,6 +16,8 @@ var gulp = require('gulp'),
replace = require('gulp-replace')
zip = require('gulp-zip');
var elixir = require('laravel-elixir');
var version = require('./package.json').version;
/**

View File

@ -1,16 +1,61 @@
<?php
/**
* Bootstrap file of Blessing Skin Server
* Laravel - A PHP Framework For Web Artisans
*
* @package Laravel
* @author Taylor Otwell <taylorotwell@gmail.com>
*/
// Define Base Directory
define('BASE_DIR', __DIR__);
// Register Composer Auto Loader
require BASE_DIR.'/vendor/autoload.php';
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| our application. We just need to utilize it! We'll simply require it
| into the script here so that we don't have to worry about manual
| loading any of our classes later on. It feels nice to relax.
|
*/
// Initialize Application
$app = new Blessing\Foundation\Application();
require BASE_DIR.'/bootstrap/autoload.php';
// Start Application
$app->run();
/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/
$app = require_once BASE_DIR.'/bootstrap/app.php';
/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request
| through the kernel, and send the associated response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have prepared for them.
|
*/
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
$response->send();
$kernel->terminate($request, $response);

View File

@ -8,6 +8,11 @@
},
"author": "printempw",
"license": "GPL-3.0",
"private": true,
"scripts": {
"prod": "gulp --production",
"dev": "gulp watch"
},
"devDependencies": {
"gulp": "^3.9.1",
"gulp-clean-css": "^2.0.11",
@ -17,6 +22,7 @@
"gulp-replace": "^0.5.4",
"gulp-ruby-sass": "^2.0.6",
"gulp-uglify": "^1.5.4",
"gulp-zip": "^3.2.0"
"gulp-zip": "^3.2.0",
"laravel-elixir": "^5.0.0",
}
}

30
phpunit.xml Normal file
View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="bootstrap/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Application Test Suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./app</directory>
<exclude>
<file>./app/Http/routes.php</file>
</exclude>
</whitelist>
</filter>
<php>
<env name="APP_ENV" value="testing"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="QUEUE_DRIVER" value="sync"/>
</php>
</phpunit>

View File

@ -0,0 +1,2 @@
// @import "node_modules/bootstrap-sass/assets/stylesheets/bootstrap";

View File

@ -0,0 +1,19 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Authentication Language Lines
|--------------------------------------------------------------------------
|
| The following language lines are used during authentication for various
| messages that we need to display to the user. You are free to modify
| these language lines according to your application's requirements.
|
*/
'failed' => 'These credentials do not match our records.',
'throttle' => 'Too many login attempts. Please try again in :seconds seconds.',
];

View File

@ -0,0 +1,19 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Pagination Language Lines
|--------------------------------------------------------------------------
|
| The following language lines are used by the paginator library to build
| the simple pagination links. You are free to change them to anything
| you want to customize your views to better match your application.
|
*/
'previous' => '&laquo; Previous',
'next' => 'Next &raquo;',
];

View File

@ -0,0 +1,22 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Password Reset Language Lines
|--------------------------------------------------------------------------
|
| The following language lines are the default lines which match reasons
| that are given by the password broker for a password update attempt
| has failed, such as for an invalid token or invalid new password.
|
*/
'password' => 'Passwords must be at least six characters and match the confirmation.',
'reset' => 'Your password has been reset!',
'sent' => 'We have e-mailed your password reset link!',
'token' => 'This password reset token is invalid.',
'user' => "We can't find a user with that e-mail address.",
];

View File

@ -0,0 +1,113 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Validation Language Lines
|--------------------------------------------------------------------------
|
| The following language lines contain the default error messages used by
| the validator class. Some of these rules have multiple versions such
| as the size rules. Feel free to tweak each of these messages here.
|
*/
'accepted' => 'The :attribute must be accepted.',
'active_url' => 'The :attribute is not a valid URL.',
'after' => 'The :attribute must be a date after :date.',
'alpha' => 'The :attribute may only contain letters.',
'alpha_dash' => 'The :attribute may only contain letters, numbers, and dashes.',
'alpha_num' => 'The :attribute may only contain letters and numbers.',
'array' => 'The :attribute must be an array.',
'before' => 'The :attribute must be a date before :date.',
'between' => [
'numeric' => 'The :attribute must be between :min and :max.',
'file' => 'The :attribute must be between :min and :max kilobytes.',
'string' => 'The :attribute must be between :min and :max characters.',
'array' => 'The :attribute must have between :min and :max items.',
],
'boolean' => 'The :attribute field must be true or false.',
'confirmed' => 'The :attribute confirmation does not match.',
'date' => 'The :attribute is not a valid date.',
'date_format' => 'The :attribute does not match the format :format.',
'different' => 'The :attribute and :other must be different.',
'digits' => 'The :attribute must be :digits digits.',
'digits_between' => 'The :attribute must be between :min and :max digits.',
'distinct' => 'The :attribute field has a duplicate value.',
'email' => 'The :attribute must be a valid email address.',
'exists' => 'The selected :attribute is invalid.',
'filled' => 'The :attribute field is required.',
'image' => 'The :attribute must be an image.',
'in' => 'The selected :attribute is invalid.',
'in_array' => 'The :attribute field does not exist in :other.',
'integer' => 'The :attribute must be an integer.',
'ip' => 'The :attribute must be a valid IP address.',
'json' => 'The :attribute must be a valid JSON string.',
'max' => [
'numeric' => 'The :attribute may not be greater than :max.',
'file' => 'The :attribute may not be greater than :max kilobytes.',
'string' => 'The :attribute may not be greater than :max characters.',
'array' => 'The :attribute may not have more than :max items.',
],
'mimes' => 'The :attribute must be a file of type: :values.',
'min' => [
'numeric' => 'The :attribute must be at least :min.',
'file' => 'The :attribute must be at least :min kilobytes.',
'string' => 'The :attribute must be at least :min characters.',
'array' => 'The :attribute must have at least :min items.',
],
'not_in' => 'The selected :attribute is invalid.',
'numeric' => 'The :attribute must be a number.',
'present' => 'The :attribute field must be present.',
'regex' => 'The :attribute format is invalid.',
'required' => 'The :attribute field is required.',
'required_if' => 'The :attribute field is required when :other is :value.',
'required_unless' => 'The :attribute field is required unless :other is in :values.',
'required_with' => 'The :attribute field is required when :values is present.',
'required_with_all' => 'The :attribute field is required when :values is present.',
'required_without' => 'The :attribute field is required when :values is not present.',
'required_without_all' => 'The :attribute field is required when none of :values are present.',
'same' => 'The :attribute and :other must match.',
'size' => [
'numeric' => 'The :attribute must be :size.',
'file' => 'The :attribute must be :size kilobytes.',
'string' => 'The :attribute must be :size characters.',
'array' => 'The :attribute must contain :size items.',
],
'string' => 'The :attribute must be a string.',
'timezone' => 'The :attribute must be a valid zone.',
'unique' => 'The :attribute has already been taken.',
'url' => 'The :attribute format is invalid.',
/*
|--------------------------------------------------------------------------
| Custom Validation Language Lines
|--------------------------------------------------------------------------
|
| Here you may specify custom validation messages for attributes using the
| convention "attribute.rule" to name the lines. This makes it quick to
| specify a specific custom language line for a given attribute rule.
|
*/
'custom' => [
'attribute-name' => [
'rule-name' => 'custom-message',
],
],
/*
|--------------------------------------------------------------------------
| Custom Validation Attributes
|--------------------------------------------------------------------------
|
| The following language lines are used to swap attribute place-holders
| with something more reader friendly such as E-Mail Address instead
| of "email". This simply helps us make messages a little cleaner.
|
*/
'attributes' => [],
];

View File

@ -1,69 +1,69 @@
@extends('admin.master')
@section('title', '仪表盘')
@section('content')
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
仪表盘
<small>Dashboard</small>
</h1>
</section>
<!-- Main content -->
<section class="content">
<div class="row">
<div class="col-md-6">
<div class="row">
<div class="col-md-6">
<div class="info-box">
<a href="../admin/users">
<span class="info-box-icon bg-aqua"><i class="fa fa-users"></i></span>
<div class="info-box-content">
<span class="info-box-text">注册用户</span>
<span class="info-box-number">{{ App\Models\UserModel::all()->count() }}</span>
</div><!-- /.info-box-content -->
</a>
</div><!-- /.info-box -->
</div>
<div class="col-md-6">
<div class="info-box">
<a href="../admin/players">
<div class="info-box-content" style="margin-left: 0;">
<span class="info-box-text">角色总数</span>
<span class="info-box-number">{{ App\Models\PlayerModel::all()->count() }}</span>
</div><!-- /.info-box-content -->
</a>
</div><!-- /.info-box -->
</div>
</div>
<div class="info-box">
<span class="info-box-icon bg-green"><i class="fa fa-files-o"></i></span>
<div class="info-box-content">
<span class="info-box-text">上传材质总数</span>
<span class="info-box-number">{{ \DB::table('textures')->getRecordNum() }}</span>
</div><!-- /.info-box-content -->
</div><!-- /.info-box -->
<div class="info-box">
<span class="info-box-icon bg-yellow"><i class="fa fa-hdd-o"></i></span>
<div class="info-box-content">
<span class="info-box-text">占用空间大小</span>
<?php $size = \DB::table('textures')->fetchArray("SELECT SUM(`size`) AS total_size FROM `{table}` WHERE 1")['total_size'] ?: 0; ?>
<span class="info-box-number">{{ $size > 1024 ? round($size / 1024, 1)."MB" : $size."KB" }}</span>
</div><!-- /.info-box-content -->
</div><!-- /.info-box -->
</div>
</div>
</section><!-- /.content -->
</div><!-- /.content-wrapper -->
@endsection
@extends('admin.master')
@section('title', '仪表盘')
@section('content')
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
仪表盘
<small>Dashboard</small>
</h1>
</section>
<!-- Main content -->
<section class="content">
<div class="row">
<div class="col-md-6">
<div class="row">
<div class="col-md-6">
<div class="info-box">
<a href="../admin/users">
<span class="info-box-icon bg-aqua"><i class="fa fa-users"></i></span>
<div class="info-box-content">
<span class="info-box-text">注册用户</span>
<span class="info-box-number">{{ App\Models\UserModel::all()->count() }}</span>
</div><!-- /.info-box-content -->
</a>
</div><!-- /.info-box -->
</div>
<div class="col-md-6">
<div class="info-box">
<a href="../admin/players">
<div class="info-box-content" style="margin-left: 0;">
<span class="info-box-text">角色总数</span>
<span class="info-box-number">{{ App\Models\PlayerModel::all()->count() }}</span>
</div><!-- /.info-box-content -->
</a>
</div><!-- /.info-box -->
</div>
</div>
<div class="info-box">
<span class="info-box-icon bg-green"><i class="fa fa-files-o"></i></span>
<div class="info-box-content">
<span class="info-box-text">上传材质总数</span>
<span class="info-box-number">{{ \Database::table('textures')->getRecordNum() }}</span>
</div><!-- /.info-box-content -->
</div><!-- /.info-box -->
<div class="info-box">
<span class="info-box-icon bg-yellow"><i class="fa fa-hdd-o"></i></span>
<div class="info-box-content">
<span class="info-box-text">占用空间大小</span>
<?php $size = \Database::table('textures')->fetchArray("SELECT SUM(`size`) AS total_size FROM `{table}` WHERE 1")['total_size'] ?: 0; ?>
<span class="info-box-number">{{ $size > 1024 ? round($size / 1024, 1)."MB" : $size."KB" }}</span>
</div><!-- /.info-box-content -->
</div><!-- /.info-box -->
</div>
</div>
</section><!-- /.content -->
</div><!-- /.content-wrapper -->
@endsection

View File

@ -19,7 +19,7 @@
<style>{!! Option::get('custom_css') !!}</style>
</head>
<?php $user = new App\Models\User($_SESSION['uid']); ?>
<?php $user = new App\Models\User(session('uid')); ?>
<body class="hold-transition {{ Option::get('color_scheme') }} sidebar-mini">
<div class="wrapper">

View File

@ -26,7 +26,7 @@
</h1>
</section>
<?php $current_user = new App\Models\User($_SESSION['uid']); ?>
<?php $current_user = new App\Models\User(session('uid')); ?>
<!-- Main content -->
<section class="content">

View File

@ -22,7 +22,7 @@
<span class="glyphicon glyphicon-lock form-control-feedback"></span>
</div>
<div class="row" id="captcha-form" style="{{ (\Utils::getValue('login_fails', $_SESSION) > 3) ? '' : 'display: none;'}}">
<div class="row" id="captcha-form" style="{{ (session('login_fails') > 3) ? '' : 'display: none;'}}">
<div class="col-xs-8">
<div class="form-group has-feedback">
<input id="captcha" type="text" class="form-control" placeholder="输入验证码">

View File

@ -24,9 +24,9 @@
<script type="text/javascript" src="../assets/dist/js/auth.js"></script>
@if (isset($_SESSION['msg']))
@if (Session::has('msg'))
<script>
toastr.info('{{ $_SESSION['msg'] }}'); <?php unset($_SESSION['msg']); ?>
toastr.info('{{ session('msg') }}');
</script>
@endif

View File

@ -0,0 +1,9 @@
@extends('errors.general')
@section('title', '503 Service Unavailable')
@section('content')
<h1>Be right back.</h1>
<p>详细信息:{{ $message or "Application is now in maintenance mode." }}</p>
@endsection

View File

@ -48,9 +48,9 @@
</table>
@if (isset($_SESSION['msg']))
<div class="alert alert-warning" role="alert">{{ htmlspecialchars($_SESSION['msg']) }}</div>
<?php unset($_SESSION['msg']); ?>
@if (session()->has('msg'))
<div class="alert alert-warning" role="alert">{{ session('msg') }}</div>
<?php session()->forget('msg'); ?>
@endif
<p class="step">
@ -71,7 +71,7 @@
if (Utils::convertString($_POST['v2_table_name']) != $_POST['v2_table_name'])
Http::redirect('index.php?action=import-v2-both&step=1', "表名 {$_POST['v2_table_name']} 中含有无效字符");
if (!DB::hasTable($_POST['v2_table_name'])) {
if (!Database::hasTable($_POST['v2_table_name'])) {
Http::redirect('index.php?action=import-v2-both&step=1', "数据表 {$_POST['v2_table_name']} 不存在");
}
}

View File

@ -56,9 +56,9 @@
</tr>
</table>
@if (isset($_SESSION['msg']))
<div class="alert alert-warning" role="alert">{{ htmlspecialchars($_SESSION['msg']) }}</div>
<?php unset($_SESSION['msg']); ?>
@if (session()->has('msg'))
<div class="alert alert-warning" role="alert">{{ session('msg') }}</div>
<?php session()->forget('msg'); ?>
@endif
<p class="step">
@ -81,7 +81,7 @@
if (Utils::convertString($_POST['v2_table_name']) != $_POST['v2_table_name'])
Http::redirect('index.php?action=import-v2-textures&step=1', "表名 {$_POST['v2_table_name']} 中含有无效字符");
if (!DB::hasTable($_POST['v2_table_name'])) {
if (!Database::hasTable($_POST['v2_table_name'])) {
Http::redirect('index.php?action=import-v2-textures&step=1', "数据表 {$_POST['v2_table_name']} 不存在");
}
}

View File

@ -26,9 +26,9 @@
</tr>
</table>
@if (isset($_SESSION['msg']))
<div class="alert alert-warning" role="alert">{{ htmlspecialchars($_SESSION['msg']) }}</div>
<?php unset($_SESSION['msg']); ?>
@if (session()->has('msg'))
<div class="alert alert-warning" role="alert">{{ session('msg') }}</div>
<?php session()->forget('msg'); ?>
@endif
<p class="step">
@ -49,7 +49,7 @@
if (Utils::convertString($_POST['v2_table_name']) != $_POST['v2_table_name'])
Http::redirect('index.php?action=import-v2-users&step=1', "表名 {$_POST['v2_table_name']} 中含有无效字符");
if (!DB::hasTable($_POST['v2_table_name'])) {
if (!Database::hasTable($_POST['v2_table_name'])) {
Http::redirect('index.php?action=import-v2-users&step=1', "数据表 {$_POST['v2_table_name']} 不存在");
}
}

View File

@ -43,9 +43,9 @@
</tr>
</table>
@if (isset($_SESSION['msg']))
<div class="alert alert-warning" role="alert">{{ htmlspecialchars($_SESSION['msg']) }}</div>
<?php unset($_SESSION['msg']); ?>
@if (session()->has('msg'))
<div class="alert alert-warning" role="alert">{{ session('msg') }}</div>
<?php session()->forget('msg'); ?>
@endif
<p class="step">

View File

@ -9,7 +9,7 @@
</p>
@if (isset($_SESSION['uid']))
@if (session()->has('uid'))
@if ($user->closet->has($texture['tid']))
<a title="从衣柜中移除" class="more like liked" tid="{{ $texture['tid'] }}" href="javascript:removeFromCloset({{ $texture['tid'] }});" data-placement="top" data-toggle="tooltip"><i class="fa fa-heart"></i></a>

View File

@ -1,145 +1,145 @@
@extends('user.master')
@section('title', '仪表盘')
@section('content')
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
仪表盘
<small>Dashboard</small>
</h1>
</section>
<!-- Main content -->
<section class="content">
<div class="row">
</div><!-- /.row -->
<div class="row">
<div class="col-md-8">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">使用情况</h3>
</div><!-- /.box-header -->
<div class="box-body">
<div class="row">
<div class="col-md-8">
<div class="progress-group">
<span class="progress-text">角色数量</span>
<?php
$players_available = count($user->getPlayers()) + floor($user->getScore() / Option::get('score_per_player'));
$percent = ($players_available == 0) ? 0 : count($user->getPlayers()) / $players_available * 100
?>
<span class="progress-number"><b>{{ count($user->getPlayers()) }}</b>/{{ $players_available }}</span>
<div class="progress sm">
<div class="progress-bar progress-bar-aqua" style="width: {{ $percent }}%"></div>
</div>
</div><!-- /.progress-group -->
<div class="progress-group">
<span class="progress-text">存储空间</span>
<?php $rate = Option::get('score_per_storage'); ?>
@if ($user->getStorageUsed() > 1024)
<span class="progress-number">
<b>{{ round($user->getStorageUsed() / 1024, 1) }}</b>/
{{ round(($user->getStorageUsed() + $user->getScore() / $rate) / 1024, 1) }} MB
</span>
@else
<span class="progress-number">
<b>{{ $user->getStorageUsed() }}</b>/
{{ $user->getStorageUsed() + $user->getScore() / $rate }} KB
</span>
@endif
<div class="progress sm">
<div class="progress-bar progress-bar-yellow" style="width: {{ $user->getStorageUsed() / ($user->getStorageUsed() + $user->getScore() / $rate) * 100 }}%"></div>
</div>
</div><!-- /.progress-group -->
</div><!-- /.col -->
<div class="col-md-4">
<p class="text-center">
<strong>当前积分</strong>
</p>
<p id="score" data-toggle="modal" data-target="#modal-score-instruction">
{{ $user->getScore() }}
</p>
<p class="text-center" style="font-size: smaller; margin-top: 20px;">点击积分查看说明</p>
</div><!-- /.col -->
</div><!-- /.row -->
</div><!-- ./box-body -->
<div class="box-footer">
@if ($user->canSign())
<button id="sign-button" class="btn btn-primary pull-left" onclick="sign()">
<i class="fa fa-calendar-check-o" aria-hidden="true"></i> &nbsp;每日签到
</button>
@else
<button class="btn btn-primary pull-left" title="上次签到于 {{ $user->getLastSignTime() }}" disabled="disabled">
<i class="fa fa-calendar-check-o" aria-hidden="true"></i> &nbsp;{{ $user->canSign(true) }} 小时后可签到
</button>
@endif
</div><!-- /.box-footer -->
</div><!-- /.box -->
</div><!-- /.col -->
<div class="col-md-4">
<div class="box box-primary">
<div class="box-header with-border">
<h3 class="box-title">公告</h3>
</div><!-- /.box-header -->
<div class="box-body">
{!! nl2br(Option::get('announcement')) !!}
</div><!-- /.box-body -->
</div>
</div>
</div>
</section><!-- /.content -->
</div><!-- /.content-wrapper -->
<div id="modal-score-instruction" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">积分是个啥?</h4>
</div>
<div class="modal-body">
<p>「既然你诚心诚意地发问了!」</p>
<p>「那我们就大发慈悲地告诉你!」</p>
<p>「为了守护皮肤站的和平」</p>
<p>「为了防止皮肤站被破坏」</p>
<p>「贯彻爱与真实的。。呸!」上面只是卖下萌~</p>
<hr />
<p>为了不出现用户一个劲上传材质导致存储空间爆满,我们决定启用积分系统。</p>
<p>添加角色以及上传材质都会消耗积分,而删除已经添加的角色和已上传的材质时积分将会被返还。</p>
<?php $sign_score = explode(',', Option::get('sign_score')); ?>
<p>本站用户初始积分为 {{ \Option::get('user_initial_score') }},每日签到可以随机获得 {{ $sign_score[0] }} ~ {{ $sign_score[1] }} 积分</p>
<p>添加皮肤库里的材质到衣柜不消耗积分。</p>
<hr />
<div class="row">
<div class="col-md-6">
<p class="text-center">{{ Option::get('score_per_storage') }} 积分 = 1 KB 存储空间</p>
</div>
<div class="col-md-6">
<p class="text-center">{{ Option::get('score_per_player') }} 积分 = 1 个角色</p>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
@endsection
@extends('user.master')
@section('title', '仪表盘')
@section('content')
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
仪表盘
<small>Dashboard</small>
</h1>
</section>
<!-- Main content -->
<section class="content">
<div class="row">
</div><!-- /.row -->
<div class="row">
<div class="col-md-8">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">使用情况</h3>
</div><!-- /.box-header -->
<div class="box-body">
<div class="row">
<div class="col-md-8">
<div class="progress-group">
<span class="progress-text">角色数量</span>
<?php
$players_available = count($user->getPlayers()) + floor($user->getScore() / Option::get('score_per_player'));
$percent = ($players_available == 0) ? 0 : count($user->getPlayers()) / $players_available * 100
?>
<span class="progress-number"><b>{{ count($user->getPlayers()) }}</b>/{{ $players_available }}</span>
<div class="progress sm">
<div class="progress-bar progress-bar-aqua" style="width: {{ $percent }}%"></div>
</div>
</div><!-- /.progress-group -->
<div class="progress-group">
<span class="progress-text">存储空间</span>
<?php $rate = Option::get('score_per_storage'); ?>
@if ($user->getStorageUsed() > 1024)
<span class="progress-number">
<b>{{ round($user->getStorageUsed() / 1024, 1) }}</b>/
{{ round(($user->getStorageUsed() + $user->getScore() / $rate) / 1024, 1) }} MB
</span>
@else
<span class="progress-number">
<b>{{ $user->getStorageUsed() }}</b>/
{{ $user->getStorageUsed() + $user->getScore() / $rate }} KB
</span>
@endif
<div class="progress sm">
<div class="progress-bar progress-bar-yellow" style="width: {{ $user->getStorageUsed() / ($user->getStorageUsed() + $user->getScore() / $rate) * 100 }}%"></div>
</div>
</div><!-- /.progress-group -->
</div><!-- /.col -->
<div class="col-md-4">
<p class="text-center">
<strong>当前积分</strong>
</p>
<p id="score" data-toggle="modal" data-target="#modal-score-instruction">
{{ $user->getScore() }}
</p>
<p class="text-center" style="font-size: smaller; margin-top: 20px;">点击积分查看说明</p>
</div><!-- /.col -->
</div><!-- /.row -->
</div><!-- ./box-body -->
<div class="box-footer">
@if ($user->canSign())
<button id="sign-button" class="btn btn-primary pull-left" onclick="sign()">
<i class="fa fa-calendar-check-o" aria-hidden="true"></i> &nbsp;每日签到
</button>
@else
<button class="btn btn-primary pull-left" title="上次签到于 {{ $user->getLastSignTime() }}" disabled="disabled">
<i class="fa fa-calendar-check-o" aria-hidden="true"></i> &nbsp;{{ $user->canSign(true) }} 小时后可签到
</button>
@endif
</div><!-- /.box-footer -->
</div><!-- /.box -->
</div><!-- /.col -->
<div class="col-md-4">
<div class="box box-primary">
<div class="box-header with-border">
<h3 class="box-title">公告</h3>
</div><!-- /.box-header -->
<div class="box-body">
{!! nl2br(Option::get('announcement')) !!}
</div><!-- /.box-body -->
</div>
</div>
</div>
</section><!-- /.content -->
</div><!-- /.content-wrapper -->
<div id="modal-score-instruction" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">积分是个啥?</h4>
</div>
<div class="modal-body">
<p>「既然你诚心诚意地发问了!」</p>
<p>「那我们就大发慈悲地告诉你!」</p>
<p>「为了守护皮肤站的和平」</p>
<p>「为了防止皮肤站被破坏」</p>
<p>「贯彻爱与真实的。。呸!」上面只是卖下萌~</p>
<hr />
<p>为了不出现用户一个劲上传材质导致存储空间爆满,我们决定启用积分系统。</p>
<p>添加角色以及上传材质都会消耗积分,而删除已经添加的角色和已上传的材质时积分将会被返还。</p>
<?php $sign_score = explode(',', Option::get('sign_score')); ?>
<p>本站用户初始积分为 {{ \Option::get('user_initial_score') }},每日签到可以随机获得 {{ $sign_score[0] }} ~ {{ $sign_score[1] }} 积分</p>
<p>添加皮肤库里的材质到衣柜不消耗积分。</p>
<hr />
<div class="row">
<div class="col-md-6">
<p class="text-center">{{ Option::get('score_per_storage') }} 积分 = 1 KB 存储空间</p>
</div>
<div class="col-md-6">
<p class="text-center">{{ Option::get('score_per_player') }} 积分 = 1 个角色</p>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
@endsection

View File

@ -134,9 +134,9 @@
@yield('script')
@if (isset($_SESSION['msg']))
@if (session()->has('msg'))
<script>
toastr.info('{{ $_SESSION['msg'] }}'); <?php unset($_SESSION['msg']) ?>
toastr.info('{{ session('msg') }}'); <?php session()->forget('msg') ?>
</script>
@endif

0
resources/views/vendor/.gitkeep vendored Normal file
View File

3
storage/app/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
*
!public/
!.gitignore

2
storage/app/public/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore

8
storage/framework/.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
config.php
routes.php
schedule-*
compiled.php
services.json
events.scanned.php
routes.scanned.php
down

Some files were not shown because too many files have changed in this diff Show More