<?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.
 */
ob_start();

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

$prefix = 'etchat_' . $this->_prefix;
?>

<?php if ($showBanner): ?>
<div id="successBanner">
    <div class="success-banner">    
        <span>Gespeichert erfolgreich!</span>
        <span class="close-btn" onclick="closeSuccessBanner()">✖</span>
    </div>
</div>
<?php endif; ?>

<form action="./?AdminUpdateConfigTab" method="post" class="admin-form-box">

<input type="hidden" name="csrf_token" value="<?=e($csrfToken)?>">

<div class="kachel-grid">
<!-- ===================================================== -->
<div class="section">
<h3>Allgemein</h3>

<?=e($lang->radio_name[0]->tagData)?>
<input type="text" name="radio_name" value="<?=e($_SESSION[$prefix.'radio_name'])?>" maxlength="50">

<br>

Wartung:
<select name="wartung">
<option value="1" <?=($_SESSION[$prefix.'wartung']==1?'selected':'')?>>An</option>
<option value="0" <?=($_SESSION[$prefix.'wartung']==0?'selected':'')?>>Aus</option>
</select>

Gastzugang:
<select name="gast_zugang">
<option value="1" <?=($_SESSION[$prefix.'gast_zugang']==1?'selected':'')?>>An</option>
<option value="0" <?=($_SESSION[$prefix.'gast_zugang']==0?'selected':'')?>>Aus</option>
</select>

Registrierung:
<select name="reg_an_aus">
<option value="1" <?=($_SESSION[$prefix.'reg_an_aus']==1?'selected':'')?>>An</option>
<option value="0" <?=($_SESSION[$prefix.'reg_an_aus']==0?'selected':'')?>>Aus</option>
</select>

</div>


<!-- ===================================================== -->
<div class="section">
<h3>System</h3>

Nachrichten Zeilen:
<input type="number" min="5" max="200" step="1" name="anz_mess" value="<?=e($_SESSION[$prefix.'anz_messages_im_chat'])?>">

Archiv Löschen nach x Tage:
<input type="number" min="1" max="730" step="1" name="loeschen_nach" value="<?=e($_SESSION[$prefix.'loeschen_nach'])?>">

<br>

Reload in ms.:
<input type="number" min="1000" max="20000" step="100" name="reload" value="<?=e($_SESSION[$prefix.'config_reloadsequenz'])?>">
<sup><small>(ein Wert zwischen 1000 bis 10000 ist sinnvoll)</sup></small>
<br>

Tab Away in Sek.:
<input type="number" min="150" max="3600" step="1" name="tab_away_delay" value="<?=e($_SESSION[$prefix.'tab_away_delay'])?>">
<sup><small>(Zwischen 150 (2,5min.) bis 1200 (20min.) ist sinnvoll)</sup></small>
</div>


<!-- ===================================================== -->
<div class="section">
<h3>Design & Sprache</h3>

Style:
<select name="style"><?=$print_styles?></select>

Sprache:
<select name="lang"><?=$print_lang_files?></select>

</div>


<!-- ===================================================== -->
<div class="section">
<h3>Privilegien Farben</h3>

<?php
function colorRow($label,$name,$value,$letter, $tooltip = ''){
?>
<div class="color-wrapper">
<span class="kreis-buchstabe" style="background: <?=e($value)?>"><?=$letter?></span>
<?=$label?>
<?php if($tooltip): ?>
<span class="info-tooltip" title="<?=e($tooltip)?>">ⓘ:</span>
<?php endif; ?>
<input class="color-input" name="<?=$name?>" value="<?=e($value)?>">
<input class="real-color-input" type="color" value="<?=e($value)?>">
<div class="color-preview" style="background: <?=e($value)?>"></div>
</div>
<?php
}

colorRow('Orgateam ', 'c_admin', $_SESSION[$prefix.'admin_color'], 'A', $lang->admin[0]->tagData);
colorRow($lang->mod[0]->tagData,'c_mod',$_SESSION[$prefix.'mod_color'],'M');
colorRow($lang->user[0]->tagData,'c_user',$_SESSION[$prefix.'user_color'],'U');
colorRow($lang->gast[0]->tagData,'c_gast',$_SESSION[$prefix.'gast_color'],'G');
?>

</div>


<!-- ===================================================== -->
<div class="section">
<h3>Chat Optionen</h3>

<h4>Im Chat</h4>

Zeit:
<select name="zeit">
<option value="1" <?=($_SESSION[$prefix.'an-time']==1?'selected':'')?>>An</option>
<option value="0" <?=($_SESSION[$prefix.'an-time']==0?'selected':'')?>>Aus</option>
</select>

Gender:
<select name="gender">
<option value="1" <?=($_SESSION[$prefix.'ch-an-gender']==1?'selected':'')?>>An</option>
<option value="0" <?=($_SESSION[$prefix.'ch-an-gender']==0?'selected':'')?>>Aus</option>
</select>

Privilegien:
<select name="privi">
<option value="1" <?=($_SESSION[$prefix.'ch-an-privi']==1?'selected':'')?>>An</option>
<option value="0" <?=($_SESSION[$prefix.'ch-an-privi']==0?'selected':'')?>>Aus</option>
</select>

Smileys pro. Messages:
<input type="number" min="4" max="100" step="1"  name="chat_anzsmily" value="<?=e($_SESSION[$prefix.'chat_anzsmily'])?>">

<h4>Online Liste</h4>

Privilegien:
<select name="privi_ol">
<option value="1" <?=($_SESSION[$prefix.'ol-an-privi']==1?'selected':'')?>>An</option>
<option value="0" <?=($_SESSION[$prefix.'ol-an-privi']==0?'selected':'')?>>Aus</option>
</select>

</div>


<!-- ===================================================== -->
<div class="section">
<h3>Startseite (Index)</h3>

Team:
<select name="index_team">
<option value="1" <?=($_SESSION[$prefix.'index_team']==1?'selected':'')?>>An</option>
<option value="0" <?=($_SESSION[$prefix.'index_team']==0?'selected':'')?>>Aus</option>
</select>

Bewerbung:
<select name="index_bewer">
<option value="1" <?=($_SESSION[$prefix.'index_bewer']==1?'selected':'')?>>An</option>
<option value="0" <?=($_SESSION[$prefix.'index_bewer']==0?'selected':'')?>>Aus</option>
</select>

User Online:
<select name="list_user_online">
<option value="1" <?=($_SESSION[$prefix.'user_online']==1?'selected':'')?>>An</option>
<option value="0" <?=($_SESSION[$prefix.'user_online']==0?'selected':'')?>>Aus</option>
</select>

Namensauflistung:
<select name="name_user_online">
<option value="1" <?=($_SESSION[$prefix.'name_user_online']==1?'selected':'')?>>An</option>
<option value="0" <?=($_SESSION[$prefix.'name_user_online']==0?'selected':'')?>>Aus</option>
</select>

Anz Namen:
<input type="number" name="name_user_anz" min="5" max="100" step="1" value="<?=e($_SESSION[$prefix.'name_user_anz'])?>">

Reg User:
<select name="reg_user_an">
<option value="1" <?=($_SESSION[$prefix.'reg_user_an']==1?'selected':'')?>>An</option>
<option value="0" <?=($_SESSION[$prefix.'reg_user_an']==0?'selected':'')?>>Aus</option>
</select>

<small>Weitere Einstellungen <a href="?AdminChatStyler" class="inline-link">Chat Styler</a></small>

</div>


<!-- ===================================================== -->
<div class="section">
<h3>Chat (Button)</h3>

Userliste:
<select name="online_li">
<option value="1" <?=($_SESSION[$prefix.'online_li']==1?'selected':'')?>>An</option>
<option value="0" <?=($_SESSION[$prefix.'online_li']==0?'selected':'')?>>Aus</option>
</select>

Scroll:
<select name="sc">
<option value="1" <?=($_SESSION[$prefix.'scroll']==1?'selected':'')?>>An</option>
<option value="0" <?=($_SESSION[$prefix.'scroll']==0?'selected':'')?>>Aus</option>
</select>

Bild:
<select name="bi">
<option value="1" <?=($_SESSION[$prefix.'bi']==1?'selected':'')?>>An</option>
<option value="0" <?=($_SESSION[$prefix.'bi']==0?'selected':'')?>>Aus</option>
</select>

Youtube:
<select name="yo">
<option value="1" <?=($_SESSION[$prefix.'yo']==1?'selected':'')?>>An</option>
<option value="0" <?=($_SESSION[$prefix.'yo']==0?'selected':'')?>>Aus</option>
</select>

Vollbild:
<select name="vb">
<option value="1" <?=($_SESSION[$prefix.'vollbild']==1?'selected':'')?>>An</option>
<option value="0" <?=($_SESSION[$prefix.'vollbild']==0?'selected':'')?>>Aus</option>
</select>

Bild Upload & Gallery:
<select name="biup">
<option value="1" <?=($_SESSION[$prefix.'biup']==1?'selected':'')?>>An</option>
<option value="0" <?=($_SESSION[$prefix.'biup']==0?'selected':'')?>>Aus</option>
</select>

Team:
<select name="team">
<option value="1" <?=($_SESSION[$prefix.'team']==1?'selected':'')?>>An</option>
<option value="0" <?=($_SESSION[$prefix.'team']==0?'selected':'')?>>Aus</option>
</select>

Bewerbung:
<select name="bewer">
<option value="1" <?=($_SESSION[$prefix.'bewer']==1?'selected':'')?>>An</option>
<option value="0" <?=($_SESSION[$prefix.'bewer']==0?'selected':'')?>>Aus</option>
</select>

Top Userliste:
<select name="top_user_onoff">
<option value="1" <?=($_SESSION[$prefix.'top_user_onoff']==1?'selected':'')?>>An</option>
<option value="0" <?=($_SESSION[$prefix.'top_user_onoff']==0?'selected':'')?>>Aus</option>
</select>
Anz. Top Userliste:
<input type="number" name="top_user" min="1" max="30" step="1" value="<?=e($_SESSION[$prefix.'top_user'])?>">

<small>Weitere Einstellungen <a href="?AdminChatStyler" class="inline-link">Chat Styler</a></small>

</div>
<div class="section">
<h3>Usereinstellungen Anzeige</h3>
Profil:
<select name="pro">
<option value="1" <?=($_SESSION[$prefix.'pro']==1?'selected':'')?>>An</option>
<option value="0" <?=($_SESSION[$prefix.'pro']==0?'selected':'')?>>Aus</option>
</select>

Avatar:
<select name="av">
<option value="1" <?=($_SESSION[$prefix.'av']==1?'selected':'')?>>An</option>
<option value="0" <?=($_SESSION[$prefix.'av']==0?'selected':'')?>>Aus</option>
</select>

Avataranzeige im Chat:
<select name="pic_chat">
<option value="1" <?=($_SESSION[$prefix.'chat_pic']==1?'selected':'')?>>An</option>
<option value="0" <?=($_SESSION[$prefix.'chat_pic']==0?'selected':'')?>>Aus</option>
</select>

Avataranzeige im Profil:
<select name="pic_ben_info">
<option value="1" <?=($_SESSION[$prefix.'be_info_pic']==1?'selected':'')?>>An</option>
<option value="0" <?=($_SESSION[$prefix.'be_info_pic']==0?'selected':'')?>>Aus</option>
</select>
</div>


<!-- ===================================================== -->
<div class="section">
<h3>Radio & Boxen</h3>

Radio:
<select name="radio_box">
<option value="1" <?=($_SESSION[$prefix.'radio_box']==1?'selected':'')?>>An</option>
<option value="0" <?=($_SESSION[$prefix.'radio_box']==0?'selected':'')?>>Aus</option>
</select>

<small>Radio-Box Einstellung <a href="?AdminRadioBoxIndex" class="inline-link">Radio-Box</a></small>
<br><br>

Iframe höhe in px:
<input type="number" name="radio_box_hi" min="1" max="500" step="1" value="<?=e($_SESSION[$prefix.'radio_box_hi'])?>">

Link:
<input type="text" name="radio_box_li" value="<?=e($_SESSION[$prefix.'radio_box_li'])?>">

<hr>
Wunsch Box:
<select name="radio_wb">
<option value="1" <?=($_SESSION[$prefix.'radio_wb']==1?'selected':'')?>>An</option>
<option value="0" <?=($_SESSION[$prefix.'radio_wb']==0?'selected':'')?>>Aus</option>
</select>

Link:
<input type="text" name="radio_wb_li" value="<?=e($_SESSION[$prefix.'radio_wb_li'])?>">

<hr>
DJ Box:
<select name="radio_dj_box">
<option value="1" <?=($_SESSION[$prefix.'dj_box']==1?'selected':'')?>>An</option>
<option value="0" <?=($_SESSION[$prefix.'dj_box']==0?'selected':'')?>>Aus</option>
</select>

Link:
<input type="text" name="radio_dj_box_li" value="<?=e($_SESSION[$prefix.'dj_box_li'])?>">

<hr>
Sendeplan Box:
<select name="radio_sendeplan">
<option value="1" <?=($_SESSION[$prefix.'sendeplan']==1?'selected':'')?>>An</option>
<option value="0" <?=($_SESSION[$prefix.'sendeplan']==0?'selected':'')?>>Aus</option>
</select>

Link:
<input type="text" name="radio_sendeplan_li" value="<?=e($_SESSION[$prefix.'sendeplan_li'])?>">

</div>

<!-- ===================================================== -->
<div class="section">
<h3>Würfel</h3>

Würfel:
<select name="wu">
<option value="1" <?=($_SESSION[$prefix.'wu']==1?'selected':'')?>>An</option>
<option value="0" <?=($_SESSION[$prefix.'wu']==0?'selected':'')?>>Aus</option>
</select>

Augenanzahl:
<input type="number" name="wuan" min="6" max="999" step="1" value="<?=e($_SESSION[$prefix.'wuan'])?>">

Würfeln max.:
<input type="number" name="wuza" min="1" max="25" step="1" value="<?=e($_SESSION[$prefix.'wuza'])?>">

Pause in Min.:
<input type="number" name="wupau" min="1" max="30" step="1" value="<?=e($_SESSION[$prefix.'wupau'])?>">
</div>
</div>

<input type="submit" value="Speichern">

</form>

<script>
document.querySelectorAll('.color-wrapper').forEach(w=>{
let t=w.querySelector('.color-input');
let c=w.querySelector('.real-color-input');
let p=w.querySelector('.color-preview');

t.onclick=()=>c.click();

c.oninput=()=>{
t.value=c.value;
p.style.background=c.value;
};

t.oninput=()=>{
if(/^#[0-9a-f]{6}$/i.test(t.value)){
c.value=t.value;
p.style.background=t.value;
}
};
});
</script>

<script>
function closeSuccessBanner() {
    const banner = document.getElementById("successBanner");
    if (banner) banner.style.display = "none";
}

document.addEventListener('DOMContentLoaded', () => {
    const banner = document.getElementById("successBanner");
    if (banner) {
        setTimeout(() => {
            banner.style.display = "none";
        }, 5000);
    }
});
</script>

<?php
$content = ob_get_clean();

$pageTitle = 'Allgemeine Einstellungen';
$backLink  = './?AdminIndex';
$footerNote = $lang->note[0]->tagData ?? '';

include "admin_master_template.php";
?>