app = (empty($app) === true) ? \Flight::app() : $app; $this->db = $this->app->db(); } public static function reg_id() { $webapp = (array)\Flight::app()->session()->get('__WEB_APP'); $id = (string)$webapp['REG_ID'] ?? ''; return (substr($id,0,3).".".substr($id,3,3).".".substr($id,6)); } public static function reg_code() { $webapp = (array)\Flight::app()->session()->get('__WEB_APP'); $id = (string)$webapp['REG_CODE'] ?? ''; return (substr($id,0,6)."-".substr($id,6,5)."-".substr($id,11,5)."-".substr($id,16,5)."-".substr($id,21,5)."-".substr($id,26,6)); } public static function reg_check() { $webapp = (array)\Flight::app()->session()->get('__WEB_APP'); return (bool)(isset($webapp['REG_STATUS']) && $webapp['REG_STATUS']) ?? false; } public function reg_status(array $apps) { $kode_db = (bool)$this->db->fetchField('SELECT UPPER(CONVERT(MD5(CONCAT(REG_YEAR,CONVERT(MD5(CONCAT(REG_ID,REG_NAME)) using latin1),REG_ID,REG_NAME)) using latin1))=REG_CODE FROM app_config WHERE REG_ID=?', [$apps['APP_CODE'] ?? '']); return [ 'REG_STATUS' => $kode_db === true ]; } } ?>