<?php
declare(strict_types=1);

/**
ET-Chat Copyright by SEDesign | ET-Chat v3.x.x Lizenz: CCPL | Autor: Evgeni Tcherkasski (info@s-e-d.de)
ET-Chat_T-FISH-MOD Weiterentwicklungen, Optimierungen und Ergänzungen am Code sind das geistige Eigentum von Tommy (Thomas Kuhn) und Harlekin (Bernd Witte).

Die darauf folgende Optimierungen und Ergänzungen am Code sind das Geistige Eigentum von Powermen (Christian K.)
und wird unter der Namenserweiterung M.C.v.x.x.x. geführt. 
PHP 8/9 Ready, XML Parser, PDO Prepared Statements Get Set sicherheit usw.
 */

$style = $_SESSION['etchat_' . $this->_prefix . 'style'] ?? 'default';
$style = preg_replace('/[^a-zA-Z0-9_\-]/', '', (string)$style);

function e(string $v): string {
    return htmlspecialchars($v, ENT_QUOTES, 'UTF-8');
}

ob_start();
?>

<div class="kachel-grid">
<!-- ===================================================== -->

<div class="section">
	<h3>Radio Box</h3>
<?php if (is_array($feld)): ?>
<form action="./?AdminUpdateRadioBox" method="post" class="user-form">



    <input type="hidden" name="csrf_token" value="<?= e($_SESSION['etchat_'.$this->_prefix.'csrf_token']); ?>">
    <input type="hidden" name="id" value="<?= e((string)$feld[0][0]); ?>">

    <label for="radiobox">Radio Box An/Aus | Status = <?= e((string)$feld[0][8]); ?></label>
    <select name="radiobox" id="radiobox">
        <option value="1" <?= $feld[0][8] == 1 ? 'selected' : '' ?>>An</option>
        <option value="0" <?= $feld[0][8] == 0 ? 'selected' : '' ?>>Aus</option>
    </select>

    <label for="host">Host</label>
		<sup><small>Link/Url zum Stream ohne https:// oder http:// oder Laut.fm Name</small></sup>
    <input type="text" name="host" id="host" value="<?= e((string)$feld[0][1]); ?>">

    <label for="port">Port</label>
		<sup><small>Port bei Laut.fm leer lassen</small></sup>
    <input type="text" name="port" id="port" value="<?= e((string)$feld[0][2]); ?>">

    <label for="radio_type">Radio Typ</label>
    <select name="radio_server_type" id="radio_type">
        <option value="shoutcast" <?= $feld[0][3] === 'shoutcast' ? 'selected' : '' ?>>Shoutcast</option>
        <option value="icecast" <?= $feld[0][3] === 'icecast' ? 'selected' : '' ?>>Icecast</option>
        <option value="lautfm" <?= $feld[0][3] === 'lautfm' ? 'selected' : '' ?>>Laut.fm</option>
    </select>

    <label for="bitrate">Bitrate</label>
    <input type="text" name="bits" id="bitrate" value="<?= e((string)$feld[0][7]); ?>">

    </div>

<!-- ===================================================== -->
<div class="section">
	<h3>Einstellungen Radio Box</h3>
<div  class="user-form">



    <label for="on_air">On Air Bild</label>
    <select name="on_air" id="on_air">
        <option value="1" <?= $feld[0][10] == 1 ? 'selected' : '' ?>>An</option>
        <option value="0" <?= $feld[0][10] == 0 ? 'selected' : '' ?>>Aus</option>
    </select>

    <label for="sys_titel">System Titel Post im Chat</label>
    <select name="sys_titel" id="sys_titel">
        <option value="1" <?= $feld[0][11] == 1 ? 'selected' : '' ?>>An</option>
        <option value="0" <?= $feld[0][11] == 0 ? 'selected' : '' ?>>Aus</option>
    </select>

    <label for="titel_hist">Titel Historie (Button)</label>
    <select name="titel_hist" id="titel_hist">
        <option value="1" <?= $feld[0][12] == 1 ? 'selected' : '' ?>>An</option>
        <option value="0" <?= $feld[0][12] == 0 ? 'selected' : '' ?>>Aus</option>
    </select>
</div>
    <h3>Player</h3>
<div  class="user-form">
    <label for="player">Player</label>
    <select name="player" id="player">
        <option value="1" <?= $feld[0][9] == 1 ? 'selected' : '' ?>>An</option>
        <option value="0" <?= $feld[0][9] == 0 ? 'selected' : '' ?>>Aus</option>
    </select>

    <label for="stream">Stream</label>
		<sup><small>https://stream.**deine IP oder Domainadresse**:**dein Port**/stream.mp3<br>
					bei Laut FM https://stream.laut.fm/**Laut FM Name**
		</small></sup>
    <input type="text" name="stream" id="stream" value="<?= e((string)$feld[0][4]); ?>">

    <input type="hidden" name="streamname" value="<?= e((string)$feld[0][5]); ?>">
    <input type="hidden" name="color" value="<?= e((string)$feld[0][6]); ?>">
	</div>
</div>
</div>
    <input type="submit" value="Speichern" class="admin-button-primary">

</form>
<?php endif; ?>

<?php
$content = ob_get_clean();

$pageTitle  = 'Radio Box & Player Einstellungen';
$backLink   = './?AdminRadioBoxIndex';
$footerNote = $lang->note[0]->tagData ?? '';

include __DIR__ . '/admin_master_template.php';