/** * Converts self::$json_data to json and send it to output with json data http headers. */ protected static function send_json() { if (!empty(self::$errors)) { self::$json_data['ok'] = 0; self::$json_data['error'] = implode("\n", self::$errors); } if (class_exists('ApmQueriesWatcher')) { self::$json_data['queries'] = ApmQueriesWatcher::get_queries(); } self::$json_data['action'] = isset($_POST['action']) ? $_POST['action'] : ''; //If something was displayed before, clean it so that our answer can //be valid json (and store it in an "echoed_before_json" answer key //so that we can warn the user about it) : $content_already_echoed = ob_get_contents(); if (!empty($content_already_echoed)) { self::$json_data['echoed_before_json'] = $content_already_echoed; ob_end_clean(); } header('Content-type: application/json'); echo json_encode(self::$json_data); }
*/ header('Content-Type: text/html; charset=UTF-8'); require_once dirname(__FILE__) . "/api_ajax.php"; ApmApiAjax::check_admin_user_connected(); //Check the AJAX nonce check_ajax_referer('apm_ajax_request'); if (isset($_POST['apm_action'])) { $action = $_POST['apm_action']; require_once dirname(__FILE__) . "/tree_ajax.php"; require_once dirname(__FILE__) . "/list_ajax.php"; require_once dirname(__FILE__) . "/nodes_ajax.php"; if (ApmOptions::get_option('queries_watcher_on') == true) { $queries_watcher_file = dirname(__FILE__) . "/../lib/queries_watcher.php"; if (file_exists($queries_watcher_file)) { require_once $queries_watcher_file; ApmQueriesWatcher::start(); } } if (method_exists('ApmTreeAjax', $action)) { ApmTreeAjax::$action(); } else { if (method_exists('ApmListAjax', $action)) { ApmListAjax::$action(); } else { if (method_exists('ApmNodesAjax', $action)) { ApmNodesAjax::$action(); } } } } exit;