またまた掃除

このコミットが含まれているのは:
テクニカル諏訪子 2020-10-06 11:22:46 +09:00
コミット 565b2c1179
24個のファイルの変更834行の追加5563行の削除

ファイルの表示

@ -19,16 +19,10 @@ class AuthController extends Controller {
}
public function checkSelf(Request $r) { // /api/auth/checkself
$check = $this->checkLegit($r->kero_token);
$check = checkLegit($r->kero_token);
return array($check);
}
public function checkLegit ($t) {
if (!isset($t) || empty($t) || is_null($t)) return 0;
$check = DB::table('users')->select('id')->where('kero_token', $t)->first();
return $check->id;
}
public function getPerms(Request $r) { // /api/auth/getpermissions
$check = $this->getPermissions($r->kero_token);
@ -36,7 +30,7 @@ class AuthController extends Controller {
}
public function getPermissions($token) {
$check = $this->checkLegit($token);
$check = checkLegit($token);
$perm = DB::table('usr_perm_id')
->select('perm_id')

ファイル差分が大きすぎるため省略します 差分を読み込み

46
app/Http/Controllers/Home/Comment.php ノーマルファイル
ファイルの表示

@ -0,0 +1,46 @@
<?php
namespace App\Http\Controllers\Home;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
// use Illuminate\Support\Facades\Log;
class Comment {
public function __construct () {
}
public function add (Request $r) {
$com = $r->comment;
if ($r->isvideo == 'f') $id = DB::table('blg_content')->select('id')->where('slug', $r->slug)->first()->id;
$shadow = DB::table('blg_blacklist')->where('ipaddress', getIp())->first();
if ($shadow && !$shadow->isShadow) return array('status' => '0101FF', 'message' => '失礼しますが、あなたはBANされていましたので、コメントを保存できません。');
$add = DB::table('blg_comments')
->insertGetId([
'user_id' => ($r->user_id != 0 ?: null),
'post_id' => ($r->isvideo == 'f' ? $id : 0),
'video_id' => ($r->isvideo == 't' ? $r->slug : ''),
'name' => $com['name'],
'email' => $com['mail'],
'message' => $com['text'],
'created' => time(),
'ipaddress' => getIp(),
'isShadow' => ($shadow ? 0 : 1)
]);
// 返事だったら、メールを送って
$res = DB::table('blg_comments')->select('id', 'name', 'created', 'message')->where('id', $add)->first();
$res->created = date('Y年m月d日 H:i:s', $res->created);
if (count(userDetail($r->user_id)) > 0) {
$det = userDetail($r->user_id);
$res->user_id = $det['user_id'];
$res->showname = $det['showname'];
$res->showcol = $det['showcol'];
$res->avatar = $det['avatar'];
}
return array('status' => '010100', 'message' => 'OK', 'result' => $res);
}
}

187
app/Http/Controllers/Home/Content.php ノーマルファイル
ファイルの表示

@ -0,0 +1,187 @@
<?php
namespace App\Http\Controllers\Home;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
// use Illuminate\Support\Facades\Log;
class Content {
private $valid;
private $menu;
private $user;
public function __construct ($v, $m, $u) {
$this->valid = $v;
$this->menu = $m;
$this->user = $u;
}
public function add (Request $r) {
if ($this->user && ($this->user->perm['blg_addpost'] || $this->user->perm['blg_addpage'])) {
$err = '';
$res = '';
$frm = array(
'user_id' => $this->user->id,
'title' => '',
'slug' => '',
'public_status' => 0,
'publish_date' => null,
'isMenu' => null,
'isPost' => 1,
'message' => ''
);
if (isset($r->submit)) {
// JS→HTML→PHPの修正
$sav = $r->publish_date;
if (is_null($r->public_status)) $r->public_status = 0;
$r->public_status = (int)$r->public_status;
if (is_null($r->isPost)) $r->isPost = 0;
$r->isPost = (int)$r->isPost;
if ($r->public_status == 1 && !is_null($r->publish_date)) {
$r->publish_date = str_replace('年', '-', $r->publish_date);
$r->publish_date = str_replace('月', '-', $r->publish_date);
$r->publish_date = str_replace('日', '', $r->publish_date);
$r->publish_date = strtotime($r->publish_date);
}
else if ($r->public_status == 1 && is_null($r->publish_date)) $r->public_status = 0;
else if ($r->public_status != 1 && is_null($r->publish_date)) $r->publish_date = time();
if (is_null($r->isMenu)) $r->isMenu = false;
if ($r->isMenu == 'on') $r->isMenu = true;
else $r->isMenu = false;
$r->isMenu = (int)$r->isMenu;
// フォームの値を保存して
$frm['title'] = $r->title;
$frm['slug'] = $r->slug;
$frm['public_status'] = $r->public_status;
$frm['publish_date'] = $r->publish_date;
$frm['isMenu'] = $r->isMenu;
$frm['isPost'] = $r->isPost;
$frm['message'] = $r->message;
// 件名、文章又はスラッグがなければ、エラーを出て
$verify = array('件名' => $r->title, 'スラッグ' => $r->slug, '文章' => $r->message);
$incomplete = array();
foreach ($verify as $k => $v) { if (is_null($v) || empty($v) || !isset($v)) $incomplete[] = $k; }
if (count($incomplete) > 0) $err = implode('、', $incomplete).'をご入力下さい。';
// スラッグが既に存在したら、エラーを出て
$sl = DB::table('blg_content')->select('slug')->where('slug', $r->slug)->first();
if ($sl && $sl->slug == $r->slug) $err = 'このスラッグがもう存在しています。';
// エラーがあったら、フォームに戻って。なければ、データベースに保存したり、ページ又はポストへ移転して
if (!empty($err)) return view('pages.site.contentadd', ['res' => $res, 'menu' => $this->menu, 'user' => $this->user, 'err' => $err, 'frm' => $frm]);
else {
// データベースに追加できるには、値を修正して
$gs = DB::table('blg_content')->select('sortorder')->orderBy('sortorder', 'desc')->first();
if (!isset($r->publish_date)) $frm['publish_date'] = ($r->isPost == 1 ? time() : 0);
if (!isset($r->public_status)) $frm['public_status'] = 0;
if (!isset($r->isPost)) $frm['isPost'] = 0;
if (!isset($r->isMenu)) $frm['isMenu'] = 0;
$frm['post_date'] = ($r->isPost == 1 ? time() : 0);
$frm['sortorder'] = ($r->isPost == 0 ? $gs->sortorder+1 : 0);
// できたの?
if ($res = $this->objSite->addContent($frm)) return redirect(($r->isPost == 1 ? '/blog/' : '/').$r->slug);
else {
// やれやれ…
$frm['publish_date'] = $sav;
unset($frm['post_date']);
unset($frm['sortorder']);
return view('pages.site.contentadd', ['res' => $res, 'menu' => $this->menu, 'user' => $this->user, 'err' => $err, 'frm' => $res['err']]);
}
}
}
return view('pages.site.contentadd', ['res' => $res, 'menu' => $this->menu, 'user' => $this->user, 'err' => $err, 'frm' => $frm]);
}
return redirect('');
}
public function delete (Request $r) {
if (($this->valid['blg_delpost'] && $bdl['isPost'] == 1) || ($this->valid['blg_delpage'] && $bdl['isPost'] == 0)) {
return DB::table('blg_content')->where('slug', $r->slug)->delete();
}
return 0;
}
public function edit (Request $r) {
if ($this->user && ($this->user->perm['blg_editpost'] || $this->user->perm['blg_editpage'])) {
$frm = DB::table('blg_content')->where('slug', $r->slug)->first();////////////////////
$err = '';
$res = '';
if (isset($r->submit)) {
// JS→HTML→PHPの修正
$sav = $r->publish_date;
if (is_null($r->public_status)) $r->public_status = 0;
$r->public_status = (int)$r->public_status;
if (is_null($r->isPost)) $r->isPost = 0;
$r->isPost = (int)$r->isPost;
if ($r->public_status == 1 && !is_null($r->publish_date)) {
$r->publish_date = str_replace('年', '-', $r->publish_date);
$r->publish_date = str_replace('月', '-', $r->publish_date);
$r->publish_date = str_replace('日', '', $r->publish_date);
$r->publish_date = strtotime($r->publish_date);
}
else if ($r->public_status == 1 && is_null($r->publish_date)) $r->public_status = 0;
else if ($r->public_status != 1 && is_null($r->publish_date)) $r->publish_date = time();
if (is_null($r->isMenu)) $r->isMenu = false;
if ($r->isMenu == 'on') $r->isMenu = true;
else $r->isMenu = false;
$r->isMenu = (int)$r->isMenu;
// フォームの値を保存して
$frm['title'] = $r->title;
$frm['slug'] = $r->slug;
$frm['public_status'] = $r->public_status;
$frm['publish_date'] = $r->publish_date;
$frm['isMenu'] = $r->isMenu;
$frm['isPost'] = $r->isPost;
$frm['message'] = $r->message;
// 件名、文章又はスラッグがなければ、エラーを出て
$verify = array('件名' => $r->title, 'スラッグ' => $r->slug, '文章' => $r->message);
$incomplete = array();
foreach ($verify as $k => $v) { if (is_null($v) || empty($v) || !isset($v)) $incomplete[] = $k; }
if (count($incomplete) > 0) $err = implode('、', $incomplete).'をご入力下さい。';
// スラッグが既に存在したら、エラーを出て
$sl = DB::table('blg_content')->select('slug')->where('slug', $r->slug)->first();
if ($sl && $sl->slug == $r->slug) $err = 'このスラッグがもう存在しています。';
// エラーがあったら、フォームに戻って。なければ、データベースに保存したり、ページ又はポストへ移転して
if (!empty($err)) return view('pages.site.contentadd', ['res' => $res, 'menu' => $this->menu, 'user' => $this->user, 'err' => $err, 'frm' => $frm]);
else {
// データベースに追加できるには、値を修正して
$gs = DB::table('blg_content')->select('sortorder')->orderBy('sortorder', 'desc')->first();
if (!isset($r->publish_date)) $frm['publish_date'] = ($r->isPost == 1 ? time() : 0);
if (!isset($r->public_status)) $frm['public_status'] = 0;
if (!isset($r->isPost)) $frm['isPost'] = 0;
if (!isset($r->isMenu)) $frm['isMenu'] = 0;
$frm['post_date'] = ($r->isPost == 1 ? time() : 0);
$frm['sortorder'] = ($r->isPost == 0 ? $gs->sortorder+1 : 0);
// できたの?
if ($res = $this->objSite->addContent($frm)) return redirect(($r->isPost == 1 ? '/blog/' : '/').$r->slug);
else {
// やれやれ…
$frm['publish_date'] = $sav;
unset($frm['post_date']);
unset($frm['sortorder']);
return view('pages.site.contentadd', ['res' => $res, 'menu' => $this->menu, 'user' => $this->user, 'err' => $err, 'frm' => $res['err']]);
}
}
}
return view('pages.site.contentadd', ['res' => $res, 'menu' => $this->menu, 'user' => $this->user, 'err' => $err, 'frm' => $frm]);
}
return redirect('');
}
}

102
app/Http/Controllers/Home/Index.php ノーマルファイル
ファイルの表示

@ -0,0 +1,102 @@
<?php
namespace App\Http\Controllers\Home;
use Illuminate\Support\Facades\DB;
// use Illuminate\Support\Facades\Log;
use App\Http\Controllers\UserController;
class Index {
private $objUser;
private $valid;
private $menu;
private $user;
public function __construct ($v, $m, $u) {
$this->objUser = new UserController();
$this->valid = $v;
$this->menu = $m;
$this->user = $u;
}
public function index () {
$get = DB::table('blg_content')->where('isPost', 1);
if ($this->valid['blg_addpost'] == 0 && $this->valid['blg_editpost'] == 0) $get = $get->where('public_status', 0);
$get = $get->orderBy('publish_date', 'desc')->get();
setlocale(LC_ALL, 'ja_JP.utf8');
return view('pages.site.index', ['res' => $get, 'menu' => $this->menu, 'user' => $this->user]);
}
public function page ($slug) {
$sel = array('id', 'title', 'slug', 'isMenu', 'public_status', 'message');
$res = DB::table('blg_content')->select($sel);
if ($this->valid['blg_editpage'] == 0) $res = $res->where('public_status', 0);
$res = $res->where('isPost', 0)->where('slug', $slug)->orderBy('sortorder', 'asc')->first();
if (!$res) return notfound($this->menu, $this->user, $res);
return view('pages.site.page', ['res' => $res, 'menu' => $this->menu, 'user' => $this->user]);
}
public function post ($slug, $kero) {
$get = DB::table('blg_content');
if ($this->valid['blg_editpost'] == 0) $get = $get->where('public_status', 0);
$get = $get->where('isPost', 1)->where('slug', $slug)->first();
$ucol = $this->objUser->getGroupColours();
setlocale(LC_ALL, 'ja_JP.utf8');
$get->showName = '';
$get->showCol = '';
$get->comments = DB::table('blg_comments')->where('post_id', $get->id)->orderBy('id', 'asc')->get();
$get->username = DB::table('users')->select('username')->where('id', $get->user_id)->first()->username;
$get->perm_id = DB::table('usr_perm_id')->select('perm_id')->where('user_id', $get->user_id)->first()->perm_id;
$p = DB::table('usr_profile')->select('gender', 'avatar', 'name_style', 'display_name')->where('user_id', $get->user_id)->first();
$get->gender = $p->gender;
$get->avatar = $p->avatar;
$get->name_style = $p->name_style;
$get->display_name = $p->display_name;
foreach ($get->comments as $k => $c) {
if (count(userDetail($c->user_id)) > 0) {
$det = userDetail($c->user_id);
$c->user_id = $det['user_id'];
$c->showname = $det['showname'];
$c->showcol = $det['showcol'];
$c->avatar = $det['avatar'];
}
if ($c->isShadow == 0) {
if (getIp() != $c->ipaddress) unset($get->comments[$k]);
}
else {
unset($c->email);
unset($c->ipaddress);
unset($c->isShadow);
$c->created = date('Y年m月d日 H:i:s', $c->created);
}
}
if (!empty($get->display_name)) $get->showname = $get->display_name;
else $get->showname = $get->username;
if (!empty($get->name_style)) $get->showcol = $get->name_style;
else {
foreach ($ucol as $j) {
if ($j->id == $get->perm_id) {
if ($get->gender == 1) $get->showcol = $j->colour_m;
else if ($get->gender == 2) $get->showcol = $j->colour_f;
else $get->showcol = $j->colour_u;
}
}
}
$get->user = userDetail(null, $kero);
$get->post_date = strftime('%Y/%m/%d(%a) %H:%M:%S %Z', $get->post_date);
$get->publish_date = strftime('%Y/%m/%d(%a) %H:%M:%S %Z', $get->publish_date);
if (!$get) return notfound($this->menu, $this->user, $get);
return view('pages.site.post', ['res' => $get, 'menu' => $this->menu, 'user' => $this->user]);
}
}

ファイルの表示

@ -1,64 +1,65 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
// use Illuminate\Support\Facades\Log;
use App\Http\Controllers\AuthController;
use App\Http\Controllers\SiteController;
use App\Http\Controllers\UserController;
use Illuminate\Support\Facades\Log;
use App\Http\Controllers\Home\Comment;
use App\Http\Controllers\Home\Content;
use App\Http\Controllers\Home\Index;
class HomeController extends Controller {
private $objAuth;
private $objSite;
private $objUser;
private $valid;
private $menu;
private $cook;
private $id;
private $user;
public function __construct() {
public function __construct () {
$this->objAuth = new AuthController();
$this->objSite = new SiteController();
$this->objUser = new UserController();
$this->valid = $this->objAuth->getPermissions((isset($_COOKIE['kero_token']) ? $_COOKIE['kero_token'] : ''));
$this->menu = getPagesInMenu();
$this->cook = (isset($_COOKIE['kero_token']) ? $_COOKIE['kero_token'] : '');
$this->id = $this->objAuth->checkLegit($this->cook);
$this->id = checkLegit($this->cook);
$this->user = $this->objUser->getLoggedUser($this->id, $this->cook);
}
public function index () {
$r = new Index($this->valid, $this->menu, $this->user);
return $r->index();
}
public function post ($slug) {
$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]);
$r = new Index($this->valid, $this->menu, $this->user);
return $r->post($slug, $this->cook);
}
public function page ($slug) {
$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]);
$r = new Index($this->valid, $this->menu, $this->user);
return $r->page($slug);
}
public function addContent (Request $r) {
if ($this->user && ($this->user['blg_addpost'] || $this->user['blg_addpage'])) {
$bdl = array();
$res = $this->objSite->addContent($bdl);
if ($res) {
return redirect('/blog/'.$r->slug);
}
$err = $res['err'];
return view('pages.site.contentadd', ['res' => $res, 'menu' => $this->menu, 'user' => $this->user, 'err' => $err]);
}
return redirect('');
public function newComment (Request $rr) {
$r = new Comment();
return $r->add($rr);
}
public function notfound () {
return view('pages.site.notfound', ['menu' => $this->menu, 'user', $this->user]);
public function addContent ($bdl) {
$r = new Content($this->valid, $this->menu, $this->user);
return $r->add($bdl);
}
public function editContent ($bdl) {
$r = new Content($this->valid, $this->menu, $this->user);
return $r->edit($bdl);
}
public function delContent ($bdl) {
$r = new Content($this->valid, $this->menu, $this->user);
return $r->delete($bdl);
}
}

ファイルの表示

@ -1,450 +0,0 @@
<?php
namespace App\Http\Controllers;
use App\Models\ForUser;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Storage;
use Illuminate\Http\Request;
use Illuminate\Contracts\Routing\ResponseFactory;
use Illuminate\Support\Facades\Log;
use App\Http\Controllers\AuthController;
use App\Http\Controllers\UserController;
class ImageController extends Controller {
private $objAuth;
private $objUser;
public function __construct() {
$this->objAuth = new AuthController();
$this->objUser = new UserController();
}
public function getUserWithUploads(Request $r) { // /api/rpc/image/get/userwithuploads
$valid = $this->objAuth->getPermissions($r->kero_token);
if ($valid['img_viewimg'] == 1) {
$cols = $this->objUser->getGroupColours()->toArray();
$imgs = File::directories('storage/assets/images');
$res = array();
foreach($imgs as $img) {
$usr = basename($img);
$protocol = isset($_SERVER["HTTPS"]) ? 'https' : 'http';
if ($usr != 0) {
$user = $this->objUser->getUser($usr, $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;
}
}
}
}
else {
$showName = "";
$showCol = "";
}
$res[] = array(
'id' => basename($img),
'avatar' => $protocol.'://'.$_SERVER['SERVER_NAME'].'/'.($user[0]->avatar != '' ? $user[0]->avatar : '/img/noicon.webp'),
'userCol' => $showCol,
'userName' => $showName
);
}
return $res;
}
}
public function getAll(Request $r) { // /api/rpc/image/get/all
$valid = $this->objAuth->getPermissions($r->kero_token);
if ($valid['img_viewimg'] == 1) {
$cols = $this->objUser->getGroupColours()->toArray();
$imgs = File::files('storage/assets/images/*');
$res = array();
foreach ($imgs as $img) {
$usr = preg_split("#/#", $img->getPathname());
$protocol = isset($_SERVER["HTTPS"]) ? 'https' : 'http';
if ($usr[3] != 0) {
$user = $this->objUser->getUser($usr[3], $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;
}
}
}
}
else {
$showName = "";
$showCol = "";
}
$res[] = array(
'id' => $usr[3],
'avatar' => $protocol.'://'.$_SERVER['SERVER_NAME'].'/'.($user[0]->avatar != '' ? $user[0]->avatar : '/img/noicon.webp'),
'name' => $img->getFilename(),
'userCol' => $showCol,
'userName' => $showName,
'image' => $protocol.'://'.$_SERVER['SERVER_NAME'].'/'.$img->getPathname()
);
}
return $res;
}
}
public function getOwn(Request $r) { // /api/rpc/image/get/own
$check = $this->objAuth->checkLegit($r->kero_token);
if ($check == 0) {
return 'Err!';
}
else {
$valid = $this->objAuth->getPermissions($r->kero_token);
if ($valid['img_viewimg'] == 1) {
$cols = $this->objUser->getGroupColours()->toArray();
$imgs = File::files('storage/assets/images/'.$check);
$res = array();
if ($check == 0) {
return 'Err!';
}
else {
foreach ($imgs as $img) {
$usr = preg_split("#/#", $img->getPathname());
$protocol = isset($_SERVER["HTTPS"]) ? 'https' : 'http';
if ($usr[3] == $check) {
$user = $this->objUser->getUser($usr[3], $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;
}
}
}
}
else {
$showName = "";
$showCol = "";
}
$res[] = array(
'id' => $usr[3],
'avatar' => $protocol.'://'.$_SERVER['SERVER_NAME'].'/'.($user[0]->avatar != '' ? $user[0]->avatar : '/img/noicon.webp'),
'name' => $img->getFilename(),
'userCol' => $showCol,
'userName' => $showName,
'image' => $protocol.'://'.$_SERVER['SERVER_NAME'].'/'.$img->getPathname()
);
}
}
return $res;
}
else {
return 'Permission denied.';
}
}
}
public function getUser($id, Request $r) { // /api/rpc/image/get/user/id
$valid = $this->objAuth->getPermissions($r->kero_token);
if ($valid['img_viewimg'] == 1) {
$cols = $this->objUser->getGroupColours()->toArray();
$imgs = File::files('storage/assets/images/'.$id);
$res = array();
foreach ($imgs as $img) {
$usr = preg_split("#/#", $img->getPathname());
$protocol = isset($_SERVER["HTTPS"]) ? 'https' : 'http';
if ($usr[3] != 0) {
$user = $this->objUser->getUser($usr[3], $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;
}
}
}
}
else {
$showName = "";
$showCol = "";
}
$res[] = array(
'id' => $id,
'avatar' => $protocol.'://'.$_SERVER['SERVER_NAME'].'/'.($user[0]->avatar != '' ? $user[0]->avatar : '/img/noicon.webp'),
'name' => $img->getFilename(),
'userCol' => $showCol,
'userName' => $showName,
'image' => $protocol.'://'.$_SERVER['SERVER_NAME'].'/'.$img->getPathname()
);
}
return $res;
}
}
public function getOther(Request $r) { // /api/rpc/image/get/other
$check = $this->objAuth->checkLegit($r->kero_token);
if ($check == 0) {
return 'Err!';
}
else {
$valid = $this->objAuth->getPermissions($r->kero_token);
if ($valid['img_viewimg'] == 1) {
$cols = $this->objUser->getGroupColours()->toArray();
$dirs = File::directories('storage/assets/images');
$res = array();
if ($check == 0) {
return 'Err!';
}
else {
foreach ($dirs as $dir) {
$usr = 0;
if (basename($dir) != $check) {
$usr = basename($dir);
$imgs = File::files('assets/images/'.$usr);
foreach ($imgs as $img) {
$protocol = isset($_SERVER["HTTPS"]) ? 'https' : 'http';
if ($usr != $check) {
$user = $this->objUser->getUser($usr, $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;
}
}
}
}
else {
$showName = "";
$showCol = "";
}
$res[] = array(
'id' => $usr,
'avatar' => $protocol.'://'.$_SERVER['SERVER_NAME'].'/'.($user[0]->avatar != '' ? $user[0]->avatar : '/img/noicon.webp'),
'name' => $img->getFilename(),
'userCol' => $showCol,
'userName' => $showName,
'image' => $protocol.'://'.$_SERVER['SERVER_NAME'].'/'.$img->getPathname()
);
}
}
}
}
return $res;
}
else {
return 'Permission denied.';
}
}
}
public function viewImage(Request $r) { // /api/rpc/image/view
$valid = $this->objAuth->getPermissions($r->kero_token);
if ($valid['img_viewimg'] == 1) {
$protocol = isset($_SERVER["HTTPS"]) ? 'https' : 'http';
if (!isset($r->id) || !isset($r->name)) {
return 'Err!';
}
return $protocol.'://'.$_SERVER['SERVER_NAME'].'/assets/images/'.$r->id.'/'.$r->name;
}
else {
return 'Permission denied.';
}
}
public function uploadImage(Request $r) { // /api/rpc/image/upload
$check = $this->objAuth->checkLegit($r->kero_token);
if ($check == 0) {
return 'Err!';
}
else {
$valid = $this->objAuth->getPermissions($r->kero_token);
if ($valid['img_addimg'] == 1) {
if (isset($r->filename)) {
if (!is_dir("assets/images/".$check)) {
if (!mkdir("assets/images/".$check, 0755, true)) {
return "Could not make folder ".$check."<br />";
}
}
$img_dir = "assets/images/".$check."/";
$image = $img_dir . $r->filename;
$imageFileType = array(
'image/png',
'image/jpeg',
'image/gif'
);
if (!in_array($r->filetype, $imageFileType)) {
return "Only JPG, PNG, JPEG, and GIF are allowed.";
}
$fname = 'assets/images/'.$check.'/'.$r->filename;
$data = base64_decode(preg_replace('#^data:image/\w+;base64,#i', '', $r->thefile));
Storage::disk('public')->put($fname, $data);
return $r->filename;
}
}
else {
return 'Permission denied.';
}
}
}
function is_dir_empty($dir) {
if (!is_readable($dir)) return NULL;
return (count(scandir($dir)) == 2);
}
public function removeImage(Request $r) { // /api/rpc/image/remove
$check = $this->objAuth->checkLegit($r->kero_token);
if ($check == 0) {
return 'Err!';
}
else {
$valid = $this->objAuth->getPermissions($r->kero_token);
if ($valid['img_delotherimg'] == 1) {
if (isset($r->name)) {
$fname = 'assets/images/'.$r->id.'/'.$r->name;
unlink('storage/'.$fname);
if ($this->is_dir_empty('storage/assets/images/'.$r->id)) rmdir('storage/assets/images/'.$r->id);
return 'Deleted';
}
}
else {
if (isset($r->name)) {
if ($check == $r->id) {
if ($valid['img_delownimg'] == 1) {
$fname = 'assets/images/'.$check.'/'.$r->name;
unlink('storage/'.$fname);
if ($this->is_dir_empty('storage/assets/images/'.$check)) rmdir('storage/assets/images/'.$check);
return 'Deleted';
}
else {
return 'Permission denied.';
}
}
else {
return 'Permission denied.';
}
}
}
}
}
}

ファイル差分が大きすぎるため省略します 差分を読み込み

ファイルの表示

ファイルの表示

@ -1,39 +0,0 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use Illuminate\Contracts\Routing\ResponseFactory;
use Illuminate\Support\Facades\Log;
use App\Http\Controllers\AuthController;
use App\Http\Controllers\UserController;
use App\Http\Controllers\PermissionController; // Remove permission controller soon.
class PackageController extends Controller {
private $objAuth;
private $objUser;
private $objPermission;
public function __construct() {
$this->objAuth = new AuthController();
$this->objUser = new UserController();
$this->objPermission = new PermissionController();
}
public function get(Request $r) { // /api/rpc/pack/get
$check = $this->objAuth->checkLegit($r->kero_token);
if ($check == 0) {
return 'err!';
}
else {
return DB::table('pck_tracks')
->select('*')
->where('user_id', $check)
->orderBy('id', 'desc')
->get();
}
}
}

ファイルの表示

@ -1,164 +0,0 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use Illuminate\Contracts\Routing\ResponseFactory;
use Illuminate\Support\Facades\Log;
use App\Http\Controllers\AuthController;
use App\Http\Controllers\UserController;
use App\Http\Controllers\PermissionController;
class SiteController extends Controller {
private $objAuth;
private $objUser;
private $objPermission;
private $valid;
public function __construct () {
$this->objAuth = new AuthController();
$this->objUser = new UserController();
$this->objPermission = new PermissionController();
$this->valid = $this->objAuth->getPermissions((isset($_COOKIE['kero_token']) ? $_COOKIE['kero_token'] : ''));
$this->cook = (isset($_COOKIE['kero_token']) ? $_COOKIE['kero_token'] : '');
$this->id = $this->objAuth->checkLegit($this->cook);
$this->user = $this->objUser->getLoggedUser($this->id, $this->cook);
}
public function index () {
$get = DB::table('blg_content')->where('isPost', 1);
if ($this->valid['blg_addpost'] == 0 && $this->valid['blg_editpost'] == 0) $get = $get->where('public_status', 0);
$get = $get->orderBy('publish_date', 'desc')->get();
setlocale(LC_ALL, 'ja_JP.utf8');
return view('pages.site.index', ['res' => $get, 'menu' => getPagesInMenu(), 'user' => $this->user]);
}
public function getPost ($slug, $kero) {
$get = DB::table('blg_content');
if ($this->valid['blg_editpost'] == 0) $get = $get->where('public_status', 0);
$get = $get->where('isPost', 1)->where('slug', $slug)->first();
$ucol = $this->objUser->getGroupColours();
setlocale(LC_ALL, 'ja_JP.utf8');
$get->showName = '';
$get->showCol = '';
$get->comments = DB::table('blg_comments')->where('post_id', $get->id)->orderBy('id', 'asc')->get();
$get->username = DB::table('users')->select('username')->where('id', $get->user_id)->first()->username;
$get->perm_id = DB::table('usr_perm_id')->select('perm_id')->where('user_id', $get->user_id)->first()->perm_id;
$p = DB::table('usr_profile')->select('gender', 'avatar', 'name_style', 'display_name')->where('user_id', $get->user_id)->first();
$get->gender = $p->gender;
$get->avatar = $p->avatar;
$get->name_style = $p->name_style;
$get->display_name = $p->display_name;
foreach ($get->comments as $k => $c) {
if (count(userDetail($c->user_id)) > 0) {
$det = userDetail($c->user_id);
$c->user_id = $det['user_id'];
$c->showname = $det['showname'];
$c->showcol = $det['showcol'];
$c->avatar = $det['avatar'];
}
if ($c->isShadow == 0) {
if (getIp() != $c->ipaddress) unset($get->comments[$k]);
}
else {
unset($c->email);
unset($c->ipaddress);
unset($c->isShadow);
$c->created = date('Y年m月d日 H:i:s', $c->created);
}
}
if (!empty($get->display_name)) $get->showname = $get->display_name;
else $get->showname = $get->username;
if (!empty($get->name_style)) $get->showcol = $get->name_style;
else {
foreach ($ucol as $j) {
if ($j->id == $get->perm_id) {
if ($get->gender == 1) $get->showcol = $j->colour_m;
else if ($get->gender == 2) $get->showcol = $j->colour_f;
else $get->showcol = $j->colour_u;
}
}
}
$get->user = userDetail(null, $kero);
$get->post_date = strftime('%Y/%m/%d(%a) %H:%M:%S %Z', $get->post_date);
$get->publish_date = strftime('%Y/%m/%d(%a) %H:%M:%S %Z', $get->publish_date);
return $get;
}
public function newComment (Request $r) {
$com = $r->comment;
if ($r->isvideo == 'f') $id = DB::table('blg_content')->select('id')->where('slug', $r->slug)->first()->id;
$shadow = DB::table('blg_blacklist')->where('ipaddress', getIp())->first();
if ($shadow && !$shadow->isShadow) return array('status' => '0101FF', 'message' => '失礼しますが、あなたはBANされていましたので、コメントを保存できません。');
$add = DB::table('blg_comments')
->insertGetId([
'user_id' => ($r->user_id != 0 ?: null),
'post_id' => ($r->isvideo == 'f' ? $id : 0),
'video_id' => ($r->isvideo == 't' ? $r->slug : ''),
'name' => $com['name'],
'email' => $com['mail'],
'message' => $com['text'],
'created' => time(),
'ipaddress' => getIp(),
'isShadow' => ($shadow ? 0 : 1)
]);
// 返事だったら、メールを送って
$res = DB::table('blg_comments')->select('id', 'name', 'created', 'message')->where('id', $add)->first();
$res->created = date('Y年m月d日 H:i:s', $res->created);
if (count(userDetail($r->user_id)) > 0) {
$det = userDetail($r->user_id);
$res->user_id = $det['user_id'];
$res->showname = $det['showname'];
$res->showcol = $det['showcol'];
$res->avatar = $det['avatar'];
}
return array('status' => '010100', 'message' => 'OK', 'result' => $res);
}
public function getPage ($slug, $kero) {
$sel = array('id', 'title', 'slug', 'isMenu', 'public_status', 'message');
$res = DB::table('blg_content')->select($sel);
if ($this->valid['blg_editpage'] == 0) $res = $res->where('public_status', 0);
$res = $res->where('isPost', 0)->where('slug', $slug)->orderBy('sortorder', 'asc')->first();
return $res;
}
public function addContent ($bdl) {
if (($this->valid['blg_addpost'] && $bdl['isPost'] == 1) || ($this->valid['blg_addpage'] && $bdl['isPost'] == 0)) {
return DB::table('blg_content')->insert($bdl);
}
return 0;
}
public function editContent ($bdl) {
if (($this->valid['blg_editpost'] && $bdl['isPost'] == 1) || ($this->valid['blg_editpage'] && $bdl['isPost'] == 0)) {
return DB::table('blg_content')->where('slug', $bdl['slug'])->update($bdl);
}
return 0;
}
public function delContent ($bdl) {
if (($this->valid['blg_delpost'] && $bdl['isPost'] == 1) || ($this->valid['blg_delpage'] && $bdl['isPost'] == 0)) {
return DB::table('blg_content')->where('slug', $bdl['slug'])->delete();
}
return 0;
}
}

ファイルの表示

@ -1,611 +0,0 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
class StoreController extends Controller {
private $objUser;
private $objPermission;
private $storePath;
public function __construct() {
$this->storePath = storage_path('app/public/store');
$this->objUser = new UserController();
$this->objPermission = new PermissionController();
}
// Game
public function getGames() { // /api/rpc/store/game/getgames
return DB::table('str_games_loc')
->join('str_games', 'str_games.id', '=', 'str_games_loc.ref_id')
->get(array(
'str_games.id',
'str_games.name',
'str_games_loc.name as altname'
));
}
public function getGame($id) { // /api/rpc/store/game/getgame/id
return DB::table('str_games_loc')
->join('str_games', 'str_games.id', '=', 'str_games_loc.ref_id')
->where('str_games.id', $id)
->get(array(
'str_games.id',
'str_games.name',
'str_games_loc.name as altname'
));
}
public function newGame(Request $r) { // /api/rpc/store/games/newgame
$add = DB::table('str_games')
->insert([
'name' => $r->name
]);
return \Response::json($add);
}
public function editGame(Request $r) { // /api/rpc/store/games/editgame
return DB::table('str_games')
->where('id', $r->id)
->update([
'name' => $r->name
]);
}
// Category
public function getCategories() { // /api/rpc/store/category/getcategories
return DB::table('str_category_loc')
->join('str_category', 'str_category.id', '=', 'str_category_loc.ref_id')
->get(array(
'str_category.id',
'str_category.name',
'str_category_loc.name as altname',
'str_category.game_id',
'str_category.min_screenshots'
));
}
public function getCategory($id) { // /api/rpc/store/category/getcategory/id
return DB::table('str_category_loc')
->join('str_category', 'str_category.id', '=', 'str_category_loc.ref_id')
->where('str_category.id', $id)
->get(array(
'str_category.id',
'str_category.name',
'str_category_loc.name as altname',
'str_category.game_id',
'str_category.min_screenshots'
));
}
public function getCategoriesOfGame($id) { // /api/rpc/store/category/getcategoriesofgame/id
return DB::table('str_category_loc')
->join('str_category', 'str_category.id', '=', 'str_category_loc.ref_id')
->join('str_games', 'str_category.game_id', '=', 'str_games.id')
->where('str_games.id', $id)
->get(array(
'str_category.id',
'str_category.name',
'str_category_loc.name as altname'
));
}
public function getGameOfCategory($id) { // /api/rpc/store/category/getgameofcategory/id
return DB::table('str_games_loc')
->join('str_games', 'str_games.id', '=', 'str_games_loc.ref_id')
->join('str_category', 'str_category.game_id', '=', 'str_games.id')
->where('str_category.id', $id)
->get(array(
'str_games.id',
'str_games.name',
'str_games_loc.name as altname'
));
}
public function getCategoryGame($id) { // /api/rpc/store/category/getcategorygame/id
return DB::table('str_category')
->select('game_id')
->where('id', $id)
->get();
}
public function getCategoryMinScreenshots($id) { // /api/rpc/store/category/getcategoryminscrot/id
return DB::table('str_category')
->select('min_screenshots')
->where('id', $id)
->get();
}
public function getCategoryName($id) { // /api/rpc/store/category/getcategoryname/id
return DB::table('str_category_loc')
->join('str_category', 'str_category.id', '=', 'str_category_loc.ref_id')
->where('str_category.id', $id)
->get(array(
'str_category.name',
'str_category_loc.name as altname'
));
}
public function getCategoryNameOfEntry($id) { // /api/rpc/store/category/getcategorynameofentry/id
return DB::table('str_file')
->join('str_category', 'str_category.id', '=', 'str_file.cat_id')
->join('str_category_loc', 'str_category.id', '=', 'str_category_loc.ref_id')
->where('str_file.id', $id)
->get(array(
'str_category.name',
'str_category_loc.name as altname'
));
}
public function newCategory(Request $r) { // /api/rpc/store/category/newcategory
$add = DB::table('str_category')
->insert([
'name' => $r->name,
'game_id' => $r->game_id,
'min_screenshots' => $r->min_screenshots
]);
return \Response::json($add);
}
public function editCategory(Request $r) { // /api/rpc/store/category/editcategory
return DB::table('str_category')
->where('id', $r->id)
->update([
'name' => $r->name,
'min_screenshots' => $r->min_screenshots
]);
}
// Entries
public function getAllEntries() { // /api/rpc/store/entry/getallentries
return DB::table('str_file')
->select('*')
->get();
}
public function getAllApprovedEntries() { // /api/rpc/store/entry/getallapprovedentries
return DB::table('str_file')
->select('*')
->where('isApproved', 1)
->get();
}
public function getAllBrokenEntries() { // /api/rpc/store/entry/getallbrokenentries
return DB::table('str_file')
->select('*')
->where('isBroken', 1)
->get();
}
public function getAllPendingEntries() { // /api/rpc/store/entry/getallpendingentries
return DB::table('str_file')
->select('*')
->where('isApproved', 0)
->get();
}
public function getNewEntries() { // /api/rpc/store/entry/getnewentries
return DB::table('str_file')
->select(
'id',
'title',
'version',
'submit_date'
)
->where('isApproved', 1)
->orderBy('submit_date', 'desc')
->limit(5)
->get();
}
public function getHotEntries() { // /api/rpc/store/entry/gethotentries
return DB::table('str_file')
->select(
'id',
'title',
'version',
'downloads'
)
->where('isApproved', 1)
->orderBy('downloads', 'desc')
->limit(5)
->get();
}
public function getEntriesPageAll($cat, $from, $to) { // /api/rpc/store/entry/getentriespageall/cat/from/to
return DB::table('str_file')
->select(
'id',
'title',
'version',
'description',
'submit_date',
'last_date',
'views',
'downloads'
)
->where('cat_id', $cat)
->offset($from)
->limit($to)
->get();
}
public function getEntriesPageApproved($cat, $from, $to) { // /api/rpc/store/entry/getentriespageapproved/cat/from/to
return DB::table('str_file')
->select(
'id',
'title',
'version',
'description',
'submit_date',
'last_date',
'views',
'downloads'
)
->where('cat_id', $cat)
->where('isApproved', 1)
->offset($from)
->limit($to)
->get();
}
public function getEntriesPagePopularView($cat, $from, $to) { // /api/rpc/store/entry/getentriespagepopularview/cat/from/to
return DB::table('str_file')
->select(
'id',
'title',
'version',
'description',
'submit_date',
'last_date',
'views',
'downloads'
)
->where('cat_id', $cat)
->where('views', '>', 1000)
->offset($from)
->limit($to)
->get();
}
public function getEntriesPagePopularDownload($cat, $from, $to) { // /api/rpc/store/entry/getentriespagepopulardownload/cat/from/to
return DB::table('str_file')
->select(
'id',
'title',
'version',
'description',
'submit_date',
'last_date',
'views',
'downloads'
)
->where('cat_id', $cat)
->where('downloads', '>', 1000)
->offset($from)
->limit($to)
->get();
}
public function getChangelog($id) { // /api/rpc/store/entry/getchangelog/id
return DB::table('str_file')
->select('version', 'changelog')
->where('id', $id)
->get();
}
public function getNotice($id) { // /api/rpc/store/entry/getnotice/id
return DB::table('str_file')
->select('title', 'version', 'warningnote')
->where('id', $id)
->get();
}
public function getDownloadCount($id) { // /api/rpc/store/entry/getdownloadcount/id
return DB::table('str_file')
->select('downloads')
->where('id', $id)
->get();
}
public function updateDownloadCount(Request $r) { // /api/rpc/store/entry/updatedownloadcount
return DB::table('str_file')
->where('id', $r->id)
->update(['downloads', $r->downloads]);
}
public function FileSizeConvert($bytes) {
$bytes = floatval($bytes);
$arBytes = array(
0 => array(
// "UNIT" => "TiB",
// "VALUE" => pow(1024, 4)
"UNIT" => "TQ",
"VALUE" => pow(4096, 4)
),
1 => array(
// "UNIT" => "GiB",
// "VALUE" => pow(1024, 3)
"UNIT" => "GQ",
"VALUE" => pow(4096, 3)
),
2 => array(
// "UNIT" => "MiB",
// "VALUE" => pow(1024, 2)
"UNIT" => "MQ",
"VALUE" => pow(4096, 2)
),
3 => array(
// "UNIT" => "KiB",
// "VALUE" => 1024
"UNIT" => "KQ",
"VALUE" => 4096
),
4 => array(
// "UNIT" => "B",
"UNIT" => "Q",
"VALUE" => 1
)
);
foreach($arBytes as $arItem) {
if($bytes >= $arItem["VALUE"]) {
$result = $bytes / $arItem["VALUE"];
$result = strval(round($result, 2))." ".$arItem["UNIT"];
break;
}
}
return $result;
}
public function getFilesOfEntry($id) { // /api/rpc/store/entry/getfilesofentry/id
$files = array_map("htmlspecialchars", scandir("assets/store/$id"));
$files = array_diff($files, array('..', '.', 'screens'));
$result = array();
foreach ($files as $file) {
array_push($result, [
'id' => $id,
'file' => $file,
'size' => $this->FileSizeConvert(filesize('assets/store/'.$id.'/'.$file))
]);
}
return $result;
}
public function getNextEntryId() { // /api/rpc/store/entry/getnextentryid
$get = DB::table('str_file')->max('id');
$get++;
return $get;
}
public function getEntry($id, $mode) { // /api/rpc/store/entry/getentry/id/mode
if ($mode == 'user') {
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('str_owners.user_id', $id)
->get(array(
'file_id',
'str_owners.user_id',
'cat_id',
'title',
'version',
'description',
'changelog',
'views',
'downloads',
'isApproved',
'submit_date',
'last_date',
'username',
'avatar',
'perm_id',
'gender',
'display_name',
'name_style',
));
}
else {
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', $id)
->take(1)
->get(array(
'file_id',
'str_owners.user_id',
'cat_id',
'title',
'version',
'description',
'changelog',
'views',
'downloads',
'isApproved',
'submit_date',
'last_date',
'username',
'avatar',
'perm_id',
'gender',
'display_name',
'name_style',
));
}
}
public function getEntryName($id) { // /api/rpc/store/entry/getentryname/id
return DB::table('str_file')
->select('title', 'version')
->where('id', $id)
->get();
}
public function getEntriesInCategory($cat_id) { // /api/rpc/store/entry/getentriesincategory/cat_id
return DB::table('str_file')
->select('*')
->where('cat_id', $cat_id)
->get();
}
public function countEntriesInCategory($cat_id) { // /api/rpc/store/entry/countentriesincategory/cat_id
// return $this->storePath.'/screens';
return DB::table('str_file')
->where('cat_id', $cat_id)
->where('isApproved', 1)
->count();
}
public function countEntriesInCategoryFull($cat_id) { // /api/rpc/store/entry/countentriesincategoryfull/cat_id
return DB::table('str_file')
->where('cat_id', $cat_id)
->count();
}
public function makedir(Request $r) {
$id = $r->id;
if (!mkdir($this->storePath.'/'.$id, 0755, true)) {
Log::error('File MKDIR failed: ');
exit();
}
if (!mkdir($this->storePath.'/'.$id.'/screens', 0755, true)) {
Log::error('Asset MKDIR failed: ');
exit();
}
}
public function uploadEntry(Request $r) { // /api/rpc/store/entry/upload
header('Access-Control-Allow-Origin: *');
$id = $r->id;
Log::info('Name: '.$r->file('imgfile')); //TMP
Log::info('Type: '.gettype($r->file('imgfile'))); // TMP
$r->file('upfile')->move(public_path('storage/store'.$id), $r->file('imgfile')->getClientOriginalName);
$r->file('imgfile')->move(public_path('storage/store'.$id.'/screens'), $r->file('imgfile')->getClientOriginalName);
exit(); // TMP
$add = DB::table('str_file')
->insert([
'game_id' => intval($r->game_id),
'cat_id' => intval($r->cat_id),
'title' => $r->title,
'version' => $r->version,
'video' => (!empty($r->video) ? $r->video : ''),
'description' => $r->description,
'changelog' => '',
'warningnote' => (!empty($r->warningnote) ? $r->warningnote : ''),
'submit_date' => intval($r->submit_date),
'last_date' => intval(0),
'views' => intval(0),
'downloads' => intval(0),
'isApproved' => intval(1),
'isBroken' => intval(0),
'failreason' => '',
'breakreason' => '',
'approveignore' => intval(0),
'brokenignore' => intval(0)
]);
return \Response::json($add);
}
public function updateEntry(Request $r) { // /api/rpc/store/entry/update
return DB::table('str_file')
->where('id', $r->id)
->update([
'cat_id' => $r->cat_id,
'title' => $r->title,
'version' => $r->version,
'description' => $r->description,
'changelog' => $r->changelog,
'warningnote' => $r->warningnote,
'last_date' => $r->last_date
]);
}
public function restoreEntry(Request $r) { // /api/rpc/store/entry/restore
return DB::table('str_file')
->where('id', $r->id)
->update(['isApproved' => 1]);
}
public function removeEntry(Request $r) { // /api/rpc/store/entry/remove
return DB::table('str_file')
->where('id', $r->id)
->update(['isApproved' => 0]);
}
public function browsePermissions($uid) {
// Get user ID.
$perm = $this->objUser->getUser($uid);
// Does the user ID exist? Grand the appropriate rights. Otherwise, use guest.
if ($uid != 0) {
// Store permissions.
$grouppermstr = $this->objPermission->getPermissionGroup('str', $perm[0]->perm_id);
$userpermstr = $this->objPermission->getPermissionUser('str', $uid);
// User permissions.
$grouppermusr = $this->objPermission->getPermissionGroup('usr', $perm[0]->perm_id);
$userpermusr = $this->objPermission->getPermissionUser('usr', $uid);
// Now provide an array of user overwritten permissions if it exists. Otherwise, give its group permissions.
$strarr = array();
$usrarr = array();
if (!empty($userpermstr[0])) {
$strarr = (array)$userpermstr[0];
}
else {
$strarr = (array)$grouppermstr[0];
}
if (!empty($userpermusr[0])) {
$usrarr = (array)$userpermusr[0];
}
else {
$usrarr = (array)$grouppermusr[0];
}
$merge = array();
$merge = array_merge($strarr, $usrarr);
return $merge;
}
else {
// Store permissions.
$grouppermstr = $this->objPermission->getPermissionGroup('str', 6);
// User permissions.
$grouppermusr = $this->objPermission->getPermissionGroup('usr', 6);
// Since guests don't have user overwritten permissions, simply return the group permissions.
$merge = array();
$merge = array_merge((array)$grouppermstr[0], (array)$grouppermusr[0]);
return $merge;
}
}
}

31
app/Http/Controllers/User/Login.php ノーマルファイル
ファイルの表示

@ -0,0 +1,31 @@
<?php
namespace App\Http\Controllers\User;
use Illuminate\Http\Request;
// use Illuminate\Support\Facades\Log;
class Login {
private $auth;
private $menu;
private $user;
public function __construct ($a, $m, $u) {
$this->auth = $a;
$this->menu = $m;
$this->user = $u;
}
public function index (Request $r) {
if (isset($_COOKIE['kero_token'])) return redirect('');
$res = array();
$err = '';
if (isset($r->username) && isset($r->password)) {
$res = $this->auth->login($r);
if (isset($res['kero_token'])) return redirect('');
$err = $res['err'];
}
return view('pages.site.login', ['res' => $res, 'menu' => $this->menu, 'user' => $this->user, 'err' => $err]);
}
}

53
app/Http/Controllers/User/Notification.php ノーマルファイル
ファイルの表示

@ -0,0 +1,53 @@
<?php
namespace App\Http\Controllers\User;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Cache;
// use Illuminate\Support\Facades\Log;
class Notification {
private $check;
public function __construct () {
$this->check = checkLegit((isset($_COOKIE['kero_token']) ? $_COOKIE['kero_token'] : ''));
}
public function get () {
$res = null;
if ($this->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', $this->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);
Cache::put('getNotification', $get);
}
}
return $res;
}
else return array();
}
public function add ($uid, $aid, $txt, $sec, $goto) {
if ($this->check != 0) {
$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 delete ($id) {
if ($this->check != 0) {
$del = DB::table('usr_notification')->where('id', $id)->where('user_id', $this->check)->delete();
if (Cache::has('getNotification')) Cache::forget('getNotification');
return $del;
}
}
}

110
app/Http/Controllers/User/Profile.php ノーマルファイル
ファイルの表示

@ -0,0 +1,110 @@
<?php
namespace App\Http\Controllers\User;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
// use Illuminate\Support\Facades\Log;
class Profile {
private $auth;
private $get;
private $cntr;
private $menu;
private $user;
public function __construct ($a, $g, $c, $m, $u) {
$this->auth = $a;
$this->get = $g;
$this->cntr = $c;
$this->menu = $m;
$this->user = $u;
}
public function index ($id, $kero) {
if (!$this->get) return notfound($this->menu, $this->user, $this->get);
return view('pages.site.profile', ['res' => $this->get, 'menu' => $this->menu, 'user' => $this->user]);
}
public function avatarUpload(Request $r) {
$check = checkLegit($r->kero_token);
if ($check == 0) return 'Err!';
else {
$valid = $this->auth->getPermissions($r->kero_token);
$user = 0;
if ($valid['usr_editother'] == 1) $user = $r->id;
else $user = $check;
if ($valid['usr_editprofile'] == 1) {
if (isset($r->filename)) {
if (!is_dir('/usericon/'.$check)) {
if (!mkdir('/usericon/'.$check, 0755, true)) return 'Could not make folder '.$check.'<br />';
}
$img_dir = '/usericon/'.$check.'/';
$image = $img_dir . $r->filename;
$imageFileType = array('image/png', 'image/jpeg', 'image/gif');
if (!in_array($r->filetype, $imageFileType)) return "Only JPG, PNG, JPEG, and GIF are allowed.";
$fname = '/usericon/'.$user.'/'.$r->filename;
$data = base64_decode(preg_replace('#^data:image/\w+;base64,#i', '', $r->thefile));
Storage::disk('public')->put($fname, $data);
return $r->filename;
}
}
else return 'Permission denied.';
}
}
public function edit ($id, Request $r) {
$err = '';
$suc = '';
if (isset($r->submit)) {
if (!is_null($r->password)) {
if ($r->password != $r->password_check) $err = '「パスワード」と「パスワード確認」が異なります。';
else {
$salt = dechex(mt_rand(0, 2147483647)) . dechex(mt_rand(0, 2147483647));
$passwd = hash('sha256', $r->password . $salt);
for ($round = 0; $round < 65536; $round++) { $passwd = hash('sha256', $passwd . $salt); }
$eduserp = DB::table('users')->where('id', $id)->update(['password' => $passwd, 'salt' => $salt]);
if (!$eduserp) $err = 'パスワードの編集失敗。';
}
}
$cheml = DB::table('users')->select('email')->where('id', $id)->first();
if ($err == '') {
if ($cheml->email != $r->email) {
$exeml = DB::table('users')->select('email')->where('email', $r->email)->count();
if ($exeml > 0) $err = '入力したメールアドレスはもう存在しています。';
else {
$edusere = DB::table('users')->where('id', $id)->update(['email' => $r->email]);
if (!$edusere) $err = 'メールアドレスの編集失敗。';
}
}
}
if ($err == '') {
$p = DB::table('usr_profile')->select('display_name', 'country', 'gender')->where('user_id', $id)->first();
$edprofile = 1;
if ($p->display_name != $r->display_name || $p->country != $r->country || $p->gender != $r->gender) {
$edprofile = DB::table('usr_profile')->where('user_id', $id)->update([
'display_name' => $r->display_name,
'country' => $r->country,
'gender' => $r->gender
]);
}
if (!$edprofile) $err = '表示名、お国、又は性別の編集失敗。';
else $suc = '編集しました!';
}
}
if ($this->user) return view('pages.site.profileedit', ['res' => $this->get, 'menu' => $this->menu, 'user' => $this->user, 'suc' => $suc, 'err' => $err, 'cnt' => $this->cntr]);
return redirect('');
}
}

32
app/Http/Controllers/User/Register.php ノーマルファイル
ファイルの表示

@ -0,0 +1,32 @@
<?php
namespace App\Http\Controllers\User;
use Illuminate\Http\Request;
// use Illuminate\Support\Facades\Log;
class Register {
private $auth;
private $cntr;
private $menu;
private $user;
public function __construct ($a, $c, $m, $u) {
$this->auth = $a;
$this->cntr = $c;
$this->menu = $m;
$this->user = $u;
}
public function index (Request $r) {
if (isset($_COOKIE['kero_token'])) return redirect('');
$err = '';
if (isset($r->username) && isset($r->password) && isset($r->email) && isset($r->password_check)) {
$reg = $this->auth->register($r);
if (isset($reg['kero_token'])) return redirect('');
$err = $reg['err'];
}
return view('pages.site.register', ['res' => $this->cntr, 'menu' => $this->menu, 'user' => $this->user, 'err' => $err]);
}
}

ファイルの表示

@ -1,59 +1,66 @@
<?php
namespace App\Http\Controllers;
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;
use Tymon\JWTAuth\Facades\JWTAuth;
use Tymon\JWTAuth\Exceptions\JWTException;
// use Illuminate\Support\Facades\Log;
use App\Http\Controllers\AuthController;
use App\Http\Controllers\User\Login;
use App\Http\Controllers\User\Notification;
use App\Http\Controllers\User\Profile;
use App\Http\Controllers\User\Register;
class UserController extends Controller {
private $objAuth;
private $objSite;
private $valid;
public function __construct() {
public function __construct () {
$this->objAuth = new AuthController();
$this->menu = getPagesInMenu();
$this->cook = (isset($_COOKIE['kero_token']) ? $_COOKIE['kero_token'] : '');
$this->id = $this->objAuth->checkLegit($this->cook);
$this->id = checkLegit($this->cook);
$this->user = $this->getLoggedUser($this->id, $this->cook);
}
public function getLoggedUser ($id, $kero) {
$check = $this->objAuth->checkLegit($kero);
if ($check == 0) return 0;
$valid = $this->objAuth->getPermissions($kero);
$cols = $this->getGroupColours()->toArray();
$get = DB::table('users')->where('id', $id)->first();
$get->profile = DB::table('usr_profile')->where('user_id', $id)->first();
$get->profile->showname = (!empty($get->profile->display_name) && !is_null($get->profile->display_name) ? $get->profile->display_name : $get->username);
$get->perm = $valid;
if (empty($get->avatar) || $get->avatar == '') $get->avatar = '/img/noicon.webp';
return $get;
public function profile ($id) {
$r = new Profile($this->objAuth, $this->getUser($id, $this->cook), $this->getCountries(), $this->menu, $this->user);
return $r->index($id, $this->cook);
}
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 editProfile ($id, Request $rr) {
$r = new Profile($this->objAuth, $this->getUser($id, $this->cook), $this->getCountries(), $this->menu, $this->user);
return $r->edit($id, $rr);
}
public function getGroupColours() {
return DB::table('usr_perm_module')->select('id', 'colour_m', 'colour_f', 'colour_u')->get();
public function login (Request $rr) {
$r = new Login($this->objAuth, $this->menu, $this->user);
return $r->index($rr);
}
public function getUser ($id, $kero) {
$check = $this->objAuth->checkLegit($kero);
public function register (Request $rr) {
$r = new Register($this->objAuth, $this->getCountries(), $this->menu, $this->user);
return $r->index($rr);
}
public function getNotification () {
$r = new Notification();
return $r->get();
}
public function addNotification ($uid, $aid, $txt, $sec, $goto) {
$r = new Notification();
return $r->add($uid, $aid, $txt, $sec, $goto);
}
public function delNotification ($id) {
$r = new Notification();
return $r->delete($id);
}
function getUser ($id, $kero) {
$check = checkLegit($kero);
$valid = $this->objAuth->getPermissions($kero);
$cols = $this->getGroupColours()->toArray();
@ -89,7 +96,23 @@ class UserController extends Controller {
return $get;
}
public function getCountries () {
function getLoggedUser ($id, $kero) {
$check = checkLegit($kero);
if ($check == 0) return 0;
$valid = $this->objAuth->getPermissions($kero);
$cols = $this->getGroupColours()->toArray();
$get = DB::table('users')->where('id', $id)->first();
$get->profile = DB::table('usr_profile')->where('user_id', $id)->first();
$get->profile->showname = (!empty($get->profile->display_name) && !is_null($get->profile->display_name) ? $get->profile->display_name : $get->username);
$get->perm = $valid;
if (empty($get->avatar) || $get->avatar == '') $get->avatar = '/img/noicon.webp';
return $get;
}
function getCountries () {
$flags = DB::table('nhn_country')->orderBy('id', 'asc')->get();
$res = array();
@ -105,168 +128,11 @@ class UserController extends Controller {
return $res;
}
public function avatarUpload(Request $r) {
$check = $this->objAuth->checkLegit($r->kero_token);
if ($check == 0) return 'Err!';
else {
$valid = $this->objAuth->getPermissions($r->kero_token);
$user = 0;
if ($valid['usr_editother'] == 1) $user = $r->id;
else $user = $check;
if ($valid['usr_editprofile'] == 1) {
if (isset($r->filename)) {
if (!is_dir('/usericon/'.$check)) {
if (!mkdir('/usericon/'.$check, 0755, true)) return 'Could not make folder '.$check.'<br />';
}
$img_dir = '/usericon/'.$check.'/';
$image = $img_dir . $r->filename;
$imageFileType = array('image/png', 'image/jpeg', 'image/gif');
if (!in_array($r->filetype, $imageFileType)) return "Only JPG, PNG, JPEG, and GIF are allowed.";
$fname = '/usericon/'.$user.'/'.$r->filename;
$data = base64_decode(preg_replace('#^data:image/\w+;base64,#i', '', $r->thefile));
Storage::disk('public')->put($fname, $data);
return $r->filename;
}
}
else return 'Permission denied.';
}
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 profile ($id) {
$res = $this->getUser($id, $this->cook);
return view('pages.site.profile', ['res' => $res, 'menu' => $this->menu, 'user' => $this->user]);
}
public function editProfile ($id, Request $r) {
$err = '';
$suc = '';
if (isset($r->submit)) {
if (!is_null($r->password)) {
if ($r->password != $r->password_check) $err = '「パスワード」と「パスワード確認」が異なります。';
else {
$salt = dechex(mt_rand(0, 2147483647)) . dechex(mt_rand(0, 2147483647));
$passwd = hash('sha256', $r->password . $salt);
for ($round = 0; $round < 65536; $round++) { $passwd = hash('sha256', $passwd . $salt); }
$eduserp = DB::table('users')->where('id', $id)->update(['password' => $passwd, 'salt' => $salt]);
if (!$eduserp) $err = 'パスワードの編集失敗。';
}
}
$cheml = DB::table('users')->select('email')->where('id', $id)->first();
if ($err == '') {
if ($cheml->email != $r->email) {
$exeml = DB::table('users')->select('email')->where('email', $r->email)->count();
if ($exeml > 0) $err = '入力したメールアドレスはもう存在しています。';
else {
$edusere = DB::table('users')->where('id', $id)->update(['email' => $r->email]);
if (!$edusere) $err = 'メールアドレスの編集失敗。';
}
}
}
if ($err == '') {
$p = DB::table('usr_profile')->select('display_name', 'country', 'gender')->where('user_id', $id)->first();
$edprofile = 1;
if ($p->display_name != $r->display_name || $p->country != $r->country || $p->gender != $r->gender) {
$edprofile = DB::table('usr_profile')->where('user_id', $id)->update([
'display_name' => $r->display_name,
'country' => $r->country,
'gender' => $r->gender
]);
}
if (!$edprofile) $err = '表示名、お国、又は性別の編集失敗。';
else $suc = '編集しました!';
}
}
if ($this->user) {
$res = $this->getUser($id, $this->cook);
$cnt = $this->getCountries();
return view('pages.site.profileedit', ['res' => $res, 'menu' => $this->menu, 'user' => $this->user, 'suc' => $suc, 'err' => $err, 'cnt' => $cnt]);
}
return redirect('');
}
public function login (Request $r) {
if (isset($_COOKIE['kero_token'])) return redirect('');
$res = array();
$err = '';
if (isset($r->username) && isset($r->password)) {
$res = $this->objAuth->login($r);
if (isset($res['kero_token'])) return redirect('');
$err = $res['err'];
}
return view('pages.site.login', ['res' => $res, 'menu' => $this->menu, 'user' => $this->user, 'err' => $err]);
}
public function register (Request $r) {
if (isset($_COOKIE['kero_token'])) return redirect('');
$res = $this->getCountries();
$err = '';
if (isset($r->username) && isset($r->password) && isset($r->email) && isset($r->password_check)) {
$reg = $this->objAuth->register($r);
if (isset($reg['kero_token'])) return redirect('');
$err = $reg['err'];
}
return view('pages.site.register', ['res' => $res, 'menu' => $this->menu, 'user' => $this->user, 'err' => $err]);
}
public function getNotification (Request $r) { // /api/rpc/user/notification/get
$check = $this->objAuth->checkLegit($r->kero_token);
$res = null;
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();
$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);
Cache::put('getNotification', $get);
}
}
return $res;
}
else return array();
}
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]);
if (Cache::has('getNotification')) Cache::forget('getNotification');
return 1;
}
}
public function delNotification(Request $r) {
$check = $this->objAuth->checkLegit($r->kero_token);
if ($check != 0) {
$del = DB::table('usr_notification')->where('id', $r->id)->where('user_id', $check)->delete();
if (Cache::has('getNotification')) Cache::forget('getNotification');
return $del;
}
function getGroupColours() {
return DB::table('usr_perm_module')->select('id', 'colour_m', 'colour_f', 'colour_u')->get();
}
}

21
app/Http/Controllers/Video/Game.php ノーマルファイル
ファイルの表示

@ -0,0 +1,21 @@
<?php
namespace App\Http\Controllers\Video;
use Illuminate\Support\Facades\DB;
// use Illuminate\Support\Facades\Log;
class Game {
private $menu;
private $user;
public function __construct ($m, $u) {
$this->menu = $m;
$this->user = $u;
}
public function index () {
$res = DB::table('vid_game')->get();
if (!$res) return notfound($this->menu, $this->user, $res);
return view('pages.site.video.game', ['res' => $res, 'menu' => $this->menu, 'user' => $this->user]);
}
}

95
app/Http/Controllers/Video/Prayer.php ノーマルファイル
ファイルの表示

@ -0,0 +1,95 @@
<?php
namespace App\Http\Controllers\Video;
use Illuminate\Support\Facades\DB;
// use Illuminate\Support\Facades\Log;
class Prayer {
private $menu;
private $cook;
private $user;
public function __construct ($m, $c, $u) {
$this->menu = $m;
$this->cook = $c;
$this->user = $u;
}
public function index ($vid) {
$res = DB::table('vid_video')->where('vid', $vid)->first();
$game = DB::table('vid_game')->where('id', $res->game_id)->first();
$res->gametitle = explode('】', $res->title);
$res->title = $res->gametitle[1];
$res->gametitle = $res->gametitle[0];
$res->gametitle = str_replace('【'.$game->name, '', $res->gametitle);
$res->mgametitle = $game->name;
$slugger = $res->vid;
$res->slug = $game->slug;
$res->pageslug = $vid;
if ($res->gametitle == '') $res->gametitle = '初代';
$comments = DB::table('blg_comments')->where('video_id', $vid)->orderBy('id', 'asc')->get()->toArray();
$ytslug = explode('?v=', $res->youtube);
$res->ytcomment = $this->getYouTubeCome($ytslug[1]);
$res->nicocomment = array();
$res->bccomment = array();
foreach ($comments as $k => $c) {
if (count(userDetail($c->user_id)) > 0) {
$det = userDetail($c->user_id);
$c->user_id = $det['user_id'];
$c->showname = $det['showname'];
$c->showcol = $det['showcol'];
$c->avatar = $det['avatar'];
}
if ($c->isShadow == 0) {
if (getIp() != $c->ipaddress) unset($comments[$k]);
}
else {
unset($c->email);
unset($c->ipaddress);
unset($c->isShadow);
$c->created = date('Y年m月d日 H:i:s', $c->created);
}
}
$res->user = userDetail(null, $this->cook);
$res->comments = $comments;
if (!$res) return notfound($this->menu, $this->user, $res);
return view('pages.site.video.prayer', ['res' => $res, 'menu' => $this->menu, 'user' => $this->user]);
}
function getYouTubeCome ($slug) {
$ch = curl_init();
$url = 'https://www.googleapis.com/youtube/v3/commentThreads?part=snippet%2Creplies&moderationStatus=published&videoId='.$slug.'&key='.env('YOUTUBE_API');
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$get = curl_exec($ch);
curl_close($ch);
$come = array();
$get = json_decode($get, false);
if (isset($get->error)) return array();
foreach ($get->items as $g) {
$g->comment = new \stdClass();
$g->comment->id = $g->id;
$g->comment->name = $g->snippet->topLevelComment->snippet->authorDisplayName;
$g->comment->channel = $g->snippet->topLevelComment->snippet->authorChannelUrl;
$g->comment->icon = $g->snippet->topLevelComment->snippet->authorProfileImageUrl;
$g->comment->created = date('Y年m月d日 H:i:s', strtotime($g->snippet->topLevelComment->snippet->publishedAt));
$g->comment->message = $g->snippet->topLevelComment->snippet->textDisplay;
$come[] = $g->comment;
}
return $come;
}
}

32
app/Http/Controllers/Video/VideoTable.php ノーマルファイル
ファイルの表示

@ -0,0 +1,32 @@
<?php
namespace App\Http\Controllers\Video;
use Illuminate\Support\Facades\DB;
// use Illuminate\Support\Facades\Log;
class VideoTable {
private $menu;
private $user;
public function __construct ($m, $u) {
$this->menu = $m;
$this->user = $u;
}
public function index ($slug) {
$slg = DB::table('vid_game')->select('id', 'name')->where('slug', $slug)->first();
$res = DB::table('vid_video')->where('game_id', $slg->id)->orderBy('id', 'desc')->get();
foreach ($res as $r) {
$r->gametitle = explode('】', $r->title);
$r->title = $r->gametitle[1];
$r->gametitle = $r->gametitle[0];
$r->gametitle = str_replace('【'.$slg->name, '', $r->gametitle);
if ($r->gametitle == '') $r->gametitle = '初代';
}
if (!$res) return notfound($this->menu, $this->user, $res);
return view('pages.site.video.videotable', ['res' => $res, 'menu' => $this->menu, 'user' => $this->user]);
}
}

ファイルの表示

@ -1,134 +1,42 @@
<?php
namespace App\Http\Controllers;
// use Illuminate\Support\Facades\Log;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\Http\Controllers\AuthController;
use App\Http\Controllers\SiteController;
use App\Http\Controllers\UserController;
use Illuminate\Support\Facades\Log;
use App\Http\Controllers\Video\Game;
use App\Http\Controllers\Video\VideoTable;
use App\Http\Controllers\Video\Prayer;
class VideoController extends Controller {
private $objAuth;
private $objUser;
private $menu;
private $cook;
private $id;
private $user;
public function __construct() {
$this->objAuth = new AuthController();
$this->objUser = new UserController();
$this->menu = getPagesInMenu();
$this->cook = (isset($_COOKIE['kero_token']) ? $_COOKIE['kero_token'] : '');
$this->id = $this->objAuth->checkLegit($this->cook);
$this->id = checkLegit($this->cook);
$this->user = $this->objUser->getLoggedUser($this->id, $this->cook);
}
public function index () {
$res = DB::table('vid_game')->get();
foreach ($res as $r) {
$p = DB::table('vid_platform')->where('id', $r->platform_id)->first();
$r->name = $r->name.'('.$p->name.')';
}
return view('pages.site.video.game', ['res' => $res, 'menu' => $this->menu, 'user' => $this->user]);
$r = new Game($this->menu, $this->user);
return $r->index();
}
public function table ($slug) {
$slg = DB::table('vid_game')->select('id', 'name')->where('slug', $slug)->first();
$res = DB::table('vid_video')->where('game_id', $slg->id)->orderBy('id', 'desc')->get();
foreach ($res as $r) {
$r->gametitle = explode('】', $r->title);
$r->title = $r->gametitle[1];
$r->gametitle = $r->gametitle[0];
$r->gametitle = str_replace('【'.$slg->name, '', $r->gametitle);
if ($r->gametitle == '') $r->gametitle = '初代';
}
return view('pages.site.video.videotable', ['res' => $res, 'menu' => $this->menu, 'user' => $this->user]);
$r = new VideoTable($this->menu, $this->user);
return $r->index($slug);
}
public function prayer ($vid) {
$res = DB::table('vid_video')->where('vid', $vid)->first();
$game = DB::table('vid_game')->where('id', $res->game_id)->first();
$res->gametitle = explode('】', $res->title);
$res->title = $res->gametitle[1];
$res->gametitle = $res->gametitle[0];
$res->gametitle = str_replace('【'.$game->name, '', $res->gametitle);
$res->mgametitle = $game->name;
$slugger = $res->vid;
$res->slug = $game->slug;
$res->pageslug = $vid;
if ($res->gametitle == '') $res->gametitle = '初代';
$comments = DB::table('blg_comments')->where('video_id', $vid)->orderBy('id', 'asc')->get()->toArray();
$ytslug = explode('?v=', $res->youtube);
$res->ytcomment = $this->getYouTubeCome($ytslug[1]);
$res->nicocomment = array();
$res->bccomment = array();
foreach ($comments as $k => $c) {
if (count(userDetail($c->user_id)) > 0) {
$det = userDetail($c->user_id);
$c->user_id = $det['user_id'];
$c->showname = $det['showname'];
$c->showcol = $det['showcol'];
$c->avatar = $det['avatar'];
}
if ($c->isShadow == 0) {
if (getIp() != $c->ipaddress) unset($comments[$k]);
}
else {
unset($c->email);
unset($c->ipaddress);
unset($c->isShadow);
$c->created = date('Y年m月d日 H:i:s', $c->created);
}
}
$res->user = userDetail(null, $this->cook);
$res->comments = $comments;
return view('pages.site.video.prayer', ['res' => $res, 'menu' => $this->menu, 'user' => $this->user]);
}
function getYouTubeCome ($slug) {
$ch = curl_init();
$url = 'https://www.googleapis.com/youtube/v3/commentThreads?part=snippet%2Creplies&moderationStatus=published&videoId='.$slug.'&key='.env('YOUTUBE_API');
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$get = curl_exec($ch);
curl_close($ch);
$come = array();
$get = json_decode($get, false);
if (isset($get->error)) return array();
foreach ($get->items as $g) {
$g->comment = new \stdClass();
$g->comment->id = $g->id;
$g->comment->name = $g->snippet->topLevelComment->snippet->authorDisplayName;
$g->comment->channel = $g->snippet->topLevelComment->snippet->authorChannelUrl;
$g->comment->icon = $g->snippet->topLevelComment->snippet->authorProfileImageUrl;
$g->comment->created = date('Y年m月d日 H:i:s', strtotime($g->snippet->topLevelComment->snippet->publishedAt));
$g->comment->message = $g->snippet->topLevelComment->snippet->textDisplay;
$come[] = $g->comment;
}
return $come;
$r = new Prayer($this->menu, $this->cook, $this->user);
return $r->index($vid);
}
}

ファイルの表示

@ -1,54 +0,0 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
class VpsController extends Controller {
public function serverList (Request $r) { // /api/rpc/vps/server/list
// 許可確認
// GMOかこのは?
// 受け取り
// リターン
/*$check = $this->objAuth->checkLegit($r->kero_token);
if ($check == 0) {
return 'Err!';
}
else {
$valid = $this->objAuth->getPermissions($r->kero_token);
if ($valid['vps_list'] == 1) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.gmocloud.com/jp002/?Action=listNodes&AccessKeyId=HWWS0VHL1QJO59F0MK3E&Version=1.0' );
// curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: text/xml"));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE );
curl_setopt($ch, CURLOPT_TIMEOUT, 30 );
// curl_setopt($ch, CURLOPT_POSTFIELDS, array(); );
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE );
$res = curl_exec($ch);
return $res;
// 'https://api.gmocloud.com/jp002/?Action=listNodes&AccessKeyId=HWWS0VHL1QJO59F0MK3E&Version=1.0'
}
else {
return 'Permission denied.';
}
}*/
}
public function serverView (Request $r) { // /api/rpc/vps/server/view
}
public function domainList (Request $r) { // /api/rpc/vps/domain/list
// 許可確認
// OpenProviderかjp-domainかお名前?
// 受け取り
// リターン
}
public function domainView (Request $r) { // /api/rpc/vps/domain/view
}
}

ファイルの表示

@ -23,6 +23,12 @@ function getIp () {
return $ip;
}
function checkLegit ($t) {
if (!isset($t) || empty($t) || is_null($t)) return 0;
$check = DB::table('users')->select('id')->where('kero_token', $t)->first();
return $check->id;
}
function userDetail ($id, $kero=null) {
if ($kero || $id) {
$log_username = null;
@ -56,4 +62,8 @@ function userDetail ($id, $kero=null) {
return array();
}
function notfound ($m, $u, $r) {
return view('pages.site.notfound', ['res' => $r, 'menu' => $m, 'user', $u]);
}
?>

ファイルの表示

@ -1,10 +1,14 @@
<?php
Route::get('/', 'SiteController@index');
Route::get('/', 'HomeController@index');
Route::get('/blog/{slug}', 'HomeController@post');
Route::get('/content/add', 'HomeController@addContent');
Route::post('/content/add', 'HomeController@addContent');
// Route::get('/content/add', 'HomeController@addContent');
// Route::post('/content/add', 'HomeController@addContent');
// Route::get('/content/edit', 'HomeController@editContent');
// Route::post('/content/edit', 'HomeController@editContent');
// Route::get('/content/del', 'HomeController@delContent');
// Route::post('/content/del', 'HomeController@delContent');
Route::get('/login', 'UserController@login');
Route::post('/login', 'UserController@login');