diff --git a/.env.example b/.env.example
index ed090d7..4594291 100644
--- a/.env.example
+++ b/.env.example
@@ -2,6 +2,7 @@ APP_NAME=076Server
APP_ENV=local
APP_KEY=
APP_DEBUG=false
+APP_LOG_LEVEL=debug
APP_URL=http://localhost
ONION_HOST=jkdasfhfdhndsfnklhjfdsknjfdgsjk.onion
SESSION_SECURE_COOKIE=false
@@ -18,6 +19,7 @@ ADMIN_NAME=""
ADMIN_PASS=""
LOG_CHANNEL=stack
+LOG_LEVEL=debug
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
@@ -32,6 +34,8 @@ QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
+MEMCACHED_HOST=127.0.0.1
+
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
@@ -41,7 +45,11 @@ MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
+MAIL_NOREPLY_USER=null
+MAIL_NOREPLY_PASS=null
MAIL_ENCRYPTION=null
+MAIL_OWNER_ADDRESS=null
+MAIL_OWNER_NAME="${APP_NAME}"
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"
@@ -51,4 +59,10 @@ GMO_SECRET=""
CONOHA_DENANT_ID=""
CONOHA_DENANT_NAME=""
CONOHA_USER_NAME=""
-CONOHA_USER_PASS=""
\ No newline at end of file
+CONOHA_USER_PASS=""
+
+YOUTUBE_API=""
+LBRY_URI=""
+PEER_URI=""
+PEER_USER=""
+PEER_PASS=""
\ No newline at end of file
diff --git a/app/Http/Controllers/BashController.php b/app/Http/Controllers/BashController.php
index 09ff50d..5356ae8 100644
--- a/app/Http/Controllers/BashController.php
+++ b/app/Http/Controllers/BashController.php
@@ -28,11 +28,11 @@ class BashController extends Controller {
if (mb_substr($args[$i], 0, 1, 'utf-8')) $opt = $args[$i];
}
- if (strpos($opt, 'l') !== false) {
+ if (str_contains($opt, 'l')) {
$ps = null;
$pg = null;
- if (strpos($opt, 't') !== false) {
+ if (str_contains($opt, 't')) {
$pg = DB::table('blg_content')->select('publish_date')->where('isPost', 0)->orderBy('title', 'asc')->first();
$ps = DB::table('blg_content')->select('publish_date')->where('isPost', 1)->orderBy('title', 'asc')->first();
}
@@ -42,8 +42,8 @@ class BashController extends Controller {
}
return "合計 2
-drwxr-xr-x 2 suwako suwako ".(strpos($opt, 'h') !== false ? '4.0K' : '4096')." ".date('m', $ps->publish_date)."月 ".date('d', $ps->publish_date)." ".date('H:i', $ps->publish_date)." post
-drwxr-xr-x 2 suwako suwako ".(strpos($opt, 'h') !== false ? '4.0K' : '4096')." ".date('m', $pg->publish_date)."月 ".date('d', $pg->publish_date)." ".date('H:i', $pg->publish_date)." page";
+drwxr-xr-x 2 suwako suwako ".(str_contains($opt, 'h') ? '4.0K' : '4096')." ".date('m', $ps->publish_date)."月 ".date('d', $ps->publish_date)." ".date('H:i', $ps->publish_date)." post
+drwxr-xr-x 2 suwako suwako ".(str_contains($opt, 'h') ? '4.0K' : '4096')." ".date('m', $pg->publish_date)."月 ".date('d', $pg->publish_date)." ".date('H:i', $pg->publish_date)." page";
}
return 'post page';
@@ -57,7 +57,7 @@ drwxr-xr-x 2 suwako suwako ".(strpos($opt, 'h') !== false ? '4.0K' : '4096')."
$slug = '';
for ($i = 1; $i < count($cat); $i++) {
- if (strpos($cat[$i], 'post') !== false) $mode = 1;
+ if (str_contains($cat[$i], 'post')) $mode = 1;
$slug = $cat[$i];
}
diff --git a/app/Http/Controllers/Home/Comment.php b/app/Http/Controllers/Home/Comment.php
index a4af3dc..bdd970b 100644
--- a/app/Http/Controllers/Home/Comment.php
+++ b/app/Http/Controllers/Home/Comment.php
@@ -13,7 +13,7 @@ class Comment {
$user = null;
if (isset($_COOKIE['kero_token'])) $user = DB::table('users')->select('id')->where('kero_token', $_COOKIE['kero_token'])->first()->id;
- if ($user == 0 && (strpos($r->newmessage, 'http://') !== false || strpos($r->newmessage, 'https://') !== false)) return redirect('/');
+ if ($user == 0 && (str_contains($r->newmessage, 'http://') || str_contains($r->newmessage, 'https://'))) return redirect('/');
$add = DB::table('blg_comments')->insertGetId([
'user_id' => $user,
diff --git a/app/Http/Controllers/Home/Contact.php b/app/Http/Controllers/Home/Contact.php
new file mode 100644
index 0000000..03c7044
--- /dev/null
+++ b/app/Http/Controllers/Home/Contact.php
@@ -0,0 +1,169 @@
+field = [
+ 'kenmei' => '',
+ 'adr' => '',
+ 'cat' => '',
+ 'cats' => [
+ '' => '',
+ 'bugreport' => 'バグ報告したい',
+ 'chat' => 'チャットサービス(XMPP、IRC、Mumble)について聞きたい',
+ 'social' => 'SNSサービス(Pleroma、PeerTube)について聞きたい',
+ 'privfront' => '代替SNSフロントサービス(Nitter、Invidious、Librarian、Searx)について聞きたい',
+ 'storage' => 'ストレージサービス(Gitea、Nextcloud)について聞きたい',
+ 'otherserv' => '076外サービス(テク諏訪、076萌、URLoli、some.very.questionable.website、hozon.site、xmr.jp等)について聞きたい',
+ 'scam1' => 'DMCA報告したい',
+ 'scam2' => '営業したい',
+ 'scam3' => '法律について',
+ 'scam4' => '税金について',
+ 'scam5' => '無駄な話',
+ ],
+ 'bunsyo' => '',
+ 'gpg' => '',
+ 'ruleapply' => false,
+ ];
+ }
+
+ public function index (Request $r) {
+ if (isset($r->submit)) return $this->send($r);
+ return view('pages.site.contact', ['field' => $this->field, 'err' => []]);
+ }
+
+ public function seiko () {
+ return view('pages.site.contact-seiko', ['field' => $this->field, 'suc' => ['メールを送りました!', '送信者様は連絡ルールを守ったら、24時間以内で返事します。']]);
+ }
+
+ public function send (Request $r) {
+ $this->field['adr'] = $r->adr;
+ $this->field['kenmei'] = $r->kenmei;
+ $this->field['cat'] = $r->cat;
+ $this->field['catname'] = $r->cat;
+ $this->field['gpg'] = !isset($r->gpg) || is_null($r->gpg) || $r->gpg == '' ? null : file_get_contents($r->file('gpg'));
+ $this->field['bunsyo'] = $r->bunsyo;
+ $this->field['ruleapply'] = isset($r->ruleapply);
+
+ $err = [];
+ $gpg = null;
+
+ // メールアドレス
+ if (!isset($this->field['adr']) || is_null($this->field['adr']) || $this->field['adr'] == '') $err[] = 'メールアドレスをご入力下さい。';
+ else if (!filter_var($this->field['adr'], FILTER_VALIDATE_EMAIL)) $err[] = 'メールアドレスを正しくご入力下さい。';
+ $this->field['filename'] = trim($this->field['adr']).'.key';
+
+ // 件名
+ if (!isset($this->field['kenmei']) || is_null($this->field['kenmei']) || $this->field['kenmei'] == '') $err[] = '件名をご入力下さい。';
+ if (str_contains($this->field['kenmei'], 'http://') || str_contains($this->field['kenmei'], 'https://')) $err[] = '件名でURLを入らないで下さい。';
+ $this->field['bunsyo'] = trim($this->field['bunsyo']);
+
+ // カテゴリ
+ if (!isset($this->field['cat']) || is_null($this->field['cat']) || $this->field['cat'] == '') $err[] = 'カテゴリをご選択下さい。';
+
+ // GPG
+ if (!isset($this->field['gpg']) || is_null($this->field['gpg']) || $this->field['gpg'] == '') $err[] = 'GPGをご選択下さい。';
+ else {
+ $gpg = new \gnupg();
+ $info = $gpg->import($this->field['gpg']);
+ $gpg->addencryptkey($info['fingerprint']);
+ Storage::disk('public')->put($this->field['filename'], $this->field['gpg']);
+ $path = Storage::disk('public')->path($this->field['filename']);
+ $verifygpg = explode("\n", $this->run('gpg --dry-run --import '.$path))[0];
+ if (!str_contains($verifygpg, '処理数の合計: 1') && !str_contains($verifygpg, 'Total number processed: 1')) $err[] = $verifygpg;
+ }
+
+ // 文章
+ if (!isset($this->field['bunsyo']) || is_null($this->field['bunsyo']) || $this->field['bunsyo'] == '') $err[] = '文章をご入力下さい。';
+ if (str_contains($this->field['bunsyo'], 'http://') || str_contains($this->field['bunsyo'], 'https://')) $err[] = '文章でURLを入らないで下さい。';
+ if (isset($this->field['gpg']) && !is_null($this->field['gpg']) && $this->field['gpg'] != '') $this->field['bunsyo'] = $gpg->encrypt(trim("メール: ".$this->field['adr']."\n\n".$this->field['bunsyo']));
+
+ // 連絡ルール
+ if (!$this->field['ruleapply']) $err[] = 'ルールを同意して下さい。';
+
+ if (!empty($err)) {
+ if (isset($this->field['gpg']) && !is_null($this->field['gpg']) && $this->field['gpg'] != '') {
+ Storage::disk('public')->delete($this->field['filename']);
+ $this->field['bunsyo'] = $r->bunsyo;
+ }
+ return view('pages.site.contact', ['field' => $this->field, 'err' => $err]);
+ }
+
+ // カテゴリはDMCA報告、営業、税金、法律、又は無駄な話を選択したら、いつでも送信せず失敗します。
+ if (str_contains($this->field['cat'], 'scam')) {
+ if (isset($this->field['gpg']) && !is_null($this->field['gpg']) && $this->field['gpg'] != '') {
+ Storage::disk('public')->delete($this->field['filename']);
+ $this->field['bunsyo'] = $r->bunsyo;
+ }
+ return view('pages.site.contact', ['field' => $this->field, 'err' => ['送信に失敗しました。数時間後もう一回送信してみて下さい。']]);
+ }
+
+ foreach ($this->field['cats'] as $i => $c) {
+ if ($this->field['cat'] == $i) $this->field['catname'] = $c;
+ }
+
+ // メールを送る
+ try {
+ $mail = new MailerController();
+ if (!$mail->compose($this->field, true)) {
+ if (isset($this->field['gpg']) && !is_null($this->field['gpg']) && $this->field['gpg'] != '') {
+ Storage::disk('public')->delete($this->field['filename']);
+ $this->field['bunsyo'] = $r->bunsyo;
+ }
+ return view('pages.site.contact', ['field' => $this->field, 'err' => ['送信に失敗しました。数時間後もう一回送信してみて下さい。']]);
+ }
+ } catch (\Throwable $e) {
+ if (isset($this->field['gpg']) && !is_null($this->field['gpg']) && $this->field['gpg'] != '') {
+ Storage::disk('public')->delete($this->field['filename']);
+ $this->field['bunsyo'] = $r->bunsyo;
+ }
+ Log::critical($e);
+ return view('pages.site.contact', ['field' => $this->field, 'err' => ['送信に失敗しました。数時間後もう一回送信してみて下さい。']]);
+ }
+
+ Storage::disk('public')->delete($this->field['filename']);
+ $this->field['kenmei'] = '';
+ $this->field['adr'] = '';
+ $this->field['cat'] = '';
+ $this->field['bunsyo'] = '';
+ $this->field['gpg'] = '';
+ $this->field['ruleapply'] = false;
+
+ return redirect('/contact/seiko');
+ }
+
+ function run ($bin, $command = '', $force = true) {
+ $stream = null;
+ $bin .= $force ? ' 2>&1' : '';
+
+ $descriptorSpec = array(
+ 0 => array('pipe', 'r'),
+ 1 => array('pipe', 'w')
+ );
+
+ $process = proc_open($bin, $descriptorSpec, $pipes);
+
+ if (is_resource($process)) {
+ fwrite($pipes[0], $command);
+ fclose($pipes[0]);
+
+ $stream = stream_get_contents($pipes[1]);
+ fclose($pipes[1]);
+
+ proc_close($process);
+ }
+
+ return $stream;
+ }
+}
\ No newline at end of file
diff --git a/app/Http/Controllers/Home/Content.php b/app/Http/Controllers/Home/Content.php
index 073fca8..b45796b 100644
--- a/app/Http/Controllers/Home/Content.php
+++ b/app/Http/Controllers/Home/Content.php
@@ -48,7 +48,7 @@ class Content extends Engine {
$frm['public_status'] = $r->public_status;
$frm['publish_date'] = $r->publish_date;
$frm['isMenu'] = (int)!is_null($r->isMenu) && $r->isMenu == 'on';
- $frm['isPost'] = (int)!is_null($r->isPost) && $r->isPost == 'on';
+ $frm['isPost'] = (int)!is_null($r->isPost) && $r->isPost == '1';
$frm['message'] = $r->message;
// 件名、文章又はスラッグがなければ、エラーを出て
diff --git a/app/Http/Controllers/MailerController.php b/app/Http/Controllers/MailerController.php
new file mode 100644
index 0000000..f5274d1
--- /dev/null
+++ b/app/Http/Controllers/MailerController.php
@@ -0,0 +1,74 @@
+SMTPDebug = 2;
+ $mail->isSMTP();
+ $mail->Host = config('mail.mailers.smtp.host');
+ $mail->Port = config('mail.mailers.smtp.port');
+ $mail->SMTPSecure = config('mail.mailers.smtp.encryption');
+ $mail->SMTPAuth = true;
+ $mail->From = config('mail.'.($form ? 'owner' : 'from').'.address');
+ $mail->FromName = mb_encode_mimeheader(config('mail.mailers.smtp.'.($form ? 'fromname' : 'noreplyfrom')), 'JIS');
+ $mail->Username = config('mail.mailers.smtp.'.($form ? 'username' : 'noreplyuser'));
+ $mail->Password = config('mail.mailers.smtp.'.($form ? 'password' : 'noreplypass'));
+
+ $mail->AddAddress(config('mail.'.($form ? 'owner' : 'from').'.address'));
+ if ($form) $mail->addReplyTo(config('mail.owner.address'), config('mail.owner.name'));
+ else $mail->addReplyTo($val['adr']);
+
+ $mail->SMTPOptions = [
+ 'ssl' => [
+ 'verify_peer' => false,
+ 'verify_peer_name' => false,
+ 'allow_self_signed' => true
+ ]
+ ];
+
+ if (isset($val['attach'])) {
+ for ($i=0; $i < count($val['attach']); $i++) {
+ $mail->AddAttachment($val['attach'][$i], $val['attachname'][$i]);
+ }
+ }
+
+ if (isset($val['gpg'])) {
+ $mail->AddStringAttachment($val['gpg'], $val['filename']);
+ $mail->AddStringAttachment($val['bunsyo'], $val['adr'].'.gpg');
+ }
+
+ $mail->isHTML(false);
+
+ $mail->Subject = mb_encode_mimeheader('【'.$val['catname'].'】'.$val['kenmei'], 'JIS');
+ if ($form) $mail->Body = mb_convert_encoding($val['bunsyo'], 'UTF-8');
+ else $mail->Body = mb_convert_encoding($val['bunsyo'], 'JIS');
+
+ if (!$mail->send()) {
+ Log::critical('Mailer error: ' . $mail->ErrorInfo);
+ return false;
+ }
+ } catch (Exception $e) {
+ Log::critical($e);
+ return false;
+ }
+
+ return true;
+ }
+}
diff --git a/app/Http/Controllers/RssFeedController.php b/app/Http/Controllers/RssFeedController.php
new file mode 100644
index 0000000..9890186
--- /dev/null
+++ b/app/Http/Controllers/RssFeedController.php
@@ -0,0 +1,23 @@
+select($select)->where('isPost', true)->where('public_status', 0)->orderBy('id', 'desc')->limit(50)->get();
+
+ foreach ($posts as $k => $v) {
+ $userd = DB::table('users')->where('id', $v->user_id)->first();
+ $userd = DB::table('usr_profile')->where('user_id', $v->user_id)->first();
+ $v->user = $userd->display_name;
+ unset($posts[$k]->user_id);
+ }
+
+ return response()->view('rss.feed', ['posts' => $posts])->header('Content-Type', 'application/xml');
+ }
+}
diff --git a/app/Http/Controllers/Video/Prayer.php b/app/Http/Controllers/Video/Prayer.php
index 341a7bc..b13cb7b 100644
--- a/app/Http/Controllers/Video/Prayer.php
+++ b/app/Http/Controllers/Video/Prayer.php
@@ -98,6 +98,7 @@ class Prayer extends Engine {
if (!$get) return $err;
$get = json_decode($get);
+ if (isset($get->status) && $get->status == 404) return [];
$come = array();
$come['come'] = array();
@@ -116,7 +117,7 @@ class Prayer extends Engine {
$g->comments->id = $g->id;
$g->comments->name = $g->account->displayName;
$g->comments->channel = $g->account->url;
- $g->comments->icon = env('PEER_URI').$g->account->avatar->path;
+ $g->comments->icon = !is_null($g->account->avatar) ? env('PEER_URI').$g->account->avatar->path : '/img/noicon.jpg';
$g->comments->message = strip_tags($g->text, array('
'));
$g->comments->createdTS = strtotime($g->createdAt);
$g->comments->created = date('Y年m月d日 H:i:s', strtotime($g->createdAt));
diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php
index ee8ca5b..d1f5496 100644
--- a/app/Providers/AppServiceProvider.php
+++ b/app/Providers/AppServiceProvider.php
@@ -3,6 +3,7 @@
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
+use Illuminate\Pagination\Paginator;
class AppServiceProvider extends ServiceProvider
{
@@ -23,6 +24,6 @@ class AppServiceProvider extends ServiceProvider
*/
public function boot()
{
- //
+ Paginator::useBootstrap();
}
}
diff --git a/composer.json b/composer.json
index 29a9d63..45a6e77 100644
--- a/composer.json
+++ b/composer.json
@@ -2,37 +2,24 @@
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
- "keywords": [
- "framework",
- "laravel"
- ],
+ "keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
- "php": "^7.2.5",
- "fideloper/proxy": "^4.2",
- "fruitcake/laravel-cors": "^1.0",
- "guzzlehttp/guzzle": "^6.3",
- "laravel/framework": "^7.0",
- "laravel/tinker": "^2.0",
- "phpmailer/phpmailer": "^6.2",
- "predis/predis": "^1.1"
+ "php": "^8.0",
+ "fideloper/proxy": "^4.4.1",
+ "fruitcake/laravel-cors": "^2.0.4",
+ "guzzlehttp/guzzle": "^7.4.0",
+ "laravel/framework": "^8.74.0",
+ "laravel/tinker": "^2.6.2",
+ "phpmailer/phpmailer": "^6.5",
+ "predis/predis": "^1.1.9"
},
"require-dev": {
- "facade/ignition": "^2.0",
- "fzaninotto/faker": "^1.9.1",
- "mockery/mockery": "^1.3.1",
- "nunomaduro/collision": "^4.1",
- "phpunit/phpunit": "^8.5"
- },
- "config": {
- "optimize-autoloader": true,
- "preferred-install": "dist",
- "sort-packages": true
- },
- "extra": {
- "laravel": {
- "dont-discover": []
- }
+ "facade/ignition": "^2.5",
+ "fakerphp/faker": "^1.16.0",
+ "mockery/mockery": "^1.4.2",
+ "nunomaduro/collision": "^5.0",
+ "phpunit/phpunit": "^9.5.10"
},
"autoload": {
"psr-4": {
@@ -51,8 +38,6 @@
"Tests\\": "tests/"
}
},
- "minimum-stability": "dev",
- "prefer-stable": true,
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
@@ -64,5 +49,17 @@
"post-create-project-cmd": [
"@php artisan key:generate --ansi"
]
- }
+ },
+ "extra": {
+ "laravel": {
+ "dont-discover": []
+ }
+ },
+ "config": {
+ "optimize-autoloader": true,
+ "preferred-install": "dist",
+ "sort-packages": true
+ },
+ "minimum-stability": "dev",
+ "prefer-stable": true
}
diff --git a/config/filesystems.php b/config/filesystems.php
index 94c8112..2ea896a 100644
--- a/config/filesystems.php
+++ b/config/filesystems.php
@@ -55,6 +55,13 @@ return [
'visibility' => 'public',
],
+ 'private' => [
+ 'driver' => 'local',
+ 'root' => storage_path('app/private'),
+ 'url' => env('APP_URL').'/storage',
+ 'visibility' => 'private',
+ ],
+
's3' => [
'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'),
diff --git a/config/mail.php b/config/mail.php
index d67deb6..c1894fd 100644
--- a/config/mail.php
+++ b/config/mail.php
@@ -39,8 +39,13 @@ return [
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
+ 'fromname' => env('MAIL_OWNER_NAME'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
+ 'noreplyfrom' => env('MAIL_FROM_NAME'),
+ 'noreplyuser' => env('MAIL_NOREPLY_USER'),
+ 'noreplypass' => env('MAIL_NOREPLY_PASS'),
+ 'sendmail' => '/usr/sbin/sendmail -bs',
'timeout' => null,
'auth_mode' => null,
],
@@ -87,6 +92,10 @@ return [
'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
'name' => env('MAIL_FROM_NAME', 'Example'),
],
+ 'owner' => [
+ 'address' => env('MAIL_OWNER_ADDRESS', 'hello@example.com'),
+ 'name' => env('MAIL_OWNER_NAME', 'Example'),
+ ],
/*
|--------------------------------------------------------------------------
diff --git a/resources/views/pages/site/contact-seiko.blade.php b/resources/views/pages/site/contact-seiko.blade.php
new file mode 100644
index 0000000..df20af4
--- /dev/null
+++ b/resources/views/pages/site/contact-seiko.blade.php
@@ -0,0 +1,15 @@
+@extends('theme.'.env('THEME').'.site')
+
+@section('content')
+