# RAJA Gen Tools — Admin Panel Setup

A self-contained PHP admin panel for **gen-codes.site**. It lets you log in and manage the live site: publish articles, upload images, set a logo, control SEO, and paste your Google Analytics / AdSense / Search Console codes — all saved straight to your server. It sits in an `/admin` folder next to your site; your existing tools and pages keep working exactly as they do now.

---

## 1. Requirements

- **cPanel / shared hosting with PHP 7.4 or newer** (PHP 8.x is fine — almost all cPanel hosts have this).
- The site is served from your `public_html` folder (the normal cPanel web root).

## 2. Install (one-time)

The panel already lives inside your project at `public/admin` (plus a `public/uploads` folder). When you deploy, upload the **contents of `public/`** into `public_html/` as usual. After that you'll have:

```
public_html/
├── admin/          ← the panel
├── uploads/        ← uploaded images
├── blog/           ← your articles (index.html + guide pages)
├── sitemap.xml
└── index.html      ← your site
```

Then open: **https://gen-codes.site/admin/**

## 3. Make these writable (important)

The panel writes files, so set folder permissions to **755** (and files to 644) via cPanel File Manager → *Change Permissions*, or FTP:

- `public_html/admin/data`  ← stores login + settings
- `public_html/uploads`     ← uploaded images
- `public_html/blog`        ← so new articles can be created
- `public_html/blog/index.html`  ← so cards can be inserted
- `public_html/sitemap.xml` ← so URLs can be added

If image upload or publishing ever says "could not write," it's almost always this step.

## 4. First login (secure setup)

On your first visit to `/admin/`, you'll see a **one-time setup screen**:

1. Username is pre-filled as **Younasjdw** (change if you like).
2. Choose a **new password** (min 8 characters).
3. Click *Create account & enter*.

Your password is stored **hashed** (never in plain text) in `admin/data/credentials.php`, which is blocked from the web by `.htaccess`.

> Security note: the password you shared in chat earlier is now visible in that chat history — please set a **different** one here.

## 5. What each section does

- **Dashboard** — overview + AdSense-readiness checklist.
- **Articles** — write / edit / delete articles. Each one is generated in your blog's style and auto-added to the blog index and sitemap. Use the toolbar buttons to insert headings, paragraphs, lists, code boxes and FAQ blocks.
- **Media & Logo** — upload images (get a URL to paste into articles) and set your logo.
- **SEO & Codes** — paste your **Google Analytics (GA4)** ID, **AdSense** client ID, and **Search Console** verification. On save, these are injected into every public page automatically. New articles include them too.
- **Appearance** — pick a colour theme; it recolours all content pages instantly and applies to future articles.

## 6. Good to know

- **Tool pages design**: your calculators/tools are a compiled app (a built React bundle). Their *look* can't be re-themed from the panel — but your Analytics/AdSense codes still cover them, because they all load through `index.html` where the codes are injected.
- **Backups**: before big changes, download a copy of `public_html` from cPanel.
- **HTTPS**: use `https://` for the admin area (the login cookie is marked secure automatically over HTTPS).
- **After setup**: in `admin/config.php`, once everything works you can set `display_errors` to `'0'` for production (it's `'1'` now so setup problems are visible).

## 7. Troubleshooting

- **HTTP 500 on /admin/** → PHP version too old, or a typo from manual editing. Check cPanel → *Select PHP Version* (use 8.0+).
- **"Could not write" messages** → fix folder permissions (step 3).
- **Login loops back** → cookies blocked, or the site is mixed http/https. Use the full `https://` URL.
- **Analytics/Ads not showing on a page** → open *SEO & Codes* and click *Re-sync Google codes to all pages*.

---

*Note: this panel was built for your cPanel/PHP host. It couldn't be executed in the build environment, so the very first run happens on your server — if any screen shows an error, copy the message and I'll fix it quickly.*
