<?php
session_start();
?>
<html>
<head>
<title>Tracklist</title>
</head>
<body>
<?php
// Wenn der Charts-Button geklickt wird, Daten in DB eintragen.
if (isset($_POST['submit'])){
$time = new DateTime();
$userid = $_SESSION['userid'];
include("config3.php");
$sqlinsertcharts = "INSERT INTO charts
(
interpret, title, userid, time
) VALUES (
'". mysql_escape_string($interpret) ."',
'". mysql_escape_string($title) ."',
'". mysql_escape_string($userid) ."',
'". mysql_escape_string($time) ."'
)";
// SQL-Anweisung an die DB schicken
$resultinsertcharts = mysql_query($sqlinsertcharts,$db) or die (mysql_error());
// Wenn kein Fehler aufgetreten ist, die Tracklist aktualisieren.
echo "<meta http-equiv='refresh' content='0; url=index.php?site=tracklist'>";
}
include("config3.php");
// Daten aus Datenbank abholen und absteigend nach id sortieren.
$sql = "SELECT
day,
month,
year,
time,
remix,
sendung,
von,
interpret,
title
FROM
tracklist
ORDER BY id DESC";
$result = mysql_query($sql,$db);
while ($row = mysql_fetch_object($result)) {
$day = $row->day;
$month = $row->month;
$year = $row->year;
$time = $row->time;
$remix = $row->remix;
$sendung = $row->sendung;
$von = $row->von;
$interpret = $row->interpret;
$title = $row->title;
if($_SESSION['loggedIn'] === true){
include("config3.php");
// Daten aus Datenbank abholen.
$sqlcharts = "SELECT
id,
interpret,
title,
userid
FROM
charts
WHERE
interpret = '".$interpret."'
AND
title = '".$title."'
AND
userid = '".$_SESSION['userid']."'";
$resultcharts = mysql_query($sqlcharts,$db);
}
if( mysql_num_rows($resultcharts) == 0 ){
echo "<form action=".$_SERVER['PHP_SELF']." method=\"post\">";
}
echo "<table border=\"0\" width=\"500\" cellspacing=\"0\" cellpadding=\"0\">
<tr valign=\"top\" width=\"500\" height=\"30\" style=\"background-image: url(images/bg_top.jpg); background-repeat:non repeat;\">
<td height=\"30\" valign=\"middle\"><font face=\"Arial\" color=\"#FFFFFF\" size=\"-1\"> <b>$interpret</b> - $title</font></td>
</tr>
</table>
<table border=\"0\" width=\"500\" cellspacing=\"0\" cellpadding=\"0\">
<tr valign=\"top\" width=\"500\" style=\"background-image: url(images/bg_middle.jpg); background-repeat:non repeat;\">
<td><font face=\"Arial\" color=\"#333333\" size=\"-1\"> <i>$time Uhr Gespielt von $von ($day.$month.$year)</i></font></td>
</tr>
<tr valign=\"top\" width=\"500\" style=\"background-image: url(images/bg_middle.jpg); background-repeat:non repeat;\">
<td><font face=\"Arial\" color=\"#333333\" size=\"-1\"> <b>Remix:</b> $remix</font></td>
</tr>
<tr valign=\"top\" width=\"500\" style=\"background-image: url(images/bg_middle.jpg); background-repeat:non repeat;\">
<td><font face=\"Arial\" color=\"#333333\" size=\"-1\"> <b>Sendung:</b> $sendung</font></td>
</tr>
<tr valign=\"middle\" width=\"500\" height=\"35\" style=\"background-image: url(images/bg_middle.jpg); background-repeat:non repeat;\">
<td>";
if( mysql_num_rows($resultcharts) == 0 ){
echo "<input type=\"submit\" name=\"submit\" value=\"Charts\">";
}
echo" </td>
</tr>
<tr valign=\"top\" width=\"500\" height=\"5\" style=\"background-image: url(images/bg_bottom.jpg); background-repeat:non repeat;\">
<td></td>
</tr>
</table>";
if( mysql_num_rows($resultcharts) == 0 ){
echo "</form>";
}
}
?>
</body>
</html>