├── public
├── favicon.ico
├── robots.txt
├── logo.png
├── background.jpg
├── .htaccess
├── web.config
├── index.php
├── style.css
└── script.js
├── bootstrap
├── cache
│ └── .gitignore
└── app.php
├── storage
├── logs
│ └── .gitignore
└── framework
│ ├── testing
│ └── .gitignore
│ ├── views
│ └── .gitignore
│ ├── cache
│ ├── data
│ │ └── .gitignore
│ └── .gitignore
│ ├── sessions
│ └── .gitignore
│ └── .gitignore
├── .gitattributes
├── .gitignore
├── .editorconfig
├── app
├── Http
│ ├── Middleware
│ │ ├── EncryptCookies.php
│ │ ├── VerifyCsrfToken.php
│ │ ├── TrustHosts.php
│ │ ├── PreventRequestsDuringMaintenance.php
│ │ ├── TrimStrings.php
│ │ ├── Authenticate.php
│ │ ├── TrustProxies.php
│ │ ├── RedirectIfAuthenticated.php
│ │ └── UnescapeJsonResponse.php
│ ├── Controllers
│ │ ├── Controller.php
│ │ └── KakologController.php
│ └── Kernel.php
├── Providers
│ ├── BroadcastServiceProvider.php
│ ├── AppServiceProvider.php
│ ├── AuthServiceProvider.php
│ ├── EventServiceProvider.php
│ └── RouteServiceProvider.php
├── Console
│ └── Kernel.php
├── Exceptions
│ └── Handler.php
└── Models
│ ├── JsonSerializer.php
│ └── Kakolog.php
├── .env.example
├── routes
├── api.php
├── console.php
└── web.php
├── server.php
├── config
├── cors.php
├── services.php
├── view.php
├── hashing.php
├── broadcasting.php
├── filesystems.php
├── queue.php
├── cache.php
├── mail.php
├── logging.php
├── auth.php
├── database.php
├── session.php
└── app.php
├── License.txt
├── composer.json
├── artisan
├── Readme.md
└── resources
└── views
└── index.blade.php
/public/favicon.ico:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/bootstrap/cache/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/storage/logs/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/public/robots.txt:
--------------------------------------------------------------------------------
1 | User-agent: *
2 | Disallow:
3 |
--------------------------------------------------------------------------------
/storage/framework/testing/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/storage/framework/views/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/storage/framework/cache/data/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/storage/framework/sessions/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/storage/framework/cache/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !data/
3 | !.gitignore
4 |
--------------------------------------------------------------------------------
/public/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tsukumijima/jikkyo-api/master/public/logo.png
--------------------------------------------------------------------------------
/public/background.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tsukumijima/jikkyo-api/master/public/background.jpg
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=auto
2 | *.css linguist-vendored
3 | *.scss linguist-vendored
4 | *.js linguist-vendored
5 | CHANGELOG.md export-ignore
6 |
--------------------------------------------------------------------------------
/storage/framework/.gitignore:
--------------------------------------------------------------------------------
1 | config.php
2 | routes.php
3 | schedule-*
4 | compiled.php
5 | services.json
6 | events.scanned.php
7 | routes.scanned.php
8 | down
9 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /JKCommentCrawler
2 | /node_modules
3 | /public/hot
4 | /public/storage
5 | /storage/*.key
6 | /vendor
7 | .env
8 | .env.backup
9 | .phpunit.result.cache
10 | Homestead.json
11 | Homestead.yaml
12 | npm-debug.log
13 | yarn-error.log
14 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | charset = utf-8
5 | end_of_line = lf
6 | insert_final_newline = true
7 | indent_style = space
8 | indent_size = 4
9 | trim_trailing_whitespace = true
10 |
11 | [*.md]
12 | trim_trailing_whitespace = false
13 |
14 | [*.{yml,yaml}]
15 | indent_size = 2
16 |
--------------------------------------------------------------------------------
/app/Http/Middleware/EncryptCookies.php:
--------------------------------------------------------------------------------
1 | allSubdomainsOfApplicationUrl(),
18 | ];
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/app/Http/Middleware/PreventRequestsDuringMaintenance.php:
--------------------------------------------------------------------------------
1 | expectsJson()) {
18 | return route('login');
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/routes/console.php:
--------------------------------------------------------------------------------
1 | comment(Inspiring::quote());
18 | })->describe('Display an inspiring quote');
19 |
--------------------------------------------------------------------------------
/server.php:
--------------------------------------------------------------------------------
1 |
8 | */
9 |
10 | $uri = urldecode(
11 | parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
12 | );
13 |
14 | // This file allows us to emulate Apache's "mod_rewrite" functionality from the
15 | // built-in PHP web server. This provides a convenient way to test a Laravel
16 | // application without having installed a "real" web server software here.
17 | if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) {
18 | return false;
19 | }
20 |
21 | require_once __DIR__.'/public/index.php';
22 |
--------------------------------------------------------------------------------
/public/.htaccess:
--------------------------------------------------------------------------------
1 |
2 |
3 | Options -MultiViews -Indexes
4 |
5 |
6 | RewriteEngine On
7 |
8 | # Handle Authorization Header
9 | RewriteCond %{HTTP:Authorization} .
10 | RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
11 |
12 | # Redirect Trailing Slashes If Not A Folder...
13 | RewriteCond %{REQUEST_FILENAME} !-d
14 | RewriteCond %{REQUEST_URI} (.+)/$
15 | RewriteRule ^ %1 [L,R=301]
16 |
17 | # Handle Front Controller...
18 | RewriteCond %{REQUEST_FILENAME} !-d
19 | RewriteCond %{REQUEST_FILENAME} !-f
20 | RewriteRule ^ index.php [L]
21 |
22 |
--------------------------------------------------------------------------------
/routes/web.php:
--------------------------------------------------------------------------------
1 | 'App\Policies\ModelPolicy',
17 | ];
18 |
19 | /**
20 | * Register any authentication / authorization services.
21 | *
22 | * @return void
23 | */
24 | public function boot()
25 | {
26 | $this->registerPolicies();
27 |
28 | //
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/app/Http/Middleware/TrustProxies.php:
--------------------------------------------------------------------------------
1 | command('inspire')->hourly();
19 | }
20 |
21 | /**
22 | * Register the commands for the application.
23 | *
24 | * @return void
25 | */
26 | protected function commands()
27 | {
28 | $this->load(__DIR__.'/Commands');
29 |
30 | require base_path('routes/console.php');
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/app/Providers/EventServiceProvider.php:
--------------------------------------------------------------------------------
1 | [
19 | SendEmailVerificationNotification::class,
20 | ],
21 | ];
22 |
23 | /**
24 | * Register any events for your application.
25 | *
26 | * @return void
27 | */
28 | public function boot()
29 | {
30 | //
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/app/Http/Middleware/RedirectIfAuthenticated.php:
--------------------------------------------------------------------------------
1 | check()) {
26 | return redirect(RouteServiceProvider::HOME);
27 | }
28 | }
29 |
30 | return $next($request);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/config/cors.php:
--------------------------------------------------------------------------------
1 | ['api/*'],
19 |
20 | 'allowed_methods' => ['*'],
21 |
22 | 'allowed_origins' => ['*'],
23 |
24 | 'allowed_origins_patterns' => [],
25 |
26 | 'allowed_headers' => ['*'],
27 |
28 | 'exposed_headers' => [],
29 |
30 | 'max_age' => 0,
31 |
32 | 'supports_credentials' => false,
33 |
34 | ];
35 |
--------------------------------------------------------------------------------
/app/Exceptions/Handler.php:
--------------------------------------------------------------------------------
1 | reportable(function (Throwable $e) {
38 | //
39 | });
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/License.txt:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2020-2022 tsukumi
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 |
7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 |
9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10 |
--------------------------------------------------------------------------------
/config/services.php:
--------------------------------------------------------------------------------
1 | [
18 | 'domain' => env('MAILGUN_DOMAIN'),
19 | 'secret' => env('MAILGUN_SECRET'),
20 | 'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'),
21 | ],
22 |
23 | 'postmark' => [
24 | 'token' => env('POSTMARK_TOKEN'),
25 | ],
26 |
27 | 'ses' => [
28 | 'key' => env('AWS_ACCESS_KEY_ID'),
29 | 'secret' => env('AWS_SECRET_ACCESS_KEY'),
30 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
31 | ],
32 |
33 | ];
34 |
--------------------------------------------------------------------------------
/config/view.php:
--------------------------------------------------------------------------------
1 | [
17 | resource_path('views'),
18 | ],
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Compiled View Path
23 | |--------------------------------------------------------------------------
24 | |
25 | | This option determines where all the compiled Blade templates will be
26 | | stored for your application. Typically, this is within the storage
27 | | directory. However, as usual, you are free to change this value.
28 | |
29 | */
30 |
31 | 'compiled' => env(
32 | 'VIEW_COMPILED_PATH',
33 | realpath(storage_path('framework/views'))
34 | ),
35 |
36 | ];
37 |
--------------------------------------------------------------------------------
/app/Http/Middleware/UnescapeJsonResponse.php:
--------------------------------------------------------------------------------
1 | getEncodingOptions() | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT;
31 | } else {
32 | $newEncodingOptions = $response->getEncodingOptions() | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES;
33 | }
34 | $response->setEncodingOptions($newEncodingOptions);
35 |
36 | return $response;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/public/web.config:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/config/hashing.php:
--------------------------------------------------------------------------------
1 | 'bcrypt',
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Bcrypt Options
23 | |--------------------------------------------------------------------------
24 | |
25 | | Here you may specify the configuration options that should be used when
26 | | passwords are hashed using the Bcrypt algorithm. This will allow you
27 | | to control the amount of time it takes to hash the given password.
28 | |
29 | */
30 |
31 | 'bcrypt' => [
32 | 'rounds' => env('BCRYPT_ROUNDS', 10),
33 | ],
34 |
35 | /*
36 | |--------------------------------------------------------------------------
37 | | Argon Options
38 | |--------------------------------------------------------------------------
39 | |
40 | | Here you may specify the configuration options that should be used when
41 | | passwords are hashed using the Argon algorithm. These will allow you
42 | | to control the amount of time it takes to hash the given password.
43 | |
44 | */
45 |
46 | 'argon' => [
47 | 'memory' => 1024,
48 | 'threads' => 2,
49 | 'time' => 2,
50 | ],
51 |
52 | ];
53 |
--------------------------------------------------------------------------------
/bootstrap/app.php:
--------------------------------------------------------------------------------
1 | singleton(
30 | Illuminate\Contracts\Http\Kernel::class,
31 | App\Http\Kernel::class
32 | );
33 |
34 | $app->singleton(
35 | Illuminate\Contracts\Console\Kernel::class,
36 | App\Console\Kernel::class
37 | );
38 |
39 | $app->singleton(
40 | Illuminate\Contracts\Debug\ExceptionHandler::class,
41 | App\Exceptions\Handler::class
42 | );
43 |
44 | /*
45 | |--------------------------------------------------------------------------
46 | | Return The Application
47 | |--------------------------------------------------------------------------
48 | |
49 | | This script returns the application instance. The instance is given to
50 | | the calling script so we can separate the building of the instances
51 | | from the actual running of the application and sending responses.
52 | |
53 | */
54 |
55 | return $app;
56 |
--------------------------------------------------------------------------------
/app/Models/JsonSerializer.php:
--------------------------------------------------------------------------------
1 | count()) {
27 | // serialize children if there are children
28 | /**
29 | * @var string $tag
30 | * @var JsonSerializer $child
31 | */
32 | foreach ($this as $tag => $child) {
33 | $temp = $child->jsonSerialize();
34 | $attributes = [];
35 |
36 | foreach ($child->attributes() as $name => $value) {
37 | $attributes[$name] = (string) $value;
38 | }
39 |
40 | $array[][$tag] = array_merge($attributes, $temp);
41 | }
42 | } else {
43 | // serialize attributes and text for a leaf-elements
44 | $temp = (string) $this;
45 |
46 | // if only contains empty string, it is actually an empty element
47 | if (trim($temp) !== "") {
48 | $array[self::CONTENT_NAME] = $temp;
49 | }
50 | }
51 |
52 | if ($this->xpath('/*') == array($this)) {
53 | // the root element needs to be named
54 | $array = [$this->getName() => $array];
55 | }
56 |
57 | return $array;
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "laravel/laravel",
3 | "type": "project",
4 | "description": "The Laravel Framework.",
5 | "keywords": [
6 | "framework",
7 | "laravel"
8 | ],
9 | "license": "MIT",
10 | "require": {
11 | "php": "^7.3.0|^8.0",
12 | "fruitcake/laravel-cors": "^2.0",
13 | "guzzlehttp/guzzle": "^7.0.1",
14 | "laravel/framework": "^8.0",
15 | "laravel/tinker": "^2.5",
16 | "wulfheart/pretty_routes": "^0.3.0"
17 | },
18 | "require-dev": {
19 | "barryvdh/laravel-ide-helper": "^2.13.0",
20 | "facade/ignition": "^2.5",
21 | "fakerphp/faker": "^1.9.1",
22 | "mockery/mockery": "^1.4.4",
23 | "nunomaduro/collision": "^5.10",
24 | "phpunit/phpunit": "^9.5.10"
25 | },
26 | "autoload": {
27 | "psr-4": {
28 | "App\\": "app/"
29 | }
30 | },
31 | "scripts": {
32 | "post-autoload-dump": [
33 | "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
34 | "@php artisan package:discover --ansi"
35 | ],
36 | "post-update-cmd": [
37 | "@php artisan vendor:publish --tag=laravel-assets --ansi",
38 | "@php artisan ide-helper:generate"
39 | ],
40 | "post-root-package-install": [
41 | "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
42 | ],
43 | "post-create-project-cmd": [
44 | "@php artisan key:generate --ansi"
45 | ]
46 | },
47 | "extra": {
48 | "laravel": {
49 | "dont-discover": []
50 | }
51 | },
52 | "config": {
53 | "optimize-autoloader": true,
54 | "preferred-install": "dist",
55 | "sort-packages": true
56 | },
57 | "minimum-stability": "dev",
58 | "prefer-stable": true
59 | }
60 |
--------------------------------------------------------------------------------
/artisan:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env php
2 | make(Illuminate\Contracts\Console\Kernel::class);
34 |
35 | $status = $kernel->handle(
36 | $input = new Symfony\Component\Console\Input\ArgvInput,
37 | new Symfony\Component\Console\Output\ConsoleOutput
38 | );
39 |
40 | /*
41 | |--------------------------------------------------------------------------
42 | | Shutdown The Application
43 | |--------------------------------------------------------------------------
44 | |
45 | | Once Artisan has finished running, we will fire off the shutdown events
46 | | so that any final work may be done by the application before we shut
47 | | down the process. This is the last thing to happen to the request.
48 | |
49 | */
50 |
51 | $kernel->terminate($input, $status);
52 |
53 | exit($status);
54 |
--------------------------------------------------------------------------------
/app/Providers/RouteServiceProvider.php:
--------------------------------------------------------------------------------
1 | configureRateLimiting();
39 |
40 | $this->routes(function () {
41 | Route::prefix('api')
42 | ->middleware('api')
43 | ->namespace($this->namespace)
44 | ->group(base_path('routes/api.php'));
45 |
46 | Route::middleware('web')
47 | ->namespace($this->namespace)
48 | ->group(base_path('routes/web.php'));
49 | });
50 | }
51 |
52 | /**
53 | * Configure the rate limiters for the application.
54 | *
55 | * @return void
56 | */
57 | protected function configureRateLimiting()
58 | {
59 | RateLimiter::for('api', function (Request $request) {
60 | return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip());
61 | });
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/config/broadcasting.php:
--------------------------------------------------------------------------------
1 | env('BROADCAST_DRIVER', 'null'),
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Broadcast Connections
23 | |--------------------------------------------------------------------------
24 | |
25 | | Here you may define all of the broadcast connections that will be used
26 | | to broadcast events to other systems or over websockets. Samples of
27 | | each available type of connection are provided inside this array.
28 | |
29 | */
30 |
31 | 'connections' => [
32 |
33 | 'pusher' => [
34 | 'driver' => 'pusher',
35 | 'key' => env('PUSHER_APP_KEY'),
36 | 'secret' => env('PUSHER_APP_SECRET'),
37 | 'app_id' => env('PUSHER_APP_ID'),
38 | 'options' => [
39 | 'cluster' => env('PUSHER_APP_CLUSTER'),
40 | 'useTLS' => true,
41 | ],
42 | ],
43 |
44 | 'ably' => [
45 | 'driver' => 'ably',
46 | 'key' => env('ABLY_KEY'),
47 | ],
48 |
49 | 'redis' => [
50 | 'driver' => 'redis',
51 | 'connection' => 'default',
52 | ],
53 |
54 | 'log' => [
55 | 'driver' => 'log',
56 | ],
57 |
58 | 'null' => [
59 | 'driver' => 'null',
60 | ],
61 |
62 | ],
63 |
64 | ];
65 |
--------------------------------------------------------------------------------
/public/index.php:
--------------------------------------------------------------------------------
1 |
8 | */
9 |
10 | define('LARAVEL_START', microtime(true));
11 |
12 | /*
13 | |--------------------------------------------------------------------------
14 | | Register The Auto Loader
15 | |--------------------------------------------------------------------------
16 | |
17 | | Composer provides a convenient, automatically generated class loader for
18 | | our application. We just need to utilize it! We'll simply require it
19 | | into the script here so that we don't have to worry about manual
20 | | loading any of our classes later on. It feels great to relax.
21 | |
22 | */
23 |
24 | require __DIR__.'/../vendor/autoload.php';
25 |
26 | /*
27 | |--------------------------------------------------------------------------
28 | | Turn On The Lights
29 | |--------------------------------------------------------------------------
30 | |
31 | | We need to illuminate PHP development, so let us turn on the lights.
32 | | This bootstraps the framework and gets it ready for use, then it
33 | | will load up this application so that we can run it and send
34 | | the responses back to the browser and delight our users.
35 | |
36 | */
37 |
38 | $app = require_once __DIR__.'/../bootstrap/app.php';
39 |
40 | /*
41 | |--------------------------------------------------------------------------
42 | | Run The Application
43 | |--------------------------------------------------------------------------
44 | |
45 | | Once we have the application, we can handle the incoming request
46 | | through the kernel, and send the associated response back to
47 | | the client's browser allowing them to enjoy the creative
48 | | and wonderful application we have prepared for them.
49 | |
50 | */
51 |
52 | $kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
53 |
54 | $response = $kernel->handle(
55 | $request = Illuminate\Http\Request::capture()
56 | );
57 |
58 | $response->send();
59 |
60 | $kernel->terminate($request, $response);
61 |
--------------------------------------------------------------------------------
/app/Http/Controllers/KakologController.php:
--------------------------------------------------------------------------------
1 | has(['format', 'starttime', 'endtime'])) {
19 |
20 | // フォーマット
21 | $format = strtolower($request->input('format'));
22 |
23 | // 取得開始/終了時刻のタイムスタンプ
24 | $start_time = $request->input('starttime');
25 | $end_time = $request->input('endtime');
26 |
27 | // XML でも JSON でもない場合はエラー
28 | if ($format !== 'xml' and $format !== 'json') {
29 | $message = Kakolog::errorMessage('フォーマットは XML または JSON 形式である必要があります。', 'json'); // JSON 決め打ち
30 | return response($message)->header('Content-Type', 'application/json');
31 | }
32 |
33 | // 生の過去ログを取得
34 | // xml ヘッダはついていない
35 | list($kakolog_raw, $kakolog_result) = Kakolog::getKakolog($jikkyo_id, intval($start_time), intval($end_time));
36 |
37 | // 指定された期間の過去ログが存在しない
38 | if ($kakolog_result === false) {
39 | $message = Kakolog::errorMessage($kakolog_raw, $format);
40 | return response($message)->header('Content-Type', "application/{$format}");
41 | }
42 |
43 | // XML にフォーマットして返す
44 | if ($format === 'xml') {
45 |
46 | $kakolog_xml = Kakolog::formatToXml($kakolog_raw);
47 |
48 | return response($kakolog_xml)->header('Content-Type', 'application/xml');
49 |
50 | // JSON にフォーマットして返す
51 | } else if ($format === 'json') {
52 |
53 | $kakolog_json = Kakolog::formatToJson($kakolog_raw);
54 |
55 | return response($kakolog_json)->header('Content-Type', 'application/json');
56 | }
57 |
58 | } else {
59 |
60 | // 必要なパラメータが存在しない
61 | $message = Kakolog::errorMessage('必要なパラメータが存在しません。', 'json'); // JSON 決め打ち
62 | return response($message)->header('Content-Type', 'application/json');
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/config/filesystems.php:
--------------------------------------------------------------------------------
1 | env('FILESYSTEM_DRIVER', 'local'),
17 |
18 | /*
19 | |--------------------------------------------------------------------------
20 | | Filesystem Disks
21 | |--------------------------------------------------------------------------
22 | |
23 | | Here you may configure as many filesystem "disks" as you wish, and you
24 | | may even configure multiple disks of the same driver. Defaults have
25 | | been setup for each driver as an example of the required options.
26 | |
27 | | Supported Drivers: "local", "ftp", "sftp", "s3"
28 | |
29 | */
30 |
31 | 'disks' => [
32 |
33 | 'local' => [
34 | 'driver' => 'local',
35 | 'root' => storage_path('app'),
36 | ],
37 |
38 | 'public' => [
39 | 'driver' => 'local',
40 | 'root' => storage_path('app/public'),
41 | 'url' => env('APP_URL').'/storage',
42 | 'visibility' => 'public',
43 | ],
44 |
45 | 's3' => [
46 | 'driver' => 's3',
47 | 'key' => env('AWS_ACCESS_KEY_ID'),
48 | 'secret' => env('AWS_SECRET_ACCESS_KEY'),
49 | 'region' => env('AWS_DEFAULT_REGION'),
50 | 'bucket' => env('AWS_BUCKET'),
51 | 'url' => env('AWS_URL'),
52 | 'endpoint' => env('AWS_ENDPOINT'),
53 | 'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
54 | ],
55 |
56 | ],
57 |
58 | /*
59 | |--------------------------------------------------------------------------
60 | | Symbolic Links
61 | |--------------------------------------------------------------------------
62 | |
63 | | Here you may configure the symbolic links that will be created when the
64 | | `storage:link` Artisan command is executed. The array keys should be
65 | | the locations of the links and the values should be their targets.
66 | |
67 | */
68 |
69 | 'links' => [
70 | public_path('storage') => storage_path('app/public'),
71 | ],
72 |
73 | ];
74 |
--------------------------------------------------------------------------------
/app/Http/Kernel.php:
--------------------------------------------------------------------------------
1 | [
34 | \App\Http\Middleware\EncryptCookies::class,
35 | \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
36 | // \Illuminate\Session\Middleware\StartSession::class,
37 | // \Illuminate\Session\Middleware\AuthenticateSession::class,
38 | // \Illuminate\View\Middleware\ShareErrorsFromSession::class,
39 | // \App\Http\Middleware\VerifyCsrfToken::class,
40 | \Illuminate\Routing\Middleware\SubstituteBindings::class,
41 | ],
42 |
43 | 'api' => [
44 | 'throttle:60,1',
45 | \Illuminate\Routing\Middleware\SubstituteBindings::class,
46 | ],
47 | ];
48 |
49 | /**
50 | * The application's route middleware.
51 | *
52 | * These middleware may be assigned to groups or used individually.
53 | *
54 | * @var array
55 | */
56 | protected $routeMiddleware = [
57 | 'auth' => \App\Http\Middleware\Authenticate::class,
58 | 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
59 | 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
60 | 'can' => \Illuminate\Auth\Middleware\Authorize::class,
61 | 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
62 | 'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
63 | 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
64 | 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
65 | 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
66 | ];
67 | }
68 |
--------------------------------------------------------------------------------
/config/queue.php:
--------------------------------------------------------------------------------
1 | env('QUEUE_CONNECTION', 'sync'),
17 |
18 | /*
19 | |--------------------------------------------------------------------------
20 | | Queue Connections
21 | |--------------------------------------------------------------------------
22 | |
23 | | Here you may configure the connection information for each server that
24 | | is used by your application. A default configuration has been added
25 | | for each back-end shipped with Laravel. You are free to add more.
26 | |
27 | | Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null"
28 | |
29 | */
30 |
31 | 'connections' => [
32 |
33 | 'sync' => [
34 | 'driver' => 'sync',
35 | ],
36 |
37 | 'database' => [
38 | 'driver' => 'database',
39 | 'table' => 'jobs',
40 | 'queue' => 'default',
41 | 'retry_after' => 90,
42 | 'after_commit' => false,
43 | ],
44 |
45 | 'beanstalkd' => [
46 | 'driver' => 'beanstalkd',
47 | 'host' => 'localhost',
48 | 'queue' => 'default',
49 | 'retry_after' => 90,
50 | 'block_for' => 0,
51 | 'after_commit' => false,
52 | ],
53 |
54 | 'sqs' => [
55 | 'driver' => 'sqs',
56 | 'key' => env('AWS_ACCESS_KEY_ID'),
57 | 'secret' => env('AWS_SECRET_ACCESS_KEY'),
58 | 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'),
59 | 'queue' => env('SQS_QUEUE', 'default'),
60 | 'suffix' => env('SQS_SUFFIX'),
61 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
62 | 'after_commit' => false,
63 | ],
64 |
65 | 'redis' => [
66 | 'driver' => 'redis',
67 | 'connection' => 'default',
68 | 'queue' => env('REDIS_QUEUE', 'default'),
69 | 'retry_after' => 90,
70 | 'block_for' => null,
71 | 'after_commit' => false,
72 | ],
73 |
74 | ],
75 |
76 | /*
77 | |--------------------------------------------------------------------------
78 | | Failed Queue Jobs
79 | |--------------------------------------------------------------------------
80 | |
81 | | These options configure the behavior of failed queue job logging so you
82 | | can control which database and table are used to store the jobs that
83 | | have failed. You may change them to any database / table you wish.
84 | |
85 | */
86 |
87 | 'failed' => [
88 | 'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'),
89 | 'database' => env('DB_CONNECTION', 'mysql'),
90 | 'table' => 'failed_jobs',
91 | ],
92 |
93 | ];
94 |
--------------------------------------------------------------------------------
/config/cache.php:
--------------------------------------------------------------------------------
1 | env('CACHE_DRIVER', 'file'),
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Cache Stores
23 | |--------------------------------------------------------------------------
24 | |
25 | | Here you may define all of the cache "stores" for your application as
26 | | well as their drivers. You may even define multiple stores for the
27 | | same cache driver to group types of items stored in your caches.
28 | |
29 | | Supported drivers: "apc", "array", "database", "file",
30 | | "memcached", "redis", "dynamodb", "octane", "null"
31 | |
32 | */
33 |
34 | 'stores' => [
35 |
36 | 'apc' => [
37 | 'driver' => 'apc',
38 | ],
39 |
40 | 'array' => [
41 | 'driver' => 'array',
42 | 'serialize' => false,
43 | ],
44 |
45 | 'database' => [
46 | 'driver' => 'database',
47 | 'table' => 'cache',
48 | 'connection' => null,
49 | 'lock_connection' => null,
50 | ],
51 |
52 | 'file' => [
53 | 'driver' => 'file',
54 | 'path' => storage_path('framework/cache/data'),
55 | ],
56 |
57 | 'memcached' => [
58 | 'driver' => 'memcached',
59 | 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
60 | 'sasl' => [
61 | env('MEMCACHED_USERNAME'),
62 | env('MEMCACHED_PASSWORD'),
63 | ],
64 | 'options' => [
65 | // Memcached::OPT_CONNECT_TIMEOUT => 2000,
66 | ],
67 | 'servers' => [
68 | [
69 | 'host' => env('MEMCACHED_HOST', '127.0.0.1'),
70 | 'port' => env('MEMCACHED_PORT', 11211),
71 | 'weight' => 100,
72 | ],
73 | ],
74 | ],
75 |
76 | 'redis' => [
77 | 'driver' => 'redis',
78 | 'connection' => 'cache',
79 | 'lock_connection' => 'default',
80 | ],
81 |
82 | 'dynamodb' => [
83 | 'driver' => 'dynamodb',
84 | 'key' => env('AWS_ACCESS_KEY_ID'),
85 | 'secret' => env('AWS_SECRET_ACCESS_KEY'),
86 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
87 | 'table' => env('DYNAMODB_CACHE_TABLE', 'cache'),
88 | 'endpoint' => env('DYNAMODB_ENDPOINT'),
89 | ],
90 |
91 | 'octane' => [
92 | 'driver' => 'octane',
93 | ],
94 |
95 | ],
96 |
97 | /*
98 | |--------------------------------------------------------------------------
99 | | Cache Key Prefix
100 | |--------------------------------------------------------------------------
101 | |
102 | | When utilizing a RAM based store such as APC or Memcached, there might
103 | | be other applications utilizing the same cache. So, we'll specify a
104 | | value to get prefixed to all our keys so we can avoid collisions.
105 | |
106 | */
107 |
108 | 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache'),
109 |
110 | ];
111 |
--------------------------------------------------------------------------------
/config/mail.php:
--------------------------------------------------------------------------------
1 | env('MAIL_MAILER', 'smtp'),
17 |
18 | /*
19 | |--------------------------------------------------------------------------
20 | | Mailer Configurations
21 | |--------------------------------------------------------------------------
22 | |
23 | | Here you may configure all of the mailers used by your application plus
24 | | their respective settings. Several examples have been configured for
25 | | you and you are free to add your own as your application requires.
26 | |
27 | | Laravel supports a variety of mail "transport" drivers to be used while
28 | | sending an e-mail. You will specify which one you are using for your
29 | | mailers below. You are free to add additional mailers as required.
30 | |
31 | | Supported: "smtp", "sendmail", "mailgun", "ses",
32 | | "postmark", "log", "array", "failover"
33 | |
34 | */
35 |
36 | 'mailers' => [
37 | 'smtp' => [
38 | 'transport' => 'smtp',
39 | 'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
40 | 'port' => env('MAIL_PORT', 587),
41 | 'encryption' => env('MAIL_ENCRYPTION', 'tls'),
42 | 'username' => env('MAIL_USERNAME'),
43 | 'password' => env('MAIL_PASSWORD'),
44 | 'timeout' => null,
45 | 'auth_mode' => null,
46 | ],
47 |
48 | 'ses' => [
49 | 'transport' => 'ses',
50 | ],
51 |
52 | 'mailgun' => [
53 | 'transport' => 'mailgun',
54 | ],
55 |
56 | 'postmark' => [
57 | 'transport' => 'postmark',
58 | ],
59 |
60 | 'sendmail' => [
61 | 'transport' => 'sendmail',
62 | 'path' => '/usr/sbin/sendmail -bs',
63 | ],
64 |
65 | 'log' => [
66 | 'transport' => 'log',
67 | 'channel' => env('MAIL_LOG_CHANNEL'),
68 | ],
69 |
70 | 'array' => [
71 | 'transport' => 'array',
72 | ],
73 |
74 | 'failover' => [
75 | 'transport' => 'failover',
76 | 'mailers' => [
77 | 'smtp',
78 | 'log',
79 | ],
80 | ],
81 | ],
82 |
83 | /*
84 | |--------------------------------------------------------------------------
85 | | Global "From" Address
86 | |--------------------------------------------------------------------------
87 | |
88 | | You may wish for all e-mails sent by your application to be sent from
89 | | the same address. Here, you may specify a name and address that is
90 | | used globally for all e-mails that are sent by your application.
91 | |
92 | */
93 |
94 | 'from' => [
95 | 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
96 | 'name' => env('MAIL_FROM_NAME', 'Example'),
97 | ],
98 |
99 | /*
100 | |--------------------------------------------------------------------------
101 | | Markdown Mail Settings
102 | |--------------------------------------------------------------------------
103 | |
104 | | If you are using Markdown based email rendering, you may configure your
105 | | theme and component paths here, allowing you to customize the design
106 | | of the emails. Or, you may simply stick with the Laravel defaults!
107 | |
108 | */
109 |
110 | 'markdown' => [
111 | 'theme' => 'default',
112 |
113 | 'paths' => [
114 | resource_path('views/vendor/mail'),
115 | ],
116 | ],
117 |
118 | ];
119 |
--------------------------------------------------------------------------------
/config/logging.php:
--------------------------------------------------------------------------------
1 | env('LOG_CHANNEL', 'stack'),
21 |
22 | /*
23 | |--------------------------------------------------------------------------
24 | | Deprecations Log Channel
25 | |--------------------------------------------------------------------------
26 | |
27 | | This option controls the log channel that should be used to log warnings
28 | | regarding deprecated PHP and library features. This allows you to get
29 | | your application ready for upcoming major versions of dependencies.
30 | |
31 | */
32 |
33 | 'deprecations' => env('LOG_DEPRECATIONS_CHANNEL', 'null'),
34 |
35 | /*
36 | |--------------------------------------------------------------------------
37 | | Log Channels
38 | |--------------------------------------------------------------------------
39 | |
40 | | Here you may configure the log channels for your application. Out of
41 | | the box, Laravel uses the Monolog PHP logging library. This gives
42 | | you a variety of powerful log handlers / formatters to utilize.
43 | |
44 | | Available Drivers: "single", "daily", "slack", "syslog",
45 | | "errorlog", "monolog",
46 | | "custom", "stack"
47 | |
48 | */
49 |
50 | 'channels' => [
51 | 'stack' => [
52 | 'driver' => 'stack',
53 | 'channels' => ['single'],
54 | 'ignore_exceptions' => false,
55 | ],
56 |
57 | 'single' => [
58 | 'driver' => 'single',
59 | 'path' => storage_path('logs/laravel.log'),
60 | 'level' => env('LOG_LEVEL', 'debug'),
61 | ],
62 |
63 | 'daily' => [
64 | 'driver' => 'daily',
65 | 'path' => storage_path('logs/laravel.log'),
66 | 'level' => env('LOG_LEVEL', 'debug'),
67 | 'days' => 14,
68 | ],
69 |
70 | 'slack' => [
71 | 'driver' => 'slack',
72 | 'url' => env('LOG_SLACK_WEBHOOK_URL'),
73 | 'username' => 'Laravel Log',
74 | 'emoji' => ':boom:',
75 | 'level' => env('LOG_LEVEL', 'critical'),
76 | ],
77 |
78 | 'papertrail' => [
79 | 'driver' => 'monolog',
80 | 'level' => env('LOG_LEVEL', 'debug'),
81 | 'handler' => SyslogUdpHandler::class,
82 | 'handler_with' => [
83 | 'host' => env('PAPERTRAIL_URL'),
84 | 'port' => env('PAPERTRAIL_PORT'),
85 | ],
86 | ],
87 |
88 | 'stderr' => [
89 | 'driver' => 'monolog',
90 | 'level' => env('LOG_LEVEL', 'debug'),
91 | 'handler' => StreamHandler::class,
92 | 'formatter' => env('LOG_STDERR_FORMATTER'),
93 | 'with' => [
94 | 'stream' => 'php://stderr',
95 | ],
96 | ],
97 |
98 | 'syslog' => [
99 | 'driver' => 'syslog',
100 | 'level' => env('LOG_LEVEL', 'debug'),
101 | ],
102 |
103 | 'errorlog' => [
104 | 'driver' => 'errorlog',
105 | 'level' => env('LOG_LEVEL', 'debug'),
106 | ],
107 |
108 | 'null' => [
109 | 'driver' => 'monolog',
110 | 'handler' => NullHandler::class,
111 | ],
112 |
113 | 'emergency' => [
114 | 'path' => storage_path('logs/laravel.log'),
115 | ],
116 | ],
117 |
118 | ];
119 |
--------------------------------------------------------------------------------
/config/auth.php:
--------------------------------------------------------------------------------
1 | [
17 | 'guard' => 'web',
18 | 'passwords' => 'users',
19 | ],
20 |
21 | /*
22 | |--------------------------------------------------------------------------
23 | | Authentication Guards
24 | |--------------------------------------------------------------------------
25 | |
26 | | Next, you may define every authentication guard for your application.
27 | | Of course, a great default configuration has been defined for you
28 | | here which uses session storage and the Eloquent user provider.
29 | |
30 | | All authentication drivers have a user provider. This defines how the
31 | | users are actually retrieved out of your database or other storage
32 | | mechanisms used by this application to persist your user's data.
33 | |
34 | | Supported: "session"
35 | |
36 | */
37 |
38 | 'guards' => [
39 | 'web' => [
40 | 'driver' => 'session',
41 | 'provider' => 'users',
42 | ],
43 | ],
44 |
45 | /*
46 | |--------------------------------------------------------------------------
47 | | User Providers
48 | |--------------------------------------------------------------------------
49 | |
50 | | All authentication drivers have a user provider. This defines how the
51 | | users are actually retrieved out of your database or other storage
52 | | mechanisms used by this application to persist your user's data.
53 | |
54 | | If you have multiple user tables or models you may configure multiple
55 | | sources which represent each model / table. These sources may then
56 | | be assigned to any extra authentication guards you have defined.
57 | |
58 | | Supported: "database", "eloquent"
59 | |
60 | */
61 |
62 | 'providers' => [
63 | 'users' => [
64 | 'driver' => 'eloquent',
65 | 'model' => App\Models\User::class,
66 | ],
67 |
68 | // 'users' => [
69 | // 'driver' => 'database',
70 | // 'table' => 'users',
71 | // ],
72 | ],
73 |
74 | /*
75 | |--------------------------------------------------------------------------
76 | | Resetting Passwords
77 | |--------------------------------------------------------------------------
78 | |
79 | | You may specify multiple password reset configurations if you have more
80 | | than one user table or model in the application and you want to have
81 | | separate password reset settings based on the specific user types.
82 | |
83 | | The expire time is the number of minutes that the reset token should be
84 | | considered valid. This security feature keeps tokens short-lived so
85 | | they have less time to be guessed. You may change this as needed.
86 | |
87 | */
88 |
89 | 'passwords' => [
90 | 'users' => [
91 | 'provider' => 'users',
92 | 'table' => 'password_resets',
93 | 'expire' => 60,
94 | 'throttle' => 60,
95 | ],
96 | ],
97 |
98 | /*
99 | |--------------------------------------------------------------------------
100 | | Password Confirmation Timeout
101 | |--------------------------------------------------------------------------
102 | |
103 | | Here you may define the amount of seconds before a password confirmation
104 | | times out and the user is prompted to re-enter their password via the
105 | | confirmation screen. By default, the timeout lasts for three hours.
106 | |
107 | */
108 |
109 | 'password_timeout' => 10800,
110 |
111 | ];
112 |
--------------------------------------------------------------------------------
/Readme.md:
--------------------------------------------------------------------------------
1 |
2 | # jikkyo-api
3 |
4 | ニコニコ実況 過去ログ API のソースコードです。Laravel 8 で構築されています。
5 |
6 | ## Setup
7 |
8 | 以下は Apache + PHP 7.4 + mod_php で動かす際の手順になります。
9 |
10 | 1. あらかじめ Apache で PHP 7.4 が動く状態にしておく
11 | 2. Laravel に必要な PHP の拡張機能をでインストールする
12 | - Ubuntu なら `sudo apt install php7.4-bcmath php7.4-curl php7.4-mbstring php7.4-xml php7.4-zip` でインストールできる
13 | 3. .env.example を .env にコピーする
14 | 4. .env を手元の環境に合わせて編集する
15 | 5. プロジェクトのディレクトリ内で `composer install` を実行する
16 | 6. Apache の設定で `public/` 以下をドキュメントルートに設定する
17 | 7. アクセスできるか確認する
18 |
19 | ## License
20 | [MIT License](License.txt)
21 |
22 |
23 | ------------------
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 | ## About Laravel
35 |
36 | Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
37 |
38 | - [Simple, fast routing engine](https://laravel.com/docs/routing).
39 | - [Powerful dependency injection container](https://laravel.com/docs/container).
40 | - Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
41 | - Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
42 | - Database agnostic [schema migrations](https://laravel.com/docs/migrations).
43 | - [Robust background job processing](https://laravel.com/docs/queues).
44 | - [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
45 |
46 | Laravel is accessible, powerful, and provides tools required for large, robust applications.
47 |
48 | ## Learning Laravel
49 |
50 | Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
51 |
52 | If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 1500 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
53 |
54 | ## Laravel Sponsors
55 |
56 | We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](https://patreon.com/taylorotwell).
57 |
58 | ### Premium Partners
59 |
60 | - **[Vehikl](https://vehikl.com/)**
61 | - **[Tighten Co.](https://tighten.co)**
62 | - **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
63 | - **[64 Robots](https://64robots.com)**
64 | - **[Cubet Techno Labs](https://cubettech.com)**
65 | - **[Cyber-Duck](https://cyber-duck.co.uk)**
66 | - **[Many](https://www.many.co.uk)**
67 | - **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)**
68 | - **[DevSquad](https://devsquad.com)**
69 | - **[Curotec](https://www.curotec.com/services/technologies/laravel/)**
70 | - **[OP.GG](https://op.gg)**
71 | - **[WebReinvent](https://webreinvent.com/?utm_source=laravel&utm_medium=github&utm_campaign=patreon-sponsors)**
72 | - **[Lendio](https://lendio.com)**
73 |
74 | ## Contributing
75 |
76 | Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
77 |
78 | ## Code of Conduct
79 |
80 | In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
81 |
82 | ## Security Vulnerabilities
83 |
84 | If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
85 |
86 | ## License
87 |
88 | The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
89 |
--------------------------------------------------------------------------------
/config/database.php:
--------------------------------------------------------------------------------
1 | env('DB_CONNECTION', 'mysql'),
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Database Connections
23 | |--------------------------------------------------------------------------
24 | |
25 | | Here are each of the database connections setup for your application.
26 | | Of course, examples of configuring each database platform that is
27 | | supported by Laravel is shown below to make development simple.
28 | |
29 | |
30 | | All database work in Laravel is done through the PHP PDO facilities
31 | | so make sure you have the driver for your particular database of
32 | | choice installed on your machine before you begin development.
33 | |
34 | */
35 |
36 | 'connections' => [
37 |
38 | 'sqlite' => [
39 | 'driver' => 'sqlite',
40 | 'url' => env('DATABASE_URL'),
41 | 'database' => env('DB_DATABASE', database_path('database.sqlite')),
42 | 'prefix' => '',
43 | 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
44 | ],
45 |
46 | 'mysql' => [
47 | 'driver' => 'mysql',
48 | 'url' => env('DATABASE_URL'),
49 | 'host' => env('DB_HOST', '127.0.0.1'),
50 | 'port' => env('DB_PORT', '3306'),
51 | 'database' => env('DB_DATABASE', 'forge'),
52 | 'username' => env('DB_USERNAME', 'forge'),
53 | 'password' => env('DB_PASSWORD', ''),
54 | 'unix_socket' => env('DB_SOCKET', ''),
55 | 'charset' => 'utf8mb4',
56 | 'collation' => 'utf8mb4_unicode_ci',
57 | 'prefix' => '',
58 | 'prefix_indexes' => true,
59 | 'strict' => true,
60 | 'engine' => null,
61 | 'options' => extension_loaded('pdo_mysql') ? array_filter([
62 | PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
63 | ]) : [],
64 | ],
65 |
66 | 'pgsql' => [
67 | 'driver' => 'pgsql',
68 | 'url' => env('DATABASE_URL'),
69 | 'host' => env('DB_HOST', '127.0.0.1'),
70 | 'port' => env('DB_PORT', '5432'),
71 | 'database' => env('DB_DATABASE', 'forge'),
72 | 'username' => env('DB_USERNAME', 'forge'),
73 | 'password' => env('DB_PASSWORD', ''),
74 | 'charset' => 'utf8',
75 | 'prefix' => '',
76 | 'prefix_indexes' => true,
77 | 'schema' => 'public',
78 | 'sslmode' => 'prefer',
79 | ],
80 |
81 | 'sqlsrv' => [
82 | 'driver' => 'sqlsrv',
83 | 'url' => env('DATABASE_URL'),
84 | 'host' => env('DB_HOST', 'localhost'),
85 | 'port' => env('DB_PORT', '1433'),
86 | 'database' => env('DB_DATABASE', 'forge'),
87 | 'username' => env('DB_USERNAME', 'forge'),
88 | 'password' => env('DB_PASSWORD', ''),
89 | 'charset' => 'utf8',
90 | 'prefix' => '',
91 | 'prefix_indexes' => true,
92 | ],
93 |
94 | ],
95 |
96 | /*
97 | |--------------------------------------------------------------------------
98 | | Migration Repository Table
99 | |--------------------------------------------------------------------------
100 | |
101 | | This table keeps track of all the migrations that have already run for
102 | | your application. Using this information, we can determine which of
103 | | the migrations on disk haven't actually been run in the database.
104 | |
105 | */
106 |
107 | 'migrations' => 'migrations',
108 |
109 | /*
110 | |--------------------------------------------------------------------------
111 | | Redis Databases
112 | |--------------------------------------------------------------------------
113 | |
114 | | Redis is an open source, fast, and advanced key-value store that also
115 | | provides a richer body of commands than a typical key-value system
116 | | such as APC or Memcached. Laravel makes it easy to dig right in.
117 | |
118 | */
119 |
120 | 'redis' => [
121 |
122 | 'client' => env('REDIS_CLIENT', 'phpredis'),
123 |
124 | 'options' => [
125 | 'cluster' => env('REDIS_CLUSTER', 'redis'),
126 | 'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
127 | ],
128 |
129 | 'default' => [
130 | 'url' => env('REDIS_URL'),
131 | 'host' => env('REDIS_HOST', '127.0.0.1'),
132 | 'password' => env('REDIS_PASSWORD', null),
133 | 'port' => env('REDIS_PORT', '6379'),
134 | 'database' => env('REDIS_DB', '0'),
135 | ],
136 |
137 | 'cache' => [
138 | 'url' => env('REDIS_URL'),
139 | 'host' => env('REDIS_HOST', '127.0.0.1'),
140 | 'password' => env('REDIS_PASSWORD', null),
141 | 'port' => env('REDIS_PORT', '6379'),
142 | 'database' => env('REDIS_CACHE_DB', '1'),
143 | ],
144 |
145 | ],
146 |
147 | ];
148 |
--------------------------------------------------------------------------------
/public/style.css:
--------------------------------------------------------------------------------
1 |
2 | *:focus {
3 | outline: none !important;
4 | }
5 |
6 | html {
7 | position: relative;
8 | min-height: 100%;
9 | padding-bottom: 55px;
10 | box-sizing: border-box;
11 | }
12 |
13 | body {
14 | font-family: -apple-system,BlinkMacSystemFont,"Open Sans","Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";
15 | background-image: url(/background.jpg);
16 | background-repeat: no-repeat;
17 | background-attachment: fixed;
18 | background-size: cover;
19 | line-height: 1.6;
20 | margin-top: 82px;
21 | }
22 | body.modal-open {
23 | padding-right: 0 !important;
24 | overflow: auto !important;
25 | }
26 | body.modal-open nav {
27 | padding: .5rem 1rem !important;
28 | }
29 |
30 | .nav-link i, .card-header i {
31 | margin-right: 10px;
32 | }
33 |
34 | li {
35 | margin-bottom: 3px;
36 | }
37 | li:last-of-type {
38 | margin-bottom: 0;
39 | }
40 |
41 | pre {
42 | padding: 1.75em 1.5em;
43 | border: 3px solid #ccc;
44 | color: #f8f8f2;
45 | text-shadow: 0 1px #1a1a1a;
46 | background: #2b2a43eb;
47 | font-size: 13px;
48 | font-family: "Menlo", "Consolas", "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Meiryo", monospace;
49 | }
50 |
51 | table.table-request, table.table-response {
52 | display: block;
53 | overflow-x: auto;
54 | white-space: nowrap;
55 | -webkit-overflow-scrolling: touch;
56 | }
57 | table.table-request tbody, table.table-response tbody {
58 | display: table;
59 | width: 100%;
60 | }
61 |
62 | table.table-response-error th {
63 | width: 270px;
64 | }
65 |
66 | h2.card-header {
67 | font-size: 1rem;
68 | }
69 |
70 | .navbar-brand {
71 | display: flex;
72 | align-items: center;
73 | }
74 |
75 | .navbar-brand img {
76 | height: 33px;
77 | margin-right: 7px;
78 | }
79 |
80 | @media (max-width: 450px) {
81 | .navbar-brand {
82 | font-size: 14.7px !important;
83 | margin-right: auto;
84 | }
85 | }
86 |
87 | @media (max-width: 380px) {
88 | .navbar-brand img {
89 | height: 20px;
90 | }
91 | .navbar-brand {
92 | font-size: 13px !important;
93 | margin-right: auto;
94 | }
95 | }
96 |
97 | @media (min-width: 768px) {
98 | .navbar-expand-md .navbar-nav .nav-link {
99 | padding-right: .7rem;
100 | padding-left: .7rem;
101 | }
102 | }
103 |
104 | @media (min-width: 768px) {
105 | .navbar-expand-md .navbar-nav .nav-link {
106 | padding-right: .7rem;
107 | padding-left: .7rem;
108 | }
109 | }
110 |
111 | @media (max-width: 1199px) {
112 | .navbar-brand {
113 | font-size: 18px;
114 | }
115 | .navbar-expand-md .navbar-nav .nav-link {
116 | padding-right: .5rem;
117 | padding-left: .5rem;
118 | font-size: 13.5px;
119 | }
120 | }
121 |
122 | @media (max-width: 1020px) {
123 | .navbar-expand-md .navbar-nav .nav-link {
124 | padding-right: .5rem;
125 | padding-left: .5rem;
126 | font-size: 13px;
127 | }
128 | }
129 |
130 | @media (max-width: 961px) {
131 | .navbar-expand-md .navbar-nav .nav-link {
132 | padding-right: .7rem;
133 | padding-left: .7rem;
134 | }
135 | }
136 |
137 | @media (min-width: 768px) {
138 | .navbar-expand-md .navbar-toggler {
139 | display: block;
140 | order: 1;
141 | }
142 | .navbar-expand-md .navbar-collapse {
143 | display: block !important;
144 | -ms-flex-positive: 1;
145 | flex-basis: 100%;
146 | }
147 | .navbar-expand-md .navbar-collapse.collapse:not(.show) {
148 | display: none !important;
149 | }
150 | .navbar-expand-md .navbar-nav {
151 | -ms-flex-direction: column;
152 | flex-direction: column;
153 | }
154 | }
155 |
156 | @media (min-width: 992px) {
157 | .navbar-expand-md .navbar-toggler {
158 | display: none;
159 | }
160 | .navbar-expand-md .navbar-collapse {
161 | display: -ms-flexbox !important;
162 | display: flex !important;
163 | -ms-flex-preferred-size: auto;
164 | flex-basis: auto;
165 | }
166 | .navbar-expand-md .navbar-collapse.collapse:not(.show) {
167 | display: -ms-flexbox!important;
168 | display: flex !important;
169 | }
170 | .navbar-expand-md .navbar-nav {
171 | -ms-flex-direction: row;
172 | flex-direction: row;
173 | }
174 | }
175 |
176 | .card-body ul:not(.bootstrap-datetimepicker-widget *) {
177 | margin-bottom: 5px !important;
178 | padding-left: 30px;
179 | }
180 |
181 | a.text-light, a.text-light {
182 | transition: background-color .15s cubic-bezier(.4,0,.6,1);
183 | border-radius: 4px;
184 | }
185 |
186 | a.text-light:hover, a.text-light:focus {
187 | color: #f8f9fa !important;
188 | }
189 |
190 | a.text-light:hover {
191 | background: rgba(0, 0, 0, 0.08);
192 | }
193 |
194 | #navigation {
195 | background: #00AA90 !important;
196 | overflow: hidden;
197 | }
198 |
199 | table.table tr:last-of-type {
200 | border-bottom: 1px solid #dee2e6;
201 | }
202 |
203 | table > tbody > tr > th {
204 | background: #dcf3ff;
205 | }
206 |
207 | @media (min-width: 1200px) {
208 | .container, .container-lg, .container-md, .container-sm, .container-xl {
209 | max-width: 1150px;
210 | }
211 | }
212 |
213 | @media screen and (max-width: 500px) {
214 | ol.mb-0 {
215 | padding-inline-start: 20px;
216 | }
217 | }
218 |
219 | .column {
220 | border: 1px solid #dee2e6;
221 | }
222 |
223 | .column div {
224 | margin: 10px 30px 6px;
225 | }
226 |
227 | .download-form .form-group {
228 | display: flex;
229 | }
230 |
231 | .download-form {
232 | max-width: 880px;
233 | margin: 0 auto;
234 | }
235 |
236 | .download-form-icon {
237 | height: 32px;
238 | }
239 |
240 | .download-form .input-group-text {
241 | font-size: 17.5px !important;
242 | }
243 |
244 | .download-form select {
245 | font-size: 17px !important;
246 | }
247 |
248 | .download-form option {
249 | font-size: 16px !important;
250 | }
251 |
252 | .download-form input {
253 | font-size: 21px !important;
254 | }
255 |
256 | #play-button {
257 | background-color: #e33157 !important;
258 | border-color: #e33157 !important;
259 | }
260 |
261 | @media screen and (max-width: 500px) {
262 | .download-form .input-group-text {
263 | font-size: 13.5px !important;
264 | padding: 0.2rem 0.5rem !important;
265 | }
266 |
267 | .download-form .input-group-text i {
268 | font-size: 13px !important;
269 | }
270 |
271 | .download-form select {
272 | font-size: 13.5px !important;
273 | }
274 |
275 | .download-form option {
276 | font-size: 15px !important;
277 | }
278 |
279 | .download-form input {
280 | font-size: 17px !important;
281 | }
282 |
283 | .download-form button {
284 | font-size: 15px !important;
285 | padding: 0.3rem 0.5rem !important;
286 | }
287 |
288 | .download-form .btn-group button {
289 | font-size: 14px !important;
290 | }
291 |
292 | .action-button-group {
293 | flex-direction: column;
294 | }
295 |
296 | .action-button-group #play-button,
297 | .action-button-group #download-button {
298 | margin-right: 0 !important;
299 | margin-bottom: 12px;
300 | }
301 | }
302 |
303 | #footer {
304 | position: absolute;
305 | left: 0;
306 | bottom: 0;
307 | width: 100%;
308 | }
309 |
--------------------------------------------------------------------------------
/public/script.js:
--------------------------------------------------------------------------------
1 |
2 | $(function() {
3 |
4 | // チャンネル
5 | let channel = 'jk1';
6 |
7 | // 取得開始時刻
8 | let starttime = moment().add(-1, 'hour').set('minute', 0).set('second', 0);
9 |
10 | // 取得終了時刻
11 | let endtime = moment().set('minute', 0).set('second', 0);
12 |
13 | // 取得開始時刻の日付ピッカー
14 | $('#datepicker-start').datetimepicker({
15 | dayViewHeaderFormat: 'YYYY年MM月',
16 | format: 'YYYY/MM/DD',
17 | locale: 'ja',
18 | defaultDate: starttime,
19 | maxDate: starttime,
20 | });
21 |
22 | // 取得開始時刻の時刻ピッカー
23 | $('#timepicker-start').datetimepicker({
24 | dayViewHeaderFormat: 'HH:mm:ss',
25 | format: 'HH:mm:ss',
26 | locale: 'ja',
27 | defaultDate: starttime,
28 | });
29 |
30 | // 取得終了時刻の日付ピッカー
31 | $('#datepicker-end').datetimepicker({
32 | dayViewHeaderFormat: 'YYYY年MM月',
33 | format: 'YYYY/MM/DD',
34 | locale: 'ja',
35 | defaultDate: endtime,
36 | maxDate: endtime,
37 | });
38 |
39 | // 取得終了時刻の時刻ピッカー
40 | $('#timepicker-end').datetimepicker({
41 | dayViewHeaderFormat: 'HH:mm:ss',
42 | format: 'HH:mm:ss',
43 | locale: 'ja',
44 | defaultDate: endtime,
45 | });
46 |
47 | // チャンネルのフォームが変化したとき
48 | $('#channel-picker').on('change', (event) => {
49 | channel = $('#channel-picker').val();
50 | });
51 |
52 | // 取得開始時刻のフォームが変化したとき
53 | $('#datepicker-start, #timepicker-start').on('change.datetimepicker', (event) => {
54 | const datepicker_start = $('#datepicker-start').val();
55 | const timepicker_start = $('#timepicker-start').val();
56 | const datetimepicker_start = moment(`${datepicker_start} ${timepicker_start}`, 'YYYY/MM/DD HH:mm:ss');
57 | starttime = datetimepicker_start;
58 | });
59 |
60 | // 取得終了時刻のフォームが変化したとき
61 | $('#datepicker-end, #timepicker-end').on('change.datetimepicker', (event) => {
62 | const datepicker_end = $('#datepicker-end').val();
63 | const timepicker_end = $('#timepicker-end').val();
64 | const datetimepicker_end = moment(`${datepicker_end} ${timepicker_end}`, 'YYYY/MM/DD HH:mm:ss');
65 | endtime = datetimepicker_end;
66 | });
67 |
68 | // 反映ボタンがクリックされたとき
69 | $('#reflect-button').click((event) => {
70 | const datepicker_start = $('#datepicker-start').val();
71 | const timepicker_start = $('#timepicker-start').val();
72 | $('#datepicker-end').val(datepicker_start);
73 | $('#timepicker-end').val(timepicker_start);
74 | const datetimepicker_end = moment(`${datepicker_start} ${timepicker_start}`, 'YYYY/MM/DD HH:mm:ss');
75 | endtime = datetimepicker_end;
76 | });
77 |
78 | // -30分ボタンがクリックされたとき
79 | $('#time-minus30-button').click((event) => {
80 | endtime = endtime.subtract(30, 'minutes');
81 | $('#datepicker-end').val(endtime.format('YYYY/MM/DD'));
82 | $('#timepicker-end').val(endtime.format('HH:mm:ss'));
83 | });
84 |
85 | // -5分ボタンがクリックされたとき
86 | $('#time-minus5-button').click((event) => {
87 | endtime = endtime.subtract(5, 'minutes');
88 | $('#datepicker-end').val(endtime.format('YYYY/MM/DD'));
89 | $('#timepicker-end').val(endtime.format('HH:mm:ss'));
90 | });
91 |
92 | // +5分ボタンがクリックされたとき
93 | $('#time-plus5-button').click((event) => {
94 | endtime = endtime.add(5, 'minutes');
95 | $('#datepicker-end').val(endtime.format('YYYY/MM/DD'));
96 | $('#timepicker-end').val(endtime.format('HH:mm:ss'));
97 | });
98 |
99 | // +30分ボタンがクリックされたとき
100 | $('#time-plus30-button').click((event) => {
101 | endtime = endtime.add(30, 'minutes');
102 | $('#datepicker-end').val(endtime.format('YYYY/MM/DD'));
103 | $('#timepicker-end').val(endtime.format('HH:mm:ss'));
104 | });
105 |
106 | // API URL を作成してエラーがないかチェック
107 | function checkAPI() {
108 |
109 | // Promise を返す
110 | return new Promise((resolve, reject) => {
111 |
112 | // API URL を構築
113 | const api_url = `${window.location.origin}/api/kakolog/${channel}?starttime=${starttime.unix()}&endtime=${endtime.unix()}&format=xml`;
114 |
115 | // エラーが出ないか確認する
116 | $.ajax({
117 | url: api_url.replace('xml', 'json'),
118 | // リクエスト成功
119 | }).done((response, textStatus, jqXHR) => {
120 | if (response.error) { // エラーがあれば
121 | // モーダルにエラーを表示
122 | $('#modal .modal-body').html(response.error);
123 | $('#modal').modal();
124 | reject(response.error);
125 | } else {
126 | if (response.packet.length === 0) {
127 | $('#modal .modal-body').html('指定された期間の過去ログは存在しません。');
128 | $('#modal').modal();
129 | reject('指定された期間の過去ログは存在しません。');
130 | } else {
131 | resolve(api_url); // エラーなし
132 | }
133 | }
134 | // リクエスト失敗
135 | }).fail((jqXHR, textStatus, errorThrown) => {
136 | let error;
137 | switch (jqXHR.status) {
138 | // 500 Internal Server Error
139 | case 500:
140 | error = 'サーバーエラーが発生しました。過去ログ API に不具合がある可能性があります。(HTTP Error 500)';
141 | break;
142 | // 503 Service Unavailable
143 | case 503:
144 | error = '現在、過去ログ API は一時的に利用できなくなっています。(HTTP Error 503)';
145 | break;
146 | // その他のステータスコード
147 | default:
148 | error = '不明なエラーが発生しました。';
149 | break;
150 | }
151 | // モーダルにエラーを表示
152 | $('#modal .modal-body').html(error + ` API URL: ${api_url} `);
153 | $('#modal').modal();
154 | reject(error);
155 | });
156 | });
157 | }
158 |
159 | // 過去ログ再生ボタンがクリックされたとき
160 | $('#play-button').click((event) => {
161 |
162 | // 新しいタブで過去ログ再生ページを開く
163 | const url = `https://nx-jikkyo.tsukumijima.net/log/${channel}/${starttime.format('YYYYMMDDHHmmss')}-${endtime.format('YYYYMMDDHHmmss')}`;
164 | window.open(url, '_blank');
165 | });
166 |
167 | // ダウンロードボタンがクリックされたとき
168 | $('#download-button').click((event) => {
169 |
170 | // エラーがなければ
171 | checkAPI().then((api_url) => {
172 |
173 | // 仮想の a 要素を作成してダウンロードさせる
174 | const link = document.createElement('a');
175 | link.href = api_url;
176 | link.download = `${channel}_${starttime.format('YYYYMMDD-HHmmss')}_${endtime.format('YYYYMMDD-HHmmss')}.xml`;
177 | link.click();
178 |
179 | // エラーがあれば
180 | }).catch((error) => {
181 |
182 | // エラーをコンソールに表示
183 | console.error(`Error: ${error}`);
184 | });
185 | });
186 |
187 | // 遷移ボタンがクリックされたとき
188 | $('#urlopen-button').click((event) => {
189 |
190 | // エラーがなければ
191 | checkAPI().then((api_url) => {
192 |
193 | // 新しいタブで API URL を開く
194 | window.open(api_url, '_blank');
195 |
196 | // エラーがあれば
197 | }).catch((error) => {
198 |
199 | // エラーをコンソールに表示
200 | console.error(`Error: ${error}`);
201 | });
202 | });
203 |
204 | });
205 |
--------------------------------------------------------------------------------
/config/session.php:
--------------------------------------------------------------------------------
1 | env('SESSION_DRIVER', 'file'),
22 |
23 | /*
24 | |--------------------------------------------------------------------------
25 | | Session Lifetime
26 | |--------------------------------------------------------------------------
27 | |
28 | | Here you may specify the number of minutes that you wish the session
29 | | to be allowed to remain idle before it expires. If you want them
30 | | to immediately expire on the browser closing, set that option.
31 | |
32 | */
33 |
34 | 'lifetime' => env('SESSION_LIFETIME', 120),
35 |
36 | 'expire_on_close' => false,
37 |
38 | /*
39 | |--------------------------------------------------------------------------
40 | | Session Encryption
41 | |--------------------------------------------------------------------------
42 | |
43 | | This option allows you to easily specify that all of your session data
44 | | should be encrypted before it is stored. All encryption will be run
45 | | automatically by Laravel and you can use the Session like normal.
46 | |
47 | */
48 |
49 | 'encrypt' => false,
50 |
51 | /*
52 | |--------------------------------------------------------------------------
53 | | Session File Location
54 | |--------------------------------------------------------------------------
55 | |
56 | | When using the native session driver, we need a location where session
57 | | files may be stored. A default has been set for you but a different
58 | | location may be specified. This is only needed for file sessions.
59 | |
60 | */
61 |
62 | 'files' => storage_path('framework/sessions'),
63 |
64 | /*
65 | |--------------------------------------------------------------------------
66 | | Session Database Connection
67 | |--------------------------------------------------------------------------
68 | |
69 | | When using the "database" or "redis" session drivers, you may specify a
70 | | connection that should be used to manage these sessions. This should
71 | | correspond to a connection in your database configuration options.
72 | |
73 | */
74 |
75 | 'connection' => env('SESSION_CONNECTION', null),
76 |
77 | /*
78 | |--------------------------------------------------------------------------
79 | | Session Database Table
80 | |--------------------------------------------------------------------------
81 | |
82 | | When using the "database" session driver, you may specify the table we
83 | | should use to manage the sessions. Of course, a sensible default is
84 | | provided for you; however, you are free to change this as needed.
85 | |
86 | */
87 |
88 | 'table' => 'sessions',
89 |
90 | /*
91 | |--------------------------------------------------------------------------
92 | | Session Cache Store
93 | |--------------------------------------------------------------------------
94 | |
95 | | While using one of the framework's cache driven session backends you may
96 | | list a cache store that should be used for these sessions. This value
97 | | must match with one of the application's configured cache "stores".
98 | |
99 | | Affects: "apc", "dynamodb", "memcached", "redis"
100 | |
101 | */
102 |
103 | 'store' => env('SESSION_STORE', null),
104 |
105 | /*
106 | |--------------------------------------------------------------------------
107 | | Session Sweeping Lottery
108 | |--------------------------------------------------------------------------
109 | |
110 | | Some session drivers must manually sweep their storage location to get
111 | | rid of old sessions from storage. Here are the chances that it will
112 | | happen on a given request. By default, the odds are 2 out of 100.
113 | |
114 | */
115 |
116 | 'lottery' => [2, 100],
117 |
118 | /*
119 | |--------------------------------------------------------------------------
120 | | Session Cookie Name
121 | |--------------------------------------------------------------------------
122 | |
123 | | Here you may change the name of the cookie used to identify a session
124 | | instance by ID. The name specified here will get used every time a
125 | | new session cookie is created by the framework for every driver.
126 | |
127 | */
128 |
129 | 'cookie' => env(
130 | 'SESSION_COOKIE',
131 | Str::slug(env('APP_NAME', 'laravel'), '_').'_session'
132 | ),
133 |
134 | /*
135 | |--------------------------------------------------------------------------
136 | | Session Cookie Path
137 | |--------------------------------------------------------------------------
138 | |
139 | | The session cookie path determines the path for which the cookie will
140 | | be regarded as available. Typically, this will be the root path of
141 | | your application but you are free to change this when necessary.
142 | |
143 | */
144 |
145 | 'path' => '/',
146 |
147 | /*
148 | |--------------------------------------------------------------------------
149 | | Session Cookie Domain
150 | |--------------------------------------------------------------------------
151 | |
152 | | Here you may change the domain of the cookie used to identify a session
153 | | in your application. This will determine which domains the cookie is
154 | | available to in your application. A sensible default has been set.
155 | |
156 | */
157 |
158 | 'domain' => env('SESSION_DOMAIN', null),
159 |
160 | /*
161 | |--------------------------------------------------------------------------
162 | | HTTPS Only Cookies
163 | |--------------------------------------------------------------------------
164 | |
165 | | By setting this option to true, session cookies will only be sent back
166 | | to the server if the browser has a HTTPS connection. This will keep
167 | | the cookie from being sent to you when it can't be done securely.
168 | |
169 | */
170 |
171 | 'secure' => env('SESSION_SECURE_COOKIE'),
172 |
173 | /*
174 | |--------------------------------------------------------------------------
175 | | HTTP Access Only
176 | |--------------------------------------------------------------------------
177 | |
178 | | Setting this value to true will prevent JavaScript from accessing the
179 | | value of the cookie and the cookie will only be accessible through
180 | | the HTTP protocol. You are free to modify this option if needed.
181 | |
182 | */
183 |
184 | 'http_only' => true,
185 |
186 | /*
187 | |--------------------------------------------------------------------------
188 | | Same-Site Cookies
189 | |--------------------------------------------------------------------------
190 | |
191 | | This option determines how your cookies behave when cross-site requests
192 | | take place, and can be used to mitigate CSRF attacks. By default, we
193 | | will set this value to "lax" since this is a secure default value.
194 | |
195 | | Supported: "lax", "strict", "none", null
196 | |
197 | */
198 |
199 | 'same_site' => 'lax',
200 |
201 | ];
202 |
--------------------------------------------------------------------------------
/config/app.php:
--------------------------------------------------------------------------------
1 | env('APP_NAME', 'Laravel'),
17 |
18 | /*
19 | |--------------------------------------------------------------------------
20 | | Application Environment
21 | |--------------------------------------------------------------------------
22 | |
23 | | This value determines the "environment" your application is currently
24 | | running in. This may determine how you prefer to configure various
25 | | services the application utilizes. Set this in your ".env" file.
26 | |
27 | */
28 |
29 | 'env' => env('APP_ENV', 'production'),
30 |
31 | /*
32 | |--------------------------------------------------------------------------
33 | | Application Debug Mode
34 | |--------------------------------------------------------------------------
35 | |
36 | | When your application is in debug mode, detailed error messages with
37 | | stack traces will be shown on every error that occurs within your
38 | | application. If disabled, a simple generic error page is shown.
39 | |
40 | */
41 |
42 | 'debug' => (bool) env('APP_DEBUG', false),
43 |
44 | /*
45 | |--------------------------------------------------------------------------
46 | | Application URL
47 | |--------------------------------------------------------------------------
48 | |
49 | | This URL is used by the console to properly generate URLs when using
50 | | the Artisan command line tool. You should set this to the root of
51 | | your application so that it is used when running Artisan tasks.
52 | |
53 | */
54 |
55 | 'url' => env('APP_URL', 'http://localhost'),
56 |
57 | 'asset_url' => env('ASSET_URL', null),
58 |
59 | 'gtag' => env('APP_GTAG', 'UA-000000000-1'),
60 |
61 | /*
62 | |--------------------------------------------------------------------------
63 | | Application Timezone
64 | |--------------------------------------------------------------------------
65 | |
66 | | Here you may specify the default timezone for your application, which
67 | | will be used by the PHP date and date-time functions. We have gone
68 | | ahead and set this to a sensible default for you out of the box.
69 | |
70 | */
71 |
72 | 'timezone' => 'Asia/Tokyo',
73 |
74 | /*
75 | |--------------------------------------------------------------------------
76 | | Application Locale Configuration
77 | |--------------------------------------------------------------------------
78 | |
79 | | The application locale determines the default locale that will be used
80 | | by the translation service provider. You are free to set this value
81 | | to any of the locales which will be supported by the application.
82 | |
83 | */
84 |
85 | 'locale' => 'ja',
86 |
87 | /*
88 | |--------------------------------------------------------------------------
89 | | Application Fallback Locale
90 | |--------------------------------------------------------------------------
91 | |
92 | | The fallback locale determines the locale to use when the current one
93 | | is not available. You may change the value to correspond to any of
94 | | the language folders that are provided through your application.
95 | |
96 | */
97 |
98 | 'fallback_locale' => 'en',
99 |
100 | /*
101 | |--------------------------------------------------------------------------
102 | | Faker Locale
103 | |--------------------------------------------------------------------------
104 | |
105 | | This locale will be used by the Faker PHP library when generating fake
106 | | data for your database seeds. For example, this will be used to get
107 | | localized telephone numbers, street address information and more.
108 | |
109 | */
110 |
111 | 'faker_locale' => 'ja_JP',
112 |
113 | /*
114 | |--------------------------------------------------------------------------
115 | | Encryption Key
116 | |--------------------------------------------------------------------------
117 | |
118 | | This key is used by the Illuminate encrypter service and should be set
119 | | to a random, 32 character string, otherwise these encrypted strings
120 | | will not be safe. Please do this before deploying an application!
121 | |
122 | */
123 |
124 | 'key' => env('APP_KEY'),
125 |
126 | 'cipher' => 'AES-256-CBC',
127 |
128 | /*
129 | |--------------------------------------------------------------------------
130 | | Autoloaded Service Providers
131 | |--------------------------------------------------------------------------
132 | |
133 | | The service providers listed here will be automatically loaded on the
134 | | request to your application. Feel free to add your own services to
135 | | this array to grant expanded functionality to your applications.
136 | |
137 | */
138 |
139 | 'providers' => [
140 |
141 | /*
142 | * Laravel Framework Service Providers...
143 | */
144 | Illuminate\Auth\AuthServiceProvider::class,
145 | Illuminate\Broadcasting\BroadcastServiceProvider::class,
146 | Illuminate\Bus\BusServiceProvider::class,
147 | Illuminate\Cache\CacheServiceProvider::class,
148 | Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
149 | Illuminate\Cookie\CookieServiceProvider::class,
150 | Illuminate\Database\DatabaseServiceProvider::class,
151 | Illuminate\Encryption\EncryptionServiceProvider::class,
152 | Illuminate\Filesystem\FilesystemServiceProvider::class,
153 | Illuminate\Foundation\Providers\FoundationServiceProvider::class,
154 | Illuminate\Hashing\HashServiceProvider::class,
155 | Illuminate\Mail\MailServiceProvider::class,
156 | Illuminate\Notifications\NotificationServiceProvider::class,
157 | Illuminate\Pagination\PaginationServiceProvider::class,
158 | Illuminate\Pipeline\PipelineServiceProvider::class,
159 | Illuminate\Queue\QueueServiceProvider::class,
160 | Illuminate\Redis\RedisServiceProvider::class,
161 | Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
162 | Illuminate\Session\SessionServiceProvider::class,
163 | Illuminate\Translation\TranslationServiceProvider::class,
164 | Illuminate\Validation\ValidationServiceProvider::class,
165 | Illuminate\View\ViewServiceProvider::class,
166 |
167 | /*
168 | * Package Service Providers...
169 | */
170 |
171 | /*
172 | * Application Service Providers...
173 | */
174 | App\Providers\AppServiceProvider::class,
175 | App\Providers\AuthServiceProvider::class,
176 | // App\Providers\BroadcastServiceProvider::class,
177 | App\Providers\EventServiceProvider::class,
178 | App\Providers\RouteServiceProvider::class,
179 |
180 | ],
181 |
182 | /*
183 | |--------------------------------------------------------------------------
184 | | Class Aliases
185 | |--------------------------------------------------------------------------
186 | |
187 | | This array of class aliases will be registered when this application
188 | | is started. However, feel free to register as many as you wish as
189 | | the aliases are "lazy" loaded so they don't hinder performance.
190 | |
191 | */
192 |
193 | 'aliases' => [
194 |
195 | 'App' => Illuminate\Support\Facades\App::class,
196 | 'Arr' => Illuminate\Support\Arr::class,
197 | 'Artisan' => Illuminate\Support\Facades\Artisan::class,
198 | 'Auth' => Illuminate\Support\Facades\Auth::class,
199 | 'Blade' => Illuminate\Support\Facades\Blade::class,
200 | 'Broadcast' => Illuminate\Support\Facades\Broadcast::class,
201 | 'Bus' => Illuminate\Support\Facades\Bus::class,
202 | 'Cache' => Illuminate\Support\Facades\Cache::class,
203 | 'Config' => Illuminate\Support\Facades\Config::class,
204 | 'Cookie' => Illuminate\Support\Facades\Cookie::class,
205 | 'Crypt' => Illuminate\Support\Facades\Crypt::class,
206 | 'Date' => Illuminate\Support\Facades\Date::class,
207 | 'DB' => Illuminate\Support\Facades\DB::class,
208 | 'Eloquent' => Illuminate\Database\Eloquent\Model::class,
209 | 'Event' => Illuminate\Support\Facades\Event::class,
210 | 'File' => Illuminate\Support\Facades\File::class,
211 | 'Gate' => Illuminate\Support\Facades\Gate::class,
212 | 'Hash' => Illuminate\Support\Facades\Hash::class,
213 | 'Http' => Illuminate\Support\Facades\Http::class,
214 | 'Js' => Illuminate\Support\Js::class,
215 | 'Lang' => Illuminate\Support\Facades\Lang::class,
216 | 'Log' => Illuminate\Support\Facades\Log::class,
217 | 'Mail' => Illuminate\Support\Facades\Mail::class,
218 | 'Notification' => Illuminate\Support\Facades\Notification::class,
219 | 'Password' => Illuminate\Support\Facades\Password::class,
220 | 'Queue' => Illuminate\Support\Facades\Queue::class,
221 | 'RateLimiter' => Illuminate\Support\Facades\RateLimiter::class,
222 | 'Redirect' => Illuminate\Support\Facades\Redirect::class,
223 | // 'Redis' => Illuminate\Support\Facades\Redis::class,
224 | 'Request' => Illuminate\Support\Facades\Request::class,
225 | 'Response' => Illuminate\Support\Facades\Response::class,
226 | 'Route' => Illuminate\Support\Facades\Route::class,
227 | 'Schema' => Illuminate\Support\Facades\Schema::class,
228 | 'Session' => Illuminate\Support\Facades\Session::class,
229 | 'Storage' => Illuminate\Support\Facades\Storage::class,
230 | 'Str' => Illuminate\Support\Str::class,
231 | 'URL' => Illuminate\Support\Facades\URL::class,
232 | 'Validator' => Illuminate\Support\Facades\Validator::class,
233 | 'View' => Illuminate\Support\Facades\View::class,
234 |
235 | ],
236 |
237 | ];
238 |
--------------------------------------------------------------------------------
/app/Models/Kakolog.php:
--------------------------------------------------------------------------------
1 | setTimestamp($start_time);
27 | $end_date = new DateTime();
28 | $end_date->setTimestamp($end_time);
29 |
30 | // 有効なタイムスタンプでない場合はエラー
31 | if (!Kakolog::isValidTimeStamp($start_time) or !Kakolog::isValidTimeStamp($end_time)) {
32 | return ['取得開始時刻または取得終了時刻が不正です。', false];
33 | }
34 |
35 | // 取得開始時刻と取得終了時刻が同じ
36 | if ($start_time === $end_time) {
37 | return ['取得開始時刻と取得終了時刻が同じ時刻です。', false];
38 | }
39 |
40 | // 取得開始時刻が取得終了時刻より大きい
41 | if ($start_time >= $end_time) {
42 | return ['指定された取得開始時刻は取得終了時刻よりも後です。', false];
43 | }
44 |
45 | // 取得開始時刻~取得終了時刻が3日間を超えている
46 | // 3日間ぴったりだけ許可する
47 | if (($start_date->diff($end_date)->days >= 3) and
48 | !($start_date->diff($end_date)->days === 3 and $start_date->diff($end_date)->h === 0 and
49 | $start_date->diff($end_date)->i === 0 and $start_date->diff($end_date)->s === 0)) {
50 | return ['3日分を超えるコメントを一度に取得することはできません。数日分かに分けて取得するようにしてください。', false];
51 | }
52 |
53 | // $start_date, $end_date は日付の比較用なので、時間:分:秒 の情報は削除して 00:00:00 に統一
54 | $start_date->setTime(0, 0, 0);
55 | $end_date->setTime(0, 0, 0);
56 |
57 | // 現在作業している日付
58 | $current_date = $start_date;
59 |
60 | // 過去ログ、この文字列に足していく
61 | $kakolog = '';
62 |
63 | // 終了時刻の日付になるまで日付を足し続ける
64 | for (; $current_date->getTimeStamp() <= $end_time; $current_date->modify('+1 days')) {
65 |
66 | // Hugging Face から過去ログを取得
67 | // 5回までリトライする
68 | $kakolog_file_name = Kakolog::getKakologFilePath($jikkyo_id, $current_date);
69 | $kakolog_file_url = "https://huggingface.co/datasets/KakologArchives/KakologArchives/resolve/main/{$kakolog_file_name}";
70 | $retry_count = 5;
71 | while ($retry_count > 0) {
72 | try {
73 | $kakolog_response = HTTP::withOptions(['verify' => false])->get($kakolog_file_url);
74 | break;
75 | } catch (\Throwable $e) {
76 | $retry_count--;
77 | if ($retry_count === 0) throw $e; // 5回失敗したら例外を投げる
78 | sleep(1); // 1秒待機
79 | }
80 | }
81 |
82 | // その日付の過去ログファイル (.nicojk) が存在しない
83 | // Hugging Face 上でステータスコードが 404 であれば存在しないものとする
84 | if ($kakolog_response->status() === 404) {
85 |
86 | // 指定された実況チャンネルが(過去を含め)存在しない場合はここでエラーにする
87 | // 過去ログが存在するならこの判定は不要なので、レスポンス高速化のためにその日付の過去ログが存在しない場合のみ判定を行う
88 | $jikkyo_ch_exists_url = "https://huggingface.co/datasets/KakologArchives/KakologArchives/tree/main/{$jikkyo_id}";
89 | $retry_count = 5;
90 | while ($retry_count > 0) {
91 | try {
92 | $jikkyo_ch_exists_response = Http::withOptions(['verify' => false])->get($jikkyo_ch_exists_url);
93 | break;
94 | } catch (\Throwable $e) {
95 | $retry_count--;
96 | if ($retry_count === 0) throw $e; // 5回失敗したら例外を投げる
97 | sleep(1); // 1秒待機
98 | }
99 | }
100 | if ($jikkyo_ch_exists_response->status() === 404) {
101 | return ['指定された実況 ID は存在しません。', false];
102 | }
103 |
104 | // ファイルだけが存在しない場合は以降の処理をスキップ
105 | continue;
106 |
107 | // 404 ではないが、200 (成功) でもない場合
108 | // Hugging Face の障害が考えられるので、その旨を表示する
109 | } else if ($kakolog_response->status() !== 200) {
110 | return ["Hugging Face で障害が発生しているため、過去ログを取得できません。(HTTP Error {$kakolog_response->status()})", false];
111 | }
112 |
113 | // 過去ログを取得( trim() で両端の改行を除去しておく)
114 | $kakolog_file = trim($kakolog_response->body());
115 |
116 | // 開始/終了時刻の日付のみ
117 | if ($start_date->getTimeStamp() === $current_date->getTimeStamp() or
118 | $end_date->getTimeStamp() === $current_date->getTimeStamp()) {
119 |
120 | // コメントを 要素ごとに分割する( \n で分割しないのはまれに複数行コメントが存在するため)
121 | $kakolog_array = explode(' ', $kakolog_file);
122 |
123 | // start_date よりも前のコメントを削除
124 | foreach ($kakolog_array as $key => $value) {
125 |
126 | // コメントのタイムスタンプを正規表現で抽出
127 | preg_match('/date="([0-9]+?)"/s', $value, $matches);
128 |
129 | // タイムスタンプが存在しない(で分割した最後の要素、空要素など)
130 | if (!isset($matches[1])) {
131 | // 当該要素を削除して次のループへ
132 | unset($kakolog_array[$key]);
133 | continue;
134 | }
135 | // コメントのタイムスタンプ
136 | $timestamp = $matches[1];
137 |
138 | // 開始時刻の日付のみ、開始時刻のタイムスタンプよりも小さいコメントを削除
139 | if ($start_date->getTimeStamp() === $current_date->getTimeStamp()) {
140 | if ($timestamp < $start_time) {
141 | unset($kakolog_array[$key]);
142 | }
143 | }
144 |
145 | // 終了時刻の日付のみ、終了時刻のタイムスタンプよりも大きいコメントを削除
146 | if ($end_date->getTimeStamp() === $current_date->getTimeStamp()) {
147 | if ($timestamp > $end_time) {
148 | unset($kakolog_array[$key]);
149 | }
150 | }
151 | }
152 |
153 | // 一度配列に分割したコメントを implode() で文字列に戻す
154 | $kakolog_implode = implode('', $kakolog_array).'';
155 |
156 | // もし末尾が "/>" になってしまった場合は、"/>" に置換する
157 | $kakolog_implode = str_replace('/>', '/>', $kakolog_implode);
158 |
159 | // 内容が しかない(=指定期間のコメントが存在しない)場合は空に設定
160 | if ($kakolog_implode === '') {
161 | $kakolog_implode = '';
162 | }
163 |
164 | // $kakolog に追記
165 | // 前後の改行は trim() で削除しておく
166 | $kakolog = $kakolog . trim($kakolog_implode);
167 |
168 | // それ以外の日付
169 | } else {
170 |
171 | // そのまま追記
172 | $kakolog = $kakolog . $kakolog_file;
173 | }
174 |
175 | // 改行を追加
176 | $kakolog = $kakolog . "\n";
177 | }
178 |
179 | // 最初と最後にあるかもしれない改行を削除
180 | $kakolog = trim($kakolog);
181 |
182 | // 生の過去ログデータを返す
183 | return [$kakolog, true];
184 | }
185 |
186 |
187 | /**
188 | * 過去ログのファイルパスを取得する
189 | *
190 | * @param string $jikkyo_id 実況ID
191 | * @param DateTime $datetime DateTime オブジェクト
192 | * @return string 過去ログのファイルパス (例: jk1/2021/20210101.nicojk)
193 | */
194 | private static function getKakologFilePath(string $jikkyo_id, DateTime $datetime): string
195 | {
196 | return "{$jikkyo_id}/{$datetime->format('Y')}/{$datetime->format('Ymd')}.nicojk";
197 | }
198 |
199 |
200 | /**
201 | * 有効なタイムスタンプかどうかを返す
202 | *
203 | * @param mixed $timestamp タイムスタンプ
204 | * @return boolean 有効なタイムスタンプかどうか
205 | */
206 | private static function isValidTimeStamp($timestamp) {
207 | // 0 以上で現在のタイムスタンプ以下の数値
208 | return is_numeric($timestamp) and intval($timestamp) >= 0 and intval($timestamp) <= time();
209 | }
210 |
211 |
212 | /**
213 | * エラーメッセージを指定の形式でフォーマットして返す
214 | * 複数の要素がある場合は改行で連結する
215 | *
216 | * @param string $message エラーメッセージ
217 | * @param string $format フォーマット形式 (XML or JSON)
218 | * @return string フォーマットしたエラーメッセージ
219 | */
220 | public static function errorMessage(string $message, string $format): string
221 | {
222 | // XML の場合
223 | if ($format === 'xml') {
224 |
225 | return Kakolog::formatToXml("{$message} ");
226 |
227 | // JSON の場合
228 | } else if ($format === 'json') {
229 |
230 | $message_array = ['error' => $message];
231 |
232 | // json_encode() で JSON にフォーマット
233 | // JSON_PRETTY_PRINT はローカル環境のみ(コメントデータが大量だとスペースや改行の分データが余計に増えて重くなる)
234 | if (\App::isLocal()) {
235 | return json_encode($message_array, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT);
236 | } else {
237 | return json_encode($message_array, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
238 | }
239 | }
240 | }
241 |
242 |
243 | /**
244 | * 生の過去ログデータを XML にフォーマットする
245 | *
246 | * @param string $kakolog_raw 生の過去ログデータ
247 | * @return string XML にフォーマットした過去ログデータ
248 | */
249 | public static function formatToXml(string $kakolog_raw): string
250 | {
251 | // XML のヘッダをつけてるだけなので Valid な XML かは微妙(たまに壊れてるのとかあるし)
252 | if (strpos($kakolog_raw, '') !== false) { // が存在するか
253 | return "\n{$kakolog_raw}";
254 | // 取得したコメントが存在しない
255 | } else if (trim($kakolog_raw) === '') {
256 | return "\n\n ";
257 | } else {
258 | return "\n\n{$kakolog_raw}\n ";
259 | }
260 | }
261 |
262 |
263 | /**
264 | * 生の過去ログデータを JSON にフォーマットする
265 | *
266 | * @param string $kakolog_raw 生の過去ログデータ
267 | * @return string JSON にフォーマットした過去ログデータ
268 | */
269 | public static function formatToJson(string $kakolog_raw): string
270 | {
271 | // まずは XML に直す
272 | $kakolog_xml = Kakolog::formatToXml($kakolog_raw);
273 |
274 | // JSON に変換した XML オブジェクト?として読み込む
275 | // 参考: https://stackoverflow.com/a/31273676
276 | $kakolog_object = new JsonSerializer($kakolog_xml);
277 |
278 | // json_encode() で JSON にフォーマット
279 | // JSON_PRETTY_PRINT はローカル環境のみ(コメントデータが大量だとスペースや改行の分データが余計に増えて重くなる)
280 | if (\App::isLocal()) {
281 | return json_encode($kakolog_object, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT);
282 | } else {
283 | return json_encode($kakolog_object, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
284 | }
285 | }
286 | }
287 |
--------------------------------------------------------------------------------
/resources/views/index.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | ニコニコ実況 過去ログ API
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
67 |
68 |
69 |
70 |
71 |
72 |
115 |
116 |
117 |
118 |
119 |
「ニコニコ実況の Web 版非公式コメントビューア」+「公式にない実況チャンネルを補完するコメントサーバー」、NX-Jikkyo を運営中です!!
120 | NX-Jikkyo から本家ニコニコ実況へコメントする機能を使えば、PC でもスマホでも使える軽量コメントビューアとして利用できます!
121 | 既に jkcommentviewer / TVTest (NicoJK) / KonomiTV など多くの実況関連ソフトの最新版にて対応していただいています!
122 | NX-Jikkyo に投稿されたコメントは随時この過去ログ API で取得できるよう反映されていますので、ぜひ使ってみてください…!!🙏🙏
123 |
124 |
125 |
126 |
127 |
239 |
240 |
241 |
242 |
243 |
244 |
ニコニコ実況 過去ログ API は、ニコニコ実況の過去ログを XML や JSON データで提供しています。
245 |
246 | 去る2020年12月、ニコニコ実況はニコニコ生放送内の一公式チャンネルとしてリニューアルされました。 これに伴い、2009年11月から運用されてきた旧システムは提供終了となり(事実上のサービス終了)、torne や BRAVIA などの家電への対応が軒並み終了する中、当時の生の声が詰まった約11年分の過去ログも同時に失われることとなってしまいました。
247 |
248 |
249 | そこで 5ch の DTV 板の住民が中心となり、旧ニコニコ実況が終了するまでに11年分の全チャンネルの過去ログをアーカイブする計画が立ち上がりました。紆余曲折あり Nekopanda 氏が約11年分のラジオや BS も含めた全チャンネルの過去ログを完璧に取得してくださったおかげで、11年分の過去ログが電子の海に消えていく事態は回避できました。
250 | しかしながら、旧 API が廃止されてしまったため過去ログを API 経由で取得することができなくなり、またアーカイブされた過去ログから見たい範囲のログを探す場合も、アーカイブのサイズが合計約 150GB もあることから、とても以前のように手軽に過去ログに触れることはできなくなってしまいました。
251 |
252 |
253 | 一方、ニコニコ生放送内の一公式チャンネルとして移行した新ニコニコ実況では、タイムシフト(旧ニコニコ実況での過去ログに相当)の視聴期限は3週間までとなっているため、その期限を過ぎると過去ログは視聴できなくなってしまいます。また一般会員は事前にタイムシフト予約をしておく必要があるなど、以前のような利便性は失われています。
254 |
255 |
256 | 私たちは、ニコニコ実況に投稿された日本のテレビ放送についてのコメントは、当時の世相や時代背景を端的に表す、歴史的価値のある資料だと考えています。
257 | この API は、ニコニコ実況のすべての過去ログを後世に残すべく、Nekopanda 氏が配布されていた旧ニコニコ実況の 2020/12/15 までのすべての過去ログに加え、コミュニティでの実況番組も含めた新ニコニコ実況、さらに 2024/06/10 からは実況用代替コメントサーバーである NX-Jikkyo の当日分の過去ログを5分に1回収集し、取得したデータを XML 形式や JSON 形式で提供する、非公式の過去ログデータベース API です。
258 | 比較的簡単に利用できるようにしているつもりですが、いくつか注意事項もあります。 利用される際は下記の 機能・注意事項 をよく読んだ上でご利用ください。
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 | 2020/12/15 までに投稿された旧ニコニコ実況のすべての過去ログを取得できます。
271 |
277 | 2020/12/16 以降に投稿された新ニコニコ実況のすべての過去ログを取得できます。
278 |
279 | 新ニコニコ実況の過去ログデータは自作の JKCommentCrawler を利用して収集しています。
280 | 公式チャンネル ( jk1・jk2・jk4・jk5・jk6・jk7・jk8・jk9・jk101・jk211 ) の放送に加えて、公式では廃止され、現在は 有志のコミュニティ から放送されている NHK BS1・BS11 以外の BS・CS 各局 ( jk103・jk141・jk151・jk161・jk171・jk181・jk191・jk192・jk193・jk222・jk236・jk252・jk260・jk263・jk265・jk333 ) 、地デジ独立局 ( jk10・jk11・jk12 ) の過去ログも収集しています。
281 |
282 | ニコニコミュニティのサービス終了 にともない、今まで有志らのコミュニティで維持されてきたニコニコ実況チャンネルは、事実上 NX-Jikkyo 上に移行する形となっています。詳しく こちらの記事 をご覧ください。
283 |
284 | 5分に1回、当日分の全チャンネルの過去ログを自動で収集します。
285 |
286 | 収集は5分に1回のため、たとえば 17:02 に終わった番組の過去ログを直後の 17:03 に取得する、といったことはできません。
287 | 17:00 ~ 17:05 の過去ログの収集が終わる 17:05 以降(実際は収集に 3 分ほどかかるため 17:08 以降)まで待つ必要があります。
288 |
289 | レスポンスには運営コメント( /nicoad や /emotion のようなコマンド付きコメント)も含まれます。
290 |
291 | 運営コメントをレスポンスに含めるべきかかなり悩みましたが、元データの段階で運営コメントを取り除いてしまうと後から運営コメントが必要になっても手遅れになってしまうので、それよりかはいいかなーと判断しました。
292 | このため、API を利用するクライアントソフト側で運営コメントをすべて弾いたり、/nicoad からメッセージだけ取り出して固定コメントとして描画したり…といった実装が別途必要になります。
293 | 正規表現なら /\/[a-z]+ / で判定できると思います。
294 | メッセージサーバーの仕様が変更された 2024/08/05 以降の新ニコニコ実況では、コメント配信形式が Protocol Buffers で構造化された関係で、「運営コメント」という概念自体が廃止されています。(それ以前の過去ログには運営コメントが記録されているため、運営コメントの除外処理自体は今後も必要です。)
295 |
296 |
297 | 2024/06/10 以降に投稿された NX-Jikkyo のすべての過去ログを取得できます。
298 |
299 | NX-Jikkyo は、サイバー攻撃の影響で 2024/06/08 ~ 08/05 まで鯖落ちしていた ニコニコ実況に代わる、ニコニコ実況民のための避難所であり、ニコニコ生放送互換の WebSocket API を備えるコメントサーバーです。
300 | 当時ニコニコ全体のサーバーダウンの長期化が見込まれたことから (実際完全復旧まで3ヶ月弱を要した) 「ニコニコ実況 過去ログ API」の運営者が突貫で開発し、2024/06/10 から運営しています。
301 | ニコニコ実況が復旧した現在では、「ニコニコ実況の Web 版非公式コメントビューア」+「公式にない実況チャンネルを補完するコメントサーバー」として運営を続けています。
302 | NX-Jikkyo のコメントデータは極力ニコニコ生放送準拠のフォーマットで保存されているほか、統合にあたり従来のニコニコ実況の過去ログ同様の XML に変換した上で保存しています。この過去ログ API からは、ニコニコ実況のコメントと全く同じように取得できます。
303 |
304 | 指定された期間の過去ログが存在しない場合は空の packet が返されます。
305 |
306 | たとえば 2009/11/26(ニコニコ実況のリリース日)よりも前の時刻などです。また、新しく開局したチャンネルで、開局前の時刻を指定したときも同じく空の packet が返されます。
307 | これ以外にも、指定された日付のコメント自体は存在するが、指定された時刻で絞り込むとその期間内にコメントが 1 件も投稿されていなかった、といった場合にも発生します(コメントの少ない早朝や昼間、BS チャンネルに多い)。
308 | 具体的には、XML なら <packet></packet> 、JSON なら {"packet": []} のようなレスポンスになります。
309 | エラーにはならないので、もし 1 件も過去ログを取得できなかった場合にエラーにしたい場合は、適宜 API クライアント側で 1 件でもコメントを取得できているか確認するような実装にしてください。
310 |
311 | レスポンスの 文字コードは UTF-8 (BOM なし) 、改行コードは LF です。 ツール等で利用する際は注意してください。
312 | 3日分を超えるコメントを一度に取得することはできません。数日分かに分けて取得するようにしてください。
313 | 万全は期しているつもりですが、突貫工事で作ったため修正できていない不具合があるかもしれません。
314 | 一個人が運営している非公式 API です。ニコニコ公式とは一切関係ありません。
315 | 過去ログデータを除いたコードは GitHub にて公開しています。なにか不具合があれば Issues へお願いします。
316 |
317 | 未検証ですが、自分のサイトでこの API をホストすることも可能です。
318 |
319 | 5分おきに収集した過去ログデータは KakologArchives (Hugging Face) にて公開しています。
320 |
321 | この API も KakologArchives リポジトリから過去ログデータを取得しています。
322 | 以前はサーバーのローカルディスクに保存された過去ログデータを出力していましたが、サーバーのディスク容量を 170GB 近く消費することから自宅サーバーで運用せざるを得ず、安定性に問題を抱えていました。
323 | Hugging Face から過去ログデータを取得するように変更し、API サーバーをクラウドに置けるようになったことで、以前よりも安定性が向上しています。
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 | データをリクエストする際のベースとなる URL は以下になります。
338 | {{ config('app.url') }}/api/kakolog/{実況ID}
339 | この URL に下の表のパラメータを加え、実際にリクエストします。
340 |
341 |
342 |
343 |
344 | パラメータ名
345 | 説明
346 |
347 |
348 | {実況ID}
349 |
350 | ニコニコ実況のチャンネル ID を表します。URL 自体に含めてください。
351 | 例: NHK総合 → jk1・BS11 → jk211
352 |
353 |
354 |
355 | starttime
356 |
357 | 取得を開始する時刻の UNIX タイムスタンプを表します。
358 |
359 |
360 |
361 | endtime
362 |
363 | 取得を終了する時刻の UNIX タイムスタンプを表します。
364 |
365 |
366 |
367 | format
368 |
369 | 出力するフォーマットを表します。xml(XML 形式)または json(JSON 形式)のいずれかを指定します。
370 | XML 形式では過去ログをヘッダーをつけた上でそのまま出力します。
371 | JSON 形式では過去ログをニコニコ動画のコメント API のレスポンスと類似した形態の JSON 形式に変換して出力します。
372 |
373 |
374 |
375 |
376 |
387 |
388 |
389 |
390 |
391 |
392 |
393 |
394 |
395 |
396 |
397 |
398 | 取得した XML・JSON データは以下の定義に基づいて構成されています。(プロパティ名は順不同)
399 | 文字コードは UTF-8(BOMなし)、改行コードは LF です。
400 |
401 |
402 |
403 |
404 | プロパティ名
405 | 内容
406 |
407 |
408 | packet
409 |
410 | すべてのコメントデータがくるまれている親要素。
411 |
412 |
413 | プロパティ名
414 | 内容
415 |
416 |
417 | chat
418 |
419 |
420 | コメントデータ。
421 | 取得した過去ログをそのまま出力しているため、一部のコメントにしか存在しないプロパティもあります。
422 |
423 |
424 |
425 | プロパティ名
426 | 内容
427 |
428 |
429 | thread
430 | コメントのスレッド ID
431 |
432 |
433 | no
434 |
435 | コメント番号 (コメ番) コメ番の単調増加や一意性は保証されていないため、
436 | ソートには date + date_usec の利用を推奨
437 |
438 |
439 |
440 | vpos
441 | スレッド ID から起算したコメントの再生位置 (1/100秒)
442 |
443 |
444 | date
445 | コメント投稿時間の UNIX タイムスタンプ
446 |
447 |
448 | date_usec
449 |
450 | コメント投稿時間 UNIX タイムスタンプの小数点以下の時間 (マイクロ秒単位)
451 | コメント投稿時間の正確なタイムスタンプは
452 | date: 1606431600 / date_usec: 257855 なら 1606431600.257855 になる
453 |
454 |
455 | user_id
456 |
457 | ユーザー ID (コマンドに 184 が指定されている場合は匿名化される)
458 | NX-Jikkyo に投稿されたコメントのユーザー ID は必ず 35 文字以上になる
459 |
460 |
461 |
462 | mail
463 | コメントのコマンド (184, red naka big など)
464 |
465 |
466 | premium
467 | コメントしたユーザーがプレミアム会員であれば 1
468 |
469 |
470 | anonymity
471 | 匿名コメントであれば 1
472 |
473 |
474 | nx_jikkyo
475 |
476 | NX-Jikkyo に投稿されたコメントであれば 1 (過去ログ API 独自のフィールド)
477 | ニコニコ実況に投稿されたコメントでは省略される
478 |
479 |
480 |
481 | content
482 |
483 | コメント本文 (XML 形式では chat 要素自体の値)
484 | AA など、まれに複数行コメントがあるので注意
485 |
486 |
487 |
488 |
489 |
490 |
491 |
492 |
493 |
494 | error
495 |
496 | エラーメッセージ(エラー発生時のみ)。指定されたフォーマットに合わせて出力されますが、
497 | 存在しないフォーマットが指定されたりパラメータが不足している場合には常に JSON 形式で出力されます。
498 |
499 |
500 |
501 |
502 |
503 |
504 | エラーメッセージ
505 | 説明
506 |
507 |
508 | 必要なパラメータが存在しません。
509 |
510 | リクエストパラメータのうちのいずれかが欠けているときに発生します。
511 | 常に JSON 形式で出力されます。
512 |
513 |
514 |
515 | フォーマットは XML または JSON 形式である必要があります。
516 |
517 | リクエストパラメータに設定されたフォーマットが xml でも json でもないときに発生します。
518 | 常に JSON 形式で出力されます。
519 |
520 |
521 |
522 | 指定された実況 ID は存在しません。
523 |
524 | 指定された実況 ID が存在しないときに発生します。
525 | 過去一度も存在したことがない実況 ID のみが対象のため、新ニコニコ実況では用意されていないラジオや BS の一部チャンネルを指定した際はこのエラーは発生しません。
526 |
527 |
528 |
529 | 取得開始時刻または取得終了時刻が不正です。
530 |
531 | 取得開始時刻・取得終了時刻の UNIX タイムスタンプがマイナスの値や現在時刻より未来の値になっているときに発生します。
532 |
533 |
534 |
535 | 取得開始時刻と取得終了時刻が同じ時刻です。
536 |
537 | 取得開始時刻と取得終了時刻の UNIX タイムスタンプが同じ値のときに発生します。
538 |
539 |
540 |
541 | 指定された取得開始時刻は取得終了時刻よりも後です。
542 |
543 | 取得開始時刻の UNIX タイムスタンプが取得終了時刻の UNIX タイムスタンプよりも大きいときに発生します。
544 |
545 |
546 |
547 | 3日分を超えるコメントを一度に取得することはできません。数日分かに分けて取得するようにしてください。
548 |
549 | サーバーの処理負荷などの兼ね合いにより、3日分を超えるコメントを一度に取得することはできません。数日分かに分けて取得するようにしてください。
550 |
551 |
552 |
553 | Hugging Face で障害が発生しているため、過去ログを取得できません。(HTTP Error xxx)
554 |
555 | 障害が発生しているなどの理由により、Hugging Face のサーバーにアクセスできなかったときに起きるエラーです。
556 | 出力元の過去ログデータは Hugging Face から取得しているため、Hugging Face で障害が発生している間は過去ログを取得できません。
557 |
558 |
559 |
560 |
561 |
562 |
563 |
564 |
565 |
566 |
567 |
568 |
569 |
570 |
571 | XML は指定された期間の過去ログをそのまま出力しているため、必ずしも Valid な XML であるとは限りません(まれに破損している場合がある)。
572 |
573 |
574 |
<packet>
575 | <chat thread="1606417201" no="2750" vpos="1440040" date="1606431601" mail="184" user_id="mmJyd4lCsV6e3loLXR0QvZnlnFI" premium="1" anonymity="1" date_usec="373180">六甲おろし歌って</chat>
576 | <chat thread="1606417201" no="2751" vpos="1440136" date="1606431602" mail="184" user_id="Vz1E1ii0OXV1ApWddfG7niOSYak" anonymity="1" date_usec="183595">キタ━━━━(゚∀゚)━━━━!!</chat>
577 | <chat thread="1606417201" no="2752" vpos="1440100" date="1606431603" mail="184" user_id="HCnCAmVDEac_T_fkeS9EHkymli8" anonymity="1" date_usec="405333">hjmt</chat>
578 | <chat thread="1606417201" no="2753" vpos="1440298" date="1606431603" mail="184" user_id="SxULPQ3aPP4noCUEGj_1GOEjp8Y" anonymity="1" date_usec="965862">完全版はBSで方式やろな</chat>
579 | <chat thread="1606417201" no="2754" vpos="1440400" date="1606431605" mail="184" user_id="2H54YZyR0BLlv8_1XnlYl-euia4" anonymity="1" date_usec="103550">合唱会</chat>
580 | <chat thread="1606417201" no="2755" vpos="1440400" date="1606431605" mail="184" user_id="0ojZYR0_KDaecXFZGnaqwazTU3w" premium="1" anonymity="1" date_usec="540295">コンサート</chat>
581 | <chat thread="1606417201" no="2756" vpos="1440400" date="1606431605" mail="184" user_id="FREZGJEF5OhEaGskb3upsxbxu2c" anonymity="1" date_usec="585768">らすとか</chat>
582 | <chat thread="1606417201" no="2757" vpos="1440404" date="1606431606" mail="184" user_id="JknVYfrFwBy2CDrz_jz8bWb5-hU" premium="1" anonymity="1" date_usec="83051">!?</chat>
583 | <chat thread="1606417201" no="2758" vpos="1440515" date="1606431606" mail="184" user_id="QrzHcVSABkD_JaPWmNzcXYBlzUY" anonymity="1" date_usec="782894">コロナ禍じゃ無かったら結構許されないよな</chat>
584 | <chat thread="1606417201" no="2759" vpos="1440803" date="1606431609" mail="184" user_id="CrwzC_JXPIjjPIBW27W1QVtUc80" anonymity="1" date_usec="16461">ハンケチ用意</chat>
585 | (以下コメントが続く)
586 | </packet>
587 |
588 |
589 |
590 |
591 |
592 |
593 |
594 |
595 |
596 |
597 |
598 | ASCII の範囲外の文字もエスケープされずに出力されます。
599 | 実際のレスポンスではサイズが大きくなってしまうため、下記のような改行やインデントは行われません。
600 |
601 |
602 |
{
603 | "packet": [
604 | {
605 | "chat": {
606 | "thread": "1606417201",
607 | "no": "2750",
608 | "vpos": "1440040",
609 | "date": "1606431601",
610 | "mail": "184",
611 | "user_id": "mmJyd4lCsV6e3loLXR0QvZnlnFI",
612 | "premium": "1",
613 | "anonymity": "1",
614 | "date_usec": "373180",
615 | "content": "六甲おろし歌って"
616 | }
617 | },
618 | {
619 | "chat": {
620 | "thread": "1606417201",
621 | "no": "2751",
622 | "vpos": "1440136",
623 | "date": "1606431602",
624 | "mail": "184",
625 | "user_id": "Vz1E1ii0OXV1ApWddfG7niOSYak",
626 | "anonymity": "1",
627 | "date_usec": "183595",
628 | "content": "キタ━━━━(゚∀゚)━━━━!!"
629 | }
630 | },
631 | {
632 | "chat": {
633 | "thread": "1606417201",
634 | "no": "2752",
635 | "vpos": "1440100",
636 | "date": "1606431603",
637 | "mail": "184",
638 | "user_id": "HCnCAmVDEac_T_fkeS9EHkymli8",
639 | "anonymity": "1",
640 | "date_usec": "405333",
641 | "content": "hjmt"
642 | }
643 | },
644 | {
645 | "chat": {
646 | "thread": "1606417201",
647 | "no": "2753",
648 | "vpos": "1440298",
649 | "date": "1606431603",
650 | "mail": "184",
651 | "user_id": "SxULPQ3aPP4noCUEGj_1GOEjp8Y",
652 | "anonymity": "1",
653 | "date_usec": "965862",
654 | "content": "完全版はBSで方式やろな"
655 | }
656 | },
657 | {
658 | "chat": {
659 | "thread": "1606417201",
660 | "no": "2754",
661 | "vpos": "1440400",
662 | "date": "1606431605",
663 | "mail": "184",
664 | "user_id": "2H54YZyR0BLlv8_1XnlYl-euia4",
665 | "anonymity": "1",
666 | "date_usec": "103550",
667 | "content": "合唱会"
668 | }
669 | },
670 | {
671 | "chat": {
672 | "thread": "1606417201",
673 | "no": "2755",
674 | "vpos": "1440400",
675 | "date": "1606431605",
676 | "mail": "184",
677 | "user_id": "0ojZYR0_KDaecXFZGnaqwazTU3w",
678 | "premium": "1",
679 | "anonymity": "1",
680 | "date_usec": "540295",
681 | "content": "コンサート"
682 | }
683 | },
684 | {
685 | "chat": {
686 | "thread": "1606417201",
687 | "no": "2756",
688 | "vpos": "1440400",
689 | "date": "1606431605",
690 | "mail": "184",
691 | "user_id": "FREZGJEF5OhEaGskb3upsxbxu2c",
692 | "anonymity": "1",
693 | "date_usec": "585768",
694 | "content": "らすとか"
695 | }
696 | },
697 | {
698 | "chat": {
699 | "thread": "1606417201",
700 | "no": "2757",
701 | "vpos": "1440404",
702 | "date": "1606431606",
703 | "mail": "184",
704 | "user_id": "JknVYfrFwBy2CDrz_jz8bWb5-hU",
705 | "premium": "1",
706 | "anonymity": "1",
707 | "date_usec": "83051",
708 | "content": "!?"
709 | }
710 | },
711 | {
712 | "chat": {
713 | "thread": "1606417201",
714 | "no": "2758",
715 | "vpos": "1440515",
716 | "date": "1606431606",
717 | "mail": "184",
718 | "user_id": "QrzHcVSABkD_JaPWmNzcXYBlzUY",
719 | "anonymity": "1",
720 | "date_usec": "782894",
721 | "content": "コロナ禍じゃ無かったら結構許されないよな"
722 | }
723 | },
724 | {
725 | "chat": {
726 | "thread": "1606417201",
727 | "no": "2759",
728 | "vpos": "1440803",
729 | "date": "1606431609",
730 | "mail": "184",
731 | "user_id": "CrwzC_JXPIjjPIBW27W1QVtUc80",
732 | "anonymity": "1",
733 | "date_usec": "16461",
734 | "content": "ハンケチ用意"
735 | }
736 | },
737 | (以下コメントが続く)
738 | ]
739 | }
740 |
741 |
742 |
743 |
744 |
745 |
754 |
755 |
756 |
757 |
--------------------------------------------------------------------------------