<?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.
// +------------------------------------------------------------------------+

$showm = '2';
include('header.php');

$message = '';

$uniq_id	=	$_GET['vid'];
$action		=	(int) $_GET['a'];
$page		=	(int) $_GET['page'];

if(empty($action))	$action = 0;
if(empty($page))	$page	= 0;

if(empty($uniq_id))
{
	$message = "<div class=\"info_msg_err\">There has been an error. Please go back to the previous page</div>";
	echo '<div id="content">';
	echo $message;
	echo '</div>';
	include('footer.php');
	exit();
}

$my_tags = a_get_video_tags($uniq_id);
$my_tags_str = '';
foreach($my_tags as $k => $arr)
{
	$my_tags_str .= $arr['tag'] . ", ";
}
$my_tags_str = substr($my_tags_str, 0, -2);


if($_POST['submit'] != '')
{
	$input = $c_inc = $c_dec = array();
	
	define('PHPMELODY', true);
	$sources = a_fetch_video_sources();
	
	foreach($_POST as $k => $v)
	{
		if ( ! is_array($v))
		{
			$input[$k] = secure_sql(trim($v));
		}
		else
		{
			$input[$k] = $v;
		}
	}
	if( is_array($_POST['category']) ){
		$categories = implode(",", $_POST['category']);
	}
	else 
		$categories = $_POST['category'];
	
	if (strcmp($categories, $_POST['categories_old']) != 0)
	{
		$buffer_new = $buffer_old = array();
		$buffer_new = explode(',', $categories);
		$buffer_old = explode(',', $_POST['categories_old']);
		
		foreach ($buffer_new as $k => $cid)
		{
			if ( ! in_array($cid, $buffer_old))
			{
				$c_inc[] = $cid;
			}
		}
		foreach ($buffer_old as $k => $cid)
		{
			if ( ! in_array($cid, $buffer_new))
			{
				$c_dec[] = $cid;
			}
		}
	}

	$description			=	$input['description'];
	$input['video_title']	=	html_entity_decode($input['video_title']);
	$input['artist']		=	html_entity_decode($input['artist']);
	$input['video_title']	=	str_replace( array("<", ">"), array("&lt;", "&gt;"), $input['video_title']);
	$input['artist']		=	str_replace( array("<", ">"), array("&lt;", "&gt;"), $input['artist']);
	$input['featured'] 		=	(int) $_POST['featured'];
	$input['source_id']		= 	(int) $_POST['source_id'];
	
	if (strlen($input['embed_code']) > 0)
	{
		$input['embed_code'] = $_POST['embed_code'];
		if (ini_get('magic_quotes_gpc') == 1)
		{
			$input['embed_code'] = stripslashes($input['embed_code']);
		}
		
		$input['embed_code'] = str_replace(array("'", "\n", "\r"), array('"', '', ''), $input['embed_code']);
		
		//	remove extra html tags
		$input['embed_code'] = strip_tags($input['embed_code'], '<iframe><embed><object><param>');
		
		//	remove left-overs
		if (strpos($input['embed_code'], '<object') !== false)
		{
			$input['embed_code'] = preg_replace('/\/object>(.*)/i', '/object>', $input['embed_code']);
		}

		//	replace width, height and wmode values with variables
		$input['embed_code'] = preg_replace('/width="([0-9]+)"/i', 'width="%%player_w%%"', $input['embed_code']);
		$input['embed_code'] = preg_replace('/height="([0-9]+)"/i', 'height="%%player_h%%"', $input['embed_code']);
		$input['embed_code'] = preg_replace('/value="(window|opaque|transparent)"/i', 'value="%%player_wmode%%"', $input['embed_code']);
		$input['embed_code'] = preg_replace('/wmode="(.*?)"/i', 'wmode="%%player_wmode%%"', $input['embed_code']);
		$input['embed_code'] = preg_replace('/width=([0-9]+)/i', 'width=%%player_w%%', $input['embed_code']);
		$input['embed_code'] = preg_replace('/height=([0-9]+)/i', 'height=%%player_h%%', $input['embed_code']);
		
		$input['embed_code'] = secure_sql($input['embed_code']);
		
		if ($input['source_id'] > 0)
			$input['source_id'] = 0;
	}
	else if ($input['source_id'] == 0 && strlen($input['embed_code']) == 0)
	{
		if (strlen($input['url_flv']) > 0)
		{
			$allowed_ext = array('.flv', '.mp4', '.mov', '.wmv', '.divx', '.avi', '.mkv', 
								'.asf', '.wma', '.mp3', '.m4v', '.m4a', '.3gp', '.3g2');
			$last_4_chars = substr($input['url_flv'], strlen($input['url_flv'])-4, strlen($input['url_flv']));
			
			if(in_array($last_4_chars, $allowed_ext) && (preg_match('/photobucket\.com/', $input['url_flv']) == 0))
			{
				if(strpos($input['url_flv'], _URL) !== false)
				{
					$input['source_id'] = 1;
				}
				else
				{
					$input['source_id'] = 2;
				}
			}
		}
		else
		{
			$input['source_id'] = 1234;
		}
		
		$sql = "DELETE FROM pm_embed_code WHERE uniq_id = '". $_POST['uniq_id'] ."'";
		mysql_query($sql);
	}
	
	if($description != '')
	{
		if((strlen($description) == 4) && ($description == "<br>"))
		{
			$description = '';
		}
	}
	
	if($input['tags'] != '')
	{
		$tags = explode(",", $input['tags']);

		//	remove duplicate tags and 'empty' tags
		$temp = array();
		for($i = 0; $i < count($tags); $i++)
		{
			if($tags[$i] != '')
				if($i <= (count($tags)-1))
				{
					$found = 0;
					for($j = $i + 1; $j < count($tags); $j++)
					{
						if(strcmp($tags[$i], $tags[$j]) == 0)
							$found++;
					}
					if($found == 0)
						$temp[] = $tags[$i];
				}
		}
		$tags = $temp;

		$tags_insert = array();
		foreach($tags as $k => $tag)
		{
			//	handle mistakes
			$tag = stripslashes(trim($tag));
			$tags[$k] = $tag;
			if($tag != '' && (strlen($tag) > 0))
			{
				//	new tags vs old tags
				$found = 0;
				$safe_tag = safe_tag($tag);
				
				foreach($my_tags as $key => $arr)
				{
					if(in_array($safe_tag, $arr))
						$found++;
				}
				if($found == 0)
					$tags_insert[] = $tag;
			}
		}
		//	were there any tags changed or removed?
		$remove_tags = array();
		foreach($my_tags as $k => $v)
		{
			if(in_array($v['tag'], $tags) === false)
			{
				$remove_tags[] = $v['tag_id'];
			} 
		}
		//	insert new tags in database
		if(count($tags_insert) > 0)
		{
			insert_tags($_POST['uniq_id'], $tags_insert);
		}
		
		//	remove left-out tags
		if(count($remove_tags) > 0)
		{
			$this_arr = '';
			$this_arr = implode(",", $remove_tags);
			$sql2 = "DELETE FROM pm_tags WHERE tag_id IN(".$this_arr.")";
			$result2 = mysql_query($sql2);	// or die(mysql_error());
		}
	}
	elseif(($input['tags'] == '') && (strlen($my_tags_str) > 0))
	{
		//	remove all tags for this video
		$sql = "DELETE FROM pm_tags WHERE uniq_id = '".$_POST['uniq_id']."'";
		$result = mysql_query($sql);
		if(!$result)
			echo "<div class=\"info_msg_err\">There was a problem during update: <b>could not update tags</b>!</div>";
	}
	
	//	Reset tags so that they show up nice and updated in the form
	$my_tags = a_get_video_tags($uniq_id);
	$my_tags_str = '';
	
	foreach($my_tags as $k => $arr)
	{
		$my_tags_str .= $arr['tag'] . ", ";
	}
	$my_tags_str = substr($my_tags_str, 0, -2);

	$sql = "UPDATE pm_videos 
			SET artist = '".$input['artist']."', 
				video_title = '".$input['video_title']."', 
				submitted = '".$input['submitted']."', 
				category= '".$categories."', 
				description = '".$description."',
				yt_thumb = '".$input['yt_thumb']."',
				language = '".$input['language']."'";
	
	// update site_views only if the input value has changed
	if ($input['site_views'] != $input['site_views_input'])
	{
		$input['site_views_input'] = abs((int) $input['site_views_input']); // positive values only		
		$sql .= ", site_views = '". $input['site_views_input'] ."'";
	}
	
	if($input['source_id'] > 2)
	{
		//	was the Direct link to video changed?
		if(strcmp($input['direct'], $input['direct-original']) != 0)
		{
			$use_this_src = -1;
					
			if($sources === false || count($sources) == 0)
			{
				$use_this_src = $input['source_id'];
			}
			else
			{
			 foreach($sources as $src_id => $source)
			 {
			   if($source['source_id'] != 1 && $source['source_id'] != 2)
			   {
				if(@preg_match($source['source_rule'], $input['direct']))
				{
					$use_this_src = $source['source_id'];
					break;
				}
			   }
			 }
			}

			if($use_this_src == -1)
			{
				if (strpos($input['direct'], _URL) !== false)
				{
					$use_this_src = $sources['localhost']['source_id'];
				}
				else if (@preg_match($sources['other']['source_rule'], $input['direct']) != 0)
				{
					$use_this_src = $sources['other']['source_id'];
				}
				else
				{
					$use_this_src = $input['source_id'];	
				}
			}
			
			$input['source_id'] = $use_this_src;

			require_once( "./src/" . $sources[ $use_this_src ]['source_name'] . ".php");
			
			$temp = array();
			do_main($temp, $input['direct']);
			
			$sql .= ", yt_id = '".$temp['yt_id']."'";
			$sql .= ", url_flv = '".$temp['url_flv']."'";
			$sql .= ", source_id = '".$input['source_id']."'";
			$sql .= ", status = '0'";
			
			
			if(empty($input['direct-original']))
			{
				$sql2 = "INSERT INTO pm_videos_urls (uniq_id, direct) VALUES ('".$_POST['uniq_id']."', '".$input['direct']."')";
				$result = mysql_query($sql2);		
			}
			else
			{
				$sql2 = "UPDATE pm_videos_urls SET direct='".$input['direct']."' WHERE uniq_id='".$_POST['uniq_id']."'";
				$result = mysql_query($sql2);			
			}
			unset($temp, $sql2);
			
			
		}
		//	was the flv location changed?
		elseif(strcmp($input['url_flv'], $input['url_flv-original']) != 0  && $input['source_id'] > 0)
		{
			$use_this_src = -1;
					
			if($sources === false || count($sources) == 0)
			{
				$use_this_src = $input['source_id'];
			}
			else
			{
			 foreach($sources as $src_id => $source)
			 {
			   if($source['source_id'] != 1 && $source['source_id'] != 2)
			   {
				if(@preg_match($source['source_rule'], $input['url_flv']))
				{
					$use_this_src = $source['source_id'];
					break;
				}
			   }
			 }
			}
			
			if($use_this_src == -1)
			{
				if (strpos($input['url_flv'], _URL) !== false)
				{
					$use_this_src = $sources['localhost']['source_id'];
				}
				else if (@preg_match($sources['other']['source_rule'], $input['url_flv']) != 0)
				{
					$use_this_src = $sources['other']['source_id'];
				}
				else
				{
					$use_this_src = $input['source_id'];	
				}
			}
			
			$input['source_id'] = $use_this_src;
			
			$yt_id = '';
			if(preg_match("/youtube\.com/i", $input['url_flv']))
			{
				preg_match("/video_id=([^(\&|$)]*)/i", $input['url_flv'], $matches);
				$yt_id = $matches[1];
				unset($matches);
			}
			
			if($yt_id != '')
			{
				$sql .= ", yt_id = '".$yt_id."'";
			}
			$sql .= ", url_flv = '".$input['url_flv']."'";
			$sql .= ", source_id = '".$input['source_id']."'";
		}
	}
	else
	{
		$source_id = $input['source_id'];
		
		if(strcmp($input['url_flv'], $input['url_flv-original']) != 0)
		{
			$sql .= ", url_flv = '".$input['url_flv']."'";
			
			if ( ! is_url($input['url_flv']) && is_file(_VIDEOS_DIR_PATH . $input['url_flv']))
			{
				$source_id = 1;
			}
		}
		
		$sql .= ", source_id = '". $source_id ."'";
	}
	
	$sql .= ", featured = '".$input['featured']."'";
	$sql .= ", restricted = '".$input['restricted']."'";
	$sql .= " WHERE uniq_id= '".$_POST['uniq_id']."' LIMIT 1";

	$result = @mysql_query($sql);

	if(!$result)
	{
		$message = "<div class=\"info_msg_err\">There was a problem encountered during update. Update failed!<br />MySQL returned this error: ".mysql_error()."</div>";
	}
	else
	{	
		if (count($c_inc) > 0)
		{
			$str = implode(',', $c_inc);
			$sql = "UPDATE pm_categories SET total_videos=total_videos+1 
					WHERE id IN (". $str .")";
			mysql_query($sql);
			unset($str);
		}
		if (count($c_dec) > 0)
		{
			$str = implode(',', $c_dec);
			$sql = "UPDATE pm_categories SET total_videos=total_videos-1 
					WHERE id IN (". $str .")";
			mysql_query($sql);
			unset($str);
		}
		if (strlen($input['embed_code']) > 0)
		{
			if (count_entries('pm_embed_code', 'uniq_id', $_POST['uniq_id']) > 0)
			{
				$sql = "UPDATE pm_embed_code SET embed_code = '". $input['embed_code'] ."' WHERE uniq_id = '". $_POST['uniq_id'] ."'";
			}
			else
			{
				$sql = "INSERT INTO pm_embed_code (uniq_id, embed_code) VALUES ('". $_POST['uniq_id'] ."', '". $input['embed_code'] ."')";
			}
			mysql_query($sql);
		}
		$message = '<div class="info_msg_ok"><strong>Video updated.</strong> <a href="'. _URL .'/musicvideo.php?vid='. $_POST['uniq_id'] .'" title="Watch video">Watch video</a></div>
		<input name="continue" type="button" value="&laquo; Manage videos" onClick="location.href=\'videos.php\'" class="inputbutton" />';
	}
}
elseif($_POST['submit'] == "Update" && empty($_POST['categories']))
{
	$message = "<div class=\"info_msg_err\">Please select a category!</div>";
}

if($message != '')
	$message;

$type = 'video';

if (strpos($uniq_id, 'article') !== false)
{	
	$pieces = explode('-', $uniq_id);
	$id = (int) $pieces[1];

	$query = mysql_query("SELECT * FROM art_articles WHERE id = '".$id."'");
	$type = 'article';
}
else
{
	$query = mysql_query("SELECT * FROM pm_videos WHERE uniq_id = '".$uniq_id."'");
}
$count = mysql_num_rows($query);

if($count == 0) {
	$message = "<div class=\"info_msg_err\">The requested video was not found in your database.</div>";
	echo '<div id="content">';
	echo $message;
	echo '</div>';
	include('footer.php');
	exit();
}
if ($type == 'video')
{
	$r = mysql_fetch_assoc($query);
	$query2 = mysql_query("SELECT mp4, direct FROM pm_videos_urls WHERE uniq_id = '".$uniq_id."'");
	$r_extent = mysql_fetch_assoc($query2);

	mysql_free_result($query);
	mysql_free_result($query2);
	
	if ($r['source_id'] == 0)
	{
		$row = array();
		$sql = "SELECT * FROM pm_embed_code WHERE uniq_id = '". $uniq_id ."'";
		$result = mysql_query($sql);
		$row = mysql_fetch_assoc($result);
		mysql_free_result($result);
		if (is_array($row))
			$r = array_merge($r, $row);
		unset($row);
	}
}
else
{
	$r_extend = array();
}

if(is_array($r_extent))
	$r = array_merge($r, $r_extent);

switch($action)
{
	case 1:
		$sql = "SELECT uniq_id, category, url_flv, source_id FROM pm_videos WHERE uniq_id = '". $uniq_id ."'";
		$result = mysql_query($sql);
		$row = mysql_fetch_assoc($result);
		mysql_free_result($result);
		
		$sql = "UPDATE pm_categories SET total_videos=total_videos-1 
				WHERE id IN (". $row['category'] .")";
		@mysql_query($sql);
		update_config('total_videos', $config['total_videos']-1);
		
		// REMOVE VIDEO AND EVERYTHING RELATED TO RESPECTIVE VIDEO
		@mysql_query("DELETE FROM pm_videos WHERE uniq_id = '".$uniq_id."'");
		@mysql_query("DELETE FROM pm_comments WHERE uniq_id = '".$uniq_id."'");
		@mysql_query("DELETE FROM pm_ratings WHERE id = '".$uniq_id."'");
		@mysql_query("DELETE FROM pm_reports WHERE entry_id = '".$uniq_id."'");
		@mysql_query("DELETE FROM pm_videos_urls WHERE uniq_id = '".$uniq_id."'");
		@mysql_query("DELETE FROM pm_favorites WHERE uniq_id = '".$uniq_id."'");
		@mysql_query("DELETE FROM pm_chart WHERE uniq_id = '".$uniq_id."'");
		@mysql_query("DELETE FROM pm_tags WHERE uniq_id = '".$uniq_id."'");
		@mysql_query("DELETE FROM pm_embed_code WHERE uniq_id = '".$uniq_id."'");
		
		if ($row['source_id'] == 1) 
		{
			if (file_exists(_VIDEOS_DIR_PATH . $row['url_flv']) && strlen($row['url_flv']) > 0)
			{
				unlink(_VIDEOS_DIR_PATH . $row['url_flv']);					
			}
		}
		if (file_exists(_THUMBS_DIR_PATH . $row['uniq_id'] .'-1.jpg'))
		{
			unlink(_THUMBS_DIR_PATH . $row['uniq_id'] .'-1.jpg');
		}
		
		$pieces = explode('/', $_SERVER['HTTP_REFERER']);
		$pieces = explode('?', $pieces[ count($pieces)-1 ]);

		echo "<meta http-equiv=\"refresh\" content=\"0;videos.php?action=deleted&". $pieces[1] ."\" />";
		exit();
	break;
	case 2:
		//	REMOVE COMMENTS ONLY 
		@mysql_query("DELETE FROM pm_comments WHERE uniq_id = '".$uniq_id."'");
		
		$pieces = explode('/', $_SERVER['HTTP_REFERER']);
		$pieces = explode('?', $pieces[ count($pieces)-1 ]);
		
		if ($type == 'video')
		{

			echo "<meta http-equiv=\"refresh\" content=\"0;videos.php?action=deleted&". $pieces[1] ."\" />";
		}
		else if ($type == 'article')
		{
			echo "<meta http-equiv=\"refresh\" content=\"0;articles.php?action=deleted&". $pieces[1] ."\" />";
		}
		exit();
	break;
}

?>
<div id="sub_menu">
<li><a href="addvideo.php">Add new video</a></li>
<li><a href="embedvideo.php">Embed new video</a></li>
<li><a href="import.php">Import from Youtube</a></li>
<li><a href="import_user.php">Import from Youtube User</a></li>
<li><a href="reports.php">Reported Videos</a></li>
<li><a href="approve.php">Approve Videos</a></li>
</div>
<div id="content">
<h2>Update Video</h2>

<?php echo $message; ?>
<br />
<form name="update" action="modify.php?vid=<?php echo $uniq_id; ?>" method="post" onsubmit="return validateFormOnSubmit(this, 'Please fill in the required fields (highlighted)')">
<table width="54%" border="0" cellspacing="1" cellpadding="3">
  <tr>
    <td valign="top"></td>
    <td align="right"><input name="submit" type="submit" value="Save" class="inputbutton" /></td>
  </tr>
  <tr>
		<td width="25%" valign="top"><strong>Artist/Band</strong></td>
    <td width="75%"><input type="text" id="must" name="artist" value="<?php echo htmlspecialchars($r['artist']); ?>" style="width: 100%;" /></td>
  </tr>
  <tr>
    <td valign="top"><strong>Video title</strong></td>
    <td><input type="text" id="must" name="video_title" value="<?php echo htmlspecialchars($r['video_title']); ?>" style="width: 100%;" /></td>
  </tr>
	<tr>
		<td><strong>Featured</strong></td>
		<td>
		 <label>
		  <input type="checkbox" name="featured" value="1" <?php if($r['featured'] == 1) echo 'checked="checked"';?> /> Yes, mark as <span class="b_featured">featured</span>
		  </label>
		</td>
	</tr>
  <tr>
    <td valign="top"><strong>Description</strong></td>
    <td>
	<textarea name="description" id="textarea-WYSIWYG" style="height: 150px; width: 500px;"><?php echo $r['description']; ?></textarea>
	<script language="javascript1.2">
		if(navigator.userAgent.toLowerCase().indexOf('chrome/1') == -1)
		{
					// Overwrite WYSIWYG Width and Height
					wysiwygWidth = '100%';
					wysiwygHeight = 150;
					generate_wysiwyg('textarea-WYSIWYG');
		}
	</script>
	<script type="text/javascript">
		//	Editor not loaded?
		if ($("#wysiwygtextarea-WYSIWYG").length == 0)
		{
			// restore textarea
			$("#textarea-WYSIWYG").show();
		}
	</script>	</td>
	</tr>
  <tr>
    <td valign="top"><strong>Tags</strong></td>
    <td>
	<input type="text" name="tags" value="<?php echo $my_tags_str; ?>" style="width: 450px;" /><br />
	<small><em>(e.g. madonna, justin timberlake, live)</em></small><br />	</td>
  </tr>
  <tr>
    <td valign="top"><strong>Thumbnail location</strong></td>
	<td>
	<input type="text" name="yt_thumb" value="<?php echo $r['yt_thumb']; ?>" style="width: 450px;" />	</td>
  </tr>
<?php
  if($r['source_id'] != 1 && $r['source_id'] != 2)
  {
?>
  <tr>
    <td valign="top"><strong>Original video</strong></td>
	<td>
	<input type="text" name="direct" value="<?php echo $r['direct']; ?>" style="width: 450px;" /> <a href="#" class="hintanchor" onMouseover="showhint('Changing this URL will reimport the \'FLV location\' of the new video from the given URL', this, event, '250px')"><img src="images/ico_help.gif" alt="" align="absmiddle" width="16" height="16" border="0" align="absmiddle" /></a>
	<input type="hidden" name="direct-original" value="<?php echo $r['direct']; ?>"  />	</td>
  </tr>
<?php
  }
?>
  <tr>
    <td valign="top"><strong>File Location</strong></td>
	<td>
	<input type="text" name="url_flv" value="<?php echo $r['url_flv']; ?>" style="width: 450px;" /> <a href="#" class="hintanchor" onMouseover="showhint('<b>Warning:</b> Changing the FLV/MOV/WMV/MP4 location of this video may cause it to stop working!', this, event, '250px')"><img src="images/ico_help.gif" alt="" align="absmiddle" width="16" height="16" border="0" align="absmiddle" /></a>
	<input type="hidden" name="url_flv-original" value="<?php echo $r['url_flv']; ?>"  />	
	<br />
	</td>
  </tr>
  <tr>
   <td valign="top"><strong>Embed code</strong></td>
   <td>
	<textarea name="embed_code" style="height: 70px; width: 500px;"><?php echo $r['embed_code']; ?></textarea>
  </tr>  
  <tr>
    <td valign="top"><strong>Views</strong></td>
    <td>
    	<input type="hidden" name="site_views" value="<?php echo $r['site_views'];?>" />
		<input type="text" name="site_views_input" value="<?php echo $r['site_views']; ?>" size="10" />
    </td>
  </tr>
  <tr>
    <td valign="top"><strong>Submitted by</strong></td>
    <td>
	<input type="text" name="submitted" value="<?php echo htmlspecialchars($r['submitted']); ?>" style="width: 100px;" /></td>
  </tr>  
  <tr>
    <td valign="top"><strong>Category</strong></td>
    <td>
	<?php
		$categories_dropdown_options = array(
										'attr_name' => 'category[]',
										'attr_id' => 'main_select_category',
										'select_all_option' => false,
										'spacer' => '&mdash;',
										'selected' => explode(',', $r['category']),
										'other_attr' => 'multiple="multiple"'
										);
		echo categories_dropdown($categories_dropdown_options);
	?>
	</td>
  </tr>
  <tr>
    <td valign="top"><strong>Restrict access</strong></td>
    <td>
    	<label><input type="radio" name="restricted" value="1" <?php echo ($r['restricted'] == '1') ? 'checked="checked"' : '';?> /> Yes</label> 
		<label><input type="radio" name="restricted" value="0" <?php echo ($r['restricted'] == '0') ? 'checked="checked"' : '';?> /> No</label>
    </td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>
    <input type="hidden" name="categories_old" value="<?php echo $r['category'];?>" />
	<input type="hidden" name="language" value="1" />
	<input type="hidden" name="uniq_id" value="<?php echo $uniq_id; ?>" />
	<input type="hidden" name="source_id" value="<?php echo $r['source_id']; ?>" />
	<input name="submit" type="submit" value="Save" class="inputbutton" />	</td>
    </tr>
</table>

</form></div>

<?php
include('footer.php');
?>