migrate to mysql
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,4 +1,2 @@
|
||||
secrets/*
|
||||
!secrets/.htaccess
|
||||
streamy/*
|
||||
!streamy/.htaccess
|
||||
!secrets/.htaccess
|
115
admin.php
115
admin.php
@ -1,115 +0,0 @@
|
||||
<?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>
|
||||
';
|
||||
}
|
||||
?>
|
334
index.php
334
index.php
@ -3,6 +3,7 @@ $cookieParams = session_get_cookie_params();
|
||||
$cookieParams['samesite'] = "Lax";
|
||||
session_set_cookie_params($cookieParams);
|
||||
session_start();
|
||||
$mysqli = new mysqli('localhost', 'streaming', file_get_contents("secrets/MySQLPWD"), 'streaming');
|
||||
|
||||
$ipcka = $_SERVER['REMOTE_ADDR'];
|
||||
|
||||
@ -16,29 +17,134 @@ foreach ($headers as $header => $value) {
|
||||
}
|
||||
}
|
||||
|
||||
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]);
|
||||
|
||||
$stmt2 = $mysqli->prepare("DELETE FROM Connections WHERE TimestampPing < (CURRENT_TIMESTAMP - 300);");
|
||||
$stmt2->execute();
|
||||
$stmt2->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";
|
||||
}
|
||||
}
|
||||
}
|
||||
file_put_contents($connsa, json_encode($connections));
|
||||
} 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;
|
||||
}
|
||||
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>' . date("d.m.Y H:i:s", $tmstmp) . ' 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
exit();
|
||||
}
|
||||
|
||||
if (!empty($_GET['logout']))
|
||||
{
|
||||
$connections = json_decode(file_get_contents($connsa), true);
|
||||
unset($connections[session_id()]);
|
||||
file_put_contents($connsa, json_encode($connections));
|
||||
$stmt3 = $mysqli->prepare("DELETE FROM Connections WHERE PHPSessID = ?;");
|
||||
$stmt3->bind_param("s", session_id());
|
||||
$stmt3->execute();
|
||||
$stmt3->store_result();
|
||||
$_SESSION["kod"] = '';
|
||||
$_SESSION["listeners"] = '';
|
||||
$_SESSION['inicialy'] = '';
|
||||
@ -50,87 +156,134 @@ if (!empty($_GET['logout']))
|
||||
window.location.href = "index.php";
|
||||
</script>
|
||||
';
|
||||
exit();
|
||||
}
|
||||
elseif (!empty($_GET['verify'])&&!empty($_POST['kod'])){
|
||||
if (!empty($_GET['verify'])&&!empty($_POST['kod'])){
|
||||
if ($_GET['verify'] == 1){
|
||||
$fol = 'streamy/' . $_POST['kod'] . '/';
|
||||
$configa = $fol . 'config.json';
|
||||
if (file_exists($configa))
|
||||
{
|
||||
echo "verified";
|
||||
if(strlen($_POST['kod']) <= 20){
|
||||
$kod = $_POST['kod'];
|
||||
$stmt5 = $mysqli->prepare("Select ID FROM Streams WHERE AdminCode = ?;");
|
||||
$stmt5->bind_param('s', $kod);
|
||||
$stmt5->execute();
|
||||
$stmt5->store_result();
|
||||
if ($stmt5->num_rows > 0)
|
||||
{
|
||||
while ($stmt5->fetch()){
|
||||
|
||||
}
|
||||
echo "admin";
|
||||
}
|
||||
else{
|
||||
$stmt4 = $mysqli->prepare("Select ID FROM Streams WHERE Code = ?;");
|
||||
$stmt4->bind_param('s', $kod);
|
||||
$stmt4->execute();
|
||||
$stmt4->store_result();
|
||||
if ($stmt4->num_rows > 0)
|
||||
{
|
||||
while ($stmt4->fetch()){
|
||||
|
||||
}
|
||||
echo "verified";
|
||||
}
|
||||
else{
|
||||
echo "unverified";
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
echo "unverified";
|
||||
}
|
||||
}
|
||||
exit();
|
||||
}
|
||||
elseif (!empty($_GET['keepalive'])){
|
||||
$connections = json_decode(file_get_contents($connsa), true);
|
||||
$connections[session_id()]["timestamp"] = time();
|
||||
$connections[session_id()]["dateping"] = date("Y.n.d H:i:s");
|
||||
file_put_contents($connsa, json_encode($connections));
|
||||
if (!empty($_GET['keepalive'])){
|
||||
$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)
|
||||
{
|
||||
$stmt7 = $mysqli->prepare("Update Connections SET TimestampPing=CURRENT_TIMESTAMP, TimePing = ? FROM WHERE StreamID = ?;");
|
||||
$stmt7->bind_param("si", date("Y.n.d H:i:s"), $streamidcko);
|
||||
$stmt7->execute();
|
||||
$stmt7->store_result();
|
||||
}
|
||||
exit();
|
||||
}
|
||||
elseif (!empty($_GET['chat'])){
|
||||
if (!empty($_GET['chat'])){
|
||||
if (!empty($_SESSION["kod"]) && !empty($_SESSION['listeners']) && !empty($_SESSION['inicialy']))
|
||||
{
|
||||
$kod = $_SESSION['kod'];
|
||||
$fol = 'streamy/' . $kod . '/';
|
||||
$chata = $fol . 'chat.txt';
|
||||
|
||||
if (file_exists($chata))
|
||||
{
|
||||
if (!empty($_GET['send'])){
|
||||
$data = '• ' . $_SESSION['inicialy'] . ':' . $_POST['text'] . "\n";
|
||||
file_put_contents($chata, $data, FILE_APPEND);
|
||||
}
|
||||
else{
|
||||
echo file_get_contents($chata);
|
||||
$stmt8 = $mysqli->prepare("Select ID FROM Streams WHERE Code = ? OR AdminCode = ?;");
|
||||
$stmt8->bind_param('ss', $kod, $kod);
|
||||
$stmt8->bind_result($idcko);
|
||||
$stmt8->execute();
|
||||
$stmt8->store_result();
|
||||
if ($stmt8->num_rows > 0){
|
||||
while ($stmt8->fetch()){
|
||||
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);
|
||||
$stmt9->execute();
|
||||
$stmt9->store_result();
|
||||
}
|
||||
}
|
||||
else{
|
||||
$stmt10 = $mysqli->prepare("Select Author, Message, Timestamp FROM Chat WHERE StreamID = ?;");
|
||||
$stmt10->bind_param('i', $idcko);
|
||||
$stmt10->execute();
|
||||
$stmt10->store_result();
|
||||
$stmt10->bind_result($author, $msg, $tmstmp);
|
||||
$data = "";
|
||||
if ($stmt10->num_rows() > 0) {
|
||||
while ($stmt10->fetch()){
|
||||
$data = $data . '• ' . $author . ' on ' . date("d.m.Y H:i:s", intval($tmstmp)) . ' GMT said: ' . $msg . "\n";
|
||||
}
|
||||
}
|
||||
echo $data;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
exit();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!empty($_POST['kod']) && !empty($_POST['listeners']) && !empty($_POST['ini'])){
|
||||
|
||||
$fol = 'streamy/' . $_POST['kod'] . '/';
|
||||
$configa = $fol . 'config.json';
|
||||
$ida = $fol . 'id.txt';
|
||||
$connsa = $fol . 'people.json';
|
||||
if (file_exists($configa))
|
||||
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'];
|
||||
$stmt11 = $mysqli->prepare("Select ID FROM Streams WHERE Code = ? OR AdminCode = ?;");
|
||||
$stmt11->bind_param('ss', $kod, $kod);
|
||||
$stmt11->bind_result($idcko);
|
||||
$stmt11->execute();
|
||||
$stmt11->store_result();
|
||||
if ($stmt11->num_rows > 0)
|
||||
{
|
||||
$jsonobj = file_get_contents($configa);
|
||||
$config = json_decode($jsonobj, false);
|
||||
while ($stmt11->fetch()){
|
||||
$listeners = intval($_POST['listeners']);
|
||||
$inicialy = $_POST['ini'];
|
||||
$_SESSION["kod"] = $kod;
|
||||
$_SESSION['listeners'] = $listeners;
|
||||
$_SESSION['inicialy'] = $inicialy;
|
||||
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);
|
||||
$stmt12->execute();
|
||||
$stmt12->store_result();
|
||||
|
||||
$inicialy = str_replace($config->adminpwd, "admin", $_POST['ini']);
|
||||
|
||||
$_SESSION["kod"] = $_POST['kod'];
|
||||
$_SESSION['listeners'] = $_POST['listeners'];
|
||||
$_SESSION["inicialyOriginal"] = $_POST['ini'];
|
||||
$_SESSION['inicialy'] = $inicialy;
|
||||
setcookie("inicialy", $inicialy);
|
||||
|
||||
$connections = json_decode(file_get_contents($connsa), true);
|
||||
$temparray = array("dateping"=>date("Y.n.d H:i:s"), "date"=>date("Y.n.d H:i:s"), "timestamp"=>time(), "listeners"=>$_SESSION['listeners'], "inicialy"=>$_SESSION['inicialy'], "ip"=>$ipcka);
|
||||
$connections[session_id()] = $temparray;
|
||||
file_put_contents($connsa, json_encode($connections));
|
||||
|
||||
$data = 'OK: ' . date("Y.n.d H:i:s") . "," . $_POST['listeners'] . "," . $inicialy . "," . $ipcka . "\n";
|
||||
file_put_contents($fol . 'log.txt', $data, FILE_APPEND);
|
||||
echo '
|
||||
<script>
|
||||
location.reload();
|
||||
</script>
|
||||
';
|
||||
echo '
|
||||
<script>
|
||||
location.reload();
|
||||
</script>
|
||||
';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$data = 'ERR: ' . date("Y.n.d H:i:s") . "," . $_POST['listeners'] . "," . $_POST['ini'] . "," . $ipcka . "\n";
|
||||
file_put_contents($fol . 'log.txt', $data, FILE_APPEND);
|
||||
$_SESSION["kod"] = '';
|
||||
$_SESSION['listeners'] = '';
|
||||
$_SESSION['inicialy'] = '';
|
||||
$_SESSION["id"] = 0;
|
||||
echo '
|
||||
<script>
|
||||
location.reload();
|
||||
@ -139,28 +292,25 @@ else
|
||||
session_destroy();
|
||||
}
|
||||
}
|
||||
elseif (!empty($_SESSION['listeners']) && !empty($_SESSION['inicialy']) && !empty($_SESSION['kod'])){
|
||||
$fol = 'streamy/' . $_SESSION['kod'] . '/';
|
||||
$configa = $fol . 'config.json';
|
||||
$ida = $fol . 'id.txt';
|
||||
if (file_exists($configa))
|
||||
{
|
||||
$jsonobj = file_get_contents($configa);
|
||||
$config = json_decode($jsonobj, false);
|
||||
|
||||
$kod = $_SESSION['kod'];
|
||||
$fol = 'streamy/' . $kod . '/';
|
||||
|
||||
$url = $config->url;
|
||||
$type = $config->type;
|
||||
exit();
|
||||
}
|
||||
if (!empty($_SESSION['listeners']) && !empty($_SESSION['inicialy']) && !empty($_SESSION['kod'])){
|
||||
$kod = $_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);
|
||||
$stmt13->execute();
|
||||
$stmt13->store_result();
|
||||
if ($stmt13->num_rows > 0){
|
||||
while ($stmt13->fetch()){
|
||||
$year = date("Y");
|
||||
|
||||
$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["inicialyOriginal"] == $config->adminpwd){
|
||||
$player = str_replace('__VLOZ_ADMIN_LINK__', '<a href="admin.php">Administrácia</a>', $player);
|
||||
if($_SESSION["kod"] == $admincode){
|
||||
$player = str_replace('__VLOZ_ADMIN_LINK__', '<a href="index.php?admin=1">Administrácia</a>', $player);
|
||||
}
|
||||
else{
|
||||
$player = str_replace('__VLOZ_ADMIN_LINK__', "" , $player);
|
||||
@ -168,8 +318,8 @@ else
|
||||
echo($player);
|
||||
}
|
||||
}
|
||||
else{
|
||||
echo str_replace("__VLOZ_ROK__", date("Y"), file_get_contents("templates/login.html"));
|
||||
}
|
||||
}
|
||||
else{
|
||||
echo str_replace("__VLOZ_ROK__", date("Y"), file_get_contents("templates/login.html"));
|
||||
}
|
||||
?>
|
@ -1,35 +0,0 @@
|
||||
<?php
|
||||
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'];
|
||||
$fol = 'streamy/' . $kod . '/';
|
||||
$address1 = $fol . 'config.json';
|
||||
$address2 = $fol . 'chat.txt';
|
||||
$address3 = $fol . 'people.json';
|
||||
$address4 = $fol . 'id.txt';
|
||||
if (file_exists($address1)) {
|
||||
echo ("Stream existuje!");
|
||||
} else {
|
||||
mkdir($fol);
|
||||
$myObj = array(
|
||||
"url" => $url,
|
||||
"type" => $type,
|
||||
"adminpwd" => $adminpwd
|
||||
);
|
||||
$myJson = json_encode($myObj);
|
||||
file_put_contents($address1, $myJson);
|
||||
file_put_contents($address2, '');
|
||||
file_put_contents($address3, "{}");
|
||||
file_put_contents($address4, "1");
|
||||
echo "Stream pridaný";
|
||||
}
|
||||
} else {
|
||||
echo "Zlé heslo.";
|
||||
}
|
||||
}
|
||||
echo str_replace("__VLOZ_ROK__", date("Y"), file_get_contents("templates/streamadd.html"));
|
||||
?>
|
@ -1 +0,0 @@
|
||||
Deny from all
|
@ -1,10 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<html data-theme="dark">
|
||||
<head>
|
||||
<script src=assets/jquery.js> </script>
|
||||
<script>
|
||||
function deleteit(indexik){
|
||||
$.post("admin.php?delete=1",
|
||||
$.post("index.php?admin=1&delete=1",
|
||||
{
|
||||
delete: indexik
|
||||
},
|
||||
@ -14,21 +14,21 @@
|
||||
}
|
||||
$(function() {
|
||||
function Ping() {
|
||||
$.get("index.php?keepalive=1", function(data, status){
|
||||
$.get("index.php?admin=1&keepalive=1", function(data, status){
|
||||
});
|
||||
}
|
||||
|
||||
Ping();
|
||||
setInterval(function(){ Ping(); }, 60000);
|
||||
function updateTable(){
|
||||
$.get("admin.php?onlytable=1", function(data, status){
|
||||
$.get("index.php?admin=1&onlytable=1", function(data, status){
|
||||
$("#chattablicka").html(data);
|
||||
});
|
||||
}
|
||||
setInterval(updateTable, 5000);
|
||||
updateTable();
|
||||
function updateConns(){
|
||||
$.get("admin.php?onlyconns=1", function(data, status){
|
||||
$.get("index.php?admin=1&onlyconns=1", function(data, status){
|
||||
$("#connections").html(data);
|
||||
});
|
||||
}
|
||||
@ -57,7 +57,7 @@
|
||||
</script>
|
||||
<meta charset="UTF-8">
|
||||
<link rel="stylesheet" href="assets/pico.css">
|
||||
<title>Administrácia</title>
|
||||
<title>Administration</title>
|
||||
<style>
|
||||
table, th, td {
|
||||
border: 2px solid;
|
||||
@ -69,28 +69,28 @@
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<p class="headingac">Vysielanie</p>
|
||||
<p class="headingac">Streaming</p>
|
||||
<audio controls src="__VLOZ_URL_AUDIA__" id="audioplayer" type="__VLOZ_TYP_AUDIA__" preload="none"></audio>
|
||||
<br>
|
||||
<a href="index.php?logout=1">
|
||||
<p>Odhlásiť sa</p>
|
||||
<p>Log out</p>
|
||||
</a>
|
||||
<a href="__VLOZ_URL_AUDIA__.m3u" download target="_blank">
|
||||
<p>Playlist na stiahnutie</p>
|
||||
<p>Playlist download</p>
|
||||
</a>
|
||||
<a href="index.php">
|
||||
<p>Obyčajný prehrávač</p>
|
||||
<p>Normal player</p>
|
||||
</a>
|
||||
<p class="headingac">Pripojenia:</p>
|
||||
<p class="headingac">Connections:</p>
|
||||
<div id="connections"></div>
|
||||
<br>
|
||||
<p class="headingac">Chat admin:</p>
|
||||
<button onclick="deleteit('*')">Zmazať všetko</button>
|
||||
<button onclick="deleteit('*')">Delete all</button>
|
||||
<br>
|
||||
<div id="chattablicka"></div><br>
|
||||
|
||||
<input id="ins"></input>
|
||||
<button id="send">Odoslať</button>
|
||||
<button id="send">Send</button>
|
||||
<br>
|
||||
<p>© BRN Systems __VLOZ_ROK__</p>
|
||||
</body>
|
||||
|
@ -37,6 +37,17 @@
|
||||
});
|
||||
|
||||
}
|
||||
else if(data == "admin"){
|
||||
$.post("index.php",
|
||||
{
|
||||
kod: kod,
|
||||
listeners: 1,
|
||||
ini: "admin"
|
||||
},
|
||||
function(data, status){
|
||||
location.reload();
|
||||
});
|
||||
}
|
||||
else{
|
||||
$("#error").fadeIn();
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
<script src=assets/jquery.js> </script>
|
||||
<meta charset="UTF-8">
|
||||
<link rel="stylesheet" href="assets/pico.css">
|
||||
<title>Vysielanie</title>
|
||||
<title>Streaming</title>
|
||||
<script>
|
||||
function getCookie(cname) {
|
||||
let name = cname + "=";
|
||||
@ -50,7 +50,7 @@
|
||||
},
|
||||
function(data2, status){
|
||||
var chatmsgs = $("#chatbox").val();
|
||||
chatmsgs = chatmsgs + '• ' + getCookie("inicialy") + ':' + data + "\n";
|
||||
chatmsgs = chatmsgs + '• ' + 'Sending' + "\n";
|
||||
$("#chatbox").val(chatmsgs);
|
||||
});
|
||||
}
|
||||
@ -71,20 +71,20 @@
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<p class="headingac">Vysielanie</p>
|
||||
<p class="headingac">Streaming</p>
|
||||
<audio controls src="__VLOZ_URL_AUDIA__" id="audioplayer" type="__VLOZ_TYP_AUDIA__" preload="none"></audio>
|
||||
<br>
|
||||
<a href="index.php?logout=1">
|
||||
<p>Odhlásiť sa</p>
|
||||
<p>Log out</p>
|
||||
</a>
|
||||
<a href="__VLOZ_URL_AUDIA__.m3u" download target="_blank">
|
||||
<p>Playlist na stiahnutie</p>
|
||||
<p>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">Odoslať</button>
|
||||
<button id="send">Send</button>
|
||||
</div>
|
||||
<p>© BRN Systems __VLOZ_ROK__</p>
|
||||
</body>
|
||||
|
@ -4,26 +4,26 @@
|
||||
<script src=assets/jquery.js> </script>
|
||||
<meta charset="UTF-8">
|
||||
<link rel="stylesheet" href="assets/pico.css">
|
||||
<title>Pridanie streamu</title>
|
||||
<title>Stream add</title>
|
||||
<body>
|
||||
<form method="post">
|
||||
Kód:<br>
|
||||
Code:<br>
|
||||
<input type="text" name="kod">
|
||||
<br>
|
||||
Adresa zvuku:<br>
|
||||
Audio address:<br>
|
||||
<input type="text" name="url">
|
||||
<br>
|
||||
Typ zvuku:<br>
|
||||
Audio type:<br>
|
||||
<input type="radio" name="type" value="audio/mpeg">mp3
|
||||
<input type="radio" name="type" value="audio/ogg">ogg
|
||||
<br>
|
||||
<br>
|
||||
Administračné heslo streamu:<br>
|
||||
Stream administration password:<br>
|
||||
<input type="text" name="adminpwd">
|
||||
Heslo prevádzkovateľa:<br>
|
||||
Webmaster password:<br>
|
||||
<input type="text" name="heslo">
|
||||
<br>
|
||||
<input type="submit" value="pridať">
|
||||
<input type="submit" value="Add">
|
||||
<br>
|
||||
<p>© BRN Systems __VLOZ_ROK__</p>
|
||||
</form>
|
||||
|
Reference in New Issue
Block a user