<?
////////////////////////////////////////////////////
// Conciliación: gestión de conciliación de activos
// Version: 1.0
//
// Copyright (C) 2014  Eustotem Multimedia, S.L.
//
// License: MIT, see LICENSE
////////////////////////////////////////////////////


// ====================================================================================
session_start();
include("../conf/preferences.php");
include("../conf/langs/".$langs[$_SESSION['userlang']][0]."/MAIN.php");
include("../conf/langs/".$langs[$_SESSION['userlang']][0]."/orphans.php");
include("../conf/connections.php");
include("../phplib/auth.php");
require_once("../phplib/utils.php");
require_once("../core/plugins.php");
// ====================================================================================

if($_REQUEST['action']=='deleteFile'){
	$yuyu=fopen("../../" . SYS_BASE_UPLOAD . $_REQUEST['file'],'w');
	fclose($yuyu);
	$yuyu=unlink("../../" . SYS_BASE_UPLOAD . $_REQUEST['file']);
	if(!yuyu){
		echo "KO";
	}else{
		echo "OK";
	}
}else if($_REQUEST['action']=='deleteAllFiles'){
	$estado="OK";
	foreach($_SESSION['sobran'] as $archivo){
		$yuyu=fopen("../../" . SYS_BASE_UPLOAD . $archivo['name'],'w');
		fclose($yuyu);
		if(!$yuyu=unlink("../../" . SYS_BASE_UPLOAD . $archivo['name'])) $estado=ADDON_OP_NOT_DELETED;
	}
	echo $estado;
}else if($_REQUEST['action']=='emptyField'){
	$cadena="UPDATE " . $_REQUEST['table'] . " SET " . $_REQUEST['field'] . "='' WHERE " . $_REQUEST['key'] . "=" . $_REQUEST['id'];
	$q=mysql_query($cadena) or die("KO");
	echo "OK";
}else if($_REQUEST['action']=='emptyAllFields'){

}

?>