app = $app; $this->db = $db; $this->session = $session; $this->auth = new Auth($app); $this->aapp = $this->session->get('WEB_APP') ?? []; $this->auser = $this->session->get('WEB_USER') ?? []; $this->ainv = $this->session->get('APP_INV') ?? []; } public function login() { $ajson['status'] = false; $auser = []; if ($this->auth->user_check(Param::Get("Username"), Param::Get("Password"))) { $auser = $this->auth->user_data(Param::Get("Username")); //MONITOR DISPLAY if (($this->ainv['MON_ENABLE'] ?? false) && ($auser['UserID'] ?? false)) { $this->auth->pos_login($this->ainv['CABANGID'], $auser['UserID'], $auser['UNIX'], $this->app->request()->ip); } $this->session->set('WEB_USER', $auser); if (Param::Get("redir", "") !== "") { $_redir = $this->auth->redirect(Param::Get("redir")); //jika kosong, tampilkan pesan redirect tidak diijinkan //jika berisi, js harus redirect ... } $ajson['status'] = true; $ajson['token'] = $this->session->get('APP_TOKEN'); $ajson['message'] = '
Login berhasil,

'.$auser["Username"].' / '.$auser["Nama"].'
'.$auser["Posisi"].'
login terakhir :
'.tgl_sql2str($auser["Last_Date"],true).'
'.$auser["Last_IP"].'

'; } else { $ajson['message'] = "Periksa kembali ID Pengguna atau Password Anda ..."; } $this->app->json($ajson); } public function logout() { $ajson['status'] = false; //MONITOR DISPLAY if (($this->ainv['MON_ENABLE'] ?? false) && ($this->auser['UserID'] ?? false)) { $this->auth->pos_logout($this->ainv['CABANGID'], $this->auser['UserID'], $this->auser['UNIX'], $this->app->request()->ip); } $this->auth->logout(); $this->session->clear(); $_host = $this->app->request()->getVar('HTTP_ORIGIN') ?? $this->aapp['PARENT_SITE']; $_host = str_replace(['http://','https://'], "", $_host); if ($this->aapp['PARENT_SUB'] === true) { $_subs = explode('.', $_host); if (count($_subs) > 2) array_shift($_subs); $_host = implode('.', $_subs); } $ajson['nexthost'] = "//" . $_host; $this->app->json($ajson); } public function menu() { $page = Param::Get("p", ""); $query = Param::Get("q", ""); $ajson['login'] = false; if (count($this->auser) > 0 && !empty($page)) { $ajson = Menu::MenuJSON($this->db, $page, $query); } $this->app->json($ajson); } public function supervisi() { $data = Param::Get("data", ""); $ajson = ['status' => 0, 'pesan' => ""]; if ($data == "super-check") { $bsuper = (Param::Get("SUPER","true") == "true") ? true : false; $buover = (Param::Get("UOVER","false") == "true") ? true : false; if (!$this->auth->user_check_level(Param::Get("UID"), $this->aapp['AUTH_LEVEL']) && $bsuper == true) { $ajson['status'] = 0; $ajson['pesan'] = "Silakan hubungi Supervisor / Administrator Anda!"; } else { if (!$this->auth->user_check(Param::Get("UID"), Param::Get("PWD"))) { $ajson['status'] = 0; $ajson['pesan'] = "User ID atau Password Anda Salah!
Anda tidak diijinkan melanjutkan proses!"; } else { $ajson['status'] = 1; if ($buover == true && $bsuper == false && Param::Get("UID") <> $this->auser['Username']) { $new_sess = $this->auth->user_data(Param::Get("UID")); $tmp_sess = $this->session->get('WEB_USER'); foreach ($new_sess as $_key => $_val) { if ($tmp_sess[$_key]) $tmp_sess[$_key] = $_val; } $this->session->set('WEB_USER', $tmp_sess); } } } } elseif ($data == "super-request") { $this->db->delete('app_auth', 'UserID=? AND Kode=? AND SID=? AND REQ=? AND Auth=0', [$this->auser['UserID'], Param::Get("KODE"), Param::Get("REQ_SID"), Param::Get("REQ")]); $this->db->runQuery('INSERT INTO app_auth (UserID, Kode, SID, REQ, Catatan, Tanggal) VALUES (?, ?, ?, ?, ?, NOW())', [ $this->auser['UserID'], Param::Get("KODE"), Param::Get("REQ_SID"), Param::Get("REQ"), Param::Get("MSG") ]); } elseif ($data == "super-cancel") { $this->db->delete('app_auth', 'UserID=? AND Kode=? AND SID=? AND REQ=?', [$this->auser['UserID'], Param::Get("KODE"), Param::Get("REQ_SID"), Param::Get("REQ")]); } elseif ($data == "request-check") { $_auth = (int) $this->db->fetchField('SELECT Auth FROM app_auth WHERE UserID=? AND Kode=? AND SID=? AND REQ=?', [$this->auser['UserID'], Param::Get("KODE"), Param::Get("REQ_SID"), Param::Get("REQ")]) ?? 0; if ($_auth == 1) $ajson['status'] = 1; } $this->app->json($ajson); } }