<?php
	
	require_once("mysqlconnect.php");
	require_once("global/functions.php");
	require_once("global/constants.php");
	session_start();
	
	$u=$_GET['u'];
	if($u<>$uhash || $_SESSION['mobile_admin_logged_in']==false)
	{
		header("location: index.php");
		die();
	}
	
	$action=$_GET['action'];
	if(!$action) 
	{
		header('location: '.$HTTP_REFERER);
		die();
	}
	
	if($action=='delete')
	{
		$id=$_GET['id'];
		if($_POST['napisane_id']<>'') $id=$_POST['napisane_id'];
		if(is_numeric($id))
		{
			$query="DELETE from mobile_video WHERE ID=$id limit 1";
			mysql_query($query, $link);
			if(mysql_affected_rows($link)>1) mysqli_rollback($link);
		}
		header('location: '.$HTTP_REFERER);
	}
	
	if($action=='delete_checked')
	{
		for($j=1;$j<=VIDEO_NASTRANU;$j++)
		{
			if($_POST['video'.$j])
			{
				$query="DELETE from mobile_video WHERE ID=".$_POST['video'.$j]." limit 1";
				mysql_query($query, $link);
				if(mysql_affected_rows($link) > 1) mysqli_rollback($link);
			}
		}
	header('location: '.$HTTP_REFERER);
	}
	
	if($action=='go')
	{
		$id=$_POST['go_id'];
		$link="video_admin.php?u=$u&i=".fnGetPage('mobile_video', $id, VIDEO_NASTRANU)."&video_id=$id";
		header("location: ".$link);
	}
?>