WEB RADIO PANEL 2.0.8  -  installation package
==============================================

WHAT IT IS
Management panel for web radios (multiple stations, music library, playlists and time-of-day scheduling, jukebox,
live DJ, site backgrounds, statistics, backup/restore, editable Legal Notice and Privacy texts, panel and public
site in several languages). The package does NOT contain MP3 or video files.

SERVER REQUIREMENTS
- Debian/Ubuntu Linux with root access (SSH)
- A website already created for the domain (site folder served by nginx/Apache with PHP-FPM 8.1+) with an SSL certificate
- MySQL or MariaDB on the server (or the details of an existing database)
- Docker, Icecast 2, PHP CLI with pdo_mysql, python3, openssl, curl, acl
  (the installer offers to install the missing ones with apt)

SERVER WITHOUT A HOSTING PANEL (manual nginx)
   Before installing run:   bash prepara_web.sh   (prompts are in Italian)
   It creates the site folder, the nginx site with PHP-FPM, the stream subdomain and Let's Encrypt certificates,
   and at the end tells you what to answer to the installer. The two DNS A records (site and stream) must exist first.
   To undo it:   bash prepara_web.sh --annulla

INSTALLATION
1. Copy the package to the server and unpack it:
       tar xzf webradio-panel-2.0.8.tar.gz && cd webradio-panel-2.0.8
2. Run the guided installer as root:
       bash install.sh
3. Choose the language (Italiano / English) and answer the questions: each one explains what is needed.
   Requested data: domain, radio name, owner name and logo, radio logo (optional), contact email, languages, panel user and
   password, database. Before anything is changed you see a summary to confirm.
4. At the end you get a report (/root/install-...txt) with addresses and passwords, and the list of
   remaining steps (stream subdomain, nginx rules).

AFTER INSTALLING (from the /admin/ panel)
- Brand and contacts : company name, logo, site title, email, domain
- Stations -> Disclaimer : Legal Notice and Privacy Policy (initially generic SAMPLE texts:
  adapt them and have a professional review them)
- Languages : choose the panel and site language; edit translations or create new languages (fr, de, es...)
- Music library : upload tracks; Playlist : create and assign; the radio starts by itself

STOP ICECAST/RADIO (since 1.0.40)
- In the menu, under START ICECAST, the STOP ICECAST/RADIO button stops everything: Icecast, all stations and the
  DJ live input. They stay stopped even after a server reboot. The public site shows a "Site under maintenance"
  page (inside index.php, no extra page); the panel shows a red notice.
- To restart press START ICECAST: it starts Icecast and the stations again and puts the site back online.
- A logged-in administrator can see the real site during maintenance with  https://yourdomain/?anteprima=1

VIDEO PLAYLIST (since 1.0.41)
- Panel -> Video Playlist: upload MP4 files (or import big files from the media/incoming folder).
- For each video choose the on-air audio: the video's original audio, no audio (silence on air) or another track
  of the Music library; and whether to use it also as radio background (without audio).
- Videos go on air in order, every N tracks (optionally only in a time slot), or immediately with "Put on air now".
  The site shows the video full screen, in sync with the radio.
- Since 1.0.42: when a video starts the site card disappears and the radio starts by itself (if the browser
  blocks autoplay a "Watch the video with sound" button appears); the card comes back when the video ends.
- Since 1.0.43: while a video is on air the site background (even if it is the same video used as background) is hidden, so the video shows only once.
- Since 1.0.44: the card disappears immediately when the video starts, without waiting for the stream delay.
- Since 1.0.45: at the end of a video the picture stays on the last frame and does not restart (except the intended case: audio longer than the video).
- Since 1.0.46: the video no longer replays at its end (the "Put on air now" booking stayed available to Liquidsoap for 8 seconds and a short video was picked up again; it is now cleared when the video starts).
- Since 1.0.50: liquidsoap_next_track.php no longer hands out the same video (and its audio) while it is still on air, so the audio does not repeat. If the audio arrives after the picture, raise "Video delay on the site" (Playlist Video page) to the stream delay (e.g. 11 seconds).
- ffmpeg is needed on the server for the original audio and the covers (installed by install.sh and aggiorna.sh).

UNINSTALL
       bash rimuovi_installazione.sh   (COMPLETE removal: services, scripts, site files and database;
       asks three safety confirmations and offers a backup first; prompts are in Italian)

NOTES
- The panel and the site load icons and fonts from the Internet (see THIRD-PARTY.txt): consider the privacy aspect.
- Translations replace whole phrases; sentences built from several pieces may stay partly in Italian: fix them in Languages.
- LICENSE.txt is a placeholder to replace with your own commercial terms.
- Since 1.0.48: Playlist Video page, under "Upload", "Search videos on the server" lists video files already on the server and adds them to the playlist without re-uploading.
- Since 1.0.50: the Play / Pause labels on the card show the state: "Play" lights up while the radio is playing, "Pause" when stopped (they were swapped). Same for the Jukebox card.
- Since 1.0.50: Stations page, between Slug and Name, an AutoStart column with YES/NO buttons: YES = the site's main page starts with the radio playing, NO = starts paused (default). Browsers may block automatic audio until the listener touches the page; then it stays paused.
- Since 1.0.51: Playlist has the sub-page "Aggiungi o cancella brani" (Add or delete tracks; in the menu under Playlist, or with the button at the top of the Playlist page): it holds the list of tracks to tick to add/remove them from the playlist (previously at the bottom of the Playlist page) and the red Delete column with the "Cancella i selezionati" (Delete selected) button: it deletes the files from the server and removes the tracks from the Library and from every playlist. It asks for confirmation; the track on air is not deleted.
- Since 1.0.52: "Aggiungi o cancella brani" shows 15 tracks per page, the Playlist and Delete columns have an "All" (Tutti) box, and at the top "Upload new tracks from the PC" (audio; ticked = appended at once to the chosen playlist).
- Since 2.0.1: while a DJ is connected live, a RED box with the DJ name and "ON THE AIR NOW" underneath appears in the panel top bar; it disappears by itself when the DJ disconnects (refreshed every 8 seconds, no page reload). Nothing shows when no DJ is connected. The administrator can click the box to disconnect the DJ and close the broadcast (asks for confirmation); DJ users see the box but cannot click it.
- Since 2.0.2: Playlist has the sub-page "Sfondi" (Backgrounds; in the menu under Playlist, or with the "Sfondi" button at the top of the Playlist page): it holds the whole "common background for all tracks of the playlist" section (Common background box, chosen background, available backgrounds with Save choice, sequence with durations and arrows, Remove, image/video upload, import from the server folder), previously on the Playlist page. On the Playlist page the track table shows 15 tracks per page and next to the page numbers there is a "Cerca" (Search) box (title, composer, artist, album or file name, several words allowed): the search stays active when changing page, sort or saving a row; "Mostra tutti" (Show all) clears it.
- Since 2.0.3: on the Programmazione (Schedule) page, below the playlist time slots, there is the "Programmazione brani" (Track scheduling) section. "Cerca in archivio brani" finds a Library track or a Playlist Video clip and "Programma" turns it into a row with its own schedule: every X tracks, period from/to, days M T W T F S S, time slot from/to, TOT plays (0 = no limit; plays done are shown, Azzera resets them), and for videos only Sfondo/video (YES = the video shows on the site, NO = audio only) and Toglie card (YES = card hidden and full-screen video with audio, NO = the card stays and the video is the background). Scheduling overrides everything: with no DJ the track starts when the current track ends; with a live DJ the broadcast is paused (the DJ stays connected) and resumes by itself when the scheduled play ends. During a live show "every X tracks" counts the tracks reported by the DJ software. The update changes radio.liq ("programmati" queue) and restarts Liquidsoap once; if Liquidsoap does not come back up, the previous radio.liq is restored.
- Since 2.0.4: api/regia_trasmissione.php (already called by MIX RADIO) also returns "programmazione": attiva (scheduled play on air, DJ paused), in_coda (about to start), titolo, durata, secondi_rimasti. MIX RADIO uses it to warn the DJ.
- Since 2.0.5: Programmazione brani, checked Salva button: a row is saved only when consistent (frequency, period, days, time slot, TOT, video options); otherwise nothing changes, wrong fields turn red and the errors are listed under the row. Warnings (slot past midnight, slot shorter than the track, TOT reached, row inactive, same track on two rows) and a status for every row.
- Since 2.0.6: Programmazione brani easier to read: each schedule is a two-line box (name, status, Attiva and buttons on top; labelled fields below), larger text.
- Since 2.0.7: Programmazione brani, large track title (with artist) and file name below; next to TOT a red read-only "Passati" box with the plays already aired (reset only with Azzera).
