$settings = $Tools->fetch_object("settings", "id", 1); } # set empty controller for options if ($_SERVER['REQUEST_METHOD'] == "OPTIONS") { if (!isset($_GET['controller']) || $_GET['controller'] == "") { $_GET['controller'] = "Tools"; } } /* wrap in a try-catch block to catch exceptions */ try { // start measuring $start = microtime(true); /* Validate application ---------- */ // verify that API is enabled on server if ($settings->api != 1) { $Response->throw_exception(503, "API server disabled"); } # fetch app $app = $Tools->fetch_object("api", "app_id", $_GET['app_id']); // verify app_id if ($app === false) { $Response->throw_exception(400, "Invalid application id"); } // check that app is enabled if ($app->app_permissions === "0") { $Response->throw_exception(503, "Application disabled"); } /* Check app security and prepare request parameters ---------- */ // crypt check if ($app->app_security == "crypt") { // verify php extensions
# exceptions/result object $Response = new Responses(); # get phpipam settings $settings = $Tools->fetch_object("settings", "id", 1); # set empty controller for options if ($_SERVER['REQUEST_METHOD'] == "OPTIONS") { if (!isset($_GET['controller']) || $_GET['controller'] == "") { $_GET['controller'] = "Tools"; } } /* wrap in a try-catch block to catch exceptions */ try { /* Validate application ---------- */ // verify that API is enabled on server if ($settings->api != 1) { $Response->throw_exception(503, "API server disabled"); } # fetch app $app = $Tools->fetch_object("api", "app_id", $_GET['app_id']); // verify app_id if ($app === false) { $Response->throw_exception(400, "Invalid application id"); } // check that app is enabled if ($app->app_permissions === "0") { $Response->throw_exception(503, "Application disabled"); } /* Check app security and prepare request parameters ---------- */ // crypt check if ($app->app_security == "crypt") { // verify php extensions
/** * Exists with exception * * @access public * @param mixed $content * @return void */ public function throw_exception($content) { // include Exceptions class for API include_once dirname(__FILE__) . '../../../api/v2/controllers/Responses.php'; // initialize exceptions $Exceptions = new Responses(); // throw error $Exceptions->throw_exception(500, $content); }