我有一个网站,你可以在上面发布一个 YouTube 视频链接,当你这样做时,它会从中获取 ID(11 个字符)并将其放入数据库中。然后,您可以在页面上查看视频,它会使用http://gdata.youtube.com/feeds/api/videos/ ID获取 YouTube 标题和作者,并将其放入带有嵌入代码的页面上。我想知道如何不允许他们发布私人视频链接,就像我可以做一些检查一样。这是我到目前为止发布链接的内容:
if(isset($_POST['video'])){
$error = array();
if(filter_var($_POST['videourl'], FILTER_VALIDATE_URL) !== false){
if(strpos($_POST['videourl'],'youtube.com')){
preg_match('/[\\?\\&]v=([^\\?\\&]+)/',$_POST['videourl'],$video_embed);
$video_embed = $video_embed[1];
}elseif(strpos($_POST['videourl'],'youtu.be')){
$video_embed = substr( parse_url($_POST['videourl'], PHP_URL_PATH), 1 );
}else{
$error[] = 'Invalid link';
}
}else{
$error[] = 'Invalid link';
}
$video_exist = mysql_num_rows(mysql_query("SELECT interest_vid FROM interest_videos WHERE interest_vid = '$video_embed'"));
$interest_exist = mysql_query("SELECT name FROM interests WHERE name = '".$_POST['interest_for_video']."'");
if(!empty($_POST['interest_for_video']) && mysql_num_rows($interest_exist) != 0){
$interest = strtolower(mysql_real_escape_string(strip_tags($_POST['interest_for_video'])));
$interest_id = mysql_result(mysql_query("SELECT id FROM interests WHERE name = '$interest'"), 0);
}else{
$error[] = 'Must specify an interest. ';
}
if(empty($error)){
if($video_exist == 0){
$result2 = mysql_query(" INSERT INTO interest_videos (user_id,interest_id,interest_vid) VALUES ('".$_SESSION['id']."','$interest_id','$video_embed')") or die(mysql_error());
if(!$result2){
die('Could not delete from database: '.mysql_error());
}else{
//$error_message = '<a href="#" onclick="toggle2(\'deletewebsite\', this); return false;"><div id="deletewebsite" class="success">Video Created</div></a>';
header("Location: /interest/video.php?interest=".$interest_id."&video=".$video_embed."");
}
}else{
$error_message = '<a href="#" onclick="toggle2(\'deletewebsite\', this); return false;"><div id="deletewebsite" class="error">That video already exists</div></a>';
}
}else{
$error_message = '<a href="#" onclick="toggle2(\'deletewebsite\', this); return false;"><div id="deletewebsite" class="error">';
foreach($error as $key => $values){
$error_message.= "$values";
}
$error_message.="</div></a>";
}
}
有没有我可以放在那里的支票,这样他们就不能发布私人视频了?