<?php
include('header.php');
if (!empty($_GET['case'])) { $case = make_safe($_GET['case']);
} else {
$case = '';
}
switch ($case) {
case 'search_youtube';
if (isset($_GET['search']) AND
$_GET['search'] == 1) { } else {
$q = '';
}
if (isset($_GET['order_by'])) { $order_by = make_safe($_GET['order_by']);
} else {
$order_by = 'date';
}
if (isset($_GET['page'])) { $page = make_safe($_GET['page']);
} else {
$page = '';
}
if (isset($_GET['max_results'])) { $max_results = intval(make_safe
($_GET['max_results'])); } else {
$max_results = 12;
}
if (isset($_GET['videoCategoryId'])) { $videoCategoryId = intval(make_safe
($_GET['videoCategoryId'])); } else {
$videoCategoryId = '';
}
$baseUrl = 'https://w...content-available-to-author-only...s.com/youtube/v3/';
$apiKey = $options['api_youtube_apikey'];
$url = $baseUrl ."search?q=$q&maxResults=$max_results&order=$order_by&part=snippet&type=video";
$url .= "&pageToken=$page";
}
if (!empty($videoCategoryId)) { $url .= "&videoCategoryId=$videoCategoryId";
}
$url .= "&key=$apiKey";
if (count($json['items']) > 0) { $search_results = true;
} else {
$message = notification('warning','There are no results for the Word '.$q.' in youtube.com');
}
} else {
$message = notification('warning','Insert the Search Word Please.');
}
}
?>
<div class="page-header page-heading">
<h1 class="row"><div class="col-md-6"><i class="fa fa-search"></i> Search Youtube</div>
<div class="col-md-6">
</div>
</h1>
</div>
<div class="row">
<div class="col-md-3">
<div class="big-search-form">
<form method="GET" action="videos.php">
<input type="hidden" name="case" value="search_youtube" />
<div class="form-group">
<label>Search Word</label>
<input type="text" name="q" class="form-control" placeholder="Search in youtube.com" value="
<?php if (isset($q)) {echo urldecode($q);} ?>" />
</div>
<div class="form-group">
<label>Test</label>
<input type="text" name="test" class="form-control" placeholder="Test" value="
<?php if (isset($test)) {echo urldecode($test);} ?>" />
</div>
<div class="form-group">
<label>Results From Category</label>
<select name="videoCategoryId" class="form-control">
<option value=""
<?php if (!isset($_GET['videoCategoryId']) or
empty($_GET['videoCategoryId'])) {echo 'SELECTED';} ?>>All Categories</option>
<?php
$ycats = youtube_categories();
foreach ($ycats AS $key=>$value) {
?>
<option value="
<?php echo $key; ?>"
<?php if (isset($_GET['videoCategoryId']) AND
$_GET['videoCategoryId'] == $key) {echo 'SELECTED';} ?>>
<?php echo $value; ?></option>
<?php
}
?>
</select>
</div>
<div class="form-group">
<label>Order By</label>
<select name="order_by" class="form-control">
<option value="date"
<?php if (isset($order_by) AND
$order_by == 'date') {echo 'SELECTED';} ?>>By Date</option>
<option value="rating"
<?php if (isset($order_by) AND
$order_by == 'rating') {echo 'SELECTED';} ?>>By Rating</option>
<option value="relevance"
<?php if (isset($order_by) AND
$order_by == 'relevance') {echo 'SELECTED';} ?>>By Relevance</option>
<option value="title"
<?php if (isset($order_by) AND
$order_by == 'title') {echo 'SELECTED';} ?>>By Title</option>
<option value="viewCount"
<?php if (isset($order_by) AND
$order_by == 'viewCount') {echo 'SELECTED';} ?>>By View Count</option>
</select>
</div>
<div class="form-group">
<label>Max Results</label>
<select name="max_results" class="form-control">
<?php for($i=12;$i<49;$i=$i+6) { ?>
<option value="
<?php echo $i; ?>"
<?php if (isset($max_results) AND
$max_results == $i) {echo 'SELECTED';} ?>>
<?php echo $i; ?></option>
<?php } ?>
</select>
</div>
<button type="submit" name="search" value="1" class="btn btn-success btn-block">Search</button>
</form>
</div>
<div class="big-search-form">
<?php
$categories = $general->categories('category_order ASC');
if ($categories == 0) {
echo notification('warning','Please add at least one category to import the videos in.');
} else {
?>
<div class="form-group">
<label>Category</label>
<select name="category" id="category" class="form-control">
<?php
foreach ($categories AS $category) {
?>
<option value="<?php echo $category['id']; ?>"><?php echo $category['category']; ?></option>
<?php
}
?>
</select>
<p class="help">This is the category where the video will be saved when click <b><span class="text-danger"><i class="fa fa-refresh"></i> Import</span></b>.</p>
</div>
<?php
}
?>
</div>
</div>
<div class="col-md-9">
<?php
echo $message;
}
if (isset($search_results)) { ?>
<div class="alert alert-warning">There are (<b>
<?php echo $json['pageInfo']['totalResults']; ?></b>) Result(s) for <b>
<?php echo urldecode($q); ?></b> Query.</div>
<form role="form" method="POST" action="">
<table class="table">
<thead>
<tr>
<th><input type="checkbox" class="parentCheckBox" /></th>
<th colspan="2">Video Details</th>
<th></th>
<tr>
</thead>
<tbody>
<?php
foreach ($json['items'] AS $item) {
?>
<tr <?php if (check_youtube_id($item['id']['videoId']) != 0) { ?>class="bg-success"<?php } ?>>
<td width="15">
<?php if (check_youtube_id($item['id']['videoId']) == 0) { ?>
<input type="checkbox" name="myCheckboxes[]" class="childCheckBox" value="<?php echo $item['id']['videoId']; ?>" />
<?php } ?>
</td>
<td width="75"><a href="javascript:void();" data-toggle="ajax-modal" data-url="ajax.php?case=video_details&id=<?php echo $item['id']['videoId']; ?>"><img src="<?php echo $item['snippet']['thumbnails']['medium']['url']; ?>" width="75" /></a></td>
<td>
<div><a href="javascript:void();" data-toggle="ajax-modal" data-url="ajax.php?case=video_details&id=<?php echo $item['id']['videoId']; ?>"><b><?php echo $item['snippet']['title']; ?></b></a></div>
</td>
<td align="right">
<?php if (check_youtube_id($item['id']['videoId']) == 0) { ?>
<a href="javascript:void();" class="import-single-video btn btn-warning" id="<?php echo $item['id']['videoId']; ?>" rel="d<?php echo $item['id']['videoId']; ?>"><span class="fa fa-download"></span></a>
<?php } else { ?>
<a href="javascript:void();" class="btn btn-success"><span class="fa fa-check"></span></a>
<?php
}
?>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
<div class="videos-actions">
<div class="col-sm-2 col-md-3"><button type="submit" name="import_all" id="import_all" class="btn btn-warning"><span class="fa fa-download"></span> Import All</button></div>
<div class="col-sm-10 col-md-9 text-right">
<?php
if (isset($json['prevPageToken'])) { echo '<a class="btn btn-default" href="videos.php?case=search_youtube&q='.$q.'&order_by='.$order_by.'&max_results='.$max_results.'&search=1&page='.$json['prevPageToken'].'&videoCategoryId='.$videoCategoryId.'" style="margin-right:10px;">Previews</a>';
}
if (isset($json['nextPageToken'])) { echo '<a class="btn btn-default" href="videos.php?case=search_youtube&q='.$q.'&order_by='.$order_by.'&max_results='.$max_results.'&search=1&page='.$json['nextPageToken'].'&videoCategoryId='.$videoCategoryId.'">Next</a>';
}
?>
</div>
</form>
</div>
<?php } ?>
</div>
</div>
<?php
break;
case 'edit';
$id = abs(intval(make_safe
(xss_clean
($_GET['id'])))); if (isset($_POST['submit'])) { $category_id = make_safe(xss_clean($_POST['category_id']));
$published = make_safe
(xss_clean
(intval($_POST['published']))); $message = notification('warning','Insert The Title Please.');
} elseif (empty($details)) { $message = notification('warning','Write Some Details Please.');
} elseif (empty($category_id)) { $message = notification('warning','Choose a Category Please.');
} else {
if (!empty($_FILES['thumbnail']['name'])) { $up = new fileDir('../upload/videos/');
$thumbnail = $up->upload($_FILES['thumbnail']);
$up->delete("$_POST[old_thumbnail]");
} else {
$thumbnail = $_POST['old_thumbnail'];
}
$sql = "UPDATE videos SET title='$title',details='$details',category_id='$category_id',thumbnail='$thumbnail',tags='$tags',published='$published' WHERE id='$id'";
$query = $mysqli->query($sql);
if ($query) {
$message = notification('success','Article Edited Successfully.');
} else {
$message = notification('danger','Error Happened.');
}
}
}
$videos = $general->video($id);
?>
<div class="page-header page-heading">
<h1>Edit videos
<a href="videos.php" class="btn btn-default pull-right"><span class="fa fa-arrow-right"></span></a>
</h1>
</div>
<?php if (isset($message)) {echo $message;} ?> <form role="form" method="POST" action="" enctype="multipart/form-data">
<div class="row">
<div class="col-md-9">
<div class="form-group">
<label for="category">Title <span>*</span></label>
<input type="text" class="form-control" name="title" id="title" value="<?php echo $videos['title']; ?>" />
</div>
<div class="form-group">
<label for="details">Details</label>
<textarea class="wysiwyg form-control" name="details" id="details" rows="20">
<?php echo htmlspecialchars_decode($videos['details'],ENT_QUOTES); ?></textarea>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="category_id">Category <span>*</span></label>
<select class="form-control" name="category_id" id="category_id">
<?php
$categories = $general->categories('category_order ASC');
foreach ($categories AS $category) {
?>
<option value="<?php echo $category['id']; ?>" <?php if ($videos['category_id'] == $category['id'] AND $videos['sub_category_id'] == 0) {echo 'SELECTED';} ?>><?php echo $category['category']; ?></option>
<?php
}
?>
</select>
</div>
<div class="form-group">
<label for="category_id">Featured Image</label>
<div class="fileinput fileinput-new input-group" data-provides="fileinput">
<div class="form-control" data-trigger="fileinput"><i class="glyphicon glyphicon-file fileinput-exists"></i> <span class="fileinput-filename"></span></div>
<span class="input-group-addon btn btn-default btn-file"><span class="fileinput-new">Select file</span><span class="fileinput-exists">Change</span><input type="file" name="thumbnail"></span>
<a href="#" class="input-group-addon btn btn-default fileinput-exists" data-dismiss="fileinput">Remove</a>
</div>
<?php if (!empty($videos['thumbnail'])) { ?> <p>Current Image : <a href="javascript:void();" data-toggle="popover" data-placement="top" title="Current Image" data-content="<img src='../upload/videos/<?php echo $videos['thumbnail']; ?>' class='img-responsive' />"><?php echo $videos['thumbnail']; ?></a></p>
<?php } ?>
</div>
<div class="form-group">
<label for="tags">Tags <span>*</span></label>
<input type="text" class="form-control tags" name="tags" id="tags" value="
<?php if (isset($videos['tags'])) { echo $videos['tags']; } ?>" />
</div>
<div class="form-group">
<input type="checkbox" name="published" id="published" value="1" <?php if ($videos['published'] == 1) {echo 'CHECKED';} ?> /> <span class="checkbox-label">Publish videos ?</span>
</div>
<input type="hidden" name="old_thumbnail" value="<?php echo $videos['thumbnail']; ?>" />
<button type="submit" name="submit" class="btn btn-primary">Save</button>
</div>
</div>
</form>
<?php
break;
case 'delete';
$id = abs(intval(make_safe
(xss_clean
($_GET['id'])))); if (isset($_POST['unpublish'])) { $delete = $mysqli->query("UPDATE videos SET deleted='1' WHERE id='$id'");
$mysqli->query("DELETE FROM lists_video WHERE videos_id='$id'");
if ($delete) {
$message = notification('success','videos Item Has Been Unpublished Successfully.');
$done = true;
} else {
$message = notification('danger','Error Happened.');
}
}
if (isset($_POST['delete'])) { $sql = "SELECT * FROM videos WHERE id='$id'";
$query = $mysqli->query($sql);
if ($query->num_rows > 0) {
$row = $query->fetch_assoc();
if (!empty($row['thumbnail']) AND
file_exists('../upload/videos/'.$row['thumbnail'])) { @unlink('../upload/videos/'.$row['thumbnail']); }
}
$mysqli->query("DELETE FROM lists_video WHERE videos_id='$id'");
$delete = $mysqli->query("DELETE FROM videos WHERE id='$id'");
if ($delete) {
$message = notification('success','Video Deleted Successfully.');
$done = true;
} else {
$message = notification('danger','Error Happened.');
}
}
$videos = $general->video($id);
?>
<div class="page-header page-heading">
<h1>Delete Video
<a href="videos.php" class="btn btn-default pull-right"><span class="fa fa-arrow-right"></span></a>
</h1>
</div>
<?php if (isset($message)) {echo $message;} ?> <form role="form" method="POST" action="">
<?php if (empty($done)) { ?> <div class="alert alert-warning">You Can Either <b>Unpublish</b> or <b>Delete</b> the Video : <b>
<?php echo htmlspecialchars_decode($videos['title'],ENT_QUOTES); ?></b>. If you Choose to Delete you Can't Undo this Action Later.</div>
<?php } ?>
<?php if ($done) { ?>
<a href="videos.php" class="btn btn-default">Back To Videos</a>
<?php } else { ?>
<button type="submit" name="unpublish" class="btn btn-warning">Temporary Delete</button>
<button type="submit" name="delete" class="btn btn-danger">Permanent Delete</button>
<?php } ?>
</form>
<?php
break;
case 'search';
$q = make_safe(xss_clean($_GET['q']));
?>
<div class="page-header page-heading">
<h1 class="row"><div class="col-md-6"><i class="fa fa-search"></i> Search For <?php echo $q; ?> In Published Videos</div>
<div class="col-md-6">
<div class="pull-right search-form">
<form method="GET" action="videos.php">
<div class="input-group">
<input type="hidden" name="case" value="search" />
<input type="text" name="q" class="form-control" placeholder="Search" value="<?php echo $q; ?>" />
<span class="input-group-addon"><button class="btn-link"><span class="fa fa-search"></span></button></span>
</div>
</form>
</div>
<a href="videos.php?case=deleted" class="btn btn-danger pull-right" data-toggle="tooltip" data-placement="top" title="Deleted Videos"><span class="fa fa-trash"></span></a>
<a href="videos.php" class="btn btn-default pull-right" data-toggle="tooltip" data-placement="top" title="Published Videos"><span class="fa fa-youtube-play"></span></a>
</div>
</h1>
</div>
<?php
if (isset($message)) {echo $message;} $page = 1;
$size = 20;
if (isset($_GET['page'])){ $page = (int
) $_GET['page']; } $sqls = "SELECT * FROM videos WHERE published='1' AND deleted='0' AND title LIKE '%$q%' ORDER BY id DESC";
$query = $mysqli->query($sqls);
$total_records = $query->num_rows;
if ($total_records == 0) {
echo notification('warning','There Are No Results.');
} else {
$pagination = new Pagination();
$pagination->setLink("?case=search&page=%s&q=$q");
$pagination->setPage($page);
$pagination->setSize($size);
$pagination->setTotalRecords($total_records);
$get = "SELECT * FROM videos WHERE published='1' AND deleted='0' AND title LIKE '%$q%' ORDER BY id DESC ".$pagination->getLimitSql();
$q = $mysqli->query($get);
?>
<table class="table">
<thead>
<tr>
<th><input type="checkbox" class="parentCheckBox" /></th>
<th colspan="2">Video Details</th>
<th></th>
<tr>
</thead>
<tbody>
<?php
while ($row = $q->fetch_assoc()) {
?>
<tr>
<td width="15"><input type="checkbox" name="id[]" class="childCheckBox" value="<?php echo $row['id']; ?>" /></td>
<td width="75"><a href="javascript:void();" data-toggle="ajax-modal" data-url="ajax.php?case=video_details&id=<?php echo $row['youtube_id']; ?>"><img src="../upload/videos/<?php echo $row['thumbnail']; ?>" width="75" /></a></td>
<td>
<div><a href="javascript:void();" data-toggle="ajax-modal" data-url="ajax.php?case=video_details&id=<?php echo $row['youtube_id']; ?>"><b><?php echo $row['title']; ?></b></a></div>
<span><i class="fa fa-folder"></i><?php echo get_category($row['category_id']); ?></span>
<span><i class="fa fa-clock-o"></i><?php echo duration($row['duration']); ?></span>
</td>
<td align="right">
<a href="videos.php?case=edit&id=<?php echo $row['id']; ?>" class="btn btn-default btn-xs"><span class="fa fa-edit"></span></a>
<a href="videos.php?case=delete&id=<?php echo $row['id']; ?>" class="btn btn-danger btn-xs"><span class="fa fa-trash"></span></a>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
<div class="videos-actions">
<div class="row">
<div class="col-xs-12"><?php echo $pagination->create_links(); ?></div>
</div>
</div>
<?php
}
break;
case 'category';
$id = intval(make_safe
(xss_clean
($_GET['id']))); if (isset($_POST['delete']) AND
isset($_POST['id'])) { $ids = $_POST['id'];
for($i=0;$i<$count;$i++){
$del_id = $ids[$i];
$sql = "UPDATE videos SET deleted='1' WHERE id='$del_id'";
$res = $mysqli->query($sql);
$mysqli->query("DELETE FROM lists_video WHERE videos_id='$del_id'");
if ($res) {
$message = notification('success','The Selected videos Items Was Deleted Successfully.');
} else {
$message = notification('error','Error Happened');
}
}
}
$category = $general->category($id);
?>
<div class="page-header page-heading">
<h1><i class="fa fa-reorder"></i> Videos About <?php echo $category['category']; ?></h1>
</div>
<?php
if (isset($message)) {echo $message;} $page = 1;
$size = 20;
if (isset($_GET['page'])){ $page = (int
) $_GET['page']; } $sqls = "SELECT * FROM videos WHERE published='1' AND deleted='0' AND category_id='$id' ORDER BY id DESC";
$query = $mysqli->query($sqls);
$total_records = $query->num_rows;
if ($total_records == 0) {
echo notification('warning','There Are No Published Videos About '.$category['category'].'.');
} else {
$pagination = new Pagination();
$pagination->setLink("?case=category&id=$id&page=%s");
$pagination->setPage($page);
$pagination->setSize($size);
$pagination->setTotalRecords($total_records);
$get = "SELECT * FROM videos WHERE published='1' AND deleted='0' AND category_id='$id' ORDER BY id DESC ".$pagination->getLimitSql();
$q = $mysqli->query($get);
?>
<form role="form" method="POST" action="">
<table class="table">
<thead>
<tr>
<th><input type="checkbox" class="parentCheckBox" /></th>
<th colspan="2">Video Details</th>
<th></th>
<tr>
</thead>
<tbody>
<?php
while ($row = $q->fetch_assoc()) {
?>
<tr>
<td width="15"><input type="checkbox" name="id[]" class="childCheckBox" value="<?php echo $row['id']; ?>" /></td>
<td width="75"><a href="javascript:void();" data-toggle="ajax-modal" data-url="ajax.php?case=video_details&id=<?php echo $row['youtube_id']; ?>"><img src="../upload/videos/<?php echo $row['thumbnail']; ?>" width="75" /></a></td>
<td>
<div><a href="javascript:void();" data-toggle="ajax-modal" data-url="ajax.php?case=video_details&id=<?php echo $row['youtube_id']; ?>"><b><?php echo $row['title']; ?></b></a></div>
<span><i class="fa fa-folder"></i><?php echo get_category($row['category_id']); ?></span>
<span><i class="fa fa-clock-o"></i><?php echo duration($row['duration']); ?></span>
</td>
<td align="right">
<a href="videos.php?case=edit&id=<?php echo $row['id']; ?>" class="btn btn-default btn-xs"><span class="fa fa-edit"></span></a>
<a href="videos.php?case=delete&id=<?php echo $row['id']; ?>" class="btn btn-danger btn-xs"><span class="fa fa-trash"></span></a>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
<div class="videos-actions">
<div class="row">
<div class="col-sm-3 col-md-4">
<button type="submit" name="delete" class="btn btn-danger"><span class="fa fa-trash"></span> Delete</button>
</div>
<div class="col-sm-9 col-md-8"><?php echo $pagination->create_links(); ?></div>
</div>
</div>
</form>
<?php
}
break;
case 'channel';
$id = intval(make_safe
(xss_clean
($_GET['id']))); if (isset($_POST['delete']) AND
isset($_POST['id'])) { $ids = $_POST['id'];
for($i=0;$i<$count;$i++){
$del_id = $ids[$i];
$sql = "UPDATE videos SET deleted='1' WHERE id='$del_id'";
$res = $mysqli->query($sql);
$mysqli->query("DELETE FROM lists_video WHERE videos_id='$del_id'");
if ($res) {
$message = notification('success','The Selected Videos Was Deleted Successfully.');
} else {
$message = notification('error','Error Happened');
}
}
}
$channel = $general->channel($id);
?>
<div class="page-header page-heading">
<h1><i class="fa fa-th-large"></i> <?php if ($id == 0) { echo 'Single Videos'; } else { echo 'Imported Videos From '.$channel['title']; } ?></h1>
</div>
<?php
if (isset($message)) {echo $message;} $page = 1;
$size = 20;
if (isset($_GET['page'])){ $page = (int
) $_GET['page']; } $sqls = "SELECT * FROM videos WHERE published='1' AND deleted='0' AND channel_id='$id' ORDER BY id DESC";
$query = $mysqli->query($sqls);
$total_records = $query->num_rows;
if ($total_records == 0) {
echo notification('warning','There Are No Published Videos From '.$channel['title'].'.');
} else {
$pagination = new Pagination();
$pagination->setLink("?case=channel&id=$id&page=%s");
$pagination->setPage($page);
$pagination->setSize($size);
$pagination->setTotalRecords($total_records);
$get = "SELECT * FROM videos WHERE published='1' AND deleted='0' AND channel_id='$id' ORDER BY id DESC ".$pagination->getLimitSql();
$q = $mysqli->query($get);
?>
<form role="form" method="POST" action="">
<table class="table">
<thead>
<tr>
<th><input type="checkbox" class="parentCheckBox" /></th>
<th colspan="2">Video Details</th>
<th></th>
<tr>
</thead>
<tbody>
<?php
while ($row = $q->fetch_assoc()) {
?>
<tr>
<td width="15"><input type="checkbox" name="id[]" class="childCheckBox" value="<?php echo $row['id']; ?>" /></td>
<td width="75"><a href="javascript:void();" data-toggle="ajax-modal" data-url="ajax.php?case=video_details&id=<?php echo $row['youtube_id']; ?>"><img src="../upload/videos/<?php echo $row['thumbnail']; ?>" width="75" /></a></td>
<td>
<div><a href="javascript:void();" data-toggle="ajax-modal" data-url="ajax.php?case=video_details&id=<?php echo $row['youtube_id']; ?>"><b><?php echo $row['title']; ?></b></a></div>
<span><i class="fa fa-folder"></i><?php echo get_category($row['category_id']); ?></span>
<span><i class="fa fa-clock-o"></i><?php echo duration($row['duration']); ?></span>
</td>
<td align="right">
<a href="videos.php?case=edit&id=<?php echo $row['id']; ?>" class="btn btn-default btn-xs"><span class="fa fa-edit"></span></a>
<a href="videos.php?case=delete&id=<?php echo $row['id']; ?>" class="btn btn-danger btn-xs"><span class="fa fa-trash"></span></a>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
<div class="videos-actions">
<div class="row">
<div class="col-sm-3 col-md-4">
<button type="submit" name="delete" class="btn btn-danger"><span class="fa fa-trash"></span> Delete</button>
</div>
<div class="col-sm-9 col-md-8"><?php echo $pagination->create_links(); ?></div>
</div>
</div>
</form>
<?php
}
break;
case 'awaiting_review';
if (isset($_POST['delete']) AND
isset($_POST['id'])) { $ids = $_POST['id'];
for($i=0;$i<$count;$i++){
$del_id = $ids[$i];
$sql = "UPDATE videos SET deleted='1' WHERE id='$del_id'";
$res = $mysqli->query($sql);
if ($res) {
$message = notification('success','The Selected videos Items Was Deleted Successfully.');
} else {
$message = notification('error','Error Happened');
}
}
}
if (isset($_POST['publish']) AND
isset($_POST['id'])) { $ids = $_POST['id'];
for($i=0;$i<$count;$i++){
$del_id = $ids[$i];
$sql = "UPDATE videos SET published='1' WHERE id='$del_id'";
$res = $mysqli->query($sql);
if ($res) {
$message = notification('success','The Selected videos Items Was Published Successfully.');
} else {
$message = notification('error','Error Happened');
}
}
}
?>
<div class="page-header page-heading">
<h1><i class="fa fa-reorder"></i> Awaiting Review Videos</h1>
</div>
<?php
if (isset($message)) {echo $message;} $page = 1;
$size = 20;
if (isset($_GET['page'])){ $page = (int
) $_GET['page']; } $sqls = "SELECT * FROM videos WHERE published='0' AND deleted='0' ORDER BY id DESC";
$query = $mysqli->query($sqls);
$total_records = $query->num_rows;
if ($total_records == 0) {
echo notification('warning','There Are No Videos awaiting for review');
} else {
$pagination = new Pagination();
$pagination->setLink("?case=awaiting_review&page=%s");
$pagination->setPage($page);
$pagination->setSize($size);
$pagination->setTotalRecords($total_records);
$get = "SELECT * FROM videos WHERE published='0' AND deleted='0' ORDER BY id DESC ".$pagination->getLimitSql();
$q = $mysqli->query($get);
?>
<form role="form" method="POST" action="">
<table class="table">
<thead>
<tr>
<th><input type="checkbox" class="parentCheckBox" /></th>
<th colspan="2">Video Details</th>
<th></th>
<tr>
</thead>
<tbody>
<?php
while ($row = $q->fetch_assoc()) {
?>
<tr>
<td width="15"><input type="checkbox" name="id[]" class="childCheckBox" value="<?php echo $row['id']; ?>" /></td>
<td width="75"><a href="javascript:void();" data-toggle="ajax-modal" data-url="ajax.php?case=video_details&id=<?php echo $row['youtube_id']; ?>"><img src="../upload/videos/<?php echo $row['thumbnail']; ?>" width="75" /></a></td>
<td>
<div><a href="javascript:void();" data-toggle="ajax-modal" data-url="ajax.php?case=video_details&id=<?php echo $row['youtube_id']; ?>"><b><?php echo $row['title']; ?></b></a></div>
<span><i class="fa fa-folder"></i><?php echo get_category($row['category_id']); ?></span>
<span><i class="fa fa-clock-o"></i><?php echo duration($row['duration']); ?></span>
</td>
<td align="right">
<a href="videos.php?case=edit&id=<?php echo $row['id']; ?>" class="btn btn-default btn-xs"><span class="fa fa-edit"></span></a>
<a href="videos.php?case=delete&id=<?php echo $row['id']; ?>" class="btn btn-danger btn-xs"><span class="fa fa-trash"></span></a>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
<div class="videos-actions">
<div class="row">
<div class="col-sm-3 col-md-4">
<button type="submit" name="publish" class="btn btn-success"><span class="fa fa-check"></span> Publish</button>
<button type="submit" name="delete" class="btn btn-danger"><span class="fa fa-trash"></span> Delete</button>
</div>
<div class="col-sm-9 col-md-8"><?php echo $pagination->create_links(); ?></div>
</div>
</div>
</form>
<?php
}
break;
case 'deleted_videos';
if (isset($_POST['restore']) AND
isset($_POST['id'])) { $ids = $_POST['id'];
for($i=0;$i<$count;$i++){
$del_id = $ids[$i];
$sql = "UPDATE videos SET deleted='0' AND published='1' WHERE id='$del_id'";
$res = $mysqli->query($sql);
if ($res) {
$message = notification('success','The Selected videos Items Was Restored Successfully.');
} else {
$message = notification('error','Error Happened');
}
}
}
if (isset($_POST['delete']) AND
isset($_POST['id'])) { $ids = $_POST['id'];
for($i=0;$i<$count;$i++){
$del_id = $ids[$i];
$sql = "SELECT * FROM videos WHERE id='$del_id'";
$query = $mysqli->query($sql);
$row = $query->fetch_assoc();
if (!empty($row['thumbnail']) AND
file_exists('../upload/videos/'.$row['thumbnail'])) { @unlink('../upload/videos/'.$row['thumbnail']); }
$mysqli->query("DELETE FROM lists_video WHERE videos_id='$row[id]'");
$delete = $mysqli->query("DELETE FROM videos WHERE id='$row[id]'");
}
if ($delete) {
$message = notification('success','Video Deleted Successfully.');
} else {
$message = notification('danger','Error Happened.');
}
}
?>
<div class="page-header page-heading">
<h1><i class="fa fa-trash"></i> Deleted Videos</h1>
</div>
<?php
if (isset($message)) {echo $message;} $page = 1;
$size = 20;
if (isset($_GET['page'])){ $page = (int
) $_GET['page']; } $sqls = "SELECT * FROM videos WHERE deleted='1' ORDER BY id DESC";
$query = $mysqli->query($sqls);
$total_records = $query->num_rows;
if ($total_records == 0) {
echo notification('warning','There Are No Deleted Videos.');
} else {
$pagination = new Pagination();
$pagination->setLink("?case=deleted_videos&page=%s");
$pagination->setPage($page);
$pagination->setSize($size);
$pagination->setTotalRecords($total_records);
$get = "SELECT * FROM videos WHERE deleted='1' ORDER BY id DESC ".$pagination->getLimitSql();
$q = $mysqli->query($get);
?>
<form role="form" method="POST" action="">
<table class="table">
<thead>
<tr>
<th><input type="checkbox" class="parentCheckBox" /></th>
<th colspan="2">Video Details</th>
<th></th>
<tr>
</thead>
<tbody>
<?php
while ($row = $q->fetch_assoc()) {
?>
<tr>
<td width="15"><input type="checkbox" name="id[]" class="childCheckBox" value="<?php echo $row['id']; ?>" /></td>
<td width="75"><a href="javascript:void();" data-toggle="ajax-modal" data-url="ajax.php?case=video_details&id=<?php echo $row['youtube_id']; ?>"><img src="../upload/videos/<?php echo $row['thumbnail']; ?>" width="75" /></a></td>
<td>
<div><a href="javascript:void();" data-toggle="ajax-modal" data-url="ajax.php?case=video_details&id=<?php echo $row['youtube_id']; ?>"><b><?php echo $row['title']; ?></b></a></div>
<span><i class="fa fa-folder"></i><?php echo get_category($row['category_id']); ?></span>
<span><i class="fa fa-clock-o"></i><?php echo duration($row['duration']); ?></span>
</td>
<td align="right">
<a href="videos.php?case=edit&id=<?php echo $row['id']; ?>" class="btn btn-default btn-xs"><span class="fa fa-edit"></span></a>
<a href="videos.php?case=delete&id=<?php echo $row['id']; ?>" class="btn btn-danger btn-xs"><span class="fa fa-trash"></span></a>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
<div class="videos-actions">
<div class="row">
<div class="col-sm-3 col-md-4">
<button type="submit" name="restore" class="btn btn-success"><span class="fa fa-check"></span> Restore</button>
<button type="submit" name="delete" class="btn btn-danger"><span class="fa fa-trash"></span> Permanent Delete</button>
</div>
<div class="col-sm-9 col-md-8"><?php echo $pagination->create_links(); ?></div>
</div>
</div>
</form>
<?php
}
break;
case 'review';
if (isset($_POST['publish']) AND
isset($_POST['id'])) { $ids = $_POST['id'];
for($i=0;$i<$count;$i++){
$del_id = $ids[$i];
$sql = "UPDATE videos SET deleted='0' AND published='1' WHERE id='$del_id'";
$res = $mysqli->query($sql);
if ($res) {
$message = notification('success','The Selected videos Items Was Published Successfully.');
} else {
$message = notification('error','Error Happened');
}
}
}
if (isset($_POST['delete']) AND
isset($_POST['id'])) { $ids = $_POST['id'];
for($i=0;$i<$count;$i++){
$del_id = $ids[$i];
$sql = "SELECT * FROM videos WHERE id='$del_id'";
$query = $mysqli->query($sql);
$row = $query->fetch_assoc();
if (!empty($row['thumbnail']) AND
file_exists('../upload/videos/'.$row['thumbnail'])) { @unlink('../upload/videos/'.$row['thumbnail']); }
$mysqli->query("DELETE FROM lists_video WHERE videos_id='$row[id]'");
$delete = $mysqli->query("DELETE FROM videos WHERE id='$row[id]'");
}
if ($delete) {
$message = notification('success','Video Deleted Successfully.');
} else {
$message = notification('danger','Error Happened.');
}
}
?>
<div class="page-header page-heading">
<h1><i class="fa fa-trash"></i> Need Review Videos</h1>
</div>
<?php
if (isset($message)) {echo $message;} $page = 1;
$size = 20;
if (isset($_GET['page'])){ $page = (int
) $_GET['page']; } $sqls = "SELECT * FROM videos WHERE deleted='0' AND published='0' ORDER BY id DESC";
$query = $mysqli->query($sqls);
$total_records = $query->num_rows;
if ($total_records == 0) {
echo notification('warning','There Are No Videos Need Review.');
} else {
$pagination = new Pagination();
$pagination->setLink("?case=deleted_videos&page=%s");
$pagination->setPage($page);
$pagination->setSize($size);
$pagination->setTotalRecords($total_records);
$get = "SELECT * FROM videos WHERE deleted='0' AND published='0' ORDER BY id DESC ".$pagination->getLimitSql();
$q = $mysqli->query($get);
?>
<form role="form" method="POST" action="">
<table class="table">
<thead>
<tr>
<th><input type="checkbox" class="parentCheckBox" /></th>
<th colspan="2">Video Details</th>
<th></th>
<tr>
</thead>
<tbody>
<?php
while ($row = $q->fetch_assoc()) {
?>
<tr>
<td width="15"><input type="checkbox" name="id[]" class="childCheckBox" value="<?php echo $row['id']; ?>" /></td>
<td width="75"><a href="javascript:void();" data-toggle="ajax-modal" data-url="ajax.php?case=video_details&id=<?php echo $row['youtube_id']; ?>"><img src="../upload/videos/<?php echo $row['thumbnail']; ?>" width="75" /></a></td>
<td>
<div><a href="javascript:void();" data-toggle="ajax-modal" data-url="ajax.php?case=video_details&id=<?php echo $row['youtube_id']; ?>"><b><?php echo $row['title']; ?></b></a></div>
<span><i class="fa fa-folder"></i><?php echo get_category($row['category_id']); ?></span>
<span><i class="fa fa-clock-o"></i><?php echo duration($row['duration']); ?></span>
</td>
<td align="right">
<a href="videos.php?case=edit&id=<?php echo $row['id']; ?>" class="btn btn-default btn-xs"><span class="fa fa-edit"></span></a>
<a href="videos.php?case=delete&id=<?php echo $row['id']; ?>" class="btn btn-danger btn-xs"><span class="fa fa-trash"></span></a>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
<div class="videos-actions">
<div class="row">
<div class="col-sm-3 col-md-4">
<button type="submit" name="publish" class="btn btn-success"><span class="fa fa-check"></span> Publish</button>
<button type="submit" name="delete" class="btn btn-danger"><span class="fa fa-trash"></span> Permanent Delete</button>
</div>
<div class="col-sm-9 col-md-8"><?php echo $pagination->create_links(); ?></div>
</div>
</div>
</form>
<?php
}
break;
default;
if (isset($_POST['delete']) AND
isset($_POST['id'])) { $ids = $_POST['id'];
for($i=0;$i<$count;$i++){
$del_id = $ids[$i];
$delete = $mysqli->query("UPDATE videos SET deleted='1' WHERE id='$del_id'");
$mysqli->query("DELETE FROM lists_video WHERE videos_id='$del_id'");
if ($delete) {
$message = notification('success','The Selected videos Items Were Assigned as Deleted.');
} else {
$message = notification('error','Error Happened');
}
}
}
?>
<div class="page-header page-heading">
<h1 class="row"><div class="col-md-6"><i class="fa fa-youtube-play"></i> Published Videos</div>
<div class="col-md-6">
<div class="pull-right search-form">
<form method="GET" action="videos.php">
<div class="input-group">
<input type="hidden" name="case" value="search" />
<input type="text" name="q" class="form-control" placeholder="Search">
<span class="input-group-addon"><button class="btn-link"><span class="fa fa-search"></span></button></span>
</div>
</form>
</div>
<a href="videos.php?case=deleted_videos" class="btn btn-danger pull-right" data-toggle="tooltip" data-placement="top" title="Deleted Videos"><span class="fa fa-trash"></span></a>
<a href="videos.php?case=review" class="btn btn-default pull-right" data-toggle="tooltip" data-placement="top" title="Need Review Videos"><span class="fa fa-edit"></span></a>
<a href="videos.php?case=search_youtube" class="btn btn-default pull-right" data-toggle="tooltip" data-placement="top" title="Search in YouTube"><span class="fa fa-youtube"></span></a>
</div>
</h1>
</div>
<?php
if (isset($message)) {echo $message;} $page = 1;
$size = 20;
if (isset($_GET['page'])){ $page = (int
) $_GET['page']; } $sqls = "SELECT * FROM videos WHERE published='1' AND deleted='0' ORDER BY id DESC";
$query = $mysqli->query($sqls);
$total_records = $query->num_rows;
if ($total_records == 0) {
echo notification('warning','There Are No Published Videos.');
} else {
$pagination = new Pagination();
$pagination->setLink("?page=%s");
$pagination->setPage($page);
$pagination->setSize($size);
$pagination->setTotalRecords($total_records);
$get = "SELECT * FROM videos WHERE published='1' AND deleted='0' ORDER BY id DESC ".$pagination->getLimitSql();
$q = $mysqli->query($get);
?>
<form role="form" method="POST" action="">
<table class="table">
<thead>
<tr>
<th><input type="checkbox" class="parentCheckBox" /></th>
<th colspan="2">Video Details</th>
<th></th>
<tr>
</thead>
<tbody>
<?php
while ($row = $q->fetch_assoc()) {
?>
<tr>
<td width="15"><input type="checkbox" name="id[]" class="childCheckBox" value="<?php echo $row['id']; ?>" /></td>
<td width="75"><a href="javascript:void();" data-toggle="ajax-modal" data-url="ajax.php?case=video_details&id=<?php echo $row['youtube_id']; ?>"><img src="../upload/videos/<?php echo $row['thumbnail']; ?>" width="75" /></a></td>
<td>
<div><a href="javascript:void();" data-toggle="ajax-modal" data-url="ajax.php?case=video_details&id=<?php echo $row['youtube_id']; ?>"><b><?php echo $row['title']; ?></b></a></div>
<span><i class="fa fa-folder"></i><?php echo get_category($row['category_id']); ?></span>
<span><i class="fa fa-clock-o"></i><?php echo duration($row['duration']); ?></span>
</td>
<td align="right">
<a href="videos.php?case=edit&id=<?php echo $row['id']; ?>" class="btn btn-default btn-xs"><span class="fa fa-edit"></span></a>
<a href="videos.php?case=delete&id=<?php echo $row['id']; ?>" class="btn btn-danger btn-xs"><span class="fa fa-trash"></span></a>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
<div class="videos-actions">
<div class="row">
<div class="col-sm-2 col-md-3"><button type="submit" name="delete" class="btn btn-danger"><span class="fa fa-trash"></span> Delete</button></div>
<div class="col-sm-10 col-md-9"><?php echo $pagination->create_links(); ?></div>
</div>
</div>
</form>
<?php
}
}
include('footer.php');
?>