fixed change of framework
This commit is contained in:
+20
-19
@@ -5,7 +5,7 @@
|
||||
Module : /Web/Auth.php
|
||||
Created By : Siau Pheng ([email protected]).
|
||||
Created Date : March 16th, 2008.
|
||||
Last Modified : August 22nd, 2026.
|
||||
Last Modified : September 3rd, 2026.
|
||||
|
||||
(c) 3FONIA Software; WWW.3FONIA.COM.
|
||||
|
||||
@@ -31,7 +31,7 @@ use \flight\database\SimplePdo;
|
||||
*/
|
||||
|
||||
final class Auth {
|
||||
private int $__id_reg = 0;
|
||||
private int $id_reg = 0;
|
||||
protected Engine $app;
|
||||
protected SimplePdo $db;
|
||||
protected Session $session;
|
||||
@@ -43,20 +43,20 @@ final class Auth {
|
||||
$this->app = $app;
|
||||
$this->db = $app->db();
|
||||
$this->session = $app->session();
|
||||
$this->__id_reg = (int)$this->session->get('__WEB_APP', ['REG_ID'=>0])['REG_ID'];
|
||||
$this->id_reg = (int) $this->session->get('WEB_APP', ['REG_ID'=>0])['REG_ID'];
|
||||
}
|
||||
|
||||
public function set_id_reg(int|string $id = 0): void {
|
||||
if ($id > 0) $this->__id_reg = (int)$id;
|
||||
if ((int) $id > 0) $this->id_reg = (int) $id;
|
||||
}
|
||||
|
||||
public function user_check(string $user, string $pass): bool {
|
||||
$i_hasil = (int)$this->db->fetchField('SELECT COUNT(*) FROM app_operator WHERE Username=? AND Password=MD5(?) AND Aktif=1', [$user, $pass]);
|
||||
$i_hasil = (int) $this->db->fetchField('SELECT COUNT(*) FROM app_operator WHERE Username=? AND Password=MD5(?) AND Aktif=1', [$user, $pass]);
|
||||
return ($i_hasil > 0 ? true : false);
|
||||
}
|
||||
|
||||
public function user_data(string $user): array {
|
||||
$adata = $this->db->fetchRow('SELECT *,DECODE(Menu,?) Menu2 FROM app_operator WHERE Username=?', [$this->__id_reg, $user])->getData();
|
||||
$adata = $this->db->fetchRow('SELECT *,DECODE(Menu,?) Menu2 FROM app_operator WHERE Username=?', [$this->id_reg, $user])->getData();
|
||||
$adata['Menu'] = $adata['Menu2'];
|
||||
unset($adata['Menu2']);
|
||||
|
||||
@@ -65,34 +65,34 @@ final class Auth {
|
||||
$this->session->set('APP_TOKEN', $_token);
|
||||
$this->db->insert('app_token', [ 'Token' => $_token, 'UserID' => $adata['UserID'], 'IP' => $this->app->request()->ip ]);
|
||||
}
|
||||
if ((int)$adata['Grup_MenuID'] > 0) $adata['Menu_Grup'] = $this->user_allmenu((int)$adata['Grup_MenuID']);
|
||||
if ((int) $adata['Grup_MenuID'] > 0) $adata['Menu_Grup'] = $this->user_allmenu((int) $adata['Grup_MenuID']);
|
||||
$adata['UNIX'] = time();
|
||||
$adata['LOCALE'] = $this->session->get('__WEB_APP', ['DEF_LOCALE'=>'id'])['DEF_LOCALE'];
|
||||
$adata['LOCALE'] = $this->session->get('WEB_APP', ['DEF_LOCALE'=>'id'])['DEF_LOCALE'];
|
||||
$adata['MENU_MODUL'] = [];
|
||||
return $adata;
|
||||
}
|
||||
|
||||
public function gen_module_menu(): void {
|
||||
$amodul = []; $aallow = []; $tallow = '';
|
||||
if ($this->session->get('__WEB_APP', ['APP_MODULE'=>0])['APP_MODULE']) {
|
||||
$tallow = $this->db->fetchField('SELECT Modul_Akses FROM app_menu_grup WHERE Grup_MenuID=?', [$this->session->get('__WEB_USER', ['Grup_MenuID'=>0])['Grup_MenuID']]);
|
||||
if ($this->session->get('WEB_APP', ['APP_MODULE'=>0])['APP_MODULE']) {
|
||||
$tallow = $this->db->fetchField('SELECT Modul_Akses FROM app_menu_grup WHERE Grup_MenuID=?', [$this->session->get('WEB_USER', ['Grup_MenuID'=>0])['Grup_MenuID']]);
|
||||
$aallow = explode(",", $tallow);
|
||||
|
||||
if (count($aallow) > 0) {
|
||||
$stat = $this->db->runQuery('SELECT * FROM (SELECT APP_MODULE,APP_PATH FROM app_config) A LEFT JOIN (SELECT Modul,Urut,Judul,Icon FROM app_menu WHERE Level=0) B ON (A.APP_MODULE=B.Modul) ORDER BY B.Urut');
|
||||
while ($row = $stat->fetch()) {
|
||||
if (!in_array($row['Modul'], $aallow) || $row['Modul']==$this->session->get('__WEB_APP')['APP_MODULE']) continue;
|
||||
if (!in_array($row['Modul'], $aallow) || $row['Modul']==$this->session->get('WEB_APP')['APP_MODULE']) continue;
|
||||
$amodul[] = $row;
|
||||
}
|
||||
}
|
||||
}
|
||||
$auser = $this->session->get('__WEB_USER', []);
|
||||
$auser = $this->session->get('WEB_USER', []);
|
||||
$auser['MENU_MODUL'] = $amodul;
|
||||
$this->session->set('__WEB_USER', $auser);
|
||||
$this->session->set('WEB_USER', $auser);
|
||||
}
|
||||
|
||||
public function user_allmenu(int $id_grup = 0): string {
|
||||
$allmenu = $this->db->fetchField('SELECT DECODE(Menu,?) MenuX FROM app_menu_grup WHERE Grup_MenuID=?', [$this->__id_reg, $id_grup]);
|
||||
$allmenu = $this->db->fetchField('SELECT DECODE(Menu,?) MenuX FROM app_menu_grup WHERE Grup_MenuID=?', [$this->id_reg, $id_grup]);
|
||||
return $allmenu;
|
||||
}
|
||||
|
||||
@@ -102,9 +102,10 @@ final class Auth {
|
||||
}
|
||||
|
||||
public function user_log(): void {
|
||||
$_user_id = $this->session->get('__WEB_USER')['UserID'] ?? 0;
|
||||
$_user_id = $this->session->get('WEB_USER')['UserID'] ?? 0;
|
||||
if ($_user_id === 0) return;
|
||||
$a_hasil = $this->db->fetchRow('SELECT * FROM app_logs WHERE UserID=? ORDER BY Last_Date DESC LIMIT 1', [$_user_id])->getData();
|
||||
$x_hasil = $this->db->fetchRow('SELECT * FROM app_logs WHERE UserID=? ORDER BY Last_Date DESC LIMIT 1', [$_user_id]);
|
||||
$a_hasil = ($x_hasil) ? $x_hasil->getData() : [];
|
||||
if (count($a_hasil) > 0) {
|
||||
$this->db->update('app_operator', [ 'Last_IP' => $a_hasil['Last_IP'], 'Last_Date' => $a_hasil['Last_Date'] ], 'UserID=?', [$_user_id]);
|
||||
}
|
||||
@@ -116,13 +117,13 @@ final class Auth {
|
||||
}
|
||||
|
||||
public function token_check(string $token): bool {
|
||||
$hasil = (bool)$this->db->fetchField('SELECT 1 FROM app_token WHERE Token=?', [$token ?? $this->session->get('APP_TOKEN')]);
|
||||
if ($hasil === true) $this->db->update('app_token', ['DateStamp' => 'NOW()'], 'Token=?', [$token ?? $this->session->get('APP_TOKEN')]);
|
||||
$hasil = (bool) $this->db->fetchField('SELECT 1 FROM app_token WHERE Token=?', [$token ?? $this->session->get('APP_TOKEN')]);
|
||||
if ($hasil === true) $this->db->runQuery('UPDATE app_token SET DateStamp=NOW() WHERE Token=?', [$token ?? $this->session->get('APP_TOKEN')]);
|
||||
return $hasil;
|
||||
}
|
||||
|
||||
public function token_update(): void {
|
||||
$this->db->update('app_token', ['DateStamp' => 'NOW()'], 'Token=?', [$this->session->get('APP_TOKEN')]);
|
||||
$this->db->runQuery('UPDATE app_token SET DateStamp=NOW() WHERE Token=?', [$this->session->get('APP_TOKEN')]);
|
||||
}
|
||||
|
||||
public function redirect(string $appUrl): string {
|
||||
|
||||
+18
-17
@@ -5,7 +5,7 @@
|
||||
Module : /Web/Form.php
|
||||
Created By : Siau Pheng ([email protected]).
|
||||
Created Date : February 27th, 2008.
|
||||
Last Modified : August 22nd, 2026.
|
||||
Last Modified : September 5th, 2026.
|
||||
|
||||
(c) 3FONIA Software; WWW.3FONIA.COM.
|
||||
|
||||
@@ -48,7 +48,7 @@ final class Form {
|
||||
|
||||
public function option(string $label, string $field, mixed $value=null, bool $enable=true, bool $req=false, array $arr=[], ?string $help=null, ?string $change=null, bool $multi=false, bool $group=false): string {
|
||||
$_opsi = '';
|
||||
if (!empty($change)) $_opsi .= ' ochan="'.$change.'"';
|
||||
if (!empty($change)) $_opsi .= ' ochan="'.rtrim($change, '();').'"';
|
||||
if ($enable===false) $_opsi .= ' disabled=true';
|
||||
if ($req===true) $_opsi .= ' required=true';
|
||||
if ($multi===true) $_opsi .= ' multiple';
|
||||
@@ -118,14 +118,14 @@ final class Form {
|
||||
}
|
||||
|
||||
public function option_ulevel(string $label, string $field, int $value=9, bool $enable=true, bool $req=false, ?string $help=null, ?string $change=null): string {
|
||||
return $this->option($label, $field, $value, $enable, $req, $this->session->get('__WEB_APP')['USER_LEVEL'], $help, $change);
|
||||
return $this->option($label, $field, $value, $enable, $req, $this->session->get('WEB_APP')['USER_LEVEL'], $help, $change);
|
||||
}
|
||||
|
||||
public function radio(string $label, string $field, mixed $value=null, bool $enable=true, bool $req=false, array $arr=[], ?string $help=null, ?string $change=null): string {
|
||||
$_val = array_values($arr);
|
||||
if (empty($value)) $value = $_val[0];
|
||||
$_val = array_keys($arr);
|
||||
if (is_null($value)) $value = $_val[0];
|
||||
$_opsi = '';
|
||||
if (!empty($change)) $_opsi .= ' ochan="'.$change.'"';
|
||||
if (!empty($change)) $_opsi .= ' ochan="'.rtrim($change, '();').'"';
|
||||
if ($enable===false) $_opsi .= ' disabled=true';
|
||||
if ($req===true) $_opsi .= ' required=true';
|
||||
$tout = '<input type="hidden" id="'.$field.'" value="'.$value.'" />';
|
||||
@@ -151,9 +151,9 @@ final class Form {
|
||||
|
||||
public function checkbox(string $label, string $field, mixed $value=null, bool $enable=true, bool $req=false, array $arr=[], ?string $help=null, ?string $change=null): string {
|
||||
$_val = array_values($arr);
|
||||
if (empty($value)) $value = $_val[1];
|
||||
if (is_null($value)) $value = $_val[0];
|
||||
$_opsi = ' odata="'.htmlspecialchars(json_encode($arr)).'"';
|
||||
if (!empty($change)) $_opsi .= ' ochan="'.$change.'"';
|
||||
if (!empty($change)) $_opsi .= ' ochan="'.rtrim($change, '();').'"';
|
||||
if ($enable===false) $_opsi .= ' disabled=true';
|
||||
if ($req===true) $_opsi .= ' required=true';
|
||||
$tout = '<div class="col-form-label form-check"><input type="checkbox" class="form-check-input" id="'.$field.'" name="'.$field.'" value="'.$value.'"'.$_opsi;
|
||||
@@ -165,9 +165,9 @@ final class Form {
|
||||
|
||||
public function switch(string $label, string $field, mixed $value=null, bool $enable=true, bool $req=false, array $arr=[], ?string $help=null, ?string $change=null): string {
|
||||
$_val = array_values($arr);
|
||||
if (empty($value)) $value = $_val[1];
|
||||
if (is_null($value)) $value = $_val[0];
|
||||
$_opsi = ' odata="'.htmlspecialchars(json_encode($arr)).'"';
|
||||
if (!empty($change)) $_opsi .= ' ochan="'.$change.'"';
|
||||
if (!empty($change)) $_opsi .= ' ochan="'.rtrim($change, '();').'"';
|
||||
if ($enable===false) $_opsi .= ' disabled=true';
|
||||
if ($req===true) $_opsi .= ' required=true';
|
||||
$tout = '<div class="col-form-label form-check form-switch"><input class="form-check-input" id="'.$field.'" name="'.$field.'" type="checkbox" role="switch" value="'.$value.'"'.$_opsi;
|
||||
@@ -179,8 +179,8 @@ final class Form {
|
||||
|
||||
public function textbox(string $label, string $field, mixed $value=null, bool $enable=true, bool $req=false, string $type="text", ?string $holdtxt=null, ?int $maxsize=null, ?string $help=null, ?string $keyup=null, ?string $blur=null): string {
|
||||
$_opsi = '';
|
||||
if (!empty($keyup)) $_opsi .= ' okyup="'.$keyup.'"';
|
||||
if (!empty($blur)) $_opsi .= ' oblur="'.$blur.'"';
|
||||
if (!empty($keyup)) $_opsi .= ' okyup="'.rtrim($keyup, '();').'"';
|
||||
if (!empty($blur)) $_opsi .= ' oblur="'.rtrim($blur, '();').'"';
|
||||
if (!empty($holdtxt)) $_opsi .= ' placeholder="'.$holdtxt.'"';
|
||||
if (!empty($maxsize)) $_opsi .= ' maxlength="'.$maxsize.'"';
|
||||
if ($enable===false) $_opsi .= ' readonly';
|
||||
@@ -196,8 +196,9 @@ final class Form {
|
||||
return $tout;
|
||||
}
|
||||
|
||||
public function textauto(string $label, string $field, array $avalue=['value'=>0,'text'=>""], bool $enable=true, bool $req=false, ?string $holdtxt=null, ?int $maxsize=null, ?string $help=null): string {
|
||||
public function textauto(string $label, string $field, array $avalue, bool $enable=true, bool $req=false, ?string $holdtxt=null, ?int $maxsize=null, ?string $help=null): string {
|
||||
$_opsi = '';
|
||||
if (count($avalue) === 0) $avalue = [ 'value' => 0, 'text' => "" ];
|
||||
if (!empty($holdtxt)) $_opsi .= ' placeholder="'.$holdtxt.'"';
|
||||
if (!empty($maxsize)) $_opsi .= ' maxlength="'.$maxsize.'"';
|
||||
if ($enable===false) $_opsi .= ' disabled=true';
|
||||
@@ -222,8 +223,8 @@ final class Form {
|
||||
|
||||
public function textarea(string $label, string $field, ?string $value=null, bool $enable=true, bool $req=false, int $rows=1, ?string $holdtxt=null, ?string $help=null, ?string $keyup=null, ?string $blur=null): string {
|
||||
$_opsi = '';
|
||||
if (!empty($keyup)) $_opsi .= ' okyup="'.$keyup.'"';
|
||||
if (!empty($blur)) $_opsi .= ' oblur="'.$blur.'"';
|
||||
if (!empty($keyup)) $_opsi .= ' okyup="'.rtrim($keyup, '();').'"';
|
||||
if (!empty($blur)) $_opsi .= ' oblur="'.rtrim($blur, '();').'"';
|
||||
if (!empty($holdtxt)) $_opsi .= ' placeholder="'.$holdtxt.'"';
|
||||
if ($enable===false) $_opsi .= ' disabled=true';
|
||||
if ($req===true) $_opsi .= ' required=true';
|
||||
@@ -244,7 +245,7 @@ final class Form {
|
||||
|
||||
public function color(string $label, string $field, ?string $value=null, bool $enable=true, bool $req=false, ?string $help=null, ?string $change=null): string {
|
||||
$_opsi = '';
|
||||
if (!empty($change)) $_opsi .= ' ochan="'.$change.'"';
|
||||
if (!empty($change)) $_opsi .= ' ochan="'.rtrim($change, '();').'"';
|
||||
if ($enable===false) $_opsi .= ' disabled=true';
|
||||
if ($req===true) $_opsi .= ' required=true';
|
||||
$tout = '<input type="color" class="form-control form-control-color" id="'.$field.'" name="'.$field.'" value="'.$value.'"'.$_opsi.' />';
|
||||
@@ -267,7 +268,7 @@ final class Form {
|
||||
$col_right = 'col-sm-' . (10-$lebar_kolom) . ' col-lg-' . (12-$lebar_kolom);
|
||||
$tres = '';
|
||||
foreach ($this->__aform as $_key => $_val) {
|
||||
$tres .= sprintf('<div class="row mb-1"><label class="%s col-form-label" for="%s">%s</label><div class="%s">%s %s</div></div>', $col_left, $_key, $_val['label'], $col_right, $_val['form'], (empty($_val['help'])?'':'<span class="help-block"><small>'.$_val['help'].'</small></span>'));
|
||||
$tres .= sprintf('<div class="row mb-1"><label class="%s col-form-label" for="%s">%s</label><div class="%s">%s %s</div></div>', $col_left, $_key, $_val['label'], $col_right.(str_contains($_val['form'],'type="radio"')?' d-flex gap-2':''), $_val['form'], (empty($_val['help'])?'':'<span class="help-block"><small>'.$_val['help'].'</small></span>'));
|
||||
}
|
||||
foreach ($this->__ahide as $_key => $_val) {
|
||||
$tres .= $_val;
|
||||
|
||||
+2
-2
@@ -44,8 +44,8 @@ final class Menu {
|
||||
$this->app = $app;
|
||||
$this->db = $app->db();
|
||||
$this->session = $app->session();
|
||||
$this->webapp = $this->session->get('__WEB_APP', ['APP_MODULE'=>'', 'PARENT_SITE'=>'', 'PARENT_SUB'=>false]);
|
||||
$this->webuser = $this->session->get('__WEB_USER', ['Menu'=>'', 'Menu_Grup'=>'', 'MENU_MODUL'=>[]]);
|
||||
$this->webapp = $this->session->get('WEB_APP', ['APP_MODULE'=>'', 'PARENT_SITE'=>'', 'PARENT_SUB'=>false]);
|
||||
$this->webuser = $this->session->get('WEB_USER', ['Menu'=>'', 'Menu_Grup'=>'', 'MENU_MODUL'=>[]]);
|
||||
}
|
||||
|
||||
public function Sidebar(): string {
|
||||
|
||||
+2
-1
@@ -38,7 +38,8 @@ final class Param {
|
||||
private static function __data(): void {
|
||||
global $app;
|
||||
if (empty($app)) $app = \Flight::app();
|
||||
$_asumber = array_merge($app->request()->query->getData(), $app->request()->data->getData());
|
||||
//$_asumber = array_merge($app->request()->query->getData(), $app->request()->data->getData());
|
||||
$_asumber = $app->request()->query->getData() + $app->request()->data->getData();
|
||||
foreach ($_asumber as $__key => $__val) {
|
||||
self::$__ahasil[$__key] = is_string($__val) ? self::safeSQL($__val) : $__val;
|
||||
}
|
||||
|
||||
@@ -35,17 +35,17 @@ final class Register {
|
||||
}
|
||||
|
||||
public static function reg_id(Session $session) {
|
||||
$id = (string)$session->get('__WEB_APP', ['REG_ID'=>''])['REG_ID'];
|
||||
$id = (string)$session->get('WEB_APP', ['REG_ID'=>''])['REG_ID'];
|
||||
return (substr($id,0,3).".".substr($id,3,3).".".substr($id,6));
|
||||
}
|
||||
|
||||
public static function reg_code(Session $session) {
|
||||
$id = (string)$session->get('__WEB_APP', ['REG_CODE'=>''])['REG_CODE'];
|
||||
$id = (string)$session->get('WEB_APP', ['REG_CODE'=>''])['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(Session $session) {
|
||||
$webapp = $session->get('__WEB_APP');
|
||||
$webapp = $session->get('WEB_APP');
|
||||
return (bool)(isset($webapp['REG_STATUS']) && $webapp['REG_STATUS']) ?? false;
|
||||
}
|
||||
|
||||
|
||||
+5
-7
@@ -5,7 +5,7 @@
|
||||
Module : /Web/Table.php
|
||||
Created By : Siau Pheng ([email protected]).
|
||||
Created Date : January 16th, 2008.
|
||||
Last Modified : August 22nd, 2026.
|
||||
Last Modified : August 27th, 2026.
|
||||
|
||||
(c) 3FONIA Software; WWW.3FONIA.COM.
|
||||
|
||||
@@ -144,7 +144,7 @@ final class Table {
|
||||
$this->__bnobutton = true;
|
||||
}
|
||||
|
||||
public function add_field(string $field = "", string $header = "", string $style = "l", string $format = "", string $footer = "", string $otype = ""): void {
|
||||
public function add_field(string $field = "", string $header = "", string $style = "l", mixed $format = "", string $footer = "", string $otype = ""): void {
|
||||
$this->__afield[] = [ 'a' => $field, 'h' => $header, 's' => $style, 'f' => $format, 't' => $footer, 'o' => $otype ];
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ final class Table {
|
||||
$row = $this->db->fetchRow("SELECT ".$this->__tfooter." FROM ".$this->__ttable.$this->__twhere, $this->__aparam);
|
||||
foreach ($this->__afield as $col) {
|
||||
$tval = $row[$col['a']] ?? '';
|
||||
if (is_set($col['t']) && !empty($col['t'])) {
|
||||
if (isset($col['t']) && !empty($col['t'])) {
|
||||
if (is_array($col['t'])) {
|
||||
$tval2 = $col['t'][$tval] ?? '';
|
||||
} else if (function_exists($col['t'])) {
|
||||
@@ -186,8 +186,7 @@ final class Table {
|
||||
// adding all option
|
||||
foreach ($this->__aoption as $opsi) {
|
||||
if (in_array($opsi['type'], ["button","button-dt"])) {
|
||||
if (!isset($opsi['field'])) continue;
|
||||
if (!empty($opsi['field']) && ($row[$opsi['field']] !== (!empty($opsi['value']) ? $opsi['value'] : (string)$this->app->session()->get('__WEB_USER')['UNIX']))) {} else {
|
||||
if (!empty($opsi['field']) && ((string) $row[$opsi['field']] !== (string) $opsi['value'])) {} else {
|
||||
$aoption['button'][] = [ $opsi['icon'], (empty($opsi['field_css'])?'':$opsi['avalue_css'][$row[$opsi['field_css']]]??'') ];
|
||||
}
|
||||
}
|
||||
@@ -270,8 +269,7 @@ final class Table {
|
||||
// adding all option
|
||||
foreach ($this->__aoption as $opsi) {
|
||||
if (in_array($opsi['type'], ["button","button-dt"])) {
|
||||
if (!isset($opsi['field'])) continue;
|
||||
if (!empty($opsi['field']) && ($row[$opsi['field']] !== (!empty($opsi['value']) ? $opsi['value'] : $this->app->session()->get('__WEB_USER')['UNIX']))) {} else {
|
||||
if (!empty($opsi['field']) && ((string) $row[$opsi['field']] !== (string) $opsi['value'])) {} else {
|
||||
$aoption['button'][] = [ $opsi['icon'], (empty($opsi['field_css'])?'':$opsi['avalue_css'][$row[$opsi['field_css']]]??'') ];
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ final class Update {
|
||||
*/
|
||||
public function __construct(Engine $app){
|
||||
$this->app = $app;
|
||||
$this->__conf = $app->session()->get('__WEB_APP');
|
||||
$this->__conf = $app->session()->get('WEB_APP');
|
||||
$this->current();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user