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 @@
+
+
+