<?php session_start();
function Make_XML_Playlist($name){
$text = '<?xml version="1.0" encoding="UTF-8"?>';
$text .= "\n".'<playlist version="1" xmlns = "http://xspf.org/ns/0/">';
$text .= "\n\t".'<trackList>';
$verz2 = opendir('mp3/'.$name);
while ($file = readdir($verz2)) {
if($file!="." && $file!=".." && $file !=""){
$title = str_replace(".mp3","",$file);
$text .= "\n\t\t".'<track>';
$text .= "\n\t\t\t".'<location>mp3/'.$name.'/'.$file.'</location>';
$text .= "\n\t\t\t".'<title>'.$title.'</title>';
$text .= "\n\t\t".'</track>';
}
}
closedir($verz2);
$text .= "\n\t".'</trackList>';
$text .= "\n".'</playlist>';
$filename = 'playlist/'.$name.".xml";
$fp = fopen ($filename,"w+");
fwrite($fp,$text);
fclose($fp);
}
function Load_Playlist($name){
$file=array();
$verz2 = opendir('mp3/'.$name);
while ($file = readdir($verz2)) {
if($file!="." && $file!=".." && $file !=""){
$list[] = $file;
}
}
closedir($verz2);
return $list;
}
function check_nutzer() {
if (isset($_POST["username"])) {
if (!isset($_SESSION["versuch"])) {
$_SESSION["versuch"]=1;
} else {
$_SESSION["versuch"]++;
}
if (!isset($_COOKIE[session_name()])) {
return false;
}
$nutzer = trim($_POST["username"]);
$pwd = trim($_POST["passwort"]);
if (strlen($nutzer)<3) {
return false;
}
if ($nutzer=='admin' && $pwd=='admin') {
$_SESSION["user"]=$nutzer;
$_SESSION["pass"]=$pwd;
return true;
} else {
return false;
}
}
if (isset($_GET["logout"])) {
$_SESSION["versuch"]=1;
session_unset();
session_destroy();
unset($_SESSION);
return false;
} else {
if (isset($_SESSION["user"]))
return true;
return false;
}
}
?>
<html>
<head>
<title>Irontom's Musikbox</title>
<script type="text/javascript" src="swfobject.js"></script>
<script>
function open_playlist(){
var adress = document.getElementById('player').value;
//alert(adress);
window.open("example_alien.php?player="+adress, "_self");
}
function open_download(){
var adress = 'mp3/'+document.getElementById('downname').innerHTML +'/'+ document.getElementById('downfile').value;
//alert(adress);
window.open(adress, "_blank");
}
</script>
</head>
<body style="background-color:transparent">
<?php
$verz = opendir('mp3');
$a=0;
while ($file = readdir($verz)) {
if($file!="." && $file!=".." && $file !=""){
$playlists[] = $file;
$a++;
}
}
closedir($verz);
sort($playlists);
for ($i = 0;$i<count($playlists);$i++) {
Make_XML_Playlist($playlists[$i]);
}
echo '<table><tr><td valign="top"><select id="player" onChange="open_playlist()" size="14">';
for ($i = 0;$i<count($playlists);$i++) {
if($i==0){
if(isset($_GET['player'])){
$name = $_GET['player'];
}else{
$name = $playlists[$i];
}
}
echo "<option value='".$playlists[$i]."'";
if ($name == $playlists[$i])echo " selected";
echo ">".$playlists[$i]."</option>";
}
echo '</select></td></tr></table>';
if($name!=''){
echo '<table><tr><td valign="top"><div id="flashcontent"></div></td><td valign="top">';
$downloadlist = Load_Playlist($name);
if(check_nutzer()){
echo '<font size="5"><b><u><span id="downname">'.$name.'</span></u></b></font> <a href="example_alien.php?logout" style="color:red;text-decoration:none;font-weight:bold">Logout</a><br />';
echo '<select size="12" id="downfile" onChange="open_download()">';
for($i=0;$i<count($downloadlist);$i++){
echo '<option><a href="mp3/'.$name.'/'.$downloadlist[$i].'">'.$downloadlist[$i].'</a></option>';
}
echo '</select>';
}else {
echo '<form method="post" action="example_alien.php" target="_self">
<br>
<table style="color:#000000">
<tr>
<td>Nutzer:</td>
<td><input type="text" name="username"></td>
</tr><tr>
<td>Passwort:</td>
<td><input type="password" name="passwort"></td>
</tr><tr>
<td colspan="2" align="center"><br><input type="submit" name="Submit" value="Login"></td>
</tr>
</table>
</form>';
}
echo '<td></tr></table></center><br /><br />';
echo '<script type="text/javascript">';
// <![CDATA[
echo 'var so = new SWFObject("ep_player.swf", "ep_player", "269", "230", "9", "#000000");
so.addVariable("skin", "skins/nobius_platinum/skin.xml");
so.addVariable("playlist", "playlist/'.$name.'.xml");
so.addVariable("autoplay", "false");
so.addVariable("shuffle", "false");
so.addVariable("repeat", "false");
so.addVariable("buffertime", "1");
so.addParam("allowscriptaccess", "always");
so.write("flashcontent");';
// ]]>
echo "</script>";
}
?>
</body>
</html>