<?php
// +------------------------------------------------------------------------+
// | PHP Melody version 1.6.7 ( www.phpsugar.com )
// +------------------------------------------------------------------------+
// | PHP Melody IS NOT FREE SOFTWARE
// | If you have downloaded this software from a website other
// | than www.phpsugar.com or if you have received
// | this software from someone who is not a representative of
// | phpSugar, you are involved in an illegal activity.
// | ---
// | In such case, please contact: support@phpsugar.com.
// +------------------------------------------------------------------------+
// | Developed by: phpSugar (www.phpsugar.com) / support@phpsugar.com
// | Copyright: (c) 2004-2011 PhpSugar.com. All rights reserved.
// +------------------------------------------------------------------------+


session_start();
require('config.php');
require_once('include/functions.php');

$uniq_id = trim($_GET['vid']);

if(strlen($uniq_id) < 10 && strlen($uniq_id) > 5)
{
	if(!ctype_alnum($uniq_id))
		die("Invalid video ID");
	else
		$uniq_id = secure_sql($uniq_id);
}
else
{
	die("Invalid video ID");
}

$social = secure_sql($_GET['social']);

$query = @mysql_query("SELECT uniq_id, artist, video_title, restricted FROM pm_videos WHERE uniq_id = '".$uniq_id."'"); 
$result = @mysql_fetch_array($query);
if(!$query || !is_array($result))
{
	die("An error occured!");
}

if ($result['restricted'] == '1')
{
	$code = $lang['share_msg8'];
}
else if($social == 'hi5' || $social == 'myspace') 
{
	$code = generate_embed_code($result['uniq_id']);
}
elseif($social == 'other') 
{
	$code = "[URL=".makevideolink($uniq_id, $result['artist'], $result['video_title'])."]".$result['video_title']." video by ".$result['artist']."[/URL]";
}

$smarty->assign('social', $social);
$smarty->assign('video_artist', $video_artist);
$smarty->assign('video_title', $video_title);
$smarty->assign('template_dir', $template_f);
$smarty->assign('vid', $uniq_id);
$smarty->assign('html_code', $code);
$smarty->assign('title', 'Post this video to your pages');
$smarty->display('share_header.tpl');
$smarty->display('share_code.tpl');
$smarty->display('share_footer.tpl');
?>