56 lines
1.8 KiB
PHP
56 lines
1.8 KiB
PHP
<?php
|
|
|
|
/*******************************************************************
|
|
|
|
Module : /Web/Register.php
|
|
Desc. : Class Registrasi Aplikasi
|
|
Created By : Siau Pheng ([email protected]).
|
|
Created Date : November 23th, 2011.
|
|
Last Modified : August 11th, 2026.
|
|
|
|
(c) 2011 - 2026, 3FONIA Software; WWW.3FONIA.COM.
|
|
|
|
*******************************************************************/
|
|
|
|
//OK
|
|
declare(strict_types=1);
|
|
|
|
namespace siaupheng\webapp\Web;
|
|
|
|
use flight\Engine;
|
|
use flight\database\SimplePdo;
|
|
|
|
final class Register {
|
|
protected Engine $app;
|
|
protected SimplePdo $db;
|
|
|
|
public function __construct(?Engine $app = null){
|
|
$this->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 ];
|
|
}
|
|
}
|
|
|
|
?>
|