<?php

require_once '../library/config.php';
require_once '../library/functions.php';

checkUser();

$action = isset($_GET['action']) ? $_GET['action'] : '';

switch ($action) {
	
	case 'add' :
		addFile();
		break;
		
	case 'modify' :
		modifyFile();
		break;
		
	case 'delete' :
		deleteClient();
		break;
  case 'deleteimg' :
		deleteImage();
		break;
   case 'deleteimg1' :
		deleteImage1();
		break;		
	case 'deleteimg2' :
		deleteImage2();
		break;			
	default :
	    // if action is not defined or unknown
		// move to main user page
		header('Location: index.php');
}


function addFile()
{	
	@$detail   = $_REQUEST["txtdetail"];
	 
    $sql   = "INSERT INTO home_txt(Hdetail)
		      VALUES ('$detail')";
		
		//die();
		dbQuery($sql);
		header('Location: index.php');	
	}

/*
	Modify a user
*/
function modifyFile()
{	
    $fileId   = $_REQUEST['hidFileId'];
	@$detail   = $_REQUEST["txtdetail"];

   
 		
	 $sql5 ="update home_txt set  Hdetail = '$detail' where Hid = $fileId";
		//die();
		 dbQuery($sql5);
		
		header('Location:index.php');	
}
/*
	Remove a user
*/
function deleteClient()
{
	if (isset($_GET['clientId']) && (int)$_GET['clientId'] > 0) {
		$clientId = (int)$_GET['clientId'];
	} else {
		header('Location: index.php');
	}
	
	
	$sql = "DELETE FROM home_txt 
	        WHERE Hid = $clientId";
	dbQuery($sql);
	
	header('Location: index.php');
}

?>