また大掃除だね

このコミットが含まれているのは:
テクニカル諏訪子 2020-09-23 22:52:53 +09:00
コミット 2453c3dc5b
4個のファイルの変更64行の追加144行の削除

ファイルの表示

@ -30,11 +30,6 @@ class HomeController extends Controller {
$this->user = $this->objUser->getLoggedUser($this->id, $this->cook);
}
public function index () {
$res = $this->objSite->getPosts(1);
return view('pages.site.index', ['res' => $res, 'menu' => $this->menu, 'user' => $this->user]);
}
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]);

ファイルの表示

@ -22,141 +22,77 @@ class SiteController extends Controller {
$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 getPosts ($ispost=1) {
$ucol = $this->objUser->getGroupColours();
$get = DB::table('blg_content')->where('isPost', $ispost)->orderBy('publish_date', 'desc')->get();
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');
foreach ($get as $g) {
if ($this->valid['blg_addpost'] == 0 && $this->valid['blg_editpost'] == 0 && $g->public_status != 0) unset($g);
}
return $get;
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();
if ($this->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 = '';
$comments = DB::table('blg_comments')->where('post_id', $i->id)->orderBy('id', 'asc')->get();
$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;
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);
}
$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 ($c->isShadow == 0) {
if (getIp() != $c->ipaddress) unset($get->comments[$k]);
}
if (!empty($i->display_name)) $showName = $i->display_name;
else $showName = $i->username;
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;
}
}
unset($c->email);
unset($c->ipaddress);
unset($c->isShadow);
$c->created = date('Y年m月d日 H:i:s', $c->created);
}
$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,
'comments' => $comments,
'message' => $i->message,
'gender' => $i->gender,
'avatar' => $i->avatar,
'showcol' => $showCol,
'showname' => $showName
]);
}
return $res;
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->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されていましたので、コメントを保存できません。');
$shadow = ($shadow ? 0 : 1);
$add = DB::table('blg_comments')
->insertGetId([
@ -167,7 +103,7 @@ class SiteController extends Controller {
'message' => $com['text'],
'created' => time(),
'ipaddress' => getIp(),
'isShadow' => $shadow
'isShadow' => ($shadow ? 0 : 1)
]);
// 返事だったら、メールを送って
@ -178,23 +114,12 @@ class SiteController extends Controller {
}
public function getPage ($slug, $kero) {
if ($this->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')
->first();
}
else {
return DB::table('blg_content')
->select('id', 'title', 'slug', 'isMenu', 'public_status', 'message')
->where('public_status', 0)
->where('isPost', 0)
->where('slug', $slug)
->orderBy('sortorder', 'asc')
->first();
}
$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) {

ファイルの表示

@ -2,23 +2,23 @@
@section('content')
<div class="within {{ ($res[0]['public_status'] !== 0 ? ' wny' : '') }}">
<div class="bar {{ ($res[0]['public_status'] !== 0 ? ' bny' : '') }}">{{ $res[0]['title'] }}</div>
<div class="within {{ ($res->public_status !== 0 ? ' wny' : '') }}">
<div class="bar {{ ($res->public_status !== 0 ? ' bny' : '') }}">{{ $res->title }}</div>
<div class="meta">
<a href="/profile/{{$res[0]['user_id']}}">
<img src="/{{ $res[0]['avatar'] }}" width="20" height="20" alt="{{ $res[0]['showname'] }}のアイコン" />
<span style="{{ $res[0]['showcol'] }}">{{ $res[0]['showname'] }}</span>
<a href="/profile/{{$res->user_id}}">
<img src="/{{ $res->avatar }}" width="20" height="20" alt="{{ $res->showname }}のアイコン" />
<span style="{{ $res->showcol }}">{{ $res->showname }}</span>
</a>
<span>{{ $res[0]['publish_date'] }}で公開</span>
<span>{{ $res->publish_date }}で公開</span>
</div>
<div class="back" style="white-space: pre-wrap;">
{!! $res[0]['message'] !!}
{!! $res->message !!}
</div>
<div class="comment">
<div class="container-fluid">
<div class="row">
<div class="col">
<comments slug="{{$res[0]['slug']}}" isvideo="f" :comments="{{json_encode($res[0]['comments'])}}" />
<comments slug="{{$res->slug}}" isvideo="f" :comments="{{json_encode($res->comments)}}" />
</div>
</div>
</div>

ファイルの表示

@ -1,6 +1,6 @@
<?php
Route::get('/', 'HomeController@index');
Route::get('/', 'SiteController@index');
Route::get('/blog/{slug}', 'HomeController@post');
Route::get('/content/add', 'HomeController@addContent');