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ệ
39 lines
1.3 KiB
PHP
39 lines
1.3 KiB
PHP
<?php
|
|
|
|
/**
|
|
* The goal of this file is to allow developers a location
|
|
* where they can overwrite core procedural functions and
|
|
* replace them with their own. This file is loaded during
|
|
* the bootstrap process and is called during the framework's
|
|
* execution.
|
|
*
|
|
* This can be looked at as a `master helper` file that is
|
|
* loaded early on, and may also contain additional functions
|
|
* that you'd like to use throughout your entire application
|
|
*
|
|
* @see: https://codeigniter.com/user_guide/extending/common.html
|
|
*/
|
|
|
|
if (! function_exists('media_version')) {
|
|
/**
|
|
* Cache-busting version for cover/thumb URLs, driven by the upstream
|
|
* catalog. When the API data changes (sourceUpdatedAt differs), the
|
|
* version bumps automatically so CDN/browser caches treat images as new.
|
|
* Falls back to the env override if Mongo is unavailable.
|
|
*/
|
|
function media_version(): string
|
|
{
|
|
static $version = null;
|
|
if ($version !== null) {
|
|
return $version;
|
|
}
|
|
try {
|
|
$meta = \App\Libraries\Mongo::col('catalog')->findOne(['_id' => 'meta']);
|
|
$version = (string) ($meta['mediaVersion'] ?? env('media.version', '1'));
|
|
} catch (\Throwable $e) {
|
|
$version = (string) env('media.version', '1');
|
|
}
|
|
return $version;
|
|
}
|
|
}
|