115 lines
4.2 KiB
PHP
Executable File
115 lines
4.2 KiB
PHP
Executable File
<?php
|
|
$cookieParams = session_get_cookie_params();
|
|
$cookieParams['samesite'] = "Lax";
|
|
session_set_cookie_params($cookieParams);
|
|
session_start();
|
|
|
|
if (!empty($_SESSION["kod"]) && !empty($_SESSION['listeners']) && !empty($_SESSION['inicialy']))
|
|
{
|
|
$kod = $_SESSION['kod'];
|
|
$fol = 'streamy/' . $kod . '/';
|
|
$connsa = $fol . 'people.json';
|
|
|
|
if (file_exists($connsa))
|
|
{
|
|
$connections = json_decode(file_get_contents($connsa), true);
|
|
foreach($connections as $key => $value) {
|
|
if((time() - $value['timestamp']) > 300){
|
|
unset($connections[$key]);
|
|
}
|
|
}
|
|
file_put_contents($connsa, json_encode($connections));
|
|
}
|
|
}
|
|
|
|
if (!empty($_SESSION["kod"]) && !empty($_SESSION['listeners']) && !empty($_SESSION["inicialyOriginal"]))
|
|
{
|
|
$kod = $_SESSION['kod'];
|
|
$fol = 'streamy/' . $kod . '/';
|
|
$chata = $fol . 'chat.txt';
|
|
$configa = $fol . 'config.json';
|
|
$jsonobj = file_get_contents($configa);
|
|
$config = json_decode($jsonobj, false);
|
|
|
|
if (file_exists($chata) && $_SESSION["inicialyOriginal"] == $config->adminpwd)
|
|
{
|
|
if (!empty($_GET["onlyconns"])){
|
|
if (!empty($_SESSION["kod"]) && !empty($_SESSION['listeners']) && !empty($_SESSION['inicialy']))
|
|
{
|
|
$connsa = $fol . 'people.json';
|
|
|
|
if (file_exists($connsa))
|
|
{
|
|
$connections = json_decode(file_get_contents($connsa), true);
|
|
$connadm = '
|
|
<table style="width:100%">
|
|
<tr><th>Iniciály</th><th>Počúvajúci</th><th>Dátum a čas pripojenia</th><th>Dátum a čas keepalive</th><th>IP adresa</th></tr>
|
|
';
|
|
foreach($connections as $key => $value) {
|
|
$connadm = $connadm . '<tr><td>' . $value["inicialy"] . '</td>' . '<td>' . $value["listeners"] . '</td>' . '<td>' . $value["date"] . '</td>' . '<td>' . $value["dateping"] . '</td>' . '<td>' . $value["ip"] . '</td></tr>';
|
|
}
|
|
$connadm = $connadm . '</table>';
|
|
echo $connadm;
|
|
}
|
|
}
|
|
}
|
|
else{
|
|
$cnt = 1;
|
|
$chatdat = explode("\n", file_get_contents($chata));
|
|
if (!empty($_GET['delete'])&&!empty($_POST['delete'])){
|
|
if($_POST['delete'] == "*"){
|
|
file_put_contents($chata, "");
|
|
}
|
|
else{
|
|
$chatxx = "";
|
|
array_splice($chatdat, $_POST['delete']-1, 1);
|
|
foreach($chatdat as $line){
|
|
if ($line != ""){
|
|
$chatxx = $chatxx . $line . "\n";
|
|
}
|
|
}
|
|
file_put_contents($chata, $chatxx);
|
|
$chatdat = explode("\n", file_get_contents($chata));
|
|
}
|
|
}
|
|
else{
|
|
$chatadm = '
|
|
<table style="width:100%">
|
|
';
|
|
foreach($chatdat as $line){
|
|
if ($cnt < sizeof($chatdat)){
|
|
$chatadm = $chatadm . '<tr><td>' . $line . '</td><td><button onclick="deleteit('.$cnt.')">Zmazať</button></td></tr>';
|
|
}
|
|
$cnt++;
|
|
}
|
|
$chatadm = $chatadm . '</table>';
|
|
if (!empty($_GET['onlytable'])){
|
|
echo $chatadm;
|
|
}
|
|
else{
|
|
$dats = file_get_contents("templates/admin.html");
|
|
$dats = str_replace('__VLOZ_CHAT_ADMIN_TABULKU__', $chatadm , $dats);
|
|
$dats = str_replace('__VLOZ_URL_AUDIA__', $config->url , $dats);
|
|
$dats = str_replace('__VLOZ_TYP_AUDIA__', $config->type , $dats);
|
|
$dats = str_replace('__VLOZ_ROK__', date("Y"), $dats);
|
|
echo $dats;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
echo '
|
|
<script>
|
|
window.location.href = "index.php";
|
|
</script>
|
|
';
|
|
}
|
|
}
|
|
else {
|
|
echo '
|
|
<script>
|
|
window.location.href = "index.php";
|
|
</script>
|
|
';
|
|
}
|
|
?>
|