<html>
<head>
<link rel="stylesheet" type="text/css" href="xml/basic.css" />
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
</head>
<body>

<?php

include 'globals.php';



		
if ($_GET['user']<>''){
	$usr=$_GET['user'];
	}

if ($_GET['week']<>''){
	$week=$_GET['week'];
	}
	
if (($usr=='NoUser') or ($usr=='')){
	echo "<div id=pInput>You don't appear to be logged into BeeX. Please log in then try again</div>";
	}
else{
	$tmpusr = str_replace('_',' ',$usr);
	echo("<div id=pInput><b>Welcome, $tmpusr. </b><br/>");
	

	$users = simplexml_load_file('xml/users.xml');

	$getuserquery="//users/$usr/*";
	$usernodes=$users->xpath($getuserquery);
	if (count($usernodes)==0){
		echo("You don't appear to be playing Song Wars. That was silly of you, wasn't it?");
		}
	elseif ($usernodes[1]==0){
		echo("You appear to have been knocked out. You should have better taste in music");
		}
	else{
		$group = $usernodes[0];
		$tmp = (intval($group))-1;		
		$themeArr = explode(',',$_GET[theme]);			
		if ($themeArr[$tmp]<>"0"){
				
			$theme="The theme for this week is $themeArr[$tmp]<br/><br/>";
			}
		else {
			$theme="";
		}
		
		$song = simplexml_load_file('xml/songs.xml');
		$getsongquery="//data/week$week/$usr/*";
		$usersong=$song->xpath($getsongquery);
			
		echo('<form action="songwars.php" method="post">');
		
		if (count($usersong)<>0){
			
			echo("This is your song for week $week. You can edit any of the data below.<br/><br/>");
			echo("$theme");
			if ($usersong[0]==1) {
				echo("<label style='display:block;float:left;width: 150px;'>Type:</label><select name=type id='opt'><option value=1 selected='selected'>Youtube</option><option value=2>Uploader</option></select><br/>");
				echo("<span id=urlInput1 style='font-size:14px'>Please enter the code short code from the youtube URL - such as in red here:<br/></span>");
				echo("<span id=urlInput2 style='font-size:14px'>http://www.youtube.com/watch?v=<font color=red>akA-B64RACU</font>&feature=g-vrec<br/></span>");
				echo("<span id=urlInput3><label style='display: block;float: left;width: 150px;'>Youtube Code:</label><input type=text value='$usersong[1]' name=code id=codeval size=60></input><br/></span>");
				echo("<label style='display: block;float: left;width: 150px;'>Title:</label><input type=text size=60 value='$usersong[2]' name=title id=title></input><br/>");
				echo("<label style='display: block;float: left;width: 150px;'>Artist:</label><input type=text size=60 value='$usersong[3]' name=artist id=artist></input><br/>");
				echo("<input type=hidden value=$week name=week></input>");
				echo("<input type=hidden value=$usr name=user></input>");
				echo("<input type=hidden value=$group name=group></input>");
				echo("<br/>");
				$submitVal='Update';
				echo "<input type=submit value=Update id='sub'></input></form><br/><br/>";
				
				echo("<div id='pInput2' style='display:none'>");

				echo("<form method='post' action='playa/upload.php' name='uploadform' target='invisibleUpload' enctype='multipart/form-data' id='playaFrm'>");
				echo("<input type='hidden' name='MAX_FILE_SIZE' value='59999999' />");
				echo("<input type='file' name='file' />");
				echo("<br /><br />");
				echo("<input type='button' value='Upload me!' onclick='this.disabled=true;this.form.submit()'/>");
				echo("</div>");
				echo("<iframe id='invisibleUpload' style='display:none' name='invisibleUpload'></iframe>");
				echo("<div id='uPlayer' style='text-align:center'>");
				echo ("<object width='425' height='350'>");
				echo ("<param name='movie' value=http://www.youtube.com/v/$usersong[1] />");
				echo ("<param name='wmode' value='transparent' />");
				echo ("<embed src=http://www.youtube.com/v/$usersong[1] type='application/x-shockwave-flash' wmode='transparent' width='425' height='350' id='dummy'/></object>");
			echo("</div>");
				}

			else {
			
				echo("<label style='display:block;float:left;width: 150px;'>Type:</label><select name=type id='opt'><option value=1>Youtube</option><option value=2 selected='selected'>Uploader</option></select><br/>");
				

			echo("<span id=urlInput1 style='display:none' style='font-size:14px'>Please enter the code short code from the youtube URL - such as in red here:<br/></span>");
			echo("<span id=urlInput2 style='display:none' style='font-size:14px'>http://www.youtube.com/watch?v=<font color=red>akA-B64RACU</font>&feature=g-vrec<br/></span>");
			echo("<span id=urlInput3 style='display:none'><label style='display:block;float:left;width: 150px;'>Youtube Code:</label><input type=text value='$usersong[1]' name=code id=codeval size=60></input><br/></span>");
			echo("<label style='display: block;float: left;width: 150px;'>Title:</label><input type=text size=60 value='$usersong[2]' name=title id=title></input><br/>");
			echo("<label style='display: block;float: left;width: 150px;'>Artist:</label><input type=text size=60 value='$usersong[3]' name=artist id=artist></input><br/>");
			echo("<input type=hidden value=$week name=week></input>");
			echo("<input type=hidden value=$usr name=user></input>");
			echo("<input type=hidden value=$group name=group></input>");
			echo("<br/>");
			$submitVal='Update';
			echo "<input type=submit value=Update id='sub'></input></form><br/><br/>";			
			echo("<div id='pInput2' style='display:none'>");

			echo("<form method='post' action='playa/upload.php' name='uploadform' target='invisibleUpload' enctype='multipart/form-data' id='playaFrm'>");
			echo("<input type='hidden' name='MAX_FILE_SIZE' value='59999999' />");
			echo("<input type='file' name='file' />");
			echo("<br /><br />");
			echo("<input type='button' value='Upload me!' onclick='this.disabled=true;this.form.submit()'/>");
			echo("</div>");
			echo("<iframe id='invisibleUpload' style='display:none' name='invisibleUpload'></iframe>");
			
			echo("<div id='showPlayer' style='text-align:center'>")	;		
			echo("<div id='container'><a href='http://www.macromedia.com/go/getflashplayer'>Get the Flash Player</a> to see this player.</div>");
			echo("<script type='text/javascript' src='playa/swfobject.js'></script>");
			echo("<script type='text/javascript'>");
    			echo("var s1 = new SWFObject('player.swf','ply','328','200','9','#FFFFFF');");
    			echo("s1.addParam('allowfullscreen','true');");
    			echo("s1.addParam('allowscriptaccess','always');");
    			echo("s1.addParam('flashvars','file=http://www.beexcellenttoeachother.com/songwars/playa/mp3/$usersong[1]&image=http://beexcellenttoeachother.com/songwars/playa/preview.jpg');");
    			echo("s1.write('container');");
			echo("</script>");
			echo("</div>");
							
					
			}
			}
		else{
			echo("You do not yet have a song entered for week $week. Enter details below<br/><br/>");


			echo("$theme");
			echo("<label style='display:block;float:left;width: 150px;'>Type:</label><select name=type id='opt'><option value=1>Youtube</option><option value=2>Uploader</option></select><br/>");
			
					

			echo("<span id=urlInput1 style='font-size:14px'>Please enter the code short code from the youtube URL - such as in red here:<br/></span>");
			echo("<span id=urlInput2 style='font-size:14px'>http://www.youtube.com/watch?v=<font color=red>akA-B64RACU</font>&feature=g-vrec<br/></span>");
				
			echo("<span id=urlInput3><label style='display:block;float:left;width: 150px;'>Youtube Code:</label><input type=text value='$usersong[1]' name=code id=codeval size=60></input><br/></span>");	
			echo("<label style='display:block;float:left;width: 150px;'>Title:</label><input type=text size=60 name=title id=title></input><br/>");
			echo("<label style='display:block;float:left;width: 150px;'>Artist:</label><input type=text size=60 name=artist id=artist></input><br/>");
			echo("<input type=hidden value=$week name=week></input>");
			echo("<input type=hidden value=$usr name=user></input>");
			echo("<input type=hidden value=$group name=group></input>");
			
			$submitVal='Submit';
			echo "<input type=submit value=Submit id='sub'></input>";
			echo("</form>")	;
			echo("<div id='pInput2' style='display:none'>");
			echo("<label style='font-size:14px'>Please choose file to upload, hit upload, then wait for the file to transfer</label><br/>");
			echo("<label style='font-size:14px'>When complete, please check title and artist and amend as necessary before submitting</label><br/>");
			echo("<form method='post' action='playa/upload.php' name='uploadform' target='invisibleUpload' enctype='multipart/form-data' id='playaFrm'>");
			echo("<input type='hidden' name='MAX_FILE_SIZE' value='59999999' />");
			echo("<input type='file' name='file' />");
			echo("<br /><br />");
			echo("<input type='button' value='Upload me!' onclick='this.disabled=true;this.form.submit()'/>");
			echo("</div>");
			echo("<iframe id='invisibleUpload' style='display:none' name='invisibleUpload'></iframe>");
			
			
			
			
			}
			
		}
	
	
	}







	?>




</div>
<script type="text/javascript"> 
    document.getElementById('pInput2').style.display = 'none'; 
</script> 

</body>
</html>