<?php
if(count(get_included_files()) ==1) exit("Direct access not permitted.");
if(isset($_POST['ikdata'])){
header("Content-type: application/json");	
	$data=$_POST['ikdata'];
	$fungsi = strip_tags(stripslashes($data[0]));
	$ex=$fungsi($data);
	if($ex){
		echo $ex;
	}else{
		echo false;
	}
}else{
	echo false;
}

function exportxls($data){
	$db=pDatabase::getInstance();
	if (!isset($_SESSION)) session_start();
	if($_SESSION['dataekspor']){
		unset($_SESSION['dataekspor']);
	}
	if($_SESSION['kolomekspor']){
		unset($_SESSION['kolomekspor']);
	}
	$token=$db->gentoken(16);
	
	if(isset($data[1])){
		$_SESSION['dataekspor'][$token]=$data[1];
	}
	$size = (int) $_SERVER['CONTENT_LENGTH'];
	//error_log("size $size data ".sizeof($data[1])." length ".strlen(json_encode($data[1])));
	if(isset($data[2])){
		$_SESSION['kolomekspor'][$token]=$data[2];
	}
	
	return "{\"token\":\"".$token."\"}";
}

function hapustoken($data){
	if (!isset($_SESSION)) session_start();
	if(isset($_SESSION['dataekspor'][$data[1]])){
		unset($_SESSION['dataekspor'][$data[1]]);
	}
	
	if(isset($_SESSION['kolomekspor'][$data[1]])){
		unset($_SESSION['kolomekspor'][$data[1]]);
	}
	return 1;
}
?>