<?php
include("config.php");
$my=str_replace("%20"," ",$_SERVER["REQUEST_URI"]);
$strcut=strstr($my, '=');
$ok=str_replace("=","",$strcut);

mysql_connect($dbloc, $dbuser, $dbpass);
mysql_select_db("$db");
$result = mysql_query("SELECT * FROM allgenres WHERE id = '$ok'"); 
if (!$result) {     
echo 'Could not run querysssssssssssssss: ' . mysql_error();     
exit; } 
$rowz = mysql_fetch_row($result); 
$views=$rowz['7']+1;
mysql_query("UPDATE allgenres SET downloads='$views' WHERE id= '$ok'");
echo '<title>'. $rowz['2']. ' - Melero Video</title>'; 
?>
<!-- Go to www.addthis.com/dashboard to customize your tools -->
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-5445a2bd018f3743" async></script>
<?php
include("headertop.php"); 
echo '<table align=center width=98%><td width=60% valign=top>
<P><table bgcolor=white align=center width=100%><td width=100% valign=top>
<center><br>
<object width="100%" height="400" data="http://releases.flowplayer.org/swf/flowplayer-3.1.5.swf" type="application/x-shockwave-flash">        
<param name="movie" value="http://releases.flowplayer.org/swf/flowplayer-3.1.5.swf" />        
<param name="allowfullscreen" value="true" />        
<param name="allowscriptaccess" value="always" />        
<param name="flashvars" value='. "'". 'config={"plugins":{"pseudo":{"url":"flowplayer.pseudostreaming-3.1.3.swf"},"controls":{"backgroundColor":"#000000","backgroundGradient":"low"}},"clip":{"provider":"pseudo","url":"songs/'. $rowz[6]. '"},"playlist":[{"provider":"pseudo","url":"songs/'. $rowz[6]. '"}]}'. "'". ' />   
</object>';
?>
</td></table>
<P>
<table bgcolor=white align=center width=100%><td width=100% valign=top>
<b><font size=4><?php echo $rowz['2']; ?></b><br>
By <?php echo $rowz[1]; ?></b> Published: <?php echo $rowz[4]; ?><P>
<P><?php echo $rowz[3]; ?></b><P>
<P><centeR>Views:<?php echo $rowz['7']; ?></b>
 <a href="#" onClick="opennewsletter(); return false">Add to Playlist</a> <span id="youremail" style="color: red"></span>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252"><link rel="stylesheet" href="windowfiles/dhtmlwindow.css" type="text/css" />
<script type="text/javascript" src="windowfiles/dhtmlwindow.js">
/***********************************************
* DHTML Window Widget- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
</script>
<link rel="stylesheet" href="modalfiles/modal.css" type="text/css" />
<script type="text/javascript" src="modalfiles/modal.js"></script>
</head>
<body>
<!-##################### 2) DHTML Modal Window Example 2: ###################-->
<script type="text/javascript">
function opennewsletter(){
	emailwindow=dhtmlmodal.open('EmailBox', 'iframe', 'playlistadd.php?=<?php echo $ok; ?> ', 'Add video to a Playlist', 'width=350px,height=400px,center=1,resize=0,scrolling=1')

emailwindow.onclose=function(){ //Define custom code to run when window is closed
	var theform=this.contentDoc.forms[0] //Access first form inside iframe just for your reference
	var theemail=this.contentDoc.getElementById("emailfield") //Access form field with id="emailfield" inside iframe
	if (theemail.value.indexOf("@")==-1){ //crude check for invalid email
		alert("Please enter a valid email address")
		return false //cancel closing of modal window
	}
	else{ //else if this is a valid email
		document.getElementById("youremail").innerHTML=theemail.value //Assign the email to a span on the page
		return true //allow closing of window
	}
}
} //End "opennewsletter" function
</script>

<!-- Go to www.addthis.com/dashboard to customize your tools -->
<div class="addthis_sharing_toolbox"></div>
<P><centeR><b><font size=4>Embed Code</b><br>
<input type=text size=70 value='<iframe src="<?php echo $site; ?>streamframe.php?=<?php echo $rowz["0"]; ?>" width=560 height=350></iframe>'>
</td>
</table>

</td>

<td width=40% valign=top bgcolor=white>
<?php
echo ' <bR>
<b><font size=4>Latest Videos</b>
<table bordercolor=white bgcolor=white width=99% align=center>';
/////////mySQL Connect////////////////
mysql_connect($dbloc, $dbuser, $dbpass);
mysql_select_db($db); 



$result = mysql_query("SELECT * FROM allgenres order by id desc limit 0, 15");
// keeps getting the next rowz until there are no more to get
$cols = 4; # Number of columns to display 
$colCtr = 0; 
while($rowz = mysql_fetch_array( $result )) {
echo '<script>
function openWin'. $rowz['id']. '()
{
window.open("stream.php?='. $rowz['id']. '","_blank");
}
</script>';
$sname = substr($rowz['vname'], 0, 50);
if($rowz['image']==''){
$rowz['image']='nophoto.png';
}
echo '<tR><td width=25% valign=top><a onclick="openWin'. $rowz['id']. '()"><img src="thumbs/'. $rowz['image']. '" width=160 height=90 alt="'. $sname. '" title="'. $sname. '"></td><td valign=top><font size=4><br><b>'. $sname. '</a></td>'; 
if($rowz['id']=15){ 
end($rowz);
}
$colCtr++; 
}
?>
</td></table></td></table>
<P><?php include("headerbottom.php"); 
?>
</body></html>