295 lines
14 KiB
PHP
295 lines
14 KiB
PHP
<?php
|
|
|
|
/* $Id: video.php 142 2009-03-26 09:15:25Z szerrade $ */
|
|
|
|
$page = "video";
|
|
include "header.php";
|
|
|
|
|
|
// DISPLAY ERROR PAGE IF USER IS NOT LOGGED IN AND ADMIN SETTING REQUIRES REGISTRATION
|
|
if( !$user->user_exists && !$setting['setting_permission_video'] )
|
|
{
|
|
if($owner->user_info["user_id"]!=$user->user_info["user_id"]){
|
|
$page = "error";
|
|
$smarty->assign('error_header', 639);
|
|
$smarty->assign('error_message', 656);
|
|
$smarty->assign('error_submit', 641);
|
|
include "footer.php";
|
|
}
|
|
}
|
|
|
|
// DISPLAY ERROR PAGE IF NO OWNER
|
|
if( !$owner->user_exists )
|
|
{
|
|
$page = "error";
|
|
$smarty->assign('error_header', 639);
|
|
$smarty->assign('error_message', 828);
|
|
$smarty->assign('error_submit', 641);
|
|
include "footer.php";
|
|
}
|
|
|
|
// DISPLAY ERROR FOR MEMBERS WITH INSUFFICIENT USER LEVEL
|
|
|
|
|
|
|
|
if(isset($_POST['task'])) { $task = $_POST['task']; } elseif(isset($_GET['task'])) { $task = $_GET['task']; } else { $task = "main"; }
|
|
if(isset($_POST['video_id'])) { $video_id = $_POST['video_id']; } elseif(isset($_GET['video_id'])) { $video_id = $_GET['video_id']; } else { $video_id = 0; }
|
|
$approval_needed = $_POST['admin_key'] == 'b4t3' ? '' : "AND video_admin_approved='1'";
|
|
|
|
function grabcomments()
|
|
{
|
|
global $url, $video_id, $database;
|
|
$query = $database->database_query("SELECT * FROM se_videocomments WHERE videocomment_video_id='".$video_id."' ORDER BY videocomment_id DESC");
|
|
while($row=$database->database_fetch_array($query))
|
|
{
|
|
$owner1=new SEUser(Array($row["videocomment_authoruser_id"]));
|
|
|
|
?>
|
|
<div style="margin-top: 10px; margin-bottom: 20px;"><div style="float: left; text-align: center; width: 90px;"><a href="<?=$url->url_create('profile', $owner1->user_info["user_username"])?>"><?php $profilepicture=$owner1->user_photo("./images/nophoto.png");
|
|
echo $owner1->userprofiledot($profilepicture, "75px");?></a></div><div style="overflow: hidden;"><div class="profile_comment_author"><a href="<?=$url->url_create('profile', $owner1->user_info["user_username"])?>"><b><?=$owner1->user_displayname?></b></a></div><div class="profile_comment_date"><?=date('n/j/Y g:i A', $row["videocomment_date"])?></div><div class="profile_comment_body" id="profile_comment_body_14612"><?=$row["videocomment_body"]?></div><div class="profile_comment_links"><a data-toggle="modal" data-target="#myModal" href="user_messages_new.php?to_user=<?=$owner1->user_info["user_username"]?>&to_id=<?=$owner1->user_info["user_username"]?>">message</a> </div></div></div><div class="clear"></div>
|
|
<?
|
|
}
|
|
|
|
}
|
|
|
|
$video_query1 = $database->database_query("SELECT * FROM se_videos WHERE video_id='$video_id' AND video_user_id='{$owner->user_info['user_id']}' LIMIT 1");
|
|
|
|
|
|
//if($database->database_num_rows($video_query) != 1) { header("Location: ".$url->url_create('profile', $owner->user_info['user_username'])); exit(); }
|
|
$video_info1 = $database->database_fetch_assoc($video_query1);
|
|
if($video_info1===false){
|
|
$page = "error";
|
|
$smarty->assign('filenotfound', 1);
|
|
$smarty->assign('item', "video");
|
|
|
|
$smarty->assign('error_message', 828);
|
|
$smarty->assign('error_submit', 641);
|
|
include "footer.php";
|
|
exit;
|
|
}
|
|
if($video_info1["videooftheday"]!=1&&$video_info1["video_user_id"]!=390124){
|
|
if ($user->user_info['user_level_id'] != 2&&$user->user_info['user_level_id'] != 7) :
|
|
if($owner->user_info["user_id"]!=$user->user_info["user_id"]){
|
|
header("Location: /premium.php?premiumonly=1");
|
|
exit;
|
|
}
|
|
endif;
|
|
}
|
|
|
|
// MAKE SURE VIDEO EXISTS
|
|
$video_query = $database->database_query("SELECT * FROM se_videos WHERE video_id='$video_id' AND video_user_id='{$owner->user_info['user_id']}' $approval_needed AND resize=0 LIMIT 1");
|
|
|
|
|
|
//if($database->database_num_rows($video_query) != 1) { header("Location: ".$url->url_create('profile', $owner->user_info['user_username'])); exit(); }
|
|
$video_info = $database->database_fetch_assoc($video_query);
|
|
|
|
// CHECK PRIVACY
|
|
if($video_info["video_admin_approved"]==1){
|
|
$privacy_max = $owner->user_privacy_max($user);
|
|
if(!($video_info[video_privacy] & $privacy_max)) {
|
|
$page = "error";
|
|
$smarty->assign('error_header', 690699016);
|
|
$smarty->assign('error_message', 690699017);
|
|
$smarty->assign('error_submit', 641);
|
|
include "footer.php";
|
|
}}
|
|
|
|
|
|
|
|
|
|
// INSTANTIATE VIDEO AND SET VIDEO VARS
|
|
$video = new se_video($owner->user_info['user_id']);
|
|
$video_info['video_dir'] = $video->video_dir();
|
|
$video_info['video_desc']=strip_tags(html_entity_decode($video_info['video_desc']), "<br>");
|
|
$video_info['video_desc_short']=substr(strip_tags(html_entity_decode($video_info['video_desc'])),0,100);
|
|
|
|
|
|
|
|
$getID3 = new getID3;
|
|
$file = $getID3->analyze($video_info["video_dir"].$video_info['video_id'].".mp4");
|
|
//echo("Duration: ".$file['playtime_string']." / Dimensions: ".$file['video']['resolution_x']." wide by ".$file['video']['resolution_y']." tall"." / Filesize: ".$file['filesize']." bytes<br />");
|
|
// ENSURE VIDEOS ARE ENABLED FOR THIS USER
|
|
// Changed for viewing videos of expired members
|
|
/*
|
|
if ((($video_info['video_type'] == 0) && (!$owner->level_info['level_video_allow'])) || (($video_info['video_type'] == 1) && (!$owner->level_info['level_youtube_allow'])))
|
|
{
|
|
header("Location: ".$url->url_create('profile', $owner->user_info['user_username']));
|
|
exit();
|
|
}
|
|
*/
|
|
|
|
|
|
|
|
$video_info['video_rating_full'] = floor($video_info['video_cache_rating']);
|
|
$video_info['video_rating_part'] = (($video_info['video_cache_rating']-$video_info['video_rating_full']) == 0) ? 0 : 1;
|
|
$video_info['video_rating_none'] = 5-$video_info['video_rating_full']-$video_info['video_rating_part'];
|
|
$video_info['video_rating_total'] = $database->database_num_rows($database->database_query("SELECT NULL FROM se_videoratings WHERE videorating_video_id='{$video_info['video_id']}'"));
|
|
// GET VIDEO COMMENT PRIVACY
|
|
$allowed_to_comment = ($privacy_max & $video_info['video_comments']);
|
|
//if ($user->user_info['user_level_id'] <= 1||$user->user_info['user_level_id']==5) {$allowed_to_comment =false;}
|
|
|
|
// CHECK IF USER IS ALLOWED TO RATE
|
|
$allowed_to_rate = 1;
|
|
if($database->database_num_rows($database->database_query("SELECT NULL FROM se_videoratings WHERE videorating_video_id='{$video_info['video_id']}' AND videorating_user_id='{$user->user_info['user_id']}'")) != 0 || !$user->user_exists) { $allowed_to_rate = 0; }
|
|
|
|
|
|
// RATE VIDEO
|
|
if($task == "rate_do")
|
|
{
|
|
$rating = (int) $_POST['rating'];
|
|
|
|
if($allowed_to_rate)
|
|
{
|
|
if($rating <= 5 && $rating >= 1)
|
|
{
|
|
$database->database_query("INSERT INTO se_videoratings (videorating_video_id, videorating_user_id, videorating_rating) VALUES ('{$video_info['video_id']}', '{$user->user_info['user_id']}', '{$rating}')");
|
|
|
|
// GET AVERAGE RATING / NUM VOTES FOR BAYESIAN WEIGHTED RATING
|
|
$avg = $database->database_fetch_assoc($database->database_query("SELECT avg(video_cache_rating) AS average_rating, avg(video_cache_rating_total) AS average_total FROM se_videos WHERE video_cache_rating_total<>'0'"));
|
|
|
|
// GET TOTAL RATING
|
|
$new_rating = ($video_info['video_cache_rating']*$video_info['video_rating_total']+$rating)/($video_info['video_rating_total']+1);
|
|
$new_total = $video_info['video_rating_total']+1;
|
|
$new_rating_weighted = ( ($avg['average_total'] * $avg['average_rating']) + ($new_total * $new_rating) ) / ($avg['average_total'] + $new_total);
|
|
|
|
// SET NEW CACHED RATINGS
|
|
$database->database_query("UPDATE se_videos SET video_cache_rating='{$new_rating}', video_cache_rating_weighted='{$new_rating_weighted}', video_cache_rating_total='{$new_total}' WHERE video_id='{$video_info['video_id']}'");
|
|
$allowed_to_rate = 0;
|
|
$video_info['video_rating_full'] = floor($new_rating);
|
|
$video_info['video_rating_part'] = (($new_rating-$video_info['video_rating_full']) == 0) ? 0 : 1;
|
|
$video_info['video_rating_none'] = 5-$video_info['video_rating_full']-$video_info['video_rating_part'];
|
|
$video_info['video_rating_total'] = $new_total;
|
|
}
|
|
}
|
|
|
|
$response_array = array(
|
|
'allowed_to_rate' => (bool) $allowed_to_rate,
|
|
'rating_full' => (int) $video_info['video_rating_full'],
|
|
'rating_part' => (int) $video_info['video_rating_part'],
|
|
'rating_none' => (int) $video_info['video_rating_none'],
|
|
'rating_total' => (int) $video_info['video_rating_total']
|
|
);
|
|
|
|
// OUTPUT JSON
|
|
echo json_encode($response_array);
|
|
exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
// GET USER'S VIDEOS FOR CAROUSEL
|
|
$total_videos = $video->video_total("(video_is_converted='1')");
|
|
$video_array = $video->video_list_all(0, $video->video_total(), "video_id DESC", "(video_is_converted='1')", 1);
|
|
|
|
|
|
// GET VIDEO COMMENTS
|
|
$comment = new se_comment('video', 'video_id', $video_info['video_id']);
|
|
$total_comments = $comment->comment_total();
|
|
|
|
|
|
// UPDATE VIDEO VIEWS
|
|
if($user->user_info['user_id'] != $owner->user_info['user_id'])
|
|
{
|
|
$video_views_new = $video_info['video_views'] + 1;
|
|
$database->database_query("UPDATE se_videos SET video_views='{$video_views_new}' WHERE video_id='{$video_info['video_id']}' LIMIT 1");
|
|
}
|
|
|
|
// UPDATE NOTIFICATIONS
|
|
if($user->user_info['user_id'] == $owner->user_info['user_id'])
|
|
{
|
|
// $database->database_query("DELETE FROM se_notifys USING se_notifys LEFT JOIN se_notifytypes ON se_notifys.notify_notifytype_id=se_notifytypes.notifytype_id WHERE se_notifys.notify_user_id='{$owner->user_info['user_id']}' AND (se_notifytypes.notifytype_name='videocomment' OR se_notifytypes.notifytype_name='likedvideo') AND notify_object_id='{$video_info['video_id']}'");
|
|
|
|
$database->database_query("UPDATE se_notifys LEFT JOIN se_notifytypes ON se_notifys.notify_notifytype_id=se_notifytypes.notifytype_id SET isread=1 WHERE se_notifys.notify_user_id='{$owner->user_info['user_id']}' AND (se_notifytypes.notifytype_name='videocomment' OR se_notifytypes.notifytype_name='likedvideo') AND notify_object_id='{$video_info['video_id']}'");
|
|
}
|
|
$commentcount = $database->database_result($database->database_query("SELECT COUNT(*) FROM se_videocomments WHERE videocomment_video_id='".$video_id."'"),0);
|
|
|
|
$smarty->assign('commentcount', $commentcount);
|
|
if(isset($_POST['favorites'])) { $fave = $_POST['favorites']; } elseif(isset($_GET['favorites'])) { $fave = $_GET['favorites']; } else { $fave = 0; }
|
|
|
|
if($fave==="delete"){
|
|
|
|
$database->database_query("DELETE FROM favorites WHERE user='".$user->user_info["user_id"]."' AND type='video' AND owner='".$owner->user_info["user_id"]."' AND objectid='".$video_info['video_id']."'");
|
|
|
|
}
|
|
|
|
if($fave==="addto"){
|
|
$query=$database->database_query("SELECT * FROM favorites WHERE user='".$user->user_info["user_id"]."' AND type='video' AND owner='".$owner->user_info["user_id"]."' AND objectid='".$video_info['video_id']."'");
|
|
|
|
if($database->database_num_rows($query)==0){
|
|
$database->database_query("INSERT INTO favorites SET user='".$user->user_info["user_id"]."', type='video', owner='".$owner->user_info["user_id"]."', objectid='".$video_info['video_id']."'");
|
|
}
|
|
}
|
|
|
|
$query=$database->database_query("SELECT * FROM favorites WHERE user='".$user->user_info["user_id"]."' AND type='video' AND owner='".$owner->user_info["user_id"]."' AND objectid='".$video_info['video_id']."'");
|
|
if($database->database_num_rows($query)>0){$smarty->assign('favorites1', 1);}
|
|
|
|
$smarty->assign('favorites', 1);
|
|
|
|
|
|
|
|
|
|
$total_likes=$database->database_result($database->database_query("SELECT COUNT(*) FROM likedvideos WHERE media_id='".$video_id."'"),0);
|
|
$smarty->assign('total_likes', $total_likes);
|
|
|
|
$likedmedia=$database->database_query("SELECT * FROM likedvideos, se_users WHERE likedvideos.user_id='".$user->user_info["user_id"]."' AND likedvideos.user_id=se_users.user_id AND media_id={$video_id}");
|
|
if($database->database_num_rows($likedmedia)>0){$smarty->assign('likedmedia', 1);}else{$smarty->assign('likedmedia', 0);}
|
|
|
|
$likedmedia1=$database->database_query("SELECT * FROM likedvideos, se_users WHERE likedvideos.user_id=se_users.user_id AND media_id={$video_id} ORDER by likedvideos.id DESC");
|
|
while($row2=$database->database_fetch_array($likedmedia1))
|
|
{
|
|
$likes[]=$row2;
|
|
}
|
|
//=$database->database_fetch_array($likedmedia);
|
|
|
|
$smarty->assign('likes', $likes);
|
|
|
|
|
|
// SET GLOBAL PAGE TITLE
|
|
$global_page_title[0] = 5500151;
|
|
$global_page_title[1] = $owner->user_displayname;
|
|
$global_page_title[2] = $video_info['video_title'];
|
|
$global_page_description[0] = 5500102;
|
|
$global_page_description[1] = $video_info['video_desc'];
|
|
$objectembed='<object id="player1" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9.0.115" width="320" height="240">
|
|
<param name=bgcolor value="#000000">
|
|
<param name=movie value="/player/player.swf">
|
|
<param name=allowfullscreen value="true">
|
|
<param name=allowscriptaccess value="always">
|
|
<param name="flashvars" value="file='.urlencode($video_info['video_dir'].$video_info['video_id'].'.flv').'&controlbar=bottom">
|
|
<embed name="player1" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" width="320"
|
|
height="240"bgcolor="#000000" src="/player/player.swf" allowfullscreen="true"allowscriptaccess="always"
|
|
flashvars="file='.urlencode($video_info['video_dir'].$video_info['video_id'].'.flv').'&controlbar=bottom">
|
|
</embed>
|
|
</object>';
|
|
// ASSIGN VARIABLES AND DISPLAY VIDEO PAGE
|
|
//for lists
|
|
$smarty->assign('objectid', $video_id);
|
|
$smarty->assign('type',"video");
|
|
|
|
$smarty->assign('list',"1");
|
|
|
|
|
|
$x=0;
|
|
$tags=$database->database_query("SELECT se_users.user_username FROM se_users, se_videotags WHERE se_users.user_id=mediatag_user_id AND mediatag_media_id=".$video_id);
|
|
while($tag=$database->database_fetch_array($tags))
|
|
{
|
|
if($x>0){$tagged.=", ";}
|
|
$tagged.="<a href='/profile.php?user=".$tag["user_username"]."'>".$tag["user_username"]."</a>";
|
|
$x++;
|
|
}
|
|
$smarty->assign('tagged', $tagged);
|
|
|
|
$smarty->assign('file', $file["video"]);
|
|
|
|
$smarty->assign('objectembed', $objectembed);
|
|
|
|
$smarty->assign('video_id', $video_id);
|
|
$smarty->assign('video_info', $video_info);
|
|
$smarty->assign('total_comments', $total_comments);
|
|
$smarty->assign('allowed_to_comment', $allowed_to_comment);
|
|
$smarty->assign('allowed_to_rate', $allowed_to_rate);
|
|
$smarty->assign('videos', $video_array);
|
|
$smarty->assign('total_videos', $total_videos);
|
|
include "footer.php";
|
|
?>
|