157 lines
5.7 KiB
PHP
157 lines
5.7 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
/* $Id: admin_viewvideos.php 13 2009-01-11 06:04:29Z john $ */
|
||
|
|
|
||
|
|
$page = "admin_viewvideos";
|
||
|
|
include "admin_header.php";
|
||
|
|
|
||
|
|
if(isset($_POST['s'])) { $s = $_POST['s']; } elseif(isset($_GET['s'])) { $s = $_GET['s']; } else { $s = "id"; }
|
||
|
|
if(isset($_POST['p'])) { $p = $_POST['p']; } elseif(isset($_GET['p'])) { $p = $_GET['p']; } else { $p = 1; }
|
||
|
|
if(isset($_POST['f_title'])) { $f_title = $_POST['f_title']; } elseif(isset($_GET['f_title'])) { $f_title = $_GET['f_title']; } else { $f_title = ""; }
|
||
|
|
if(isset($_POST['f_owner'])) { $f_owner = $_POST['f_owner']; } elseif(isset($_GET['f_owner'])) { $f_owner = $_GET['f_owner']; } else { $f_owner = ""; }
|
||
|
|
if(isset($_POST['task'])) { $task = $_POST['task']; } elseif(isset($_GET['task'])) { $task = $_GET['task']; } else { $task = "main"; }
|
||
|
|
if(isset($_POST['video_id'])) { $video_id = $_POST['video_id']; } elseif(isset($_GET['video_id'])) { $video_id = $_GET['video_id']; } else { $video_id = 0; }
|
||
|
|
|
||
|
|
// CREATE VIDEO OBJECT
|
||
|
|
$videos_per_page = 100;
|
||
|
|
$video = new se_video();
|
||
|
|
|
||
|
|
// APPROVE VIDEO
|
||
|
|
if($task == 'approvevideo') :
|
||
|
|
$video_to_approve = new se_video(NULL, $video_id);
|
||
|
|
$query = "UPDATE se_videos SET video_admin_approved = 1 WHERE video_id='$video_id'";
|
||
|
|
$database->database_query($query);
|
||
|
|
|
||
|
|
$actions = new se_actions();
|
||
|
|
|
||
|
|
#lifted straight from functions_video.php
|
||
|
|
$video_info = $database->database_fetch_assoc($database->database_query("SELECT user_id, user_username, user_fname, user_lname, user_privacy, video_id, video_title FROM se_videos LEFT JOIN se_users ON se_videos.video_user_id=se_users.user_id WHERE se_videos.video_id='".htmlspecialchars(strip_tags($video_id))."' LIMIT 1"));
|
||
|
|
$author = new se_user();
|
||
|
|
$author->user_exists = 1;
|
||
|
|
$author->user_info['user_id'] = $video_info['user_id'];
|
||
|
|
$author->user_info['user_email'] = $video_info['user_email'];
|
||
|
|
$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_privacy'] = $video_info['user_privacy'];
|
||
|
|
$author->user_displayname();
|
||
|
|
$action_media = array();
|
||
|
|
$thumb_path = str_replace('./', '../', $video_to_approve->video_dir($video_info['user_id']).$video_info['video_id']."_thumb.jpg");
|
||
|
|
|
||
|
|
$media_link = str_replace($url->url_base, '', $url->url_create('video', $author->user_info['user_username'], $video_info['video_id']));
|
||
|
|
if( file_exists($thumb_path) )
|
||
|
|
{
|
||
|
|
$misc = new se_misc();
|
||
|
|
$media_width = $misc->photo_size($thumb_path, "100", "100", "w");
|
||
|
|
$media_height = $misc->photo_size($thumb_path, "100", "100", "h");
|
||
|
|
$thumb_path = str_replace('../', '/', $thumb_path);
|
||
|
|
$action_media[] = array(
|
||
|
|
'media_link' => $media_link,
|
||
|
|
'media_path' => $thumb_path,
|
||
|
|
'media_width' => $media_width,
|
||
|
|
'media_height' => $media_height
|
||
|
|
);
|
||
|
|
}
|
||
|
|
$actions->actions_add($author, "newvideo", array($author->user_info['user_username'], $author->user_displayname, $video_info['video_id'], $video_info['video_title']), $action_media, 0, false, "user", $author->user_info['user_id'], $author->user_info['user_privacy']);
|
||
|
|
endif;
|
||
|
|
|
||
|
|
|
||
|
|
// UN-APPROVE VIDEO
|
||
|
|
if($task == 'unapprovevideo') :
|
||
|
|
$query = "UPDATE se_videos SET video_admin_approved = 0 WHERE video_id='$video_id'";
|
||
|
|
$database->database_query($query);
|
||
|
|
endif;
|
||
|
|
|
||
|
|
// DELETE VIDEO
|
||
|
|
if($task == "deletevideo") {
|
||
|
|
if($database->database_num_rows($database->database_query("SELECT video_id FROM se_videos WHERE video_id='$video_id'")) == 1) {
|
||
|
|
$video->video_delete($video_id);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
// SET VIDEO SORT-BY VARIABLES FOR HEADING LINKS
|
||
|
|
$i = "id"; // VIDEO_ID
|
||
|
|
$t = "t"; // VIDEO_TITLE
|
||
|
|
$u = "u"; // OWNER OF VIDEO
|
||
|
|
|
||
|
|
// SET SORT VARIABLE FOR DATABASE QUERY
|
||
|
|
if($s == "i") {
|
||
|
|
$sort = "se_videos.video_id";
|
||
|
|
$i = "id";
|
||
|
|
} elseif($s == "id") {
|
||
|
|
$sort = "se_videos.video_id DESC";
|
||
|
|
$i = "i";
|
||
|
|
} elseif($s == "t") {
|
||
|
|
$sort = "se_videos.video_title";
|
||
|
|
$t = "td";
|
||
|
|
} elseif($s == "td") {
|
||
|
|
$sort = "se_videos.video_title DESC";
|
||
|
|
$t = "t";
|
||
|
|
} elseif($s == "u") {
|
||
|
|
$sort = "user_username";
|
||
|
|
$u = "ud";
|
||
|
|
} elseif($s == "ud") {
|
||
|
|
$sort = "user_username DESC";
|
||
|
|
$u = "u";
|
||
|
|
}
|
||
|
|
elseif($s == "notuploaded") {
|
||
|
|
$sort = "se_videos.video_uploaded ASC";
|
||
|
|
$u = "u";
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
$sort = "se_videos.video_id DESC";
|
||
|
|
$i = "i";
|
||
|
|
}
|
||
|
|
|
||
|
|
# @jdw sort first by unapproved videos
|
||
|
|
$sort = 'se_videos.video_admin_approved DESC, ' . $sort;
|
||
|
|
|
||
|
|
|
||
|
|
// ADD CRITERIA FOR FILTER
|
||
|
|
$where_clause = Array();
|
||
|
|
if($f_owner != "") { $where_clause[] = "(se_users.user_username LIKE '%$f_owner%' OR CONCAT(se_users.user_fname, ' ', se_users.user_lname) LIKE '%$f_owner%')"; }
|
||
|
|
if($f_title != "") { $where_clause[] = " se_videos.video_title LIKE '%$f_title%'"; }
|
||
|
|
if(count($where_clause) != 0) { $where = "(".implode(" AND ", $where_clause).")"; }
|
||
|
|
|
||
|
|
|
||
|
|
// DELETE NECESSARY VIDEOS
|
||
|
|
$start = ($p - 1) * $videos_per_page;
|
||
|
|
if($task == "delete") { $video->video_delete_selected($start, $videos_per_page, $sort, $where); }
|
||
|
|
|
||
|
|
// GET TOTAL VIDEOS
|
||
|
|
$total_videos = $video->video_total($where);
|
||
|
|
|
||
|
|
// MAKE VIDEO PAGES
|
||
|
|
$page_vars = make_page($total_videos, $videos_per_page, $p);
|
||
|
|
$page_array = Array();
|
||
|
|
for($x=0;$x<=$page_vars[2]-1;$x++) {
|
||
|
|
if($x+1 == $page_vars[1]) { $link = "1"; } else { $link = "0"; }
|
||
|
|
$page_array[$x] = Array('page' => $x+1,
|
||
|
|
'link' => $link);
|
||
|
|
}
|
||
|
|
|
||
|
|
// GET VIDEO ARRAY
|
||
|
|
$videos = $video->video_list($page_vars[0], $videos_per_page, $sort, $where);
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// ASSIGN VARIABLES AND SHOW VIEW VIDEOS PAGE
|
||
|
|
$smarty->assign('total_videos', $total_videos);
|
||
|
|
$smarty->assign('pages', $page_array);
|
||
|
|
$smarty->assign('videos', $videos);
|
||
|
|
$smarty->assign('f_title', $f_title);
|
||
|
|
$smarty->assign('f_owner', $f_owner);
|
||
|
|
$smarty->assign('i', $i);
|
||
|
|
$smarty->assign('t', $t);
|
||
|
|
$smarty->assign('u', $u);
|
||
|
|
$smarty->assign('f', $f);
|
||
|
|
$smarty->assign('su', $su);
|
||
|
|
$smarty->assign('p', $page_vars[1]);
|
||
|
|
$smarty->assign('s', $s);
|
||
|
|
include "admin_footer.php";
|
||
|
|
?>
|