<?php
/**
* Immo Manager verhuur op jaarbasis
*
*/

/**
* Veiligheid controle ...
*/

define('dArKCMS', true);

/**
* Includes ophalen ...
*/

include($_SERVER['DOCUMENT_ROOT']."/CMS/includes/_darkcmsConfiguratie.php"); 
include($_SERVER['DOCUMENT_ROOT']."/CMS/includes/class.sessieBeheer.php");
include($_SERVER['DOCUMENT_ROOT']."/CMS/includes/_darkcmsCore.php");

include($_SERVER['DOCUMENT_ROOT']."/CMS/modules/mod_FileUpload/includes/_modFunkties.php");
include($_SERVER['DOCUMENT_ROOT']."/CMS/modules/mod_FileUpload/includes/class.upload.php");


/**
* Taal ophalen ...
*/

$CoreTaal	= strtoupper($_GET['tl']); if ($CoreTaal == ''){$CoreTaal = 'NL';}

if (($CoreTaal != 'NL') && ($CoreTaal != 'FR')){ 
	$CoreTaal = 'NL'; 
}

/**
* CoreTaal ophalen ...
*/

include("../../talen/_core".$CoreTaal.".php");

/**
* Module Taal ophalen ...
*/

include("talen/_modTaal".$CoreTaal.".php");

/**
* Diverse akties gaan uitvoeren ...
*/

switch ($_GET['a']){

	case "logUit" :
		$session->uitloggen();
	break;

}	

/**
 * Gebruiker is ingelogd ...
 */

if($session->checkLogin()){
	
	switch ($_GET['a']){

	case "BestandOpslaan" :
			
			$Type = ($_GET['t']);
											
			$handle = new upload($_FILES['image_field'], 'nl_NL');
			if ($handle->uploaded) 
			{
				$handle->allowed 			  = array ('application/pdf');
				$handle->mime_check			  = true;
//				$handle->file_name_body_add	  = '_'.date ('dmY');
				$handle->file_overwrite           = true;
				$handle->auto_create_dir 	  = true;
				$handle->dir_chmod 	  		  = 0777;
				$handle->file_auto_rename 	  = false;
				
				$handle->process('/home/hetkompa/public_html/CMS/menus/', 'nl_NL');
				if ($handle->processed) 
				{
				 $naam = $handle->file_dst_name;
				$dbconnect	= mysql_connect (DBhost,DBgebruiker,DBwachtwoord) or die ("Kan niet verbinden: " . mysql_error());
				$dbselect 	= mysql_select_db (DBnaam,$dbconnect);

				$SQL = ("INSERT INTO mod_FileUpload SET BestandsNaam = '".$naam."', Type='".$Type."'");
				$sql_result = mysql_query ($SQL);

				mysql_close($dbconnect);
				$handle->clean();
	
				} else {
				echo 'error : ' . $handle->error;
				}
				header("Location: index.php?tl=".$CoreTaal);
			}

		break;

	
	case "wisFile" :
		
		$FileId	= $_GET['id'];
		$dbconnect	= mysql_connect (DBhost,DBgebruiker,DBwachtwoord) or die ("Kan niet verbinden: " . mysql_error());
		$dbselect 	= mysql_select_db (DBnaam,$dbconnect);
		
		$SQL = ("SELECT * FROM mod_FileUpload WHERE id='".$FileId."'");
		$sql_result = mysql_query ($SQL);
		
		$SQL = ("DELETE FROM mod_FileUpload WHERE id='".$FileId."'");
		$sql_result = mysql_query ($SQL);
		mysql_close($dbconnect);
		header("Location: index.php?tl=".$CoreTaal);
		
	break;
	
	case "Publiceer" :
			
		$id = $_GET['id'];
		$dbconnect	= mysql_connect (DBhost,DBgebruiker,DBwachtwoord) or die ("Kan niet verbinden: " . mysql_error());
		$dbselect 	= mysql_select_db (DBnaam,$dbconnect);
		$SQL = ("SELECT * FROM mod_FileUpload WHERE id='".$id."'");
		$sql_result	= mysql_query($SQL);

		while ($row=mysql_fetch_array ($sql_result)) {  

			if ($row['Publiceren']=='1'){ $tmpVar='0'; } else { $tmpVar='1'; }
			$SQL2 = "UPDATE mod_FileUpload SET Publiceren=$tmpVar WHERE id=$id";
			$result = mysql_query ($SQL2) OR DIE(mysql_error());	

		}

		mysql_close($dbconnect);
		header("Location: index.php?tl=".$CoreTaal);
	 	
 	break;
 	
 	default :
		
		include('includes/_modHeader.php');
		coreGebruikerStats($CoreTaal);
		coreModules (1,$CoreTaal);
		Overzicht();
		echo '</div>';
		include('../../includes/_darkcmsFooter.php');
	}	
	

/**
 * Gebruiker is NIET ingelogd ...
 */

} else {
	header("Location: ".CORE_Path."index.php");
}

?>