add localizatin, fix bugs

This commit is contained in:
2023-01-31 16:08:04 +01:00
parent aa3bdecd08
commit 18360eb63e
10 changed files with 433 additions and 220 deletions

434
index.php
View File

@@ -3,9 +3,7 @@ session_start();
$mysqli = new mysqli('localhost', 'streaming', file_get_contents("secrets/MySQLPWD"), 'streaming');
$ipcka = $_SERVER['REMOTE_ADDR'];
$headers = apache_request_headers();
foreach ($headers as $header => $value) {
if($header == 'X-Real-IP'){
if (!empty($value) && $_SERVER['REMOTE_ADDR'] == "127.0.0.1"){
@@ -14,137 +12,154 @@ foreach ($headers as $header => $value) {
}
}
//BEGIN FUNCTIONS
$stmt2 = $mysqli->prepare("DELETE FROM Connections WHERE TimestampPing < (CURRENT_TIMESTAMP - 300);");
$stmt2->execute();
$stmt2->store_result();
$stmt20 = $mysqli->prepare("DELETE FROM Chat WHERE Timestamp < (CURRENT_TIMESTAMP - 86400);");
$stmt20->execute();
$stmt20->store_result();
if (!empty($_GET["adder"])){
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$heslo = trim($_POST['heslo']);
if (password_verify($heslo, file_get_contents("secrets/AdminPwdHash"))) {
$kod = $_POST['kod'];
$url = $_POST['url'];
$type = $_POST['type'];
$adminpwd = $_POST['adminpwd'];
if(!empty($kod) && !empty($url) && !empty($type) && !empty($adminpwd)){
if(strlen($kod) <= 20 && strlen($url) <= 256 && strlen($type) <= 20 && strlen($adminpwd) <= 20){
$stmt2 = $mysqli->prepare("SELECT ID FROM Streams WHERE Code=? OR AdminCode=?");
$stmt2->bind_param('ss', $kod, $adminpwd);
$stmt2->execute();
$stmt2->store_result();
if ($stmt2->num_rows > 0) {
echo ("Stream exists!");
} else {
$stmt = $mysqli->prepare("INSERT INTO Streams (URL, Type, AdminCode, Code) VALUES (?, ?, ?, ?);");
$stmt->bind_param('ssss', $url, $type, $adminpwd, $kod);
$stmt->execute();
$stmt->store_result();
echo "Stream added";
}
}
}
} else {
echo "Bad password.";
}
}
echo str_replace("__VLOZ_ROK__", date("Y"), file_get_contents("templates/streamadd.html"));
exit();
}
if (!empty($_SESSION["kod"]) && !empty($_SESSION['listeners']) && !empty($_SESSION["inicialy"]) && !empty($_GET["admin"]))
{
$kod = $_SESSION['kod'];
$stmt = $mysqli->prepare("Select ID, URL, Type, Code FROM Streams WHERE AdminCode = ?;");
$stmt->bind_param('s', $kod);
$stmt->bind_result($idcko, $url, $type, $code);
$stmt->execute();
$stmt->store_result();
if ($stmt->num_rows > 0){
while ($stmt->fetch())
{
if (!empty($_GET["onlyconns"])){
$stmt3 = $mysqli->prepare("Select ID, PHPSessID, TimeConnect, TimePing, Listeners, Inicialy, IP FROM Connections WHERE StreamID = ?");
$stmt3->bind_param('i', $idcko);
$stmt3->bind_result($idcko, $phpSessID, $timeConn, $timePing, $listeners, $inicialy, $IP);
$stmt3->execute();
$stmt3->store_result();
$connadm = '
<table style="width:100%">
<tr><th>Iniciály</th><th>Listeners</th><th>Date and time of connection</th><th>Date and time of keepalive</th><th>IP address</th></tr>
';
if ($stmt3->num_rows > 0){
while ($stmt3->fetch())
{
$connadm = $connadm . '<tr><td>' . $inicialy . '</td>' . '<td>' . $listeners . '</td>' . '<td>' . $timeConn . '</td>' . '<td>' . $timePing . '</td>' . '<td>' . $IP . '</td></tr>';
}
}
$connadm = $connadm . '</table>';
echo $connadm;
function languageSelector(){
$lang_dir = "templates/locale";
$langs = scandir($lang_dir);
$langSelectDat = '<div id="langselect"><select>';
foreach($langs as $lang){
if (str_contains($lang, ".json")){
$parsedLang = json_decode(file_get_contents($lang_dir . '/' . $lang), true);
$shortLang = $parsedLang['__LOCALIZATION_LANG_SHORT'];
$longLang = $parsedLang['__LOCALIZATION_LANG_LONG'];
if ($lang == $_SESSION['language'] . '.json'){
$langSelectDat = $langSelectDat . '<option selected onclick="SetLang(\'' . $shortLang . '\');">'. $longLang . '</option>' . "\n";
}
else{
if (!empty($_GET['delete'])&&!empty($_POST['delete'])){
if($_POST['delete'] == "*"){
$stmt5 = $mysqli->prepare("DELETE from Chat WHERE StreamID = ?;");
$stmt5->bind_param('i', $idcko);
$stmt5->execute();
$stmt5->store_result();
}
else{
$deleteid = intval($_POST['delete']);
if ($deleteid >= 0){
$stmt6 = $mysqli->prepare("DELETE from Chat WHERE StreamID = ? AND ID = ?;");
$stmt6->bind_param('ii', $idcko, $deleteid);
$stmt6->execute();
$stmt6->store_result();
}
}
}
else{
$stmt7 = $mysqli->prepare("Select ID, Timestamp, Author, Message from Chat WHERE StreamID = ?;");
$stmt7->bind_param('i', $idcko);
$stmt7->bind_result($idckochat, $timestamp, $author, $message);
$stmt7->execute();
$stmt7->store_result();
$chatadm = '
<table style="width:100%">
<tr>
<th>Author</th><th>Date</th><th>Message</th><th>Delete</th>
</tr>
';
if ($stmt7->num_rows > 0){
while ($stmt7->fetch()){
$chatadm = $chatadm . '<tr><td>' . $author . '</td><td>' . $timestamp . ' GMT</td><td>' . $message . '<td><button onclick="deleteit(' . $idckochat . ')">Delete</button></td></tr>' . "\n";
}
}
$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;
}
}
$langSelectDat = $langSelectDat . '<option onclick="SetLang(\'' . $shortLang . '\');">'. $longLang . '</option>' . "\n";
}
}
}
$langSelectDat = $langSelectDat . '</select></div>';
return $langSelectDat;
}
function localize($input_string){
if (empty($_SESSION['language'])){
$_SESSION['language'] = "en";
}
$language = htmlspecialchars($_SESSION['language']) ;
$lang_dir = "templates/locale";
$langs = scandir($lang_dir);
$lang_file = "";
foreach($langs as $lang){
if ($lang == $language . '.json'){
$lang_file = $lang_dir . '/' . $lang;
}
}
if (file_exists($lang_file)){
$language_obj = json_decode(file_get_contents($lang_file), true);
$tempStr = str_replace("__VLOZ_ROK__", date("Y"), $input_string);
$tempStr = str_replace("__LOCALIZATION_LANGSELECT__", languageSelector(), $tempStr);
$tempStr = str_replace("__LOCALIZATION_LANGSELECT_SCRIPT__", file_get_contents('templates/langSelector.js'), $tempStr);
foreach ($language_obj as $key => $value){
$tempStr = str_replace($key, $value, $tempStr);
}
return $tempStr;
}
else{
return 'LANGUAGE NON EXISTENT';
}
}
function connectionAdminTable($idcko){
global $mysqli;
$stmt2 = $mysqli->prepare("DELETE FROM Connections WHERE TimestampPing < (CURRENT_TIMESTAMP - 300);");
$stmt2->execute();
$stmt2->store_result();
$stmt3 = $mysqli->prepare("Select ID, PHPSessID, TimeConnect, TimePing, Listeners, Inicialy, IP FROM Connections WHERE StreamID = ?");
$stmt3->bind_param('i', $idcko);
$stmt3->bind_result($idckoconnection, $phpSessID, $timeConn, $timePing, $listeners, $inicialy, $IP);
$stmt3->execute();
$stmt3->store_result();
$connadm = '
<table style="width:100%">
<tr><th>__LOCALIZATION_LOGIN_INITIALS_LABEL__</th><th>__LOCALIZATION_LOGIN_LISTENERS_LABEL__</th><th>__LOCALIZATION_CONNECTIONS_DATETIME_CONNECT_ADMIN__</th><th>__LOCALIZATION_CONNECTIONS_DATETIME_PING_ADMIN__</th><th>__LOCALIZATION_CONNECTIONS_IP_ADMIN__</th></tr>
';
if ($stmt3->num_rows > 0){
while ($stmt3->fetch())
{
$connadm = $connadm . '<tr><td>' . $inicialy . '</td>' . '<td>' . $listeners . '</td>' . '<td>' . $timeConn . '</td>' . '<td>' . $timePing . '</td>' . '<td>' . $IP . '</td></tr>';
}
}
$connadm = $connadm . '</table>';
$localized = localize($connadm);
return $localized;
}
function chatAdminTable($idcko){
global $mysqli;
$stmt7 = $mysqli->prepare("Select ID, Timestamp, Author, Message from Chat WHERE StreamID = ?;");
$stmt7->bind_param('i', $idcko);
$stmt7->bind_result($idckochat, $timestamp, $author, $message);
$stmt7->execute();
$stmt7->store_result();
$chatadm = '
<table style="width:100%">
<tr>
<th>__LOCALIZATION_CHAT_AUTHOR_ADMIN__</th><th>__LOCALIZATION_CHAT_DATE_ADMIN__</th><th>__LOCALIZATION_CHAT_MESSAGE_ADMIN__</th><th>__LOCALIZATION_CHAT_ADMIN_DELETE_HEAD__</th>
</tr>
';
if ($stmt7->num_rows > 0){
while ($stmt7->fetch()){
$chatadm = $chatadm . '<tr><td>' . $author . '</td><td>' . $timestamp . ' GMT</td><td>' . $message . '<td><button onclick="deleteit(' . $idckochat . ')">__LOCALIZATION_CHAT_ADMIN_DELETE__</button></td></tr>' . "\n";
}
}
$chatadm = $chatadm . '</table>';
$localized = localize($chatadm);
return $localized;
}
//END OF FUNCTIONS
//CHAT AUTO PURGE
if ( (!empty($_GET['delete'])&&!empty($_POST['delete'])) || (!empty($_GET['chat'])) || (!empty($_GET['onlychattable']))){
$stmt20 = $mysqli->prepare("DELETE FROM Chat WHERE Timestamp < (CURRENT_TIMESTAMP - 86400);");
$stmt20->execute();
$stmt20->store_result();
}
//API CALLS START
if (!empty($_GET['setLang'])){
$language = htmlspecialchars($_GET['setLang']);
$lang_dir = "templates/locale";
$langs = scandir($lang_dir);
$lang_file = "";
foreach($langs as $lang){
if ($lang == $language . '.json'){
$lang2 = str_replace(".json", "", $lang);
$_SESSION['language'] = htmlspecialchars($lang2);
}
}
exit();
}
if (!empty($_GET['keepalive'])){
$kod = htmlspecialchars($_SESSION['kod']);
$stmt6 = $mysqli->prepare("Select ID FROM Streams WHERE Code = ? OR AdminCode = ?;");
$stmt6->bind_param('ss', $kod, $kod);
$stmt6->execute();
$stmt6->store_result();
if ($stmt6->num_rows > 0)
{
while($stmt6->fetch()){
$stmt7 = $mysqli->prepare("UPDATE Connections SET TimestampPing=CURRENT_TIMESTAMP, TimePing = ? WHERE PHPSessID = ?;");
$currsessid = session_id();
$stmt7->bind_param("ss", date("Y.n.d H:i:s"), $currsessid);
$stmt7->execute();
$stmt7->store_result();
}
}
exit();
}
if (!empty($_GET['logout']))
{
$stmt3 = $mysqli->prepare("DELETE FROM Connections WHERE PHPSessID = ?;");
$stmt3->bind_param("s", session_id());
$currsessid = session_id();
$stmt3->bind_param("s", $currsessid);
$stmt3->execute();
$stmt3->store_result();
$_SESSION["kod"] = '';
@@ -153,17 +168,14 @@ if (!empty($_GET['logout']))
session_destroy();
session_unset();
setcookie("inicialy", "", 1);
echo '
<script>
window.location.href = "index.php";
</script>
';
echo file_get_contents("templates/redirect.html");
exit();
}
if (!empty($_GET['verify'])&&!empty($_POST['kod'])){
if ($_GET['verify'] == 1){
if(strlen($_POST['kod']) <= 20){
$kod = $_POST['kod'];
$kod = htmlspecialchars($_POST['kod']);
$stmt5 = $mysqli->prepare("Select ID FROM Streams WHERE AdminCode = ?;");
$stmt5->bind_param('s', $kod);
$stmt5->execute();
@@ -198,27 +210,11 @@ if (!empty($_GET['verify'])&&!empty($_POST['kod'])){
}
exit();
}
if (!empty($_GET['keepalive'])){
$kod = $_SESSION['kod'];
$stmt6 = $mysqli->prepare("Select ID FROM Streams WHERE Code = ? OR AdminCode = ?;");
$stmt6->bind_param('ss', $kod, $kod);
$stmt6->execute();
$stmt6->store_result();
if ($stmt6->num_rows > 0)
{
while($stmt6->fetch()){
$stmt7 = $mysqli->prepare("UPDATE Connections SET TimestampPing=CURRENT_TIMESTAMP, TimePing = ? WHERE PHPSessID = ?;");
$stmt7->bind_param("ss", date("Y.n.d H:i:s"), session_id());
$stmt7->execute();
$stmt7->store_result();
}
}
exit();
}
if (!empty($_GET['chat'])){
if (!empty($_SESSION["kod"]) && !empty($_SESSION['listeners']) && !empty($_SESSION['inicialy']))
{
$kod = $_SESSION['kod'];
$kod = htmlspecialchars($_SESSION['kod']);
$stmt8 = $mysqli->prepare("Select ID FROM Streams WHERE Code = ? OR AdminCode = ?;");
$stmt8->bind_param('ss', $kod, $kod);
$stmt8->bind_result($idcko);
@@ -229,7 +225,9 @@ if (!empty($_GET['chat'])){
if (!empty($_GET['send'])&& !empty($_POST['text'])){
if (strlen($_POST['text']) <= 1024){
$stmt9 = $mysqli->prepare("INSERT INTO Chat (Author, Message, StreamID) VALUES (?, ?, ?);");
$stmt9->bind_param('ssi', $_SESSION['inicialy'], $_POST['text'], $idcko);
$messagetext = htmlspecialchars($_POST['text']);
$inicialy = htmlspecialchars($_SESSION['inicialy']);
$stmt9->bind_param('ssi', $inicialy, $messagetext, $idcko);
$stmt9->execute();
$stmt9->store_result();
}
@@ -246,7 +244,7 @@ if (!empty($_GET['chat'])){
$data = $data . '• ' . $author . ' on ' . $tmstmp . ' GMT said: ' . $msg . "\n";
}
}
echo $data;
echo localize($data);
}
}
@@ -254,9 +252,11 @@ if (!empty($_GET['chat'])){
}
exit();
}
//LOGIN HANDLING
if (!empty($_POST['kod']) && !empty($_POST['listeners']) && !empty($_POST['ini'])){
if(strlen($_POST['kod']) <= 20 && strlen($_POST['ini']) <= 100 && intval($_POST['listeners']) <= 999 && intval($_POST['listeners']) >= 1){
$kod = $_POST['kod'];
if(strlen($_POST['kod']) <= 20 && strlen($_POST['ini']) <= 100 && intval(htmlspecialchars($_POST['listeners'])) <= 999 && intval(htmlspecialchars($_POST['listeners'])) >= 1){
$kod = htmlspecialchars($_POST['kod']);
$stmt11 = $mysqli->prepare("Select ID FROM Streams WHERE Code = ? OR AdminCode = ?;");
$stmt11->bind_param('ss', $kod, $kod);
$stmt11->bind_result($idcko);
@@ -265,23 +265,24 @@ if (!empty($_POST['kod']) && !empty($_POST['listeners']) && !empty($_POST['ini']
if ($stmt11->num_rows > 0)
{
while ($stmt11->fetch()){
$listeners = intval($_POST['listeners']);
$inicialy = $_POST['ini'];
$_SESSION["kod"] = $kod;
$_SESSION['listeners'] = $listeners;
$_SESSION['inicialy'] = $inicialy;
$listeners = intval(htmlspecialchars($_POST['listeners']));
$inicialy = htmlspecialchars($_POST['ini']);
$_SESSION["kod"] = htmlspecialchars($kod);
$_SESSION['listeners'] = htmlspecialchars($listeners);
$_SESSION['inicialy'] = htmlspecialchars($inicialy);
if (empty($_SESSION['language'])){
$_SESSION['language'] = "en";
}
setcookie("inicialy", $inicialy);
$stmt12 = $mysqli->prepare("INSERT INTO Connections (PHPSessID, TimeConnect, TimestampPing, TimePing, Listeners, Inicialy, IP, StreamID) VALUES (?, ?, CURRENT_TIMESTAMP, ?, ?, ?, ?, ?);");
$stmt12->bind_param('sssissi', session_id(), date("Y.n.d H:i:s"), date("Y.n.d H:i:s"), $listeners, $inicialy, $ipcka, $idcko);
$currsessid = session_id();
$stmt12->bind_param('sssissi', $currsessid, date("Y.n.d H:i:s"), date("Y.n.d H:i:s"), $listeners, $inicialy, $ipcka, $idcko);
$stmt12->execute();
$stmt12->store_result();
echo '
<script>
location.reload();
</script>
';
echo file_get_contents("templates/reload.html");
exit();
}
}
else
@@ -289,18 +290,110 @@ if (!empty($_POST['kod']) && !empty($_POST['listeners']) && !empty($_POST['ini']
$_SESSION["kod"] = '';
$_SESSION['listeners'] = '';
$_SESSION['inicialy'] = '';
echo '
<script>
location.reload();
</script>
';
echo file_get_contents("templates/reload.html");
session_destroy();
exit();
}
}
exit();
}
//END API CALLS
//START SPECIAL PAGES
if (!empty($_GET["adder"])){
$datasendadder = "";
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$heslo = trim($_POST['heslo']);
if (password_verify($heslo, file_get_contents("secrets/AdminPwdHash"))) {
$kod = htmlspecialchars($_POST['kod']);
$url = htmlspecialchars($_POST['url']);
$type = htmlspecialchars($_POST['type']);
$adminpwd = htmlspecialchars($_POST['adminpwd']);
if(!empty($kod) && !empty($url) && !empty($type) && !empty($adminpwd)){
if(strlen($kod) <= 20 && strlen($url) <= 256 && strlen($type) <= 20 && strlen($adminpwd) <= 20){
$stmt2 = $mysqli->prepare("SELECT ID FROM Streams WHERE Code=? OR AdminCode=?");
$stmt2->bind_param('ss', $kod, $adminpwd);
$stmt2->execute();
$stmt2->store_result();
if ($stmt2->num_rows > 0) {
$datasendadder = $datasendadder . "__LOCALIZATION_ADDER_EXISTS_LABEL__";
} else {
$stmt = $mysqli->prepare("INSERT INTO Streams (URL, Type, AdminCode, Code) VALUES (?, ?, ?, ?);");
$stmt->bind_param('ssss', $url, $type, $adminpwd, $kod);
$stmt->execute();
$stmt->store_result();
$datasendadder = $datasendadder . "__LOCALIZATION_ADDER_SUCCESS_LABEL__";
}
}
}
} else {
$datasendadder = $datasendadder . "__LOCALIZATION_ADDER_PASSWORD_LABEL__";
}
}
$datasendadder = $datasendadder . file_get_contents("templates/streamadd.html");
echo localize($datasendadder);
exit();
}
if (!empty($_GET["admin"])){
if (!empty($_SESSION["kod"]) && !empty($_SESSION['listeners']) && !empty($_SESSION["inicialy"]))
{
$kod = htmlspecialchars($_SESSION['kod']);
$stmt = $mysqli->prepare("Select ID, URL, Type, Code FROM Streams WHERE AdminCode = ?;");
$stmt->bind_param('s', $kod);
$stmt->bind_result($idcko, $url, $type, $code);
$stmt->execute();
$stmt->store_result();
if ($stmt->num_rows > 0){
while ($stmt->fetch())
{
if (!empty($_GET['deletechatmsg'])&&!empty($_POST['deletechatmsg'])){
if(htmlspecialchars($_POST['deletechatmsg']) == "*"){
$stmt5 = $mysqli->prepare("DELETE from Chat WHERE StreamID = ?;");
$stmt5->bind_param('i', $idcko);
$stmt5->execute();
$stmt5->store_result();
}
else{
$deleteid = intval(htmlspecialchars($_POST['deletechatmsg']));
if ($deleteid >= 0){
$stmt6 = $mysqli->prepare("DELETE from Chat WHERE StreamID = ? AND ID = ?;");
$stmt6->bind_param('ii', $idcko, $deleteid);
$stmt6->execute();
$stmt6->store_result();
}
}
}
if (!empty($_GET['admin_dash_api'])){
$connadm = connectionAdminTable($idcko);
$chatadm = chatAdminTable($idcko);
$myobjcko = array("connadm"=>$connadm, "chatadm"=>$chatadm);
echo json_encode($myobjcko);
}
else{
$dats = file_get_contents("templates/admin.html");
$dats = str_replace('__VLOZ_URL_AUDIA__', $config->url , $dats);
$dats = str_replace('__VLOZ_TYP_AUDIA__', $config->type , $dats);
echo localize($dats);
}
}
}
else{
echo file_get_contents("templates/redirect.html");
exit();
}
exit();
}
}
//END SPECIAL PAGES
//MAIN PLAYER
if (!empty($_SESSION['listeners']) && !empty($_SESSION['inicialy']) && !empty($_SESSION['kod'])){
$kod = $_SESSION['kod'];
$kod = htmlspecialchars($_SESSION['kod']);
$stmt13 = $mysqli->prepare("Select ID, URL, Type, AdminCode, Code FROM Streams WHERE Code = ? OR AdminCode = ?;");
$stmt13->bind_param('ss', $kod, $kod);
$stmt13->bind_result($idcko, $url, $type, $admincode, $code);
@@ -313,18 +406,17 @@ if (!empty($_SESSION['listeners']) && !empty($_SESSION['inicialy']) && !empty($_
$player = file_get_contents("templates/player.html");
$player = str_replace('__VLOZ_URL_AUDIA__', $url , $player);
$player = str_replace('__VLOZ_TYP_AUDIA__', $type , $player);
$player = str_replace('__VLOZ_ROK__', $year, $player);
if($_SESSION["kod"] == $admincode){
$player = str_replace('__VLOZ_ADMIN_LINK__', '<a href="index.php?admin=1">Administrácia</a>', $player);
$player = str_replace('__VLOZ_ADMIN_LINK__', '<a href="index.php?admin=1">__LOCALIZATION_ADMIN_LINK__</a>', $player);
}
else{
$player = str_replace('__VLOZ_ADMIN_LINK__', "" , $player);
}
echo($player);
echo localize($player);
}
}
}
else{
echo str_replace("__VLOZ_ROK__", date("Y"), file_get_contents("templates/login.html"));
echo localize(file_get_contents("templates/login.html"));
}
?>

View File

@@ -3,6 +3,7 @@
<head>
<script src=assets/jquery.js> </script>
<script>
__LOCALIZATION_LANGSELECT_SCRIPT__
function deleteit(indexik){
$.post("index.php?admin=1&delete=1",
{
@@ -20,20 +21,15 @@
Ping();
setInterval(function(){ Ping(); }, 60000);
function updateTable(){
$.get("index.php?admin=1&onlytable=1", function(data, status){
$("#chattablicka").html(data);
function updateDashboard(){
$.get("index.php?admin=1&admin_dash_api=1", function(data, status){
var parsedData = JSON.parse(data);
$("#chattablicka").html(parsedData.chatadm);
$("#connections").html(parsedData.connadm);
});
}
setInterval(updateTable, 5000);
updateTable();
function updateConns(){
$.get("index.php?admin=1&onlyconns=1", function(data, status){
$("#connections").html(data);
});
}
setInterval(updateConns, 30000);
updateConns();
setInterval(updateDashboard, 5000);
updateDashboard();
$("#send").click(function(){
data = $("#ins").val();
@@ -57,7 +53,7 @@
</script>
<meta charset="UTF-8">
<link rel="stylesheet" href="assets/pico.css">
<title>Administration</title>
<title>__LOCALIZATION_ADMIN_LINK__</title>
<style>
table, th, td {
border: 2px solid;
@@ -69,28 +65,29 @@
</style>
</head>
<body>
<p class="headingac">Streaming</p>
__LOCALIZATION_LANGSELECT__
<p class="headingac">__LOCALIZATION_PLAYER_TITLE__</p>
<audio controls src="__VLOZ_URL_AUDIA__" id="audioplayer" type="__VLOZ_TYP_AUDIA__" preload="none"></audio>
<br>
<a href="index.php?logout=1">
<p>Log out</p>
<p>__LOCALIZATION_LOGOUT__</p>
</a>
<a href="__VLOZ_URL_AUDIA__.m3u" download target="_blank">
<p>Playlist download</p>
<p>__LOCALIZATION_PLAYLIST_DOWNLOAD__</p>
</a>
<a href="index.php">
<p>Normal player</p>
<p>__LOCALIZATION_NORMAL_LINK__</p>
</a>
<p class="headingac">Connections:</p>
<p class="headingac">__LOCALIZATION_CONNECTIONS__</p>
<div id="connections"></div>
<br>
<p class="headingac">Chat admin:</p>
<button onclick="deleteit('*')">Delete all</button>
<p class="headingac">__LOCALIZATION_CHAT_ADMIN__</p>
<button onclick="deleteit('*')">__LOCALIZATION_CHAT_ADMIN_DELETE_ALL__</button>
<br>
<div id="chattablicka"></div><br>
<input id="ins"></input>
<button id="send">Send</button>
<button id="send">__LOCALIZATION_CHAT_SEND__</button>
<br>
<p>© BRN Systems __VLOZ_ROK__</p>
</body>

View File

@@ -0,0 +1,5 @@
function SetLang(lang) {
$.get("index.php?setLang=" + lang, function(data, status){
location.reload();
});
}

53
templates/locale/en.json Normal file
View File

@@ -0,0 +1,53 @@
{
"__LOCALIZATION_LANG_SHORT": "en",
"__LOCALIZATION_LANG_LONG": "English",
"__LOCALIZATION_LOGOUT__": "Log out",
"__LOCALIZATION_PLAYLIST_DOWNLOAD__": "Playlist download",
"__LOCALIZATION_PLAYER_TITLE__": "Streaming",
"__LOCALIZATION_CHAT_SENDING__": "Sending",
"__LOCALIZATION_CHAT_SEND__": "Send",
"__LOCALIZATION_CHAT_PLACEHOLDER__": "Chat message",
"__LOCALIZATION_LOGIN_TITLE__": "Login",
"__LOCALIZATION_LOGIN_ERROR__": "Bad code",
"__LOCALIZATION_LOGIN_CODE_LABEL__": "Code:",
"__LOCALIZATION_LOGIN_NEXT__": "Next",
"__LOCALIZATION_LOGIN_LISTENERS_LABEL__": "Listeners count:",
"__LOCALIZATION_LOGIN_INITIALS_LABEL__": "Initials:",
"__LOCALIZATION_LOGIN_LOGIN__": "Login",
"__LOCALIZATION_LOGIN_BACK__": "Back",
"__LOCALIZATION_ADMIN_LINK__": "Administration",
"__LOCALIZATION_NORMAL_LINK__": "Normal player",
"__LOCALIZATION_CONNECTIONS__": "Connections:",
"__LOCALIZATION_CHAT_ADMIN__": "Chat admin:",
"__LOCALIZATION_CHAT_AUTHOR_ADMIN__": "Author:",
"__LOCALIZATION_CHAT_DATE_ADMIN__": "Date:",
"__LOCALIZATION_CHAT_MESSAGE_ADMIN__": "Message:",
"__LOCALIZATION_CHAT_ADMIN_DELETE_ALL__": "Delete all chat messages",
"__LOCALIZATION_CHAT_ADMIN_DELETE__": "Delete",
"__LOCALIZATION_CHAT_ADMIN_DELETE_HEAD__": "Delete:",
"__LOCALIZATION_CONNECTIONS_DATETIME_CONNECT_ADMIN__": "Date and time of connection",
"__LOCALIZATION_CONNECTIONS_DATETIME_PING_ADMIN__": "Date and time of keepalive",
"__LOCALIZATION_CONNECTIONS_IP_ADMIN__": "IP address",
"__LOCALIZATION_ADDER_ADDRESS_LABEL__": "Audio address:",
"__LOCALIZATION_ADDER_TYPE_LABEL__": "Audio type:",
"__LOCALIZATION_ADDER_CODE_LABEL__": "Code:",
"__LOCALIZATION_ADDER_ADMIN_PWD_LABEL__": "Stream administration password:",
"__LOCALIZATION_ADDER_WEBMASTER_PWD_LABEL__": "Webmaster password:",
"__LOCALIZATION_ADDER_WEBMASTER_ADD_LABEL__": "Add stream",
"__LOCALIZATION_ADDER_TITLE_LABEL__": "Stream adder",
"__LOCALIZATION_ADDER_SUCCESS_LABEL__": "Stream added!",
"__LOCALIZATION_ADDER_EXISTS_LABEL__": "Stream exists!",
"__LOCALIZATION_ADDER_PASSWORD_LABEL__": "Bad password!",
"__LOCALIZATION_ADDER_MP3_LABEL__": "MP3",
"__LOCALIZATION_ADDER_OGG_LABEL__": "OGG"
}

53
templates/locale/sk.json Normal file
View File

@@ -0,0 +1,53 @@
{
"__LOCALIZATION_LANG_SHORT": "sk",
"__LOCALIZATION_LANG_LONG": "Slovenčina",
"__LOCALIZATION_LOGOUT__": "Odhlásiť sa",
"__LOCALIZATION_PLAYLIST_DOWNLOAD__": "Stiahnunť playlist",
"__LOCALIZATION_PLAYER_TITLE__": "Streaming",
"__LOCALIZATION_CHAT_SENDING__": "Odosielam",
"__LOCALIZATION_CHAT_SEND__": "Odoslať",
"__LOCALIZATION_CHAT_PLACEHOLDER__": "Správa",
"__LOCALIZATION_LOGIN_TITLE__": "Prihlásenie",
"__LOCALIZATION_LOGIN_ERROR__": "Zlý kód",
"__LOCALIZATION_LOGIN_CODE_LABEL__": "Kód:",
"__LOCALIZATION_LOGIN_NEXT__": "Ďalej",
"__LOCALIZATION_LOGIN_LISTENERS_LABEL__": "Počet poslucháčov:",
"__LOCALIZATION_LOGIN_INITIALS_LABEL__": "Iniciály:",
"__LOCALIZATION_LOGIN_LOGIN__": "Prihlásenie",
"__LOCALIZATION_LOGIN_BACK__": "Späť",
"__LOCALIZATION_ADMIN_LINK__": "Administrácia",
"__LOCALIZATION_NORMAL_LINK__": "Normálny prehrávač",
"__LOCALIZATION_CONNECTIONS__": "Pripojenia:",
"__LOCALIZATION_CHAT_ADMIN__": "Administrácia chatu:",
"__LOCALIZATION_CHAT_AUTHOR_ADMIN__": "Autor:",
"__LOCALIZATION_CHAT_DATE_ADMIN__": "Dátum:",
"__LOCALIZATION_CHAT_MESSAGE_ADMIN__": "Správa:",
"__LOCALIZATION_CHAT_ADMIN_DELETE_ALL__": "Zmazať všetky správy",
"__LOCALIZATION_CHAT_ADMIN_DELETE__": "Zmazať",
"__LOCALIZATION_CHAT_ADMIN_DELETE_HEAD__": "Zmazanie:",
"__LOCALIZATION_CONNECTIONS_DATETIME_CONNECT_ADMIN__": "Dátum a čas pripojenia",
"__LOCALIZATION_CONNECTIONS_DATETIME_PING_ADMIN__": "Dátum a čas keepalive",
"__LOCALIZATION_CONNECTIONS_IP_ADMIN__": "IP adresa",
"__LOCALIZATION_ADDER_ADDRESS_LABEL__": "Adresa zvuku:",
"__LOCALIZATION_ADDER_TYPE_LABEL__": "Typ zvuku:",
"__LOCALIZATION_ADDER_CODE_LABEL__": "Kód:",
"__LOCALIZATION_ADDER_ADMIN_PWD_LABEL__": "Heslo administrácie streamu:",
"__LOCALIZATION_ADDER_WEBMASTER_PWD_LABEL__": "Heslo webmastera:",
"__LOCALIZATION_ADDER_WEBMASTER_ADD_LABEL__": "Pridať stream",
"__LOCALIZATION_ADDER_TITLE_LABEL__": "Pridávanie streamu",
"__LOCALIZATION_ADDER_SUCCESS_LABEL__": "Stream pridaný!",
"__LOCALIZATION_ADDER_EXISTS_LABEL__": "Stream existuje!",
"__LOCALIZATION_ADDER_PASSWORD_LABEL__": "Zlé heslo!",
"__LOCALIZATION_ADDER_MP3_LABEL__": "MP3",
"__LOCALIZATION_ADDER_OGG_LABEL__": "OGG"
}

View File

@@ -1,10 +1,9 @@
<!DOCTYPE html>
<html data-theme="dark">
<head>
<title>Prihlásenie</title>
<title>__LOCALIZATION_LOGIN_TITLE__</title>
<link rel="stylesheet" href="assets/pico.css">
<meta charset="utf-8">
</meta>
<meta charset="utf-8"></meta>
<script src="assets/jquery.js"></script>
<style>
#error{
@@ -16,6 +15,7 @@
}
</style>
<script>
__LOCALIZATION_LANGSELECT_SCRIPT__
$(function() {
$("#kod").focus();
var kod = "";
@@ -92,24 +92,25 @@
</script>
</head>
<body>
__LOCALIZATION_LANGSELECT__
<form method="post">
<div id="firstQuestion">
<p id="error">Zlý kód</p>
<label id="kodik" for="kod">Kód:<br></label>
<input type="text" id="kod" placeholder="Kód" name="kod" required>
<p id="error">__LOCALIZATION_LOGIN_ERROR__</p>
<label id="kodik" for="kod">__LOCALIZATION_LOGIN_CODE_LABEL__<br></label>
<input type="text" id="kod" placeholder="__LOCALIZATION_LOGIN_CODE_LABEL__" name="kod" required>
<br>
<button id="next" type="button">Ďalej</button>
<button id="next" type="button">__LOCALIZATION_LOGIN_NEXT__</button>
<br>
<p>© BRN Systems __VLOZ_ROK__</p>
</div>
<div id="secondQuestion" style="display: none;">
<label for="ini">Iniciály:<br></label>
<input type="text" id="ini" placeholder="Iniciály" name="ini" required autofocus>
<label for="ini">__LOCALIZATION_LOGIN_INITIALS_LABEL__<br></label>
<input type="text" id="ini" placeholder="__LOCALIZATION_LOGIN_INITIALS_LABEL__" name="ini" required autofocus>
<br>
<label for="listeners">Počet počúvajúcich:<br></label>
<input type="text" id="listeners" placeholder="Počet počúvajúcich" name="listeners" required>
<label for="listeners">__LOCALIZATION_LOGIN_LISTENERS_LABEL__<br></label>
<input type="text" id="listeners" placeholder="__LOCALIZATION_LOGIN_LISTENERS_LABEL__" name="listeners" required>
<br>
<button id="send" type="button">Prihlásiť sa</button><button id="back" type="button">Späť</button>
<button id="send" type="button">__LOCALIZATION_LOGIN_LOGIN__</button><button id="back" type="button">__LOCALIZATION_LOGIN_BACK__</button>
<br>
<p>© BRN Systems __VLOZ_ROK__</p>
</div>

View File

@@ -4,8 +4,9 @@
<script src=assets/jquery.js> </script>
<meta charset="UTF-8">
<link rel="stylesheet" href="assets/pico.css">
<title>Streaming</title>
<title>__LOCALIZATION_PLAYER_TITLE__</title>
<script>
__LOCALIZATION_LANGSELECT_SCRIPT__
function getCookie(cname) {
let name = cname + "=";
let decodedCookie = decodeURIComponent(document.cookie);
@@ -50,7 +51,7 @@
},
function(data2, status){
var chatmsgs = $("#chatbox").val();
chatmsgs = chatmsgs + '• ' + 'Sending' + "\n";
chatmsgs = chatmsgs + '• ' + '__LOCALIZATION_CHAT_SENDING__' + "\n";
$("#chatbox").val(chatmsgs);
});
}
@@ -71,20 +72,21 @@
</style>
</head>
<body>
<p class="headingac">Streaming</p>
__LOCALIZATION_LANGSELECT__
<p class="headingac">__LOCALIZATION_PLAYER_TITLE__</p>
<audio controls src="__VLOZ_URL_AUDIA__" id="audioplayer" type="__VLOZ_TYP_AUDIA__" preload="none"></audio>
<br>
<a href="index.php?logout=1">
<p>Log out</p>
<p>__LOCALIZATION_LOGOUT__</p>
</a>
<a href="__VLOZ_URL_AUDIA__.m3u" download target="_blank">
<p>Playlist download</p>
<p>__LOCALIZATION_PLAYLIST_DOWNLOAD__</p>
</a>
__VLOZ_ADMIN_LINK__
<div id="chat">
<textarea rows=5 id="chatbox" readonly></textarea><br>
<input id="ins"></input>
<button id="send">Send</button>
<input id="ins" placeholder="__LOCALIZATION_CHAT_PLACEHOLDER__"></input>
<button id="send">__LOCALIZATION_CHAT_SEND__</button>
</div>
<p>© BRN Systems __VLOZ_ROK__</p>
</body>

3
templates/redirect.html Normal file
View File

@@ -0,0 +1,3 @@
<script>
window.location.href = "index.php";
</script>

3
templates/reload.html Normal file
View File

@@ -0,0 +1,3 @@
<script>
location.reload();
</script>

View File

@@ -2,28 +2,32 @@
<html data-theme="dark">
<head>
<script src=assets/jquery.js> </script>
<script>
__LOCALIZATION_LANGSELECT_SCRIPT__
</script>
<meta charset="UTF-8">
<link rel="stylesheet" href="assets/pico.css">
<title>Stream add</title>
<title>__LOCALIZATION_ADDER_TITLE_LABEL__</title>
<body>
__LOCALIZATION_LANGSELECT__
<form method="post">
Code:<br>
__LOCALIZATION_ADDER_CODE_LABEL__<br>
<input type="text" name="kod">
<br>
Audio address:<br>
__LOCALIZATION_ADDER_ADDRESS_LABEL__<br>
<input type="text" name="url">
<br>
Audio type:<br>
<input type="radio" name="type" value="audio/mpeg">mp3
<input type="radio" name="type" value="audio/ogg">ogg
__LOCALIZATION_ADDER_TYPE_LABEL__<br>
<input type="radio" name="type" value="audio/mpeg">__LOCALIZATION_ADDER_MP3_LABEL__</input>
<input type="radio" name="type" value="audio/ogg">__LOCALIZATION_ADDER_OGG_LABEL__</input>
<br>
<br>
Stream administration password:<br>
__LOCALIZATION_ADDER_ADMIN_PWD_LABEL__<br>
<input type="text" name="adminpwd">
Webmaster password:<br>
__LOCALIZATION_ADDER_WEBMASTER_PWD_LABEL__<br>
<input type="text" name="heslo">
<br>
<input type="submit" value="Add">
<input type="submit" value="__LOCALIZATION_ADDER_WEBMASTER_ADD_LABEL__">
<br>
<p>© BRN Systems __VLOZ_ROK__</p>
</form>