SPONGIE AI – UPDATED PHP / MYSQL WEBSITE
=========================================

NEW IN THIS UPDATE
- Quiet cookie banner with Accept all, Reject optional and granular Settings.
- Essential cookies only by default; Google Analytics and AdSense tags are blocked until the relevant opt-in.
- Cookie Policy page and persistent Cookie settings control.
- About Spongie AI and Contact Us pages.
- Google account sign-in / account creation (Google Identity Services).
- Newsletter consent checkbox (unchecked by default) and newsletter_subscribers database table.
- Existing guest chat, account chat history, OpenAI Responses API and logo retained.
- Payments remain disabled.

IMPORTANT PRIVACY / GDPR NOTES
You cannot legally make non-essential cookies mandatory by saying that merely using the website automatically means consent. In the EEA, analytics and advertising cookies generally require prior, affirmative consent. This package therefore uses a small banner and does not load GA4 or AdSense tags until the visitor opts in to those categories. Essential session cookies remain active.
Newsletter marketing consent is separate and optional. A visitor is NOT automatically added to the marketing list just because they register or use Google sign-in. They must tick the newsletter checkbox. This is intentional; pre-ticked or bundled consent is not a safe GDPR/ePrivacy approach.
For AdSense visitors in the EEA, UK and Switzerland, Google requires publishers to use a Google-certified CMP integrated with IAB TCF for serving ads in those regions. This lightweight banner is a starter consent interface and is NOT a substitute for Google's certified CMP requirement. Before enabling AdSense for EEA traffic, integrate a Google-certified CMP and test Consent Mode / TCF behaviour.
The cookie policy and privacy page are starter drafts. Have them reviewed and complete the controller identity, address, retention, processors, legal bases, user rights and contact details before launch.

INSTALL / UPDATE
1. Back up your existing website files and database.
2. Upload the contents of this folder over your existing Spongie AI folder. Keep your existing config.php credentials.
3. If this is an existing installation, import migration_newsletter.sql into the EXISTING database using phpMyAdmin. Do not re-import schema.sql into a live database unless you know what you are doing. For a brand-new installation, import schema.sql instead.
4. Edit config.php and set: contact_email, google_client_id, ga4_id and adsense_client_id. Leave GA4 and AdSense IDs blank until ready to activate them.
5. Set base_path to the exact URL path.
6. Use HTTPS. Make sure PHP has PDO MySQL, cURL and mbstring enabled.

CONTACT EMAIL
No actual contact email address was supplied in the project files or the prior Spongie AI discussion. The contact page reads config.php -> contact_email. Replace REPLACE_WITH_YOUR_CONTACT_EMAIL with the real address before launch.

GOOGLE SIGN-IN SETUP
1. In Google Cloud Console, create/select a project and configure the OAuth consent screen.
2. Create an OAuth Client ID of type Web application.
3. Add your exact website origin to Authorized JavaScript origins (e.g. https://example.com).
4. Copy the Client ID into config.php -> google_client_id. Do not put a client secret in public JavaScript.
5. Test Google sign-in on HTTPS. The backend verifies the Google ID token audience and email_verified claim before creating/logging in a local account.

GOOGLE ANALYTICS / ADSENSE
- GA4: enter the Measurement ID (G-XXXXXXXXXX) in ga4_id. The tag is only loaded after Analytics consent.
- AdSense: enter the publisher ID (ca-pub-XXXXXXXXXXXXXXXX) in adsense_client_id. The tag is only loaded after Advertising consent. Add the AdSense verification code / ads.txt file as Google instructs.
- For EEA/UK/CH AdSense traffic, configure a Google-certified CMP (IAB TCF) before serving ads.
- Cookie choices are stored in browser localStorage in this starter. A production CMP should manage consent records and regional requirements appropriately.

NEWSLETTER
The database stores only email addresses for which the visitor explicitly opted in. Run migration_newsletter.sql on an existing database. This package stores the consented email list but does not send newsletters; connect a mailing platform and provide an unsubscribe mechanism before sending marketing emails. Google sign-in alone does not subscribe the user.

CONTACT PAGE
Contact page uses mailto and displays the configured contact email. Add a real email address in config.php.

OPENAI / USAGE
Keep your OpenAI API key in config.php only. Default daily free usage limit is 20. API usage is billed separately. Add hosting/WAF rate limiting and monitor costs.

SECURITY / PRODUCTION CHECKS
- Replace all draft legal copy with accurate details about the real operator and processing.
- Confirm config.php and SQL files cannot be downloaded. Apache .htaccess protection is included; configure equivalent Nginx rules if applicable.
- Add database backups, rate limiting, bot protection and monitoring.
- Add a proper unsubscribe route / mailing provider before sending newsletter campaigns.
- Verify Google OAuth authorized origins and redirect / origin settings.
- Test all features on your actual hosting account before public launch.
