{ function makeError($err, $code = 500) { $this->response->status($code); $this->response->headers->set("Content-Type", "application/json"); echo json_encode(array("errors" => array($err))); } function authed() { return isset($_SESSION["adminid"]); } } $app = new Web(array("debug" => false)); $app->add(new Slim\Middleware\ContentTypes()); $app->notFound(function () use($app) { echo "Requested resource not found"; }); $app->get("/", function () use($app) { $app->redirect("/"); }); $app->get("/plans", function () use($app) { if (!$app->authed()) { $app->makeError("Access denied"); return; } $qres = mysql_query("SELECT * FROM `tblproducts` p WHERE p.`type` IN ( 'hostingaccount','reselleraccount') and p.`configoption1` != '' and p.`servertype` = 'cpanel';"); if ($qres === FALSE) { $app->makeError("Unable to get the list of hosting packages"); return; } $plans = array();