# NTPPA CMS

A small, self-hosted **PHP + MySQL** content management system with an **ExpertAims-branded**
admin. The client logs in and edits **every page** — its sections, banner, and SEO meta — plus
blog posts, media, and global settings. Built to run on ordinary **cPanel** hosting with no
frameworks, Composer, Node, or GitHub.

The public site reuses the revamp design verbatim (`assets/style.css` + `assets/common.js` +
`images/`), so CMS-driven pages look identical to `newtampappa-revamp`.

## Deploy

See **[DEPLOY-CPANEL.md](DEPLOY-CPANEL.md)** — create DB → import `database/schema.sql` → upload →
set `app/config.php` → `admin/setup.php` → done.

## Run locally (to try before cPanel)

Needs PHP 8+ and MySQL/MariaDB (e.g. Laravel Herd, MAMP, XAMPP, or Homebrew php+mysql):

```bash
# 1. create a DB and import the schema
mysql -u root -e "CREATE DATABASE ntppa"
mysql -u root ntppa < database/schema.sql
# 2. cp app/config.sample.php app/config.php  (set db_name=ntppa, your db_user/pass)
# 3. serve the folder
php -S localhost:8000
# 4. open http://localhost:8000/admin/setup.php  → create admin → delete setup.php
#    then http://localhost:8000/admin/  and  http://localhost:8000/
```

## How it works

```
index.php            Public front controller: URL → page → render (reusing the revamp design)
admin/index.php      The whole admin (login, dashboard, pages, page editor, blog, media, settings)
admin/setup.php      One-time admin-account creator (delete after use)
app/                 config, PDO (db.php), helpers.php, render.php  — blocked from the web
assets/              style.css, common.js (public) · admin.css, admin.js (admin) · ExpertAims logos
database/schema.sql  Tables + starter content (all 8 pages, settings, sample sections & posts)
images/  uploads/    Static images · client-uploaded media (writable)
```

- **Content model:** `pages` (hero + SEO columns) → many `sections` (`richtext`, `image_text`,
  `cards`, `cta`, `html`). `posts` for the blog. `settings` for header/footer identity.
- **Editing:** the Page Editor has three tabs — **Content & Sections** (add / reorder / show-hide /
  edit blocks), **Banner** (hero image + overlay), **SEO & Meta** (title, description, keyword,
  canonical, robots, OG — with a live Google-result preview and checklist score).
- **Security:** session auth, Argon2/bcrypt password hashing (`password_hash`), CSRF tokens on
  every form, PDO prepared statements, `app/` and `database/` blocked via `.htaccess`, upload
  type/size validation.

## Notes & next steps

- **Not runnable in this sandbox** (no PHP here) — build was authored carefully; test on local/cPanel
  and report any errors and I'll fix them.
- Section/post **Body** fields accept HTML (like any CMS WYSIWYG) — admin-only, trusted input. A rich
  text editor (e.g. TinyMCE) can be dropped in later.
- To fully replace the current live site, migrate remaining page content into sections and switch the
  hardcoded nav links in `common.js` to be settings-driven (small follow-up).
