<?php


session_start();
include("include/config.php");
include("include/functions/import.php");
$thebaseurl = $config['baseurl'];

$mainmenu = "1";
STemplate::assign('mainmenu',$mainmenu);

if ($_SESSION[USERID] != "" && $_SESSION[USERID] >= 0 && is_numeric($_SESSION[USERID]))
{
	// Verify valid video
	if (is_numeric($_REQUEST[videoid]))
	{
		$videoid = $_REQUEST[videoid];
		STemplate::assign('videoid',$videoid);
	}
	else
	{
		$error = "$lang[568]";
	}

	if ($error == "")
	{
		if (does_video_exist($videoid))
		{
		$query = "SELECT * FROM videos WHERE VIDEOID='".mysql_real_escape_string($videoid)."'";
       	$executequery = $conn->execute($query);
       	$videoarray = $executequery->getarray();
		STemplate::assign('videoarray',$videoarray);
		$videouserid = $videoarray[0][USERID];
		
		STemplate::assign('pagetitle',"$lang[669] ".$videoarray[0][title]." $lang[668]");		
			$USERID = $videoarray[0][USERID];
			STemplate::assign('USERID',$USERID);
			$VIDEOID = $videoarray[0][VIDEOID];
			STemplate::assign('VIDEOID',$VIDEOID);

			$showtheme = "sharevideo.tpl";
		}	
		else
		{
			$error = "$lang[570]";
		}
	}
}
else
{
	header("Location:$config[baseurl]/login.php");exit;
}
//TEMPLATES BEGIN
STemplate::assign('error',$error);
STemplate::assign('message',$message);

STemplate::display('header.tpl');
if ($error == "")
{
	STemplate::display($showtheme);
}
else
{
	STemplate::display('playvideoerror.tpl');
}
STemplate::display('footer.tpl');
//TEMPLATES END
?>