diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php
index c36ccae..a2da8d0 100644
--- a/app/Http/Controllers/HomeController.php
+++ b/app/Http/Controllers/HomeController.php
@@ -30,24 +30,24 @@ class HomeController extends Controller {
}
public function index () {
- $res = $this->objSite->getPosts2();
+ $res = $this->objSite->getPosts();
return view('pages.site.index', ['res' => $res, 'menu' => $this->menu, 'user' => $this->user]);
}
public function post ($slug) {
- $res = $this->objSite->getPost2($slug, $this->cook);
+ $res = $this->objSite->getPost($slug, $this->cook);
if (!$res) return view('pages.site.notfound', ['res' => $res, 'menu' => $this->menu, 'user' => $this->user]);
return view('pages.site.post', ['res' => $res, 'menu' => $this->menu, 'user' => $this->user]);
}
public function page ($slug) {
- $res = $this->objSite->getPage2($slug, $this->cook);
+ $res = $this->objSite->getPage($slug, $this->cook);
if (!$res) return view('pages.site.notfound', ['res' => $res, 'menu' => $this->menu, 'user' => $this->user]);
return view('pages.site.page', ['res' => $res, 'menu' => $this->menu, 'user' => $this->user]);
}
public function profile ($id) {
- $res = $this->objUser->getUser2($id, $this->cook);
+ $res = $this->objUser->getUser($id, $this->cook);
return view('pages.site.profile', ['res' => $res, 'menu' => $this->menu, 'user' => $this->user]);
}
diff --git a/app/Http/Controllers/SiteController.php b/app/Http/Controllers/SiteController.php
index 7379ac4..a74face 100644
--- a/app/Http/Controllers/SiteController.php
+++ b/app/Http/Controllers/SiteController.php
@@ -22,16 +22,13 @@ class SiteController extends Controller {
$this->objPermission = new PermissionController();
}
- // Posts
- public function getPosts2 () {
+ public function getPosts () {
$kero_token = (isset($_COOKIE['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')
@@ -93,15 +90,9 @@ class SiteController extends Controller {
$showCol = '';
$showGroupName = '';
- // Display name or username?
- if (!empty($i->display_name)) {
- $showName = $i->display_name;
- }
- else {
- $showName = $i->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;
}
@@ -115,7 +106,6 @@ class SiteController extends Controller {
}
}
- // Group names.
$gname = $this->objUser->getGroupName($i->user_id);
$showGroupName = $gname[0]->name;
@@ -139,179 +129,12 @@ class SiteController extends Controller {
return $res;
}
- public function getPosts(Request $r) { // /api/rpc/site/post/get/all
- $check = $this->objAuth->checkLegit($r->kero_token);
-
- // Load group colours.
- $ucol = $this->objUser->getGroupColours();
- $valid = $this->objAuth->getPermissions($r->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 getUserPosts($id) { // /api/rpc/site/post/get/user/id
- $get = DB::table('blg_content')
- ->select('id', 'title', 'slug', 'post_date', 'publish_date', 'public_status', 'message')
- ->where('public_status', 0)
- ->where('isPost', 1)
- ->where('user_id', $id)
- ->orderBy('publish_date', 'desc')
- ->get();
-
- $res = array();
- $key = 0;
-
- setlocale(LC_ALL, 'ja_JP.utf8');
-
- foreach ($get as $i) {
- array_push($res, [
- 'key' => $key,
- 'id' => $i->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
- ]);
- $key++;
- }
-
- return $res;
- }
-
- public function getPostSlug($id) { // /api/rpc/site/post/get/id/id
- $get = DB::table('blg_content')
- ->select('slug')
- ->where('public_status', 0)
- ->where('isPost', 1)
- ->where('id', $id)
- ->get();
-
- $res = array();
-
- foreach ($get as $i) {
- array_push($res, [
- 'slug' => $i->slug
- ]);
- }
-
- return $res;
- }
-
- public function getPost2 ($slug, $kero) {
+ public function getPost ($slug, $kero) {
$check = $this->objAuth->checkLegit($kero);
$valid = $this->objAuth->getPermissions($kero);
- // Load group colours.
$ucol = $this->objUser->getGroupColours();
- // Load content.
if ($valid['blg_editpost']) {
$get = DB::table('blg_content')
->join('users', 'blg_content.user_id', '=', 'users.id')
@@ -372,18 +195,10 @@ class SiteController extends Controller {
$showCol = '';
$showGroupName = '';
- // Display name or username?
- if (!empty($i->display_name)) {
- $showName = $i->display_name;
- }
- else {
- $showName = $i->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;
- }
+ if (!empty($i->name_style)) $showCol = $i->name_style;
else {
foreach ($ucol as $j) {
if ($j->id == $i->perm_id) {
@@ -394,7 +209,6 @@ class SiteController extends Controller {
}
}
- // Group names.
$gname = $this->objUser->getGroupName($i->user_id);
$showGroupName = $gname[0]->name;
@@ -417,214 +231,9 @@ class SiteController extends Controller {
return $res;
}
- public function getPost($slug, Request $r) { // /api/rpc/site/post/get/slug/slug
- $check = $this->objAuth->checkLegit($r->kero_token);
- $valid = $this->objAuth->getPermissions($r->kero_token);
-
- // Load group colours.
+ public function getComments ($id) {
$ucol = $this->objUser->getGroupColours();
- // 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)
- ->where('slug', $slug)
- ->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)
- ->where('slug', $slug)
- ->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();
- 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, [
- '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,
- 'gender' => $i->gender,
- 'avatar' => $i->avatar,
- 'showcol' => $showCol,
- 'showname' => $showName
- ]);
- }
-
- return $res;
- }
-
- public function newPost(Request $r) { // /api/rpc/site/post/new
- $check = $this->objAuth->checkLegit($r->kero_token);
-
- if ($check == 0) {
- return \Response::json(array('error' => 'ログインされませんでした。'));
- }
- else {
- $valid = $this->objAuth->getPermissions($r->kero_token);
-
- if ($valid['blg_addpost'] == 1) {
- $pubdate = 0;
-
- if ($r->public_status == 1) {
- if ($r->publish_date <= time()) {
- return \Response::json(array('error' => '投稿日より公開日の方がもっと古いだと不許可です。'));
- }
- else {
- $pubdate = $r->publish_date;
- }
- }
- else {
- $pubdate = time();
- }
-
- $add = DB::table('blg_content')
- ->insert([
- 'user_id' => $check,
- 'isPost' => 1,
- 'title' => $r->title,
- 'slug' => $r->slug,
- 'post_date' => time(),
- 'publish_date' => $pubdate,
- 'sortorder' => 0,
- 'public_status' => $r->public_status,
- 'isMenu' => 0,
- 'message' => $r->message
- ]);
-
- return \Response::json($add);
- }
- else {
- return \Response::json(array('error' => '不許可。'));
- }
- }
- }
-
- public function editPost(Request $r) { // /api/rpc/site/post/edit
- $check = $this->objAuth->checkLegit($r->kero_token);
-
- if ($check == 0) {
- return \Response::json(array('error' => 'ログインされませんでした。'));
- }
- else {
- $valid = $this->objAuth->getPermissions($r->kero_token);
-
- if ($valid['blg_editpost'] == 1) {
- return DB::table('blg_content')
- ->where('id', $r->id)
- ->update([
- 'title' => $r->title,
- 'slug' => $r->slug,
- 'public_status' => $r->public_status,
- 'message' => $r->message
- ]);
- }
- else {
- return \Response::json(array('error' => '不許可。'));
- }
- }
- }
-
- public function deletePost(Request $r) { // /api/rpc/site/post/delete
- $check = $this->objAuth->checkLegit($r->kero_token);
-
- if ($check == 0) {
- return \Response::json(array('error' => 'ログインされませんでした。'));
- }
- else {
- $valid = $this->objAuth->getPermissions($r->kero_token);
-
- if ($valid['blg_delpost'] == 1) {
- return DB::table('blg_content')->where('id', $r->id)->delete();
- }
- else {
- return \Response::json(array('error' => '不許可。'));
- }
- }
- }
-
- // Comments
- public function getComments($id) { // /api/rpc/site/comment/get/all/id
- // Load group colours.
- $ucol = $this->objUser->getGroupColours();
-
- // Load content.
$get = DB::table('blg_comments')
->join('users', 'blg_comments.user_id', '=', 'users.id')
->join('usr_details', 'usr_details.user_id', '=', 'blg_comments.user_id')
@@ -658,18 +267,10 @@ class SiteController extends Controller {
$showCol = '';
$showGroupName = '';
- // Display name or username?
- if (!empty($i->display_name)) {
- $showName = $i->display_name;
- }
- else {
- $showName = $i->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;
- }
+ if (!empty($i->name_style)) $showCol = $i->name_style;
else {
foreach ($ucol as $j) {
if ($j->id == $i->perm_id) {
@@ -680,7 +281,6 @@ class SiteController extends Controller {
}
}
- // Group names.
$gname = $this->objUser->getGroupName($i->user_id);
$showGroupName = $gname[0]->name;
@@ -705,11 +305,9 @@ class SiteController extends Controller {
return $res;
}
- public function getComment($id) { // /api/rpc/site/comment/get/one/id
- // Load group colours.
+ public function getComment ($id) {
$ucol = $this->objUser->getGroupColours();
- // Load content.
$get = DB::table('blg_comments')
->join('users', 'blg_comments.user_id', '=', 'users.id')
->join('usr_details', 'usr_details.user_id', '=', 'blg_comments.user_id')
@@ -743,18 +341,10 @@ class SiteController extends Controller {
$showCol = '';
$showGroupName = '';
- // Display name or username?
- if (!empty($i->display_name)) {
- $showName = $i->display_name;
- }
- else {
- $showName = $i->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;
- }
+ if (!empty($i->name_style)) $showCol = $i->name_style;
else {
foreach ($ucol as $j) {
if ($j->id == $i->perm_id) {
@@ -765,7 +355,6 @@ class SiteController extends Controller {
}
}
- // Group names.
$gname = $this->objUser->getGroupName($i->user_id);
$showGroupName = $gname[0]->name;
@@ -789,12 +378,10 @@ class SiteController extends Controller {
return $res;
}
- public function newComment(Request $r) { // /api/rpc/site/comment/new
+ public function newComment (Request $r) {
$check = $this->objAuth->checkLegit($r->kero_token);
- if ($check == 0) {
- return \Response::json(array('error' => 'ログインされませんでした。'));
- }
+ if ($check == 0) return \Response::json(array('error' => 'ログインされませんでした。'));
else {
$valid = $this->objAuth->getPermissions($r->kero_token);
@@ -812,23 +399,17 @@ class SiteController extends Controller {
]);
$g = DB::table('blg_content')->select('slug', 'user_id')->where('id', $r->content_id)->first();
-
if ($check != $g->user_id) $this->objUser->addNotification($r, $g->user_id, 1, '新規ブログコメント', 'blog/'.$g->slug, 'comment-'.$add);
-
return \Response::json($add);
}
- else {
- return \Response::json(array('error' => '不許可。'));
- }
+ else return \Response::json(array('error' => '不許可。'));
}
}
- public function editComment(Request $r) { // /api/rpc/site/comment/edit
+ public function editComment (Request $r) {
$check = $this->objAuth->checkLegit($r->kero_token);
- if ($check == 0) {
- return \Response::json(array('error' => 'ログインされませんでした。'));
- }
+ if ($check == 0) return \Response::json(array('error' => 'ログインされませんでした。'));
else {
$owner = DB::table('blg_comments')->select('user_id')->where('id', $r->id)->where('user_id', $r->user)->get()->toArray();
$valid = $this->objAuth->getPermissions($r->kero_token);
@@ -836,41 +417,27 @@ class SiteController extends Controller {
if ($valid['blg_editcomment'] == 1) {
return DB::table('blg_comments')
->where('id', $r->id)
- ->update([
- 'last_date' => time(),
- 'message' => $r->message
- ]);
+ ->update(['last_date' => time(), 'message' => $r->message]);
}
else if ($valid['blg_delcomment'] == 1 && $owner[0]->user_id == $check) {
return DB::table('blg_comments')
->where('id', $r->id)
- ->update([
- 'last_date' => time(),
- 'message' => $r->message
- ]);
- }
- else {
- return \Response::json(array('error' => '不許可。'));
+ ->update(['last_date' => time(), 'message' => $r->message]);
}
+ else return \Response::json(array('error' => '不許可。'));
}
}
- public function removeComment(Request $r) { // /api/rpc/site/comment/remove
+ public function removeComment (Request $r) {
$check = $this->objAuth->checkLegit($r->kero_token);
- if ($check == 0) {
- return \Response::json(array('error' => 'ログインされませんでした。'));
- }
+ if ($check == 0) return \Response::json(array('error' => 'ログインされませんでした。'));
else {
$owner = DB::table('blg_comments')->select('user_id')->where('id', $r->id)->where('user_id', $r->user)->get()->toArray();
$valid = $this->objAuth->getPermissions($r->kero_token);
if ($valid['blg_delcomment'] == 1) {
- $get = DB::table('blg_comments')
- ->select('isDeleted')
- ->where('id', $r->id)
- ->get();
-
+ $get = DB::table('blg_comments')->select('isDeleted')->where('id', $r->id)->get();
$mod = 0;
foreach ($get as $i) {
@@ -878,69 +445,35 @@ class SiteController extends Controller {
else $mod = 1;
}
- return DB::table('blg_comments')
- ->where('id', $r->id)
- ->update([
- 'isDeleted' => $mod
- ]);
+ return DB::table('blg_comments')->where('id', $r->id)->update(['isDeleted' => $mod]);
}
else if ($valid['blg_delowncomment'] == 1 && $owner[0]->user_id == $check) {
- $get = DB::table('blg_comments')
- ->select('isDeleted')
- ->where('id', $r->id)
- ->get();
-
- foreach ($get as $i) {
- if ($i->isDeleted == 1) return "不許可";
- }
-
- return DB::table('blg_comments')
- ->where('id', $r->id)
- ->update([
- 'isDeleted' => 1
- ]);
- }
- else {
- return \Response::json(array('error' => '不許可。'));
+ $get = DB::table('blg_comments')->select('isDeleted')->where('id', $r->id)->get();
+ foreach ($get as $i) if ($i->isDeleted == 1) return "不許可";
+ return DB::table('blg_comments')->where('id', $r->id)->update(['isDeleted' => 1]);
}
+ else return \Response::json(array('error' => '不許可。'));
}
}
- public function voteComment(Request $r) { // /api/rpc/site/comment/vote
+ public function voteComment (Request $r) {
$check = $this->objAuth->checkLegit($r->kero_token);
- if ($check == 0) {
- return \Response::json(array('error' => 'ログインされませんでした。'));
- }
+ if ($check == 0) return \Response::json(array('error' => 'ログインされませんでした。'));
else {
$valid = $this->objAuth->getPermissions($r->kero_token);
if ($valid['blg_addcomment'] == 1) {
- $get = DB::table('blg_comments')
- ->select('votes')
- ->where('id', $r->id)
- ->get();
-
+ $get = DB::table('blg_comments')->select('votes')->where('id', $r->id)->get();
$mod = 0;
-
- foreach ($get as $i) {
- $mod = $i->votes;
- }
-
- return DB::table('blg_comments')
- ->where('id', $r->id)
- ->update([
- 'votes' => $r->votemod
- ]);
- }
- else {
- return \Response::json(array('error' => '不許可。'));
+ foreach ($get as $i) { $mod = $i->votes; }
+ return DB::table('blg_comments')->where('id', $r->id)->update(['votes' => $r->votemod]);
}
+ else return \Response::json(array('error' => '不許可。'));
}
}
- // Pages
- public function getPagesInMenu() { // /api/rpc/site/page/get/menu
+ public function getPagesInMenu () {
$get = DB::table('blg_content')
->select('title', 'slug')
->where('public_status', 0)
@@ -953,54 +486,14 @@ class SiteController extends Controller {
$key = 0;
foreach ($get as $i) {
- array_push($res, [
- 'key' => $key,
- 'title' => $i->title,
- 'slug' => $i->slug
- ]);
+ array_push($res, ['key' => $key, 'title' => $i->title, 'slug' => $i->slug]);
$key++;
}
return $res;
}
- public function getPages() { // /api/rpc/site/page/all
- $get = DB::table('blg_content')
- ->select('id', 'title', 'slug', 'public_status', 'isMenu', 'message')
- ->where('public_status', 0)
- ->where('isPost', 0)
- ->orderBy('sortorder', 'asc')
- ->get();
-
- $res = array();
- $key = 0;
-
- foreach ($get as $i) {
- array_push($res, [
- 'key' => $key,
- 'id' => $i->id,
- 'title' => $i->title,
- 'slug' => $i->slug,
- 'public_status' => $i->public_status,
- 'isMenu' => $i->isMenu,
- 'message' => $i->message
- ]);
- $key++;
- }
-
- return $res;
- }
-
- public function getPageSlug($id) { // /api/rpc/site/page/get/id/id
- return DB::table('blg_content')
- ->select('slug')
- ->where('public_status', 0)
- ->where('isPost', 0)
- ->where('id', $id)
- ->get();
- }
-
- public function getPage2 ($slug, $kero) {
+ public function getPage ($slug, $kero) {
$valid = $this->objAuth->getPermissions($kero);
if ($valid['blg_editpage'] == 1) {
@@ -1021,188 +514,4 @@ class SiteController extends Controller {
->first();
}
}
-
- public function getPage($slug, Request $r) { // /api/rpc/site/page/get/slug/slug
- $valid = $this->objAuth->getPermissions($r->kero_token);
-
- if ($valid['blg_editpage'] == 1) {
- return DB::table('blg_content')
- ->select('id', 'title', 'slug', 'isMenu', 'public_status', 'message')
- ->where('isPost', 0)
- ->where('slug', $slug)
- ->orderBy('sortorder', 'asc')
- ->get();
- }
- else {
- return DB::table('blg_content')
- ->select('id', 'title', 'slug', 'message')
- ->where('public_status', 0)
- ->where('isPost', 0)
- ->where('slug', $slug)
- ->orderBy('sortorder', 'asc')
- ->get();
- }
- }
-
- public function newPage(Request $r) { // /api/rpc/site/page/new
- $check = $this->objAuth->checkLegit($r->kero_token);
-
- if ($check == 0) {
- return \Response::json(array('error' => 'ログインされませんでした。'));
- }
- else {
- $valid = $this->objAuth->getPermissions($r->kero_token);
-
- if ($valid['blg_addpage'] == 1) {
- $lorder = DB::table('blg_content')
- ->select('sortorder')
- ->where('isPost', 0)
- ->orderBy('sortorder', 'desc')
- ->first()->sortorder;
-
- $add = DB::table('blg_content')
- ->insert([
- 'user_id' => 0,
- 'isPost' => 0,
- 'title' => $r->title,
- 'slug' => $r->slug,
- 'post_date' => 0,
- 'publish_date' => 0,
- 'sortorder' => ($r->isMenu == 1 ? $lorder : 0),
- 'public_status' => $r->public_status,
- 'isMenu' => ($r->isMenu ? 1 : 0),
- 'message' => $r->message
- ]);
-
- return \Response::json($add);
- }
- else {
- return \Response::json(array('error' => '不許可。'));
- }
- }
- }
-
- public function editPage(Request $r) { // /api/rpc/site/page/edit
- $check = $this->objAuth->checkLegit($r->kero_token);
-
- if ($check == 0) {
- return \Response::json(array('error' => 'ログインされませんでした。'));
- }
- else {
- $valid = $this->objAuth->getPermissions($r->kero_token);
-
- if ($valid['blg_editpage'] == 1) {
- return DB::table('blg_content')
- ->where('id', $r->id)
- ->update([
- 'title' => $r->title,
- 'slug' => $r->slug,
- 'public_status' => $r->public_status,
- 'isMenu' => $r->isMenu,
- 'message' => $r->message
- ]);
- }
- else {
- return \Response::json(array('error' => '不許可。'));
- }
- }
- }
-
- public function deletePage(Request $r) { // /api/rpc/site/page/delete
- $check = $this->objAuth->checkLegit($r->kero_token);
-
- if ($check == 0) {
- return \Response::json(array('error' => 'ログインされませんでした。'));
- }
- else {
- $valid = $this->objAuth->getPermissions($r->kero_token);
-
- if ($valid['blg_delpage'] == 1) {
- return DB::table('blg_content')->where('id', $r->id)->delete();
- }
- else {
- return \Response::json(array('error' => '不許可。'));
- }
- }
- }
-
- // Contact Fields
- public function getContactFields() { // /api/rpc/site/contact/getcontactfields
- return false;
- }
-
- public function getContactField($id) { // /api/rpc/site/contact/getcontactfield/id
- return false;
- }
-
- // Portfolio Categories
- public function getPortfolioCategories() { // /api/rpc/site/portfolio/getportfoliocategories
- return false;
- }
-
- public function getPortfolioCategory($id) { // /api/rpc/site/portfolio/getportfoliocategory/id
- return false;
- }
-
- public function newPortfolioCategory(Request $r) { // /api/rpc/site/portfolio/newcategory
- return false;
- }
-
- public function editPortfolioCategory(Request $r) { // /api/rpc/site/portfolio/editcategory
- return false;
- }
-
- public function removePortfolioCategory(Request $r) { // /api/rpc/site/portfolio/removecategory
- return false;
- }
-
- public function deletePortfolioCategory(Request $r) { // /api/rpc/site/portfolio/deletecategory
- return false;
- }
-
- // Portfolio Items
- public function getPortfolioItems($id) { // /api/rpc/site/portfolio/getportfolioitems/id
- return false;
- }
-
- public function getPortfolioItem($id) { // /api/rpc/site/portfolio/getportfolioitems/id
- return false;
- }
-
- public function newPortfolioItem(Request $r) { // /api/rpc/site/portfolio/newitem
- return false;
- }
-
- public function editPortfolioItem(Request $r) { // /api/rpc/site/portfolio/edititem
- return false;
- }
-
- public function removePortfolioItem(Request $r) { // /api/rpc/site/portfolio/removeitem
- return false;
- }
-
- public function deletePortfolioItem(Request $r) { // /api/rpc/site/portfolio/deleteitem
- return false;
- }
-
- // Admin
- public function getSettings() { // /api/rpc/site/admin/getsettings
- return DB::table('blg_settings')
- ->select('sitename', 'description', 'tags', 'blog_status', 'homepage', 'announcement', 'theme', 'locale')
- ->get();
- }
-
- public function setSettings(Request $r) { // /api/rpc/site/admin/setsettings
- return DB::table('blg_settings')
- ->update([
- 'sitename' => $r->sitename,
- 'description' => $r->description,
- 'tags' => $r->tags,
- 'blog_status' => $r->blog_status,
- 'homepage' => $r->homepage,
- 'announcement' => $r->announcement,
- 'theme' => $r->theme,
- 'locale' => $r->locale
- ]);
- }
}
diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php
index 21bc965..2ecf9cf 100644
--- a/app/Http/Controllers/UserController.php
+++ b/app/Http/Controllers/UserController.php
@@ -23,155 +23,6 @@ class UserController extends Controller {
$this->objAuth = new AuthController();
}
- // User
- public function getUsersOnline() { // /api/rpc/user/user/getusersonline
- $cols = $this->getGroupColours()->toArray();
-
- $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')
- ->orderBy('display_name', 'asc')
- ->orderBy('username', 'asc')
- ->get(array(
- 'id',
- 'username',
- 'gender',
- 'perm_id',
- 'avatar',
- 'name_style',
- 'display_name',
- 'ostatus',
- 'ontime'
- ));
-
- $res = array();
-
- foreach ($get as $i) {
- $showName = "";
- $showCol = "";
- $showStatus = "";
- $showAva = "";
-
- if ($i->display_name !== '') {
- $showName = $i->display_name;
- }
- else {
- $showName = $i->username;
- }
-
- if ($i->name_style !== '') {
- $showCol = $i->name_style;
- }
- else {
- foreach($cols as $cl) {
- if ($cl->id === $i->perm_id) {
- if ($i->gender === 1) $showCol = $cl->colour_m;
- else if ($i->gender === 2) $showCol = $cl->colour_f;
- else $showCol = $cl->colour_u;
- }
- }
- }
-
- if ($i->ostatus == 1) {
- $showStatus = "green";
- }
- else if ($i->ostatus == 2) {
- $showStatus = "red";
- }
- else if ($i->ostatus == 3) {
- $showStatus = "yellow";
- }
- else {
- $showStatus = "dark";
- }
-
- if (empty($i->avatar)) {
- $showAva = "assets/avatars/haznoavaz.png";
- }
- else {
- $showAva = $i->avatar;
- }
-
- $res[] = array(
- 'id' => $i->id,
- 'display_name' => $showName,
- 'name_style' => $showCol,
- 'avatar' => $showAva,
- 'status' => $showStatus,
- 'ontime' => $i->ontime
- );
- }
-
- return $res;
- }
-
- public function updateUserStatus(Request $r) { // /api/rpc/user/user/updateuserstatus
- $check = $this->objAuth->checkLegit($r->kero_token);
-
- if ($check != 0) {
- return DB::table('usr_profile')
- ->where('user_id', $check)
- ->update([
- 'ostatus' => $r->ostatus
- ]);
- }
- }
-
- public function updateUserOnline(Request $r) { // /api/rpc/user/user/updateuseronline
- $check = $this->objAuth->checkLegit($r->kero_token);
-
- if ($check != 0) {
- return DB::table('usr_details')
- ->where('user_id', $check)
- ->update([
- 'ontime' => time()
- ]);
- }
- }
-
- public function getUsers(Request $r) { // /api/rpc/user/user/getusers
- $get = null;
-
- 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'
- );
-
- $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);
- }
-
- return $get;
- }
-
public function getLoggedUser ($id, $kero) {
$check = $this->objAuth->checkLegit($kero);
if ($check == 0) return 0;
@@ -186,7 +37,15 @@ class UserController extends Controller {
return $get;
}
- public function getUser2 ($id, $kero) {
+ public function getGroupName($id) {
+ return DB::table('usr_perm_module')->join('usr_perm_id', 'usr_perm_id.perm_id', '=', 'usr_perm_module.id')->where('user_id', $id)->get(array('name'));
+ }
+
+ public function getGroupColours() {
+ return DB::table('usr_perm_module')->select('id', 'colour_m', 'colour_f', 'colour_u')->get();
+ }
+
+ public function getUser ($id, $kero) {
$check = $this->objAuth->checkLegit($kero);
$valid = $this->objAuth->getPermissions($kero);
@@ -219,275 +78,8 @@ class UserController extends Controller {
return $get;
}
- public function getUser ($id, Request $r) { // /api/rpc/user/user/getuser/id/uid
- $getting = array(
- 'users.id',
- 'users.username',
- 'usr_perm_module.name as group_name',
- 'usr_profile.display_name',
- 'usr_profile.name_style',
- 'usr_perm_id.perm_id',
- 'usr_profile.member_title',
- 'usr_details.total_posts',
- 'usr_details.total_threads',
- 'usr_details.reg_date',
- 'usr_contacts.website_link',
- 'usr_contacts.website_name',
- 'usr_profile.post_style as poststyle',
- 'usr_profile.gender',
- 'usr_profile.location',
- 'usr_profile.birthday',
- 'usr_profile.bio',
- 'usr_profile.avatar',
- 'usr_profile.country',
- 'usr_contacts.website_link',
- 'usr_contacts.website_name',
- 'usr_contacts.youtube_link',
- 'usr_contacts.youtube_name',
- 'usr_contacts.niconico',
- 'usr_contacts.pixiv',
- 'usr_contacts.discord',
- 'usr_contacts.mastodon',
- 'usr_contacts.twitter'
- );
-
- $check = $this->objAuth->checkLegit($r->kero_token);
- $valid = $this->objAuth->getPermissions($r->kero_token);
- $cols = $this->getGroupColours()->toArray();
-
- if ($valid['usr_editother'] == 1 || $id == $check) {
- array_push($getting, 'users.password');
- }
-
- if ($valid['usr_emailshow'] == 1 || $id == $check) {
- array_push($getting, 'users.email');
- }
-
- if ($valid['usr_ipshow'] == 1 || $id == $check) {
- array_push($getting, 'usr_profile.ip_address');
- }
-
- if ($valid['usr_canwarn'] == 1 || $id == $check) {
- array_push($getting, 'usr_details.strikes');
- }
-
- return DB::table('users')
- ->join('usr_details', 'usr_details.user_id', '=', 'users.id')
- ->join('usr_profile', 'usr_profile.user_id', '=', 'users.id')
- ->join('usr_contacts', 'usr_contacts.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')
- ->where('users.id', $id)
- ->get($getting);
- }
-
- public function getExist($username, $email) { // /api/rpc/user/user/getexist/username/email
- $isExist = DB::table('users')
- ->select('username', 'email')
- ->where('username', mb_strtolower($username))
- ->orWhere('email', mb_strtolower($email))
- ->get();
-
- return $isExist->count();
- }
-
- public function getPostStyle($id) { // /api/rpc/user/user/getpoststyle/id
- return DB::table('users')
- ->select('header', 'footer')
- ->where('id', $id)
- ->get();
- }
-
- public function getGroups() { // /api/rpc/user/user/getgroups
- return DB::table('usr_perm_module')
- ->select('id', 'name', 'colour_m', 'colour_f', 'colour_u')
- ->get();
- }
-
- public function getGroupName($id) { // /api/rpc/user/user/getgroupname/id
- return DB::table('usr_perm_module')
- ->join('usr_perm_id', 'usr_perm_id.perm_id', '=', 'usr_perm_module.id')
- ->where('user_id', $id)
- ->get(array(
- 'name',
- // 'badge' (this is a pipeline feature, please don't uncomment for now!)
- ));
- }
-
- public function getGroupColours() { // /api/rpc/user/user/getgroupcolours
- return DB::table('usr_perm_module')
- ->select(
- 'id',
- 'colour_m',
- 'colour_f',
- 'colour_u'
- )
- ->get();
- }
-
- // Owner
- public function getOwnerList() { // /api/rpc/user/owner/getownerlist
- $user_data = DB::table('users')
- ->join('usr_profile', 'usr_profile.user_id', '=', 'users.id')
- ->orderBy('id', 'asc')
- ->get(array('id', 'username', 'display_name'));
-
- $result = array();
-
- foreach ($user_data as $u) {
- $name = '';
-
- if (!empty($u->display_name)) {
- $name = $u->display_name;
- }
- else {
- $name = $u->username;
- }
-
- array_push($result, [
- 'value' => $u->id,
- 'label' => $name,
- ]);
- }
-
- return $result;
- }
-
- public function countOwnersOfEntry($file_id) { // /api/rpc/user/owner/countownersofentry/id
- return DB::table('str_owners')
- ->where('file_id', $file_id)
- ->count();
- }
-
- public function getOwnersOfEntry($file_id) { // /api/rpc/user/owner/getownersofentry/id
- return DB::table('str_owners')
- ->join('str_file', 'str_owners.file_id', '=', 'str_file.id')
- ->join('users', 'str_owners.user_id', '=', 'users.id')
- ->join('usr_details', 'usr_details.user_id', '=', 'str_owners.user_id')
- ->join('usr_profile', 'usr_profile.user_id', '=', 'str_owners.user_id')
- ->join('usr_perm_id', 'usr_perm_id.user_id', '=', 'str_owners.user_id')
- ->where('file_id', $file_id)
- ->get(array(
- 'users.id',
- 'title',
- 'version',
- 'views',
- 'downloads',
- 'submit_date',
- 'last_date',
- 'username',
- 'avatar',
- 'perm_id',
- 'gender',
- 'display_name',
- 'name_style',
- ));
- }
-
- public function countEntriesOfOwner($user_id) { // /api/rpc/user/owner/countentriesofowner/id
- return DB::table('str_owners')
- ->where('user_id', $user_id)
- ->count();
- }
-
- public function getEntriesOfOwner($user_id) { // /api/rpc/user/owner/getentriesofowner/id
- return DB::table('str_owners')
- ->join('str_file', 'str_owners.file_id', '=', 'str_file.id')
- ->join('users', 'str_owners.user_id', '=', 'users.id')
- ->join('usr_details', 'usr_details.user_id', '=', 'str_owners.user_id')
- ->join('usr_profile', 'usr_profile.user_id', '=', 'str_owners.user_id')
- ->join('usr_perm_id', 'usr_perm_id.user_id', '=', 'str_owners.user_id')
- ->where('user_id', $user_id)
- ->get(array(
- 'users.id',
- 'title',
- 'version',
- 'views',
- 'downloads',
- 'submit_date',
- 'last_date',
- 'username',
- 'avatar',
- 'perm_id',
- 'gender',
- 'display_name',
- 'name_style',
- ));
- }
-
- public function getTotalPostCount($id) { // /api/rpc/user/user/gettotalpostcount/id
- return DB::table('usr_details')
- ->select('total_posts')
- ->where('user_id', $id)
- ->first()->total_posts;
- }
-
- public function getTotalTopicCount($id) { // /api/rpc/user/user/gettotaltopiccount/id
- return DB::table('usr_details')
- ->select('total_threads')
- ->where('user_id', $id)
- ->first()->total_threads;
- }
-
- public function addOwner(Request $r) { // /api/rpc/user/owner/addowner
- $check = $this->objAuth->checkLegit($r->kero_token);
-
- if ($check == 0) {
- return 'Err!';
- }
- else {
- $add = DB::table('str_owners')
- ->insert([
- 'user_id' => $r->user_id,
- 'file_id' => $r->file_id
- ]);
-
- return \Response::json($add);
- }
- }
-
- public function updateTotalPostCount(Request $r) { // /api/rpc/user/user/updatetotalpostcount
- $check = $this->objAuth->checkLegit($r->kero_token);
-
- if ($check == 0) {
- return 'Err!';
- }
- else {
- $getPC = $this->getTotalPostCount($check);
- $getPC++;
-
- return DB::table('usr_details')
- ->where('user_id', $check)
- ->update([
- 'total_posts' => $getPC
- ]);
- }
- }
-
- public function updateTotalTopicCount(Request $r) { // /api/rpc/user/user/updatetotaltopiccount
- $check = $this->objAuth->checkLegit($r->kero_token);
-
- if ($check == 0) {
- return 'Err!';
- }
- else {
- $getPC = $this->getTotalPostCount($r->user_id);
- $getTC = $this->getTotalTopicCount($r->user_id);
- $getPC++;
- $getTC++;
-
- return DB::table('usr_details')
- ->where('user_id', $r->user_id)
- ->update([
- 'total_posts' => $getPC,
- 'total_threads' => $getTC
- ]);
- }
- }
-
- public function getCountries() { // /api/rpc/user/user/getcountries
+ public function getCountries() {
$flags = File::files('assets/flags');
-
$res = array();
foreach ($flags as $flag) {
@@ -502,12 +94,10 @@ class UserController extends Controller {
return $res;
}
- public function avatarUpload(Request $r) { // /api/rpc/user/user/avatarupload
+ public function avatarUpload(Request $r) {
$check = $this->objAuth->checkLegit($r->kero_token);
- if ($check == 0) {
- return 'Err!';
- }
+ if ($check == 0) return 'Err!';
else {
$valid = $this->objAuth->getPermissions($r->kero_token);
$user = 0;
@@ -518,22 +108,14 @@ class UserController extends Controller {
if ($valid['usr_editprofile'] == 1) {
if (isset($r->filename)) {
if (!is_dir("assets/avatars/".$check)) {
- if (!mkdir("assets/avatars/".$check, 0755, true)) {
- return "Could not make folder ".$check."
";
- }
+ if (!mkdir("assets/avatars/".$check, 0755, true)) return "Could not make folder ".$check."
";
}
$img_dir = "assets/avatars/".$check."/";
$image = $img_dir . $r->filename;
- $imageFileType = array(
- 'image/png',
- 'image/jpeg',
- 'image/gif'
- );
+ $imageFileType = array('image/png', 'image/jpeg', 'image/gif');
- if (!in_array($r->filetype, $imageFileType)) {
- return "Only JPG, PNG, JPEG, and GIF are allowed.";
- }
+ if (!in_array($r->filetype, $imageFileType)) return "Only JPG, PNG, JPEG, and GIF are allowed.";
$fname = 'assets/avatars/'.$user.'/'.$r->filename;
$data = base64_decode(preg_replace('#^data:image/\w+;base64,#i', '', $r->thefile));
@@ -542,365 +124,7 @@ class UserController extends Controller {
return $r->filename;
}
}
- else {
- return 'Permission denied.';
- }
- }
- }
-
- public function editUser(Request $r) { // /api/rpc/user/user/edit
- $check = $this->objAuth->checkLegit($r->kero_token);
-
- if ($check == 0) {
- return 'Err!';
- }
- else {
- $valid = $this->objAuth->getPermissions($r->kero_token);
-
- if ($valid['usr_editprofile'] == 1) {
- if (isset($r->newPassword)) {
- DB::table('users')
- ->where('id', $r->id)
- ->update([
- 'password' => $r->newPassword
- ]);
- }
- if (isset($r->email)) {
- DB::table('users')
- ->where('id', $r->id)
- ->update([
- 'email' => $r->email
- ]);
- }
-
- if (
- isset($r->website_link) ||
- isset($r->website_name) ||
- isset($r->youtube_link) ||
- isset($r->youtube_name) ||
- isset($r->niconico) ||
- isset($r->pixiv) ||
- isset($r->discord) ||
- isset($r->mastodon) ||
- isset($r->twitter)
- ) {
- DB::table('usr_contacts')
- ->where('user_id', $r->id)
- ->update([
- 'website_link' => ($r->website_link != '' ? $r->website_link : ''),
- 'website_name' => ($r->website_name != '' ? $r->website_name : ''),
- 'youtube_link' => ($r->youtube_link != '' ? $r->youtube_link : ''),
- 'youtube_name' => ($r->youtube_name != '' ? $r->youtube_name : ''),
- 'niconico' => ($r->niconico != '' ? $r->niconico : ''),
- 'pixiv' => ($r->pixiv != '' ? $r->pixiv : ''),
- 'discord' => ($r->discord != '' ? $r->discord : ''),
- 'mastodon' => ($r->mastodon != '' ? $r->mastodon : ''),
- 'twitter' => ($r->twitter != '' ? $r->twitter : '')
- ]);
- }
-
- if (isset($r->group) && $valid['usr_editother']) {
- DB::table('usr_perm_id')
- ->where('user_id', $r->id)
- ->update([
- 'perm_id' => $r->group
- ]);
- }
-
- if (isset($r->avatar)) {
- DB::table('usr_profile')
- ->where('user_id', $r->id)
- ->update([
- 'avatar' => ($r->avatar != '' ? $r->avatar : '')
- ]);
- }
-
- if (isset($r->avatarRemove)) {
- if ($r->avatarRemove) {
- DB::table('usr_profile')
- ->where('user_id', $r->id)
- ->update([
- 'avatar' => ''
- ]);
- }
- }
-
- if (
- isset($r->gender) ||
- isset($r->aboutSelf) ||
- isset($r->signature) ||
- isset($r->poststyle) ||
- isset($r->nameStyle) ||
- isset($r->displayName) ||
- isset($r->memberTitle) ||
- isset($r->birthDay) ||
- isset($r->country)
- ) {
- DB::table('usr_profile')
- ->where('user_id', $r->id)
- ->update([
- 'gender' => $r->gender,
- 'bio' => ($r->aboutSelf != '' ? $r->aboutSelf : ''),
- 'post_style' => ($r->poststyle != '' ? $r->poststyle : ''),
- 'signature' => ($r->signature != '' ? $r->signature : ''),
- 'name_style' => ($r->nameStyle != '' ? $r->nameStyle : ''),
- 'display_name' => ($r->displayName != '' ? $r->displayName : ''),
- 'member_title' => ($r->memberTitle != '' ? $r->memberTitle : ''),
- 'birthday' => ($r->birthDay != 0 ? $r->birthDay : 0),
- 'country' => $r->country
- ]);
- }
-
- return 'Success!';
- }
- else {
- return 'Permission denied.';
- }
- }
- }
-
- public function countComments($id) { // /api/rpc/user/comment/count/id
- return DB::table('usr_comments')
- ->where('profile_id', $id)
- ->count();
- }
-
- public function getComments ($id, Request $r) { // /api/rpc/user/comment/get/id
- $cols = $this->getGroupColours()->toArray();
- $valid = $this->objAuth->getPermissions($r->kero_token);
-
- if ($valid['usr_viewcomment'] == 1) {
- $come = array();
- $get = DB::table('usr_comments')
- ->where('profile_id', $id)
- ->where('reply_id', 0)
- ->orderBy('usr_comments.postdate', 'asc')
- ->get(array(
- 'usr_comments.id as come_id',
- 'user_id',
- 'postdate',
- 'message',
- 'isEdit',
- 'isDel'
- ));
-
- // Foreach, new getter but check on replies, and only if isDel is 0.
- foreach ($get as $g) {
- $user = $this->getUser($g->user_id, $r)->toArray();
- $showName = "";
- $showCol = "";
-
- if ($user[0]->display_name !== '') {
- $showName = $user[0]->display_name;
- }
- else {
- $showName = $user[0]->username;
- }
-
- if ($user[0]->name_style !== '') {
- $showCol = $user[0]->name_style;
- }
- else {
- foreach($cols as $cl) {
- if ($cl->id === $user[0]->perm_id) {
- if ($user[0]->gender === 1) $showCol = $cl->colour_m;
- else if ($user[0]->gender === 2) $showCol = $cl->colour_f;
- else $showCol = $cl->colour_u;
- }
- }
- }
-
- setlocale(LC_ALL, 'ja_JP.utf8');
-
- $come[] = array(
- 'come_id' => $g->come_id,
- 'user_id' => $g->user_id,
- 'name' => $showName,
- 'avatar' => ($user[0]->avatar != '' ? $user[0]->avatar : 'assets/avatars/haznoavaz.png'),
- 'col' => $showCol,
- 'message' => $g->message,
- 'postdate' => strftime('%Y/%m/%d(%a) %H:%M:%S %Z', $g->postdate),
- 'isEdit' => $g->isEdit,
- 'isDel' => $g->isDel
- );
- }
-
- return $come;
- }
- else {
- return 'Permission denied.';
- }
- }
-
- public function getReplies ($id, Request $r) { // /api/rpc/user/comment/reply/id
- $cols = $this->getGroupColours()->toArray();
- $valid = $this->objAuth->getPermissions($r->kero_token);
-
- if ($valid['usr_viewcomment'] == 1) {
- $come = array();
- $get = DB::table('usr_comments')
- ->where('reply_id', $id)
- ->orderBy('usr_comments.postdate', 'asc')
- ->get(array(
- 'reply_id',
- 'usr_comments.id as come_id',
- 'user_id',
- 'postdate',
- 'message',
- 'isEdit',
- 'isDel'
- ));
-
- // Foreach, new getter but check on replies, and only if isDel is 0.
- foreach ($get as $g) {
- $user = $this->getUser($g->user_id, $r)->toArray();
- $showName = "";
- $showCol = "";
-
- if ($user[0]->display_name !== '') {
- $showName = $user[0]->display_name;
- }
- else {
- $showName = $user[0]->username;
- }
-
- if ($user[0]->name_style !== '') {
- $showCol = $user[0]->name_style;
- }
- else {
- foreach($cols as $cl) {
- if ($cl->id === $user[0]->perm_id) {
- if ($user[0]->gender === 1) $showCol = $cl->colour_m;
- else if ($user[0]->gender === 2) $showCol = $cl->colour_f;
- else $showCol = $cl->colour_u;
- }
- }
- }
-
- setlocale(LC_ALL, 'ja_JP.utf8');
-
- $come[] = array(
- 'reply_id' => $g->reply_id,
- 'come_id' => $g->come_id,
- 'user_id' => $g->user_id,
- 'name' => $showName,
- 'avatar' => ($user[0]->avatar != '' ? $user[0]->avatar : 'assets/avatars/haznoavaz.png'),
- 'col' => $showCol,
- 'message' => $g->message,
- 'postdate' => strftime('%Y/%m/%d(%a) %H:%M:%S %Z', $g->postdate),
- 'isEdit' => $g->isEdit,
- 'isDel' => $g->isDel
- );
- }
-
- return $come;
- }
- else {
- return 'Permission denied.';
- }
- }
-
- public function addComment (Request $r) { // /api/rpc/user/comment/add
- $check = $this->objAuth->checkLegit($r->kero_token);
-
- if ($check == 0) {
- return 'Err!';
- }
- else {
- $valid = $this->objAuth->getPermissions($r->kero_token);
-
- if ($valid['usr_addcomment'] == 1) {
- $add = DB::table('usr_comments')
- ->insertGetId([
- 'user_id' => $check,
- 'profile_id' => $r->profile_id,
- 'reply_id' => ($r->reply_id > 0 ? $r->reply_id : 0),
- 'postdate' => time(),
- 'message' => $r->message,
- 'isEdit' => 0,
- 'isDel' => 0
- ]);
-
- if ($check != $r->profile_id) $this->addNotification($r, $r->profile_id, 2, '新規プロファイルコメント', 'profile/'.$r->profile_id, 'comment-'.$add);
-
- return \Response::json($add);
- }
- else {
- return 'Permission denied.';
- }
- }
- }
-
- public function editComment (Request $r) { // /api/rpc/user/comment/edit
- $check = $this->objAuth->checkLegit($r->kero_token);
-
- if ($check == 0) {
- return 'Err!';
- }
- else {
- $valid = $this->objAuth->getPermissions($r->kero_token);
-
- if ($valid['usr_editowncomment'] == 1) {
- DB::table('usr_comments')
- ->where('profile_id', $r->profile_id)
- ->update([
- 'message' => $r->message,
- 'isEdit' => 1
- ]);
-
- return 'Success!';
- }
- else {
- return 'Permission denied.';
- }
- }
- }
-
- public function deleteComment (Request $r) { // /api/rpc/user/comment/delete
- $check = $this->objAuth->checkLegit($r->kero_token);
-
- if ($check == 0) {
- return 'Err!';
- }
- else {
- $valid = $this->objAuth->getPermissions($r->kero_token);
-
- if ($valid['usr_delcomment'] == 1) {
- DB::table('usr_comments')
- ->where('id', $r->id)
- ->update([
- 'isDel' => 1
- ]);
-
- return 'Success!';
- }
- else {
- return 'Permission denied.';
- }
- }
- }
-
- public function undeleteComment (Request $r) { // /api/rpc/user/comment/undelete
- $check = $this->objAuth->checkLegit($r->kero_token);
-
- if ($check == 0) {
- return 'Err!';
- }
- else {
- $valid = $this->objAuth->getPermissions($r->kero_token);
-
- if ($valid['usr_delcomment'] == 1) {
- DB::table('usr_comments')
- ->where('id', $r->id)
- ->update([
- 'isDel' => 0
- ]);
-
- return 'Success!';
- }
- else {
- return 'Permission denied.';
- }
+ else return 'Permission denied.';
}
}
@@ -911,23 +135,14 @@ class UserController extends Controller {
if ($check != 0) {
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();
-
+ $get = DB::table('usr_notification')->select('id', 'app_id', 'text', 'section', 'goto')->where('user_id', $check)->get();
$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;
- $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);
}
}
@@ -937,35 +152,23 @@ class UserController extends Controller {
else return array();
}
- public function addNotification(Request $r, $uid, $aid, $txt, $sec, $goto) { // /api/rpc/user/notification/add
+ public function addNotification(Request $r, $uid, $aid, $txt, $sec, $goto) {
$check = $this->objAuth->checkLegit($r->kero_token);
if ($check != 0) {
- $add = DB::table('usr_notification')
- ->insert([
- 'user_id' => $uid,
- 'app_id' => $aid,
- 'text' => $txt,
- 'section' => $sec,
- 'goto' => $goto
- ]);
-
+ $add = DB::table('usr_notification')->insert(['user_id' => $uid, 'app_id' => $aid, 'text' => $txt, 'section' => $sec, 'goto' => $goto]);
if (Cache::has('getNotification')) Cache::forget('getNotification');
-
return 1;
}
}
- public function delNotification(Request $r) { // /api/rpc/user/notification/del
+ public function delNotification(Request $r) {
$check = $this->objAuth->checkLegit($r->kero_token);
if ($check != 0) {
- return DB::table('usr_notification')
- ->where('id', $r->id)
- ->where('user_id', $check)
- ->delete();
-
+ $del = DB::table('usr_notification')->where('id', $r->id)->where('user_id', $check)->delete();
if (Cache::has('getNotification')) Cache::forget('getNotification');
+ return $del;
}
}
}
diff --git a/routes/api/board.php b/routes/api/board.php
deleted file mode 100644
index 0558c7a..0000000
--- a/routes/api/board.php
+++ /dev/null
@@ -1,76 +0,0 @@
-middleware('auth');
-Route::get('/api/rpc/store/entry/getallapprovedentries', 'StoreController@getAllApprovedEntries');
-Route::get('/api/rpc/store/entry/getallbrokenentries', 'StoreController@getAllBrokenEntries');
-Route::get('/api/rpc/store/entry/getallpendingentries', 'StoreController@getAllPendingEntries');
-Route::get('/api/rpc/store/entry/getnewentries', 'StoreController@getNewEntries');
-Route::get('/api/rpc/store/entry/gethotentries', 'StoreController@getHotEntries');
-Route::get('/api/rpc/store/entry/getentriespageall/{cat}/{from}/{to}', 'StoreController@getEntriesPageAll');
-Route::get('/api/rpc/store/entry/getentriespageapproved/{cat}/{from}/{to}', 'StoreController@getEntriesPageApproved');
-Route::get('/api/rpc/store/entry/getentriespagepopularview/{cat}/{from}/{to}', 'StoreController@getEntriesPagePopularView');
-Route::get('/api/rpc/store/entry/getentriespagepopulardownload/{cat}/{from}/{to}', 'StoreController@getEntriesPagePopularDownload');
-Route::get('/api/rpc/store/entry/getdownloadcount/{id}', 'StoreController@getDownloadCount');
-Route::post('/api/rpc/store/entry/updatedownloadcount', 'StoreController@updateDownloadCount');
-Route::get('/api/rpc/store/entry/getnotice/{id}', 'StoreController@getNotice');
-Route::get('/api/rpc/store/entry/getchangelog/{id}', 'StoreController@getChangelog');
-Route::get('/api/rpc/store/entry/getfilesofentry/{id}', 'StoreController@getFilesOfEntry');
-Route::get('/api/rpc/store/entry/getnextentryid', 'StoreController@getNextEntryId');
-Route::get('/api/rpc/store/entry/getentry/{id}/{mode}', 'StoreController@getEntry');
-Route::get('/api/rpc/store/entry/getentryname/{id}', 'StoreController@getEntryName');
-Route::get('/api/rpc/store/entry/getentriesincategory/{cat_id}', 'StoreController@getEntriesInCategory');
-Route::get('/api/rpc/store/entry/countentriesincategory/{cat_id}', 'StoreController@countEntriesInCategory');
-Route::get('/api/rpc/store/entry/countentriesincategoryfull/{cat_id}', 'StoreController@countEntriesInCategoryFull');
-Route::post('/api/rpc/store/entry/makedir', 'StoreController@makedir');
-Route::post('/api/rpc/store/entry/upload', 'StoreController@uploadEntry');
-Route::post('/api/rpc/store/entry/update', 'StoreController@updateEntry');
-Route::post('/api/rpc/store/entry/restore', 'StoreController@restoreEntry');
-Route::post('/api/rpc/store/entry/remove', 'StoreController@removeEntry');
-
-// ルート
-Route::get('/api/rpc/store/browse/browsepermissions/{uid}', 'StoreController@browsePermissions');
diff --git a/routes/api/user.php b/routes/api/user.php
index 53a81fc..7d2025a 100644
--- a/routes/api/user.php
+++ b/routes/api/user.php
@@ -1,46 +1,4 @@