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:
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
class Pages extends BaseController
|
||||
{
|
||||
public function view(string $page)
|
||||
{
|
||||
if (! is_file(APPPATH . 'Views/pages/' . $page . '.php')) {
|
||||
throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound();
|
||||
}
|
||||
|
||||
return view('pages/' . $page, ['page' => $page]);
|
||||
}
|
||||
|
||||
public function contact()
|
||||
{
|
||||
$sent = false;
|
||||
$error = null;
|
||||
|
||||
if ($this->request->getPost('submit')) {
|
||||
$name = trim((string) $this->request->getPost('name'));
|
||||
$email = trim((string) $this->request->getPost('email'));
|
||||
$message = trim((string) $this->request->getPost('message'));
|
||||
$honey = trim((string) $this->request->getPost('website'));
|
||||
|
||||
if ($honey !== '') {
|
||||
$sent = true; // honeypot: silently accept
|
||||
} elseif (! $name || ! filter_var($email, FILTER_VALIDATE_EMAIL) || mb_strlen($message) < 10) {
|
||||
$error = 'Vui lòng điền đầy đủ và đúng định dạng các trường.';
|
||||
} else {
|
||||
// store in mongo (no mail server in local dev)
|
||||
\App\Libraries\Mongo::col('contact_messages')->insertOne([
|
||||
'name' => $name,
|
||||
'email' => $email,
|
||||
'message' => $message,
|
||||
'ip' => $this->request->getIPAddress(),
|
||||
'at' => new \MongoDB\BSON\UTCDateTime(),
|
||||
'handled' => false,
|
||||
]);
|
||||
$sent = true;
|
||||
}
|
||||
}
|
||||
|
||||
return view('pages/contact', ['sent' => $sent, 'error' => $error]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user