<?php


include("../include/config.php");
include_once("../include/functions/import.php");
include_once("../include/functions/admin.php");
verify_login_admin();
        
		
if($_REQUEST['update'] == "success")
{
	$message = "Video Successfully Deleted";
	Stemplate::assign('message',$message);
	STemplate::display("administrator/show_message.tpl");
}
elseif($_REQUEST['update'] == "success2")
{
	$message = "Report Successfully Deleted";
	Stemplate::assign('message',$message);
	STemplate::display("administrator/show_message.tpl");
}

// REMOVE BEGIN
if($_REQUEST[remove]=="true")
{
$RID = htmlentities(strip_tags($_REQUEST[RID]));
$sql="DELETE FROM videos_reports WHERE RID='".mysql_real_escape_string($RID)."'";
$conn->Execute($sql);
header("location: reportedvideos.php?update=success2");
}
// REMOVE END

// DELETE BEGIN
if($_REQUEST[delete]=="true")
{
$VIDEOID = htmlentities(strip_tags($_REQUEST[VIDEOID]));
$sql="DELETE FROM videos WHERE VIDEOID='".mysql_real_escape_string($VIDEOID)."'";
$conn->Execute($sql);
$sql="DELETE FROM videos_comments WHERE VIDEOID='".mysql_real_escape_string($VIDEOID)."'";
$conn->Execute($sql);
$sql="DELETE FROM videos_favorited WHERE VIDEOID='".mysql_real_escape_string($VIDEOID)."'";
$conn->Execute($sql);
$sql="DELETE FROM videos_reports WHERE VIDEOID='".mysql_real_escape_string($VIDEOID)."'";
$conn->Execute($sql);
header("location: reportedvideos.php?update=success");
}
// DELETE END

// SORT BEGIN
if($_REQUEST['sortby']=="reason")
{
	$sort =" order by reason";
}
elseif($_REQUEST['sortby']=="remarks")
{
	$sort =" order by remarks";
}
else
{
	$sort =" order by RID";
}

if($_REQUEST['sorthow']=="asc")
{
	$sorthow ="asc";
}
else
{
	$sorthow ="desc";
}
// SORT END

$query="SELECT * FROM videos_reports $sort $sorthow";
$executequery = $conn->Execute($query);
$total = $executequery->recordcount()+0;
$videos = $executequery->getrows();

STemplate::assign('total',$total+0);
STemplate::assign('videos',$videos);

Stemplate::assign('error',$error);
STemplate::display("administrator/reportedvideos.tpl");
?>