ajaxRadio/index.php

224 lines
6.4 KiB
PHP
Raw Permalink Normal View History

2017-11-09 21:57:09 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>Theresianum Radio</title>
<script>
window.onload = function(){setInterval(function(){loadXMLDoc()}, 100); };
function loadXMLDoc()
{
var xmlhttp;
// for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
var response = xmlhttp.responseXML;
time=response.getElementsByTagName("update")[0].firstChild.nodeValue;
command=response.getElementsByTagName("command")[0].firstChild.nodeValue;
deck1=response.getElementsByTagName("deck1")[0].firstChild.nodeValue;
deck2=response.getElementsByTagName("deck2")[0].firstChild.nodeValue;
deck3=response.getElementsByTagName("deck3")[0].firstChild.nodeValue;
playmode=response.getElementsByTagName("playmode")[0].firstChild.nodeValue;
if(time != document.getElementById('update').innerHTML){
var mediaElement = document.getElementById("player");
if(command == "play1")
{
mediaElement.src='http://radio.lbsfilm.at/Audio1.mp3';
if(playmode=="loop")mediaElement.loop=true;
else mediaElement.loop=false;
mediaElement.play();
document.getElementById('state').innerHTML="Playing! (1)";
document.getElementById('sName').innerHTML=deck1;
document.getElementById('playmode').innerHTML=playmode;
}
else if(command == "play2")
{
mediaElement.src='http://radio.lbsfilm.at/Audio2.mp3';
if(playmode=="loop")mediaElement.loop=true;
else mediaElement.loop=false;
mediaElement.play();
document.getElementById('state').innerHTML="Playing! (2)";
document.getElementById('sName').innerHTML=deck2;
document.getElementById('playmode').innerHTML=playmode;
}
else if(command == "play3")
{
mediaElement.src='http://radio.lbsfilm.at/Audio3.mp3';
if(playmode=="loop")mediaElement.loop=true;
else mediaElement.loop=false;
mediaElement.play();
document.getElementById('state').innerHTML="Playing! (3)";
document.getElementById('sName').innerHTML=deck3;
document.getElementById('playmode').innerHTML=playmode;
}
else if(command == "stop")
{
mediaElement.pause();
mediaElement.src='';
document.getElementById('state').innerHTML="Stopped.";
document.getElementById('sName').innerHTML="/";
document.getElementById('playmode').innerHTML="/";
}
document.getElementById('update').innerHTML=time;
}
}
}
/*Fuck you cache!!!!!*/
xmlhttp.open("GET","control.xml?t=" + Math.random(),true);
xmlhttp.send();
}
</script>
</head>
<body>
<center>
<h1>Theresianum Radio</h1>
<h3>by <a href="lbsfilm.at">lbsfilm.at</a></h3>
<audio id="player" src="" type="audio/mpeg" loop></audio>
<br>
<br>
<b>Status:</b>
<div id="state">updating...</div>
<b>Song Name:</b>
<div id="sName">updating...</div>
<b>After Song:</b>
<div id="playmode">updating...</div>
<b>UpdateNumber:</b>
<div id="update">updating...</div>
<?php if(!isset($_POST['pass'])){ ?>
<input id="djbutton" value="I am the DJ!" type="button" onClick="document.getElementById('login').style.display='inline';document.getElementById('djbutton').style.display='none';">
<br>
<div id="login" style="display:none;">
So you're the DJ? Prove it! :P
<form method="POST">
<input type="text" name="pass">
<input type="submit" value="Check my Skills!">
</form>
</div>
<?php } else {
$xml=simplexml_load_file("control.xml");
if($_POST['pass'] == 'niemehrschule')
{
if(isset($_POST['command'])){
/*rewrite the controls!!! */
$xml->update = rand();
$xml->command = $_POST["command"];
$xml->playmode = $_POST["playmode"];
$xml->asXml('control.xml');
}
?>
<br>
Hi DJ!
<br>
<?php
if(isset($_POST['upload'])){
if ($_FILES["file"]["error"] > 0) {
echo "Error: " . $_FILES["file"]["error"] . "<br>";
} else {
echo "Upload: " . $_FILES["file"]["name"] . "<br>";
if($_FILES["file"]["type"]== "audio/mpeg"){
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
$xml=simplexml_load_file("control.xml");
if($_POST['upload'] == "Upload into Deck 1"){
move_uploaded_file($_FILES["file"]["tmp_name"],
"Audio1.mp3");
$xml->deck1 = $_FILES["file"]["name"];
}
else if($_POST['upload'] == "Upload into Deck 2"){
move_uploaded_file($_FILES["file"]["tmp_name"],
"Audio2.mp3");
$xml->deck2 = $_FILES["file"]["name"];
}
else {
move_uploaded_file($_FILES["file"]["tmp_name"],
"Audio3.mp3");
$xml->deck3 = $_FILES["file"]["name"];
}
$xml->asXml('control.xml');
}
else
{
echo "I said it must be an mp3!!!!!!!!!";
}
}
}
?>
<br>
<br>
Loaded Tracks:<br>
<form method="POST" action="">
<input type="hidden" name="pass" value="<?php echo $_POST['pass'];?>" >
Deck1:
<?php echo $xml->deck1; ?>
<input id="play1B" type="submit" name="command" value="play1" type="button">
<br>
Deck2:
<?php echo $xml->deck2; ?>
<input id="play2B" type="submit" name="command" value="play2" type="button">
<br>
Deck3:
<?php echo $xml->deck3; ?>
<input id="play3B" type="submit" name="command" value="play3" type="button">
<br>
<br>
What to do after the song played?
<br>
<input type="radio" name="playmode" value="loop" checked> Play Again<br>
<input type="radio" name="playmode" value="stop"> Stop it!<br>
<br>
<input id="stopB" type="submit" name="command" value="stop" type="button">
</form>
<br>
Please just hit the buttons once (there might be a delay of up to 15 seconds...)
<br>
<br>
Get some good music from <a target="_blank" href="http://www.youtube.com/">youtube</a> and <a target="_blank" href="http://www.youtube-mp3.org/">download it!</a>
<br>
<br>
Load new files (this can take up to 2 minutes):
<form method="POST" action="" enctype="multipart/form-data">
<input type="hidden" name="pass" value="<?php echo $_POST['pass'];?>" >
<label for="file">Filename(must be an mp3):</label>
<input type="file" name="file" id="file"><br>
<input type="submit" name="upload" value="Upload into Deck 1">
<input type="submit" name="upload" value="Upload into Deck 2">
<input type="submit" name="upload" value="Upload into Deck 3">
</form>
<br>
<br>
<a href="http://radio.lbsfilm.at">Logout</a>
<br>
<?php }else { ?>
Wrong Password What are you even doing here? <a href="http://radio.lbsfilm.at"> Get off!!!!! </a>
<?php }}?>
</center>
</body>
</html>