6389 lines
245 KiB
PHP
6389 lines
245 KiB
PHP
<?php
|
|
|
|
/* $Id: class_video.php 208 2009-08-07 01:56:42Z john $ */
|
|
|
|
|
|
// THIS CLASS CONTAINS VIDEO-RELATED METHODS
|
|
// METHODS IN THIS CLASS:
|
|
// se_video()
|
|
// video_total()
|
|
// video_list()
|
|
// video_dir()
|
|
// video_edit()
|
|
// video_upload()
|
|
// video_delete()
|
|
// video_delete_selected()
|
|
// video_update_youtube_thumb()
|
|
|
|
//defined('SE_PAGE') or exit();
|
|
|
|
|
|
use Aws\Exception\MultipartUploadException;
|
|
use Aws\S3\MultipartUploader;
|
|
use Aws\S3\ObjectUploader;
|
|
use Aws\S3\S3Client;
|
|
|
|
class se_eventvideo
|
|
{var $eventvideo_exists = true;
|
|
function __construct($user_id=NULL, $video_id=NULL)
|
|
{
|
|
global $database, $user;
|
|
|
|
$this->user_id = $user_id;
|
|
$this->video_id = $video_id;
|
|
|
|
if( $video_id )
|
|
{
|
|
$sql = "SELECT * FROM se_videos WHERE video_id='{$video_id}' LIMIT 1";
|
|
$resource = $database->database_query($sql);
|
|
|
|
if( $resource && $database->database_num_rows($resource) )
|
|
{
|
|
$this->video_exists = TRUE;
|
|
$this->video_info = $database->database_fetch_assoc($resource);
|
|
}
|
|
}
|
|
}
|
|
|
|
// THIS METHOD RETURNS MAXIMUM PRIVACY LEVEL VIEWABLE BY A USER WITH REGARD TO THE CURRENT GROUP
|
|
// INPUT: $other_user REPRESENTING A USER OBJECT
|
|
// OUTPUT: RETURNS PRIVACY LEVEL OF GIVEN USER WITH RESPECT TO CURRENT GROUP
|
|
function eventvideo_privacy_max($user) {
|
|
global $database;
|
|
|
|
switch(TRUE) {
|
|
|
|
// GROUP LEADER
|
|
case($this->group_info['group_user_id'] == $user->user_info['user_id']):
|
|
return 1;
|
|
break;
|
|
|
|
// GROUP OFFICER
|
|
case($database->database_num_rows($database->database_query("SELECT groupmember_id FROM se_groupmembers WHERE groupmember_user_id='{$user->user_info['user_id']}' AND groupmember_group_id='{$this->group_info['group_id']}' AND groupmember_status='1' AND groupmember_rank='1'")) != 0):
|
|
return 2;
|
|
break;
|
|
|
|
// GROUP MEMBER
|
|
case($database->database_num_rows($database->database_query("SELECT groupmember_id FROM se_groupmembers WHERE groupmember_user_id='{$user->user_info['user_id']}' AND groupmember_group_id='{$this->group_info['group_id']}' AND groupmember_status='1'")) != 0):
|
|
return 4;
|
|
break;
|
|
|
|
// GROUP LEADER'S FRIEND
|
|
case($database->database_num_rows($database->database_query("SELECT friend_id FROM se_friends WHERE friend_status='1' AND friend_user_id1='{$this->group_info['group_user_id']}' AND friend_user_id2='{$user->user_info['user_id']}'")) != 0):
|
|
return 8;
|
|
break;
|
|
|
|
// GROUP MEMBER'S FRIEND
|
|
case($database->database_num_rows($database->database_query("SELECT se_friends.friend_id FROM se_groupmembers LEFT JOIN se_friends ON se_groupmembers.groupmember_user_id=se_friends.friend_user_id1 WHERE se_groupmembers.groupmember_status='1' AND se_groupmembers.groupmember_group_id='{$this->group_info['group_id']}' AND se_friends.friend_status='1' AND se_friends.friend_user_id2='{$user->user_info['user_id']}'")) != 0):
|
|
return 16;
|
|
break;
|
|
|
|
// FRIEND OF GROUP MEMBER'S FRIENDS
|
|
case($database->database_num_rows($database->database_query("SELECT t2.friend_user_id2 FROM se_groupmembers LEFT JOIN se_friends AS t1 ON se_groupmembers.groupmember_user_id=t1.friend_user_id1 LEFT JOIN se_friends AS t2 ON t1.friend_user_id2=t2.friend_user_id1 WHERE se_groupmembers.groupmember_status='1' AND se_groupmembers.groupmember_group_id='{$group->group_info['group_id']}' AND t1.friend_status='1' AND t2.friend_status='1' AND t2.friend_user_id2='{$user->user_info['user_id']}'")) != 0):
|
|
return 32;
|
|
break;
|
|
|
|
// REGISTERED USER
|
|
case($user->user_exists == 1):
|
|
return 64;
|
|
break;
|
|
|
|
// DEFAULT EVERYONE
|
|
default:
|
|
return 128;
|
|
|
|
}
|
|
|
|
} // END group_privacy_max() METHOD
|
|
}
|
|
|
|
class se_video
|
|
{
|
|
// INITIALIZE VARIABLES
|
|
var $is_error = NULL; // DETERMINES WHETHER THERE IS AN ERROR OR NOT
|
|
|
|
var $user_id = NULL; // CONTAINS THE USER ID OF THE USER WHOSE VIDEO WE ARE EDITING
|
|
|
|
var $video_exists = FALSE; // CONTAINS TRUE IF THE VIDEO EXISTS
|
|
|
|
var $video_info = array(); // CONTAINS THE INFO ABOUT THE VIDEO
|
|
|
|
var $debug = FALSE; // DO DEBUGGING?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
// THIS METHOD SETS INITIAL VARS
|
|
//
|
|
// INPUT:
|
|
// $user_id (OPTIONAL) REPRESENTING THE USER ID OF THE USER WHOSE VIDEOS WE ARE CONCERNED WITH
|
|
// $video_id (OPTIONAL) REPRESENTING THE ID OF THE VIDEO WE ARE CONCERNED WITH
|
|
//
|
|
// OUTPUT:
|
|
// void
|
|
//
|
|
|
|
function __construct($user_id=NULL, $video_id=NULL)
|
|
{
|
|
global $database, $user;
|
|
|
|
$this->user_id = $user_id;
|
|
$this->video_id = $video_id;
|
|
|
|
if( $video_id )
|
|
{
|
|
$sql = "SELECT * FROM se_videos WHERE video_id='{$video_id}' LIMIT 1";
|
|
$resource = $database->database_query($sql);
|
|
|
|
if( $resource && $database->database_num_rows($resource) )
|
|
{
|
|
$this->video_exists = TRUE;
|
|
$this->video_info = $database->database_fetch_assoc($resource);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
function album_media_list($start, $limit, $sort_by = "media_id DESC", $where = "", $select = "")
|
|
{
|
|
global $database, $user, $owner;
|
|
|
|
// BEGIN QUERY
|
|
$sql = "
|
|
SELECT
|
|
se_videos.*,
|
|
se_videoalbums.album_id,
|
|
se_videoalbums.album_user_id,
|
|
se_videoalbums.album_title,
|
|
se_videos.video_totalcomments AS total_comments
|
|
";
|
|
|
|
// IF NO USER ID SPECIFIED, RETRIEVE USER INFORMATION
|
|
if( !$this->user_id ) $sql .= ",
|
|
se_users.user_id,
|
|
se_users.user_username,
|
|
se_users.user_photo,
|
|
se_users.user_fname,
|
|
se_users.user_lname
|
|
";
|
|
|
|
// ADD ADDITIONAL SELECTS
|
|
if( !empty($select) ) $sql .= $select;
|
|
|
|
// CONTINUE QUERY
|
|
$sql .= "
|
|
FROM
|
|
se_videos
|
|
LEFT JOIN
|
|
se_videoalbums
|
|
ON se_videoalbums.album_id=se_videos.video_album
|
|
";
|
|
|
|
// IF NO USER ID SPECIFIED, JOIN TO USER TABLE
|
|
if( !$this->user_id ) $sql .= "
|
|
LEFT JOIN
|
|
se_users
|
|
ON se_videoalbums.album_user_id=se_users.user_id
|
|
";
|
|
|
|
// ADD WHERE IF NECESSARY
|
|
if( !empty($where) || $this->user_id ) $sql .= "
|
|
WHERE
|
|
";
|
|
|
|
// ENSURE USER ID IS NOT EMPTY
|
|
if( $this->user_id ) $sql .= "
|
|
album_user_id='{$this->user_id}'
|
|
";
|
|
|
|
// INSERT AND IF NECESSARY
|
|
if( $this->user_id && !empty($where) ) $sql .= " AND";
|
|
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
|
if( !empty($where) ) $sql .= "
|
|
{$where}
|
|
";
|
|
|
|
// ADD GROUP BY, ORDER, AND LIMIT CLAUSE
|
|
$sql .= "
|
|
ORDER BY
|
|
{$sort_by}
|
|
LIMIT
|
|
{$start}, {$limit}
|
|
";
|
|
// RUN QUERY
|
|
$resource = $database->database_query($sql);
|
|
|
|
// GET MEDIA INTO AN ARRAY
|
|
$media_array = array();
|
|
while($media_info = $database->database_fetch_assoc($resource))
|
|
{
|
|
$tags="";
|
|
$checkusers=$database->database_query("SELECT * FROM se_mediatags WHERE mediatag_media_id='".$database->database_real_escape_string($media_info['media_id'])."'");
|
|
while($rowusers=$database->database_fetch_array($checkusers))
|
|
{
|
|
|
|
$thisuser=$database->database_query("SELECT user_username FROM se_users WHERE user_id='".$database->database_real_escape_string($rowusers['mediatag_user_id'])."'");
|
|
$rowuser=$database->database_fetch_array($thisuser);
|
|
|
|
if($tags==""){
|
|
$tags=$rowuser["user_username"]."<br>";}
|
|
else{$tags.=$rowuser["user_username"]."<br>";}
|
|
}
|
|
$media_info['media_tags']=$tags;
|
|
|
|
// IF NO USER ID SPECIFIED, CREATE OBJECT FOR AUTHOR
|
|
if( !$this->user_id )
|
|
{
|
|
$author = new se_user();
|
|
$author->user_exists = TRUE;
|
|
$author->user_info['user_id'] = $media_info['user_id'];
|
|
$author->user_info['user_username'] = $media_info['user_username'];
|
|
$author->user_info['user_photo'] = $media_info['user_photo'];
|
|
$author->user_info['user_fname'] = $media_info['user_fname'];
|
|
$author->user_info['user_lname'] = $media_info['user_lname'];
|
|
$author->user_displayname();
|
|
}
|
|
|
|
// OTHERWISE, SET AUTHOR TO OWNER/LOGGED-IN USER
|
|
elseif( $owner->user_exists && $owner->user_info['user_id']==$media_info['album_user_id'] )
|
|
{
|
|
$author =& $owner;
|
|
}
|
|
elseif( $user->user_exists && $user->user_info['user_id']==$media_info['album_user_id'] )
|
|
{
|
|
$author =& $user;
|
|
}
|
|
|
|
$media_info['media_author'] =& $author;
|
|
|
|
// BACKWARDS COMPAT
|
|
$media_info['media_comments_total'] = $media_info['total_comments'];
|
|
|
|
//$media_info['media_desc'] = str_replace("<br>", "\r\n", $media_info['media_desc']);
|
|
|
|
// CREATE ARRAY OF MEDIA DATA
|
|
$media_array[] = $media_info;
|
|
|
|
unset($media_info, $author);
|
|
}
|
|
|
|
// RETURN ARRAY
|
|
return $media_array;
|
|
}
|
|
|
|
|
|
function album_total($where = "")
|
|
{
|
|
global $database;
|
|
|
|
// BEGIN ALBUM QUERY
|
|
/*$sql = "
|
|
SELECT
|
|
NULL
|
|
FROM
|
|
se_albums
|
|
";*/
|
|
$sql = "
|
|
SELECT
|
|
COUNT(*) as cnt
|
|
FROM
|
|
se_videoalbums
|
|
";
|
|
// IF NO USER ID SPECIFIED, JOIN TO USER TABLE
|
|
if( !$this->user_id ) $sql .= "
|
|
LEFT JOIN
|
|
se_users
|
|
ON
|
|
se_videoalbums.album_user_id=se_users.user_id
|
|
";
|
|
|
|
// ADD WHERE IF NECESSARY
|
|
$sql .= "
|
|
WHERE 1=1
|
|
";
|
|
if( !$this->user_id ){
|
|
|
|
$sql .= "
|
|
AND se_users.user_enabled='1'
|
|
";
|
|
|
|
}
|
|
// ENSURE USER ID IS NOT EMPTY
|
|
if( $this->user_id ) $sql .= "
|
|
AND album_user_id='{$this->user_id}'
|
|
";
|
|
|
|
// INSERT AND IF NECESSARY
|
|
if( !empty($where) ) $sql .= " AND";
|
|
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
|
if( !empty($where) ) $sql .= "
|
|
{$where}
|
|
";
|
|
|
|
$res2=$database->database_query($sql);
|
|
// GET AND RETURN TOTAL PHOTO ALBUMS
|
|
$row= $database->database_fetch_assoc($res2);
|
|
$album_total=$row['cnt'];
|
|
//$album_total = $database->database_num_rows($database->database_query($sql));
|
|
|
|
return (int) $album_total;
|
|
}
|
|
|
|
|
|
|
|
function album_files($album_id = 0, $where = "")
|
|
{
|
|
global $database;
|
|
|
|
// NEW HANDLING
|
|
|
|
|
|
// BEGIN QUERY
|
|
$album_query = "SELECT count(se_videos.video_id) AS total_files";
|
|
|
|
// CONTINUE QUERY
|
|
$album_query .= " FROM se_videos WHERE video_admin_approved=1 AND video_album='".$database->database_real_escape_string($album_id)."' AND (video_is_converted='1') ";
|
|
|
|
// ADD WHERE IF NECESSARY
|
|
// if($this->user_id != 0 || $album_id != 0 || $where != "") { $album_query .= " WHERE"; }
|
|
|
|
// ENSURE USER ID IS NOT EMPTY
|
|
if($this->user_id != 0) { $album_query .= " AND video_user_id='".$this->user_id."'"; }
|
|
|
|
// INSERT AND IF NECESSARY
|
|
//if($this->user_id != 0 && ($album_id != 0 || $where != "")) { $album_query .= " AND"; }
|
|
|
|
// SPECIFY ALBUM IF NECESSARY
|
|
// if($album_id != 0) { $album_query .= " album_id='".$database->database_real_escape_string($album_id)."'"; }
|
|
|
|
// INSERT AND IF NECESSARY
|
|
///if($album_id != 0 && $where != "") { $album_query .= " AND"; }
|
|
|
|
// ADD WHERE CLAUSE
|
|
if($where != "") { $album_query .= " AND $where"; }
|
|
|
|
|
|
|
|
// if($_SERVER['REMOTE_ADDR']=="24.47.141.40"){echo $album_query;}
|
|
// GET AND RETURN TOTAL FILES
|
|
//if($_SERVER['REMOTE_ADDR']!="73.180.162.90"){echo $album_query;}
|
|
$file_info = $database->database_fetch_assoc($database->database_query($album_query));
|
|
return $file_info["total_files"];
|
|
}
|
|
|
|
// END album_files() METHOD
|
|
|
|
// THIS METHOD DELETES A SPECIFIED ALBUM
|
|
// INPUT: $album_id REPRESENTING THE ID OF THE ALBUM TO DELETE
|
|
// OUTPUT:
|
|
function album_delete($album_id) {
|
|
global $database, $url, $user;
|
|
if($user=="")
|
|
{
|
|
$killuser=1;
|
|
$user = new SEUser(Array($this->user_id));
|
|
|
|
}
|
|
|
|
$media = $database->database_query("SELECT video_id FROM se_videos WHERE video_album=".$database->database_real_escape_string($album_id)." ");
|
|
|
|
// LOOP OVER MEDIA
|
|
while($media_info = $database->database_fetch_assoc($media)) {
|
|
$media_path = $url->url_userdir($this->user_id).$media_info["media_id"].".mp4";
|
|
if(file_exists($media_path)) { unlink($media_path); }
|
|
|
|
|
|
|
|
$client = new MyS3Wrapper([
|
|
'region' => 'us-north-1',
|
|
'version' => 'latest',
|
|
'endpoint' => ENDPOINT,
|
|
'credentials' => [
|
|
'key' => AWS_KEY,
|
|
'secret' => AWS_SECRET_KEY
|
|
],
|
|
|
|
// Set the S3 class to use objects.dreamhost.com/bucket
|
|
// instead of bucket.objects.dreamhost.com
|
|
'use_path_style_endpoint' => true
|
|
]);
|
|
try {
|
|
$client->deleteObject(array(
|
|
'Bucket'=>'bateworld',
|
|
'Key' => str_replace("./", "",$media_path),
|
|
|
|
));}catch (Exception $e) {}
|
|
|
|
|
|
$thumb_path = $url->url_userdir($this->user_id).$media_info["media_id"]."_thumb.jpg";
|
|
if(file_exists($thumb_path)) { unlink($thumb_path); }
|
|
|
|
try {
|
|
$client->deleteObject(array(
|
|
'Bucket'=>'bateworld',
|
|
'Key' => str_replace("./", "",$thumb_path),
|
|
|
|
));}catch (Exception $e) {}
|
|
|
|
}
|
|
|
|
$database->database_query("DELETE FROM se_videoalbums, se_videos, se_videocomments, se_videotags, likedvideos USING se_videoalbums LEFT JOIN se_videos ON se_videoalbums.album_id=se_videos.video_album LEFT JOIN se_videocomments ON se_videos.video_id=se_videocomments.videocomment_video_id LEFT JOIN se_videotags ON se_videos.video_id=se_videotags.mediatag_media_id LEFT JOIN likedvideos ON se_videos.video_id=likedvideos.media_id WHERE se_videoalbums.album_id='".$database->database_real_escape_string($album_id)."'");
|
|
|
|
// CALL ALBUM CREATION HOOK
|
|
($hook = SE_Hook::exists('se_album_delete')) ? SE_Hook::call($hook, array()) : NULL;
|
|
|
|
if($killuser=="1")
|
|
{
|
|
$killuser=0;
|
|
$user = "";
|
|
|
|
}
|
|
} // END album_delete() METHOD
|
|
|
|
// END se_video() METHOD
|
|
|
|
|
|
function album_list($start=0, $limit=50, $sort_by = "album_id DESC", $where = "")
|
|
{
|
|
global $database, $user, $owner;
|
|
if($limit==""){$limit=50;}
|
|
// BEGIN QUERY
|
|
$sql = "
|
|
SELECT
|
|
se_videoalbums.*,
|
|
se_videoalbums.album_totalfiles AS total_files,
|
|
se_videoalbums.album_totalspace AS total_space
|
|
";
|
|
|
|
// IF NO USER ID SPECIFIED, RETRIEVE USER INFORMATION
|
|
if( !$this->user_id ) $sql .= ",
|
|
se_users.user_id,
|
|
se_users.user_username,
|
|
se_users.user_photo,
|
|
se_users.user_fname,
|
|
se_users.user_lname
|
|
";
|
|
|
|
// CONTINUE QUERY
|
|
$sql .= "
|
|
FROM
|
|
se_videoalbums
|
|
";
|
|
|
|
// IF NO USER ID SPECIFIED, JOIN TO USER TABLE
|
|
if( !$this->user_id ){$sql .= "
|
|
LEFT JOIN
|
|
se_users
|
|
ON se_videoalbums.album_user_id=se_users.user_id
|
|
";
|
|
|
|
|
|
}
|
|
// ADD WHERE IF NECESSARY
|
|
$sql .= "
|
|
WHERE album_totalfiles!='jijjoijsoijiojsdfiofiosjisjrfoijf'
|
|
";
|
|
if( !$this->user_id ){
|
|
|
|
$sql .= "
|
|
AND se_users.user_enabled='1'
|
|
";
|
|
|
|
}
|
|
// ENSURE USER ID IS NOT EMPTY
|
|
if( $this->user_id ){$sql .= "
|
|
AND album_user_id='{$this->user_id}'
|
|
";
|
|
|
|
}
|
|
// INSERT AND IF NECESSARY
|
|
if( !empty($where) ) $sql .= " AND";
|
|
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
|
if( !empty($where) ) $sql .= "
|
|
{$where}
|
|
";
|
|
|
|
// ADD ORDER, AND LIMIT CLAUSE
|
|
$sql .= "
|
|
ORDER BY
|
|
{$sort_by}
|
|
LIMIT
|
|
{$start}, {$limit}
|
|
";
|
|
//error_log($sql." AAAAAAAAAA");
|
|
|
|
|
|
//echo $sql; //exit;
|
|
// RUN QUERY
|
|
$resource = $database->database_query($sql);
|
|
|
|
// GET ALBUMS INTO AN ARRAY
|
|
$album_array = Array();
|
|
while( $album_info = $database->database_fetch_assoc($resource) )
|
|
{
|
|
// IF NO USER ID SPECIFIED, CREATE OBJECT FOR AUTHOR
|
|
if( !$this->user_id )
|
|
{
|
|
$author = new se_user();
|
|
$author->user_exists = TRUE;
|
|
$author->user_info['user_id'] = $album_info['user_id'];
|
|
$author->user_info['user_username'] = $album_info['user_username'];
|
|
$author->user_info['user_fname'] = $album_info['user_fname'];
|
|
$author->user_info['user_lname'] = $album_info['user_lname'];
|
|
$author->user_info['user_photo'] = $album_info['user_photo'];
|
|
$author->user_displayname();
|
|
}
|
|
|
|
// OTHERWISE, SET AUTHOR TO OWNER/LOGGED-IN USER
|
|
elseif( $owner->user_exists && $owner->user_info['user_id']==$album_info['album_user_id'] )
|
|
{
|
|
$author =& $owner;
|
|
}
|
|
elseif( $user->user_exists && $user->user_info['user_id'] == $album_info['album_user_id'] )
|
|
{
|
|
$author =& $user;
|
|
}
|
|
|
|
// CONVERT SPACE TO MB
|
|
$album_space_mb = ($album_info['total_space'] / 1024) / 1024;
|
|
$album_space_mb = round($album_space_mb, 2);
|
|
|
|
// GET PATH OF ALBUM COVER
|
|
$album_cover_id = 0;
|
|
$album_cover_ext = "";
|
|
|
|
if( $album_info['album_cover'] )
|
|
{
|
|
$album_cover_query = $database->database_query("SELECT video_id, cloud FROM se_videos WHERE video_id='{$album_info['album_cover']}' AND video_album='{$album_info['album_id']}' LIMIT 1");
|
|
|
|
if( $database->database_num_rows($album_cover_query) )
|
|
{
|
|
$album_cover_array = $database->database_fetch_assoc($album_cover_query);
|
|
$album_cover_id = $album_cover_array['video_id'];
|
|
$cloud = $album_cover_array['cloud'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// CREATE ARRAY OF ALBUM DATA
|
|
SE_Language::_preload(user_privacy_levels($album_info['album_privacy']));
|
|
|
|
// SET OTHER INFO
|
|
$album_info['album_author'] =& $author;
|
|
$album_info['album_space'] = $album_space_mb;
|
|
$album_info['album_privacy'] = user_privacy_levels($album_info['album_privacy']);
|
|
$album_info['album_cover_id'] = $album_cover_id;
|
|
$album_info['album_cover_ext'] = $album_cover_ext;
|
|
$album_info['cloud'] = $cloud;
|
|
$album_info['album_files'] = $album_info['total_files'];
|
|
$album_info['video_dir'] = "".$this->video_dir($video_info['video_user_id'], TRUE);
|
|
$album_array[] = $album_info;
|
|
|
|
unset($author, $album_info);
|
|
}
|
|
|
|
|
|
// RETURN ARRAY
|
|
return $album_array;
|
|
}
|
|
|
|
// END album_list() METHOD
|
|
|
|
|
|
function randomvideos($where)
|
|
{
|
|
global $database, $user, $owner;
|
|
|
|
// BEGIN QUERY
|
|
$sql = "
|
|
SELECT
|
|
se_videos.*,
|
|
|
|
";
|
|
|
|
// IF NO USER ID SPECIFIED, RETRIEVE USER INFORMATION
|
|
if( !$this->user_id ) $sql .= "
|
|
se_users.user_id,
|
|
se_users.user_username,
|
|
se_users.user_photo,
|
|
se_users.user_fname,
|
|
se_users.user_lname,
|
|
se_users.user_enabled
|
|
";
|
|
|
|
// CONTINUE QUERY
|
|
$sql .= "
|
|
FROM
|
|
se_videos
|
|
";
|
|
|
|
// IF NO USER ID SPECIFIED, JOIN TO USER TABLE
|
|
if( !$this->user_id ) $sql .= "
|
|
LEFT JOIN
|
|
se_users
|
|
ON se_videos.video_user_id=se_users.user_id
|
|
";
|
|
|
|
// ADD WHERE IF NECESSARY
|
|
//if( !empty($where) || $this->user_id )
|
|
$sql .= "
|
|
WHERE se_users.user_enabled='1'
|
|
";
|
|
|
|
// ENSURE USER ID IS NOT EMPTY
|
|
if( $this->user_id ) $sql .= "
|
|
AND video_user_id='{$this->user_id}'
|
|
";
|
|
|
|
// INSERT AND IF NECESSARY
|
|
//if( $this->user_id && !empty($where) ) $sql .= " AND";
|
|
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
|
if( !empty($where) ) $sql .= "
|
|
AND {$where}
|
|
";
|
|
$rand=rand(1, $this->video_total()-56);
|
|
|
|
//$rand=rand(1, 1000-56);
|
|
if($rand<1){$rand=1;}
|
|
$top=$rand+55;
|
|
// ADD ORDER, AND LIMIT CLAUSE
|
|
$sql .= "
|
|
ORDER BY
|
|
video_id
|
|
LIMIT
|
|
$rand, 56
|
|
";
|
|
|
|
// RUN QUERY
|
|
$resource = $database->database_query($sql);
|
|
|
|
// GET ALBUMS INTO AN ARRAY
|
|
|
|
|
|
$video_array = Array();
|
|
while($video_info = $database->database_fetch_assoc($resource))
|
|
{
|
|
// IF NO USER ID SPECIFIED, CREATE OBJECT FOR AUTHOR
|
|
if($this->user_id == 0)
|
|
{
|
|
$author = new se_user();
|
|
$author->user_exists = 1;
|
|
$author->user_info['user_id'] = $video_info['user_id'];
|
|
$author->user_info['user_username'] = $video_info['user_username'];
|
|
$author->user_info['user_fname'] = $video_info['user_fname'];
|
|
$author->user_info['user_lname'] = $video_info['user_lname'];
|
|
$author->user_info['user_photo'] = $video_info['user_photo'];
|
|
$author->user_info['user_enabled'] = $video_info['user_enabled'];
|
|
$author->user_displayname();
|
|
}
|
|
|
|
// OTHERWISE, SET AUTHOR TO OWNER/LOGGED-IN USER
|
|
elseif($owner->user_exists != 0 && $owner->user_info['user_id'] == $video_info['video_user_id'])
|
|
{
|
|
$author = $owner;
|
|
}
|
|
elseif($user->user_exists != 0 && $user->user_info['user_id'] == $video_info['video_user_id'])
|
|
{
|
|
$author = $user;
|
|
}
|
|
|
|
// SET AUTHOR AND DIRECTORY
|
|
$video_info['video_author'] = $author;
|
|
$video_info['video_dir'] = str_replace("./", "", $this->video_dir($video_info['video_user_id'], TRUE));
|
|
|
|
|
|
// CHECK FOR THUMBNAIL
|
|
$video_info['video_thumb'] = file_exists($video_info['video_dir'].$video_info['video_id']."_thumb.jpg");
|
|
|
|
// SET UP DURATION
|
|
$minutes = floor($video_info['video_duration_in_sec']/60);
|
|
$seconds = $video_info['video_duration_in_sec']-60*$minutes;
|
|
$video_info['video_duration_in_min'] = sprintf("%02d:%02d", $minutes, $seconds);
|
|
|
|
// SET UP RATING
|
|
$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'];
|
|
|
|
// CREATE ARRAY OF VIDEO DATA
|
|
$video_array[] = $video_info;
|
|
}
|
|
//$album_array[] =& $signup_user;
|
|
unset($author, $album_info, $signup_user);
|
|
|
|
//if(SE_DEBUG)var_dump($video_info);
|
|
|
|
// RETURN ARRAY
|
|
return $video_array;
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
// THIS METHOD RETURNS THE TOTAL NUMBER OF VIDEOS
|
|
//
|
|
// INPUT:
|
|
// $where (OPTIONAL) REPRESENTING ADDITIONAL THINGS TO INCLUDE IN THE WHERE CLAUSE
|
|
//
|
|
// OUTPUT:
|
|
// AN INTEGER REPRESENTING THE NUMBER OF VIDEOS
|
|
//
|
|
|
|
function video_tag_total($where = "")
|
|
{
|
|
global $database, $user;
|
|
|
|
// BEGIN VIDEO QUERY
|
|
$video_query = "SELECT video_id FROM se_videotags, se_videos";
|
|
|
|
// IF NO USER ID SPECIFIED, JOIN TO USER TABLE
|
|
$video_query .= " LEFT JOIN se_users ON se_videos.video_user_id=se_users.user_id";
|
|
|
|
// ADD WHERE IF NECESSARY
|
|
//$video_query .= " WHERE (video_uploaded=1 OR video_admin_approved=1) ";
|
|
$video_query .= " WHERE video_admin_approved=1 ";
|
|
// ENSURE USER ID IS NOT EMPTY
|
|
|
|
$video_query .= "AND se_users.user_enabled='1' AND se_videotags.mediatag_media_id=se_videos.video_id AND mediatag_user_id='".$user->user_info["user_id"]."'";
|
|
|
|
|
|
|
|
// INSERT AND IF NECESSARY
|
|
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
|
if($where != "") { $video_query .= " AND $where"; }
|
|
|
|
// GET AND RETURN TOTAL VIDEOS
|
|
$video_total = $database->database_num_rows($database->database_query($video_query));
|
|
return $video_total;
|
|
}
|
|
|
|
|
|
function video_total($where = "", $showdisabled=0)
|
|
{
|
|
global $database;
|
|
|
|
// BEGIN VIDEO QUERY
|
|
$video_query = "SELECT video_id FROM se_videos ";
|
|
|
|
// IF NO USER ID SPECIFIED, JOIN TO USER TABLE
|
|
if($this->user_id == 0) { $video_query .= " LEFT JOIN se_users ON se_videos.video_user_id=se_users.user_id"; }
|
|
|
|
// ADD WHERE IF NECESSARY
|
|
//$video_query .= " WHERE (video_uploaded=1 OR video_admin_approved=1) ";
|
|
$video_query .= " WHERE video_admin_approved=1 AND video_uploaded=1 ";
|
|
// ENSURE USER ID IS NOT EMPTY
|
|
if($this->user_id != 0) { $video_query .= "AND video_user_id='{$this->user_id}'"; }
|
|
else{
|
|
if($showdisabled==0){
|
|
$video_query .= "AND se_users.user_enabled='1' ";
|
|
}
|
|
}
|
|
|
|
// INSERT AND IF NECESSARY
|
|
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
|
if($where != "") { $video_query .= " AND $where"; }
|
|
|
|
|
|
// GET AND RETURN TOTAL VIDEOS
|
|
$video_total = $database->database_num_rows($database->database_query($video_query));
|
|
|
|
|
|
return $video_total;
|
|
}
|
|
|
|
// END video_total() METHOD
|
|
|
|
function video_album_total($album_id, $where = "")
|
|
{
|
|
global $database;
|
|
|
|
// BEGIN VIDEO QUERY
|
|
$video_query = "SELECT video_id FROM se_videos";
|
|
|
|
// IF NO USER ID SPECIFIED, JOIN TO USER TABLE
|
|
if($this->user_id == 0) { $video_query .= " LEFT JOIN se_users ON se_videos.video_user_id=se_users.user_id"; }
|
|
|
|
// ADD WHERE IF NECESSARY
|
|
//$video_query .= " WHERE (video_uploaded=1 OR video_admin_approved=1) ";
|
|
$video_query .= " WHERE video_admin_approved=1 AND video_album=".$database->database_real_escape_string($album_id)." ";
|
|
// ENSURE USER ID IS NOT EMPTY
|
|
if($this->user_id != 0) { $video_query .= "AND video_user_id='{$this->user_id}'"; }
|
|
else{
|
|
$video_query .= "AND se_users.user_enabled='1' ";
|
|
|
|
}
|
|
|
|
// INSERT AND IF NECESSARY
|
|
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
|
if($where != "") { $video_query .= " AND $where"; }
|
|
|
|
// GET AND RETURN TOTAL VIDEOS
|
|
$video_total = $database->database_num_rows($database->database_query($video_query));
|
|
return $video_total;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
// THIS METHOD RETURNS AN ARRAY OF VIDEOS
|
|
//
|
|
// INPUT:
|
|
// $start REPRESENTING THE VIDEO TO START WITH
|
|
// $limit REPRESENTING THE NUMBER OF VIDEOS TO RETURN
|
|
// $sort_by (OPTIONAL) REPRESENTING THE ORDER BY CLAUSE
|
|
// $where (OPTIONAL) REPRESENTING ADDITIONAL THINGS TO INCLUDE IN THE WHERE CLAUSE
|
|
// $details (OPTIONAL) REPRESENTING WHETHER TO GET DETAILS LIKE TOTAL COMMENTS
|
|
//
|
|
// OUTPUT:
|
|
// AN ARRAY OF VIDEOS
|
|
//
|
|
function video_list_test($start, $limit, $sort_by = "video_id DESC", $where = "", $details = 0)
|
|
{
|
|
global $database, $user, $owner;
|
|
|
|
// BEGIN QUERY
|
|
$video_query = "SELECT se_videos.*";
|
|
|
|
// GET DETAILS
|
|
if($details) { $video_query .= ", count(se_videocomments.videocomment_id) AS total_comments"; }
|
|
|
|
// IF NO USER ID SPECIFIED, RETRIEVE USER INFORMATION
|
|
if($this->user_id == 0) { $video_query .= ", se_users.user_id, se_users.user_username, se_users.user_photo, se_users.user_fname, se_users.user_lname"; }
|
|
|
|
// CONTINUE QUERY
|
|
$video_query .= " FROM se_videos";
|
|
|
|
// GET DETAILS
|
|
if($details) { $video_query .= " LEFT JOIN se_videocomments ON se_videos.video_id=se_videocomments.videocomment_video_id"; }
|
|
|
|
// IF NO USER ID SPECIFIED, JOIN TO USER TABLE
|
|
if($this->user_id == 0) { $video_query .= " LEFT JOIN se_users ON se_videos.video_user_id=se_users.user_id"; }
|
|
|
|
// ADD WHERE IF NECESSARY
|
|
// $video_query .= " WHERE (video_uploaded=1 OR video_admin_approved=1)";
|
|
$video_query .= " WHERE video_admin_approved=1 AND se_users.user_enabled='1'";
|
|
|
|
// ENSURE USER ID IS NOT EMPTY
|
|
if($this->user_id != 0) { $video_query .= "AND video_user_id='{$this->user_id}'"; }
|
|
|
|
// INSERT AND IF NECESSARY
|
|
//$video_query .= " AND";
|
|
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
|
if($where != "") { $video_query .= " AND $where"; }
|
|
|
|
// ADD GROUP BY, ORDER, AND LIMIT CLAUSE
|
|
$video_query .= " GROUP BY video_id ORDER BY $sort_by LIMIT $start, $limit";
|
|
|
|
// RUN QUERY
|
|
$videos = $database->database_query($video_query);
|
|
|
|
// GET VIDEOS INTO AN ARRAY
|
|
$video_array = Array();
|
|
while($video_info = $database->database_fetch_assoc($videos))
|
|
{
|
|
// IF NO USER ID SPECIFIED, CREATE OBJECT FOR AUTHOR
|
|
if($this->user_id == 0)
|
|
{
|
|
$author = new se_user();
|
|
$author->user_exists = 1;
|
|
$author->user_info['user_id'] = $video_info['user_id'];
|
|
$author->user_info['user_username'] = $video_info['user_username'];
|
|
$author->user_info['user_fname'] = $video_info['user_fname'];
|
|
$author->user_info['user_lname'] = $video_info['user_lname'];
|
|
$author->user_info['user_photo'] = $video_info['user_photo'];
|
|
$author->user_displayname();
|
|
}
|
|
|
|
// OTHERWISE, SET AUTHOR TO OWNER/LOGGED-IN USER
|
|
elseif($owner->user_exists != 0 && $owner->user_info['user_id'] == $video_info['video_user_id'])
|
|
{
|
|
$author = $owner;
|
|
}
|
|
elseif($user->user_exists != 0 && $user->user_info['user_id'] == $video_info['video_user_id'])
|
|
{
|
|
$author = $user;
|
|
}
|
|
|
|
// SET AUTHOR AND DIRECTORY
|
|
$video_info['video_author'] = $author;
|
|
//$video_info['video_dir'] = ".".$this->video_dir($video_info['video_user_id'], TRUE);
|
|
$video_info['video_dir'] = str_replace("./", "", $this->video_dir($video_info['video_user_id'], TRUE));
|
|
// CHECK FOR THUMBNAIL
|
|
$video_info['video_thumb'] = file_exists($video_info['video_dir'].$video_info['video_id']."_thumb.jpg");
|
|
|
|
// SET UP DURATION
|
|
$minutes = floor($video_info['video_duration_in_sec']/60);
|
|
$seconds = $video_info['video_duration_in_sec']-60*$minutes;
|
|
$video_info['video_duration_in_min'] = sprintf("%02d:%02d", $minutes, $seconds);
|
|
|
|
// SET UP RATING
|
|
$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'];
|
|
|
|
// CREATE ARRAY OF VIDEO DATA
|
|
$video_array[] = $video_info;
|
|
}
|
|
|
|
// RETURN ARRAY
|
|
return $video_array;
|
|
}
|
|
function eventuser_tag_video_total($event_id)
|
|
{
|
|
global $database, $user;
|
|
|
|
// BEGIN VIDEO QUERY
|
|
$video_query = "SELECT video_id FROM se_eventvideotags, se_event_videos";
|
|
|
|
// IF NO USER ID SPECIFIED, JOIN TO USER TABLE
|
|
if($this->user_id == 0) { $video_query .= " LEFT JOIN se_users ON se_event_videos.video_user_id=se_users.user_id"; }
|
|
|
|
$video_query .= " WHERE se_eventvideotags.mediatag_media_id=se_event_videos.video_id AND mediatag_user_id='".$user->user_info["user_id"]."' AND video_is_converted!= -1 AND video_uploaded=1";
|
|
// ADD WHERE IF NECESSARY
|
|
if($where != "" || $this->user_id != 0) { }
|
|
|
|
// ENSURE USER ID IS NOT EMPTY
|
|
//if($this->user_id != 0) { $video_query .= " video_user_id='{$this->user_id}'"; }
|
|
|
|
// INSERT AND IF NECESSARY
|
|
if($this->user_id != 0 && $where != "") { $video_query .= " AND"; }
|
|
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
|
if($where != "") { $video_query .= " $where";
|
|
|
|
}
|
|
|
|
// GET AND RETURN TOTAL VIDEOS
|
|
$video_total = $database->database_num_rows($database->database_query($video_query));
|
|
return $video_total;
|
|
}
|
|
|
|
function eventuser_tag_video_list($start, $limit, $sort_by = "video_id DESC", $event_id, $details = 0)
|
|
{
|
|
global $database, $user, $owner;
|
|
|
|
$event = new se_event($user->user_info['user_id'], $event_id);
|
|
// BEGIN QUERY
|
|
$video_query = "SELECT se_event_videos.*";
|
|
|
|
// GET DETAILS
|
|
|
|
// IF NO USER ID SPECIFIED, RETRIEVE USER INFORMATION
|
|
|
|
// CONTINUE QUERY
|
|
$video_query .= " FROM se_eventvideotags, se_event_videos";
|
|
|
|
// GET DETAILS
|
|
|
|
|
|
// IF NO USER ID SPECIFIED, JOIN TO USER TABLE
|
|
|
|
|
|
// ADD WHERE IF NECESSARY
|
|
//if($where != "" || $this->user_id != 0) { }
|
|
$video_query .= " WHERE se_eventvideotags.mediatag_media_id=se_event_videos.video_id AND mediatag_user_id='".$user->user_info["user_id"]."' AND video_is_converted!= -1 AND video_uploaded=1";
|
|
// ENSURE USER ID IS NOT EMPTY
|
|
//if($this->user_id != 0) { $video_query .= " video_user_id='{$this->user_id}'"; }
|
|
|
|
// INSERT AND IF NECESSARY
|
|
if($this->user_id != 0 && $where != "") { $video_query .= " AND"; }
|
|
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
|
if($where != "") { $video_query .= " $where"; }
|
|
|
|
// ADD event BY, ORDER, AND LIMIT CLAUSE
|
|
$video_query .= " ORDER BY $sort_by";// LIMIT $start, $limit";
|
|
if(SE_DEBUG1){
|
|
//echo $video_query;
|
|
}// RUN QUERY
|
|
$videos = $database->database_query($video_query);
|
|
|
|
// GET VIDEOS INTO AN ARRAY
|
|
$video_array = Array();
|
|
while($video_info = $database->database_fetch_assoc($videos))
|
|
{
|
|
|
|
$tags="";
|
|
$checkusers=$database->database_query("SELECT * FROM se_eventvideotags WHERE mediatag_media_id='".$database->database_real_escape_string($video_info['video_id'])."'");
|
|
|
|
|
|
while($rowusers=$database->database_fetch_array($checkusers))
|
|
{
|
|
|
|
$thisuser=$database->database_query("SELECT user_username FROM se_users WHERE user_id='".$database->database_real_escape_string($rowusers['mediatag_user_id'])."'");
|
|
$rowuser=$database->database_fetch_array($thisuser);
|
|
|
|
if($tags==""){
|
|
$tags=$rowuser["user_username"]."<br>";}
|
|
else{$tags.=$rowuser["user_username"]."<br>";}
|
|
}
|
|
$video_info['media_tags']=$tags;
|
|
// IF NO USER ID SPECIFIED, CREATE OBJECT FOR AUTHOR
|
|
if($this->user_id == 0)
|
|
{
|
|
$author = new se_user();
|
|
$author->user_exists = 1;
|
|
$author->user_info['user_id'] = $video_info['user_id'];
|
|
$author->user_info['user_username'] = $video_info['user_username'];
|
|
$author->user_info['user_fname'] = $video_info['user_fname'];
|
|
$author->user_info['user_lname'] = $video_info['user_lname'];
|
|
$author->user_info['user_photo'] = $video_info['user_photo'];
|
|
$author->user_displayname();
|
|
}
|
|
|
|
// OTHERWISE, SET AUTHOR TO OWNER/LOGGED-IN USER
|
|
elseif($owner->user_exists != 0 && $owner->user_info['user_id'] == $video_info['video_user_id'])
|
|
{
|
|
$author = $owner;
|
|
}
|
|
elseif($user->user_exists != 0 && $user->user_info['user_id'] == $video_info['video_user_id'])
|
|
{
|
|
$author = $user;
|
|
}
|
|
|
|
// SET AUTHOR AND DIRECTORY
|
|
$video_info['video_author'] = $author;
|
|
//$video_info['video_dir'] = ".".$this->video_dir($video_info['video_user_id'], TRUE);
|
|
$video_info['video_dir'] = str_replace("./", "", $this->video_dir($video_info['video_user_id'], TRUE));
|
|
// CHECK FOR THUMBNAIL
|
|
$video_info['video_thumb'] = file_exists(event_dir($video_info['video_event_id'])."video_".$video_info['video_id']."_thumb.jpg");
|
|
if( $video_info['video_thumb']){
|
|
$video_info['thumbfolder']=event_dir($video_info['video_event_id'])."video_".$video_info['video_id']."_thumb.jpg";
|
|
}
|
|
//echo $event->event_dir($event_id).$video_info['video_id']."_thumb.jpg";
|
|
// SET UP DURATION
|
|
$minutes = floor($video_info['video_duration_in_sec']/60);
|
|
$seconds = $video_info['video_duration_in_sec']-60*$minutes;
|
|
$video_info['video_duration_in_min'] = sprintf("%02d:%02d", $minutes, $seconds);
|
|
|
|
// SET UP RATING
|
|
$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'];
|
|
|
|
// CREATE ARRAY OF VIDEO DATA
|
|
$video_array[] = $video_info;
|
|
}
|
|
|
|
// RETURN ARRAY
|
|
return $video_array;
|
|
}
|
|
function groupuser_tag_video_total($group_id)
|
|
{
|
|
global $database, $user;
|
|
|
|
// BEGIN VIDEO QUERY
|
|
$video_query = "SELECT video_id FROM se_groupvideotags, se_group_videos";
|
|
|
|
// IF NO USER ID SPECIFIED, JOIN TO USER TABLE
|
|
if($this->user_id == 0) { $video_query .= " LEFT JOIN se_users ON se_group_videos.video_user_id=se_users.user_id"; }
|
|
|
|
$video_query .= " WHERE se_groupvideotags.mediatag_media_id=se_group_videos.video_id AND mediatag_user_id='".$user->user_info["user_id"]."' AND video_is_converted!= -1 AND video_uploaded=1";
|
|
// ADD WHERE IF NECESSARY
|
|
if($where != "" || $this->user_id != 0) { }
|
|
|
|
// ENSURE USER ID IS NOT EMPTY
|
|
//if($this->user_id != 0) { $video_query .= " video_user_id='{$this->user_id}'"; }
|
|
|
|
// INSERT AND IF NECESSARY
|
|
if($this->user_id != 0 && $where != "") { $video_query .= " AND"; }
|
|
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
|
if($where != "") { $video_query .= " $where";
|
|
|
|
}
|
|
|
|
// GET AND RETURN TOTAL VIDEOS
|
|
$video_total = $database->database_num_rows($database->database_query($video_query));
|
|
return $video_total;
|
|
}
|
|
|
|
function groupuser_tag_video_list($start, $limit, $sort_by = "video_id DESC", $group_id, $details = 0)
|
|
{
|
|
global $database, $user, $owner;
|
|
|
|
$group = new se_group($user->user_info['user_id'], $group_id);
|
|
// BEGIN QUERY
|
|
$video_query = "SELECT se_group_videos.*";
|
|
|
|
// GET DETAILS
|
|
|
|
// IF NO USER ID SPECIFIED, RETRIEVE USER INFORMATION
|
|
|
|
// CONTINUE QUERY
|
|
$video_query .= " FROM se_groupvideotags, se_group_videos";
|
|
|
|
// GET DETAILS
|
|
|
|
|
|
// IF NO USER ID SPECIFIED, JOIN TO USER TABLE
|
|
|
|
|
|
// ADD WHERE IF NECESSARY
|
|
//if($where != "" || $this->user_id != 0) { }
|
|
$video_query .= " WHERE se_groupvideotags.mediatag_media_id=se_group_videos.video_id AND mediatag_user_id='".$user->user_info["user_id"]."' AND video_is_converted!= -1 AND video_uploaded=1";
|
|
// ENSURE USER ID IS NOT EMPTY
|
|
//if($this->user_id != 0) { $video_query .= " video_user_id='{$this->user_id}'"; }
|
|
|
|
// INSERT AND IF NECESSARY
|
|
if($this->user_id != 0 && $where != "") { $video_query .= " AND"; }
|
|
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
|
if($where != "") { $video_query .= " $where"; }
|
|
|
|
// ADD GROUP BY, ORDER, AND LIMIT CLAUSE
|
|
$video_query .= " ORDER BY $sort_by";// LIMIT $start, $limit";
|
|
if(SE_DEBUG1){
|
|
//echo $video_query;
|
|
}// RUN QUERY
|
|
$videos = $database->database_query($video_query);
|
|
|
|
// GET VIDEOS INTO AN ARRAY
|
|
$video_array = Array();
|
|
while($video_info = $database->database_fetch_assoc($videos))
|
|
{
|
|
|
|
$tags="";
|
|
$checkusers=$database->database_query("SELECT * FROM se_groupvideotags WHERE mediatag_media_id='".$database->database_real_escape_string($video_info['video_id'])."'");
|
|
|
|
|
|
while($rowusers=$database->database_fetch_array($checkusers))
|
|
{
|
|
|
|
$thisuser=$database->database_query("SELECT user_username FROM se_users WHERE user_id='".$database->database_real_escape_string($rowusers['mediatag_user_id'])."'");
|
|
$rowuser=$database->database_fetch_array($thisuser);
|
|
|
|
if($tags==""){
|
|
$tags=$rowuser["user_username"]."<br>";}
|
|
else{$tags.=$rowuser["user_username"]."<br>";}
|
|
}
|
|
$video_info['media_tags']=$tags;
|
|
// IF NO USER ID SPECIFIED, CREATE OBJECT FOR AUTHOR
|
|
if($this->user_id == 0)
|
|
{
|
|
$author = new se_user();
|
|
$author->user_exists = 1;
|
|
$author->user_info['user_id'] = $video_info['user_id'];
|
|
$author->user_info['user_username'] = $video_info['user_username'];
|
|
$author->user_info['user_fname'] = $video_info['user_fname'];
|
|
$author->user_info['user_lname'] = $video_info['user_lname'];
|
|
$author->user_info['user_photo'] = $video_info['user_photo'];
|
|
$author->user_displayname();
|
|
}
|
|
|
|
// OTHERWISE, SET AUTHOR TO OWNER/LOGGED-IN USER
|
|
elseif($owner->user_exists != 0 && $owner->user_info['user_id'] == $video_info['video_user_id'])
|
|
{
|
|
$author = $owner;
|
|
}
|
|
elseif($user->user_exists != 0 && $user->user_info['user_id'] == $video_info['video_user_id'])
|
|
{
|
|
$author = $user;
|
|
}
|
|
|
|
// SET AUTHOR AND DIRECTORY
|
|
$video_info['video_author'] = $author;
|
|
//$video_info['video_dir'] = ".".$this->video_dir($video_info['video_user_id'], TRUE);
|
|
$video_info['video_dir'] = str_replace("./", "", $this->video_dir($video_info['video_user_id'], TRUE));
|
|
// CHECK FOR THUMBNAIL
|
|
$video_info['video_thumb'] = file_exists(group_dir($video_info['video_group_id'])."video_".$video_info['video_id']."_thumb.jpg");
|
|
if( $video_info['video_thumb']){
|
|
$video_info['thumbfolder']=group_dir($video_info['video_group_id'])."video_".$video_info['video_id']."_thumb.jpg";
|
|
}
|
|
//echo $group->group_dir($group_id).$video_info['video_id']."_thumb.jpg";
|
|
// SET UP DURATION
|
|
$minutes = floor($video_info['video_duration_in_sec']/60);
|
|
$seconds = $video_info['video_duration_in_sec']-60*$minutes;
|
|
$video_info['video_duration_in_min'] = sprintf("%02d:%02d", $minutes, $seconds);
|
|
|
|
// SET UP RATING
|
|
$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'];
|
|
|
|
// CREATE ARRAY OF VIDEO DATA
|
|
$video_array[] = $video_info;
|
|
}
|
|
|
|
// RETURN ARRAY
|
|
return $video_array;
|
|
}
|
|
|
|
function video_tag_list($start, $limit, $sort_by = "video_id DESC", $where = "", $details = 0)
|
|
{
|
|
global $database, $user, $owner;
|
|
|
|
|
|
|
|
// BEGIN QUERY
|
|
$video_query = "SELECT se_videos.*";
|
|
|
|
// GET DETAILS
|
|
if($details) { $video_query .= ", count(se_videocomments.videocomment_id) AS total_comments"; }
|
|
|
|
// IF NO USER ID SPECIFIED, RETRIEVE USER INFORMATION
|
|
$video_query .= ", se_users.user_id, se_users.user_username, se_users.user_photo, se_users.user_fname, se_users.user_lname";
|
|
|
|
// CONTINUE QUERY
|
|
$video_query .= " FROM se_videotags, se_videos ";
|
|
|
|
// GET DETAILS
|
|
if($details) { $video_query .= " LEFT JOIN se_videocomments ON se_videos.video_id=se_videocomments.videocomment_video_id"; }
|
|
|
|
// IF NO USER ID SPECIFIED, JOIN TO USER TABLE
|
|
$video_query .= " LEFT JOIN se_users ON se_videos.video_user_id=se_users.user_id";
|
|
|
|
// ADD WHERE IF NECESSARY
|
|
// $video_query .= " WHERE (video_uploaded=1 OR video_admin_approved=1)";
|
|
$video_query .= " WHERE se_videotags.mediatag_media_id=se_videos.video_id AND mediatag_user_id='".$user->user_info["user_id"]."' AND video_admin_approved=1 ";
|
|
|
|
// ENSURE USER ID IS NOT EMPTY
|
|
|
|
$video_query .= "AND se_users.user_enabled='1' ";
|
|
|
|
|
|
|
|
// INSERT AND IF NECESSARY
|
|
//$video_query .= " AND";
|
|
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
|
if($where != "") { $video_query .= " AND $where"; }
|
|
|
|
// ADD GROUP BY, ORDER, AND LIMIT CLAUSE
|
|
$video_query .= " GROUP BY video_id ORDER BY $sort_by LIMIT $start, $limit";
|
|
|
|
// RUN QUERY
|
|
$videos = $database->database_query($video_query);
|
|
|
|
// GET VIDEOS INTO AN ARRAY
|
|
$video_array = Array();
|
|
while($video_info = $database->database_fetch_assoc($videos))
|
|
{
|
|
|
|
$tags="";
|
|
$checkusers=$database->database_query("SELECT * FROM se_videotags WHERE mediatag_media_id='".$database->database_real_escape_string($video_info['video_id'])."'");
|
|
|
|
|
|
while($rowusers=$database->database_fetch_array($checkusers))
|
|
{
|
|
|
|
$thisuser=$database->database_query("SELECT user_username FROM se_users WHERE user_id='".$database->database_real_escape_string($rowusers['mediatag_user_id'])."'");
|
|
$rowuser=$database->database_fetch_array($thisuser);
|
|
|
|
if($tags==""){
|
|
$tags=$rowuser["user_username"]."<br>";}
|
|
else{$tags.=$rowuser["user_username"]."<br>";}
|
|
}
|
|
$video_info['media_tags']=$tags;
|
|
|
|
// IF NO USER ID SPECIFIED, CREATE OBJECT FOR AUTHOR
|
|
|
|
$author = new se_user();
|
|
$author->user_exists = 1;
|
|
$author->user_info['user_id'] = $video_info['user_id'];
|
|
$author->user_info['user_username'] = $video_info['user_username'];
|
|
$author->user_info['user_fname'] = $video_info['user_fname'];
|
|
$author->user_info['user_lname'] = $video_info['user_lname'];
|
|
$author->user_info['user_photo'] = $video_info['user_photo'];
|
|
$author->user_displayname();
|
|
|
|
|
|
|
|
|
|
// SET AUTHOR AND DIRECTORY
|
|
$video_info['video_author'] = $author;
|
|
//$video_info['video_dir'] = ".".$this->video_dir($video_info['video_user_id'], TRUE);
|
|
$video_info['video_dir'] = str_replace("./", "", $this->video_dir($video_info['video_user_id'], TRUE));
|
|
// CHECK FOR THUMBNAIL
|
|
$video_info['video_thumb'] = file_exists($video_info['video_dir'].$video_info['video_id']."_thumb.jpg");
|
|
|
|
// SET UP DURATION
|
|
$minutes = floor($video_info['video_duration_in_sec']/60);
|
|
$seconds = $video_info['video_duration_in_sec']-60*$minutes;
|
|
$video_info['video_duration_in_min'] = sprintf("%02d:%02d", $minutes, $seconds);
|
|
|
|
// SET UP RATING
|
|
$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'];
|
|
|
|
// CREATE ARRAY OF VIDEO DATA
|
|
$video_array[] = $video_info;
|
|
|
|
}
|
|
|
|
// RETURN ARRAY
|
|
return $video_array;
|
|
}
|
|
function video_list_all_new($start, $limit, $sort_by = "video_id DESC", $where = "", $details = 0, $album_id=0)
|
|
{
|
|
global $database, $user, $owner;
|
|
|
|
|
|
|
|
// BEGIN QUERY
|
|
$video_query = "(SELECT SQL_BIG_RESULT se_videos.video_id, '' as video_group_id, video_duration_in_sec, video_title, video_datecreated, video_views, video_cache_rating_weighted, video_user_id ";
|
|
|
|
// GET DETAILS
|
|
//if($details) { $video_query .= ", count(se_videocomments.videocomment_id) AS total_comments"; }
|
|
|
|
// IF NO USER ID SPECIFIED, RETRIEVE USER INFORMATION
|
|
if($this->user_id == 0) { $video_query .= ", se_users.user_id, se_users.user_username "; }
|
|
|
|
// CONTINUE QUERY
|
|
$video_query .= " FROM se_videos";
|
|
|
|
// GET DETAILS
|
|
//if($details) { $video_query .= " LEFT JOIN se_videocomments ON se_videos.video_id=se_videocomments.videocomment_video_id"; }
|
|
|
|
// IF NO USER ID SPECIFIED, JOIN TO USER TABLE
|
|
if($this->user_id == 0) { $video_query .= " LEFT JOIN se_users ON se_videos.video_user_id=se_users.user_id"; }
|
|
|
|
// ADD WHERE IF NECESSARY
|
|
// $video_query .= " WHERE (video_uploaded=1 OR video_admin_approved=1)";
|
|
$video_query .= " WHERE video_admin_approved=1 ";
|
|
|
|
// ENSURE USER ID IS NOT EMPTY
|
|
if($this->user_id != 0) { $video_query .= "AND video_user_id='{$this->user_id}' "; }
|
|
else{
|
|
$video_query .= "AND se_users.user_enabled='1' ";
|
|
|
|
}
|
|
|
|
// INSERT AND IF NECESSARY
|
|
//$video_query .= " AND";
|
|
|
|
|
|
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
|
if($where != "") { $video_query .= " AND $where"; }
|
|
|
|
|
|
$video_query .= ") UNION ";
|
|
|
|
$video_query.="(SELECT se_group_videos.video_id, video_group_id, video_duration_in_sec, video_title, video_datecreated, video_views, video_cache_rating_weighted, video_user_id ";
|
|
|
|
if($this->user_id == 0) { $video_query .= ", se_users.user_id, se_users.user_username "; }
|
|
|
|
$video_query .= " FROM se_groups, `se_group_videos` ";
|
|
if($this->user_id == 0) { $video_query .= " LEFT JOIN se_users ON se_group_videos.video_user_id=se_users.user_id "; }
|
|
$video_query .= " WHERE `video_group_id`=group_id AND approved=1
|
|
AND video_admin_approved=1 AND se_users.user_enabled='1'
|
|
AND (se_group_videos.video_user_id='".$user->user_info["user_id"]."' OR se_groups.group_privacy=127))";
|
|
|
|
|
|
$video_query.="(SELECT se_event_videos.video_id, video_event_id, video_duration_in_sec, video_title, video_datecreated, video_views, video_cache_rating_weighted, video_user_id ";
|
|
|
|
if($this->user_id == 0) { $video_query .= ", se_users.user_id, se_users.user_username "; }
|
|
|
|
$video_query .= " FROM se_events, `se_event_videos` ";
|
|
if($this->user_id == 0) { $video_query .= " LEFT JOIN se_users ON se_event_videos.video_user_id=se_users.user_id "; }
|
|
$video_query .= " WHERE `video_event_id`=event_id AND approved=1
|
|
AND video_admin_approved=1 AND se_users.user_enabled='1'
|
|
AND (se_event_videos.video_user_id='".$user->user_info["user_id"]."' OR se_events.event_privacy=127))";
|
|
|
|
// ADD GROUP BY, ORDER, AND LIMIT CLAUSE
|
|
$video_query .= " ORDER BY $sort_by LIMIT $start, $limit";
|
|
|
|
//SELECT * FROM `se_group_videos`, se_groups WHERE `video_group_id`=group_id AND (CASE WHEN se_group_videos.video_user_id='7653' THEN TRUE WHEN (se_groups.group_privacy=12) THEN TRUE ELSE FALSE END);
|
|
/*
|
|
(SELECT SQL_BIG_RESULT se_videos.*, count(se_videocomments.videocomment_id) AS total_comments, se_users.user_id, se_users.user_username, se_users.user_photo, se_users.user_fname, se_users.user_lname FROM se_videos LEFT JOIN se_videocomments ON se_videos.video_id=se_videocomments.videocomment_video_id LEFT JOIN se_users ON se_videos.video_user_id=se_users.user_id WHERE video_admin_approved=1 AND se_users.user_enabled='1' AND video_search='1' AND approved=1 AND shadowbanned=0 AND se_videos.video_is_converted='1' AND (CASE WHEN se_videos.video_user_id='7653' THEN TRUE WHEN ((se_videos.video_privacy & @SE_PRIVACY_FRIEND) AND (SELECT TRUE FROM se_friends WHERE friend_user_id1=se_videos.video_user_id AND friend_user_id2='7653' AND friend_status='1' LIMIT 1)) THEN TRUE WHEN ((se_videos.video_privacy & @SE_PRIVACY_FRIEND2)) THEN TRUE ELSE FALSE END) GROUP BY video_id)
|
|
UNION
|
|
|
|
(SELECT * FROM `se_group_videos`, se_groups WHERE `video_group_id`=group_id
|
|
|
|
AND (CASE WHEN se_group_videos.video_user_id='7653' THEN TRUE WHEN (se_groups.group_privacy=12) THEN TRUE ELSE FALSE END))*/
|
|
// RUN QUERY
|
|
$videos = $database->database_query($video_query);
|
|
|
|
// GET VIDEOS INTO AN ARRAY
|
|
$video_array = Array();
|
|
while($video_info = $database->database_fetch_assoc($videos))
|
|
{
|
|
|
|
|
|
|
|
// IF NO USER ID SPECIFIED, CREATE OBJECT FOR AUTHOR
|
|
if($this->user_id == 0)
|
|
{
|
|
$author = new se_user();
|
|
$author->user_exists = 1;
|
|
$author->user_info['user_id'] = $video_info['user_id'];
|
|
$author->user_info['user_username'] = $video_info['user_username'];
|
|
$author->user_info['user_fname'] = $video_info['user_fname'];
|
|
|
|
$author->user_displayname();
|
|
}
|
|
|
|
// OTHERWISE, SET AUTHOR TO OWNER/LOGGED-IN USER
|
|
elseif($owner->user_exists != 0 && $owner->user_info['user_id'] == $video_info['video_user_id'])
|
|
{
|
|
$author = $owner;
|
|
}
|
|
elseif($user->user_exists != 0 && $user->user_info['user_id'] == $video_info['video_user_id'])
|
|
{
|
|
$author = $user;
|
|
}
|
|
|
|
if($video_info["video_group_id"]!=""){
|
|
|
|
// SET AUTHOR AND DIRECTORY
|
|
$video_info['video_author'] = $author;
|
|
//$video_info['video_dir'] = ".".$this->video_dir($video_info['video_user_id'], TRUE);
|
|
//$video_info['video_dir'] = str_replace("./", "", $this->video_dir($video_info['video_user_id']));
|
|
$video_info['video_dir'] = str_replace("./", "", group_dir($video_info['video_group_id']));
|
|
|
|
// CHECK FOR THUMBNAIL
|
|
$video_info['video_thumb'] = file_exists($video_info['video_dir'].$video_info['video_id']."_thumb.jpg");
|
|
}else{
|
|
// SET AUTHOR AND DIRECTORY
|
|
$video_info['video_author'] = $author;
|
|
//$video_info['video_dir'] = ".".$this->video_dir($video_info['video_user_id'], TRUE);
|
|
$video_info['video_dir'] = str_replace("./", "", $this->video_dir($video_info['video_user_id']));
|
|
|
|
// CHECK FOR THUMBNAIL
|
|
$video_info['video_thumb'] = file_exists($video_info['video_dir'].$video_info['video_id']."_thumb.jpg");
|
|
}
|
|
// SET UP DURATION
|
|
$minutes = floor($video_info['video_duration_in_sec']/60);
|
|
$seconds = $video_info['video_duration_in_sec']-60*$minutes;
|
|
$video_info['video_duration_in_min'] = sprintf("%02d:%02d", $minutes, $seconds);
|
|
|
|
// SET UP RATING
|
|
$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'];
|
|
|
|
// CREATE ARRAY OF VIDEO DATA
|
|
$video_array[] = $video_info;
|
|
|
|
}
|
|
|
|
// RETURN ARRAY
|
|
return $video_array;
|
|
}
|
|
|
|
function video_list_all($start, $limit, $sort_by = "video_id DESC", $where = "", $details = 0, $album_id=0, $showdisabled=0)
|
|
{
|
|
global $database, $user, $owner;
|
|
|
|
|
|
|
|
// BEGIN QUERY
|
|
$video_query = "SELECT SQL_BIG_RESULT se_videos.*";
|
|
|
|
// GET DETAILS
|
|
if($details) { $video_query .= ", count(se_videocomments.videocomment_id) AS total_comments"; }
|
|
|
|
// IF NO USER ID SPECIFIED, RETRIEVE USER INFORMATION
|
|
if($this->user_id == 0) { $video_query .= ", se_users.user_id, se_users.user_username, se_users.user_photo, se_users.user_fname, se_users.user_lname, se_users.user_enabled"; }
|
|
|
|
// CONTINUE QUERY
|
|
$video_query .= " FROM se_videos";
|
|
|
|
// GET DETAILS
|
|
if($details) { $video_query .= " LEFT JOIN se_videocomments ON se_videos.video_id=se_videocomments.videocomment_video_id"; }
|
|
|
|
// IF NO USER ID SPECIFIED, JOIN TO USER TABLE
|
|
if($this->user_id == 0) { $video_query .= " LEFT JOIN se_users ON se_videos.video_user_id=se_users.user_id"; }
|
|
|
|
// ADD WHERE IF NECESSARY
|
|
// $video_query .= " WHERE (video_uploaded=1 OR video_admin_approved=1)";
|
|
$video_query .= " WHERE video_admin_approved=1 ";
|
|
|
|
// ENSURE USER ID IS NOT EMPTY
|
|
if($this->user_id != 0) { $video_query .= "AND video_user_id='{$this->user_id}' "; }
|
|
else{
|
|
if($showdisabled==0){
|
|
$video_query .= "AND se_users.user_enabled='1' ";
|
|
}
|
|
}
|
|
|
|
// INSERT AND IF NECESSARY
|
|
//$video_query .= " AND";
|
|
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
|
if($where != "") { $video_query .= " AND $where"; }
|
|
|
|
// ADD GROUP BY, ORDER, AND LIMIT CLAUSE
|
|
$video_query .= " GROUP BY video_id ORDER BY $sort_by LIMIT $start, $limit";
|
|
//if(SE_DEBUG1){echo $video_query;exit;}
|
|
// RUN QUERY
|
|
$videos = $database->database_query($video_query);
|
|
|
|
// GET VIDEOS INTO AN ARRAY
|
|
$video_array = Array();
|
|
while($video_info = $database->database_fetch_assoc($videos))
|
|
{
|
|
|
|
$tags="";
|
|
$checkusers=$database->database_query("SELECT * FROM se_videotags WHERE mediatag_media_id='".$database->database_real_escape_string($video_info['video_id'])."'");
|
|
|
|
|
|
while($rowusers=$database->database_fetch_array($checkusers))
|
|
{
|
|
|
|
$thisuser=$database->database_query("SELECT user_username FROM se_users WHERE user_id='".$database->database_real_escape_string($rowusers['mediatag_user_id'])."'");
|
|
$rowuser=$database->database_fetch_array($thisuser);
|
|
|
|
if($tags==""){
|
|
$tags=$rowuser["user_username"]."<br>";}
|
|
else{$tags.=$rowuser["user_username"]."<br>";}
|
|
}
|
|
$video_info['media_tags']=$tags;
|
|
|
|
// IF NO USER ID SPECIFIED, CREATE OBJECT FOR AUTHOR
|
|
if($this->user_id == 0)
|
|
{
|
|
$author = new se_user();
|
|
$author->user_exists = 1;
|
|
$author->user_info['user_id'] = $video_info['user_id'];
|
|
$author->user_info['user_username'] = $video_info['user_username'];
|
|
$author->user_info['user_fname'] = $video_info['user_fname'];
|
|
$author->user_info['user_lname'] = $video_info['user_lname'];
|
|
$author->user_info['user_photo'] = $video_info['user_photo'];
|
|
$author->user_info['user_enabled'] = $video_info['user_enabled'];
|
|
$author->user_displayname();
|
|
}
|
|
|
|
// OTHERWISE, SET AUTHOR TO OWNER/LOGGED-IN USER
|
|
elseif($owner->user_exists != 0 && $owner->user_info['user_id'] == $video_info['video_user_id'])
|
|
{
|
|
$author = $owner;
|
|
}
|
|
elseif($user->user_exists != 0 && $user->user_info['user_id'] == $video_info['video_user_id'])
|
|
{
|
|
$author = $user;
|
|
}
|
|
|
|
// SET AUTHOR AND DIRECTORY
|
|
$video_info['video_author'] = $author;
|
|
//$video_info['video_dir'] = ".".$this->video_dir($video_info['video_user_id'], TRUE);
|
|
$video_info['video_dir'] = str_replace("./", "", $this->video_dir($video_info['video_user_id']));
|
|
|
|
// CHECK FOR THUMBNAIL
|
|
$video_info['video_thumb'] = file_exists($video_info['video_dir'].$video_info['video_id']."_thumb.jpg");
|
|
|
|
// SET UP DURATION
|
|
$minutes = floor($video_info['video_duration_in_sec']/60);
|
|
$seconds = $video_info['video_duration_in_sec']-60*$minutes;
|
|
$video_info['video_duration_in_min'] = sprintf("%02d:%02d", $minutes, $seconds);
|
|
|
|
// SET UP RATING
|
|
$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'];
|
|
|
|
// CREATE ARRAY OF VIDEO DATA
|
|
$video_array[] = $video_info;
|
|
|
|
}
|
|
|
|
// RETURN ARRAY
|
|
return $video_array;
|
|
}
|
|
|
|
function video_list($start, $limit, $sort_by = "video_id DESC", $where = "", $details = 0, $album_id=0)
|
|
{
|
|
global $database, $user, $owner;
|
|
|
|
|
|
|
|
// BEGIN QUERY
|
|
$video_query = "SELECT se_videos.*";
|
|
|
|
// GET DETAILS
|
|
if($details) { $video_query .= ", count(se_videocomments.videocomment_id) AS total_comments"; }
|
|
|
|
// IF NO USER ID SPECIFIED, RETRIEVE USER INFORMATION
|
|
if($this->user_id == 0) { $video_query .= ", se_users.user_id, se_users.user_username, se_users.user_photo, se_users.user_fname, se_users.user_lname"; }
|
|
|
|
// CONTINUE QUERY
|
|
$video_query .= " FROM se_videos";
|
|
|
|
// GET DETAILS
|
|
if($details) { $video_query .= " LEFT JOIN se_videocomments ON se_videos.video_id=se_videocomments.videocomment_video_id"; }
|
|
|
|
// IF NO USER ID SPECIFIED, JOIN TO USER TABLE
|
|
if($this->user_id == 0) { $video_query .= " LEFT JOIN se_users ON se_videos.video_user_id=se_users.user_id"; }
|
|
|
|
// ADD WHERE IF NECESSARY
|
|
// $video_query .= " WHERE (video_uploaded=1 OR video_admin_approved=1)";
|
|
$video_query .= " WHERE video_admin_approved=1 ";
|
|
if($album_id>0){ $video_query .="AND video_album='".$database->database_real_escape_string($album_id)."'";}
|
|
|
|
if($owner->user_info["user_id"]==$user->user_info["user_id"]||$this->user_id==$user->user_info["user_id"]){
|
|
$video_query .= "
|
|
AND approved!=1000
|
|
";
|
|
}
|
|
else{
|
|
$video_query .= "
|
|
AND approved=1
|
|
";
|
|
}
|
|
|
|
// ENSURE USER ID IS NOT EMPTY
|
|
if($this->user_id != 0) { $video_query .= "AND video_user_id='{$this->user_id}' "; }
|
|
else{
|
|
$video_query .= "AND se_users.user_enabled='1' ";
|
|
|
|
}
|
|
|
|
// INSERT AND IF NECESSARY
|
|
//$video_query .= " AND";
|
|
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
|
if($where != "") { $video_query .= " AND $where"; }
|
|
|
|
// ADD GROUP BY, ORDER, AND LIMIT CLAUSE
|
|
$video_query .= " GROUP BY video_id ORDER BY $sort_by LIMIT $start, $limit";
|
|
|
|
// RUN QUERY
|
|
$videos = $database->database_query($video_query);
|
|
|
|
// GET VIDEOS INTO AN ARRAY
|
|
$video_array = Array();
|
|
while($video_info = $database->database_fetch_assoc($videos))
|
|
{
|
|
|
|
$tags="";
|
|
$checkusers=$database->database_query("SELECT * FROM se_videotags WHERE mediatag_media_id='".$database->database_real_escape_string($video_info['video_id'])."'");
|
|
|
|
|
|
while($rowusers=$database->database_fetch_array($checkusers))
|
|
{
|
|
|
|
$thisuser=$database->database_query("SELECT user_username FROM se_users WHERE user_id='".$database->database_real_escape_string($rowusers['mediatag_user_id'])."'");
|
|
$rowuser=$database->database_fetch_array($thisuser);
|
|
|
|
if($tags==""){
|
|
$tags=$rowuser["user_username"]."<br>";}
|
|
else{$tags.=$rowuser["user_username"]."<br>";}
|
|
}
|
|
$video_info['media_tags']=$tags;
|
|
|
|
// IF NO USER ID SPECIFIED, CREATE OBJECT FOR AUTHOR
|
|
if($this->user_id == 0)
|
|
{
|
|
$author = new se_user();
|
|
$author->user_exists = 1;
|
|
$author->user_info['user_id'] = $video_info['user_id'];
|
|
$author->user_info['user_username'] = $video_info['user_username'];
|
|
$author->user_info['user_fname'] = $video_info['user_fname'];
|
|
$author->user_info['user_lname'] = $video_info['user_lname'];
|
|
$author->user_info['user_photo'] = $video_info['user_photo'];
|
|
$author->user_displayname();
|
|
}
|
|
|
|
// OTHERWISE, SET AUTHOR TO OWNER/LOGGED-IN USER
|
|
elseif($owner->user_exists != 0 && $owner->user_info['user_id'] == $video_info['video_user_id'])
|
|
{
|
|
$author = $owner;
|
|
}
|
|
elseif($user->user_exists != 0 && $user->user_info['user_id'] == $video_info['video_user_id'])
|
|
{
|
|
$author = $user;
|
|
}
|
|
|
|
// SET AUTHOR AND DIRECTORY
|
|
$video_info['video_author'] = $author;
|
|
//$video_info['video_dir'] = ".".$this->video_dir($video_info['video_user_id'], TRUE);
|
|
$video_info['video_dir'] = str_replace("./", "", $this->video_dir($video_info['video_user_id'], TRUE));
|
|
// CHECK FOR THUMBNAIL
|
|
$video_info['video_thumb'] = file_exists($video_info['video_dir'].$video_info['video_id']."_thumb.jpg");
|
|
|
|
// SET UP DURATION
|
|
$minutes = floor($video_info['video_duration_in_sec']/60);
|
|
$seconds = $video_info['video_duration_in_sec']-60*$minutes;
|
|
$video_info['video_duration_in_min'] = sprintf("%02d:%02d", $minutes, $seconds);
|
|
|
|
// SET UP RATING
|
|
$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'];
|
|
|
|
// CREATE ARRAY OF VIDEO DATA
|
|
$video_array[] = $video_info;
|
|
|
|
}
|
|
|
|
// RETURN ARRAY
|
|
return $video_array;
|
|
}
|
|
|
|
// END video_list() METHOD
|
|
|
|
|
|
function video_album_list($album_id, $start, $limit, $sort_by = "video_id DESC", $where = "", $details = 0)
|
|
{
|
|
global $database, $user, $owner;
|
|
|
|
|
|
|
|
// BEGIN QUERY
|
|
$video_query = "SELECT se_videos.*";
|
|
|
|
// GET DETAILS
|
|
if($details) { $video_query .= ", count(se_videocomments.videocomment_id) AS total_comments"; }
|
|
|
|
// IF NO USER ID SPECIFIED, RETRIEVE USER INFORMATION
|
|
if($this->user_id == 0) { $video_query .= ", se_users.user_id, se_users.user_username, se_users.user_photo, se_users.user_fname, se_users.user_lname"; }
|
|
|
|
// CONTINUE QUERY
|
|
$video_query .= " FROM se_videos";
|
|
|
|
// GET DETAILS
|
|
if($details) { $video_query .= " LEFT JOIN se_videocomments ON se_videos.video_id=se_videocomments.videocomment_video_id"; }
|
|
|
|
// IF NO USER ID SPECIFIED, JOIN TO USER TABLE
|
|
if($this->user_id == 0) { $video_query .= " LEFT JOIN se_users ON se_videos.video_user_id=se_users.user_id"; }
|
|
|
|
// ADD WHERE IF NECESSARY
|
|
// $video_query .= " WHERE (video_uploaded=1 OR video_admin_approved=1)";
|
|
$video_query .= " WHERE video_admin_approved=1 AND video_album=".$database->database_real_escape_string($album_id)." ";
|
|
|
|
// ENSURE USER ID IS NOT EMPTY
|
|
if($this->user_id != 0) { $video_query .= "AND video_user_id='{$this->user_id}' "; }
|
|
else{
|
|
$video_query .= "AND se_users.user_enabled='1' ";
|
|
|
|
}
|
|
if($owner->user_info["user_id"]==$user->user_info["user_id"]||$this->user_id==$user->user_info["user_id"]){
|
|
$video_query .= "
|
|
AND approved!=1000
|
|
";
|
|
}
|
|
else{
|
|
$video_query .= "
|
|
AND approved=1
|
|
";
|
|
}
|
|
|
|
// INSERT AND IF NECESSARY
|
|
//$video_query .= " AND";
|
|
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
|
if($where != "") { $video_query .= " AND $where"; }
|
|
|
|
// ADD GROUP BY, ORDER, AND LIMIT CLAUSE
|
|
$video_query .= " GROUP BY video_id ORDER BY $sort_by LIMIT $start, $limit";
|
|
|
|
// RUN QUERY
|
|
$videos = $database->database_query($video_query);
|
|
|
|
// GET VIDEOS INTO AN ARRAY
|
|
$video_array = Array();
|
|
while($video_info = $database->database_fetch_assoc($videos))
|
|
{
|
|
|
|
$tags="";
|
|
$checkusers=$database->database_query("SELECT * FROM se_videotags WHERE mediatag_media_id='".$database->database_real_escape_string($video_info['video_id'])."'");
|
|
|
|
|
|
while($rowusers=$database->database_fetch_array($checkusers))
|
|
{
|
|
|
|
$thisuser=$database->database_query("SELECT user_username FROM se_users WHERE user_id='".$database->database_real_escape_string($rowusers['mediatag_user_id'])."'");
|
|
$rowuser=$database->database_fetch_array($thisuser);
|
|
|
|
if($tags==""){
|
|
$tags=$rowuser["user_username"]."<br>";}
|
|
else{$tags.=$rowuser["user_username"]."<br>";}
|
|
}
|
|
$video_info['media_tags']=$tags;
|
|
//$video_info['video_dir'] = ".".$this->video_dir($video_info['video_user_id'], TRUE);
|
|
// IF NO USER ID SPECIFIED, CREATE OBJECT FOR AUTHOR
|
|
if($this->user_id == 0)
|
|
{
|
|
$author = new se_user();
|
|
$author->user_exists = 1;
|
|
$author->user_info['user_id'] = $video_info['user_id'];
|
|
$author->user_info['user_username'] = $video_info['user_username'];
|
|
$author->user_info['user_fname'] = $video_info['user_fname'];
|
|
$author->user_info['user_lname'] = $video_info['user_lname'];
|
|
$author->user_info['user_photo'] = $video_info['user_photo'];
|
|
$author->user_displayname();
|
|
}
|
|
|
|
// OTHERWISE, SET AUTHOR TO OWNER/LOGGED-IN USER
|
|
elseif($owner->user_exists != 0 && $owner->user_info['user_id'] == $video_info['video_user_id'])
|
|
{
|
|
$author = $owner;
|
|
}
|
|
elseif($user->user_exists != 0 && $user->user_info['user_id'] == $video_info['video_user_id'])
|
|
{
|
|
$author = $user;
|
|
}
|
|
|
|
// SET AUTHOR AND DIRECTORY
|
|
$video_info['video_author'] = $author;
|
|
//$video_info['video_dir'] = ".".$this->video_dir($video_info['video_user_id'], TRUE);
|
|
$video_info['video_dir'] = str_replace("./", "", $this->video_dir($video_info['video_user_id'], TRUE));
|
|
// CHECK FOR THUMBNAIL
|
|
$video_info['video_thumb'] = file_exists($video_info['video_dir'].$video_info['video_id']."_thumb.jpg");
|
|
|
|
// SET UP DURATION
|
|
$minutes = floor($video_info['video_duration_in_sec']/60);
|
|
$seconds = $video_info['video_duration_in_sec']-60*$minutes;
|
|
$video_info['video_duration_in_min'] = sprintf("%02d:%02d", $minutes, $seconds);
|
|
|
|
// SET UP RATING
|
|
$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'];
|
|
|
|
// CREATE ARRAY OF VIDEO DATA
|
|
$video_array[] = $video_info;
|
|
|
|
}
|
|
|
|
// RETURN ARRAY
|
|
return $video_array;
|
|
}
|
|
|
|
|
|
function contest_list($start, $limit, $sort_by = "video_id DESC", $where = "", $details = 0)
|
|
{
|
|
global $database, $user, $owner;
|
|
|
|
// BEGIN QUERY
|
|
$video_query = "SELECT contest.*";
|
|
|
|
// GET DETAILS
|
|
// if($details) { $video_query .= ", count(se_videocomments.videocomment_id) AS total_comments"; }
|
|
|
|
// IF NO USER ID SPECIFIED, RETRIEVE USER INFORMATION
|
|
$video_query .= ", se_users.user_id, se_users.user_username, se_users.user_photo, se_users.user_fname, se_users.user_lname";
|
|
|
|
// CONTINUE QUERY
|
|
$video_query .= " FROM contest, se_users";
|
|
|
|
// GET DETAILS
|
|
// if($details) { $video_query .= " LEFT JOIN se_videocomments ON se_videos.video_id=se_videocomments.videocomment_video_id"; }
|
|
|
|
// IF NO USER ID SPECIFIED, JOIN TO USER TABLE
|
|
$video_query .= "";
|
|
|
|
// ADD WHERE IF NECESSARY
|
|
$video_query .= " WHERE approved=1 AND contest.user=se_users.user_id AND file!=''";
|
|
|
|
// ENSURE USER ID IS NOT EMPTY
|
|
//if($this->user_id != 0) { $video_query .= " AND user='{$this->user_id}'"; }
|
|
|
|
// INSERT AND IF NECESSARY
|
|
if( $where != "") { $video_query .= " AND"; }
|
|
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
|
if($where != "") { $video_query .= " $where"; }
|
|
|
|
// ADD GROUP BY, ORDER, AND LIMIT CLAUSE
|
|
$video_query .= " GROUP BY id ORDER BY $sort_by LIMIT $start, $limit";
|
|
|
|
// RUN QUERY
|
|
//echo $video_query;
|
|
$videos = $database->database_query($video_query);
|
|
|
|
// GET VIDEOS INTO AN ARRAY
|
|
$video_array = Array();
|
|
while($video_info = $database->database_fetch_assoc($videos))
|
|
{
|
|
// IF NO USER ID SPECIFIED, CREATE OBJECT FOR AUTHOR
|
|
if($this->user_id == 0)
|
|
{
|
|
$author = new se_user();
|
|
$author->user_exists = 1;
|
|
$author->user_info['user_id'] = $video_info['user_id'];
|
|
$author->user_info['user_username'] = $video_info['user_username'];
|
|
$author->user_info['user_fname'] = $video_info['user_fname'];
|
|
$author->user_info['user_lname'] = $video_info['user_lname'];
|
|
$author->user_info['user_photo'] = $video_info['user_photo'];
|
|
$author->user_displayname();
|
|
}
|
|
|
|
// OTHERWISE, SET AUTHOR TO OWNER/LOGGED-IN USER
|
|
elseif($owner->user_exists != 0 && $owner->user_info['user_id'] == $video_info['video_user_id'])
|
|
{
|
|
$author = $owner;
|
|
}
|
|
elseif($user->user_exists != 0 && $user->user_info['user_id'] == $video_info['video_user_id'])
|
|
{
|
|
$author = $user;
|
|
}
|
|
|
|
// SET AUTHOR AND DIRECTORY
|
|
$video_info['video_author'] = $author;
|
|
//$video_info['video_dir'] = ".".$this->video_dir($video_info['video_user_id'], TRUE);
|
|
$video_info['video_dir'] = str_replace("./", "", $this->video_dir($video_info['video_user_id'], TRUE));
|
|
// CHECK FOR THUMBNAIL
|
|
$video_info['video_thumb'] = file_exists($video_info['video_dir'].$video_info['video_id']."_thumb.jpg");
|
|
|
|
// SET UP DURATION
|
|
$minutes = floor($video_info['video_duration_in_sec']/60);
|
|
$seconds = $video_info['video_duration_in_sec']-60*$minutes;
|
|
$video_info['video_duration_in_min'] = sprintf("%02d:%02d", $minutes, $seconds);
|
|
|
|
// SET UP RATING
|
|
$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'];
|
|
// var_dump($video_info);
|
|
// CREATE ARRAY OF VIDEO DATA
|
|
$video_array[] = $video_info;
|
|
}
|
|
|
|
// RETURN ARRAY
|
|
return $video_array;
|
|
}
|
|
|
|
|
|
|
|
//
|
|
// THIS METHOD RETURNS THE PATH TO THE GIVEN USER'S VIDEO DIRECTORY
|
|
//
|
|
// INPUT:
|
|
// $user_id (OPTIONAL) REPRESENTING A USER'S USER_ID
|
|
//
|
|
// OUTPUT:
|
|
// A STRING REPRESENTING THE RELATIVE PATH TO THE USER'S VIDEO DIRECTORY
|
|
//
|
|
|
|
function video_dir($user_id = 0, $create_if_missing = FALSE)
|
|
{
|
|
|
|
if( !$user_id && $this->user_id )
|
|
$user_id = $this->user_id;
|
|
|
|
if( !$user_id && !is_numeric($user_id) )
|
|
return FALSE;
|
|
|
|
$subdir = $user_id + 999 - ( ( $user_id - 1 ) % 1000 );
|
|
|
|
$videodir = "./uploads_video/{$subdir}/{$user_id}/";
|
|
/*
|
|
if( $create_if_missing )
|
|
{
|
|
// IN ADMIN DIRECTORY, ABORT
|
|
if( !is_dir('./uploads_video') ){
|
|
//return FALSE;
|
|
}
|
|
|
|
$video_path_array = explode("/", $videodir);
|
|
array_pop($video_path_array);
|
|
array_pop($video_path_array);
|
|
$subdir = ".".implode("/", $video_path_array)."/";
|
|
if( !is_dir($subdir) )
|
|
{
|
|
|
|
@mkdir($subdir, 0777);
|
|
@chmod($subdir, 0777);
|
|
$handle = @fopen($subdir."index.php", 'x+');
|
|
@fclose($handle);
|
|
}
|
|
if( !is_dir(".".$videodir) )
|
|
{
|
|
|
|
@mkdir(".".$videodir, 0777);
|
|
@chmod(".".$videodir, 0777);
|
|
$handle = @fopen($videodir."/index.php", 'x+');
|
|
@fclose($handle);
|
|
}
|
|
}*/
|
|
|
|
return $videodir;
|
|
}
|
|
|
|
function cronvideo_dir($user_id = 0, $create_if_missing = FALSE)
|
|
{
|
|
if( !$user_id && $this->user_id )
|
|
$user_id = $this->user_id;
|
|
|
|
if( !$user_id && !is_numeric($user_id) )
|
|
return FALSE;
|
|
|
|
$subdir = $user_id + 999 - ( ( $user_id - 1 ) % 1000 );
|
|
$videodir = "../uploads_video/{$subdir}/{$user_id}/";
|
|
|
|
if( $create_if_missing )
|
|
{
|
|
// IN ADMIN DIRECTORY, ABORT
|
|
if( !is_dir('../uploads_video') )
|
|
return FALSE;
|
|
|
|
$video_path_array = explode("/", $videodir);
|
|
array_pop($video_path_array);
|
|
array_pop($video_path_array);
|
|
$subdir = implode("/", $video_path_array)."/";
|
|
if( !is_dir($subdir) )
|
|
{
|
|
@mkdir($subdir, 0777);
|
|
@chmod($subdir, 0777);
|
|
$handle = @fopen($subdir."index.php", 'x+');
|
|
@fclose($handle);
|
|
}
|
|
if( !is_dir($videodir) )
|
|
{
|
|
@mkdir($videodir, 0777);
|
|
@chmod($videodir, 0777);
|
|
$handle = @fopen($videodir."/index.php", 'x+');
|
|
@fclose($handle);
|
|
}
|
|
}
|
|
|
|
return $videodir;
|
|
}
|
|
|
|
// END video_dir() METHOD
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
// THIS METHOD CREATES/EDITS A VIDEO
|
|
//
|
|
// INPUT:
|
|
// $video_title REPRESENTING THE TITLE OF THE VIDEO
|
|
// $video_desc REPRESENTING THE DESCRIPTION OF THE VIDEO
|
|
// $video_search REPRESENTING THE SEARCH PRIVACY
|
|
// $video_privacy REPRESENTING THE VIDEO PRIVACY
|
|
// $video_comments REPRESENTING THE COMMENT PRIVACY
|
|
//
|
|
// OUTPUT:
|
|
// The ID of the video or FALSE
|
|
//
|
|
|
|
function video_edit($video_title, $video_desc, $video_search, $video_privacy, $video_comments, $video_type, $video_youtube_code=NULL, $video_album="")
|
|
{
|
|
global $database, $url, $setting, $user, $actions, $misc;
|
|
|
|
// INSERT ROW INTO VIDEO TABLE
|
|
if( empty($video_title) )
|
|
{
|
|
$this->is_error = 5500200;
|
|
return FALSE;
|
|
}
|
|
|
|
$this->video_info['video_title'] = $video_title;
|
|
$this->video_info['video_desc'] = $video_desc;
|
|
$this->video_info['video_search'] = $video_search;
|
|
$this->video_info['video_privacy'] = $video_privacy;
|
|
$this->video_info['video_comments'] = $video_comments;
|
|
$this->video_info['video_type'] = $video_type;
|
|
$this->video_info['video_youtube_code'] = $video_youtube_code;
|
|
$this->video_info['video_album'] = $video_album;
|
|
$time = time();
|
|
|
|
if( ($video_type == 1) && (!$video_youtube_code) )
|
|
{
|
|
$this->is_error = 5500189;
|
|
return FALSE;
|
|
}
|
|
|
|
if( !$this->video_exists )
|
|
{
|
|
$consentmarking=$_POST["consent"];
|
|
if($consentmarking==1){$marketingdate=time();}
|
|
$sql = "
|
|
INSERT INTO se_videos
|
|
(
|
|
video_user_id,
|
|
video_datecreated,
|
|
video_title,
|
|
video_desc,
|
|
video_search,
|
|
video_privacy,
|
|
video_comments,
|
|
video_type,
|
|
video_dateupdated,
|
|
rights, consentgiven, video_album, ai
|
|
";
|
|
|
|
if( $video_type == 1 ) $sql .= ",
|
|
video_youtube_code,
|
|
video_uploaded,
|
|
video_is_converted
|
|
";
|
|
|
|
$sql .= "
|
|
) VALUES (
|
|
'{$user->user_info['user_id']}',
|
|
'{$time}',
|
|
'{$video_title}',
|
|
'{$video_desc}',
|
|
'{$video_search}',
|
|
'{$video_privacy}',
|
|
'{$video_comments}',
|
|
'{$video_type}',
|
|
'{$time}',
|
|
'".$database->database_real_escape_string($consentmarking)."',
|
|
'".$database->database_real_escape_string($marketingdate)."', '".$database->database_real_escape_string($video_album)."', '".$database->database_real_escape_string($_POST["ai"])."'
|
|
";
|
|
|
|
if( $video_type == 1 ) $sql .= ",
|
|
'{$this->video_info['video_youtube_code']}',
|
|
'1',
|
|
'1'
|
|
";
|
|
|
|
$sql .= "
|
|
)
|
|
";
|
|
|
|
$resource = $database->database_query($sql);
|
|
$this->video_info['video_id'] = $database->database_insert_id();
|
|
if( !$database->database_affected_rows() || !$this->video_info['video_id'] ) {
|
|
return FALSE;
|
|
}
|
|
$this->video_exists = TRUE;
|
|
|
|
// INSERT ACTION NOW IF YOUTUBE
|
|
if( $this->video_info['video_type'] == 1 )
|
|
{
|
|
// INSERT ACTION
|
|
if(strlen($this->video_info['video_title']) > 100)
|
|
{
|
|
$video_info['video_title'] = substr($video_info['video_title'], 0, 97);
|
|
$video_info['video_title'] .= "...";
|
|
}
|
|
$action_media = array($this->video_update_youtube_thumb());
|
|
$actions->actions_add($user, "newyoutubevideo", array($user->user_info['user_username'], $user->user_displayname, $this->video_info['video_id'], $this->video_info['video_title']), $action_media, 0, false, "user", $user->user_info['user_id'], $user->user_info['user_privacy']);
|
|
}
|
|
}
|
|
|
|
// UPDATE VIDEO
|
|
else
|
|
{
|
|
// Check owner
|
|
if( $this->video_info['video_user_id']!=$this->user_id )
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
$sql = "
|
|
UPDATE
|
|
se_videos
|
|
SET
|
|
video_title='{$video_title}',
|
|
video_desc='{$video_desc}',
|
|
video_search='{$video_search}',
|
|
video_privacy='{$video_privacy}',
|
|
video_comments='{$video_comments}'
|
|
WHERE
|
|
video_id='{$this->video_info['video_id']}'
|
|
LIMIT
|
|
1
|
|
";
|
|
|
|
$resource = $database->database_query($sql);
|
|
|
|
if( !$resource )
|
|
return FALSE;
|
|
}
|
|
|
|
// GET UPDATED VIDEO INFO
|
|
$sql = "SELECT * FROM se_videos WHERE video_id='{$this->video_info['video_id']}' LIMIT 1";
|
|
$resource = $database->database_query($sql);
|
|
|
|
if( !$resource || !$database->database_num_rows($resource) )
|
|
return FALSE;
|
|
$this->video_info = $database->database_fetch_assoc($resource);
|
|
return $this->video_info;
|
|
}
|
|
|
|
// END video_edit() METHOD
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
// THIS METHOD UPLOADS A VIDEO
|
|
//
|
|
// INPUT:
|
|
// $file_name REPRESENTING THE NAME OF THE FILE INPUT
|
|
//
|
|
// OUTPUT:
|
|
// TRUE/FALSE
|
|
//
|
|
function video_upload_chunk($file_name)
|
|
{
|
|
global $database, $url, $setting, $user;
|
|
|
|
// Check exists and owner
|
|
if( !$this->video_exists || $this->video_info['video_user_id']!=$this->user_id )
|
|
{
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// SET KEY VARIABLES
|
|
$file_maxsize = $user->level_info['level_video_maxsize'];
|
|
$file_exts = explode(",", str_replace(" ", "", strtolower($setting['setting_video_exts'])));
|
|
$file_types = explode(",", str_replace(" ", "", strtolower($setting['setting_video_mime'])));
|
|
|
|
// IF FILE EXTS AND MIMES ARE EMPTY, FILL IN WITH VIDEO'S EXT/TYPE
|
|
if(trim($setting['setting_video_exts']) == "") { $file_exts[] = strtolower(str_replace(".", "", strrchr($_FILES[$file_name]['name'], "."))); }
|
|
if(trim($setting['setting_video_mime']) == "") { $file_types[] = strtolower($_FILES[$file_name]['type']); }
|
|
|
|
$video_ext = strtolower(str_replace(".", "", strrchr($_FILES[$file_name]['name'], ".")));
|
|
|
|
// CHECK THAT UPLOAD DIRECTORY EXISTS, IF NOT THEN CREATE
|
|
$video_directory = ".".$this->video_dir($this->user_id, TRUE);
|
|
|
|
// CHECK FOR ERRORS
|
|
$new_video = new se_upload();
|
|
$new_video->new_upload($file_name, $file_maxsize, $file_exts, $file_types);
|
|
|
|
// UPLOAD VIDEO IF NO ERROR
|
|
if( !$new_video->is_error )
|
|
{
|
|
// SET FILE DESTINATION
|
|
$video_id = $this->video_info['video_id'];
|
|
$new_filename = $video_id;
|
|
$file_dest = ".".$this->video_dir($this->user_id).$new_filename.".original.".$video_ext;
|
|
|
|
$target_file = ".".$this->video_dir($this->user_id).$new_filename.".original.".$video_ext;
|
|
$target_path = $this->video_dir($this->user_id);
|
|
$tmp_name = $_FILES[$file_name]['tmp_name'];
|
|
$size = $_FILES[$file_name]['size'];
|
|
$name = $_FILES[$file_name]['name'];
|
|
$name2 = $new_filename.".original.".$video_ext;
|
|
|
|
$complete =$target_path.$name2;
|
|
$com = fopen($complete, "ab");
|
|
//error_log($target_path);
|
|
|
|
// Open temp file
|
|
//$out = fopen($target_file, "wb");
|
|
|
|
//if ( $out ) {
|
|
// Read binary input stream and append it to temp file
|
|
$in = fopen($tmp_name, "rb");
|
|
if ( $in ) {
|
|
while ( $buff = fread( $in, 10000000 ) ) {
|
|
// fwrite($out, $buff);
|
|
fwrite($com, $buff);
|
|
}
|
|
}
|
|
fclose($in);
|
|
|
|
//}
|
|
//fclose($out);
|
|
fclose($com);
|
|
|
|
|
|
// MOVE FILE
|
|
|
|
//$new_video->upload_file($file_dest);
|
|
|
|
// (DON'T) DELETE FROM DATABASE IF ERROR
|
|
if( $new_video->is_error )
|
|
{
|
|
|
|
$database->database_query("UPDATE se_videos SET error_code='".$new_video->is_error."' WHERE video_id='{$video_id}' AND video_user_id='{$user->user_info['user_id']}'");
|
|
//@unlink($file_dest);
|
|
|
|
}
|
|
|
|
// ALERT FFMPEG IF SUCCESSFUL
|
|
else
|
|
{
|
|
//if(!$database->database_ping())
|
|
if (!is_object($database) && !$database instanceof mysqli)
|
|
{
|
|
global $database, $database_host, $database_username, $database_password, $database_name;
|
|
$database =NULL;
|
|
$database =& SEDatabase::getInstance();
|
|
|
|
|
|
}
|
|
// SET UPLOADED STATUS IN DATABASE
|
|
$sql = "UPDATE se_videos SET video_uploaded=1, rawfile='{$new_filename}.original.{$video_ext}' WHERE video_id='{$video_id}' LIMIT 1";
|
|
$database->database_query($sql);
|
|
//wrapup("upload_video");
|
|
// PREPARE SHELL SCRIPT INFO
|
|
$linebreak = "\n";
|
|
$directory = getcwd().substr(".".$this->video_dir($this->user_id), 1);
|
|
|
|
// ffmpeg doc
|
|
// http://ffmpeg.mplayerhq.hu/ffmpeg-doc.html
|
|
|
|
// WRITE SHELL SCRIPT
|
|
$duration_session = rand(1, 9999);
|
|
$cwd = getcwd();
|
|
|
|
$shell_script = "touch {$cwd}/uploads_video/encoding/queue/{$new_filename}".$linebreak;
|
|
$shell_script .= "FULLOUTPUT{$duration_session}=$({$setting['setting_video_ffmpeg_path']} -i {$directory}{$new_filename}.original.{$video_ext} -ab 64k -ar 44100 -qscale 5 -vcodec flv -f flv -r 25 -s {$setting['setting_video_width']}x{$setting['setting_video_height']} {$directory}{$new_filename}.flv 2>&1)".$linebreak;
|
|
if($user->user_info["user_id"]==7653)
|
|
{
|
|
$shell_script .= "{$setting['setting_video_ffmpeg_path']} -i {$directory}{$new_filename}.original.{$video_ext}-s {$setting['setting_video_width']}x{$setting['setting_video_height']} -y -vcodec libx264 -g 30 {$directory}{$new_filename}.mp4".$linebreak;
|
|
}
|
|
if( $this->debug )
|
|
{
|
|
$shell_script .= "echo \$FULLOUTPUT{$duration_session} > {$cwd}/uploads_video/encoding/debug/{$new_filename}.ffmpeg.log".$linebreak;
|
|
}
|
|
|
|
$shell_script .= "DURATION{$duration_session}=$(echo \$FULLOUTPUT{$duration_session} | grep -o --perl-regexp '[Dd]uration.{1,3}([0-9][0-9]:[0-9][0-9]:[0-9][0-9])' | grep -o [0-9][0-9]:[0-9][0-9]:[0-9][0-9])".$linebreak;
|
|
//$shell_script .= "DURATION{$duration_session}=$(echo \$FULLOUTPUT{$duration_session} | grep Duration | grep -o [0-9][0-9]:[0-9][0-9]:[0-9][0-9])".$linebreak;
|
|
//$shell_script .= "DURATION{$duration_session}=$({$setting['setting_video_ffmpeg_path']} -i {$directory}{$new_filename} -ab 64k -vcodec flv -f flv -r 25 -s {$setting['setting_video_width']}x{$setting['setting_video_height']} {$directory}{$new_filename}.flv 2>&1 | grep Duration | grep -o [0-9][0-9]:[0-9][0-9]:[0-9][0-9])".$linebreak;
|
|
|
|
$shell_script .= "{$setting['setting_video_ffmpeg_path']} -i {$directory}{$new_filename}.flv -s {$setting['setting_video_thumb_width']}x{$setting['setting_video_thumb_height']} -f image2 -ss 4.00 -vframes 1 {$directory}{$new_filename}_thumb.jpg".$linebreak;
|
|
//$shell_script .= "{$setting['setting_video_ffmpeg_path']} -i {$directory}{$new_filename}.flv -s {$setting['setting_video_thumb_width']}x{$setting['setting_video_thumb_height']} -f image2 -ss 4.00 -vframes 1 -pix_fmt jpeg {$directory}{$new_filename}_thumb.jpg".$linebreak;
|
|
$shell_script .= "rm --force {$directory}{$new_filename}.original.{$video_ext}".$linebreak;
|
|
$shell_script .= "mv {$cwd}/uploads_video/encoding/queue/{$new_filename} \"{$cwd}/uploads_video/encoding/queue/{$new_filename}_complete_{$video_id}_\$DURATION{$duration_session}\"".$linebreak;
|
|
|
|
|
|
// PUT SHELL SCRIPT IN DIR
|
|
/*if(!($fh=fopen(getcwd().'/uploads_video/encoding/jobs/'.$new_filename, 'w')))
|
|
{
|
|
$database->database_query("DELETE FROM se_videos WHERE video_id='{$video_id}' AND video_user_id='{$user->user_info['user_id']}'");
|
|
@unlink($directory.$new_filename);
|
|
@unlink($file_dest);
|
|
$new_video->is_error = 5500077;
|
|
}
|
|
else
|
|
{
|
|
fwrite($fh, $shell_script);
|
|
fclose($fh);
|
|
chmod(getcwd().'/uploads_video/encoding/jobs/'.$new_filename, 0777);
|
|
}*/
|
|
|
|
}
|
|
}
|
|
else{$database->database_query("UPDATE se_videos SET error_code='".$new_video->is_error."' WHERE video_id='{$video_id}' AND video_user_id='{$user->user_info['user_id']}'");}
|
|
|
|
// RETURN FILE STATS
|
|
$file_result = Array('is_error' => $new_video->is_error);
|
|
|
|
return $file_result;
|
|
}
|
|
function video_upload($file_name)
|
|
{
|
|
global $database, $url, $setting, $user;
|
|
|
|
|
|
// Check exists and owner
|
|
if( !$this->video_exists || $this->video_info['video_user_id']!=$this->user_id )
|
|
{
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
// SET KEY VARIABLES
|
|
$file_maxsize = $user->level_info['level_video_maxsize'];
|
|
$file_exts = explode(",", str_replace(" ", "", strtolower($setting['setting_video_exts'])));
|
|
$file_types = explode(",", str_replace(" ", "", strtolower($setting['setting_video_mime'])));
|
|
|
|
// IF FILE EXTS AND MIMES ARE EMPTY, FILL IN WITH VIDEO'S EXT/TYPE
|
|
if(trim($setting['setting_video_exts']) == "") { $file_exts[] = strtolower(str_replace(".", "", strrchr($_FILES[$file_name]['name'], "."))); }
|
|
if(trim($setting['setting_video_mime']) == "") { $file_types[] = strtolower($_FILES[$file_name]['type']); }
|
|
|
|
$video_ext = strtolower(str_replace(".", "", strrchr($_FILES[$file_name]['name'], ".")));
|
|
|
|
// CHECK THAT UPLOAD DIRECTORY EXISTS, IF NOT THEN CREATE
|
|
$video_directory = ".".$this->video_dir($this->user_id, TRUE);
|
|
|
|
// CHECK FOR ERRORS
|
|
$new_video = new se_upload();
|
|
$new_video->new_upload($file_name, $file_maxsize, $file_exts, $file_types);
|
|
|
|
// UPLOAD VIDEO IF NO ERROR
|
|
if( !$new_video->is_error )
|
|
{
|
|
// SET FILE DESTINATION
|
|
$video_id = $this->video_info['video_id'];
|
|
$new_filename = $video_id;
|
|
$file_dest = ".".$this->video_dir($this->user_id).$new_filename.".original.".$video_ext;
|
|
|
|
// MOVE FILE
|
|
/*if(SE_DEBUG){
|
|
//error_log("CHUNK");
|
|
$new_video->upload_file_chunks($file_dest);
|
|
}
|
|
else{*/
|
|
//error_log("NOT CHUNK");
|
|
$new_video->upload_file($file_dest);
|
|
if(SE_DEBUG1){
|
|
$getID3 = new getID3;
|
|
$file = $getID3->analyze($file_dest);
|
|
|
|
if($file['playtime_seconds']>2){
|
|
$new_video->is_error=999;
|
|
}
|
|
}
|
|
//}
|
|
// (DON'T) DELETE FROM DATABASE IF ERROR
|
|
if( $new_video->is_error )
|
|
{
|
|
|
|
$database->database_query("UPDATE se_videos SET error_code='".$new_video->is_error."' WHERE video_id='{$video_id}' AND video_user_id='{$user->user_info['user_id']}'");
|
|
//@unlink($file_dest);
|
|
|
|
}
|
|
|
|
// ALERT FFMPEG IF SUCCESSFUL
|
|
else
|
|
{
|
|
//if(!$database->database_ping())
|
|
if (!is_object($database) && !$database instanceof mysqli)
|
|
{
|
|
global $database, $database_host, $database_username, $database_password, $database_name;
|
|
$database =NULL;
|
|
$database =& SEDatabase::getInstance();
|
|
|
|
|
|
}
|
|
|
|
// SET UPLOADED STATUS IN DATABASE
|
|
$sql = "UPDATE se_videos SET video_uploaded=1, rawfile='{$new_filename}.original.{$video_ext}' WHERE video_id='{$video_id}' LIMIT 1";
|
|
$database->database_query($sql);
|
|
// wrapup("upload_video");
|
|
addspampoint(6, $user->user_info["user_id"]);
|
|
// PREPARE SHELL SCRIPT INFO
|
|
$linebreak = "\n";
|
|
$directory = getcwd().substr(".".$this->video_dir($this->user_id), 1);
|
|
|
|
// ffmpeg doc
|
|
// http://ffmpeg.mplayerhq.hu/ffmpeg-doc.html
|
|
|
|
// WRITE SHELL SCRIPT
|
|
$duration_session = rand(1, 9999);
|
|
$cwd = getcwd();
|
|
|
|
$shell_script = "touch {$cwd}/uploads_video/encoding/queue/{$new_filename}".$linebreak;
|
|
$shell_script .= "FULLOUTPUT{$duration_session}=$({$setting['setting_video_ffmpeg_path']} -i {$directory}{$new_filename}.original.{$video_ext} -ab 64k -ar 44100 -qscale 5 -vcodec flv -f flv -r 25 -s {$setting['setting_video_width']}x{$setting['setting_video_height']} {$directory}{$new_filename}.flv 2>&1)".$linebreak;
|
|
if($user->user_info["user_id"]==7653)
|
|
{
|
|
$shell_script .= "{$setting['setting_video_ffmpeg_path']} -i {$directory}{$new_filename}.original.{$video_ext}-s {$setting['setting_video_width']}x{$setting['setting_video_height']} -y -vcodec libx264 -g 30 {$directory}{$new_filename}.mp4".$linebreak;
|
|
}
|
|
if( $this->debug )
|
|
{
|
|
$shell_script .= "echo \$FULLOUTPUT{$duration_session} > {$cwd}/uploads_video/encoding/debug/{$new_filename}.ffmpeg.log".$linebreak;
|
|
}
|
|
|
|
$shell_script .= "DURATION{$duration_session}=$(echo \$FULLOUTPUT{$duration_session} | grep -o --perl-regexp '[Dd]uration.{1,3}([0-9][0-9]:[0-9][0-9]:[0-9][0-9])' | grep -o [0-9][0-9]:[0-9][0-9]:[0-9][0-9])".$linebreak;
|
|
//$shell_script .= "DURATION{$duration_session}=$(echo \$FULLOUTPUT{$duration_session} | grep Duration | grep -o [0-9][0-9]:[0-9][0-9]:[0-9][0-9])".$linebreak;
|
|
//$shell_script .= "DURATION{$duration_session}=$({$setting['setting_video_ffmpeg_path']} -i {$directory}{$new_filename} -ab 64k -vcodec flv -f flv -r 25 -s {$setting['setting_video_width']}x{$setting['setting_video_height']} {$directory}{$new_filename}.flv 2>&1 | grep Duration | grep -o [0-9][0-9]:[0-9][0-9]:[0-9][0-9])".$linebreak;
|
|
|
|
$shell_script .= "{$setting['setting_video_ffmpeg_path']} -i {$directory}{$new_filename}.flv -s {$setting['setting_video_thumb_width']}x{$setting['setting_video_thumb_height']} -f image2 -ss 4.00 -vframes 1 {$directory}{$new_filename}_thumb.jpg".$linebreak;
|
|
//$shell_script .= "{$setting['setting_video_ffmpeg_path']} -i {$directory}{$new_filename}.flv -s {$setting['setting_video_thumb_width']}x{$setting['setting_video_thumb_height']} -f image2 -ss 4.00 -vframes 1 -pix_fmt jpeg {$directory}{$new_filename}_thumb.jpg".$linebreak;
|
|
$shell_script .= "rm --force {$directory}{$new_filename}.original.{$video_ext}".$linebreak;
|
|
$shell_script .= "mv {$cwd}/uploads_video/encoding/queue/{$new_filename} \"{$cwd}/uploads_video/encoding/queue/{$new_filename}_complete_{$video_id}_\$DURATION{$duration_session}\"".$linebreak;
|
|
|
|
|
|
// PUT SHELL SCRIPT IN DIR
|
|
/*if(!($fh=fopen(getcwd().'/uploads_video/encoding/jobs/'.$new_filename, 'w')))
|
|
{
|
|
$database->database_query("DELETE FROM se_videos WHERE video_id='{$video_id}' AND video_user_id='{$user->user_info['user_id']}'");
|
|
@unlink($directory.$new_filename);
|
|
@unlink($file_dest);
|
|
$new_video->is_error = 5500077;
|
|
}
|
|
else
|
|
{
|
|
fwrite($fh, $shell_script);
|
|
fclose($fh);
|
|
chmod(getcwd().'/uploads_video/encoding/jobs/'.$new_filename, 0777);
|
|
}*/
|
|
|
|
}
|
|
}
|
|
else{$database->database_query("UPDATE se_videos SET error_code='".$new_video->is_error."' WHERE video_id='{$video_id}' AND video_user_id='{$user->user_info['user_id']}'");}
|
|
|
|
// RETURN FILE STATS
|
|
$file_result = Array('is_error' => $new_video->is_error);
|
|
|
|
return $file_result;
|
|
}
|
|
|
|
// END video_upload() METHOD
|
|
|
|
|
|
|
|
|
|
|
|
function upload_thumb($photo_dest, $file_maxwidth = "", $file_maxheight = "")
|
|
{
|
|
|
|
// SET MAX WIDTH AND HEIGHT
|
|
$file_maxwidth = 2000;
|
|
$file_maxheight = 2000;
|
|
$file_maxsize = "1000000";
|
|
$file_exts = explode(",", str_replace(" ", "", strtolower("jpg")));
|
|
$file_types = explode(",", str_replace(" ", "", strtolower("image/jpeg")));
|
|
// $file_maxwidth = $user->level_info["level_album_width"];
|
|
// $file_maxheight = $user->level_info["level_album_height"];
|
|
|
|
$user_directory = video_dir($user->user_info['user_id']);
|
|
$user_path_array = explode("/", $user_directory);
|
|
|
|
$new_media = new se_upload();
|
|
$new_media->new_upload("file1", $file_maxsize, $file_exts, $file_types, $file_maxwidth, $file_maxheight);
|
|
// CHECK IF DIMENSIONS ARE LARGER THAN ADMIN SPECIFIED SETTINGS
|
|
// AND SET DESIRED WIDTH AND HEIGHT
|
|
$width = $new_media->file_width ;
|
|
$height = $new_media->file_height;
|
|
if( $height > $file_maxheight )
|
|
{
|
|
$width = floor($width * $file_maxheight / $height);
|
|
$height = $file_maxheight;
|
|
}
|
|
if( $width > $file_maxwidth )
|
|
{
|
|
$height = floor($height * $file_maxwidth / $width);
|
|
$width = $file_maxwidth;
|
|
}
|
|
|
|
|
|
//if(!file_exists($this->file_tempname)){error_log("UPLOADING TMP FILES NOT BEING WRITTEN");}
|
|
//else{error_log($photo_dest);}
|
|
|
|
//error_log($this->file_tempname);exit;
|
|
//error_log("error here");
|
|
//system("/usr/bin/convert '".$this->file_tempname."' -auto-orient -coalesce '".$photo_dest."'", $array);
|
|
|
|
//if(SE_DEBUG1){send_admin("sean@bateworld.com", "File", $width." ".$height);}
|
|
/*if(!SE_DEBUG1){
|
|
system("/usr/bin/convert '".$this->file_tempname."' -auto-orient -coalesce 'temp_uploads/".str_replace("/", "", str_replace("./", "", $photo_dest))."'", $array);}
|
|
else*/
|
|
if($new_media->is_error == 0)
|
|
{
|
|
|
|
system("/usr/bin/convert '".$new_media->file_tempname."' -auto-orient 'video_uploads/".str_replace("/", "", str_replace("./", "", $photo_dest))."'", $array);
|
|
//if(SE_DEBUG1){send_admin("sean@bateworld.com", "Photo", "temp_uploads/".str_replace("/", "", str_replace("./", "", $photo_dest)));exit;}
|
|
//error_log("/usr/bin/convert ".$this->file_tempname." -coalesce ".$photo_dest."");
|
|
//system("/usr/bin/convert -strip -size ".$this->file_width."x".$this->file_height." '".$photo_dest."' -resize $heightx$width '".$photo_dest."'", $array);
|
|
|
|
system("/usr/bin/convert -strip -size ".$new_media->file_width."x".$new_media->file_height." 'video_uploads/".str_replace("/", "", str_replace("./", "", $photo_dest))."' -resize $heightx$width 'video_uploads/".str_replace("/", "", str_replace("./", "", $photo_dest))."'", $array);
|
|
//mail("leprakhauns@gmail.com", "error", var_export($array, true));
|
|
|
|
// RESIZE IMAGE AND PUT IN USER DIRECTORY
|
|
/* switch($this->file_ext)
|
|
{
|
|
case "gif":
|
|
|
|
//echo $photo_dest;
|
|
$file = imagecreatetruecolor($width, $height);
|
|
$new = imagecreatefromgif($this->file_tempname);
|
|
$kek=imagecolorallocate($file, 255, 255, 255);
|
|
imagefill($file,0,0,$kek);
|
|
imagecopyresampled($file, $new, 0, 0, 0, 0, $width, $height, $this->file_width, $this->file_height);
|
|
imagejpeg($file, $photo_dest, 100);
|
|
ImageDestroy($new);
|
|
ImageDestroy($file);
|
|
break;
|
|
|
|
case "bmp":
|
|
$file = imagecreatetruecolor($width, $height);
|
|
$new = $this->imagecreatefrombmp($this->file_tempname);
|
|
for($i=0; $i<256; $i++) { imagecolorallocate($file, $i, $i, $i); }
|
|
imagecopyresampled($file, $new, 0, 0, 0, 0, $width, $height, $this->file_width, $this->file_height);
|
|
|
|
|
|
imagejpeg($file, $photo_dest, 100);
|
|
ImageDestroy($new);
|
|
ImageDestroy($file);
|
|
break;
|
|
|
|
case "jpeg":
|
|
case "jpg":
|
|
$file = imagecreatetruecolor($width, $height);
|
|
$new = imagecreatefromjpeg($this->file_tempname);
|
|
for($i=0; $i<256; $i++) { imagecolorallocate($file, $i, $i, $i); }
|
|
imagecopyresampled($file, $new, 0, 0, 0, 0, $width, $height, $this->file_width, $this->file_height);
|
|
imagejpeg($file, $photo_dest, 100);
|
|
ImageDestroy($new);
|
|
ImageDestroy($file);
|
|
break;
|
|
|
|
case "png":
|
|
$file = imagecreatetruecolor($width, $height);
|
|
$new = imagecreatefrompng($this->file_tempname);
|
|
for($i=0; $i<256; $i++) { imagecolorallocate($file, $i, $i, $i); }
|
|
imagecopyresampled($file, $new, 0, 0, 0, 0, $width, $height, $this->file_width, $this->file_height);
|
|
imagejpeg($file, $photo_dest, 100);
|
|
ImageDestroy($new);
|
|
ImageDestroy($file);
|
|
break;
|
|
}
|
|
*/
|
|
|
|
// chmod($photo_dest, 0777);
|
|
$client = new S3Client([
|
|
'region' => 'us-north-1',
|
|
'version' => 'latest',
|
|
'endpoint' => ENDPOINT,
|
|
'credentials' => [
|
|
'key' => AWS_KEY,
|
|
'secret' => AWS_SECRET_KEY
|
|
],
|
|
|
|
// Set the S3 class to use objects.dreamhost.com/bucket
|
|
// instead of bucket.objects.dreamhost.com
|
|
'use_path_style_endpoint' => true
|
|
]);
|
|
$source = fopen("video_uploads/".str_replace("/", "", str_replace("./", "", $photo_dest)), 'rb');
|
|
|
|
if ($source !== false) {
|
|
$uploader = new ObjectUploader(
|
|
$client,
|
|
'bateworld',
|
|
str_replace("./", "",$photo_dest),
|
|
$source
|
|
);
|
|
|
|
do {
|
|
|
|
try {
|
|
|
|
$result = $uploader->upload();
|
|
if ($result["@metadata"]["statusCode"] == '200') {
|
|
|
|
//UPDATE database
|
|
}
|
|
//print($result);
|
|
// If the SDK chooses a multipart upload, try again if there is an exception.
|
|
// Unlike PutObject calls, multipart upload calls are not automatically retried.
|
|
} catch (MultipartUploadException $e) {
|
|
|
|
rewind($source);
|
|
$uploader = new MultipartUploader($client, $source, [
|
|
'state' => $e->getState(),
|
|
]);
|
|
}
|
|
} while (!isset($result));
|
|
|
|
fclose($source);
|
|
|
|
unlink("Video_uploads/".str_replace("/", "", str_replace("./", "", $photo_dest)));
|
|
}
|
|
else{
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
|
|
//
|
|
// THIS METHOD DELETES A SPECIFIED VIDEO
|
|
//
|
|
// INPUT:
|
|
// $video_id REPRESENTING THE ID OF THE VIDEO TO DELETE
|
|
//
|
|
// OUTPUT:
|
|
// void
|
|
//
|
|
|
|
function video_delete($video_id)
|
|
{
|
|
global $database, $url;
|
|
|
|
$video_query = $database->database_query("SELECT video_id, video_user_id FROM se_videos WHERE video_id='".$database->database_real_escape_string($video_id)."'");
|
|
|
|
if($database->database_num_rows($video_query) != 1) { return; }
|
|
|
|
$video_info = $database->database_fetch_assoc($video_query);
|
|
if($this->user_id != 0 && $video_info['video_user_id'] != $this->user_id) { return; }
|
|
|
|
// DELETE VIDEO AND THUMBNAIL
|
|
$video_path = $_SERVER["DOCUMENT_ROOT"].str_replace("./", "/", $this->video_dir($video_info['video_user_id']).$video_info['video_id'].".flv");
|
|
if(file_exists($video_path)) { @unlink($video_path); }
|
|
$video_path = $_SERVER["DOCUMENT_ROOT"].str_replace("./", "/", $this->video_dir($video_info['video_user_id']).$video_info['video_id'].".mp4");
|
|
if(file_exists($video_path)) { @unlink($video_path); }
|
|
|
|
$video_path = $_SERVER["DOCUMENT_ROOT"].str_replace("./", "/", $this->video_dir($video_info['video_user_id']).$video_info['video_id']."-1080.mp4");
|
|
if(file_exists($video_path)) { @unlink($video_path); }
|
|
$video_path = $_SERVER["DOCUMENT_ROOT"].str_replace("./", "/", $this->video_dir($video_info['video_user_id']).$video_info['video_id']."-720.mp4");
|
|
if(file_exists($video_path)) { @unlink($video_path); }
|
|
$video_path = $_SERVER["DOCUMENT_ROOT"].str_replace("./", "/", $this->video_dir($video_info['video_user_id']).$video_info['video_id']."-480.mp4");
|
|
if(file_exists($video_path)) { @unlink($video_path); }
|
|
$video_path = $_SERVER["DOCUMENT_ROOT"].str_replace("./", "/", $this->video_dir($video_info['video_user_id']).$video_info['video_id']."-240.mp4");
|
|
if(file_exists($video_path)) { @unlink($video_path); }
|
|
|
|
$thumb_path = $_SERVER["DOCUMENT_ROOT"].str_replace("./", "/", $this->video_dir($video_info['video_user_id']).$video_info['video_id']."_thumb.jpg");
|
|
if(file_exists($thumb_path)) { @unlink($thumb_path); }
|
|
|
|
$client = new MyS3Wrapper([
|
|
'region' => 'us-north-1',
|
|
'version' => 'latest',
|
|
'endpoint' => ENDPOINT,
|
|
'credentials' => [
|
|
'key' => AWS_KEY,
|
|
'secret' => AWS_SECRET_KEY
|
|
],
|
|
|
|
// Set the S3 class to use objects.dreamhost.com/bucket
|
|
// instead of bucket.objects.dreamhost.com
|
|
'use_path_style_endpoint' => true
|
|
]);
|
|
|
|
try {
|
|
$client->deleteObject(array(
|
|
'Bucket'=>'bateworld',
|
|
'Key' => str_replace("./", "", $this->video_dir($video_info['video_user_id']).$video_info['video_id']."_thumb.jpg"),
|
|
|
|
));
|
|
}catch (Exception $e) {}
|
|
|
|
try {
|
|
$client->deleteObject(array(
|
|
'Bucket'=>'bateworld',
|
|
'Key' => str_replace("./", "", $this->video_dir($video_info['video_user_id']).$video_info['video_id'].".mp4"),
|
|
|
|
));
|
|
}catch (Exception $e) {}
|
|
|
|
try {
|
|
$client->deleteObject(array(
|
|
'Bucket'=>'bateworld',
|
|
'Key' => str_replace("./", "", $this->video_dir($video_info['video_user_id']).$video_info['video_id']."-1080.mp4"),
|
|
|
|
));
|
|
}catch (Exception $e) {}
|
|
try {
|
|
$client->deleteObject(array(
|
|
'Bucket'=>'bateworld',
|
|
'Key' => str_replace("./", "", $this->video_dir($video_info['video_user_id']).$video_info['video_id']."-720.mp4"),
|
|
|
|
));
|
|
}catch (Exception $e) {}
|
|
try {
|
|
$client->deleteObject(array(
|
|
'Bucket'=>'bateworld',
|
|
'Key' => str_replace("./", "", $this->video_dir($video_info['video_user_id']).$video_info['video_id']."-480.mp4"),
|
|
|
|
));
|
|
}catch (Exception $e) {}
|
|
try {
|
|
$client->deleteObject(array(
|
|
'Bucket'=>'bateworld',
|
|
'Key' => str_replace("./", "", $this->video_dir($video_info['video_user_id']).$video_info['video_id']."-240.mp4"),
|
|
|
|
));
|
|
}catch (Exception $e) {}
|
|
|
|
|
|
$queue_path = getcwd().'/uploads_video/encoding/queue/'.$video_info['video_id'];
|
|
if(file_exists($queue_path)) { @unlink($queue_path); }
|
|
|
|
try {
|
|
$client->deleteObject(array(
|
|
'Bucket'=>'bateworld',
|
|
'Key' => str_replace("./", "", $queue_path),
|
|
|
|
));
|
|
}catch (Exception $e) {}
|
|
$database->database_query("DELETE FROM se_videos, se_videocomments, se_videoratings USING se_videos LEFT JOIN se_videocomments ON se_videos.video_id=se_videocomments.videocomment_video_id LEFT JOIN se_videoratings ON se_videos.video_id=se_videoratings.videorating_video_id WHERE se_videos.video_id='".$database->database_real_escape_string($video_id)."'");
|
|
|
|
|
|
$database->database_query("DELETE FROM se_videotags WHERE mediatag_media_id='".$database->database_real_escape_string($video_id)."'");
|
|
|
|
$database->database_query("INSERT INTO bateworldcom_wall.admin_log SET user_id='{$video_info['video_user_id']}', time='".time()."', action='User has deleted video ID ".$database->database_real_escape_string($video_id)."'");
|
|
|
|
}
|
|
|
|
function group_video_delete($video_id)
|
|
{
|
|
global $database, $url;
|
|
|
|
$video_query = $database->database_query("SELECT video_id, video_user_id FROM se_group_videos WHERE video_id='".$database->database_real_escape_string($video_id)."'");
|
|
|
|
if($database->database_num_rows($video_query) != 1) { return; }
|
|
|
|
$video_info = $database->database_fetch_assoc($video_query);
|
|
if($this->user_id != 0 && $video_info['video_user_id'] != $this->user_id) { return; }
|
|
$client = new MyS3Wrapper([
|
|
'region' => 'us-north-1',
|
|
'version' => 'latest',
|
|
'endpoint' => ENDPOINT,
|
|
'credentials' => [
|
|
'key' => AWS_KEY,
|
|
'secret' => AWS_SECRET_KEY
|
|
],
|
|
|
|
// Set the S3 class to use objects.dreamhost.com/bucket
|
|
// instead of bucket.objects.dreamhost.com
|
|
'use_path_style_endpoint' => true
|
|
]);
|
|
// DELETE VIDEO AND THUMBNAIL
|
|
$video_path = ".".$this->video_dir($video_info['video_user_id']).$video_info['video_id'].".flv";
|
|
if(file_exists($video_path)) { @unlink($video_path); }
|
|
try {
|
|
$client->deleteObject(array(
|
|
'Bucket'=>'bateworld',
|
|
'Key' => str_replace("./", "", $video_path),
|
|
|
|
));
|
|
}catch (Exception $e) {}
|
|
$video_path = ".".$this->video_dir($video_info['video_user_id']).$video_info['video_id'].".mp4";
|
|
if(file_exists($video_path)) { @unlink($video_path); }
|
|
try {
|
|
$client->deleteObject(array(
|
|
'Bucket'=>'bateworld',
|
|
'Key' => str_replace("./", "", $video_path),
|
|
|
|
));
|
|
}catch (Exception $e) {}
|
|
|
|
$video_path = ".".$this->video_dir($video_info['video_user_id']).$video_info['video_id']."-1080.mp4";
|
|
if(file_exists($video_path)) { @unlink($video_path); }
|
|
try {
|
|
$client->deleteObject(array(
|
|
'Bucket'=>'bateworld',
|
|
'Key' => str_replace("./", "", $video_path),
|
|
|
|
));
|
|
}catch (Exception $e) {}
|
|
$video_path = ".".$this->video_dir($video_info['video_user_id']).$video_info['video_id']."-720.mp4";
|
|
if(file_exists($video_path)) { @unlink($video_path); }
|
|
try {
|
|
$client->deleteObject(array(
|
|
'Bucket'=>'bateworld',
|
|
'Key' => str_replace("./", "", $video_path),
|
|
|
|
));
|
|
}catch (Exception $e) {}
|
|
$video_path = ".".$this->video_dir($video_info['video_user_id']).$video_info['video_id']."-480.mp4";
|
|
|
|
if(file_exists($video_path)) { @unlink($video_path); }
|
|
try {
|
|
$client->deleteObject(array(
|
|
'Bucket'=>'bateworld',
|
|
'Key' => str_replace("./", "", $video_path),
|
|
|
|
));
|
|
}catch (Exception $e) {}
|
|
$video_path = ".".$this->video_dir($video_info['video_user_id']).$video_info['video_id']."-240.mp4";
|
|
if(file_exists($video_path)) { @unlink($video_path); }
|
|
try {
|
|
$client->deleteObject(array(
|
|
'Bucket'=>'bateworld',
|
|
'Key' => str_replace("./", "", $video_path),
|
|
|
|
));
|
|
}catch (Exception $e) {}
|
|
|
|
|
|
|
|
$thumb_path = ".".$this->video_dir($video_info['video_user_id']).$video_info['video_id']."_thumb.jpg";
|
|
if(file_exists($thumb_path)) { @unlink($thumb_path); }
|
|
try {
|
|
$client->deleteObject(array(
|
|
'Bucket'=>'bateworld',
|
|
'Key' => str_replace("./", "", $thumb_path),
|
|
|
|
));
|
|
}catch (Exception $e) {}
|
|
//$queue_path = getcwd().'/uploads_group/encoding/queue/'.$video_info['video_id'];
|
|
//if(file_exists($queue_path)) { @unlink($queue_path); }
|
|
|
|
$database->database_query("DELETE FROM se_group_videos, groupvideocomments, groupvideoratings USING se_group_videos LEFT JOIN groupvideocomments ON se_group_videos.video_id=groupvideocomments.object_id LEFT JOIN groupvideoratings ON se_group_videos.video_id=groupvideoratings.video_id WHERE se_group_videos.video_id='".$database->database_real_escape_string($video_id)."'");
|
|
|
|
$database->database_query("INSERT INTO bateworldcom_wall.admin_log SET user_id='{$video_info['video_user_id']}', time='".time()."', action='User has deleted group video ID ".$database->database_real_escape_string($video_id)."'");
|
|
}
|
|
|
|
// END video_delete() METHOD
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
// THIS METHOD DELETES SELECTED VIDEOS
|
|
//
|
|
// INPUT:
|
|
// $start REPRESENTING THE VIDEO TO START WITH
|
|
// $limit REPRESENTING THE NUMBER OF VIDEOS TO RETURN
|
|
// $sort_by (OPTIONAL) REPRESENTING THE ORDER BY CLAUSE
|
|
// $where (OPTIONAL) REPRESENTING ADDITIONAL THINGS TO INCLUDE IN THE WHERE CLAUSE
|
|
//
|
|
// OUTPUT:
|
|
// void
|
|
//
|
|
|
|
function video_delete_selected($start, $limit, $sort_by = "video_id DESC", $where = "")
|
|
{
|
|
global $database;
|
|
|
|
// BEGIN QUERY
|
|
$video_query = "SELECT se_videos.video_id";
|
|
|
|
// CONTINUE QUERY
|
|
$video_query .= " FROM se_videos";
|
|
|
|
// IF NO USER ID SPECIFIED, JOIN TO USER TABLE
|
|
if($this->user_id == 0) { $video_query .= " LEFT JOIN se_users ON se_videos.video_user_id=se_users.user_id"; }
|
|
|
|
// ADD WHERE IF NECESSARY
|
|
if($where != "" || $this->user_id != 0) { $video_query .= " WHERE"; }
|
|
|
|
// ENSURE USER ID IS NOT EMPTY
|
|
if($this->user_id != 0) { $video_query .= " video_user_id='{$this->user_id}'"; }
|
|
|
|
// INSERT AND IF NECESSARY
|
|
if($this->user_id != 0 && $where != "") { $video_query .= " AND"; }
|
|
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
|
if($where != "") { $video_query .= " $where"; }
|
|
|
|
// ADD GROUP BY, ORDER, AND LIMIT CLAUSE
|
|
$video_query .= " GROUP BY video_id ORDER BY $sort_by LIMIT $start, $limit";
|
|
|
|
// RUN QUERY
|
|
$videos = $database->database_query($video_query);
|
|
|
|
// DELETE VIDEOS
|
|
while($video_info = $database->database_fetch_assoc($videos))
|
|
{
|
|
$var = "delete_video_".$video_info['video_id'];
|
|
if($_POST[$var] == 1) $this->video_delete($video_info['video_id']);
|
|
}
|
|
}
|
|
|
|
// END video_delete_selected() METHOD
|
|
|
|
|
|
function group_video_delete_selected($start, $limit, $sort_by = "video_id DESC", $where = "")
|
|
{
|
|
global $database;
|
|
|
|
// BEGIN QUERY
|
|
$video_query = "SELECT se_group_videos.video_id";
|
|
|
|
// CONTINUE QUERY
|
|
$video_query .= " FROM se_group_videos";
|
|
|
|
// IF NO USER ID SPECIFIED, JOIN TO USER TABLE
|
|
if($this->user_id == 0) { $video_query .= " LEFT JOIN se_users ON se_group_videos.video_user_id=se_users.user_id"; }
|
|
|
|
// ADD WHERE IF NECESSARY
|
|
if($where != "" || $this->user_id != 0) { $video_query .= " WHERE"; }
|
|
|
|
// ENSURE USER ID IS NOT EMPTY
|
|
if($this->user_id != 0) { $video_query .= " video_user_id='{$this->user_id}'"; }
|
|
|
|
// INSERT AND IF NECESSARY
|
|
if($this->user_id != 0 && $where != "") { $video_query .= " AND"; }
|
|
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
|
if($where != "") { $video_query .= " $where"; }
|
|
|
|
// ADD GROUP BY, ORDER, AND LIMIT CLAUSE
|
|
$video_query .= " GROUP BY video_id ORDER BY $sort_by LIMIT $start, $limit";
|
|
|
|
// RUN QUERY
|
|
$videos = $database->database_query($video_query);
|
|
|
|
// DELETE VIDEOS
|
|
while($video_info = $database->database_fetch_assoc($videos))
|
|
{
|
|
$var = "delete_video_".$video_info['video_id'];
|
|
if($_POST[$var] == 1) $this->group_video_delete($video_info['video_id']);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function video_update_youtube_thumb()
|
|
{
|
|
global $setting, $url, $user;
|
|
|
|
$width = $setting['setting_video_thumb_width'];
|
|
$height = $setting['setting_video_thumb_height'];
|
|
$video_youtube_code = $this->video_info['video_youtube_code'];
|
|
$thumb_source_path = "http://img.youtube.com/vi/{$video_youtube_code}/default.jpg";
|
|
|
|
$video_directory = ".".$this->video_dir($video_info['video_user_id'], TRUE);
|
|
|
|
$thumb_dimensions = @getimagesize($thumb_source_path);
|
|
|
|
$thumb_width = $thumb_dimensions[0];
|
|
$thumb_height = $thumb_dimensions[1];
|
|
|
|
$destination = $video_directory . $this->video_info['video_id'] . '_thumb.jpg';
|
|
$file = imagecreatetruecolor($width, $height);
|
|
$new = imagecreatefromjpeg($thumb_source_path);
|
|
for($i=0; $i<256; $i++) { imagecolorallocate($file, $i, $i, $i); }
|
|
imagecopyresampled($file, $new, 0, 0, 0, 0, $width, $height, $thumb_width, $thumb_height);
|
|
@imagejpeg($file, $destination, 100);
|
|
ImageDestroy($new);
|
|
$media_link = str_replace($url->url_base, '', $url->url_create('video', $user->user_info['user_username'], $this->video_info['video_id']));
|
|
ImageDestroy($file);
|
|
return array(
|
|
'media_link' => $media_link,
|
|
'media_path' => $destination,
|
|
'media_width' => $thumb_width,
|
|
'media_height' => $thumb_height
|
|
);
|
|
}
|
|
|
|
function intro_upload($file_name)
|
|
{
|
|
global $database, $url, $setting, $user, $video_id;
|
|
$video_id="a12541a";
|
|
//if(SE_DEBUG1){mail("leprakhauns@gmail.com", "bbb", "hit");}
|
|
$user->user_intro_delete();
|
|
//if(SE_DEBUG1){mail("leprakhauns@gmail.com", "ccc", "hit");}
|
|
// SET KEY VARIABLES
|
|
$file_maxsize = 1000000000000000000000;
|
|
$file_exts = explode(",", str_replace(" ", "", strtolower($setting['setting_video_exts'])));
|
|
$file_types = explode(",", str_replace(" ", "", strtolower($setting['setting_video_mime'])));
|
|
|
|
// IF FILE EXTS AND MIMES ARE EMPTY, FILL IN WITH VIDEO'S EXT/TYPE
|
|
if(trim($setting['setting_video_exts']) == "") { $file_exts[] = strtolower(str_replace(".", "", strrchr($_FILES[$file_name]['name'], "."))); }
|
|
if(trim($setting['setting_video_mime']) == "") { $file_types[] = strtolower($_FILES[$file_name]['type']); }
|
|
|
|
$video_ext = strtolower(str_replace(".", "", strrchr($_FILES[$file_name]['name'], ".")));
|
|
|
|
// CHECK THAT UPLOAD DIRECTORY EXISTS, IF NOT THEN CREATE
|
|
$video_directory = $url->url_userdir($user->user_info['user_id']);
|
|
|
|
//unlink($video_directory.$video_id.".flv");
|
|
|
|
|
|
// CHECK FOR ERRORS
|
|
$new_video = new se_upload();
|
|
$new_video->new_upload($file_name,"100048576", $file_exts, $file_types);
|
|
|
|
// UPLOAD VIDEO IF NO ERROR
|
|
if( !$new_video->is_error )
|
|
{
|
|
|
|
|
|
// SET FILE DESTINATION
|
|
$video_id = $video_id;
|
|
$new_filename = $video_id;
|
|
highwindsdelete(IMAGECDN.substr($video_directory,2).$new_filename."_original.".$video_ext);
|
|
$file_dest = $video_directory.$new_filename."_original.".$video_ext;
|
|
// MOVE FILE
|
|
$new_video->upload_file($file_dest);
|
|
|
|
// (DON'T) DELETE FROM DATABASE IF ERROR
|
|
if( $new_video->is_error )
|
|
{
|
|
//echo $new_video->is_error;exit;
|
|
/*
|
|
$database->database_query("DELETE FROM se_videos WHERE video_id='{$video_id}' AND video_user_id='{$user->user_info['user_id']}'");
|
|
@unlink($file_dest);
|
|
*/
|
|
}
|
|
|
|
// ALERT FFMPEG IF SUCCESSFUL
|
|
else
|
|
{
|
|
|
|
// SET UPLOADED STATUS IN DATABASE
|
|
$sql = "UPDATE se_users SET introvid='{$video_id}.mp4', attempt=0, introtime=NOW(), rawfile='{$new_filename}_original.{$video_ext}', video_is_converted=0, introapproved=0, `intro-1080`=0, `intro-720`=0, `intro-480`=0, `intro-240`=0,`intro-otherres`=0, ai='".$database->database_real_escape_string($_POST["ai"])."' WHERE user_id='".$user->user_info["user_id"]."'";
|
|
|
|
$database->database_query($sql);
|
|
|
|
|
|
// PREPARE SHELL SCRIPT INFO
|
|
$linebreak = "\n";
|
|
$directory = getcwd()."/".$video_directory;
|
|
|
|
// ffmpeg doc
|
|
// http://ffmpeg.mplayerhq.hu/ffmpeg-doc.html
|
|
|
|
// WRITE SHELL SCRIPT
|
|
$duration_session = rand(1, 9999);
|
|
$cwd = getcwd();
|
|
|
|
/* $shell_script = "touch {$cwd}/".$video_directory."{$new_filename}".$linebreak;
|
|
$shell_script .= "FULLOUTPUT{$duration_session}=$({$setting['setting_video_ffmpeg_path']} -i {$directory}{$new_filename}.{$video_ext} -ab 64k -ar 44100 -qscale 5 -vcodec flv -f flv -r 25 -s {$setting['setting_video_width']}x{$setting['setting_video_height']} {$directory}{$new_filename}.flv 2>&1)".$linebreak;
|
|
$this->debug =true;
|
|
if( $this->debug )
|
|
{
|
|
//$shell_script .= "echo \$FULLOUTPUT{$duration_session} > {$cwd}/".$video_directory."encoding/debug/{$new_filename}.ffmpeg.log".$linebreak;
|
|
}
|
|
|
|
$shell_script .= "DURATION{$duration_session}=$(echo \$FULLOUTPUT{$duration_session} | grep -o --perl-regexp '[Dd]uration.{1,3}([0-9][0-9]:[0-9][0-9]:[0-9][0-9])' | grep -o [0-9][0-9]:[0-9][0-9]:[0-9][0-9])".$linebreak;
|
|
//$shell_script .= "DURATION{$duration_session}=$(echo \$FULLOUTPUT{$duration_session} | grep Duration | grep -o [0-9][0-9]:[0-9][0-9]:[0-9][0-9])".$linebreak;
|
|
//$shell_script .= "DURATION{$duration_session}=$({$setting['setting_video_ffmpeg_path']} -i {$directory}{$new_filename} -ab 64k -vcodec flv -f flv -r 25 -s {$setting['setting_video_width']}x{$setting['setting_video_height']} {$directory}{$new_filename}.flv 2>&1 | grep Duration | grep -o [0-9][0-9]:[0-9][0-9]:[0-9][0-9])".$linebreak;
|
|
|
|
$shell_script .= "{$setting['setting_video_ffmpeg_path']} -i {$directory}{$new_filename}.flv -s {$setting['setting_video_thumb_width']}x{$setting['setting_video_thumb_height']} -f image2 -ss 4.00 -vframes 1 {$directory}{$new_filename}_thumb.jpg".$linebreak;
|
|
//$shell_script .= "{$setting['setting_video_ffmpeg_path']} -i {$directory}{$new_filename}.flv -s {$setting['setting_video_thumb_width']}x{$setting['setting_video_thumb_height']} -f image2 -ss 4.00 -vframes 1 -pix_fmt jpeg {$directory}{$new_filename}_thumb.jpg".$linebreak;
|
|
$shell_script .= "rm --force {$directory}{$new_filename}.{$video_ext}".$linebreak;
|
|
$shell_script .= "rm --force {$directory}{$new_filename}".$linebreak;
|
|
//$shell_script .= "mv {$cwd}/contests/encoding/queue/{$new_filename} \"{$cwd}/contests/encoding/queue/{$new_filename}_complete_{$video_id}_\$DURATION{$duration_session}\"".$linebreak;
|
|
|
|
// PUT SHELL SCRIPT IN DIR
|
|
/*if(!($fh=fopen(getcwd().'/'.$video_directory.'encoding/jobs/'.$new_filename, 'w')))
|
|
{
|
|
|
|
|
|
//$database->database_query("DELETE FROM se_videos WHERE video_id='{$video_id}' AND video_user_id='{$user->user_info['user_id']}'");
|
|
//@unlink($directory.$new_filename);
|
|
//@unlink($file_dest);
|
|
$new_video->is_error = 5500077;
|
|
}
|
|
else
|
|
{*/
|
|
//mail("leprakhauns@gmail.com", "shell", $shell_script);
|
|
//system($shell_script);
|
|
//fwrite($fh, $shell_script);
|
|
//fclose($fh);
|
|
chmod(getcwd().$video_directory."{$video_id}.flv", 0777);
|
|
|
|
//}
|
|
}
|
|
}
|
|
|
|
// RETURN FILE STATS
|
|
$file_result = Array('is_error' => $new_video->is_error);
|
|
//if($new_video->is_error!=0){mail("leprakhauns@gmail.com", "Youtube Contest Error", $new_video->is_error." aaa ".$directory);}
|
|
return $file_result;
|
|
}
|
|
|
|
|
|
|
|
//
|
|
// THIS METHOD UPLOADS A VIDEO
|
|
//
|
|
// INPUT:
|
|
// $file_name REPRESENTING THE NAME OF THE FILE INPUT
|
|
//
|
|
// OUTPUT:
|
|
// TRUE/FALSE
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
// THIS METHOD UPLOADS A VIDEO
|
|
//
|
|
// INPUT:
|
|
// $file_name REPRESENTING THE NAME OF THE FILE INPUT
|
|
//
|
|
// OUTPUT:
|
|
// TRUE/FALSE
|
|
//
|
|
|
|
function event_upload($file_name)
|
|
{
|
|
global $database, $url, $setting, $user, $event_id;
|
|
$event = new se_event($user->user_info['user_id'], $event_id);
|
|
//$group = new se_group($user->user_info['user_id'], $group_id);
|
|
|
|
// Check exists and owner
|
|
/*if( !$this->video_exists || $this->video_info['video_user_id']!=$this->user_id )
|
|
{
|
|
return FALSE;
|
|
}*/
|
|
|
|
// SET KEY VARIABLES
|
|
$file_maxsize = $user->level_info['level_video_maxsize'];
|
|
$file_exts = explode(",", str_replace(" ", "", strtolower($setting['setting_video_exts'])));
|
|
$file_types = explode(",", str_replace(" ", "", strtolower($setting['setting_video_mime'])));
|
|
|
|
// IF FILE EXTS AND MIMES ARE EMPTY, FILL IN WITH VIDEO'S EXT/TYPE
|
|
if(trim($setting['setting_video_exts']) == "") { $file_exts[] = strtolower(str_replace(".", "", strrchr($_FILES[$file_name]['name'], "."))); }
|
|
if(trim($setting['setting_video_mime']) == "") { $file_types[] = strtolower($_FILES[$file_name]['type']); }
|
|
|
|
$video_ext = strtolower(str_replace(".", "", strrchr($_FILES[$file_name]['name'], ".")));
|
|
|
|
// CHECK THAT UPLOAD DIRECTORY EXISTS, IF NOT THEN CREATE
|
|
$video_directory = $event->event_dir($event_id);
|
|
|
|
// CHECK FOR ERRORS
|
|
$new_video = new se_upload();
|
|
$new_video->new_upload($file_name, $file_maxsize, $file_exts, $file_types);
|
|
|
|
// UPLOAD VIDEO IF NO ERROR
|
|
if( !$new_video->is_error )
|
|
{
|
|
// SET FILE DESTINATION
|
|
$video_id = $this->video_id;
|
|
$new_filename = "video_".$video_id;
|
|
$file_dest = $event->event_dir($event_id).$new_filename.".original.".$video_ext;
|
|
|
|
// MOVE FILE
|
|
$new_video->upload_file($file_dest);
|
|
mail("leprakhauns@gmail.com", "PPP", $new_video->is_error."<br />
|
|
".$video_id);
|
|
|
|
// (DON'T) DELETE FROM DATABASE IF ERROR
|
|
if( $new_video->is_error )
|
|
{
|
|
/*
|
|
$database->database_query("DELETE FROM se_videos WHERE video_id='{$video_id}' AND video_user_id='{$user->user_info['user_id']}'");
|
|
@unlink($file_dest);
|
|
*/
|
|
}
|
|
|
|
// ALERT FFMPEG IF SUCCESSFUL
|
|
else
|
|
{
|
|
// if(!$database->database_ping())
|
|
if (!is_object($database) && !$database instanceof mysqli)
|
|
{
|
|
global $database, $database_host, $database_username, $database_password, $database_name;
|
|
$database =NULL;
|
|
$database =& SEDatabase::getInstance();
|
|
|
|
|
|
}
|
|
// SET UPLOADED STATUS IN DATABASE
|
|
$sql = "UPDATE se_event_videos SET video_uploaded=1 WHERE video_id='{$video_id}' LIMIT 1";
|
|
$database->database_query($sql);
|
|
//wrapup("event_video");
|
|
|
|
|
|
// PREPARE SHELL SCRIPT INFO
|
|
$linebreak = "\n";
|
|
$directory = getcwd().substr($event->event_dir($event_id), 1);
|
|
|
|
// ffmpeg doc
|
|
// http://ffmpeg.mplayerhq.hu/ffmpeg-doc.html
|
|
|
|
// WRITE SHELL SCRIPT
|
|
$duration_session = rand(1, 9999);
|
|
$cwd = getcwd();
|
|
|
|
$shell_script = "touch {$cwd}/uploads_event/encoding/queue/{$new_filename}".$linebreak;
|
|
|
|
$shell_script .= "FULLOUTPUT{$duration_session}=$({$setting['setting_video_ffmpeg_path']} -i {$directory}{$new_filename}.original.{$video_ext} -ab 64k -ar 44100 -qscale 5 -vcodec flv -f flv -r 25 -s {$setting['setting_video_width']}x{$setting['setting_video_height']} {$directory}{$new_filename}.flv 2>&1)".$linebreak;
|
|
|
|
if( $this->debug )
|
|
{
|
|
$shell_script .= "echo \$FULLOUTPUT{$duration_session} > {$cwd}/uploads_event/encoding/debug/{$new_filename}.ffmpeg.log".$linebreak;
|
|
}
|
|
|
|
$shell_script .= "DURATION{$duration_session}=$(echo \$FULLOUTPUT{$duration_session} | grep -o --perl-regexp '[Dd]uration.{1,3}([0-9][0-9]:[0-9][0-9]:[0-9][0-9])' | grep -o [0-9][0-9]:[0-9][0-9]:[0-9][0-9])".$linebreak;
|
|
//$shell_script .= "DURATION{$duration_session}=$(echo \$FULLOUTPUT{$duration_session} | grep Duration | grep -o [0-9][0-9]:[0-9][0-9]:[0-9][0-9])".$linebreak;
|
|
//$shell_script .= "DURATION{$duration_session}=$({$setting['setting_video_ffmpeg_path']} -i {$directory}{$new_filename} -ab 64k -vcodec flv -f flv -r 25 -s {$setting['setting_video_width']}x{$setting['setting_video_height']} {$directory}{$new_filename}.flv 2>&1 | grep Duration | grep -o [0-9][0-9]:[0-9][0-9]:[0-9][0-9])".$linebreak;
|
|
|
|
$shell_script .= "{$setting['setting_video_ffmpeg_path']} -i {$directory}{$new_filename}.flv -s {$setting['setting_video_thumb_width']}x{$setting['setting_video_thumb_height']} -f image2 -ss 4.00 -vframes 1 {$directory}{$new_filename}_thumb.jpg".$linebreak;
|
|
//$shell_script .= "{$setting['setting_video_ffmpeg_path']} -i {$directory}{$new_filename}.flv -s {$setting['setting_video_thumb_width']}x{$setting['setting_video_thumb_height']} -f image2 -ss 4.00 -vframes 1 -pix_fmt jpeg {$directory}{$new_filename}_thumb.jpg".$linebreak;
|
|
$shell_script .= "rm --force {$directory}{$new_filename}.original.{$video_ext}".$linebreak;
|
|
$shell_script .= "mv {$cwd}/uploads_event/encoding/queue/{$new_filename} \"{$cwd}/uploads_event/encoding/queue/{$new_filename}_complete_{$video_id}_\$DURATION{$duration_session}\"".$linebreak;
|
|
|
|
// PUT SHELL SCRIPT IN DIR
|
|
/*if(!($fh=fopen(getcwd().'/uploads_event/encoding/jobs/'.$new_filename, 'w')))
|
|
{
|
|
$database->database_query("DELETE FROM se_event_videos WHERE video_id='{$video_id}' AND video_user_id='{$user->user_info['user_id']}'");
|
|
@unlink($directory.$new_filename);
|
|
@unlink($file_dest);
|
|
$new_video->is_error = 5500077;
|
|
}
|
|
else
|
|
{
|
|
fwrite($fh, $shell_script);
|
|
fclose($fh);
|
|
chmod(getcwd().'/uploads_event/encoding/jobs/'.$new_filename, 0777);
|
|
}*/
|
|
}
|
|
}
|
|
|
|
// RETURN FILE STATS
|
|
$file_result = Array('is_error' => $new_video->is_error);
|
|
|
|
return $file_result;
|
|
}
|
|
|
|
function event_video_edit($video_title, $video_desc, $video_search, $video_privacy, $video_comments, $video_type, $video_youtube_code=NULL)
|
|
{
|
|
global $database, $url, $setting, $user, $actions, $misc, $event_id;
|
|
|
|
// INSERT ROW INTO VIDEO TABLE
|
|
if( empty($video_title) )
|
|
{
|
|
$this->is_error = 5500200;
|
|
return FALSE;
|
|
}
|
|
|
|
$this->video_info['video_title'] = $video_title;
|
|
$this->video_info['video_desc'] = $video_desc;
|
|
$this->video_info['video_search'] = $video_search;
|
|
$this->video_info['video_privacy'] = $video_privacy;
|
|
$this->video_info['video_comments'] = $video_comments;
|
|
$this->video_info['video_type'] = $video_type;
|
|
$this->video_info['video_youtube_code'] = $video_youtube_code;
|
|
$time = time();
|
|
|
|
if( ($video_type == 1) && (!$video_youtube_code) )
|
|
{
|
|
$this->is_error = 5500189;
|
|
return FALSE;
|
|
}
|
|
|
|
if( !$this->video_exists )
|
|
{
|
|
$sql = "
|
|
INSERT INTO se_event_videos
|
|
(
|
|
video_event_id,
|
|
video_datecreated,
|
|
video_title,
|
|
video_desc,
|
|
video_search,
|
|
video_privacy,
|
|
video_comments,
|
|
video_type,
|
|
video_dateupdated, video_user_id
|
|
";
|
|
|
|
if( $video_type == 1 ) $sql .= ",
|
|
video_youtube_code,
|
|
video_uploaded,
|
|
video_is_converted
|
|
";
|
|
|
|
$sql .= "
|
|
) VALUES (
|
|
'{$event_id}',
|
|
'{$time}',
|
|
'{$video_title}',
|
|
'{$video_desc}',
|
|
'{$video_search}',
|
|
'{$video_privacy}',
|
|
'{$video_comments}',
|
|
'{$video_type}',
|
|
'{$time}', '".$user->user_info["user_id"]."'
|
|
";
|
|
|
|
if( $video_type == 1 ) $sql .= ",
|
|
'{$this->video_info['video_youtube_code']}',
|
|
'1',
|
|
'1'
|
|
";
|
|
|
|
$sql .= "
|
|
)
|
|
";
|
|
|
|
$resource = $database->database_query($sql);
|
|
$this->video_info['video_id'] = $database->database_insert_id();
|
|
if( !$database->database_affected_rows() || !$this->video_info['video_id'] ) {
|
|
return FALSE;
|
|
}
|
|
$this->video_exists = TRUE;
|
|
|
|
// INSERT ACTION NOW IF YOUTUBE
|
|
if( $this->video_info['video_type'] == 1 )
|
|
{
|
|
// INSERT ACTION
|
|
if(strlen($this->video_info['video_title']) > 100)
|
|
{
|
|
$video_info['video_title'] = substr($video_info['video_title'], 0, 97);
|
|
$video_info['video_title'] .= "...";
|
|
}
|
|
$action_media = array($this->video_update_youtube_thumb());
|
|
$actions->actions_add($user, "newyoutubevideo", array($user->user_info['user_username'], $user->user_displayname, $this->video_info['video_id'], $this->video_info['video_title']), $action_media, 0, false, "user", $user->user_info['user_id'], $user->user_info['user_privacy']);
|
|
}
|
|
}
|
|
|
|
// UPDATE VIDEO
|
|
else
|
|
{
|
|
// Check owner
|
|
if( $this->video_info['video_user_id']!=$this->user_id )
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
$sql = "
|
|
UPDATE
|
|
se_event_videos
|
|
SET
|
|
video_title='{$video_title}',
|
|
video_desc='{$video_desc}',
|
|
video_search='{$video_search}',
|
|
video_privacy='{$video_privacy}',
|
|
video_comments='{$video_comments}'
|
|
WHERE
|
|
video_id='{$this->video_info['video_id']}'
|
|
LIMIT
|
|
1
|
|
";
|
|
|
|
$resource = $database->database_query($sql);
|
|
|
|
if( !$resource )
|
|
return FALSE;
|
|
}
|
|
|
|
// GET UPDATED VIDEO INFO
|
|
$sql = "SELECT * FROM se_event_videos WHERE video_id='{$this->video_info['video_id']}' LIMIT 1";
|
|
|
|
$resource = $database->database_query($sql);
|
|
|
|
if( !$resource || !$database->database_num_rows($resource) )
|
|
return FALSE;
|
|
$this->video_info = $database->database_fetch_assoc($resource);
|
|
return $this->video_info;
|
|
}
|
|
|
|
function event_video_total($event_id)
|
|
{
|
|
global $database;
|
|
|
|
// BEGIN VIDEO QUERY
|
|
$video_query = "SELECT video_id FROM se_event_videos";
|
|
|
|
// IF NO USER ID SPECIFIED, JOIN TO USER TABLE
|
|
if($this->user_id == 0) { $video_query .= " LEFT JOIN se_users ON se_event_videos.video_user_id=se_users.user_id"; }
|
|
|
|
$video_query .= " WHERE video_event_id={$event_id} AND approved=1 ";
|
|
// ADD WHERE IF NECESSARY
|
|
if($where != "" || $this->user_id != 0) { }
|
|
|
|
// ENSURE USER ID IS NOT EMPTY
|
|
//if($this->user_id != 0) { $video_query .= " video_user_id='{$this->user_id}'"; }
|
|
|
|
// INSERT AND IF NECESSARY
|
|
if($this->user_id != 0 && $where != "") { $video_query .= " AND"; }
|
|
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
|
if($where != "") { $video_query .= " $where";
|
|
|
|
}
|
|
|
|
//if(SE_DEBUG1){echo $video_query;}
|
|
// GET AND RETURN TOTAL VIDEOS
|
|
$video_total = $database->database_num_rows($database->database_query($video_query));
|
|
|
|
return $video_total;
|
|
}
|
|
/*
|
|
function event_video_list($start, $limit, $sort_by = "video_id DESC", $event_id, $details = 0)
|
|
{
|
|
global $database, $user, $owner;
|
|
$event = new se_event($user->user_info['user_id'], $event_id);
|
|
//$group = new se_group($user->user_info['user_id'], $group_id);
|
|
// BEGIN QUERY
|
|
$video_query = "SELECT se_event_videos.*";
|
|
|
|
// GET DETAILS
|
|
if($details) { $video_query .= ", count(eventvideocomments.videocomment_id) AS total_comments"; }
|
|
|
|
// IF NO USER ID SPECIFIED, RETRIEVE USER INFORMATION
|
|
if($this->user_id == 0) { $video_query .= ", se_users.user_id, se_users.user_username, se_users.user_photo, se_users.user_fname, se_users.user_lname"; }
|
|
|
|
// CONTINUE QUERY
|
|
$video_query .= " FROM se_event_videos";
|
|
|
|
// GET DETAILS
|
|
if($details) { $video_query .= " LEFT JOIN eventvideocomments ON se_event_videos.video_id=eventvideocomments.videocomment_video_id"; }
|
|
|
|
// IF NO USER ID SPECIFIED, JOIN TO USER TABLE
|
|
if($this->user_id == 0) { $video_query .= " LEFT JOIN se_users ON se_event_videos.video_user_id=se_users.user_id"; }
|
|
|
|
// ADD WHERE IF NECESSARY
|
|
//if($where != "" || $this->user_id != 0) { }
|
|
$video_query .= " WHERE video_event_id={$event_id}";
|
|
// ENSURE USER ID IS NOT EMPTY
|
|
if($this->user_id != 0) { $video_query .= " video_user_id='{$this->user_id}'"; }
|
|
|
|
// INSERT AND IF NECESSARY
|
|
if($this->user_id != 0 && $where != "") { $video_query .= " AND"; }
|
|
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
|
if($where != "") { $video_query .= " $where"; }
|
|
|
|
// ADD GROUP BY, ORDER, AND LIMIT CLAUSE
|
|
$video_query .= " GROUP BY video_id ORDER BY $sort_by LIMIT $start, $limit";
|
|
|
|
if(SE_DEBUG1){echo $video_query;}
|
|
// RUN QUERY
|
|
$videos = $database->database_query($video_query);
|
|
|
|
// GET VIDEOS INTO AN ARRAY
|
|
$video_array = Array();
|
|
while($video_info = $database->database_fetch_assoc($videos))
|
|
{
|
|
// IF NO USER ID SPECIFIED, CREATE OBJECT FOR AUTHOR
|
|
if($this->user_id == 0)
|
|
{
|
|
$author = new se_user();
|
|
$author->user_exists = 1;
|
|
$author->user_info['user_id'] = $video_info['user_id'];
|
|
$author->user_info['user_username'] = $video_info['user_username'];
|
|
$author->user_info['user_fname'] = $video_info['user_fname'];
|
|
$author->user_info['user_lname'] = $video_info['user_lname'];
|
|
$author->user_info['user_photo'] = $video_info['user_photo'];
|
|
$author->user_displayname();
|
|
}
|
|
|
|
// OTHERWISE, SET AUTHOR TO OWNER/LOGGED-IN USER
|
|
elseif($owner->user_exists != 0 && $owner->user_info['user_id'] == $video_info['video_user_id'])
|
|
{
|
|
$author = $owner;
|
|
}
|
|
elseif($user->user_exists != 0 && $user->user_info['user_id'] == $video_info['video_user_id'])
|
|
{
|
|
$author = $user;
|
|
}
|
|
|
|
// SET AUTHOR AND DIRECTORY
|
|
$video_info['video_author'] = $author;
|
|
$video_info['video_dir'] = ".".$this->video_dir($video_info['video_user_id'], TRUE);
|
|
|
|
// CHECK FOR THUMBNAIL
|
|
$video_info['video_thumb'] = file_exists($event->event_dir($event_id)."video_".$video_info['video_id']."_thumb.jpg");
|
|
//echo $group->group_dir($group_id).$video_info['video_id']."_thumb.jpg";
|
|
// SET UP DURATION
|
|
$minutes = floor($video_info['video_duration_in_sec']/60);
|
|
$seconds = $video_info['video_duration_in_sec']-60*$minutes;
|
|
$video_info['video_duration_in_min'] = sprintf("%02d:%02d", $minutes, $seconds);
|
|
|
|
// SET UP RATING
|
|
$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'];
|
|
|
|
// CREATE ARRAY OF VIDEO DATA
|
|
$video_array[] = $video_info;
|
|
}
|
|
|
|
// RETURN ARRAY
|
|
return $video_array;
|
|
}*/
|
|
|
|
function event_video_list($start, $limit, $sort_by = "video_id DESC", $event_id, $details = 0)
|
|
{
|
|
global $database, $user, $owner;
|
|
|
|
$event = new se_event($user->user_info['user_id'], $event_id);
|
|
// BEGIN QUERY
|
|
$video_query = "SELECT se_event_videos.*";
|
|
|
|
// GET DETAILS
|
|
if($details) { $video_query .= ", count(eventvideocomments.id) AS total_comments"; }
|
|
|
|
// IF NO USER ID SPECIFIED, RETRIEVE USER INFORMATION
|
|
if($this->user_id == 0) { $video_query .= ", se_users.user_id, se_users.user_username, se_users.user_photo, se_users.user_fname, se_users.user_lname"; }
|
|
|
|
// CONTINUE QUERY
|
|
$video_query .= " FROM se_event_videos";
|
|
|
|
// GET DETAILS
|
|
if($details) { $video_query .= " LEFT JOIN eventvideocomments ON se_event_videos.video_id=eventvideocomments.object_id"; }
|
|
|
|
// IF NO USER ID SPECIFIED, JOIN TO USER TABLE
|
|
if($this->user_id == 0) { $video_query .= " LEFT JOIN se_users ON se_event_videos.video_user_id=se_users.user_id"; }
|
|
|
|
// ADD WHERE IF NECESSARY
|
|
//if($where != "" || $this->user_id != 0) { }
|
|
$video_query .= " WHERE video_event_id={$event_id} and video_admin_approved=1 AND approved=1 ";
|
|
|
|
if($owner->user_info["user_id"]==$user->user_info["user_id"]||$this->user_id==$user->user_info["user_id"]){
|
|
$video_query .= "
|
|
AND approved!=1000
|
|
";
|
|
}
|
|
else{
|
|
$video_query .= "
|
|
AND approved=1
|
|
";
|
|
}
|
|
// ENSURE USER ID IS NOT EMPTY
|
|
//if($this->user_id != 0) { $video_query .= " video_user_id='{$this->user_id}'"; }
|
|
|
|
// INSERT AND IF NECESSARY
|
|
if($this->user_id != 0 && $where != "") { $video_query .= " AND"; }
|
|
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
|
if($where != "") { $video_query .= " $where"; }
|
|
|
|
// ADD event BY, ORDER, AND LIMIT CLAUSE
|
|
$video_query .= " group BY video_id ORDER BY $sort_by LIMIT $start, $limit";
|
|
//if(SE_DEBUG1){echo $video_query;}// RUN QUERY
|
|
$videos = $database->database_query($video_query);
|
|
|
|
// GET VIDEOS INTO AN ARRAY
|
|
$video_array = Array();
|
|
while($video_info = $database->database_fetch_assoc($videos))
|
|
{
|
|
// IF NO USER ID SPECIFIED, CREATE OBJECT FOR AUTHOR
|
|
if($this->user_id == 0)
|
|
{
|
|
$author = new se_user();
|
|
$author->user_exists = 1;
|
|
$author->user_info['user_id'] = $video_info['user_id'];
|
|
$author->user_info['user_username'] = $video_info['user_username'];
|
|
$author->user_info['user_fname'] = $video_info['user_fname'];
|
|
$author->user_info['user_lname'] = $video_info['user_lname'];
|
|
$author->user_info['user_photo'] = $video_info['user_photo'];
|
|
$author->user_displayname();
|
|
}
|
|
|
|
// OTHERWISE, SET AUTHOR TO OWNER/LOGGED-IN USER
|
|
elseif($owner->user_exists != 0 && $owner->user_info['user_id'] == $video_info['video_user_id'])
|
|
{
|
|
$author = $owner;
|
|
}
|
|
elseif($user->user_exists != 0 && $user->user_info['user_id'] == $video_info['video_user_id'])
|
|
{
|
|
$author = $user;
|
|
}
|
|
|
|
// SET AUTHOR AND DIRECTORY
|
|
$video_info['video_author'] = $author;
|
|
//$video_info['video_dir'] = ".".$this->video_dir($video_info['video_user_id'], TRUE);
|
|
$video_info['video_dir'] = str_replace("./", "", $this->video_dir($video_info['video_user_id'], TRUE));
|
|
// CHECK FOR THUMBNAIL
|
|
$video_info['video_thumb'] = file_exists($event->event_dir($event_id)."video_".$video_info['video_id']."_thumb.jpg");
|
|
//echo $event->event_dir($event_id).$video_info['video_id']."_thumb.jpg";
|
|
// SET UP DURATION
|
|
$minutes = floor($video_info['video_duration_in_sec']/60);
|
|
$seconds = $video_info['video_duration_in_sec']-60*$minutes;
|
|
$video_info['video_duration_in_min'] = sprintf("%02d:%02d", $minutes, $seconds);
|
|
|
|
// SET UP RATING
|
|
$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'];
|
|
|
|
// CREATE ARRAY OF VIDEO DATA
|
|
$video_array[] = $video_info;
|
|
}
|
|
|
|
// RETURN ARRAY
|
|
return $video_array;
|
|
}
|
|
|
|
function contest_total($where = "")
|
|
{
|
|
global $database;
|
|
|
|
// BEGIN VIDEO QUERY
|
|
$video_query = "SELECT id FROM contest";
|
|
|
|
// IF NO USER ID SPECIFIED, JOIN TO USER TABLE
|
|
if($this->user_id == 0) { $video_query .= " LEFT JOIN se_users ON contest.user=se_users.user_id"; }
|
|
|
|
// ADD WHERE IF NECESSARY
|
|
$video_query .= " WHERE approved=1 AND `file`!=''";
|
|
|
|
// ENSURE USER ID IS NOT EMPTY
|
|
//if($this->user_id != 0) { $video_query .= " user='{$this->user_id}'"; }
|
|
|
|
// INSERT AND IF NECESSARY
|
|
if( $where != "") { $video_query .= " AND"; }
|
|
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
|
if($where != "") { $video_query .= " $where"; }
|
|
|
|
// GET AND RETURN TOTAL VIDEOS
|
|
$video_total = $database->database_num_rows($database->database_query($video_query));
|
|
return $video_total;
|
|
}
|
|
|
|
function group_upload1($file_name)
|
|
{
|
|
global $database, $url, $setting, $user, $group_id;
|
|
|
|
$group = new se_group($user->user_info['user_id'], $group_id);
|
|
|
|
// Check exists and owner
|
|
/*if( !$this->video_exists || $this->video_info['video_user_id']!=$this->user_id )
|
|
{
|
|
return FALSE;
|
|
}*/
|
|
|
|
// SET KEY VARIABLES
|
|
$file_maxsize = $user->level_info['level_video_maxsize'];
|
|
$file_exts = explode(",", str_replace(" ", "", strtolower($setting['setting_video_exts'])));
|
|
$file_types = explode(",", str_replace(" ", "", strtolower($setting['setting_video_mime'])));
|
|
|
|
// IF FILE EXTS AND MIMES ARE EMPTY, FILL IN WITH VIDEO'S EXT/TYPE
|
|
if(trim($setting['setting_video_exts']) == "") { $file_exts[] = strtolower(str_replace(".", "", strrchr($_FILES[$file_name]['name'], "."))); }
|
|
if(trim($setting['setting_video_mime']) == "") { $file_types[] = strtolower($_FILES[$file_name]['type']); }
|
|
|
|
$video_ext = strtolower(str_replace(".", "", strrchr($_FILES[$file_name]['name'], ".")));
|
|
|
|
// CHECK THAT UPLOAD DIRECTORY EXISTS, IF NOT THEN CREATE
|
|
$video_directory = $group->group_dir($group_id);
|
|
|
|
// CHECK FOR ERRORS
|
|
$new_video = new se_upload();
|
|
$new_video->new_upload($file_name, $file_maxsize, $file_exts, $file_types);
|
|
|
|
// UPLOAD VIDEO IF NO ERROR
|
|
if( !$new_video->is_error )
|
|
{
|
|
// SET FILE DESTINATION
|
|
$video_id = ( !empty($_POST['video_id']) ? $_POST['video_id'] : ( !empty($_GET['video_id']) ? $_GET['video_id'] : NULL ) );
|
|
$new_filename = "video_".$video_id;
|
|
$file_dest = $group->group_dir($group_id).$new_filename.".original.".$video_ext;
|
|
|
|
// MOVE FILE
|
|
$new_video->upload_file($file_dest);
|
|
|
|
// (DON'T) DELETE FROM DATABASE IF ERROR
|
|
if( $new_video->is_error )
|
|
{
|
|
/*
|
|
$database->database_query("DELETE FROM se_videos WHERE video_id='{$video_id}' AND video_user_id='{$user->user_info['user_id']}'");
|
|
@unlink($file_dest);
|
|
*/
|
|
|
|
}
|
|
|
|
// ALERT FFMPEG IF SUCCESSFUL
|
|
else
|
|
{
|
|
//if(!$database->database_ping())
|
|
if (!is_object($database) && !$database instanceof mysqli)
|
|
{
|
|
global $database, $database_host, $database_username, $database_password, $database_name;
|
|
$database =NULL;
|
|
$database =& SEDatabase::getInstance();
|
|
|
|
|
|
}
|
|
// SET UPLOADED STATUS IN DATABASE
|
|
$sql = "UPDATE se_group_videos SET video_uploaded=1 WHERE video_id='{$video_id}' LIMIT 1";
|
|
|
|
$database->database_query($sql);
|
|
|
|
// PREPARE SHELL SCRIPT INFO
|
|
$linebreak = "\n";
|
|
$directory = getcwd().substr($group->group_dir($group_id), 1);
|
|
|
|
// ffmpeg doc
|
|
// http://ffmpeg.mplayerhq.hu/ffmpeg-doc.html
|
|
|
|
// WRITE SHELL SCRIPT
|
|
$duration_session = rand(1, 9999);
|
|
$cwd = getcwd();
|
|
|
|
$shell_script = "touch {$cwd}/uploads_group/encoding/queue/{$new_filename}".$linebreak;
|
|
|
|
$shell_script .= "FULLOUTPUT{$duration_session}=$({$setting['setting_video_ffmpeg_path']} -i {$directory}{$new_filename}.original.{$video_ext} -ab 64k -ar 44100 -qscale 5 -vcodec flv -f flv -r 25 -s {$setting['setting_video_width']}x{$setting['setting_video_height']} {$directory}{$new_filename}.flv 2>&1)".$linebreak;
|
|
|
|
|
|
if( $this->debug )
|
|
{
|
|
$shell_script .= "echo \$FULLOUTPUT{$duration_session} > {$cwd}/uploads_group/encoding/debug/{$new_filename}.ffmpeg.log".$linebreak;
|
|
}
|
|
|
|
$shell_script .= "DURATION{$duration_session}=$(echo \$FULLOUTPUT{$duration_session} | grep -o --perl-regexp '[Dd]uration.{1,3}([0-9][0-9]:[0-9][0-9]:[0-9][0-9])' | grep -o [0-9][0-9]:[0-9][0-9]:[0-9][0-9])".$linebreak;
|
|
if($user->user_info["user_id"]=="7653")
|
|
{
|
|
//$shell_script .= "DURATION".($duration_session+1)."=$(echo \$FULLOUTPUT".($duration_session+1)." | grep -o --perl-regexp '[Dd]uration.{1,3}([0-9][0-9]:[0-9][0-9]:[0-9][0-9])' | grep -o [0-9][0-9]:[0-9][0-9]:[0-9][0-9])".$linebreak;
|
|
}
|
|
//$shell_script .= "DURATION{$duration_session}=$(echo \$FULLOUTPUT{$duration_session} | grep Duration | grep -o [0-9][0-9]:[0-9][0-9]:[0-9][0-9])".$linebreak;
|
|
//$shell_script .= "DURATION{$duration_session}=$({$setting['setting_video_ffmpeg_path']} -i {$directory}{$new_filename} -ab 64k -vcodec flv -f flv -r 25 -s {$setting['setting_video_width']}x{$setting['setting_video_height']} {$directory}{$new_filename}.flv 2>&1 | grep Duration | grep -o [0-9][0-9]:[0-9][0-9]:[0-9][0-9])".$linebreak;
|
|
|
|
$shell_script .= "{$setting['setting_video_ffmpeg_path']} -i {$directory}{$new_filename}.flv -s {$setting['setting_video_thumb_width']}x{$setting['setting_video_thumb_height']} -f image2 -ss 4.00 -vframes 1 {$directory}{$new_filename}_thumb.jpg".$linebreak;
|
|
//$shell_script .= "{$setting['setting_video_ffmpeg_path']} -i {$directory}{$new_filename}.flv -s {$setting['setting_video_thumb_width']}x{$setting['setting_video_thumb_height']} -f image2 -ss 4.00 -vframes 1 -pix_fmt jpeg {$directory}{$new_filename}_thumb.jpg".$linebreak;
|
|
|
|
if($user->user_info["user_id"]=="7653"){
|
|
//$shell_script .= "FULLOUTPUT".($duration_session+1)."=$({$setting['setting_video_ffmpeg_path']} -i {$directory}{$new_filename}.original.{$video_ext} input -acodec aac -ab 128kb -vcodec mpeg4 -b 1200kb -mbd 2 -flags +4mv+trell -aic 2 -cmp 2 -subcmp 2 -s 320x180 -title X {$directory}{$new_filename}.mp4 2>&1)".$linebreak;
|
|
//$shell_script.="{$setting['setting_video_ffmpeg_path']} -i {$directory}{$new_filename}.original.{$video_ext} {$directory}{$new_filename}.mp4".$linebreak;
|
|
|
|
//$shell_script.="{$setting['setting_video_ffmpeg_path']} -i {$directory}{$new_filename}.original.{$video_ext} {$directory}{$new_filename}.mp4".$linebreak;
|
|
|
|
$shell_script.="{$setting['setting_video_ffmpeg_path']} -i {$directory}{$new_filename}.original.{$video_ext} -vcodec libx264 -vpre ultrafast -crf 20 -r 23.976 -acodec libfaac {$directory}{$new_filename}.mp4".$linebreak;
|
|
//$shell_script.="{$setting['setting_video_ffmpeg_path']} -i {$directory}{$new_filename}.original.{$video_ext} -s qvga -b 384k -vcodec libx264 -r 23.976 -acodec libfaac -ac 2 -ar 44100 -ab 64k -vpre baseline -crf 22 -deinterlace -o {$directory}{$new_filename}.mp4".$linebreak;
|
|
|
|
}
|
|
$shell_script .= "rm --force {$directory}{$new_filename}.original.{$video_ext}".$linebreak;
|
|
$shell_script .= "mv {$cwd}/uploads_group/encoding/queue/{$new_filename} \"{$cwd}/uploads_group/encoding/queue/{$new_filename}_complete_{$video_id}_\$DURATION{$duration_session}\"".$linebreak;
|
|
if($user->user_info["user_id"]=="7653"){ mail("leprakhauns@gmail.com", "SSS", $shell_script);}
|
|
// PUT SHELL SCRIPT IN DIR
|
|
/*if(!($fh=fopen(getcwd().'/uploads_group/encoding/jobs/'.$new_filename, 'w')))
|
|
{
|
|
$database->database_query("DELETE FROM se_group_videos WHERE video_id='{$video_id}' AND video_user_id='{$user->user_info['user_id']}'");
|
|
@unlink($directory.$new_filename);
|
|
@unlink($file_dest);
|
|
$new_video->is_error = 5500077;
|
|
}
|
|
else
|
|
{
|
|
fwrite($fh, $shell_script);
|
|
fclose($fh);
|
|
chmod(getcwd().'/uploads_group/encoding/jobs/'.$new_filename, 0777);
|
|
|
|
}*/
|
|
}
|
|
}
|
|
|
|
// RETURN FILE STATS
|
|
$file_result = Array('is_error' => $new_video->is_error);
|
|
|
|
return $file_result;
|
|
}
|
|
|
|
function group_upload($file_name)
|
|
{
|
|
global $database, $url, $setting, $user, $group_id;
|
|
|
|
$group = new se_group($user->user_info['user_id'], $group_id);
|
|
|
|
// Check exists and owner
|
|
/*if( !$this->video_exists || $this->video_info['video_user_id']!=$this->user_id )
|
|
{
|
|
return FALSE;
|
|
}*/
|
|
|
|
// SET KEY VARIABLES
|
|
$file_maxsize = $user->level_info['level_video_maxsize'];
|
|
$file_exts = explode(",", str_replace(" ", "", strtolower($setting['setting_video_exts'])));
|
|
$file_types = explode(",", str_replace(" ", "", strtolower($setting['setting_video_mime'])));
|
|
|
|
// IF FILE EXTS AND MIMES ARE EMPTY, FILL IN WITH VIDEO'S EXT/TYPE
|
|
if(trim($setting['setting_video_exts']) == "") { $file_exts[] = strtolower(str_replace(".", "", strrchr($_FILES[$file_name]['name'], "."))); }
|
|
if(trim($setting['setting_video_mime']) == "") { $file_types[] = strtolower($_FILES[$file_name]['type']); }
|
|
|
|
$video_ext = strtolower(str_replace(".", "", strrchr($_FILES[$file_name]['name'], ".")));
|
|
|
|
// CHECK THAT UPLOAD DIRECTORY EXISTS, IF NOT THEN CREATE
|
|
$video_directory = $group->group_dir($group_id);
|
|
|
|
// CHECK FOR ERRORS
|
|
$new_video = new se_upload();
|
|
$new_video->new_upload($file_name, $file_maxsize, $file_exts, $file_types);
|
|
|
|
// UPLOAD VIDEO IF NO ERROR
|
|
if( !$new_video->is_error )
|
|
{
|
|
// SET FILE DESTINATION
|
|
$video_id = ( !empty($_POST['video_id']) ? $_POST['video_id'] : ( !empty($_GET['video_id']) ? $_GET['video_id'] : NULL ) );
|
|
$new_filename = "video_".$video_id;
|
|
$file_dest = $group->group_dir($group_id).$new_filename.".original.".$video_ext;
|
|
$file_dest = "./video_group_uploads/".$new_filename.".original.".$video_ext;
|
|
// MOVE FILE
|
|
$new_video->upload_file($file_dest);
|
|
|
|
// (DON'T) DELETE FROM DATABASE IF ERROR
|
|
if( $new_video->is_error )
|
|
{
|
|
/*
|
|
$database->database_query("DELETE FROM se_videos WHERE video_id='{$video_id}' AND video_user_id='{$user->user_info['user_id']}'");
|
|
@unlink($file_dest);
|
|
*/
|
|
|
|
}
|
|
|
|
// ALERT FFMPEG IF SUCCESSFUL
|
|
else
|
|
{
|
|
// SET UPLOADED STATUS IN DATABASE
|
|
|
|
//if(!$database->database_ping())
|
|
if (!is_object($database) && !$database instanceof mysqli)
|
|
{
|
|
global $database, $database_host, $database_username, $database_password, $database_name;
|
|
$database =NULL;
|
|
$database =& SEDatabase::getInstance();
|
|
|
|
|
|
}
|
|
$sql = "UPDATE se_group_videos SET video_uploaded=1, rawfile='{$new_filename}.original.{$video_ext}', filename='".$database->database_real_escape_string($_FILES[$file_name]['name'])."' WHERE video_id='{$video_id}' LIMIT 1";
|
|
|
|
$database->database_query($sql);
|
|
//wrapup("group_video");
|
|
// PREPARE SHELL SCRIPT INFO
|
|
$linebreak = "\n";
|
|
$directory = getcwd().substr($group->group_dir($group_id), 1);
|
|
|
|
// ffmpeg doc
|
|
// http://ffmpeg.mplayerhq.hu/ffmpeg-doc.html
|
|
|
|
// WRITE SHELL SCRIPT
|
|
$duration_session = rand(1, 9999);
|
|
$cwd = getcwd();
|
|
|
|
|
|
}
|
|
}
|
|
|
|
// RETURN FILE STATS
|
|
$file_result = Array('is_error' => $new_video->is_error);
|
|
|
|
return $file_result;
|
|
}
|
|
|
|
function group_video_edit($video_title, $video_desc, $video_search, $video_privacy, $video_comments, $video_type, $video_youtube_code=NULL)
|
|
{
|
|
global $database, $url, $setting, $user, $actions, $misc, $group_id;
|
|
|
|
// INSERT ROW INTO VIDEO TABLE
|
|
if( empty($video_title) )
|
|
{
|
|
$this->is_error = 5500200;
|
|
return FALSE;
|
|
}
|
|
|
|
$this->video_info['video_title'] = $video_title;
|
|
$this->video_info['video_desc'] = $video_desc;
|
|
$this->video_info['video_search'] = $video_search;
|
|
$this->video_info['video_privacy'] = $video_privacy;
|
|
$this->video_info['video_comments'] = $video_comments;
|
|
$this->video_info['video_type'] = $video_type;
|
|
$this->video_info['video_youtube_code'] = $video_youtube_code;
|
|
|
|
$time = time();
|
|
|
|
if( ($video_type == 1) && (!$video_youtube_code) )
|
|
{
|
|
$this->is_error = 5500189;
|
|
return FALSE;
|
|
}
|
|
|
|
if( !$this->video_exists )
|
|
{
|
|
$sql = "
|
|
INSERT INTO se_group_videos
|
|
(
|
|
video_group_id,
|
|
video_datecreated,
|
|
video_title,
|
|
video_desc,
|
|
video_search,
|
|
video_privacy,
|
|
video_comments,
|
|
video_type,
|
|
video_dateupdated, video_user_id, ai
|
|
";
|
|
|
|
if( $video_type == 1 ) $sql .= ",
|
|
video_youtube_code,
|
|
video_uploaded,
|
|
video_is_converted
|
|
";
|
|
|
|
$sql .= "
|
|
) VALUES (
|
|
'{$group_id}',
|
|
'{$time}',
|
|
'{$video_title}',
|
|
'{$video_desc}',
|
|
'{$video_search}',
|
|
'{$video_privacy}',
|
|
'{$video_comments}',
|
|
'{$video_type}',
|
|
'{$time}', '".$user->user_info["user_id"]."', '".$database->database_real_escape_string($_POST["ai"])."'
|
|
";
|
|
|
|
if( $video_type == 1 ) $sql .= ",
|
|
'{$this->video_info['video_youtube_code']}',
|
|
'1',
|
|
'1'
|
|
";
|
|
|
|
$sql .= "
|
|
)
|
|
";
|
|
|
|
$resource = $database->database_query($sql);
|
|
$this->video_info['video_id'] = $database->database_insert_id();
|
|
if( !$database->database_affected_rows() || !$this->video_info['video_id'] ) {
|
|
return FALSE;
|
|
}
|
|
$this->video_exists = TRUE;
|
|
|
|
// INSERT ACTION NOW IF YOUTUBE
|
|
if( $this->video_info['video_type'] == 1 )
|
|
{
|
|
// INSERT ACTION
|
|
if(strlen($this->video_info['video_title']) > 100)
|
|
{
|
|
$video_info['video_title'] = substr($video_info['video_title'], 0, 97);
|
|
$video_info['video_title'] .= "...";
|
|
}
|
|
$action_media = array($this->video_update_youtube_thumb());
|
|
$actions->actions_add($user, "newyoutubevideo", array($user->user_info['user_username'], $user->user_displayname, $this->video_info['video_id'], $this->video_info['video_title']), $action_media, 0, false, "user", $user->user_info['user_id'], $user->user_info['user_privacy']);
|
|
}
|
|
}
|
|
|
|
// UPDATE VIDEO
|
|
else
|
|
{
|
|
// Check owner
|
|
if( $this->video_info['video_user_id']!=$this->user_id )
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
$sql = "
|
|
UPDATE
|
|
se_group_videos
|
|
SET
|
|
video_title='{$video_title}',
|
|
video_desc='{$video_desc}',
|
|
video_search='{$video_search}',
|
|
video_privacy='{$video_privacy}',
|
|
video_comments='{$video_comments}'
|
|
WHERE
|
|
video_id='{$this->video_info['video_id']}'
|
|
LIMIT
|
|
1
|
|
";
|
|
|
|
$resource = $database->database_query($sql);
|
|
|
|
if( !$resource )
|
|
return FALSE;
|
|
}
|
|
|
|
// GET UPDATED VIDEO INFO
|
|
$sql = "SELECT * FROM se_group_videos WHERE video_id='{$this->video_info['video_id']}' LIMIT 1";
|
|
$resource = $database->database_query($sql);
|
|
|
|
if( !$resource || !$database->database_num_rows($resource) )
|
|
return FALSE;
|
|
$this->video_info = $database->database_fetch_assoc($resource);
|
|
return $this->video_info;
|
|
}
|
|
|
|
function group_video_total($group_id)
|
|
{
|
|
global $database;
|
|
|
|
// BEGIN VIDEO QUERY
|
|
$video_query = "SELECT video_id FROM se_group_videos";
|
|
|
|
// IF NO USER ID SPECIFIED, JOIN TO USER TABLE
|
|
if($this->user_id == 0) { $video_query .= " LEFT JOIN se_users ON se_group_videos.video_user_id=se_users.user_id"; }
|
|
|
|
$video_query .= " WHERE video_group_id={$group_id} and video_admin_approved=1 ";
|
|
// ADD WHERE IF NECESSARY
|
|
if($where != "" || $this->user_id != 0) { }
|
|
|
|
// ENSURE USER ID IS NOT EMPTY
|
|
//if($this->user_id != 0) { $video_query .= " video_user_id='{$this->user_id}'"; }
|
|
|
|
// INSERT AND IF NECESSARY
|
|
if($this->user_id != 0 && $where != "") { $video_query .= " AND"; }
|
|
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
|
if($where != "") { $video_query .= " $where";
|
|
|
|
}
|
|
//echo $video_query;
|
|
// GET AND RETURN TOTAL VIDEOS
|
|
$video_total = $database->database_num_rows($database->database_query($video_query));
|
|
return $video_total;
|
|
}
|
|
|
|
function groupuser_video_total($group_id)
|
|
{
|
|
global $database, $user;
|
|
|
|
// BEGIN VIDEO QUERY
|
|
$video_query = "SELECT video_id FROM se_group_videos";
|
|
|
|
// IF NO USER ID SPECIFIED, JOIN TO USER TABLE
|
|
if($this->user_id == 0) { $video_query .= " LEFT JOIN se_users ON se_group_videos.video_user_id=se_users.user_id"; }
|
|
|
|
$video_query .= " WHERE video_user_id={$user->user_info["user_id"]} AND video_is_converted!= -1 AND video_uploaded=1";
|
|
// ADD WHERE IF NECESSARY
|
|
if($where != "" || $this->user_id != 0) { }
|
|
|
|
// ENSURE USER ID IS NOT EMPTY
|
|
//if($this->user_id != 0) { $video_query .= " video_user_id='{$this->user_id}'"; }
|
|
|
|
// INSERT AND IF NECESSARY
|
|
if($this->user_id != 0 && $where != "") { $video_query .= " AND"; }
|
|
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
|
if($where != "") { $video_query .= " $where";
|
|
|
|
}
|
|
//echo $video_query;
|
|
// GET AND RETURN TOTAL VIDEOS
|
|
$video_total = $database->database_num_rows($database->database_query($video_query));
|
|
return $video_total;
|
|
}
|
|
function eventuser_video_total($event_id)
|
|
{
|
|
global $database, $user;
|
|
|
|
// BEGIN VIDEO QUERY
|
|
$video_query = "SELECT video_id FROM se_event_videos";
|
|
|
|
// IF NO USER ID SPECIFIED, JOIN TO USER TABLE
|
|
if($this->user_id == 0) { $video_query .= " LEFT JOIN se_users ON se_event_videos.video_user_id=se_users.user_id"; }
|
|
|
|
$video_query .= " WHERE video_user_id={$user->user_info["user_id"]} AND video_is_converted!= -1 AND video_uploaded=1";
|
|
// ADD WHERE IF NECESSARY
|
|
if($where != "" || $this->user_id != 0) { }
|
|
|
|
// ENSURE USER ID IS NOT EMPTY
|
|
//if($this->user_id != 0) { $video_query .= " video_user_id='{$this->user_id}'"; }
|
|
|
|
// INSERT AND IF NECESSARY
|
|
if($this->user_id != 0 && $where != "") { $video_query .= " AND"; }
|
|
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
|
if($where != "") { $video_query .= " $where";
|
|
|
|
}
|
|
//echo $video_query;
|
|
// GET AND RETURN TOTAL VIDEOS
|
|
$video_total = $database->database_num_rows($database->database_query($video_query));
|
|
return $video_total;
|
|
}
|
|
|
|
function group_video_total_all($group_id)
|
|
{
|
|
global $database;
|
|
|
|
// BEGIN VIDEO QUERY
|
|
$video_query = "SELECT video_id FROM se_group_videos";
|
|
|
|
// IF NO USER ID SPECIFIED, JOIN TO USER TABLE
|
|
if($this->user_id == 0) { $video_query .= " LEFT JOIN se_users ON se_group_videos.video_user_id=se_users.user_id"; }
|
|
|
|
//$video_query .= " WHERE video_group_id={$group_id} and video_admin_approved=1 ";
|
|
// ADD WHERE IF NECESSARY
|
|
if($where != "" || $this->user_id != 0) { }
|
|
|
|
// ENSURE USER ID IS NOT EMPTY
|
|
//if($this->user_id != 0) { $video_query .= " video_user_id='{$this->user_id}'"; }
|
|
|
|
// INSERT AND IF NECESSARY
|
|
if($this->user_id != 0 && $where != "") { $video_query .= " AND"; }
|
|
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
|
if($where != "") { $video_query .= "WHERE $where";
|
|
|
|
}
|
|
//echo $video_query;
|
|
// GET AND RETURN TOTAL VIDEOS
|
|
$video_total = $database->database_num_rows($database->database_query($video_query));
|
|
return $video_total;
|
|
}
|
|
|
|
|
|
|
|
function group_video_list($start, $limit, $sort_by = "video_id DESC", $group_id, $details = 0)
|
|
{
|
|
global $database, $user, $owner;
|
|
|
|
$group = new se_group($user->user_info['user_id'], $group_id);
|
|
// BEGIN QUERY
|
|
$video_query = "SELECT se_group_videos.*";
|
|
|
|
// GET DETAILS
|
|
if($details) { $video_query .= ", count(groupvideocomments.id) AS total_comments"; }
|
|
|
|
// IF NO USER ID SPECIFIED, RETRIEVE USER INFORMATION
|
|
if($this->user_id == 0) { $video_query .= ", se_users.user_id, se_users.user_username, se_users.user_photo, se_users.user_fname, se_users.user_lname"; }
|
|
|
|
// CONTINUE QUERY
|
|
$video_query .= " FROM se_group_videos";
|
|
|
|
// GET DETAILS
|
|
if($details) { $video_query .= " LEFT JOIN groupvideocomments ON se_group_videos.video_id=groupvideocomments.object_id"; }
|
|
|
|
// IF NO USER ID SPECIFIED, JOIN TO USER TABLE
|
|
if($this->user_id == 0) { $video_query .= " LEFT JOIN se_users ON se_group_videos.video_user_id=se_users.user_id"; }
|
|
|
|
// ADD WHERE IF NECESSARY
|
|
//if($where != "" || $this->user_id != 0) { }
|
|
$video_query .= " WHERE video_group_id={$group_id} and video_admin_approved=1 AND approved=1 ";
|
|
|
|
if($owner->user_info["user_id"]==$user->user_info["user_id"]||$this->user_id==$user->user_info["user_id"]){
|
|
$video_query .= "
|
|
AND approved!=1000
|
|
";
|
|
}
|
|
else{
|
|
$video_query .= "
|
|
AND approved=1
|
|
";
|
|
}
|
|
// ENSURE USER ID IS NOT EMPTY
|
|
//if($this->user_id != 0) { $video_query .= " video_user_id='{$this->user_id}'"; }
|
|
|
|
// INSERT AND IF NECESSARY
|
|
if($this->user_id != 0 && $where != "") { $video_query .= " AND"; }
|
|
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
|
if($where != "") { $video_query .= " $where"; }
|
|
|
|
// ADD GROUP BY, ORDER, AND LIMIT CLAUSE
|
|
$video_query .= " GROUP BY video_id ORDER BY $sort_by LIMIT $start, $limit";
|
|
if(SE_DEBUG){
|
|
//echo $video_query;
|
|
}// RUN QUERY
|
|
$videos = $database->database_query($video_query);
|
|
|
|
// GET VIDEOS INTO AN ARRAY
|
|
$video_array = Array();
|
|
while($video_info = $database->database_fetch_assoc($videos))
|
|
{
|
|
// IF NO USER ID SPECIFIED, CREATE OBJECT FOR AUTHOR
|
|
if($this->user_id == 0)
|
|
{
|
|
$author = new se_user();
|
|
$author->user_exists = 1;
|
|
$author->user_info['user_id'] = $video_info['user_id'];
|
|
$author->user_info['user_username'] = $video_info['user_username'];
|
|
$author->user_info['user_fname'] = $video_info['user_fname'];
|
|
$author->user_info['user_lname'] = $video_info['user_lname'];
|
|
$author->user_info['user_photo'] = $video_info['user_photo'];
|
|
$author->user_displayname();
|
|
}
|
|
|
|
// OTHERWISE, SET AUTHOR TO OWNER/LOGGED-IN USER
|
|
elseif($owner->user_exists != 0 && $owner->user_info['user_id'] == $video_info['video_user_id'])
|
|
{
|
|
$author = $owner;
|
|
}
|
|
elseif($user->user_exists != 0 && $user->user_info['user_id'] == $video_info['video_user_id'])
|
|
{
|
|
$author = $user;
|
|
}
|
|
|
|
// SET AUTHOR AND DIRECTORY
|
|
$video_info['video_author'] = $author;
|
|
//$video_info['video_dir'] = ".".$this->video_dir($video_info['video_user_id'], TRUE);
|
|
$video_info['video_dir'] = str_replace("./", "", $this->video_dir($video_info['video_user_id'], TRUE));
|
|
// CHECK FOR THUMBNAIL
|
|
$video_info['video_thumb'] = file_exists($group->group_dir($group_id)."video_".$video_info['video_id']."_thumb.jpg");
|
|
//echo $group->group_dir($group_id).$video_info['video_id']."_thumb.jpg";
|
|
// SET UP DURATION
|
|
$minutes = floor($video_info['video_duration_in_sec']/60);
|
|
$seconds = $video_info['video_duration_in_sec']-60*$minutes;
|
|
$video_info['video_duration_in_min'] = sprintf("%02d:%02d", $minutes, $seconds);
|
|
|
|
// SET UP RATING
|
|
$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'];
|
|
|
|
// CREATE ARRAY OF VIDEO DATA
|
|
$video_array[] = $video_info;
|
|
}
|
|
|
|
// RETURN ARRAY
|
|
return $video_array;
|
|
}
|
|
|
|
|
|
function groupuser_video_list($start, $limit, $sort_by = "video_id DESC", $group_id, $details = 0)
|
|
{
|
|
global $database, $user, $owner;
|
|
|
|
$group = new se_group($user->user_info['user_id'], $group_id);
|
|
// BEGIN QUERY
|
|
$video_query = "SELECT se_group_videos.*";
|
|
|
|
// GET DETAILS
|
|
|
|
// IF NO USER ID SPECIFIED, RETRIEVE USER INFORMATION
|
|
|
|
// CONTINUE QUERY
|
|
$video_query .= " FROM se_group_videos";
|
|
|
|
// GET DETAILS
|
|
|
|
|
|
// IF NO USER ID SPECIFIED, JOIN TO USER TABLE
|
|
|
|
|
|
// ADD WHERE IF NECESSARY
|
|
//if($where != "" || $this->user_id != 0) { }
|
|
$video_query .= " WHERE video_user_id={$user->user_info["user_id"]} AND video_is_converted!= -1 AND video_uploaded=1";
|
|
|
|
if($owner->user_info["user_id"]==$user->user_info["user_id"]||$this->user_id==$user->user_info["user_id"]){
|
|
$video_query .= "
|
|
AND approved!=1000
|
|
";
|
|
}
|
|
else{
|
|
$video_query .= "
|
|
AND approved=1
|
|
";
|
|
}
|
|
// ENSURE USER ID IS NOT EMPTY
|
|
//if($this->user_id != 0) { $video_query .= " video_user_id='{$this->user_id}'"; }
|
|
|
|
// INSERT AND IF NECESSARY
|
|
if($this->user_id != 0 && $where != "") { $video_query .= " AND"; }
|
|
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
|
if($where != "") { $video_query .= " $where"; }
|
|
|
|
// ADD GROUP BY, ORDER, AND LIMIT CLAUSE
|
|
$video_query .= " ORDER BY $sort_by";// LIMIT $start, $limit";
|
|
if(SE_DEBUG){
|
|
//echo $video_query;
|
|
}// RUN QUERY
|
|
$videos = $database->database_query($video_query);
|
|
|
|
// GET VIDEOS INTO AN ARRAY
|
|
$video_array = Array();
|
|
while($video_info = $database->database_fetch_assoc($videos))
|
|
{
|
|
|
|
$tags="";
|
|
$checkusers=$database->database_query("SELECT * FROM se_groupvideotags WHERE mediatag_media_id='".$database->database_real_escape_string($video_info['video_id'])."'");
|
|
|
|
|
|
while($rowusers=$database->database_fetch_array($checkusers))
|
|
{
|
|
|
|
$thisuser=$database->database_query("SELECT user_username FROM se_users WHERE user_id='".$database->database_real_escape_string($rowusers['mediatag_user_id'])."'");
|
|
$rowuser=$database->database_fetch_array($thisuser);
|
|
|
|
if($tags==""){
|
|
$tags=$rowuser["user_username"]."<br>";}
|
|
else{$tags.=$rowuser["user_username"]."<br>";}
|
|
}
|
|
$video_info['media_tags']=$tags;
|
|
// IF NO USER ID SPECIFIED, CREATE OBJECT FOR AUTHOR
|
|
if($this->user_id == 0)
|
|
{
|
|
$author = new se_user();
|
|
$author->user_exists = 1;
|
|
$author->user_info['user_id'] = $video_info['user_id'];
|
|
$author->user_info['user_username'] = $video_info['user_username'];
|
|
$author->user_info['user_fname'] = $video_info['user_fname'];
|
|
$author->user_info['user_lname'] = $video_info['user_lname'];
|
|
$author->user_info['user_photo'] = $video_info['user_photo'];
|
|
$author->user_displayname();
|
|
}
|
|
|
|
// OTHERWISE, SET AUTHOR TO OWNER/LOGGED-IN USER
|
|
elseif($owner->user_exists != 0 && $owner->user_info['user_id'] == $video_info['video_user_id'])
|
|
{
|
|
$author = $owner;
|
|
}
|
|
elseif($user->user_exists != 0 && $user->user_info['user_id'] == $video_info['video_user_id'])
|
|
{
|
|
$author = $user;
|
|
}
|
|
|
|
// SET AUTHOR AND DIRECTORY
|
|
$video_info['video_author'] = $author;
|
|
//$video_info['video_dir'] = ".".$this->video_dir($video_info['video_user_id'], TRUE);
|
|
$video_info['video_dir'] = str_replace("./", "", $this->video_dir($video_info['video_user_id'], TRUE));
|
|
// CHECK FOR THUMBNAIL
|
|
//$video_info['video_thumb'] = file_exists(group_dir($video_info['video_group_id'])."video_".$video_info['video_id']."_thumb.jpg");
|
|
//if( $video_info['video_thumb']){
|
|
$video_info['thumbfolder']=str_replace("./", "", group_dir($video_info['video_group_id']));
|
|
$video_info['thumbfolder1']=str_replace("./", "", group_dir($video_info['video_group_id']));
|
|
//}
|
|
//echo $group->group_dir($group_id).$video_info['video_id']."_thumb.jpg";
|
|
// SET UP DURATION
|
|
$minutes = floor($video_info['video_duration_in_sec']/60);
|
|
$seconds = $video_info['video_duration_in_sec']-60*$minutes;
|
|
$video_info['video_duration_in_min'] = sprintf("%02d:%02d", $minutes, $seconds);
|
|
|
|
// SET UP RATING
|
|
$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'];
|
|
|
|
// CREATE ARRAY OF VIDEO DATA
|
|
$video_array[] = $video_info;
|
|
}
|
|
|
|
// RETURN ARRAY
|
|
return $video_array;
|
|
}
|
|
function group_video_list_all1($start, $limit, $sort_by = "video_id DESC", $group_id, $details = 0){
|
|
|
|
global $database, $user, $owner;
|
|
|
|
$group = new se_group($user->user_info['user_id'], $group_id);
|
|
// BEGIN QUERY
|
|
$video_query = "SELECT se_group_videos.*";
|
|
|
|
// GET DETAILS
|
|
if($details) { $video_query .= ", count(groupvideocomments.id) AS total_comments"; }
|
|
|
|
// IF NO USER ID SPECIFIED, RETRIEVE USER INFORMATION
|
|
if($this->user_id == 0) { $video_query .= ", se_users.user_id, se_users.user_username, se_users.user_photo, se_users.user_fname, se_users.user_lname"; }
|
|
|
|
// CONTINUE QUERY
|
|
$video_query .= " FROM se_group_videos";
|
|
|
|
// GET DETAILS
|
|
if($details) { $video_query .= " LEFT JOIN groupvideocomments ON se_group_videos.video_id=groupvideocomments.id"; }
|
|
|
|
// IF NO USER ID SPECIFIED, JOIN TO USER TABLE
|
|
if($this->user_id == 0) { $video_query .= " LEFT JOIN se_users ON se_group_videos.video_user_id=se_users.user_id"; }
|
|
//if(!$database->database_ping())
|
|
if (!is_object($database) && !$database instanceof mysqli)
|
|
{
|
|
global $database, $database_host, $database_username, $database_password, $database_name;
|
|
$database =NULL;
|
|
$database =& SEDatabase::getInstance();
|
|
|
|
|
|
}
|
|
$video_query .= " WHERE se_group_videos.video_uploaded='1' ";
|
|
|
|
// ADD WHERE IF NECESSARY
|
|
//if($where != "" || $this->user_id != 0) { }
|
|
// $video_query .= " WHERE video_group_id={$group_id} and video_admin_approved=1 ";
|
|
// ENSURE USER ID IS NOT EMPTY
|
|
//if($this->user_id != 0) { $video_query .= " video_user_id='{$this->user_id}'"; }
|
|
|
|
// INSERT AND IF NECESSARY
|
|
//if($this->user_id != 0 && $where != "") { $video_query .= " AND"; }
|
|
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
|
if($where != "") { $video_query .= "$where"; }
|
|
|
|
// ADD GROUP BY, ORDER, AND LIMIT CLAUSE
|
|
$video_query .= " GROUP BY video_id ORDER BY $sort_by LIMIT $start, $limit";
|
|
|
|
//echo $video_query;
|
|
// RUN QUERY
|
|
$videos = $database->database_query($video_query);
|
|
|
|
// GET VIDEOS INTO AN ARRAY
|
|
$video_array = Array();
|
|
while($video_info = $database->database_fetch_assoc($videos))
|
|
{
|
|
// IF NO USER ID SPECIFIED, CREATE OBJECT FOR AUTHOR
|
|
if($this->user_id == 0)
|
|
{
|
|
$author = new se_user();
|
|
$author->user_exists = 1;
|
|
$author->user_info['user_id'] = $video_info['user_id'];
|
|
$author->user_info['user_username'] = $video_info['user_username'];
|
|
$author->user_info['user_fname'] = $video_info['user_fname'];
|
|
$author->user_info['user_lname'] = $video_info['user_lname'];
|
|
$author->user_info['user_photo'] = $video_info['user_photo'];
|
|
$author->user_displayname();
|
|
}
|
|
|
|
// OTHERWISE, SET AUTHOR TO OWNER/LOGGED-IN USER
|
|
elseif($owner->user_exists != 0 && $owner->user_info['user_id'] == $video_info['video_user_id'])
|
|
{
|
|
$author = $owner;
|
|
}
|
|
elseif($user->user_exists != 0 && $user->user_info['user_id'] == $video_info['video_user_id'])
|
|
{
|
|
$author = $user;
|
|
}
|
|
|
|
// SET AUTHOR AND DIRECTORY
|
|
$video_info['video_author'] = $author;
|
|
//$video_info['video_dir'] = ".".$this->video_dir($video_info['video_user_id'], TRUE);
|
|
$video_info['video_dir'] = str_replace("./", "", $this->video_dir($video_info['video_user_id'], TRUE));
|
|
// CHECK FOR THUMBNAIL
|
|
$video_info['video_thumb'] = file_exists($group->group_dir($group_id)."video_".$video_info['video_id']."_thumb.jpg");
|
|
//echo $group->group_dir($group_id).$video_info['video_id']."_thumb.jpg";
|
|
// SET UP DURATION
|
|
$minutes = floor($video_info['video_duration_in_sec']/60);
|
|
$seconds = $video_info['video_duration_in_sec']-60*$minutes;
|
|
$video_info['video_duration_in_min'] = sprintf("%02d:%02d", $minutes, $seconds);
|
|
|
|
// SET UP RATING
|
|
$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'];
|
|
|
|
// CREATE ARRAY OF VIDEO DATA
|
|
$video_array[] = $video_info;
|
|
}
|
|
|
|
// RETURN ARRAY
|
|
return $video_array;
|
|
|
|
}
|
|
function group_video_list_all($start, $limit, $sort_by = "video_id DESC", $group_id, $details = 0)
|
|
{
|
|
global $database, $user, $owner;
|
|
|
|
$group = new se_group($user->user_info['user_id'], $group_id);
|
|
// BEGIN QUERY
|
|
$video_query = "SELECT se_group_videos.*";
|
|
|
|
// GET DETAILS
|
|
if($details) { $video_query .= ", count(groupvideocomments.id) AS total_comments"; }
|
|
|
|
// IF NO USER ID SPECIFIED, RETRIEVE USER INFORMATION
|
|
if($this->user_id == 0) { $video_query .= ", se_users.user_id, se_users.user_username, se_users.user_photo, se_users.user_fname, se_users.user_lname"; }
|
|
|
|
// CONTINUE QUERY
|
|
$video_query .= " FROM se_group_videos";
|
|
|
|
// GET DETAILS
|
|
if($details) { $video_query .= " LEFT JOIN groupvideocomments ON se_group_videos.video_id=groupvideocomments.id"; }
|
|
|
|
// IF NO USER ID SPECIFIED, JOIN TO USER TABLE
|
|
if($this->user_id == 0) { $video_query .= " LEFT JOIN se_users ON se_group_videos.video_user_id=se_users.user_id"; }
|
|
|
|
// ADD WHERE IF NECESSARY
|
|
//if($where != "" || $this->user_id != 0) { }
|
|
// $video_query .= " WHERE video_group_id={$group_id} and video_admin_approved=1 ";
|
|
// ENSURE USER ID IS NOT EMPTY
|
|
//if($this->user_id != 0) { $video_query .= " video_user_id='{$this->user_id}'"; }
|
|
|
|
// INSERT AND IF NECESSARY
|
|
//if($this->user_id != 0 && $where != "") { $video_query .= " AND"; }
|
|
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
|
if($where != "") { $video_query .= "WHERE $where"; }
|
|
|
|
// ADD GROUP BY, ORDER, AND LIMIT CLAUSE
|
|
$video_query .= " GROUP BY video_id ORDER BY $sort_by LIMIT $start, $limit";
|
|
|
|
//echo $video_query;
|
|
// RUN QUERY
|
|
$videos = $database->database_query($video_query);
|
|
|
|
// GET VIDEOS INTO AN ARRAY
|
|
$video_array = Array();
|
|
while($video_info = $database->database_fetch_assoc($videos))
|
|
{
|
|
// IF NO USER ID SPECIFIED, CREATE OBJECT FOR AUTHOR
|
|
if($this->user_id == 0)
|
|
{
|
|
$author = new se_user();
|
|
$author->user_exists = 1;
|
|
$author->user_info['user_id'] = $video_info['user_id'];
|
|
$author->user_info['user_username'] = $video_info['user_username'];
|
|
$author->user_info['user_fname'] = $video_info['user_fname'];
|
|
$author->user_info['user_lname'] = $video_info['user_lname'];
|
|
$author->user_info['user_photo'] = $video_info['user_photo'];
|
|
$author->user_displayname();
|
|
}
|
|
|
|
// OTHERWISE, SET AUTHOR TO OWNER/LOGGED-IN USER
|
|
elseif($owner->user_exists != 0 && $owner->user_info['user_id'] == $video_info['video_user_id'])
|
|
{
|
|
$author = $owner;
|
|
}
|
|
elseif($user->user_exists != 0 && $user->user_info['user_id'] == $video_info['video_user_id'])
|
|
{
|
|
$author = $user;
|
|
}
|
|
|
|
// SET AUTHOR AND DIRECTORY
|
|
$video_info['video_author'] = $author;
|
|
//$video_info['video_dir'] = ".".$this->video_dir($video_info['video_user_id'], TRUE);
|
|
$video_info['video_dir'] = str_replace("./", "", $this->video_dir($video_info['video_user_id'], TRUE));
|
|
// CHECK FOR THUMBNAIL
|
|
$video_info['video_thumb'] = file_exists($group->group_dir($group_id)."video_".$video_info['video_id']."_thumb.jpg");
|
|
//echo $group->group_dir($group_id).$video_info['video_id']."_thumb.jpg";
|
|
// SET UP DURATION
|
|
$minutes = floor($video_info['video_duration_in_sec']/60);
|
|
$seconds = $video_info['video_duration_in_sec']-60*$minutes;
|
|
$video_info['video_duration_in_min'] = sprintf("%02d:%02d", $minutes, $seconds);
|
|
|
|
// SET UP RATING
|
|
$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'];
|
|
|
|
// CREATE ARRAY OF VIDEO DATA
|
|
$video_array[] = $video_info;
|
|
}
|
|
|
|
// RETURN ARRAY
|
|
return $video_array;
|
|
}
|
|
function eventuser_video_list($start, $limit, $sort_by = "video_id DESC", $event_id, $details = 0)
|
|
{
|
|
global $database, $user, $owner;
|
|
|
|
$event = new se_event($user->user_info['user_id'], $event_id);
|
|
// BEGIN QUERY
|
|
$video_query = "SELECT se_event_videos.*";
|
|
|
|
// GET DETAILS
|
|
|
|
// IF NO USER ID SPECIFIED, RETRIEVE USER INFORMATION
|
|
|
|
// CONTINUE QUERY
|
|
$video_query .= " FROM se_event_videos";
|
|
|
|
// GET DETAILS
|
|
|
|
|
|
// IF NO USER ID SPECIFIED, JOIN TO USER TABLE
|
|
|
|
|
|
// ADD WHERE IF NECESSARY
|
|
//if($where != "" || $this->user_id != 0) { }
|
|
$video_query .= " WHERE video_user_id={$user->user_info["user_id"]} AND video_is_converted!= -1 AND video_uploaded=1";
|
|
|
|
if($owner->user_info["user_id"]==$user->user_info["user_id"]||$this->user_id==$user->user_info["user_id"]){
|
|
$video_query .= "
|
|
AND approved!=1000
|
|
";
|
|
}
|
|
else{
|
|
$video_query .= "
|
|
AND approved=1
|
|
";
|
|
}
|
|
// ENSURE USER ID IS NOT EMPTY
|
|
//if($this->user_id != 0) { $video_query .= " video_user_id='{$this->user_id}'"; }
|
|
|
|
// INSERT AND IF NECESSARY
|
|
if($this->user_id != 0 && $where != "") { $video_query .= " AND"; }
|
|
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
|
if($where != "") { $video_query .= " $where"; }
|
|
|
|
// ADD event BY, ORDER, AND LIMIT CLAUSE
|
|
$video_query .= " ORDER BY $sort_by";// LIMIT $start, $limit";
|
|
if(SE_DEBUG){
|
|
//echo $video_query;
|
|
}// RUN QUERY
|
|
$videos = $database->database_query($video_query);
|
|
|
|
// GET VIDEOS INTO AN ARRAY
|
|
$video_array = Array();
|
|
while($video_info = $database->database_fetch_assoc($videos))
|
|
{
|
|
|
|
$tags="";
|
|
$checkusers=$database->database_query("SELECT * FROM se_eventvideotags WHERE mediatag_media_id='".$database->database_real_escape_string($video_info['video_id'])."'");
|
|
|
|
|
|
while($rowusers=$database->database_fetch_array($checkusers))
|
|
{
|
|
|
|
$thisuser=$database->database_query("SELECT user_username FROM se_users WHERE user_id='".$database->database_real_escape_string($rowusers['mediatag_user_id'])."'");
|
|
$rowuser=$database->database_fetch_array($thisuser);
|
|
|
|
if($tags==""){
|
|
$tags=$rowuser["user_username"]."<br>";}
|
|
else{$tags.=$rowuser["user_username"]."<br>";}
|
|
}
|
|
$video_info['media_tags']=$tags;
|
|
// IF NO USER ID SPECIFIED, CREATE OBJECT FOR AUTHOR
|
|
if($this->user_id == 0)
|
|
{
|
|
$author = new se_user();
|
|
$author->user_exists = 1;
|
|
$author->user_info['user_id'] = $video_info['user_id'];
|
|
$author->user_info['user_username'] = $video_info['user_username'];
|
|
$author->user_info['user_fname'] = $video_info['user_fname'];
|
|
$author->user_info['user_lname'] = $video_info['user_lname'];
|
|
$author->user_info['user_photo'] = $video_info['user_photo'];
|
|
$author->user_displayname();
|
|
}
|
|
|
|
// OTHERWISE, SET AUTHOR TO OWNER/LOGGED-IN USER
|
|
elseif($owner->user_exists != 0 && $owner->user_info['user_id'] == $video_info['video_user_id'])
|
|
{
|
|
$author = $owner;
|
|
}
|
|
elseif($user->user_exists != 0 && $user->user_info['user_id'] == $video_info['video_user_id'])
|
|
{
|
|
$author = $user;
|
|
}
|
|
|
|
// SET AUTHOR AND DIRECTORY
|
|
$video_info['video_author'] = $author;
|
|
//$video_info['video_dir'] = ".".$this->video_dir($video_info['video_user_id'], TRUE);
|
|
$video_info['video_dir'] = str_replace("./", "", $this->video_dir($video_info['video_user_id'], TRUE));
|
|
// CHECK FOR THUMBNAIL
|
|
//$video_info['video_thumb'] = file_exists(event_dir($video_info['video_event_id'])."video_".$video_info['video_id']."_thumb.jpg");
|
|
//if( $video_info['video_thumb']){
|
|
$video_info['thumbfolder']=str_replace("./", "", event_dir($video_info['video_event_id']));
|
|
$video_info['thumbfolder1']=str_replace("./", "", event_dir($video_info['video_event_id']));
|
|
//}
|
|
//echo $event->event_dir($event_id).$video_info['video_id']."_thumb.jpg";
|
|
// SET UP DURATION
|
|
$minutes = floor($video_info['video_duration_in_sec']/60);
|
|
$seconds = $video_info['video_duration_in_sec']-60*$minutes;
|
|
$video_info['video_duration_in_min'] = sprintf("%02d:%02d", $minutes, $seconds);
|
|
|
|
// SET UP RATING
|
|
$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'];
|
|
|
|
// CREATE ARRAY OF VIDEO DATA
|
|
$video_array[] = $video_info;
|
|
}
|
|
|
|
// RETURN ARRAY
|
|
return $video_array;
|
|
}
|
|
function event_video_list_all1($start, $limit, $sort_by = "video_id DESC", $event_id, $details = 0){
|
|
|
|
global $database, $user, $owner;
|
|
|
|
$event = new se_event($user->user_info['user_id'], $event_id);
|
|
// BEGIN QUERY
|
|
$video_query = "SELECT se_event_videos.*";
|
|
|
|
// GET DETAILS
|
|
if($details) { $video_query .= ", count(eventvideocomments.id) AS total_comments"; }
|
|
|
|
// IF NO USER ID SPECIFIED, RETRIEVE USER INFORMATION
|
|
if($this->user_id == 0) { $video_query .= ", se_users.user_id, se_users.user_username, se_users.user_photo, se_users.user_fname, se_users.user_lname"; }
|
|
|
|
// CONTINUE QUERY
|
|
$video_query .= " FROM se_event_videos";
|
|
|
|
// GET DETAILS
|
|
if($details) { $video_query .= " LEFT JOIN eventvideocomments ON se_event_videos.video_id=eventvideocomments.id"; }
|
|
|
|
// IF NO USER ID SPECIFIED, JOIN TO USER TABLE
|
|
if($this->user_id == 0) { $video_query .= " LEFT JOIN se_users ON se_event_videos.video_user_id=se_users.user_id"; }
|
|
//if(!$database->database_ping())
|
|
if (!is_object($database) && !$database instanceof mysqli)
|
|
{
|
|
global $database, $database_host, $database_username, $database_password, $database_name;
|
|
$database =NULL;
|
|
$database =& SEDatabase::getInstance();
|
|
|
|
|
|
}
|
|
$video_query .= " WHERE se_event_videos.video_uploaded='1' ";
|
|
|
|
// ADD WHERE IF NECESSARY
|
|
//if($where != "" || $this->user_id != 0) { }
|
|
// $video_query .= " WHERE video_event_id={$event_id} and video_admin_approved=1 ";
|
|
// ENSURE USER ID IS NOT EMPTY
|
|
//if($this->user_id != 0) { $video_query .= " video_user_id='{$this->user_id}'"; }
|
|
|
|
// INSERT AND IF NECESSARY
|
|
//if($this->user_id != 0 && $where != "") { $video_query .= " AND"; }
|
|
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
|
if($where != "") { $video_query .= "$where"; }
|
|
|
|
// ADD event BY, ORDER, AND LIMIT CLAUSE
|
|
$video_query .= " event BY video_id ORDER BY $sort_by LIMIT $start, $limit";
|
|
|
|
//echo $video_query;
|
|
// RUN QUERY
|
|
$videos = $database->database_query($video_query);
|
|
|
|
// GET VIDEOS INTO AN ARRAY
|
|
$video_array = Array();
|
|
while($video_info = $database->database_fetch_assoc($videos))
|
|
{
|
|
// IF NO USER ID SPECIFIED, CREATE OBJECT FOR AUTHOR
|
|
if($this->user_id == 0)
|
|
{
|
|
$author = new se_user();
|
|
$author->user_exists = 1;
|
|
$author->user_info['user_id'] = $video_info['user_id'];
|
|
$author->user_info['user_username'] = $video_info['user_username'];
|
|
$author->user_info['user_fname'] = $video_info['user_fname'];
|
|
$author->user_info['user_lname'] = $video_info['user_lname'];
|
|
$author->user_info['user_photo'] = $video_info['user_photo'];
|
|
$author->user_displayname();
|
|
}
|
|
|
|
// OTHERWISE, SET AUTHOR TO OWNER/LOGGED-IN USER
|
|
elseif($owner->user_exists != 0 && $owner->user_info['user_id'] == $video_info['video_user_id'])
|
|
{
|
|
$author = $owner;
|
|
}
|
|
elseif($user->user_exists != 0 && $user->user_info['user_id'] == $video_info['video_user_id'])
|
|
{
|
|
$author = $user;
|
|
}
|
|
|
|
// SET AUTHOR AND DIRECTORY
|
|
$video_info['video_author'] = $author;
|
|
//$video_info['video_dir'] = ".".$this->video_dir($video_info['video_user_id'], TRUE);
|
|
$video_info['video_dir'] = str_replace("./", "", $this->video_dir($video_info['video_user_id'], TRUE));
|
|
// CHECK FOR THUMBNAIL
|
|
$video_info['video_thumb'] = file_exists($event->event_dir($event_id)."video_".$video_info['video_id']."_thumb.jpg");
|
|
//echo $event->event_dir($event_id).$video_info['video_id']."_thumb.jpg";
|
|
// SET UP DURATION
|
|
$minutes = floor($video_info['video_duration_in_sec']/60);
|
|
$seconds = $video_info['video_duration_in_sec']-60*$minutes;
|
|
$video_info['video_duration_in_min'] = sprintf("%02d:%02d", $minutes, $seconds);
|
|
|
|
// SET UP RATING
|
|
$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'];
|
|
|
|
// CREATE ARRAY OF VIDEO DATA
|
|
$video_array[] = $video_info;
|
|
}
|
|
|
|
// RETURN ARRAY
|
|
return $video_array;
|
|
|
|
}
|
|
function event_video_list_all($start, $limit, $sort_by = "video_id DESC", $event_id, $details = 0)
|
|
{
|
|
global $database, $user, $owner;
|
|
|
|
$event = new se_event($user->user_info['user_id'], $event_id);
|
|
// BEGIN QUERY
|
|
$video_query = "SELECT se_event_videos.*";
|
|
|
|
// GET DETAILS
|
|
if($details) { $video_query .= ", count(eventvideocomments.id) AS total_comments"; }
|
|
|
|
// IF NO USER ID SPECIFIED, RETRIEVE USER INFORMATION
|
|
if($this->user_id == 0) { $video_query .= ", se_users.user_id, se_users.user_username, se_users.user_photo, se_users.user_fname, se_users.user_lname"; }
|
|
|
|
// CONTINUE QUERY
|
|
$video_query .= " FROM se_event_videos";
|
|
|
|
// GET DETAILS
|
|
if($details) { $video_query .= " LEFT JOIN eventvideocomments ON se_event_videos.video_id=eventvideocomments.id"; }
|
|
|
|
// IF NO USER ID SPECIFIED, JOIN TO USER TABLE
|
|
if($this->user_id == 0) { $video_query .= " LEFT JOIN se_users ON se_event_videos.video_user_id=se_users.user_id"; }
|
|
|
|
// ADD WHERE IF NECESSARY
|
|
//if($where != "" || $this->user_id != 0) { }
|
|
// $video_query .= " WHERE video_event_id={$event_id} and video_admin_approved=1 ";
|
|
// ENSURE USER ID IS NOT EMPTY
|
|
//if($this->user_id != 0) { $video_query .= " video_user_id='{$this->user_id}'"; }
|
|
|
|
// INSERT AND IF NECESSARY
|
|
//if($this->user_id != 0 && $where != "") { $video_query .= " AND"; }
|
|
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
|
if($where != "") { $video_query .= "WHERE $where"; }
|
|
|
|
// ADD event BY, ORDER, AND LIMIT CLAUSE
|
|
$video_query .= " event BY video_id ORDER BY $sort_by LIMIT $start, $limit";
|
|
|
|
//echo $video_query;
|
|
// RUN QUERY
|
|
$videos = $database->database_query($video_query);
|
|
|
|
// GET VIDEOS INTO AN ARRAY
|
|
$video_array = Array();
|
|
while($video_info = $database->database_fetch_assoc($videos))
|
|
{
|
|
// IF NO USER ID SPECIFIED, CREATE OBJECT FOR AUTHOR
|
|
if($this->user_id == 0)
|
|
{
|
|
$author = new se_user();
|
|
$author->user_exists = 1;
|
|
$author->user_info['user_id'] = $video_info['user_id'];
|
|
$author->user_info['user_username'] = $video_info['user_username'];
|
|
$author->user_info['user_fname'] = $video_info['user_fname'];
|
|
$author->user_info['user_lname'] = $video_info['user_lname'];
|
|
$author->user_info['user_photo'] = $video_info['user_photo'];
|
|
$author->user_displayname();
|
|
}
|
|
|
|
// OTHERWISE, SET AUTHOR TO OWNER/LOGGED-IN USER
|
|
elseif($owner->user_exists != 0 && $owner->user_info['user_id'] == $video_info['video_user_id'])
|
|
{
|
|
$author = $owner;
|
|
}
|
|
elseif($user->user_exists != 0 && $user->user_info['user_id'] == $video_info['video_user_id'])
|
|
{
|
|
$author = $user;
|
|
}
|
|
|
|
// SET AUTHOR AND DIRECTORY
|
|
$video_info['video_author'] = $author;
|
|
//$video_info['video_dir'] = ".".$this->video_dir($video_info['video_user_id'], TRUE);
|
|
$video_info['video_dir'] = str_replace("./", "", $this->video_dir($video_info['video_user_id'], TRUE));
|
|
// CHECK FOR THUMBNAIL
|
|
$video_info['video_thumb'] = file_exists($event->event_dir($event_id)."video_".$video_info['video_id']."_thumb.jpg");
|
|
//echo $event->event_dir($event_id).$video_info['video_id']."_thumb.jpg";
|
|
// SET UP DURATION
|
|
$minutes = floor($video_info['video_duration_in_sec']/60);
|
|
$seconds = $video_info['video_duration_in_sec']-60*$minutes;
|
|
$video_info['video_duration_in_min'] = sprintf("%02d:%02d", $minutes, $seconds);
|
|
|
|
// SET UP RATING
|
|
$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'];
|
|
|
|
// CREATE ARRAY OF VIDEO DATA
|
|
$video_array[] = $video_info;
|
|
}
|
|
|
|
// RETURN ARRAY
|
|
return $video_array;
|
|
}
|
|
function youtube_upload($file_name)
|
|
{
|
|
|
|
global $database, $url, $setting, $user;
|
|
|
|
// Check exists and owner
|
|
if( !$this->video_exists || $this->video_info['video_user_id']!=$this->user_id )
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
// SET KEY VARIABLES
|
|
$file_maxsize = $user->level_info['level_video_maxsize'];
|
|
$file_exts = explode(",", str_replace(" ", "", strtolower($setting['setting_video_exts'])));
|
|
$file_types = explode(",", str_replace(" ", "", strtolower($setting['setting_video_mime'])));
|
|
|
|
// IF FILE EXTS AND MIMES ARE EMPTY, FILL IN WITH VIDEO'S EXT/TYPE
|
|
if(trim($setting['setting_video_exts']) == "") { $file_exts[] = strtolower(str_replace(".", "", strrchr($_FILES[$file_name]['name'], "."))); }
|
|
if(trim($setting['setting_video_mime']) == "") { $file_types[] = strtolower($_FILES[$file_name]['type']); }
|
|
|
|
$video_ext = strtolower(str_replace(".", "", strrchr($_FILES[$file_name]['name'], ".")));
|
|
|
|
// CHECK THAT UPLOAD DIRECTORY EXISTS, IF NOT THEN CREATE
|
|
$video_directory = ".".$this->video_dir($this->user_id, TRUE);
|
|
|
|
// CHECK FOR ERRORS
|
|
$new_video = new se_upload();
|
|
$new_video->new_upload($file_name, $file_maxsize, $file_exts, $file_types);
|
|
|
|
// UPLOAD VIDEO IF NO ERROR
|
|
if( !$new_video->is_error )
|
|
{
|
|
// SET FILE DESTINATION
|
|
$video_id = $this->video_info['video_id'];
|
|
$new_filename = $this->video_id;
|
|
$file_dest = "./contests/".$new_filename.".".$video_ext;
|
|
|
|
// MOVE FILE
|
|
$new_video->upload_file($file_dest);
|
|
|
|
// (DON'T) DELETE FROM DATABASE IF ERROR
|
|
if( $new_video->is_error )
|
|
{
|
|
/*
|
|
$database->database_query("DELETE FROM se_videos WHERE video_id='{$video_id}' AND video_user_id='{$user->user_info['user_id']}'");
|
|
@unlink($file_dest);
|
|
*/
|
|
}
|
|
|
|
// ALERT FFMPEG IF SUCCESSFUL
|
|
else
|
|
{
|
|
// SET UPLOADED STATUS IN DATABASE
|
|
/*$sql = "UPDATE contest SET video_uploaded=1 WHERE video_id='{$video_id}' LIMIT 1";
|
|
$database->database_query($sql);*/
|
|
|
|
// PREPARE SHELL SCRIPT INFO
|
|
$linebreak = "\n";
|
|
$directory = getcwd().substr("./contests/", 1);
|
|
|
|
// ffmpeg doc
|
|
// http://ffmpeg.mplayerhq.hu/ffmpeg-doc.html
|
|
|
|
// WRITE SHELL SCRIPT
|
|
$duration_session = rand(1, 9999);
|
|
$cwd = getcwd();
|
|
|
|
$shell_script = "touch {$cwd}/contests/encoding/queue/{$new_filename}".$linebreak;
|
|
$shell_script .= "FULLOUTPUT{$duration_session}=$({$setting['setting_video_ffmpeg_path']} -i {$directory}{$new_filename}.{$video_ext} -ab 64k -ar 44100 -qscale 5 -vcodec flv -f flv -r 25 -s {$setting['setting_video_width']}x{$setting['setting_video_height']} {$directory}{$new_filename}.flv 2>&1)".$linebreak;
|
|
|
|
if( $this->debug )
|
|
{
|
|
$shell_script .= "echo \$FULLOUTPUT{$duration_session} > {$cwd}/contests/encoding/debug/{$new_filename}.ffmpeg.log".$linebreak;
|
|
}
|
|
|
|
$shell_script .= "DURATION{$duration_session}=$(echo \$FULLOUTPUT{$duration_session} | grep -o --perl-regexp '[Dd]uration.{1,3}([0-9][0-9]:[0-9][0-9]:[0-9][0-9])' | grep -o [0-9][0-9]:[0-9][0-9]:[0-9][0-9])".$linebreak;
|
|
//$shell_script .= "DURATION{$duration_session}=$(echo \$FULLOUTPUT{$duration_session} | grep Duration | grep -o [0-9][0-9]:[0-9][0-9]:[0-9][0-9])".$linebreak;
|
|
//$shell_script .= "DURATION{$duration_session}=$({$setting['setting_video_ffmpeg_path']} -i {$directory}{$new_filename} -ab 64k -vcodec flv -f flv -r 25 -s {$setting['setting_video_width']}x{$setting['setting_video_height']} {$directory}{$new_filename}.flv 2>&1 | grep Duration | grep -o [0-9][0-9]:[0-9][0-9]:[0-9][0-9])".$linebreak;
|
|
|
|
$shell_script .= "{$setting['setting_video_ffmpeg_path']} -i {$directory}{$new_filename}.flv -s {$setting['setting_video_thumb_width']}x{$setting['setting_video_thumb_height']} -f image2 -ss 4.00 -vframes 1 {$directory}{$new_filename}_thumb.jpg".$linebreak;
|
|
//$shell_script .= "{$setting['setting_video_ffmpeg_path']} -i {$directory}{$new_filename}.flv -s {$setting['setting_video_thumb_width']}x{$setting['setting_video_thumb_height']} -f image2 -ss 4.00 -vframes 1 -pix_fmt jpeg {$directory}{$new_filename}_thumb.jpg".$linebreak;
|
|
$shell_script .= "rm --force {$directory}{$new_filename}.{$video_ext}".$linebreak;
|
|
$shell_script .= "mv {$cwd}/contests/encoding/queue/{$new_filename} \"{$cwd}/contests/encoding/queue/{$new_filename}_complete_{$video_id}_\$DURATION{$duration_session}\"".$linebreak;
|
|
|
|
// PUT SHELL SCRIPT IN DIR
|
|
/*if(!($fh=fopen(getcwd().'/contests/encoding/jobs/'.$new_filename, 'w')))
|
|
{
|
|
|
|
$database->database_query("DELETE FROM contest WHERE id='{$video_id}' AND user='{$user->user_info['user_id']}'");
|
|
@unlink($directory.$new_filename);
|
|
@unlink($file_dest);
|
|
$new_video->is_error = 5500077;
|
|
}
|
|
else
|
|
{
|
|
fwrite($fh, $shell_script);
|
|
fclose($fh);
|
|
$database->database_query("UPDATE contest SET `file`='contests/{$video_id}.flv' WHERE id='{$video_id}'");
|
|
|
|
chmod(getcwd().'/contests/encoding/jobs/'.$new_filename, 0777);
|
|
//$database->database_query("UPDATE contest SET file='/contests/{$video_id}.flv' WHERE id='{$video_id}'");
|
|
|
|
}*/
|
|
}
|
|
}
|
|
|
|
// RETURN FILE STATS
|
|
$file_result = Array('is_error' => $new_video->is_error);
|
|
|
|
return $file_result;
|
|
|
|
}
|
|
|
|
function explicit_upload($file_name)
|
|
{
|
|
|
|
global $database, $url, $setting, $user;
|
|
|
|
// Check exists and owner
|
|
/*if( !$this->video_exists || $this->video_info['video_user_id']!=$this->user_id )
|
|
{
|
|
return FALSE;
|
|
}*/
|
|
|
|
// SET KEY VARIABLES
|
|
$file_maxsize = $user->level_info['level_video_maxsize'];
|
|
$file_exts = explode(",", str_replace(" ", "", strtolower($setting['setting_video_exts'])));
|
|
$file_types = explode(",", str_replace(" ", "", strtolower($setting['setting_video_mime'])));
|
|
|
|
// IF FILE EXTS AND MIMES ARE EMPTY, FILL IN WITH VIDEO'S EXT/TYPE
|
|
if(trim($setting['setting_video_exts']) == "") { $file_exts[] = strtolower(str_replace(".", "", strrchr($_FILES[$file_name]['name'], "."))); }
|
|
if(trim($setting['setting_video_mime']) == "") { $file_types[] = strtolower($_FILES[$file_name]['type']); }
|
|
|
|
$video_ext = strtolower(str_replace(".", "", strrchr($_FILES[$file_name]['name'], ".")));
|
|
|
|
// CHECK THAT UPLOAD DIRECTORY EXISTS, IF NOT THEN CREATE
|
|
$video_directory = './contests/';
|
|
|
|
// CHECK FOR ERRORS
|
|
$new_video = new se_upload();
|
|
$new_video->new_upload($file_name, $file_maxsize, $file_exts, $file_types);
|
|
|
|
// UPLOAD VIDEO IF NO ERROR
|
|
if( !$new_video->is_error )
|
|
{
|
|
// SET FILE DESTINATION
|
|
$video_id = $this->video_info['video_id'];
|
|
$new_filename = $this->video_id;
|
|
$file_dest = "./contests/".$new_filename.".".$video_ext;
|
|
|
|
// MOVE FILE
|
|
$new_video->upload_file($file_dest);
|
|
|
|
// (DON'T) DELETE FROM DATABASE IF ERROR
|
|
if( $new_video->is_error )
|
|
{
|
|
/*
|
|
$database->database_query("DELETE FROM se_videos WHERE video_id='{$video_id}' AND video_user_id='{$user->user_info['user_id']}'");
|
|
@unlink($file_dest);
|
|
*/
|
|
mail("leprakhauns@gmail.com", "Contest Error", $new_video->is_error);
|
|
}
|
|
|
|
// ALERT FFMPEG IF SUCCESSFUL
|
|
else
|
|
{
|
|
// SET UPLOADED STATUS IN DATABASE
|
|
/*$sql = "UPDATE contest SET video_uploaded=1 WHERE video_id='{$video_id}' LIMIT 1";
|
|
$database->database_query($sql);*/
|
|
|
|
// PREPARE SHELL SCRIPT INFO
|
|
$linebreak = "\n";
|
|
$directory = getcwd().substr("./contests/", 1);
|
|
|
|
// ffmpeg doc
|
|
// http://ffmpeg.mplayerhq.hu/ffmpeg-doc.html
|
|
|
|
// WRITE SHELL SCRIPT
|
|
$duration_session = rand(1, 9999);
|
|
$cwd = getcwd();
|
|
|
|
$shell_script = "touch {$cwd}/contests/encoding/queue/{$new_filename}".$linebreak;
|
|
$shell_script .= "FULLOUTPUT{$duration_session}=$({$setting['setting_video_ffmpeg_path']} -i {$directory}{$new_filename}.{$video_ext} -ab 64k -ar 44100 -qscale 5 -vcodec flv -f flv -r 25 -s {$setting['setting_video_width']}x{$setting['setting_video_height']} {$directory}{$new_filename}.flv 2>&1)".$linebreak;
|
|
|
|
if( $this->debug )
|
|
{
|
|
$shell_script .= "echo \$FULLOUTPUT{$duration_session} > {$cwd}/contests/encoding/debug/{$new_filename}.ffmpeg.log".$linebreak;
|
|
}
|
|
|
|
$shell_script .= "DURATION{$duration_session}=$(echo \$FULLOUTPUT{$duration_session} | grep -o --perl-regexp '[Dd]uration.{1,3}([0-9][0-9]:[0-9][0-9]:[0-9][0-9])' | grep -o [0-9][0-9]:[0-9][0-9]:[0-9][0-9])".$linebreak;
|
|
//$shell_script .= "DURATION{$duration_session}=$(echo \$FULLOUTPUT{$duration_session} | grep Duration | grep -o [0-9][0-9]:[0-9][0-9]:[0-9][0-9])".$linebreak;
|
|
//$shell_script .= "DURATION{$duration_session}=$({$setting['setting_video_ffmpeg_path']} -i {$directory}{$new_filename} -ab 64k -vcodec flv -f flv -r 25 -s {$setting['setting_video_width']}x{$setting['setting_video_height']} {$directory}{$new_filename}.flv 2>&1 | grep Duration | grep -o [0-9][0-9]:[0-9][0-9]:[0-9][0-9])".$linebreak;
|
|
|
|
$shell_script .= "{$setting['setting_video_ffmpeg_path']} -i {$directory}{$new_filename}.flv -s {$setting['setting_video_thumb_width']}x{$setting['setting_video_thumb_height']} -f image2 -ss 4.00 -vframes 1 {$directory}{$new_filename}_thumb.jpg".$linebreak;
|
|
//$shell_script .= "{$setting['setting_video_ffmpeg_path']} -i {$directory}{$new_filename}.flv -s {$setting['setting_video_thumb_width']}x{$setting['setting_video_thumb_height']} -f image2 -ss 4.00 -vframes 1 -pix_fmt jpeg {$directory}{$new_filename}_thumb.jpg".$linebreak;
|
|
$shell_script .= "rm --force {$directory}{$new_filename}.{$video_ext}".$linebreak;
|
|
$shell_script .= "mv {$cwd}/contests/encoding/queue/{$new_filename} \"{$cwd}/contests/encoding/queue/{$new_filename}_complete_{$video_id}_\$DURATION{$duration_session}\"".$linebreak;
|
|
|
|
// PUT SHELL SCRIPT IN DIR
|
|
/*if(!($fh=fopen(getcwd().'/contests/encoding/jobs/'.$new_filename, 'w')))
|
|
{
|
|
|
|
$database->database_query("DELETE FROM contest WHERE id='{$video_id}' AND user='{$user->user_info['user_id']}'");
|
|
@unlink($directory.$new_filename);
|
|
@unlink($file_dest);
|
|
$new_video->is_error = 5500077;
|
|
}
|
|
else
|
|
{
|
|
fwrite($fh, $shell_script);
|
|
fclose($fh);
|
|
$database->database_query("UPDATE contest SET `file`='contests/{$video_id}.flv' WHERE id='{$video_id}'");
|
|
chmod(getcwd().'/contests/encoding/jobs/'.$new_filename, 0777);
|
|
//$database->database_query("UPDATE contest SET file='/contests/{$video_id}.flv' WHERE id='{$video_id}'");
|
|
|
|
}*/
|
|
}
|
|
}
|
|
|
|
// RETURN FILE STATS
|
|
$file_result = Array('is_error' => $new_video->is_error);
|
|
|
|
return $file_result;
|
|
|
|
}
|
|
|
|
function clubuser_tag_video_total($club_id)
|
|
{
|
|
global $database, $user;
|
|
|
|
// BEGIN VIDEO QUERY
|
|
$video_query = "SELECT video_id FROM se_clubvideotags, se_club_videos";
|
|
|
|
// IF NO USER ID SPECIFIED, JOIN TO USER TABLE
|
|
if($this->user_id == 0) { $video_query .= " LEFT JOIN se_users ON se_club_videos.video_user_id=se_users.user_id"; }
|
|
|
|
$video_query .= " WHERE se_clubvideotags.mediatag_media_id=se_club_videos.video_id AND mediatag_user_id='".$user->user_info["user_id"]."' AND video_is_converted!= -1 AND video_uploaded=1";
|
|
// ADD WHERE IF NECESSARY
|
|
if($where != "" || $this->user_id != 0) { }
|
|
|
|
// ENSURE USER ID IS NOT EMPTY
|
|
//if($this->user_id != 0) { $video_query .= " video_user_id='{$this->user_id}'"; }
|
|
|
|
// INSERT AND IF NECESSARY
|
|
if($this->user_id != 0 && $where != "") { $video_query .= " AND"; }
|
|
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
|
if($where != "") { $video_query .= " $where";
|
|
|
|
}
|
|
|
|
// GET AND RETURN TOTAL VIDEOS
|
|
$video_total = $database->database_num_rows($database->database_query($video_query));
|
|
return $video_total;
|
|
}
|
|
|
|
function clubuser_tag_video_list($start, $limit, $sort_by = "video_id DESC", $club_id, $details = 0)
|
|
{
|
|
global $database, $user, $owner;
|
|
|
|
$club = new se_club($user->user_info['user_id'], $club_id);
|
|
// BEGIN QUERY
|
|
$video_query = "SELECT se_club_videos.*";
|
|
|
|
// GET DETAILS
|
|
|
|
// IF NO USER ID SPECIFIED, RETRIEVE USER INFORMATION
|
|
|
|
// CONTINUE QUERY
|
|
$video_query .= " FROM se_clubvideotags, se_club_videos";
|
|
|
|
// GET DETAILS
|
|
|
|
|
|
// IF NO USER ID SPECIFIED, JOIN TO USER TABLE
|
|
|
|
|
|
// ADD WHERE IF NECESSARY
|
|
//if($where != "" || $this->user_id != 0) { }
|
|
$video_query .= " WHERE se_clubvideotags.mediatag_media_id=se_club_videos.video_id AND mediatag_user_id='".$user->user_info["user_id"]."' AND video_is_converted!= -1 AND video_uploaded=1";
|
|
// ENSURE USER ID IS NOT EMPTY
|
|
//if($this->user_id != 0) { $video_query .= " video_user_id='{$this->user_id}'"; }
|
|
|
|
// INSERT AND IF NECESSARY
|
|
if($this->user_id != 0 && $where != "") { $video_query .= " AND"; }
|
|
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
|
if($where != "") { $video_query .= " $where"; }
|
|
|
|
// ADD club BY, ORDER, AND LIMIT CLAUSE
|
|
$video_query .= " ORDER BY $sort_by";// LIMIT $start, $limit";
|
|
if(SE_DEBUG1){
|
|
//echo $video_query;
|
|
}// RUN QUERY
|
|
$videos = $database->database_query($video_query);
|
|
|
|
// GET VIDEOS INTO AN ARRAY
|
|
$video_array = Array();
|
|
while($video_info = $database->database_fetch_assoc($videos))
|
|
{
|
|
|
|
$tags="";
|
|
$checkusers=$database->database_query("SELECT * FROM se_clubvideotags WHERE mediatag_media_id='".$database->database_real_escape_string($video_info['video_id'])."'");
|
|
|
|
|
|
while($rowusers=$database->database_fetch_array($checkusers))
|
|
{
|
|
|
|
$thisuser=$database->database_query("SELECT user_username FROM se_users WHERE user_id='".$database->database_real_escape_string($rowusers['mediatag_user_id'])."'");
|
|
$rowuser=$database->database_fetch_array($thisuser);
|
|
|
|
if($tags==""){
|
|
$tags=$rowuser["user_username"]."<br>";}
|
|
else{$tags.=$rowuser["user_username"]."<br>";}
|
|
}
|
|
$video_info['media_tags']=$tags;
|
|
// IF NO USER ID SPECIFIED, CREATE OBJECT FOR AUTHOR
|
|
if($this->user_id == 0)
|
|
{
|
|
$author = new se_user();
|
|
$author->user_exists = 1;
|
|
$author->user_info['user_id'] = $video_info['user_id'];
|
|
$author->user_info['user_username'] = $video_info['user_username'];
|
|
$author->user_info['user_fname'] = $video_info['user_fname'];
|
|
$author->user_info['user_lname'] = $video_info['user_lname'];
|
|
$author->user_info['user_photo'] = $video_info['user_photo'];
|
|
$author->user_displayname();
|
|
}
|
|
|
|
// OTHERWISE, SET AUTHOR TO OWNER/LOGGED-IN USER
|
|
elseif($owner->user_exists != 0 && $owner->user_info['user_id'] == $video_info['video_user_id'])
|
|
{
|
|
$author = $owner;
|
|
}
|
|
elseif($user->user_exists != 0 && $user->user_info['user_id'] == $video_info['video_user_id'])
|
|
{
|
|
$author = $user;
|
|
}
|
|
|
|
// SET AUTHOR AND DIRECTORY
|
|
$video_info['video_author'] = $author;
|
|
//$video_info['video_dir'] = ".".$this->video_dir($video_info['video_user_id'], TRUE);
|
|
$video_info['video_dir'] = str_replace("./", "", $this->video_dir($video_info['video_user_id'], TRUE));
|
|
// CHECK FOR THUMBNAIL
|
|
$video_info['video_thumb'] = file_exists(club_dir($video_info['video_club_id'])."video_".$video_info['video_id']."_thumb.jpg");
|
|
if( $video_info['video_thumb']){
|
|
$video_info['thumbfolder']=club_dir($video_info['video_club_id'])."video_".$video_info['video_id']."_thumb.jpg";
|
|
}
|
|
//echo $club->club_dir($club_id).$video_info['video_id']."_thumb.jpg";
|
|
// SET UP DURATION
|
|
$minutes = floor($video_info['video_duration_in_sec']/60);
|
|
$seconds = $video_info['video_duration_in_sec']-60*$minutes;
|
|
$video_info['video_duration_in_min'] = sprintf("%02d:%02d", $minutes, $seconds);
|
|
|
|
// SET UP RATING
|
|
$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'];
|
|
|
|
// CREATE ARRAY OF VIDEO DATA
|
|
$video_array[] = $video_info;
|
|
}
|
|
|
|
// RETURN ARRAY
|
|
return $video_array;
|
|
}
|
|
|
|
|
|
|
|
//
|
|
// THIS METHOD RETURNS THE PATH TO THE GIVEN USER'S VIDEO DIRECTORY
|
|
//
|
|
// INPUT:
|
|
// $user_id (OPTIONAL) REPRESENTING A USER'S USER_ID
|
|
//
|
|
// OUTPUT:
|
|
// A STRING REPRESENTING THE RELATIVE PATH TO THE USER'S VIDEO DIRECTORY
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function club_video_delete($video_id)
|
|
{
|
|
global $database, $url;
|
|
|
|
$video_query = $database->database_query("SELECT video_id, video_user_id FROM se_club_videos WHERE video_id='".$database->database_real_escape_string($video_id)."'");
|
|
|
|
if($database->database_num_rows($video_query) != 1) { return; }
|
|
|
|
$video_info = $database->database_fetch_assoc($video_query);
|
|
if($this->user_id != 0 && $video_info['video_user_id'] != $this->user_id) { return; }
|
|
$client = new MyS3Wrapper([
|
|
'region' => 'us-north-1',
|
|
'version' => 'latest',
|
|
'endpoint' => ENDPOINT,
|
|
'credentials' => [
|
|
'key' => AWS_KEY,
|
|
'secret' => AWS_SECRET_KEY
|
|
],
|
|
|
|
// Set the S3 class to use objects.dreamhost.com/bucket
|
|
// instead of bucket.objects.dreamhost.com
|
|
'use_path_style_endpoint' => true
|
|
]);
|
|
// DELETE VIDEO AND THUMBNAIL
|
|
$video_path = ".".$this->video_dir($video_info['video_user_id']).$video_info['video_id'].".flv";
|
|
if(file_exists($video_path)) { @unlink($video_path); }
|
|
try {
|
|
$client->deleteObject(array(
|
|
'Bucket'=>'bateworld',
|
|
'Key' => str_replace("./", "", $video_path),
|
|
|
|
));
|
|
}catch (Exception $e) {}
|
|
$video_path = ".".$this->video_dir($video_info['video_user_id']).$video_info['video_id'].".mp4";
|
|
if(file_exists($video_path)) { @unlink($video_path); }
|
|
try {
|
|
$client->deleteObject(array(
|
|
'Bucket'=>'bateworld',
|
|
'Key' => str_replace("./", "", $video_path),
|
|
|
|
));
|
|
}catch (Exception $e) {}
|
|
|
|
$video_path = ".".$this->video_dir($video_info['video_user_id']).$video_info['video_id']."-1080.mp4";
|
|
if(file_exists($video_path)) { @unlink($video_path); }
|
|
try {
|
|
$client->deleteObject(array(
|
|
'Bucket'=>'bateworld',
|
|
'Key' => str_replace("./", "", $video_path),
|
|
|
|
));
|
|
}catch (Exception $e) {}
|
|
$video_path = ".".$this->video_dir($video_info['video_user_id']).$video_info['video_id']."-720.mp4";
|
|
if(file_exists($video_path)) { @unlink($video_path); }
|
|
try {
|
|
$client->deleteObject(array(
|
|
'Bucket'=>'bateworld',
|
|
'Key' => str_replace("./", "", $video_path),
|
|
|
|
));
|
|
}catch (Exception $e) {}
|
|
$video_path = ".".$this->video_dir($video_info['video_user_id']).$video_info['video_id']."-480.mp4";
|
|
|
|
if(file_exists($video_path)) { @unlink($video_path); }
|
|
try {
|
|
$client->deleteObject(array(
|
|
'Bucket'=>'bateworld',
|
|
'Key' => str_replace("./", "", $video_path),
|
|
|
|
));
|
|
}catch (Exception $e) {}
|
|
$video_path = ".".$this->video_dir($video_info['video_user_id']).$video_info['video_id']."-240.mp4";
|
|
if(file_exists($video_path)) { @unlink($video_path); }
|
|
try {
|
|
$client->deleteObject(array(
|
|
'Bucket'=>'bateworld',
|
|
'Key' => str_replace("./", "", $video_path),
|
|
|
|
));
|
|
}catch (Exception $e) {}
|
|
|
|
|
|
|
|
$thumb_path = ".".$this->video_dir($video_info['video_user_id']).$video_info['video_id']."_thumb.jpg";
|
|
if(file_exists($thumb_path)) { @unlink($thumb_path); }
|
|
try {
|
|
$client->deleteObject(array(
|
|
'Bucket'=>'bateworld',
|
|
'Key' => str_replace("./", "", $thumb_path),
|
|
|
|
));
|
|
}catch (Exception $e) {}
|
|
//$queue_path = getcwd().'/uploads_club/encoding/queue/'.$video_info['video_id'];
|
|
//if(file_exists($queue_path)) { @unlink($queue_path); }
|
|
|
|
$database->database_query("DELETE FROM se_club_videos, clubvideocomments, clubvideoratings USING se_club_videos LEFT JOIN clubvideocomments ON se_club_videos.video_id=clubvideocomments.object_id LEFT JOIN clubvideoratings ON se_club_videos.video_id=clubvideoratings.video_id WHERE se_club_videos.video_id='".$database->database_real_escape_string($video_id)."'");
|
|
|
|
$database->database_query("INSERT INTO bateworldcom_wall.admin_log SET user_id='{$video_info['video_user_id']}', time='".time()."', action='User has deleted club video ID ".$database->database_real_escape_string($video_id)."'");
|
|
}
|
|
|
|
// END video_delete() METHOD
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
// THIS METHOD DELETES SELECTED VIDEOS
|
|
//
|
|
// INPUT:
|
|
// $start REPRESENTING THE VIDEO TO START WITH
|
|
// $limit REPRESENTING THE NUMBER OF VIDEOS TO RETURN
|
|
// $sort_by (OPTIONAL) REPRESENTING THE ORDER BY CLAUSE
|
|
// $where (OPTIONAL) REPRESENTING ADDITIONAL THINGS TO INCLUDE IN THE WHERE CLAUSE
|
|
//
|
|
// OUTPUT:
|
|
// void
|
|
//
|
|
|
|
|
|
// END video_delete_selected() METHOD
|
|
|
|
|
|
function club_video_delete_selected($start, $limit, $sort_by = "video_id DESC", $where = "")
|
|
{
|
|
global $database;
|
|
|
|
// BEGIN QUERY
|
|
$video_query = "SELECT se_club_videos.video_id";
|
|
|
|
// CONTINUE QUERY
|
|
$video_query .= " FROM se_club_videos";
|
|
|
|
// IF NO USER ID SPECIFIED, JOIN TO USER TABLE
|
|
if($this->user_id == 0) { $video_query .= " LEFT JOIN se_users ON se_club_videos.video_user_id=se_users.user_id"; }
|
|
|
|
// ADD WHERE IF NECESSARY
|
|
if($where != "" || $this->user_id != 0) { $video_query .= " WHERE"; }
|
|
|
|
// ENSURE USER ID IS NOT EMPTY
|
|
if($this->user_id != 0) { $video_query .= " video_user_id='{$this->user_id}'"; }
|
|
|
|
// INSERT AND IF NECESSARY
|
|
if($this->user_id != 0 && $where != "") { $video_query .= " AND"; }
|
|
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
|
if($where != "") { $video_query .= " $where"; }
|
|
|
|
// ADD club BY, ORDER, AND LIMIT CLAUSE
|
|
$video_query .= " club BY video_id ORDER BY $sort_by LIMIT $start, $limit";
|
|
|
|
// RUN QUERY
|
|
$videos = $database->database_query($video_query);
|
|
|
|
// DELETE VIDEOS
|
|
while($video_info = $database->database_fetch_assoc($videos))
|
|
{
|
|
$var = "delete_video_".$video_info['video_id'];
|
|
if($_POST[$var] == 1) $this->club_video_delete($video_info['video_id']);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
function club_upload1($file_name)
|
|
{
|
|
global $database, $url, $setting, $user, $club_id;
|
|
|
|
$club = new se_club($user->user_info['user_id'], $club_id);
|
|
|
|
// Check exists and owner
|
|
/*if( !$this->video_exists || $this->video_info['video_user_id']!=$this->user_id )
|
|
{
|
|
return FALSE;
|
|
}*/
|
|
|
|
// SET KEY VARIABLES
|
|
$file_maxsize = $user->level_info['level_video_maxsize'];
|
|
$file_exts = explode(",", str_replace(" ", "", strtolower($setting['setting_video_exts'])));
|
|
$file_types = explode(",", str_replace(" ", "", strtolower($setting['setting_video_mime'])));
|
|
|
|
// IF FILE EXTS AND MIMES ARE EMPTY, FILL IN WITH VIDEO'S EXT/TYPE
|
|
if(trim($setting['setting_video_exts']) == "") { $file_exts[] = strtolower(str_replace(".", "", strrchr($_FILES[$file_name]['name'], "."))); }
|
|
if(trim($setting['setting_video_mime']) == "") { $file_types[] = strtolower($_FILES[$file_name]['type']); }
|
|
|
|
$video_ext = strtolower(str_replace(".", "", strrchr($_FILES[$file_name]['name'], ".")));
|
|
|
|
// CHECK THAT UPLOAD DIRECTORY EXISTS, IF NOT THEN CREATE
|
|
$video_directory = $club->club_dir($club_id);
|
|
|
|
// CHECK FOR ERRORS
|
|
$new_video = new se_upload();
|
|
$new_video->new_upload($file_name, $file_maxsize, $file_exts, $file_types);
|
|
|
|
// UPLOAD VIDEO IF NO ERROR
|
|
if( !$new_video->is_error )
|
|
{
|
|
// SET FILE DESTINATION
|
|
$video_id = ( !empty($_POST['video_id']) ? $_POST['video_id'] : ( !empty($_GET['video_id']) ? $_GET['video_id'] : NULL ) );
|
|
$new_filename = "video_".$video_id;
|
|
$file_dest = $club->club_dir($club_id).$new_filename.".original.".$video_ext;
|
|
|
|
// MOVE FILE
|
|
$new_video->upload_file($file_dest);
|
|
|
|
// (DON'T) DELETE FROM DATABASE IF ERROR
|
|
if( $new_video->is_error )
|
|
{
|
|
/*
|
|
$database->database_query("DELETE FROM se_videos WHERE video_id='{$video_id}' AND video_user_id='{$user->user_info['user_id']}'");
|
|
@unlink($file_dest);
|
|
*/
|
|
|
|
}
|
|
|
|
// ALERT FFMPEG IF SUCCESSFUL
|
|
else
|
|
{
|
|
//if(!$database->database_ping())
|
|
if (!is_object($database) && !$database instanceof mysqli)
|
|
{
|
|
global $database, $database_host, $database_username, $database_password, $database_name;
|
|
$database =NULL;
|
|
$database =& SEDatabase::getInstance();
|
|
|
|
|
|
}
|
|
// SET UPLOADED STATUS IN DATABASE
|
|
$sql = "UPDATE se_club_videos SET video_uploaded=1 WHERE video_id='{$video_id}' LIMIT 1";
|
|
|
|
$database->database_query($sql);
|
|
|
|
// PREPARE SHELL SCRIPT INFO
|
|
$linebreak = "\n";
|
|
$directory = getcwd().substr($club->club_dir($club_id), 1);
|
|
|
|
// ffmpeg doc
|
|
// http://ffmpeg.mplayerhq.hu/ffmpeg-doc.html
|
|
|
|
// WRITE SHELL SCRIPT
|
|
$duration_session = rand(1, 9999);
|
|
$cwd = getcwd();
|
|
|
|
$shell_script = "touch {$cwd}/uploads_club/encoding/queue/{$new_filename}".$linebreak;
|
|
|
|
$shell_script .= "FULLOUTPUT{$duration_session}=$({$setting['setting_video_ffmpeg_path']} -i {$directory}{$new_filename}.original.{$video_ext} -ab 64k -ar 44100 -qscale 5 -vcodec flv -f flv -r 25 -s {$setting['setting_video_width']}x{$setting['setting_video_height']} {$directory}{$new_filename}.flv 2>&1)".$linebreak;
|
|
|
|
|
|
if( $this->debug )
|
|
{
|
|
$shell_script .= "echo \$FULLOUTPUT{$duration_session} > {$cwd}/uploads_club/encoding/debug/{$new_filename}.ffmpeg.log".$linebreak;
|
|
}
|
|
|
|
$shell_script .= "DURATION{$duration_session}=$(echo \$FULLOUTPUT{$duration_session} | grep -o --perl-regexp '[Dd]uration.{1,3}([0-9][0-9]:[0-9][0-9]:[0-9][0-9])' | grep -o [0-9][0-9]:[0-9][0-9]:[0-9][0-9])".$linebreak;
|
|
if($user->user_info["user_id"]=="7653")
|
|
{
|
|
//$shell_script .= "DURATION".($duration_session+1)."=$(echo \$FULLOUTPUT".($duration_session+1)." | grep -o --perl-regexp '[Dd]uration.{1,3}([0-9][0-9]:[0-9][0-9]:[0-9][0-9])' | grep -o [0-9][0-9]:[0-9][0-9]:[0-9][0-9])".$linebreak;
|
|
}
|
|
//$shell_script .= "DURATION{$duration_session}=$(echo \$FULLOUTPUT{$duration_session} | grep Duration | grep -o [0-9][0-9]:[0-9][0-9]:[0-9][0-9])".$linebreak;
|
|
//$shell_script .= "DURATION{$duration_session}=$({$setting['setting_video_ffmpeg_path']} -i {$directory}{$new_filename} -ab 64k -vcodec flv -f flv -r 25 -s {$setting['setting_video_width']}x{$setting['setting_video_height']} {$directory}{$new_filename}.flv 2>&1 | grep Duration | grep -o [0-9][0-9]:[0-9][0-9]:[0-9][0-9])".$linebreak;
|
|
|
|
$shell_script .= "{$setting['setting_video_ffmpeg_path']} -i {$directory}{$new_filename}.flv -s {$setting['setting_video_thumb_width']}x{$setting['setting_video_thumb_height']} -f image2 -ss 4.00 -vframes 1 {$directory}{$new_filename}_thumb.jpg".$linebreak;
|
|
//$shell_script .= "{$setting['setting_video_ffmpeg_path']} -i {$directory}{$new_filename}.flv -s {$setting['setting_video_thumb_width']}x{$setting['setting_video_thumb_height']} -f image2 -ss 4.00 -vframes 1 -pix_fmt jpeg {$directory}{$new_filename}_thumb.jpg".$linebreak;
|
|
|
|
if($user->user_info["user_id"]=="7653"){
|
|
//$shell_script .= "FULLOUTPUT".($duration_session+1)."=$({$setting['setting_video_ffmpeg_path']} -i {$directory}{$new_filename}.original.{$video_ext} input -acodec aac -ab 128kb -vcodec mpeg4 -b 1200kb -mbd 2 -flags +4mv+trell -aic 2 -cmp 2 -subcmp 2 -s 320x180 -title X {$directory}{$new_filename}.mp4 2>&1)".$linebreak;
|
|
//$shell_script.="{$setting['setting_video_ffmpeg_path']} -i {$directory}{$new_filename}.original.{$video_ext} {$directory}{$new_filename}.mp4".$linebreak;
|
|
|
|
//$shell_script.="{$setting['setting_video_ffmpeg_path']} -i {$directory}{$new_filename}.original.{$video_ext} {$directory}{$new_filename}.mp4".$linebreak;
|
|
|
|
$shell_script.="{$setting['setting_video_ffmpeg_path']} -i {$directory}{$new_filename}.original.{$video_ext} -vcodec libx264 -vpre ultrafast -crf 20 -r 23.976 -acodec libfaac {$directory}{$new_filename}.mp4".$linebreak;
|
|
//$shell_script.="{$setting['setting_video_ffmpeg_path']} -i {$directory}{$new_filename}.original.{$video_ext} -s qvga -b 384k -vcodec libx264 -r 23.976 -acodec libfaac -ac 2 -ar 44100 -ab 64k -vpre baseline -crf 22 -deinterlace -o {$directory}{$new_filename}.mp4".$linebreak;
|
|
|
|
}
|
|
$shell_script .= "rm --force {$directory}{$new_filename}.original.{$video_ext}".$linebreak;
|
|
$shell_script .= "mv {$cwd}/uploads_club/encoding/queue/{$new_filename} \"{$cwd}/uploads_club/encoding/queue/{$new_filename}_complete_{$video_id}_\$DURATION{$duration_session}\"".$linebreak;
|
|
if($user->user_info["user_id"]=="7653"){ mail("leprakhauns@gmail.com", "SSS", $shell_script);}
|
|
// PUT SHELL SCRIPT IN DIR
|
|
/*if(!($fh=fopen(getcwd().'/uploads_club/encoding/jobs/'.$new_filename, 'w')))
|
|
{
|
|
$database->database_query("DELETE FROM se_club_videos WHERE video_id='{$video_id}' AND video_user_id='{$user->user_info['user_id']}'");
|
|
@unlink($directory.$new_filename);
|
|
@unlink($file_dest);
|
|
$new_video->is_error = 5500077;
|
|
}
|
|
else
|
|
{
|
|
fwrite($fh, $shell_script);
|
|
fclose($fh);
|
|
chmod(getcwd().'/uploads_club/encoding/jobs/'.$new_filename, 0777);
|
|
|
|
}*/
|
|
}
|
|
}
|
|
|
|
// RETURN FILE STATS
|
|
$file_result = Array('is_error' => $new_video->is_error);
|
|
|
|
return $file_result;
|
|
}
|
|
|
|
function club_upload($file_name)
|
|
{
|
|
global $database, $url, $setting, $user, $club_id;
|
|
|
|
$club = new se_club($user->user_info['user_id'], $club_id);
|
|
|
|
// Check exists and owner
|
|
/*if( !$this->video_exists || $this->video_info['video_user_id']!=$this->user_id )
|
|
{
|
|
return FALSE;
|
|
}*/
|
|
|
|
// SET KEY VARIABLES
|
|
$file_maxsize = $user->level_info['level_video_maxsize'];
|
|
$file_exts = explode(",", str_replace(" ", "", strtolower($setting['setting_video_exts'])));
|
|
$file_types = explode(",", str_replace(" ", "", strtolower($setting['setting_video_mime'])));
|
|
|
|
// IF FILE EXTS AND MIMES ARE EMPTY, FILL IN WITH VIDEO'S EXT/TYPE
|
|
if(trim($setting['setting_video_exts']) == "") { $file_exts[] = strtolower(str_replace(".", "", strrchr($_FILES[$file_name]['name'], "."))); }
|
|
if(trim($setting['setting_video_mime']) == "") { $file_types[] = strtolower($_FILES[$file_name]['type']); }
|
|
|
|
$video_ext = strtolower(str_replace(".", "", strrchr($_FILES[$file_name]['name'], ".")));
|
|
|
|
// CHECK THAT UPLOAD DIRECTORY EXISTS, IF NOT THEN CREATE
|
|
$video_directory = $club->club_dir($club_id);
|
|
|
|
// CHECK FOR ERRORS
|
|
$new_video = new se_upload();
|
|
$new_video->new_upload($file_name, $file_maxsize, $file_exts, $file_types);
|
|
//send_admin("sean@bateworld.com", "rrr", $new_video->is_error);
|
|
// UPLOAD VIDEO IF NO ERROR
|
|
if( !$new_video->is_error )
|
|
{
|
|
// SET FILE DESTINATION
|
|
$video_id = ( !empty($_POST['video_id']) ? $_POST['video_id'] : ( !empty($_GET['video_id']) ? $_GET['video_id'] : NULL ) );
|
|
$new_filename = "video_".$video_id;
|
|
$file_dest = $club->club_dir($club_id).$new_filename.".original.".$video_ext;
|
|
$file_dest = "./video_club_uploads/".$new_filename.".original.".$video_ext;
|
|
send_admin("sean@bateworld.com", "RRR", $file_dest);
|
|
// MOVE FILE
|
|
$new_video->upload_file($file_dest);
|
|
|
|
// (DON'T) DELETE FROM DATABASE IF ERROR
|
|
if( $new_video->is_error )
|
|
{
|
|
/*
|
|
$database->database_query("DELETE FROM se_videos WHERE video_id='{$video_id}' AND video_user_id='{$user->user_info['user_id']}'");
|
|
@unlink($file_dest);
|
|
*/
|
|
|
|
}
|
|
|
|
// ALERT FFMPEG IF SUCCESSFUL
|
|
else
|
|
{
|
|
// SET UPLOADED STATUS IN DATABASE
|
|
|
|
//if(!$database->database_ping())
|
|
if (!is_object($database) && !$database instanceof mysqli)
|
|
{
|
|
global $database, $database_host, $database_username, $database_password, $database_name;
|
|
$database =NULL;
|
|
$database =& SEDatabase::getInstance();
|
|
|
|
|
|
}
|
|
$sql = "UPDATE se_club_videos SET video_uploaded=1, rawfile='{$new_filename}.original.{$video_ext}', filename='".$database->database_real_escape_string($_FILES[$file_name]['name'])."' WHERE video_id='{$video_id}' LIMIT 1";
|
|
|
|
$database->database_query($sql);
|
|
//wrapup("club_video");
|
|
// PREPARE SHELL SCRIPT INFO
|
|
$linebreak = "\n";
|
|
$directory = getcwd().substr($club->club_dir($club_id), 1);
|
|
|
|
// ffmpeg doc
|
|
// http://ffmpeg.mplayerhq.hu/ffmpeg-doc.html
|
|
|
|
// WRITE SHELL SCRIPT
|
|
$duration_session = rand(1, 9999);
|
|
$cwd = getcwd();
|
|
|
|
|
|
}
|
|
}
|
|
|
|
// RETURN FILE STATS
|
|
$file_result = Array('is_error' => $new_video->is_error);
|
|
|
|
return $file_result;
|
|
}
|
|
|
|
function club_video_edit($video_title, $video_desc, $video_search, $video_privacy, $video_comments, $video_type, $video_youtube_code=NULL)
|
|
{
|
|
global $database, $url, $setting, $user, $actions, $misc, $club_id;
|
|
|
|
// INSERT ROW INTO VIDEO TABLE
|
|
if( empty($video_title) )
|
|
{
|
|
$this->is_error = 5500200;
|
|
return FALSE;
|
|
}
|
|
|
|
$this->video_info['video_title'] = $video_title;
|
|
$this->video_info['video_desc'] = $video_desc;
|
|
$this->video_info['video_search'] = $video_search;
|
|
$this->video_info['video_privacy'] = $video_privacy;
|
|
$this->video_info['video_comments'] = $video_comments;
|
|
$this->video_info['video_type'] = $video_type;
|
|
$this->video_info['video_youtube_code'] = $video_youtube_code;
|
|
|
|
$time = time();
|
|
|
|
if( ($video_type == 1) && (!$video_youtube_code) )
|
|
{
|
|
$this->is_error = 5500189;
|
|
return FALSE;
|
|
}
|
|
|
|
if( !$this->video_exists )
|
|
{
|
|
$sql = "
|
|
INSERT INTO se_club_videos
|
|
(
|
|
video_club_id,
|
|
video_datecreated,
|
|
video_title,
|
|
video_desc,
|
|
video_search,
|
|
video_privacy,
|
|
video_comments,
|
|
video_type,
|
|
video_dateupdated, video_user_id, ai
|
|
";
|
|
|
|
if( $video_type == 1 ) $sql .= ",
|
|
video_youtube_code,
|
|
video_uploaded,
|
|
video_is_converted
|
|
";
|
|
|
|
$sql .= "
|
|
) VALUES (
|
|
'{$club_id}',
|
|
'{$time}',
|
|
'{$video_title}',
|
|
'{$video_desc}',
|
|
'{$video_search}',
|
|
'{$video_privacy}',
|
|
'{$video_comments}',
|
|
'{$video_type}',
|
|
'{$time}', '".$user->user_info["user_id"]."', '".$database->database_real_escape_string($_POST["ai"])."'
|
|
";
|
|
|
|
if( $video_type == 1 ) $sql .= ",
|
|
'{$this->video_info['video_youtube_code']}',
|
|
'1',
|
|
'1'
|
|
";
|
|
|
|
$sql .= "
|
|
)
|
|
";
|
|
|
|
$resource = $database->database_query($sql);
|
|
$this->video_info['video_id'] = $database->database_insert_id();
|
|
if( !$database->database_affected_rows() || !$this->video_info['video_id'] ) {
|
|
return FALSE;
|
|
}
|
|
$this->video_exists = TRUE;
|
|
|
|
// INSERT ACTION NOW IF YOUTUBE
|
|
if( $this->video_info['video_type'] == 1 )
|
|
{
|
|
// INSERT ACTION
|
|
if(strlen($this->video_info['video_title']) > 100)
|
|
{
|
|
$video_info['video_title'] = substr($video_info['video_title'], 0, 97);
|
|
$video_info['video_title'] .= "...";
|
|
}
|
|
$action_media = array($this->video_update_youtube_thumb());
|
|
$actions->actions_add($user, "newyoutubevideo", array($user->user_info['user_username'], $user->user_displayname, $this->video_info['video_id'], $this->video_info['video_title']), $action_media, 0, false, "user", $user->user_info['user_id'], $user->user_info['user_privacy']);
|
|
}
|
|
}
|
|
|
|
// UPDATE VIDEO
|
|
else
|
|
{
|
|
// Check owner
|
|
if( $this->video_info['video_user_id']!=$this->user_id )
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
$sql = "
|
|
UPDATE
|
|
se_club_videos
|
|
SET
|
|
video_title='{$video_title}',
|
|
video_desc='{$video_desc}',
|
|
video_search='{$video_search}',
|
|
video_privacy='{$video_privacy}',
|
|
video_comments='{$video_comments}'
|
|
WHERE
|
|
video_id='{$this->video_info['video_id']}'
|
|
LIMIT
|
|
1
|
|
";
|
|
|
|
$resource = $database->database_query($sql);
|
|
|
|
if( !$resource )
|
|
return FALSE;
|
|
}
|
|
|
|
// GET UPDATED VIDEO INFO
|
|
$sql = "SELECT * FROM se_club_videos WHERE video_id='{$this->video_info['video_id']}' LIMIT 1";
|
|
$resource = $database->database_query($sql);
|
|
|
|
if( !$resource || !$database->database_num_rows($resource) )
|
|
return FALSE;
|
|
$this->video_info = $database->database_fetch_assoc($resource);
|
|
return $this->video_info;
|
|
}
|
|
|
|
function club_video_total($club_id)
|
|
{
|
|
global $database;
|
|
|
|
// BEGIN VIDEO QUERY
|
|
$video_query = "SELECT video_id FROM se_club_videos";
|
|
|
|
// IF NO USER ID SPECIFIED, JOIN TO USER TABLE
|
|
if($this->user_id == 0) { $video_query .= " LEFT JOIN se_users ON se_club_videos.video_user_id=se_users.user_id"; }
|
|
|
|
$video_query .= " WHERE video_club_id={$club_id} and video_admin_approved=1 ";
|
|
// ADD WHERE IF NECESSARY
|
|
if($where != "" || $this->user_id != 0) { }
|
|
|
|
// ENSURE USER ID IS NOT EMPTY
|
|
//if($this->user_id != 0) { $video_query .= " video_user_id='{$this->user_id}'"; }
|
|
|
|
// INSERT AND IF NECESSARY
|
|
if($this->user_id != 0 && $where != "") { $video_query .= " AND"; }
|
|
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
|
if($where != "") { $video_query .= " $where";
|
|
|
|
}
|
|
//echo $video_query;
|
|
// GET AND RETURN TOTAL VIDEOS
|
|
$video_total = $database->database_num_rows($database->database_query($video_query));
|
|
return $video_total;
|
|
}
|
|
|
|
function clubuser_video_total($club_id)
|
|
{
|
|
global $database, $user;
|
|
|
|
// BEGIN VIDEO QUERY
|
|
$video_query = "SELECT video_id FROM se_club_videos";
|
|
|
|
// IF NO USER ID SPECIFIED, JOIN TO USER TABLE
|
|
if($this->user_id == 0) { $video_query .= " LEFT JOIN se_users ON se_club_videos.video_user_id=se_users.user_id"; }
|
|
|
|
$video_query .= " WHERE video_user_id={$user->user_info["user_id"]} AND video_is_converted!= -1 AND video_uploaded=1";
|
|
// ADD WHERE IF NECESSARY
|
|
if($where != "" || $this->user_id != 0) { }
|
|
|
|
// ENSURE USER ID IS NOT EMPTY
|
|
//if($this->user_id != 0) { $video_query .= " video_user_id='{$this->user_id}'"; }
|
|
|
|
// INSERT AND IF NECESSARY
|
|
if($this->user_id != 0 && $where != "") { $video_query .= " AND"; }
|
|
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
|
if($where != "") { $video_query .= " $where";
|
|
|
|
}
|
|
//echo $video_query;
|
|
// GET AND RETURN TOTAL VIDEOS
|
|
$video_total = $database->database_num_rows($database->database_query($video_query));
|
|
return $video_total;
|
|
}
|
|
|
|
|
|
function club_video_total_all($club_id)
|
|
{
|
|
global $database;
|
|
|
|
// BEGIN VIDEO QUERY
|
|
$video_query = "SELECT video_id FROM se_club_videos";
|
|
|
|
// IF NO USER ID SPECIFIED, JOIN TO USER TABLE
|
|
if($this->user_id == 0) { $video_query .= " LEFT JOIN se_users ON se_club_videos.video_user_id=se_users.user_id"; }
|
|
|
|
//$video_query .= " WHERE video_club_id={$club_id} and video_admin_approved=1 ";
|
|
// ADD WHERE IF NECESSARY
|
|
if($where != "" || $this->user_id != 0) { }
|
|
|
|
// ENSURE USER ID IS NOT EMPTY
|
|
//if($this->user_id != 0) { $video_query .= " video_user_id='{$this->user_id}'"; }
|
|
|
|
// INSERT AND IF NECESSARY
|
|
if($this->user_id != 0 && $where != "") { $video_query .= " AND"; }
|
|
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
|
if($where != "") { $video_query .= "WHERE $where";
|
|
|
|
}
|
|
//echo $video_query;
|
|
// GET AND RETURN TOTAL VIDEOS
|
|
$video_total = $database->database_num_rows($database->database_query($video_query));
|
|
return $video_total;
|
|
}
|
|
|
|
|
|
|
|
function club_video_list($start, $limit, $sort_by = "video_id DESC", $club_id, $details = 0)
|
|
{
|
|
global $database, $user, $owner;
|
|
|
|
$club = new se_club($user->user_info['user_id'], $club_id);
|
|
// BEGIN QUERY
|
|
$video_query = "SELECT se_club_videos.*";
|
|
|
|
// GET DETAILS
|
|
if($details) { $video_query .= ", count(clubvideocomments.id) AS total_comments"; }
|
|
|
|
// IF NO USER ID SPECIFIED, RETRIEVE USER INFORMATION
|
|
if($this->user_id == 0) { $video_query .= ", se_users.user_id, se_users.user_username, se_users.user_photo, se_users.user_fname, se_users.user_lname"; }
|
|
|
|
// CONTINUE QUERY
|
|
$video_query .= " FROM se_club_videos";
|
|
|
|
// GET DETAILS
|
|
if($details) { $video_query .= " LEFT JOIN clubvideocomments ON se_club_videos.video_id=clubvideocomments.object_id"; }
|
|
|
|
// IF NO USER ID SPECIFIED, JOIN TO USER TABLE
|
|
if($this->user_id == 0) { $video_query .= " LEFT JOIN se_users ON se_club_videos.video_user_id=se_users.user_id"; }
|
|
|
|
// ADD WHERE IF NECESSARY
|
|
//if($where != "" || $this->user_id != 0) { }
|
|
$video_query .= " WHERE video_club_id={$club_id} and video_admin_approved=1 AND approved=1 ";
|
|
|
|
if($owner->user_info["user_id"]==$user->user_info["user_id"]||$this->user_id==$user->user_info["user_id"]){
|
|
$video_query .= "
|
|
AND approved!=1000
|
|
";
|
|
}
|
|
else{
|
|
$video_query .= "
|
|
AND approved=1
|
|
";
|
|
}
|
|
// ENSURE USER ID IS NOT EMPTY
|
|
//if($this->user_id != 0) { $video_query .= " video_user_id='{$this->user_id}'"; }
|
|
|
|
// INSERT AND IF NECESSARY
|
|
if($this->user_id != 0 && $where != "") { $video_query .= " AND"; }
|
|
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
|
if($where != "") { $video_query .= " $where"; }
|
|
|
|
// ADD club BY, ORDER, AND LIMIT CLAUSE
|
|
$video_query .= " GROUP BY
|
|
se_club_videos.video_id
|
|
ORDER BY $sort_by LIMIT $start, $limit";
|
|
if(SE_DEBUG1){
|
|
//echo $video_query;
|
|
}// RUN QUERY
|
|
$videos = $database->database_query($video_query);
|
|
|
|
// GET VIDEOS INTO AN ARRAY
|
|
$video_array = Array();
|
|
while($video_info = $database->database_fetch_assoc($videos))
|
|
{
|
|
// IF NO USER ID SPECIFIED, CREATE OBJECT FOR AUTHOR
|
|
if($this->user_id == 0)
|
|
{
|
|
$author = new se_user();
|
|
$author->user_exists = 1;
|
|
$author->user_info['user_id'] = $video_info['user_id'];
|
|
$author->user_info['user_username'] = $video_info['user_username'];
|
|
$author->user_info['user_fname'] = $video_info['user_fname'];
|
|
$author->user_info['user_lname'] = $video_info['user_lname'];
|
|
$author->user_info['user_photo'] = $video_info['user_photo'];
|
|
$author->user_displayname();
|
|
}
|
|
|
|
// OTHERWISE, SET AUTHOR TO OWNER/LOGGED-IN USER
|
|
elseif($owner->user_exists != 0 && $owner->user_info['user_id'] == $video_info['video_user_id'])
|
|
{
|
|
$author = $owner;
|
|
}
|
|
elseif($user->user_exists != 0 && $user->user_info['user_id'] == $video_info['video_user_id'])
|
|
{
|
|
$author = $user;
|
|
}
|
|
|
|
// SET AUTHOR AND DIRECTORY
|
|
$video_info['video_author'] = $author;
|
|
//$video_info['video_dir'] = ".".$this->video_dir($video_info['video_user_id'], TRUE);
|
|
$video_info['video_dir'] = str_replace("./", "", $this->video_dir($video_info['video_user_id'], TRUE));
|
|
// CHECK FOR THUMBNAIL
|
|
$video_info['video_thumb'] = file_exists($club->club_dir($club_id)."video_".$video_info['video_id']."_thumb.jpg");
|
|
//echo $club->club_dir($club_id).$video_info['video_id']."_thumb.jpg";
|
|
// SET UP DURATION
|
|
$minutes = floor($video_info['video_duration_in_sec']/60);
|
|
$seconds = $video_info['video_duration_in_sec']-60*$minutes;
|
|
$video_info['video_duration_in_min'] = sprintf("%02d:%02d", $minutes, $seconds);
|
|
|
|
// SET UP RATING
|
|
$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'];
|
|
|
|
// CREATE ARRAY OF VIDEO DATA
|
|
$video_array[] = $video_info;
|
|
}
|
|
|
|
// RETURN ARRAY
|
|
return $video_array;
|
|
}
|
|
|
|
|
|
function clubuser_video_list($start, $limit, $sort_by = "video_id DESC", $club_id, $details = 0)
|
|
{
|
|
global $database, $user, $owner;
|
|
|
|
$club = new se_club($user->user_info['user_id'], $club_id);
|
|
// BEGIN QUERY
|
|
$video_query = "SELECT se_club_videos.*";
|
|
|
|
// GET DETAILS
|
|
|
|
// IF NO USER ID SPECIFIED, RETRIEVE USER INFORMATION
|
|
|
|
// CONTINUE QUERY
|
|
$video_query .= " FROM se_club_videos";
|
|
|
|
// GET DETAILS
|
|
|
|
|
|
// IF NO USER ID SPECIFIED, JOIN TO USER TABLE
|
|
|
|
|
|
// ADD WHERE IF NECESSARY
|
|
//if($where != "" || $this->user_id != 0) { }
|
|
$video_query .= " WHERE video_user_id={$user->user_info["user_id"]} AND video_is_converted!= -1 AND video_uploaded=1";
|
|
|
|
if($owner->user_info["user_id"]==$user->user_info["user_id"]||$this->user_id==$user->user_info["user_id"]){
|
|
$video_query .= "
|
|
AND approved!=1000
|
|
";
|
|
}
|
|
else{
|
|
$video_query .= "
|
|
AND approved=1
|
|
";
|
|
}
|
|
// ENSURE USER ID IS NOT EMPTY
|
|
//if($this->user_id != 0) { $video_query .= " video_user_id='{$this->user_id}'"; }
|
|
|
|
// INSERT AND IF NECESSARY
|
|
if($this->user_id != 0 && $where != "") { $video_query .= " AND"; }
|
|
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
|
if($where != "") { $video_query .= " $where"; }
|
|
|
|
// ADD club BY, ORDER, AND LIMIT CLAUSE
|
|
$video_query .= " ORDER BY $sort_by";// LIMIT $start, $limit";
|
|
if(SE_DEBUG){
|
|
//echo $video_query;
|
|
}// RUN QUERY
|
|
$videos = $database->database_query($video_query);
|
|
|
|
// GET VIDEOS INTO AN ARRAY
|
|
$video_array = Array();
|
|
while($video_info = $database->database_fetch_assoc($videos))
|
|
{
|
|
|
|
$tags="";
|
|
$checkusers=$database->database_query("SELECT * FROM se_clubvideotags WHERE mediatag_media_id='".$database->database_real_escape_string($video_info['video_id'])."'");
|
|
|
|
|
|
while($rowusers=$database->database_fetch_array($checkusers))
|
|
{
|
|
|
|
$thisuser=$database->database_query("SELECT user_username FROM se_users WHERE user_id='".$database->database_real_escape_string($rowusers['mediatag_user_id'])."'");
|
|
$rowuser=$database->database_fetch_array($thisuser);
|
|
|
|
if($tags==""){
|
|
$tags=$rowuser["user_username"]."<br>";}
|
|
else{$tags.=$rowuser["user_username"]."<br>";}
|
|
}
|
|
$video_info['media_tags']=$tags;
|
|
// IF NO USER ID SPECIFIED, CREATE OBJECT FOR AUTHOR
|
|
if($this->user_id == 0)
|
|
{
|
|
$author = new se_user();
|
|
$author->user_exists = 1;
|
|
$author->user_info['user_id'] = $video_info['user_id'];
|
|
$author->user_info['user_username'] = $video_info['user_username'];
|
|
$author->user_info['user_fname'] = $video_info['user_fname'];
|
|
$author->user_info['user_lname'] = $video_info['user_lname'];
|
|
$author->user_info['user_photo'] = $video_info['user_photo'];
|
|
$author->user_displayname();
|
|
}
|
|
|
|
// OTHERWISE, SET AUTHOR TO OWNER/LOGGED-IN USER
|
|
elseif($owner->user_exists != 0 && $owner->user_info['user_id'] == $video_info['video_user_id'])
|
|
{
|
|
$author = $owner;
|
|
}
|
|
elseif($user->user_exists != 0 && $user->user_info['user_id'] == $video_info['video_user_id'])
|
|
{
|
|
$author = $user;
|
|
}
|
|
|
|
// SET AUTHOR AND DIRECTORY
|
|
$video_info['video_author'] = $author;
|
|
//$video_info['video_dir'] = ".".$this->video_dir($video_info['video_user_id'], TRUE);
|
|
$video_info['video_dir'] = str_replace("./", "", $this->video_dir($video_info['video_user_id'], TRUE));
|
|
// CHECK FOR THUMBNAIL
|
|
//$video_info['video_thumb'] = file_exists(club_dir($video_info['video_club_id'])."video_".$video_info['video_id']."_thumb.jpg");
|
|
//if( $video_info['video_thumb']){
|
|
$video_info['thumbfolder']=str_replace("./", "", club_dir($video_info['video_club_id']));
|
|
$video_info['thumbfolder1']=str_replace("./", "", club_dir($video_info['video_club_id']));
|
|
//}
|
|
//echo $club->club_dir($club_id).$video_info['video_id']."_thumb.jpg";
|
|
// SET UP DURATION
|
|
$minutes = floor($video_info['video_duration_in_sec']/60);
|
|
$seconds = $video_info['video_duration_in_sec']-60*$minutes;
|
|
$video_info['video_duration_in_min'] = sprintf("%02d:%02d", $minutes, $seconds);
|
|
|
|
// SET UP RATING
|
|
$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'];
|
|
|
|
// CREATE ARRAY OF VIDEO DATA
|
|
$video_array[] = $video_info;
|
|
}
|
|
|
|
// RETURN ARRAY
|
|
return $video_array;
|
|
}
|
|
function club_video_list_all1($start, $limit, $sort_by = "video_id DESC", $club_id, $details = 0){
|
|
|
|
global $database, $user, $owner;
|
|
|
|
$club = new se_club($user->user_info['user_id'], $club_id);
|
|
// BEGIN QUERY
|
|
$video_query = "SELECT se_club_videos.*";
|
|
|
|
// GET DETAILS
|
|
if($details) { $video_query .= ", count(clubvideocomments.id) AS total_comments"; }
|
|
|
|
// IF NO USER ID SPECIFIED, RETRIEVE USER INFORMATION
|
|
if($this->user_id == 0) { $video_query .= ", se_users.user_id, se_users.user_username, se_users.user_photo, se_users.user_fname, se_users.user_lname"; }
|
|
|
|
// CONTINUE QUERY
|
|
$video_query .= " FROM se_club_videos";
|
|
|
|
// GET DETAILS
|
|
if($details) { $video_query .= " LEFT JOIN clubvideocomments ON se_club_videos.video_id=clubvideocomments.id"; }
|
|
|
|
// IF NO USER ID SPECIFIED, JOIN TO USER TABLE
|
|
if($this->user_id == 0) { $video_query .= " LEFT JOIN se_users ON se_club_videos.video_user_id=se_users.user_id"; }
|
|
//if(!$database->database_ping())
|
|
if (!is_object($database) && !$database instanceof mysqli)
|
|
{
|
|
global $database, $database_host, $database_username, $database_password, $database_name;
|
|
$database =NULL;
|
|
$database =& SEDatabase::getInstance();
|
|
|
|
|
|
}
|
|
$video_query .= " WHERE se_club_videos.video_uploaded='1' ";
|
|
|
|
// ADD WHERE IF NECESSARY
|
|
//if($where != "" || $this->user_id != 0) { }
|
|
// $video_query .= " WHERE video_club_id={$club_id} and video_admin_approved=1 ";
|
|
// ENSURE USER ID IS NOT EMPTY
|
|
//if($this->user_id != 0) { $video_query .= " video_user_id='{$this->user_id}'"; }
|
|
|
|
// INSERT AND IF NECESSARY
|
|
//if($this->user_id != 0 && $where != "") { $video_query .= " AND"; }
|
|
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
|
if($where != "") { $video_query .= "$where"; }
|
|
|
|
// ADD club BY, ORDER, AND LIMIT CLAUSE
|
|
$video_query .= " club BY video_id ORDER BY $sort_by LIMIT $start, $limit";
|
|
|
|
//echo $video_query;
|
|
// RUN QUERY
|
|
$videos = $database->database_query($video_query);
|
|
|
|
// GET VIDEOS INTO AN ARRAY
|
|
$video_array = Array();
|
|
while($video_info = $database->database_fetch_assoc($videos))
|
|
{
|
|
// IF NO USER ID SPECIFIED, CREATE OBJECT FOR AUTHOR
|
|
if($this->user_id == 0)
|
|
{
|
|
$author = new se_user();
|
|
$author->user_exists = 1;
|
|
$author->user_info['user_id'] = $video_info['user_id'];
|
|
$author->user_info['user_username'] = $video_info['user_username'];
|
|
$author->user_info['user_fname'] = $video_info['user_fname'];
|
|
$author->user_info['user_lname'] = $video_info['user_lname'];
|
|
$author->user_info['user_photo'] = $video_info['user_photo'];
|
|
$author->user_displayname();
|
|
}
|
|
|
|
// OTHERWISE, SET AUTHOR TO OWNER/LOGGED-IN USER
|
|
elseif($owner->user_exists != 0 && $owner->user_info['user_id'] == $video_info['video_user_id'])
|
|
{
|
|
$author = $owner;
|
|
}
|
|
elseif($user->user_exists != 0 && $user->user_info['user_id'] == $video_info['video_user_id'])
|
|
{
|
|
$author = $user;
|
|
}
|
|
|
|
// SET AUTHOR AND DIRECTORY
|
|
$video_info['video_author'] = $author;
|
|
//$video_info['video_dir'] = ".".$this->video_dir($video_info['video_user_id'], TRUE);
|
|
$video_info['video_dir'] = str_replace("./", "", $this->video_dir($video_info['video_user_id'], TRUE));
|
|
// CHECK FOR THUMBNAIL
|
|
$video_info['video_thumb'] = file_exists($club->club_dir($club_id)."video_".$video_info['video_id']."_thumb.jpg");
|
|
//echo $club->club_dir($club_id).$video_info['video_id']."_thumb.jpg";
|
|
// SET UP DURATION
|
|
$minutes = floor($video_info['video_duration_in_sec']/60);
|
|
$seconds = $video_info['video_duration_in_sec']-60*$minutes;
|
|
$video_info['video_duration_in_min'] = sprintf("%02d:%02d", $minutes, $seconds);
|
|
|
|
// SET UP RATING
|
|
$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'];
|
|
|
|
// CREATE ARRAY OF VIDEO DATA
|
|
$video_array[] = $video_info;
|
|
}
|
|
|
|
// RETURN ARRAY
|
|
return $video_array;
|
|
|
|
}
|
|
function club_video_list_all($start, $limit, $sort_by = "video_id DESC", $club_id, $details = 0)
|
|
{
|
|
global $database, $user, $owner;
|
|
|
|
$club = new se_club($user->user_info['user_id'], $club_id);
|
|
// BEGIN QUERY
|
|
$video_query = "SELECT se_club_videos.*";
|
|
|
|
// GET DETAILS
|
|
if($details) { $video_query .= ", count(clubvideocomments.id) AS total_comments"; }
|
|
|
|
// IF NO USER ID SPECIFIED, RETRIEVE USER INFORMATION
|
|
if($this->user_id == 0) { $video_query .= ", se_users.user_id, se_users.user_username, se_users.user_photo, se_users.user_fname, se_users.user_lname"; }
|
|
|
|
// CONTINUE QUERY
|
|
$video_query .= " FROM se_club_videos";
|
|
|
|
// GET DETAILS
|
|
if($details) { $video_query .= " LEFT JOIN clubvideocomments ON se_club_videos.video_id=clubvideocomments.id"; }
|
|
|
|
// IF NO USER ID SPECIFIED, JOIN TO USER TABLE
|
|
if($this->user_id == 0) { $video_query .= " LEFT JOIN se_users ON se_club_videos.video_user_id=se_users.user_id"; }
|
|
|
|
// ADD WHERE IF NECESSARY
|
|
//if($where != "" || $this->user_id != 0) { }
|
|
// $video_query .= " WHERE video_club_id={$club_id} and video_admin_approved=1 ";
|
|
// ENSURE USER ID IS NOT EMPTY
|
|
//if($this->user_id != 0) { $video_query .= " video_user_id='{$this->user_id}'"; }
|
|
|
|
// INSERT AND IF NECESSARY
|
|
//if($this->user_id != 0 && $where != "") { $video_query .= " AND"; }
|
|
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
|
if($where != "") { $video_query .= "WHERE $where"; }
|
|
|
|
// ADD club BY, ORDER, AND LIMIT CLAUSE
|
|
$video_query .= " club BY video_id ORDER BY $sort_by LIMIT $start, $limit";
|
|
|
|
//echo $video_query;
|
|
// RUN QUERY
|
|
$videos = $database->database_query($video_query);
|
|
|
|
// GET VIDEOS INTO AN ARRAY
|
|
$video_array = Array();
|
|
while($video_info = $database->database_fetch_assoc($videos))
|
|
{
|
|
// IF NO USER ID SPECIFIED, CREATE OBJECT FOR AUTHOR
|
|
if($this->user_id == 0)
|
|
{
|
|
$author = new se_user();
|
|
$author->user_exists = 1;
|
|
$author->user_info['user_id'] = $video_info['user_id'];
|
|
$author->user_info['user_username'] = $video_info['user_username'];
|
|
$author->user_info['user_fname'] = $video_info['user_fname'];
|
|
$author->user_info['user_lname'] = $video_info['user_lname'];
|
|
$author->user_info['user_photo'] = $video_info['user_photo'];
|
|
$author->user_displayname();
|
|
}
|
|
|
|
// OTHERWISE, SET AUTHOR TO OWNER/LOGGED-IN USER
|
|
elseif($owner->user_exists != 0 && $owner->user_info['user_id'] == $video_info['video_user_id'])
|
|
{
|
|
$author = $owner;
|
|
}
|
|
elseif($user->user_exists != 0 && $user->user_info['user_id'] == $video_info['video_user_id'])
|
|
{
|
|
$author = $user;
|
|
}
|
|
|
|
// SET AUTHOR AND DIRECTORY
|
|
$video_info['video_author'] = $author;
|
|
//$video_info['video_dir'] = ".".$this->video_dir($video_info['video_user_id'], TRUE);
|
|
$video_info['video_dir'] = str_replace("./", "", $this->video_dir($video_info['video_user_id'], TRUE));
|
|
// CHECK FOR THUMBNAIL
|
|
$video_info['video_thumb'] = file_exists($club->club_dir($club_id)."video_".$video_info['video_id']."_thumb.jpg");
|
|
//echo $club->club_dir($club_id).$video_info['video_id']."_thumb.jpg";
|
|
// SET UP DURATION
|
|
$minutes = floor($video_info['video_duration_in_sec']/60);
|
|
$seconds = $video_info['video_duration_in_sec']-60*$minutes;
|
|
$video_info['video_duration_in_min'] = sprintf("%02d:%02d", $minutes, $seconds);
|
|
|
|
// SET UP RATING
|
|
$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'];
|
|
|
|
// CREATE ARRAY OF VIDEO DATA
|
|
$video_array[] = $video_info;
|
|
}
|
|
|
|
// RETURN ARRAY
|
|
return $video_array;
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
?>
|