diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 889a50d..edcd643 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -3,24 +3,21 @@ namespace App\Http\Controllers; use Illuminate\Http\Request; +use App\Http\Controllers\SiteController; + +class HomeController extends Controller { + private $objSite; + private $menu; -class HomeController extends Controller -{ - /** - * Create a new controller instance. - * - * @return void - */ public function __construct() { - $this->middleware('auth'); + $this->objSite = new SiteController(); + $this->menu = $this->objSite->getPagesInMenu(); + //$this->middleware('auth'); } - /** - * Show the application dashboard. - * - * @return \Illuminate\Http\Response - */ - public function index() { - return view('home'); + public function index () { + $menu = $this->menu; + $res = $this->objSite->getPosts2(); + return view('pages.site.index', compact(['res', 'menu'])); } } diff --git a/app/Http/Controllers/SiteController.php b/app/Http/Controllers/SiteController.php index 908f706..b752fb6 100644 --- a/app/Http/Controllers/SiteController.php +++ b/app/Http/Controllers/SiteController.php @@ -23,6 +23,122 @@ class SiteController extends Controller { } // Posts + public function getPosts2() { // /api/rpc/site/post/get/all + $kero_token = $_COOKIE['kero_token']; + $check = $this->objAuth->checkLegit($kero_token); + + // Load group colours. + $ucol = $this->objUser->getGroupColours(); + $valid = $this->objAuth->getPermissions($kero_token); + + // Load content. + if ($valid['blg_editpost']) { + $get = DB::table('blg_content') + ->join('users', 'blg_content.user_id', '=', 'users.id') + ->join('usr_details', 'usr_details.user_id', '=', 'blg_content.user_id') + ->join('usr_profile', 'usr_profile.user_id', '=', 'blg_content.user_id') + ->join('usr_perm_id', 'usr_perm_id.user_id', '=', 'blg_content.user_id') + ->where('isPost', 1) + ->orderBy('publish_date', 'desc') + ->get(array( + 'blg_content.id', + 'blg_content.user_id', + 'title', + 'slug', + 'post_date', + 'publish_date', + 'public_status', + 'message', + 'username', + 'perm_id', + 'gender', + 'avatar', + 'name_style', + 'display_name' + )); + } + else { + $get = DB::table('blg_content') + ->join('users', 'blg_content.user_id', '=', 'users.id') + ->join('usr_details', 'usr_details.user_id', '=', 'blg_content.user_id') + ->join('usr_profile', 'usr_profile.user_id', '=', 'blg_content.user_id') + ->join('usr_perm_id', 'usr_perm_id.user_id', '=', 'blg_content.user_id') + ->where('public_status', 0) + ->where('isPost', 1) + ->orderBy('publish_date', 'desc') + ->get(array( + 'blg_content.id', + 'blg_content.user_id', + 'title', + 'slug', + 'post_date', + 'publish_date', + 'public_status', + 'message', + 'username', + 'perm_id', + 'gender', + 'avatar', + 'name_style', + 'display_name' + )); + } + + $res = array(); + $key = 0; + setlocale(LC_ALL, 'ja_JP.utf8'); + + foreach ($get as $i) { + $showName = ''; + $showCol = ''; + $showGroupName = ''; + + // Display name or username? + if (!empty($i->display_name)) { + $showName = $i->display_name; + } + else { + $showName = $i->username; + } + + // Custom name styling or default? + if (!empty($i->name_style)) { + $showCol = $i->name_style; + } + else { + foreach ($ucol as $j) { + if ($j->id == $i->perm_id) { + if ($i->gender == 1) $showCol = $j->colour_m; + else if ($i->gender == 2) $showCol = $j->colour_f; + else $showCol = $j->colour_u; + } + } + } + + // Group names. + $gname = $this->objUser->getGroupName($i->user_id); + $showGroupName = $gname[0]->name; + + array_push($res, [ + 'key' => $key, + 'id' => $i->id, + 'user_id' => $i->user_id, + 'title' => $i->title, + 'slug' => $i->slug, + 'post_date' => strftime('%Y/%m/%d(%a) %H:%M:%S %Z', $i->post_date), + 'publish_date' => strftime('%Y/%m/%d(%a) %H:%M:%S %Z', $i->publish_date), + 'public_status' => $i->public_status, + 'message' => $i->message, + 'avatar' => $i->avatar, + 'showcol' => $showCol, + 'showname' => $showName + ]); + $key++; + } + + return $res; + } + public function getPosts(Request $r) { // /api/rpc/site/post/get/all $check = $this->objAuth->checkLegit($r->kero_token); diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 83f1d10..449d4a9 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -7,6 +7,7 @@ use App\Models\ForUser; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\File; use Illuminate\Support\Facades\Storage; +use Illuminate\Support\Facades\Cache; use Illuminate\Http\Request; use Illuminate\Contracts\Routing\ResponseFactory; use Illuminate\Support\Facades\Log; @@ -130,36 +131,45 @@ class UserController extends Controller { } public function getUsers(Request $r) { // /api/rpc/user/user/getusers - $getting = array( - 'users.id', - 'usr_perm_module.name as group_name', - 'users.username', - 'usr_perm_id.perm_id', - 'usr_details.reg_date', - 'usr_profile.gender', - 'usr_profile.avatar', - 'usr_profile.name_style', - 'usr_profile.display_name', - 'usr_profile.country' - ); + $get = null; - $valid = $this->objAuth->getPermissions($r->kero_token); + if (Cache::has('getUsers')) $get = Cache::get('getUsers'); + else { + $getting = array( + 'users.id', + 'usr_perm_module.name as group_name', + 'users.username', + 'usr_perm_id.perm_id', + 'usr_details.reg_date', + 'usr_profile.gender', + 'usr_profile.avatar', + 'usr_profile.name_style', + 'usr_profile.display_name', + 'usr_profile.country' + ); - if ($valid['usr_emailshow'] == 1) { - array_push($getting, 'users.email'); + $valid = $this->objAuth->getPermissions($r->kero_token); + + if ($valid['usr_emailshow'] == 1) { + array_push($getting, 'users.email'); + } + + if ($valid['usr_ipshow'] == 1) { + array_push($getting, 'usr_profile.ip_address'); + } + + $get = DB::table('users') + ->join('usr_details', 'usr_details.user_id', '=', 'users.id') + ->join('usr_profile', 'usr_profile.user_id', '=', 'users.id') + ->join('usr_perm_id', 'usr_perm_id.user_id', '=', 'users.id') + ->join('usr_perm_module', 'usr_perm_module.id', 'usr_perm_id.perm_id') + ->orderBy('usr_details.reg_date', 'asc') + ->get($getting); + + Cache::put('getUsers', $get); } - if ($valid['usr_ipshow'] == 1) { - array_push($getting, 'usr_profile.ip_address'); - } - - return DB::table('users') - ->join('usr_details', 'usr_details.user_id', '=', 'users.id') - ->join('usr_profile', 'usr_profile.user_id', '=', 'users.id') - ->join('usr_perm_id', 'usr_perm_id.user_id', '=', 'users.id') - ->join('usr_perm_module', 'usr_perm_module.id', 'usr_perm_id.perm_id') - ->orderBy('usr_details.reg_date', 'asc') - ->get($getting); + return $get; } public function getUser($id, Request $r) { // /api/rpc/user/user/getuser/id/uid @@ -847,34 +857,37 @@ class UserController extends Controller { } } - public function getNotification(Request $r) { // /api/rpc/user/notification/get + public function getNotification (Request $r) { // /api/rpc/user/notification/get $check = $this->objAuth->checkLegit($r->kero_token); + $res = null; if ($check != 0) { - $get = DB::table('usr_notification') - ->select('id', 'app_id', 'text', 'section', 'goto') - ->where('user_id', $check) - ->get(); + if (Cache::has('getNotification')) $get = Cache::get('getNotification'); + else { + $get = DB::table('usr_notification') + ->select('id', 'app_id', 'text', 'section', 'goto') + ->where('user_id', $check) + ->get(); - $res = array(); + $res = array(); - foreach ($get as $g) { - $prot = DB::table('sys_settings')->select('protocol')->first()->protocol; - $goto = DB::table('sys_apps')->select('url')->where('id', $g->app_id)->first()->url; + foreach ($get as $g) { + $prot = DB::table('sys_settings')->select('protocol')->first()->protocol; + $goto = DB::table('sys_apps')->select('url')->where('id', $g->app_id)->first()->url; - $res[] = array( - 'id' => $g->id, - 'text' => $g->text, - 'url' => 'http'.($prot == 1 ? 's' : '').'://'.$goto.'/#/'.$g->section - ); + $res[] = array( + 'id' => $g->id, + 'text' => $g->text, + 'url' => 'http'.($prot == 1 ? 's' : '').'://'.$goto.'/#/'.$g->section + ); + + Cache::put('getNotification', $get); + } } return $res; } - - else { - return array(); - } + else return array(); } public function addNotification(Request $r, $uid, $aid, $txt, $sec, $goto) { // /api/rpc/user/notification/add @@ -890,6 +903,8 @@ class UserController extends Controller { 'goto' => $goto ]); + if (Cache::has('getNotification')) Cache::forget('getNotification'); + return 1; } } @@ -902,6 +917,8 @@ class UserController extends Controller { ->where('id', $r->id) ->where('user_id', $check) ->delete(); + + if (Cache::has('getNotification')) Cache::forget('getNotification'); } } } diff --git a/package.json b/package.json index 6973df4..fc089a4 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,9 @@ "vue-template-compiler": "^2.5.21" }, "dependencies": { - "js-cookie": "^2.2.0" + "bootstrap-vue": "^2.0.4", + "browserslist": "^4.7.2", + "caniuse-lite": "^1.0.30001006", + "js-cookie": "^2.2.1" } } diff --git a/resources/assets/js/app.js b/resources/assets/js/app.js index 8a7c3a4..0502d31 100644 --- a/resources/assets/js/app.js +++ b/resources/assets/js/app.js @@ -9,8 +9,12 @@ require('./bootstrap'); window.Vue = require('vue'); import bash from './components/bash/cli.vue'; +import navbar from './components/site/components/navbar.vue'; +import index from './components/site/views/index.vue'; Vue.component('bash', bash); +Vue.component('navbar', navbar); +Vue.component('index', index); /** * Next, we will create a fresh Vue application instance and attach it to diff --git a/resources/assets/js/auth.js b/resources/assets/js/auth.js new file mode 100644 index 0000000..3166d98 --- /dev/null +++ b/resources/assets/js/auth.js @@ -0,0 +1,39 @@ +import Cookie from 'js-cookie' + +const LOGIN_URL = '/api/auth/login' +const SIGNUP_URL = '/api/auth/register' + +export default { + domain: '076.ne.jp', + user: { id: 0, authenticated: false }, + login (creds) { + axios.post(LOGIN_URL, creds).then(res => { + if (creds.username === res.data.username && creds.password === res.data.rawPassword) { + Cookie.set('kero_token', res.data.kero_token, { expires: 365, domain: this.domain, path: '/' }); + + this.user.authenticated = true; + window.location.reload(); + } + }); + }, + signup (creds) { axios.post(SIGNUP_URL, creds).then(res => { if (res.data[0] === '1') this.login(creds); }); }, + logout () { + Cookie.remove('kero_token', { domain: this.domain, path: '/' }); + this.user.authenticated = false; + window.location.reload(); + }, + checkAuth () { + const tok = Cookie.get('kero_token'); + + axios.post('/api/auth/checkauth', { kero_token: tok }).then(res => { + if (tok === res.data.kero_token) { + this.user.id = res.data.id; + this.user.authenticated = true; + } + else { + this.user.id = 0; + this.user.authenticated = false; + } + }) + } +} diff --git a/resources/assets/js/components/site/components/index.vue b/resources/assets/js/components/site/components/index.vue new file mode 100644 index 0000000..d6213e2 --- /dev/null +++ b/resources/assets/js/components/site/components/index.vue @@ -0,0 +1,61 @@ + + + + + + diff --git a/resources/assets/js/components/site/components/navbar.vue b/resources/assets/js/components/site/components/navbar.vue new file mode 100644 index 0000000..5a2b75b --- /dev/null +++ b/resources/assets/js/components/site/components/navbar.vue @@ -0,0 +1,159 @@ + + + + diff --git a/resources/assets/js/components/site/components/post.vue b/resources/assets/js/components/site/components/post.vue new file mode 100644 index 0000000..780d522 --- /dev/null +++ b/resources/assets/js/components/site/components/post.vue @@ -0,0 +1,208 @@ + + + + + + diff --git a/resources/assets/js/components/site/views/index.vue b/resources/assets/js/components/site/views/index.vue new file mode 100644 index 0000000..318755b --- /dev/null +++ b/resources/assets/js/components/site/views/index.vue @@ -0,0 +1,32 @@ + + + + diff --git a/resources/assets/sass/app.scss b/resources/assets/sass/app.scss index 695a9f8..e0eb3ab 100644 --- a/resources/assets/sass/app.scss +++ b/resources/assets/sass/app.scss @@ -9,5 +9,242 @@ @import '~bootstrap/scss/bootstrap'; html { - cursor: text; + // cursor: text; } + +body { + font-family: 'Avenir', Helvetica, Arial, sans-serif; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + text-align: center; + color: #fcfcfc; + background-color: #232629; + } + a { + color: #1d99f3; + } + .bg-dark { + background: radial-gradient(farthest-corner at 50% 85%, + #3498db 0%, #232629 100%); + border-bottom: 2px solid #3daee9; + box-shadow: 0 0 7px 3px #1d99f3; + } + .navbar-nav .dropdown-menu { + background-color: #31363b; + color: #fcfcfc; + border: 2px solid #3daee9; + box-shadow: 0 0 7px 3px #1d99f3; + } + .dropdown-item { + color: #fcfcfc; + } + .dropdown-item.active, .dropdown-item:active, .dropdown-item:hover, .dropdown-item:focus { + color: #fcfcfc; + background-color: #3daee9; + } + .navbar-brand { + padding: 5px; + } + .navbar-brand, .nav-item { + transition: background 0.3s, color 0.3s; + border-radius: 2px; + cursor: pointer; + } + .navbar-brand:hover, .nav-item:hover { + background-color: #2980b9; + } + .badge-light { + color: #232629; + background-color: #eff0f1; + } + .badge { + font-size: 100%; + } + .within { + margin: 30px auto; + border: 2px solid #3daee9; + box-shadow: 0px 0px 7px 3px #1d99f3; + } + .bar { + background: linear-gradient( + to bottom, + #22699c 0%, + #436a86 34%, + #1a3746 100% + ); + padding: 5px; + font-size: 200%; + border-bottom: solid 2px #3daee9; + cursor: pointer; + transition: background 0.3s, color 0.3s; + } + .bar > a { + color: #fcfcfc; + } + .bar > a:hover { + text-decoration: none; + } + .bar:hover { + background: linear-gradient( + to bottom, + #2980b9 0%, + #6e93ad 34%, + #2b6b8b 100% + ); + // background-color: #2980b9; + } + .meta { + padding: 5px; + text-align: left; + background-color: #2c3e50; + border-bottom: solid 2px #3daee9; + } + .comment { + border-top: solid 2px #3daee9; + } + .back, .comment { + padding: 10px; + background-color: #31363b; + text-align: left; + } + .modal-header, .modal-body, .modal-footer { + color: #fcfcfc; + } + .modal-header { + background: linear-gradient( + to bottom, + #1d99f3 0%, + #6ec0fb 34%, + #3daee9 100% + ); + } + .modal-body { + background-color: #4d4d4d; + } + .modal-footer { + background-color: #31363b; + } + .form-control, .form-control:focus { + background-color: #31363b; + color: #fcfcfc; + } + .form-control { + border: 1px solid #34495e; + } + .form-control:focus { + border: 1px solid #3daee9; + } + .form-control:disabled, .form-control[readonly] { + background-color: #232629; + } + .custom-control-input:checked ~ .custom-control-label::before, + .custom-radio .custom-control-input:checked ~ .custom-control-label::before, + .custom-checkbox .custom-control-input:checked ~ .custom-control-label::before + { + color: #fcfcfc; + background-color: #3daee9; + border-color: #1d99f3; + } + .btn, btn:hover { + margin: 0 2px; + border: 2px solid; + } + .btn { + border-left-color: #fcfcfc; + border-top-color: #fcfcfc; + } + .btn:hover { + border-left-color: #7f8c8d; + border-top-color: #7f8c8d; + } + .btn-forum, .btn-forum.disabled, .btn-forum:disabled { + color: #fcfcfc; + background-color: #9b59b6; + border-color: transparent; + border-bottom-color: #cb81ea; + border-right-color: #cb81ea; + } + .btn-forum:hover { + color: #fcfcfc; + background-color: #61237c; + border-bottom-color: #9b59b6; + border-right-color: #9b59b6; + } + .btn-cwgames, .btn-cwgames.disabled, .btn-cwgames:disabled { + background: radial-gradient(ellipse at top, #4d4d4d, transparent), + radial-gradient(ellipse at bottom, #232629, transparent); + color: #fcfcfc; + border-bottom-color: #bdc3c7; + border-right-color: #bdc3c7; + } + .btn-cwgames:hover { + color: #fcfcfc; + background-color: #727272; + border-color: transparent; + border-bottom-color: #31363b; + border-right-color: #31363b; + } + .btn-primary, .btn-primary.disabled, .btn-primary:disabled { + background: radial-gradient(ellipse at top, #3daee9, transparent), + radial-gradient(ellipse at bottom, #232629, transparent); + color: #fcfcfc; + border-bottom-color: #9ed6ff; + border-right-color: #9ed6ff; + } + .btn-primary:hover { + color: #fcfcfc; + background-color: #205e7d; + border-color: transparent; + border-bottom-color: #1d99f3; + border-right-color: #1d99f3; + } + .btn-secondary, .btn-secondary.disabled, .btn-secondary:disabled { + color: #fcfcfc; + background-color: #7f8c8d; + border-color: transparent; + border-bottom-color: #d6dfe4; + border-right-color: #d6dfe4; + } + .btn-secondary:hover { + color: #fcfcfc; + background-color: #495051; + border-color: transparent; + border-bottom-color: #bdc3c7; + border-right-color: #bdc3c7; + } + .btn-success, .btn-success.disabled, .btn-success:disabled { + color: #fcfcfc; + background-color: #2ecc71; + border-color: transparent; + border-bottom-color: #20ec77; + border-right-color: #20ec77; + } + .btn-success:hover { + color: #fcfcfc; + background-color: #145d33; + border-bottom-color: #27ae60; + border-right-color: #27ae60; + } + .btn-danger, .btn-danger.disabled, .btn-danger:disabled { + color: #fcfcfc; + background-color: #da4453; + border-color: transparent; + border-bottom-color: #f58276; + border-right-color: #f58276; + } + .btn-danger:hover { + color: #fcfcfc; + background-color: #611e24; + border-bottom-color: #e74c3c; + border-right-color: #e74c3c; + } + + .within { margin: 0 auto; } + .wny { border: solid 2px #ed1515; box-shadow: 0px 0px 20px 10px rgba(237,21,21,1); } + .bny, .cny { background-color: #da4453; border-bottom: solid 2px #ed1515; } + .mny { background-color: #c0392b; border-bottom: solid 2px #ed1515; } + .new { background-color: #2c3e50; margin: 10px auto; padding: 0; } + .head > div { margin: 5px 0; } + .new-head, .new-body { padding: 10px; } + .new-head { border: 2px solid #3daee9; background-color: #34495e; } + .new-body { border-bottom: 2px solid #3daee9; border-left: 2px solid #3daee9; border-right: 2px solid #3daee9; } diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/bash.blade.php similarity index 98% rename from resources/views/layouts/app.blade.php rename to resources/views/layouts/bash.blade.php index ff63e6d..12187bb 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/bash.blade.php @@ -27,6 +27,7 @@
+ @yield('content')
diff --git a/resources/views/layouts/site.blade.php b/resources/views/layouts/site.blade.php new file mode 100644 index 0000000..9b82939 --- /dev/null +++ b/resources/views/layouts/site.blade.php @@ -0,0 +1,85 @@ + + + + + + + + + + + {{ config('app.name', 'Laravel') }} + + + + + + + +
+
+
+
画像
+
+ +
+
+
+ @foreach ($menu as $m) + {{ $m['title'] }} + @endforeach +
+
+
+ @yield('content') +
+
+
+
+ + + + + diff --git a/resources/views/pages/bash/cli.blade.php b/resources/views/pages/bash/cli.blade.php index 78a3259..2c1e1ae 100644 --- a/resources/views/pages/bash/cli.blade.php +++ b/resources/views/pages/bash/cli.blade.php @@ -1,4 +1,4 @@ -@extends('layouts.app') +@extends('layouts.bash') @section('content') diff --git a/resources/views/pages/site/index.blade.php b/resources/views/pages/site/index.blade.php new file mode 100644 index 0000000..c7b88c9 --- /dev/null +++ b/resources/views/pages/site/index.blade.php @@ -0,0 +1,13 @@ +@extends('layouts.site') + +@section('content') + +@foreach ($res as $r) +
+ +
+@endforeach + +@endsection diff --git a/resources/views/pages/site/post.blade.php b/resources/views/pages/site/post.blade.php index e69de29..45be6fd 100644 --- a/resources/views/pages/site/post.blade.php +++ b/resources/views/pages/site/post.blade.php @@ -0,0 +1,158 @@ + + + + diff --git a/routes/view/site.php b/routes/view/site.php new file mode 100644 index 0000000..5d81985 --- /dev/null +++ b/routes/view/site.php @@ -0,0 +1,5 @@ +