# 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/full-install.sql  ← IMPORT THIS ONE: whole DB in one file (schema + content + submenu
                     split). Safe to re-run — preserves logins, media library and settings.
database/schema.sql  (advanced) tables only · content.sql (advanced) site content ·
database/split-pages.sql  (advanced) Programs/About submenu split — order: schema → content → split
images/  uploads/    Static images · client-uploaded media (writable)
```

- **Content model:** `pages` (hero + SEO columns) → many `sections` (`richtext`, `image_text`,
  `cards`, `videos`, `gallery`, `cta`, `html`). `posts` for the blog. `settings` for header/footer identity.
- **Video Gallery / Photo Gallery sections:** on any page (faculty, gallery, anywhere) the client
  clicks **Add section → Video Gallery** and pastes YouTube links (one per line) — thumbnails render
  with a click-to-play lightbox; or **Add section → Photo Gallery** and pastes image paths (upload in
  Media first, one per line) for a lightbox photo grid. The 9 faculty pages and the Gallery page come
  pre-seeded with these in `content.sql`.
- **Pages screen:** pages are grouped into cards that mirror the website menus — Programs (8 pages:
  overview + Preparatory, Core, Adult, Program Details, Calendar, Performance & Exams, Summer),
  About Us (5), Faculty (listing + one page per teacher), Gallery, Press & News (collapsible list),
  Blog, Career & Contact. Faculty and Press cards include an **Add** box that creates a new draft
  page with the right URL prefix. Fully responsive — usable from a phone (hamburger sidebar).
- **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).
