BestDigitalCard — Digital Visiting Card PHP Script
Design and Developed by MediaByteX

================================================================
READ THIS FIRST
================================================================

This zip is arranged as follows:

    README.txt            This file (zip root)
    START-HERE.txt        One-page quick start
    LICENSE.txt           License and third-party credits
    CHANGELOG.txt         Version history
    Documentation/        HTML guide + installation text
    database/             database.sql (tables, plans, settings — no default accounts)
                          demo-data.sql (OPTIONAL: 4 dummy cards, demo customer,
                                         coupon WELCOME20)
                          upgrade-1.0.2.sql (installs older than v1.0.2 only)
    source/               THE SCRIPT — upload this folder to your website

Open Documentation/index.html in a browser for the illustrated guide.

English only. No encoded PHP. No Composer. No Node. No build step.

================================================================
WHAT TO UPLOAD TO THE SERVER
================================================================

Upload EVERY file INSIDE the "source" folder to public_html (or www / htdocs).

    CORRECT server root after upload:
        public_html/index.php
        public_html/app/
        public_html/install/
        public_html/database/database.sql
        public_html/.htaccess
        public_html/.env.example

    WRONG:
        public_html/source/index.php
        public_html/Documentation/   (docs stay on your PC)

Do not upload this README, Documentation, or the zip-root database folder
as extra parent folders. The installer already has database/database.sql
inside source/.

================================================================
REQUIREMENTS
================================================================

    PHP 8.1 or newer
    MySQL 5.7+ or MariaDB 10.3+ (utf8mb4)
    Apache 2.4 with mod_rewrite and AllowOverride All
        (Nginx rules are in Documentation/index.html)
    Extensions: mysqli, mbstring, openssl, json, curl, gd
    Writable: uploads/  and  logs/

Recommended PHP limits:

    upload_max_filesize = 20M
    post_max_size       = 64M
    max_file_uploads    = 100
    max_input_vars      = 5000
    memory_limit        = 256M

================================================================
INSTALLATION (web installer — recommended)
================================================================

1. Unzip this package on your computer.
2. Open Documentation/index.html and read the steps.
3. Upload every file inside source/ to the website root.
4. Create a MySQL database and a user with ALL privileges on it.
5. In a browser open:

       https://YOUR-DOMAIN.com/install/

6. Enter database details, site URL and site name.
7. Administrator account: enter your admin name, email and YOUR OWN strong
   password twice. There is no default password. Rules: 10+ characters,
   uppercase, lowercase, a number and a symbol (Admin@123-style common
   passwords are rejected).
8. Demo content (optional, OFF by default): tick "Install demo content" to
   add 4 dummy cards, coupon WELCOME20 and a demo customer
   (demo@example.com) whose random password is shown once.
9. Click "Install BestDigitalCard".

   The wizard writes .env, imports /database/database.sql (and
   /database/demo-data.sql if ticked), creates your administrator, and
   writes install/installed.lock. If the lock cannot be written you get an
   error (not "finished"): make install/ writable, create an empty
   install/installed.lock, or delete the install/ folder.

   Reinstall protection: the installer refuses to run if the lock file
   exists OR the database already has an administrator. Deleting the lock
   file alone does not re-open it; use a new, empty database to start over.

10. Sign in at /app/Admin/login.php with the email and password you chose.

Do not upload a .env file from your PC. The installer creates one.

================================================================
INSTALLATION (manual / phpMyAdmin)
================================================================

1. Create database bestdigitalcard  charset utf8mb4  collation utf8mb4_unicode_ci
2. Import  database/database.sql  from this zip (same file as source/database/database.sql)
   Tables, plans, settings — no default accounts: NO admin account, NO default
   password, NO demo cards, NO demo customer, NO coupons.
3. Optional: import  database/demo-data.sql  (4 dummy cards, demo customer whose
   login is disabled when imported by hand, coupon WELCOME20).
4. Copy source/.env.example to .env on the server and set DB_HOST, DB_USER,
   DB_PASS, DB_NAME, CRON_KEY
5. Create the first administrator (one time only — the tool refuses to run
   once an administrator exists, then locks the installer):
       SSH:      php install/create-admin.php
       Browser:  add  SETUP_TOKEN=<random 32+ characters>  to .env, open
                 https://YOUR-DOMAIN/install/create-admin.php, enter the
                 token, your email and a strong password, then remove
                 SETUP_TOKEN from .env.
6. Make uploads/ and logs/ writable (0755 or 0775)
7. Enable mod_rewrite. Visit the site URL.

    mysql -u USER -p bestdigitalcard < database/database.sql
    mysql -u USER -p bestdigitalcard < database/demo-data.sql     (optional)
    php install/create-admin.php

UPGRADING FROM v1.0.2
    Upload the new files (keep .env and uploads/). No SQL import needed.

UPGRADING FROM v1.0.0 / v1.0.1
    Back up. Upload the new files (keep .env and uploads/). Import
    database/upgrade-1.0.2.sql once. Admins sign in again once.

================================================================
LOGINS AND OPTIONAL DEMO CONTENT
================================================================

    Admin   the email + password YOU chose     →  /app/Admin/login.php
            (no default administrator exists)
    Demo    demo@example.com — only if demo content was installed;
            random password shown once by the installer   →  /app/Auth/login.php

    Live dummy cards (only with demo content):
        /business-card       Sharma Consulting
        /menu-card           Spice Garden restaurant
        /appointment-card    Glow Salon & Spa
        /catalog-card        Urban Mart shop

    Dummy coupon (demo content only): WELCOME20  (20% off)

================================================================
HOW TO USE — ADMIN
================================================================

Path: /app/Admin/

    Dashboard      Users, cards, views
    Users          Activate accounts, assign a plan
    Cards          All published and draft cards
    Coupons        Discount codes
    Plans          Free / Pro / Business prices and limits
    Site Settings  Name, logo, SMTP, Razorpay, Cashfree, UPI, maintenance
    Admins         Extra staff (super vs admin)
    Error Logs     logs/php_errors.log

A public card is live only when the card is published, the owner is active,
and a paid plan still has an active unexpired subscription.

================================================================
HOW TO USE — CUSTOMER
================================================================

Path: /app/User/ after /app/Auth/register.php or login.

    Create Card, My Cards, Leads, Reviews, Offline PDF, Subscription.

Pretty URL:  https://your-domain.com/your-slug

================================================================
REBRANDING / RESKIN
================================================================

1. Product name, tagline, logo, support email, WhatsApp
       Admin → Site Settings. Logo about 400×400 px PNG or JPG.

2. Landing accent colour
       source/index.php  — CSS :root  (default #16a34a)

3. Admin panel     source/resources/css/admin-panel.css
4. User panel      source/resources/css/user-panel.css
5. Public cards    source/resources/card_assets/css/card.css
6. Dummy cards     Admin → Cards (only if demo content was installed)
7. Legal pages     follow the site name from settings
8. Author credit   source/core/Config/author.php (MediaByteX)

================================================================
PAYMENTS, EMAIL, CRON
================================================================

    Razorpay webhook    /app/User/razorpay-webhook.php
    Cashfree webhook    /app/User/cashfree-webhook.php
    APP_ENV=production  disables demo "activate without pay"

SMTP: Admin → Settings → Email. Port 587 TLS or 465 SSL.
Leave email verification OFF until a test password-reset arrives.

    0 2 * * * php /path/to/cron/subscription-check.php
    0 3 * * 0 php /path/to/cron/cleanup-logs.php
    https://YOUR-DOMAIN/cron/subscription-check.php?key=YOUR_CRON_KEY

================================================================
TROUBLESHOOTING
================================================================

Homepage "service unavailable"
    Wrong DB details in .env, or database.sql not imported.
    Read logs/php_errors.log

Pretty URLs 404
    Enable mod_rewrite and AllowOverride All. Confirm .htaccess is in the web root
    (uploaded from source/, not left inside a nested source folder).

Blank page
    PHP below 8.1, or a missing extension. The installer lists checks.

Installer says database/database.sql was not found
    You uploaded the parent folders. Upload the CONTENTS of source/ so
    database/database.sql sits next to index.php.

Emails never arrive
    Fill SMTP. Test with forgot-password on your own test customer account.

Installer says "already installed"
    Reinstall protection: the lock file exists or the database already has
    an administrator. Use a new, empty database for a fresh install.

Admin logged out unexpectedly
    Since v1.0.2 deactivating, deleting or changing the password of an admin
    ends that admin's sessions immediately. Sign in again.

================================================================
SUPPORT
================================================================

MediaByteX
Support is provided through this marketplace's item comments/messages.
When you write, include: domain, PHP version, a screenshot,
and the last lines of logs/php_errors.log.

HTML guide:   Documentation/index.html
License:      LICENSE.txt
Changelog:    CHANGELOG.txt
