掃除ですね

このコミットが含まれているのは:
テクニカル諏訪子 2020-09-23 14:15:07 +09:00
コミット 282fc016b5
7個のファイルの変更181行の追加132行の削除

ファイルの表示

@ -24,7 +24,7 @@ class HomeController extends Controller {
$this->objAuth = new AuthController();
$this->objSite = new SiteController();
$this->objUser = new UserController();
$this->menu = $this->objSite->getPagesInMenu();
$this->menu = getPagesInMenu();
$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);
@ -47,70 +47,6 @@ class HomeController extends Controller {
return view('pages.site.page', ['res' => $res, 'menu' => $this->menu, 'user' => $this->user]);
}
public function profile ($id) {
$res = $this->objUser->getUser($id, $this->cook);
return view('pages.site.profile', ['res' => $res, 'menu' => $this->menu, 'user' => $this->user]);
}
public function videoGame () {
$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]);
}
public function videoTable ($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]);
}
public function videoPlay ($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;
$res->slug = $game->slug;
if ($res->gametitle == '') $res->gametitle = '初代';
$comments = DB::table('blg_comments')->where('video_id', $res->slug)->orderBy('id', 'asc')->get()->toArray();
foreach ($comments as $k => $c) {
if ($c->isShadow == 0) {
if ($this->objSite->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->comments = $comments;
return view('pages.site.video.prayer', ['res' => $res, 'menu' => $this->menu, 'user' => $this->user]);
}
public function addContent (Request $r) {
if ($this->user && ($this->user['blg_addpost'] || $this->user['blg_addpage'])) {
$bdl = array();
@ -127,34 +63,6 @@ class HomeController extends Controller {
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->objUser->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 notfound () {
return view('pages.site.notfound', ['menu' => $this->menu, 'user', $this->user]);
}

ファイルの表示

@ -103,7 +103,7 @@ class SiteController extends Controller {
foreach ($comments as $k => $c) {
if ($c->isShadow == 0) {
if ($this->getIp() != $c->ipaddress) unset($comments[$k]);
if (getIp() != $c->ipaddress) unset($comments[$k]);
}
else {
unset($c->email);
@ -153,7 +153,7 @@ class SiteController extends Controller {
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', $this->getIp())->first();
$shadow = DB::table('blg_blacklist')->where('ipaddress', getIp())->first();
if ($shadow && !$shadow->isShadow) return array('status' => '0101FF', 'message' => '失礼しますが、あなたはBANされていましたので、コメントを保存できません。');
$shadow = ($shadow ? 0 : 1);
@ -166,7 +166,7 @@ class SiteController extends Controller {
'email' => $com['mail'],
'message' => $com['text'],
'created' => time(),
'ipaddress' => $this->getIp(),
'ipaddress' => getIp(),
'isShadow' => $shadow
]);
@ -177,33 +177,6 @@ class SiteController extends Controller {
return array('status' => '010100', 'message' => 'OK', 'result' => $res);
}
public function getIp () {
if (!empty($_SERVER['HTTP_CLIENT_IP'])) $ip = $_SERVER['HTTP_CLIENT_IP'];
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
else $ip = $_SERVER['REMOTE_ADDR'];
return $ip;
}
public function getPagesInMenu () {
$get = DB::table('blg_content')
->select('title', 'slug')
->where('public_status', 0)
->where('isPost', 0)
->where('isMenu', 1)
->orderBy('sortorder', 'asc')
->get();
$res = array();
$key = 0;
foreach ($get as $i) {
array_push($res, ['key' => $key, 'title' => $i->title, 'slug' => $i->slug]);
$key++;
}
return $res;
}
public function getPage ($slug, $kero) {
if ($this->valid['blg_editpage'] == 1) {
return DB::table('blg_content')

ファイルの表示

@ -18,9 +18,14 @@ use App\Http\Controllers\AuthController;
class UserController extends Controller {
private $objAuth;
private $objSite;
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->user = $this->getLoggedUser($this->id, $this->cook);
}
public function getLoggedUser ($id, $kero) {
@ -134,6 +139,51 @@ class UserController extends Controller {
}
}
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) {
$err = '';
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, '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;

89
app/Http/Controllers/VideoController.php ノーマルファイル
ファイルの表示

@ -0,0 +1,89 @@
<?php
namespace App\Http\Controllers;
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;
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->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]);
}
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]);
}
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;
$res->slug = $game->slug;
if ($res->gametitle == '') $res->gametitle = '初代';
$comments = DB::table('blg_comments')->where('video_id', $res->slug)->orderBy('id', 'asc')->get()->toArray();
foreach ($comments as $k => $c) {
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->comments = $comments;
return view('pages.site.video.prayer', ['res' => $res, 'menu' => $this->menu, 'user' => $this->user]);
}
}

26
app/helpers.php ノーマルファイル
ファイルの表示

@ -0,0 +1,26 @@
<?php
use Illuminate\Support\Facades\DB;
function getPagesInMenu () {
$get = DB::table('blg_content')->select('title', 'slug')->where('public_status', 0)->where('isPost', 0)->where('isMenu', 1)->orderBy('sortorder', 'asc')->get();
$res = array();
$key = 0;
foreach ($get as $i) {
array_push($res, ['key' => $key, 'title' => $i->title, 'slug' => $i->slug]);
$key++;
}
return $res;
}
function getIp () {
if (!empty($_SERVER['HTTP_CLIENT_IP'])) $ip = $_SERVER['HTTP_CLIENT_IP'];
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
else $ip = $_SERVER['REMOTE_ADDR'];
return $ip;
}
?>

ファイルの表示

@ -36,6 +36,9 @@
"psr-4": {
"App\\": "app/"
},
"files": [
"app/helpers.php"
],
"classmap": [
"database/seeds",
"database/factories"

ファイルの表示

@ -3,18 +3,18 @@
Route::get('/', 'HomeController@index');
Route::get('/blog/{slug}', 'HomeController@post');
Route::get('/login', 'HomeController@login');
Route::post('/login', 'HomeController@login');
Route::get('/register', 'HomeController@register');
Route::post('/register', 'HomeController@register');
Route::get('/content/add', 'HomeController@addContent');
Route::post('/content/add', 'HomeController@addContent');
Route::get('/profile/{id}', 'HomeController@profile');
Route::get('/login', 'UserController@login');
Route::post('/login', 'UserController@login');
Route::get('/register', 'UserController@register');
Route::post('/register', 'UserController@register');
Route::get('/video', 'HomeController@videoGame');
Route::get('/video/{slug}', 'HomeController@videoTable');
Route::get('/video/play/{vid}', 'HomeController@videoPlay');
Route::get('/profile/{id}', 'UserController@profile');
Route::get('/video', 'VideoController@index');
Route::get('/video/{slug}', 'VideoController@table');
Route::get('/video/play/{vid}', 'VideoController@prayer');
Route::get('/{slug}', 'HomeController@page');