corrected same function

This commit is contained in:
2026-10-21 16:13:30 +07:00
parent 17188f6134
commit 0a47ddc422
5 changed files with 64 additions and 78 deletions
+13 -9
View File
@@ -5,7 +5,7 @@
Module : /Data/Cache.php
Created By : Siau Pheng ([email protected]).
Created Date : March 16th, 2008.
Last Modified : September 3rd, 2026.
Last Modified : October 12th, 2026.
(c) 3FONIA Software; WWW.3FONIA.COM.
@@ -43,6 +43,7 @@ final class Cache {
private array $ini;
private array $web_app;
private array $web_user;
private array $my_menu = [];
private bool $is_login;
private bool $IS_DEV = false;
protected Engine $app;
@@ -72,7 +73,7 @@ final class Cache {
$this->ini = [
'login' => [ 'css' => "", 'js' => "", 'app' => "", ],
'index' => [ 'css' => "", 'js' => "", 'app' => "", ],
'display' => [ 'css' => "", 'js' => "", 'app' => "", ],
'monitor' => [ 'css' => "", 'js' => "", 'app' => "", ],
];
$this->save_ini();
} else $this->ini = parse_ini_file($this->cachedir . "cache.ini", true);
@@ -134,7 +135,7 @@ final class Cache {
}
if ($mode === 'index') {
$_ajs = ['system/profile', 'system/chpasswd'];
$amenu = array_values($this->web_user['Merge_Menu'] ?? []);
$amenu = array_values($this->my_menu ?? []);
$_ops = $this->db->fetchColumn("SELECT Link FROM app_menu WHERE Kode IN (?) AND Link<>'' ORDER BY Kode", [$amenu]);
if ($_ops) $_ajs = array_merge($_ajs, $_ops);
$dirIterator = new \RecursiveDirectoryIterator($this->jsapp, \RecursiveDirectoryIterator::SKIP_DOTS);
@@ -142,7 +143,7 @@ final class Cache {
$iterator = new \RecursiveIteratorIterator($dirFilter);
foreach ($iterator as $_file) {
if ($_file->isFile() &&
!in_array($_file->getFilename(), ['login.js','index.js','display.js']) &&
!in_array($_file->getFilename(), ['login.js','index.js','monitor.js']) &&
array_any($_ajs, fn($js) => str_ends_with(str_replace(['_','\\'],['','/'],$_file->getRealPath()), $js.'.js'))) {
$afile[] = $_file->getRealPath();
$itime += $_file->getMTime();
@@ -194,7 +195,10 @@ final class Cache {
public function Cache(string $mode = "index"): array {
if ($mode === 'index') {
$this->ini['index']['app'] = (string) $this->db->fetchField("SELECT JS FROM app_operator_profile WHERE UserID=?", [$this->web_user['UserID']]) ?? '';
$this->web_user['Merge_Menu'] = array_filter(array_unique(explode(",", $this->web_user['Menu_Grup'] .",". $this->web_user['Menu'])));
$_menu = $this->db->fetchField("SELECT CONVERT(DECODE(Menu,?) USING UTF8MB4) Menu FROM app_operator WHERE UserID=?", [$this->web_app['PARENT_CODE'], $this->web_user['UserID']]) ?? '';
$_gmenu = '';
if ($this->web_user['Grup_MenuID'] > 0) $_gmenu = $this->db->fetchField('SELECT CONVERT(DECODE(Menu,?) USING UTF8MB4) Menu FROM app_menu_grup WHERE Grup_MenuID=?', [$this->web_app['PARENT_CODE'], $this->web_user['Grup_MenuID']]) ?? '';
$this->my_menu = array_filter(array_unique(explode(",", $_gmenu .",". $_menu)));
}
$is_modif = false;
@@ -235,7 +239,7 @@ final class Cache {
return $acache;
}
public function Make_Cache(array $amode = ['login', 'index', 'display']): array {
public function Make_Cache(array $amode = ['login', 'index', 'monitor']): array {
$is_modif = false;
foreach ($amode as $mode) {
foreach (['css','js','app'] as $type) {
@@ -252,11 +256,11 @@ final class Cache {
if ($is_modif === true) $this->save_ini();
if (in_array('index', $amode)) {
$agrup = $this->db->fetchAll('SELECT Grup_MenuID,DECODE(Menu,?) Menu FROM app_menu_grup', [$this->web_app['PARENT_CODE']]);
$auser = $this->db->fetchAll("SELECT A.*,IFNULL(B.JS,'') JS FROM (SELECT UserID,Grup_MenuID,DECODE(Menu,?) Menu FROM app_operator) A LEFT JOIN app_operator_profile B ON (A.UserID=B.UserID)", [$this->web_app['PARENT_CODE']]);
$agrup = $this->db->fetchAll('SELECT Grup_MenuID,CONVERT(DECODE(Menu,?) USING UTF8MB4) Menu FROM app_menu_grup', [$this->web_app['PARENT_CODE']]);
$auser = $this->db->fetchAll("SELECT A.*,IFNULL(B.JS,'') JS FROM (SELECT UserID,Grup_MenuID,CONVERT(DECODE(Menu,?) USING UTF8MB4) Menu FROM app_operator) A LEFT JOIN app_operator_profile B ON (A.UserID=B.UserID)", [$this->web_app['PARENT_CODE']]);
foreach ($auser as $user) {
if (empty($user['JS']) || !file_exists($this->cachedir . $user['JS'])) {
$this->web_user['Merge_Menu'] = array_filter(array_unique(explode(",", $user['Menu'] .",". ($agrup[$user['Grup_MenuID']]['Menu'] ?? ''))));
$this->my_menu = array_filter(array_unique(explode(",", $user['Menu'] .",". ($agrup[$user['Grup_MenuID']]['Menu'] ?? ''))));
[ $afile, $lastmod ] = $this->gen_file('index', 'app');
$cachefile = md5('index-app-' . (string) $user['UserID'] . $lastmod) . '.js';
+1 -1
View File
@@ -2,7 +2,7 @@
/*******************************************************************
PHP Class : /Data/Xls.php
PHP Class : /Data/Xlsx.php
Created By : Siau Pheng ([email protected]).
Created Date : November 18th, 2012.
Last Modified : October 1st, 2026.