<?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  = filter($_REQUEST['txtdetail']);
	 
    $sql   = "INSERT INTO contect(contdetail)
		      VALUES ('$Detail')";
		
		//die();
		dbQuery($sql);
		header('Location: index.php');	
	}

/*
	Modify a user
*/
function modifyFile()
{	
    $fileId   = $_REQUEST['hidFileId'];
	@$Detail  = filter($_REQUEST['txtdetail']);
	
   
		
	 $sql5 ="update contect set  contdetail = '$Detail' where contactid = $fileId";
		//die();
		 dbQuery($sql5);
		
		header('Location:index.php');	
}

function deleteClient()
{
	if (isset($_GET['clientId']) && (int)$_GET['clientId'] > 0) {
		$clientId = (int)$_GET['clientId'];
	} else {
		header('Location: index.php');
	}
	
	
	$sql = "DELETE FROM contect 
	        WHERE contactid = $clientId";
	dbQuery($sql);
	
	header('Location: index.php');
}

?>