/** * Is logged In. Fungsi ini memanggil method is_loggedin() yang ada di file Loader * mbulet juga :( */ function is_logged($app, $ctr) { if (!isset($_SERVER['PHP_AUTH_USER'])) { halt401($app); return; } $pass = FALSE; $pass = $ctr->MainModel->check_user($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']); if (!$pass) { halt401($app); } }
* Verb: aduan */ $app->post('/aduan', function () use($app, $ctr) { $ctr->load('model', 'main'); is_logged($app, $ctr); $ctr->load('model', 'pelanggan'); $r = $ctr->PelangganModel->add_aduan(); if ($r === FALSE) { return halt401($app); } json_output($app, $r); }); // ---------------------------------------------------------------- /** * Method: DELETE * Verb: aduan */ $app->options('/aduan/:Id', function () use($app) { $app->status(200); $app->stop(); }); $app->delete('/aduan/:Id', function ($id) use($app, $ctr) { $ctr->load('model', 'main'); is_logged($app, $ctr); $ctr->load('model', 'pelanggan'); $r = $ctr->PelangganModel->delete_aduan($id); if ($r === FALSE) { return halt401($app); } json_output($app, $r); });