<?php require("check.php"); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
<title>Administratoriaus prisijungimas</title>
<link href="stilius.css" rel="stylesheet" type="text/css" />

<?php
	require("configas.php");
	global $dbhost, $dbuname, $dbpass, $dbname; 
	mysql_connect($dbhost, $dbuname, $dbpass); 

	mysql_query("SET NAMES utf8");
	@mysql_select_db($dbname) or die ("Unable to select database !"); 
?>
</head>
<body>


<table id="pagr" align="center">
	<tr valign="top">
		<td class="meniu">
			<table class="meniu2" width="200px">
				<?php require("meniu.php"); ?>
			</table>			
		</td>
		<td class="turinys">
			<table border="0" class="turinys2">
				<tr>
					<td class="t1">Dainos esan&#269;ios grotuve</td>
				</tr>
				<tr>
					<td class="t2" align="center">
					<form  action="<? echo $php_self ?>" method="post" enctype="multipart/form-data">
						<table class="lentele">
						<?php
						$id=$_GET["id"];
						if ($id==NULL && $name==NULL){
						rodyti();
						}else{
						delete($id);
						}
						function rodyti(){
							$uzklausa = "SELECT * FROM flamplayer_musics ORDER BY title_music";
							$rezultatas = mysql_query($uzklausa) or die(mysql_error());
							while ($eilute = mysql_fetch_array($rezultatas)){
							echo "<tr><td width='300px'>".$eilute['title_music']."</td>";
							echo "<td><a href='mgalerija.php?id=".$eilute['id_music']."' class='busena'><img src='images/stop.png' border='0'/></a></td></tr>";
							}
						}
						function delete($id){
							$uzklausa2 = "SELECT filename_music FROM flamplayer_musics WHERE id_music='$id'";
							$rezultatas2 = mysql_query($uzklausa2) or die(mysql_error());
							$eilute = mysql_fetch_array($rezultatas2);
							$failas = $eilute['filename_music'];
							$myFile = "../mp3/".$failas;
							unlink($myFile);
							
							$uzklausa = "DELETE FROM flamplayer_musics WHERE id_music='$id'";
							$rezultatas = mysql_query($uzklausa) or die(mysql_error());
							rodyti();
						}
						?>
						</table>
					</form>
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>

</body>
</html>