<?php
if(count(get_included_files()) ==1) exit("Direct access not permitted.");
header("Content-type: application/json");
if(isset($_POST['ikdata'])){
	if (!isset($_SESSION)) session_start();
	$db=pDatabase::getInstance();
	$datafungsi=[
		"getPopup"=>"getPopup"
	];
	
	$data=$_POST['ikdata'];
	$ex=false;
	if(isset($datafungsi[$data[0]])) $ex=$datafungsi[$data[0]]($data,$cl);
	echo $ex;
}

function getPopup($data){
	$db=pDatabase::getInstance();
	$_SESSION['popup']=1;
	$query="select t1.id,t1.nama,t1.idgambar,
			t1.tautan,
			t2.nama_baru,t2.ukuran,
			t2.folder 
		from tb_popup as t1
		inner join tb_dokumen as t2 on t1.idgambar=t2.id
		where t1.status=1";
	$rs=$db->loadAssoc($query);
	return json_encode($rs,true);
}

?>