# GamesJi Updates — gamesji.com/updates

Auto-updating online-games news + games directory website. PHP + SQLite, no
framework, built to run on any normal shared/cloud hosting (cPanel, Hostinger,
GoDaddy, etc. — anywhere PHP 7.4+ with PDO SQLite is available, which is
almost every host by default).

## What's included
- **RSS fetcher** (`cron/fetch_rss.php`) — pulls from 10 gaming news feeds,
  keyword-filters so only online/mobile/multiplayer game stories are kept,
  dedupes, stores in SQLite.
- **285 real, well-known games** pre-loaded in `data/games.csv` (PUBG, Free
  Fire, Fortnite, Minecraft, Roblox, Ludo King, Chess.com, Genshin Impact,
  Valorant, io-games, and many more) — each with a description and working
  Play Store / App Store install links, plus a direct "Play Online" link for
  the games that have an official browser version.
- **PWA**: `manifest.json` + `sw.js` (service worker) + `offline.html`.
- **SEO**: canonical tags, Open Graph/Twitter cards, JSON-LD (NewsArticle /
  VideoGame / WebSite+SearchAction schema), `robots.txt`, auto-generated
  `sitemap-index.xml` / `sitemap-news.xml` / `sitemap-games.xml` /
  `sitemap-static.xml`.
- **AdSense-ready** ad slots on home, news detail and game detail pages, plus
  `ads.txt`.
- **Search** across all games and all news, with pagination.
- The **"Play Online Free Games"** blinking link to `gamesji.com` appears in
  the top strip and footer of every single page.
- Dark, gaming-themed responsive UI (no external UI framework, pure CSS).

## 1. Upload
Upload the entire contents of this folder to `public_html/updates/` (or
wherever `gamesji.com/updates` points on your host) via FTP/SFTP or your
host's File Manager.

## 2. Set your real domain
Open `includes/config.php` and confirm:
```php
define('SITE_URL', 'https://gamesji.com/updates');
define('MAIN_SITE_URL', 'https://gamesji.com');
```

## 3. Run the installer once
Visit in your browser:
```
https://gamesji.com/updates/install.php
```
This creates the SQLite database (`data/gamesji_updates.sqlite`) and imports
all 285 seed games. **Delete or rename `install.php` after this succeeds.**

Requirements: PHP with `pdo_sqlite` enabled (default on almost all hosts) and
the `data/` folder writable by PHP (usually already the case; if not,
`chmod 755 data`).

## 4. Set up cron jobs (this is what makes it fully automatic — no manual
updates ever needed)
In cPanel → **Cron Jobs** (or your host's equivalent), add:

**Fetch news every 20 minutes:**
```
*/20 * * * * php /home/YOUR_CPANEL_USER/public_html/updates/cron/fetch_rss.php >> /home/YOUR_CPANEL_USER/cron_rss.log 2>&1
```

**Rebuild sitemaps once a day** (also runs automatically after every RSS
fetch, this is just a safety net):
```
0 3 * * * php /home/YOUR_CPANEL_USER/public_html/updates/cron/generate_sitemap.php >> /home/YOUR_CPANEL_USER/cron_sitemap.log 2>&1
```

If your host only offers "URL cron" (visits a URL instead of running PHP
CLI), point the cron at:
```
https://gamesji.com/updates/cron/fetch_rss.php
```
It works either way — the script detects CLI vs HTTP automatically.

## 5. Submit to Google Search Console
- Add property for `gamesji.com` (or specifically `/updates/` as a prefix
  property).
- Submit sitemap: `https://gamesji.com/updates/sitemap-index.xml`
- Optional: paste your verification code into `GOOGLE_SITE_VERIFICATION` in
  `includes/config.php` for meta-tag verification instead of DNS/file upload.

## 6. Turn on Google AdSense
Once your AdSense account is approved:
1. Put your publisher ID into `ADSENSE_CLIENT_ID` in `includes/config.php`
   (looks like `ca-pub-1234567890123456`).
2. Create 3 ad units in AdSense and paste their slot IDs into
   `ADSENSE_SLOT_HEADER`, `ADSENSE_SLOT_INARTICLE`, `ADSENSE_SLOT_SIDEBAR`.
3. Update `ads.txt` with the exact line AdSense gives you (Account → Sites).

## Growing the games directory toward 1000+
`data/games.csv` ships with 285 real, currently popular online/mobile games
— going to a full 1000 with accurate names/links is something you'll want to
grow over time rather than fill with filler entries. To add more:
1. Open `data/games.csv` in Excel/Sheets.
2. Add rows in the same format: `slug,name,category,description,play_url,gplay_url,appstore_url`
   (leave `play_url` blank if the game has no official browser version).
3. Re-run `install.php` — it only inserts new slugs, so it's always safe to
   re-run.
No code changes needed; the games list, search, sitemap and pages all read
straight from the database.

## How the automation satisfies "no manual updates"
- News: cron → `fetch_rss.php` → new SQLite rows → automatically visible on
  `news.php` / homepage / `news-detail.php` → sitemap regenerated → Google
  pinged. Zero manual steps.
- Games: one-time seed import; you only touch `games.csv` again if you want
  to *add more games* (there's no "update" needed for existing ones since
  Play Store/App Store search links never go stale).

## File map
```
index.php              Homepage (latest news + popular games + live ticker)
news.php               News listing, search, pagination
news-detail.php         Single article + JSON-LD + related stories
games.php               Games directory, search + category filter
game-detail.php         Single game + Play/Install buttons + JSON-LD
install.php             One-time DB + seed importer (delete after use)
cron/fetch_rss.php      RSS fetch + filter + store (run every ~20 min)
cron/generate_sitemap.php  Rebuilds all sitemap XML files + pings search engines
includes/config.php     All settings (domain, feeds, AdSense, keywords)
includes/db.php         SQLite connection + schema
includes/functions.php  Shared helper functions
includes/header.php     <head> + top nav + blinking link (every page)
includes/footer.php     Footer + blinking link (every page)
assets/css/style.css    Full theme (dark, cyan/violet gaming look)
assets/js/app.js        Service worker registration + mobile nav
manifest.json, sw.js, offline.html   PWA
robots.txt, sitemap-*.xml, ads.txt   SEO / ads
data/games.csv          Seed data for the games directory
```

## Notes / honesty check
- Games directory ships with **285** real, verifiable titles (not a padded
  fake 1000) — quality over inflated quantity, and it's built to scale
  infinitely via the CSV importer above.
- RSS feed list uses well-known gaming publications + Google News search
  feeds; swap/add feeds any time in `RSS_FEEDS` inside `config.php`.
- SQLite is used so there's zero database setup on your host. If you'd
  rather use MySQL, the schema in `includes/db.php` maps 1:1 to standard SQL
  and can be ported in a few minutes.
