Sách Giáo Khoa Việt Nam - sachgiaokhoa.org

CodeIgniter 4 website:
- Catalog 999 SGK (lớp 1-12) từ API, lọc theo lớp/môn/NXB, tìm kiếm
- Trang chủ grouped browse (bậc học -> lớp -> môn, ưu tiên môn quan trọng)
- Chi tiết sách: metadata đầy đủ, cover nghệ thuật /thumb/{W}x{H}/
- Đọc online qua gate captcha + countdown, PDF viewer pdf.js
- Download: captcha + token một lần + auto cache-bust version
- Tự đồng bộ catalog/cover khi API thay đổi (refresh:catalog)
- Legal: DMCA, miễn trừ trách nhiệm, điều khoản, bảo mật, liên hệ
This commit is contained in:
sachgiaokhoaorg
2026-08-23 07:05:49 +00:00
commit e6b265db99
494 changed files with 134829 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
namespace App\Libraries;
use MongoDB\Client;
/**
* MongoDB connection singleton (mongo-harness).
*/
class Mongo
{
private static ?Client $client = null;
public static function client(): Client
{
if (self::$client === null) {
$uri = env('mongo.uri', 'mongodb://127.0.0.1:27017');
self::$client = new Client($uri, ['serverSelectionTimeoutMS' => 5000]);
}
return self::$client;
}
public static function db(): \MongoDB\Database
{
return self::client()->selectDatabase((string) env('mongo.db', 'sachgiaokhoa'));
}
public static function col(string $name): \MongoDB\Collection
{
return self::db()->selectCollection($name, ['typeMap' => ['root' => 'array', 'document' => 'array', 'array' => 'array']]);
}
}