FETx Web Studio - installation on shared web hosting
=====================================================

What you need
-------------
* PHP 7.4 or newer (8.0+ recommended) with the mysqli, mbstring, json and session extensions
  (all standard on cPanel / Plesk / DirectAdmin hosting).
* One empty MySQL / MariaDB database + a database user with full rights on it.
* A browser with internet access for the visitors (the interface loads Tailwind CSS, SweetAlert2,
  Font Awesome, jQuery, DataTables and the Plus Jakarta Sans font from public CDNs; without
  internet the app still works but falls back to plain system fonts and loses styling/icons).
* HTTPS is strongly recommended (passwords are typed into the sign-in form).

Install in 5 steps
------------------
1. In your hosting control panel create a database and a database user, and give the user ALL
   privileges on that database (cPanel: "MySQL Databases"). Note the database name, user and password.
   On cPanel the real names are usually prefixed, e.g. "account_fetx" and "account_fetxuser".

2. Upload the zip to the folder where the site should live and extract it there:
     - whole domain:   public_html/
     - sub-folder:     public_html/timetable/   (the site will then be https://yourdomain/timetable/)
   (cPanel: File Manager -> Upload -> right-click the zip -> Extract.)
   You should now see index.php, api.php, auth.php, the folders "assets", "inc" and "install".

3. Open the site in your browser (https://yourdomain/ or .../timetable/). You are sent to the
   installer automatically; or open  .../install/  yourself.

4. Follow the wizard:  Requirements -> Database -> Administrator -> Finish.
   You choose your own administrator username and password. The installer creates the tables,
   writes inc/config.local.php and locks itself.

5. Click "Delete the installer folder" on the last page (or delete the "install" folder with the
   file manager / FTP). Then sign in and add your users under Administration.

Folder permissions
------------------
The "inc" folder must be writable by PHP during installation (755 normally works; use 775 if the
installer says it cannot write). If it cannot be made writable, the installer shows the small
config file to create by hand.

Upgrading to a newer version
----------------------------
1. Back up the database (cPanel: phpMyAdmin -> Export) and your inc/config.local.php.
2. Extract the new package over the old files, but do NOT delete inc/config.local.php and
   inc/install.lock (the new package does not contain them, so they are kept).
3. Open the site. Database changes are applied automatically on the first request.
   Do not re-upload the "install" folder.

Reinstalling / moving to another host
-------------------------------------
* To run the installer again delete inc/config.local.php and inc/install.lock, upload "install" again.
* To move hosts: export/import the database, upload the files, then edit inc/config.local.php with
  the new database details (or reinstall into the imported database - the installer keeps existing
  users and projects).

Troubleshooting
---------------
* Blank page or "500 error": your PHP version is too old, or a required extension is missing. Open
  /install/ (before locking) to see the requirement check, or ask your host to enable mysqli/mbstring.
* "Cannot connect to the database server": the host is usually "localhost"; on some hosts it is a
  name shown in the control panel. Check user/password and that the user was added to the database.
* "Database setup failed ... privileges": give the database user ALL privileges on the database.
* Large projects will not save: raise post_max_size and upload_max_filesize (php.ini / "MultiPHP INI
  Editor") to at least 16M.
* After install you are redirected to the installer again: inc/config.local.php was not written;
  check that the file exists inside the "inc" folder.
* The login page is unstyled or icons are missing: the visitor's browser cannot reach the CDNs.

Security notes
--------------
* Delete the "install" folder after installation.
* The "inc" folder is blocked from the web by .htaccess (Apache/LiteSpeed). On nginx hosts, deny
  access to /inc/ in the server configuration if you can; the files there print nothing when
  requested directly.
* Keep PHP up to date and use HTTPS.
* Back up your database regularly - all projects and timetables live there.
