result = $resultValue; $Value->content = $resultContent; echo json_encode($Value); die(); } /* Include all Admin Ajax operations */ require_once(ADMIN_DIR . 'adminAjaxOperations.php'); foreach($AjaxFunctionMap as $currentName => $currentFunction) { addAdminAjaxOperation($currentName, $currentFunction); } /* Recibe $POST to access ajax Function */ if(isset($_POST)) { if(!isset($_POST['Operation'])) { returnJSONValue(AJAXERROR, 'Flatpress Ajax needs operation'); } if(!array_key_exists($_POST['Operation'], $ajaxFunctions)) { returnJSONValue(AJAXERROR, 'Flatpress Ajax Operation doesnt not exist'); } //Check if this OP needs admin permissions. If true, check users permissions. if($ajaxIsAdminOrNot[$_POST['Operation']]) { if(!user_loggedin()) { returnJSONValue(AJAXERROR, 'Forbidden. You dont have admin permissions'); } } try { if(!isset($_POST['Arguments'])) { $result = $ajaxFunctions[$_POST['Operation']](); } else { $result = $ajaxFunctions[$_POST['Operation']]($_POST['Arguments']); } returnJSONValue(AJAXSUCCESS, $result); } catch(Exception $e) { returnJSONValue(AJAXERROR, $e->getMessage()); } } ?>