From 026d3219d6c553b8c96217052c9b7ba891b02364 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hi=E1=BA=BFu=20Star?=
<66201416+huzely@users.noreply.github.com>
Date: Thu, 25 Dec 2025 21:50:59 +0700
Subject: [PATCH] Enhance stats, uploads, and ad tracking
---
README.md | 28 ---------
public_html/.htaccess | 6 ++
public_html/README.md | 34 +++++++++++
public_html/admin/dashboard.php | 14 +++++
public_html/admin/includes/auth_check.php | 7 +++
public_html/admin/includes/footer.php | 3 +
public_html/admin/includes/header.php | 16 +++++
public_html/admin/login.php | 28 +++++++++
public_html/admin/logout.php | 4 ++
public_html/admin/post_add.php | 45 ++++++++++++++
public_html/admin/post_copy.php | 14 +++++
public_html/admin/post_delete.php | 9 +++
public_html/admin/post_edit.php | 41 +++++++++++++
public_html/admin/posts.php | 23 ++++++++
public_html/admin/settings.php | 62 ++++++++++++++++++++
public_html/admin/stats.php | 56 ++++++++++++++++++
public_html/api/stats.php | 5 ++
public_html/api/track.php | 16 +++++
public_html/app/cache/.gitkeep | 0
public_html/app/config/config.php | 14 +++++
public_html/app/lib/auth.php | 27 +++++++++
public_html/app/lib/cache.php | 15 +++++
public_html/app/lib/csrf.php | 19 ++++++
public_html/app/lib/db.php | 12 ++++
public_html/app/lib/rate_limit.php | 28 +++++++++
public_html/app/lib/slugify.php | 9 +++
public_html/app/lib/telegram.php | 25 ++++++++
public_html/assets/css/admin.css | 1 +
public_html/assets/css/base.css | 15 +++++
public_html/assets/css/theme1.css | 1 +
public_html/assets/css/theme2.css | 4 ++
public_html/assets/css/theme3.css | 4 ++
public_html/assets/js/adflow.js | 25 ++++++++
public_html/assets/js/app.js | 5 ++
public_html/assets/js/track.js | 11 ++++
public_html/bots/telegram/webhook.php | 2 +
public_html/includes/footer.php | 6 ++
public_html/includes/header.php | 43 ++++++++++++++
public_html/includes/menu.php | 5 ++
public_html/index.php | 49 ++++++++++++++++
public_html/post.php | 54 +++++++++++++++++
public_html/sql/database.sql | 71 +++++++++++++++++++++++
42 files changed, 828 insertions(+), 28 deletions(-)
delete mode 100644 README.md
create mode 100644 public_html/.htaccess
create mode 100644 public_html/README.md
create mode 100644 public_html/admin/dashboard.php
create mode 100644 public_html/admin/includes/auth_check.php
create mode 100644 public_html/admin/includes/footer.php
create mode 100644 public_html/admin/includes/header.php
create mode 100644 public_html/admin/login.php
create mode 100644 public_html/admin/logout.php
create mode 100644 public_html/admin/post_add.php
create mode 100644 public_html/admin/post_copy.php
create mode 100644 public_html/admin/post_delete.php
create mode 100644 public_html/admin/post_edit.php
create mode 100644 public_html/admin/posts.php
create mode 100644 public_html/admin/settings.php
create mode 100644 public_html/admin/stats.php
create mode 100644 public_html/api/stats.php
create mode 100644 public_html/api/track.php
create mode 100644 public_html/app/cache/.gitkeep
create mode 100644 public_html/app/config/config.php
create mode 100644 public_html/app/lib/auth.php
create mode 100644 public_html/app/lib/cache.php
create mode 100644 public_html/app/lib/csrf.php
create mode 100644 public_html/app/lib/db.php
create mode 100644 public_html/app/lib/rate_limit.php
create mode 100644 public_html/app/lib/slugify.php
create mode 100644 public_html/app/lib/telegram.php
create mode 100644 public_html/assets/css/admin.css
create mode 100644 public_html/assets/css/base.css
create mode 100644 public_html/assets/css/theme1.css
create mode 100644 public_html/assets/css/theme2.css
create mode 100644 public_html/assets/css/theme3.css
create mode 100644 public_html/assets/js/adflow.js
create mode 100644 public_html/assets/js/app.js
create mode 100644 public_html/assets/js/track.js
create mode 100644 public_html/bots/telegram/webhook.php
create mode 100644 public_html/includes/footer.php
create mode 100644 public_html/includes/header.php
create mode 100644 public_html/includes/menu.php
create mode 100644 public_html/index.php
create mode 100644 public_html/post.php
create mode 100644 public_html/sql/database.sql
diff --git a/README.md b/README.md
deleted file mode 100644
index cdc16c5..0000000
--- a/README.md
+++ /dev/null
@@ -1,28 +0,0 @@
-# Decrypt
-### [+] Created By HTR-TECH (@***tahmid.rayat***)
-### [+] Disclaimer :
-***Decrypter is a tool to decrypt Encrypted Bash Scripts into a Readable Format.This Tool is created for Educational Purpose only.I am not responsible for any misuse of this tool.***
-
-
-
-### [+] Installation
-```apt update```
-
-```apt install git python2 -y```
-
-```git clone https://github.com/hax0rtahm1d/decrypt```
-
-```cd decrypt```
-
-```python2 dec.py```
-
-### Or, Use Single Command
-
-```
-apt update && apt install git python2 -y && git clone https://github.com/hax0rtahm1d/decrypt && cd decrypt && python2 dec.py
-```
-
-## [+] Find Me on :
-[](https://github.com/htr-tech)
-[](https://www.instagram.com/tahmid.rayat)
-[](https://m.me/tahmid.rayat.official)
diff --git a/public_html/.htaccess b/public_html/.htaccess
new file mode 100644
index 0000000..cd960f0
--- /dev/null
+++ b/public_html/.htaccess
@@ -0,0 +1,6 @@
+RewriteEngine On
+RewriteBase /
+RewriteCond %{REQUEST_URI} !^/(admin|api|bots|assets|includes|app|sql)/
+RewriteCond %{REQUEST_FILENAME} !-f
+RewriteCond %{REQUEST_FILENAME} !-d
+RewriteRule ^([^/]+)/?$ post.php?slug=$1 [QSA,L]
diff --git a/public_html/README.md b/public_html/README.md
new file mode 100644
index 0000000..766d5ba
--- /dev/null
+++ b/public_html/README.md
@@ -0,0 +1,34 @@
+# Tin tức PHP cho shared hosting (dataonline.vn)
+
+## Cấu trúc & upload
+- Giữ nguyên thư mục `public_html/` và upload thẳng vào hosting dataonline.vn (đúng tên public_html).
+- File cấu hình duy nhất: `app/config/config.php` (DB_HOST, DB_NAME, DB_USER, DB_PASS, BASE_URL, SESSION_SALT, CACHE_PATH, CACHE_TTL, TELEGRAM_BOT_TOKEN, TELEGRAM_ADMIN_CHAT_ID).
+- Import `sql/database.sql` vào MySQL (có seed admin + bài mẫu).
+- Đảm bảo `app/cache` có quyền ghi (777 nếu cần).
+- Apache mod_rewrite bật sẵn: `.htaccess` map `/slug` → `post.php?slug=...` và bỏ qua `/admin|/api|/bots|/assets|/includes|/app|/sql`.
+
+## Thiết lập nhanh
+1) Import DB: `sql/database.sql`.
+2) Sửa `app/config/config.php` với thông tin DB + BASE_URL + SESSION_SALT (tùy chọn đổi CACHE_TTL).
+3) (Tuỳ chọn) Điền TELEGRAM_BOT_TOKEN + TELEGRAM_ADMIN_CHAT_ID để bật notify.
+4) Kiểm tra quyền ghi `app/cache/` và thư mục `assets/img` (upload logo/banner).
+
+## Đăng nhập admin
+- URL: `BASE_URL/admin/login.php`
+- Tài khoản mẫu: `admin / admin123` (đổi ngay bằng UPDATE DB hoặc `password_hash` PHP).
+
+## Acceptance test checklist
+1) Slug: mở `/tin-nong-hom-nay` đúng bài.
+2) Quảng cáo Shopee (ads_enabled=1, ad_link có):
+ - Từ trang chủ hoặc truy cập trực tiếp `/slug`: overlay hiện ngay.
+ - Click overlay/nút X/anywhere: tab hiện tại chuyển NGAY đến ad_link, đồng thời mở tab mới `/slug?ad=0` không quảng cáo, không delay.
+3) Ads tắt: ads_enabled=0 hoặc ad_link rỗng → không overlay.
+4) Chống click ảo: spam `/api/track.php` trong 30s không tăng vô hạn (rate limit + hash IP/UA + token phiên).
+5) Theme: đổi theme 1/2/3 trong admin/settings, frontend thay CSS tương ứng.
+6) Telegram notify: publish bài public → nhận tin “Bài mới”; ad_click tích lũy → gửi gộp tối thiểu mỗi 5 phút.
+7) Responsive: kiểm tra mobile/laptop, menu hamburger 3D, admin/login cân đối.
+
+## Lưu ý hiệu năng
+- Cache file: settings (5 phút), home (60s), bài (60s, key theo slug+updated_at).
+- Có thể đặt cache-control dài cho assets tĩnh.
+- Không dùng .env, không cần composer, thuần PHP 7.4+/PDO.
diff --git a/public_html/admin/dashboard.php b/public_html/admin/dashboard.php
new file mode 100644
index 0000000..079627f
--- /dev/null
+++ b/public_html/admin/dashboard.php
@@ -0,0 +1,14 @@
+query('SELECT event_type, COUNT(*) as c FROM events GROUP BY event_type')->fetchAll();
+$byType = []; foreach ($stats as $s){$byType[$s['event_type']] = $s['c'];}
+?>
+
Page views: = $byType['page_view'] ?? 0 ?>
+Post views: = $byType['post_view'] ?? 0 ?>
+Ad clicks: = $byType['ad_click'] ?? 0 ?>
+