upgrade first session to flightphp

This commit is contained in:
2026-08-19 17:22:07 +07:00
parent 36395c2b55
commit 27ebdca49b
31 changed files with 1383 additions and 7659 deletions
-506
View File
@@ -1,506 +0,0 @@
.CodeMirror {
font-family: monospace;
height: 300px;
color: #000;
direction: ltr
}
.CodeMirror-lines {
padding: 4px 0
}
.CodeMirror pre.CodeMirror-line,
.CodeMirror pre.CodeMirror-line-like {
padding: 0 4px
}
.CodeMirror-scrollbar-filler,
.CodeMirror-gutter-filler {
background-color: #fff
}
.CodeMirror-gutters {
border-right: 1px solid #ddd;
background-color: #f7f7f7;
white-space: nowrap
}
.CodeMirror-linenumbers {}
.CodeMirror-linenumber {
padding: 0 3px 0 5px;
min-width: 20px;
text-align: right;
color: #999;
white-space: nowrap
}
.CodeMirror-guttermarker {
color: #000
}
.CodeMirror-guttermarker-subtle {
color: #999
}
.CodeMirror-cursor {
border-left: 1px solid #000;
border-right: none;
width: 0
}
.CodeMirror div.CodeMirror-secondarycursor {
border-left: 1px solid silver
}
.cm-fat-cursor .CodeMirror-cursor {
width: auto;
border: 0!important;
background: #7e7
}
.cm-fat-cursor div.CodeMirror-cursors {
z-index: 1
}
.cm-fat-cursor-mark {
background-color: rgba(20, 255, 20, .5);
-webkit-animation: blink 1.06s steps(1) infinite;
-moz-animation: blink 1.06s steps(1) infinite;
animation: blink 1.06s steps(1) infinite
}
.cm-animate-fat-cursor {
width: auto;
border: 0;
-webkit-animation: blink 1.06s steps(1) infinite;
-moz-animation: blink 1.06s steps(1) infinite;
animation: blink 1.06s steps(1) infinite;
background-color: #7e7
}
@-moz-keyframes blink {
0% {}
50% {
background-color: transparent
}
100% {}
}
@-webkit-keyframes blink {
0% {}
50% {
background-color: transparent
}
100% {}
}
@keyframes blink {
0% {}
50% {
background-color: transparent
}
100% {}
}
.CodeMirror-overwrite .CodeMirror-cursor {}
.cm-tab {
display: inline-block;
text-decoration: inherit
}
.CodeMirror-rulers {
position: absolute;
left: 0;
right: 0;
top: -50px;
bottom: 0;
overflow: hidden
}
.CodeMirror-ruler {
border-left: 1px solid #ccc;
top: 0;
bottom: 0;
position: absolute
}
.cm-s-default .cm-header {
color: blue
}
.cm-s-default .cm-quote {
color: #090
}
.cm-negative {
color: #d44
}
.cm-positive {
color: #292
}
.cm-header,
.cm-strong {
font-weight: 700
}
.cm-em {
font-style: italic
}
.cm-link {
text-decoration: underline
}
.cm-strikethrough {
text-decoration: line-through
}
.cm-s-default .cm-keyword {
color: #708
}
.cm-s-default .cm-atom {
color: #219
}
.cm-s-default .cm-number {
color: #164
}
.cm-s-default .cm-def {
color: #00f
}
.cm-s-default .cm-variable,
.cm-s-default .cm-punctuation,
.cm-s-default .cm-property,
.cm-s-default .cm-operator {}
.cm-s-default .cm-variable-2 {
color: #05a
}
.cm-s-default .cm-variable-3,
.cm-s-default .cm-type {
color: #085
}
.cm-s-default .cm-comment {
color: #a50
}
.cm-s-default .cm-string {
color: #a11
}
.cm-s-default .cm-string-2 {
color: #f50
}
.cm-s-default .cm-meta {
color: #555
}
.cm-s-default .cm-qualifier {
color: #555
}
.cm-s-default .cm-builtin {
color: #30a
}
.cm-s-default .cm-bracket {
color: #997
}
.cm-s-default .cm-tag {
color: #170
}
.cm-s-default .cm-attribute {
color: #00c
}
.cm-s-default .cm-hr {
color: #999
}
.cm-s-default .cm-link {
color: #00c
}
.cm-s-default .cm-error {
color: red
}
.cm-invalidchar {
color: red
}
.CodeMirror-composing {
border-bottom: 2px solid
}
div.CodeMirror span.CodeMirror-matchingbracket {
color: #0b0
}
div.CodeMirror span.CodeMirror-nonmatchingbracket {
color: #a22
}
.CodeMirror-matchingtag {
background: rgba(255, 150, 0, .3)
}
.CodeMirror-activeline-background {
background: #e8f2ff
}
.CodeMirror {
position: relative;
overflow: hidden;
background: #fff
}
.CodeMirror-scroll {
overflow: scroll!important;
margin-bottom: -30px;
margin-right: -30px;
padding-bottom: 30px;
height: 100%;
outline: none;
position: relative
}
.CodeMirror-sizer {
position: relative;
border-right: 30px solid transparent
}
.CodeMirror-vscrollbar,
.CodeMirror-hscrollbar,
.CodeMirror-scrollbar-filler,
.CodeMirror-gutter-filler {
position: absolute;
z-index: 6;
display: none
}
.CodeMirror-vscrollbar {
right: 0;
top: 0;
overflow-x: hidden;
overflow-y: scroll
}
.CodeMirror-hscrollbar {
bottom: 0;
left: 0;
overflow-y: hidden;
overflow-x: scroll
}
.CodeMirror-scrollbar-filler {
right: 0;
bottom: 0
}
.CodeMirror-gutter-filler {
left: 0;
bottom: 0
}
.CodeMirror-gutters {
position: absolute;
left: 0;
top: 0;
min-height: 100%;
z-index: 3
}
.CodeMirror-gutter {
white-space: normal;
height: 100%;
display: inline-block;
vertical-align: top;
margin-bottom: -30px
}
.CodeMirror-gutter-wrapper {
position: absolute;
z-index: 4;
background: 0 0!important;
border: none!important
}
.CodeMirror-gutter-background {
position: absolute;
top: 0;
bottom: 0;
z-index: 4
}
.CodeMirror-gutter-elt {
position: absolute;
cursor: default;
z-index: 4
}
.CodeMirror-gutter-wrapper::selection {
background-color: transparent
}
.CodeMirror-gutter-wrapper::-moz-selection {
background-color: transparent
}
.CodeMirror-lines {
cursor: text;
min-height: 1px
}
.CodeMirror pre.CodeMirror-line,
.CodeMirror pre.CodeMirror-line-like {
-moz-border-radius: 0;
-webkit-border-radius: 0;
border-radius: 0;
border-width: 0;
background: 0 0;
font-family: inherit;
font-size: inherit;
margin: 0;
white-space: pre;
word-wrap: normal;
line-height: inherit;
color: inherit;
z-index: 2;
position: relative;
overflow: visible;
-webkit-tap-highlight-color: transparent;
-webkit-font-variant-ligatures: contextual;
font-variant-ligatures: contextual
}
.CodeMirror-wrap pre.CodeMirror-line,
.CodeMirror-wrap pre.CodeMirror-line-like {
word-wrap: break-word;
white-space: pre-wrap;
word-break: normal
}
.CodeMirror-linebackground {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
z-index: 0
}
.CodeMirror-linewidget {
position: relative;
z-index: 2;
padding: .1px
}
.CodeMirror-widget {}
.CodeMirror-rtl pre {
direction: rtl
}
.CodeMirror-code {
outline: none
}
.CodeMirror-scroll,
.CodeMirror-sizer,
.CodeMirror-gutter,
.CodeMirror-gutters,
.CodeMirror-linenumber {
-moz-box-sizing: content-box;
box-sizing: content-box
}
.CodeMirror-measure {
position: absolute;
width: 100%;
height: 0;
overflow: hidden;
visibility: hidden
}
.CodeMirror-cursor {
position: absolute;
pointer-events: none
}
.CodeMirror-measure pre {
position: static
}
div.CodeMirror-cursors {
visibility: hidden;
position: relative;
z-index: 3
}
div.CodeMirror-dragcursors {
visibility: visible
}
.CodeMirror-focused div.CodeMirror-cursors {
visibility: visible
}
.CodeMirror-selected {
background: #d9d9d9
}
.CodeMirror-focused .CodeMirror-selected {
background: #d7d4f0
}
.CodeMirror-crosshair {
cursor: crosshair
}
.CodeMirror-line::selection,
.CodeMirror-line>span::selection,
.CodeMirror-line>span>span::selection {
background: #d7d4f0
}
.CodeMirror-line::-moz-selection,
.CodeMirror-line>span::-moz-selection,
.CodeMirror-line>span>span::-moz-selection {
background: #d7d4f0
}
.cm-searching {
background-color: #ffa;
background-color: rgba(255, 255, 0, .4)
}
.cm-force-border {
padding-right: .1px
}
@media print {
.CodeMirror div.CodeMirror-cursors {
visibility: hidden
}
}
.cm-tab-wrap-hack:after {
content: ''
}
span.CodeMirror-selectedtext {
background: 0 0
}
File diff suppressed because one or more lines are too long
-217
View File
@@ -1,217 +0,0 @@
[data-simplebar] {
position: relative;
flex-direction: column;
flex-wrap: wrap;
justify-content: flex-start;
align-content: flex-start;
align-items: flex-start;
}
.simplebar-wrapper {
overflow: hidden;
width: inherit;
height: inherit;
max-width: inherit;
max-height: inherit;
}
.simplebar-mask {
direction: inherit;
position: absolute;
overflow: hidden;
padding: 0;
margin: 0;
left: 0;
top: 0;
bottom: 0;
right: 0;
width: auto !important;
height: auto !important;
z-index: 0;
}
.simplebar-offset {
direction: inherit !important;
box-sizing: inherit !important;
resize: none !important;
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
padding: 0;
margin: 0;
-webkit-overflow-scrolling: touch;
}
.simplebar-content-wrapper {
direction: inherit;
box-sizing: border-box !important;
position: relative;
display: block;
height: 100%; /* Required for horizontal native scrollbar to not appear if parent is taller than natural height */
width: auto;
max-width: 100%; /* Not required for horizontal scroll to trigger */
max-height: 100%; /* Needed for vertical scroll to trigger */
scrollbar-width: none;
-ms-overflow-style: none;
}
.simplebar-content-wrapper::-webkit-scrollbar,
.simplebar-hide-scrollbar::-webkit-scrollbar {
width: 0;
height: 0;
}
.simplebar-content:before,
.simplebar-content:after {
content: ' ';
display: table;
}
.simplebar-placeholder {
max-height: 100%;
max-width: 100%;
width: 100%;
pointer-events: none;
}
.simplebar-height-auto-observer-wrapper {
box-sizing: inherit !important;
height: 100%;
width: 100%;
max-width: 1px;
position: relative;
float: left;
max-height: 1px;
overflow: hidden;
z-index: -1;
padding: 0;
margin: 0;
pointer-events: none;
flex-grow: inherit;
flex-shrink: 0;
flex-basis: 0;
}
.simplebar-height-auto-observer {
box-sizing: inherit;
display: block;
opacity: 0;
position: absolute;
top: 0;
left: 0;
height: 1000%;
width: 1000%;
min-height: 1px;
min-width: 1px;
overflow: hidden;
pointer-events: none;
z-index: -1;
}
.simplebar-track {
z-index: 1;
position: absolute;
right: 0;
bottom: 0;
pointer-events: none;
overflow: hidden;
}
[data-simplebar].simplebar-dragging .simplebar-content {
pointer-events: none;
user-select: none;
-webkit-user-select: none;
}
[data-simplebar].simplebar-dragging .simplebar-track {
pointer-events: all;
}
.simplebar-scrollbar {
position: absolute;
left: 0;
right: 0;
min-height: 10px;
}
.simplebar-scrollbar:before {
position: absolute;
content: '';
background: black;
border-radius: 7px;
left: 2px;
right: 2px;
opacity: 0;
transition: opacity 0.2s linear;
}
.simplebar-scrollbar.simplebar-visible:before {
/* When hovered, remove all transitions from drag handle */
opacity: 0.5;
transition: opacity 0s linear;
}
.simplebar-track.simplebar-vertical {
top: 0;
width: 11px;
}
.simplebar-track.simplebar-vertical .simplebar-scrollbar:before {
top: 2px;
bottom: 2px;
}
.simplebar-track.simplebar-horizontal {
left: 0;
height: 11px;
}
.simplebar-track.simplebar-horizontal .simplebar-scrollbar:before {
height: 100%;
left: 2px;
right: 2px;
}
.simplebar-track.simplebar-horizontal .simplebar-scrollbar {
right: auto;
left: 0;
top: 2px;
height: 7px;
min-height: 0;
min-width: 10px;
width: auto;
}
/* Rtl support */
[data-simplebar-direction='rtl'] .simplebar-track.simplebar-vertical {
right: auto;
left: 0;
}
.hs-dummy-scrollbar-size {
direction: rtl;
position: fixed;
opacity: 0;
visibility: hidden;
height: 500px;
width: 500px;
overflow-y: hidden;
overflow-x: scroll;
}
.simplebar-hide-scrollbar {
position: fixed;
left: 0;
visibility: hidden;
overflow-y: scroll;
scrollbar-width: none;
-ms-overflow-style: none;
}
.simplebar-content {
display: flex;
flex-direction: column;
min-height: 100%;
}
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
-402
View File
@@ -1,402 +0,0 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: https://codemirror.net/LICENSE
(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
mod(require("../../lib/codemirror"));
else if (typeof define == "function" && define.amd) // AMD
define(["../../lib/codemirror"], mod);
else // Plain browser env
mod(CodeMirror);
})(function(CodeMirror) {
"use strict";
var htmlConfig = {
autoSelfClosers: {'area': true, 'base': true, 'br': true, 'col': true, 'command': true,
'embed': true, 'frame': true, 'hr': true, 'img': true, 'input': true,
'keygen': true, 'link': true, 'meta': true, 'param': true, 'source': true,
'track': true, 'wbr': true, 'menuitem': true},
implicitlyClosed: {'dd': true, 'li': true, 'optgroup': true, 'option': true, 'p': true,
'rp': true, 'rt': true, 'tbody': true, 'td': true, 'tfoot': true,
'th': true, 'tr': true},
contextGrabbers: {
'dd': {'dd': true, 'dt': true},
'dt': {'dd': true, 'dt': true},
'li': {'li': true},
'option': {'option': true, 'optgroup': true},
'optgroup': {'optgroup': true},
'p': {'address': true, 'article': true, 'aside': true, 'blockquote': true, 'dir': true,
'div': true, 'dl': true, 'fieldset': true, 'footer': true, 'form': true,
'h1': true, 'h2': true, 'h3': true, 'h4': true, 'h5': true, 'h6': true,
'header': true, 'hgroup': true, 'hr': true, 'menu': true, 'nav': true, 'ol': true,
'p': true, 'pre': true, 'section': true, 'table': true, 'ul': true},
'rp': {'rp': true, 'rt': true},
'rt': {'rp': true, 'rt': true},
'tbody': {'tbody': true, 'tfoot': true},
'td': {'td': true, 'th': true},
'tfoot': {'tbody': true},
'th': {'td': true, 'th': true},
'thead': {'tbody': true, 'tfoot': true},
'tr': {'tr': true}
},
doNotIndent: {"pre": true},
allowUnquoted: true,
allowMissing: true,
caseFold: true
}
var xmlConfig = {
autoSelfClosers: {},
implicitlyClosed: {},
contextGrabbers: {},
doNotIndent: {},
allowUnquoted: false,
allowMissing: false,
allowMissingTagName: false,
caseFold: false
}
CodeMirror.defineMode("xml", function(editorConf, config_) {
var indentUnit = editorConf.indentUnit
var config = {}
var defaults = config_.htmlMode ? htmlConfig : xmlConfig
for (var prop in defaults) config[prop] = defaults[prop]
for (var prop in config_) config[prop] = config_[prop]
// Return variables for tokenizers
var type, setStyle;
function inText(stream, state) {
function chain(parser) {
state.tokenize = parser;
return parser(stream, state);
}
var ch = stream.next();
if (ch == "<") {
if (stream.eat("!")) {
if (stream.eat("[")) {
if (stream.match("CDATA[")) return chain(inBlock("atom", "]]>"));
else return null;
} else if (stream.match("--")) {
return chain(inBlock("comment", "-->"));
} else if (stream.match("DOCTYPE", true, true)) {
stream.eatWhile(/[\w\._\-]/);
return chain(doctype(1));
} else {
return null;
}
} else if (stream.eat("?")) {
stream.eatWhile(/[\w\._\-]/);
state.tokenize = inBlock("meta", "?>");
return "meta";
} else {
type = stream.eat("/") ? "closeTag" : "openTag";
state.tokenize = inTag;
return "tag bracket";
}
} else if (ch == "&") {
var ok;
if (stream.eat("#")) {
if (stream.eat("x")) {
ok = stream.eatWhile(/[a-fA-F\d]/) && stream.eat(";");
} else {
ok = stream.eatWhile(/[\d]/) && stream.eat(";");
}
} else {
ok = stream.eatWhile(/[\w\.\-:]/) && stream.eat(";");
}
return ok ? "atom" : "error";
} else {
stream.eatWhile(/[^&<]/);
return null;
}
}
inText.isInText = true;
function inTag(stream, state) {
var ch = stream.next();
if (ch == ">" || (ch == "/" && stream.eat(">"))) {
state.tokenize = inText;
type = ch == ">" ? "endTag" : "selfcloseTag";
return "tag bracket";
} else if (ch == "=") {
type = "equals";
return null;
} else if (ch == "<") {
state.tokenize = inText;
state.state = baseState;
state.tagName = state.tagStart = null;
var next = state.tokenize(stream, state);
return next ? next + " tag error" : "tag error";
} else if (/[\'\"]/.test(ch)) {
state.tokenize = inAttribute(ch);
state.stringStartCol = stream.column();
return state.tokenize(stream, state);
} else {
stream.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/);
return "word";
}
}
function inAttribute(quote) {
var closure = function(stream, state) {
while (!stream.eol()) {
if (stream.next() == quote) {
state.tokenize = inTag;
break;
}
}
return "string";
};
closure.isInAttribute = true;
return closure;
}
function inBlock(style, terminator) {
return function(stream, state) {
while (!stream.eol()) {
if (stream.match(terminator)) {
state.tokenize = inText;
break;
}
stream.next();
}
return style;
}
}
function doctype(depth) {
return function(stream, state) {
var ch;
while ((ch = stream.next()) != null) {
if (ch == "<") {
state.tokenize = doctype(depth + 1);
return state.tokenize(stream, state);
} else if (ch == ">") {
if (depth == 1) {
state.tokenize = inText;
break;
} else {
state.tokenize = doctype(depth - 1);
return state.tokenize(stream, state);
}
}
}
return "meta";
};
}
function Context(state, tagName, startOfLine) {
this.prev = state.context;
this.tagName = tagName;
this.indent = state.indented;
this.startOfLine = startOfLine;
if (config.doNotIndent.hasOwnProperty(tagName) || (state.context && state.context.noIndent))
this.noIndent = true;
}
function popContext(state) {
if (state.context) state.context = state.context.prev;
}
function maybePopContext(state, nextTagName) {
var parentTagName;
while (true) {
if (!state.context) {
return;
}
parentTagName = state.context.tagName;
if (!config.contextGrabbers.hasOwnProperty(parentTagName) ||
!config.contextGrabbers[parentTagName].hasOwnProperty(nextTagName)) {
return;
}
popContext(state);
}
}
function baseState(type, stream, state) {
if (type == "openTag") {
state.tagStart = stream.column();
return tagNameState;
} else if (type == "closeTag") {
return closeTagNameState;
} else {
return baseState;
}
}
function tagNameState(type, stream, state) {
if (type == "word") {
state.tagName = stream.current();
setStyle = "tag";
return attrState;
} else if (config.allowMissingTagName && type == "endTag") {
setStyle = "tag bracket";
return attrState(type, stream, state);
} else {
setStyle = "error";
return tagNameState;
}
}
function closeTagNameState(type, stream, state) {
if (type == "word") {
var tagName = stream.current();
if (state.context && state.context.tagName != tagName &&
config.implicitlyClosed.hasOwnProperty(state.context.tagName))
popContext(state);
if ((state.context && state.context.tagName == tagName) || config.matchClosing === false) {
setStyle = "tag";
return closeState;
} else {
setStyle = "tag error";
return closeStateErr;
}
} else if (config.allowMissingTagName && type == "endTag") {
setStyle = "tag bracket";
return closeState(type, stream, state);
} else {
setStyle = "error";
return closeStateErr;
}
}
function closeState(type, _stream, state) {
if (type != "endTag") {
setStyle = "error";
return closeState;
}
popContext(state);
return baseState;
}
function closeStateErr(type, stream, state) {
setStyle = "error";
return closeState(type, stream, state);
}
function attrState(type, _stream, state) {
if (type == "word") {
setStyle = "attribute";
return attrEqState;
} else if (type == "endTag" || type == "selfcloseTag") {
var tagName = state.tagName, tagStart = state.tagStart;
state.tagName = state.tagStart = null;
if (type == "selfcloseTag" ||
config.autoSelfClosers.hasOwnProperty(tagName)) {
maybePopContext(state, tagName);
} else {
maybePopContext(state, tagName);
state.context = new Context(state, tagName, tagStart == state.indented);
}
return baseState;
}
setStyle = "error";
return attrState;
}
function attrEqState(type, stream, state) {
if (type == "equals") return attrValueState;
if (!config.allowMissing) setStyle = "error";
return attrState(type, stream, state);
}
function attrValueState(type, stream, state) {
if (type == "string") return attrContinuedState;
if (type == "word" && config.allowUnquoted) {setStyle = "string"; return attrState;}
setStyle = "error";
return attrState(type, stream, state);
}
function attrContinuedState(type, stream, state) {
if (type == "string") return attrContinuedState;
return attrState(type, stream, state);
}
return {
startState: function(baseIndent) {
var state = {tokenize: inText,
state: baseState,
indented: baseIndent || 0,
tagName: null, tagStart: null,
context: null}
if (baseIndent != null) state.baseIndent = baseIndent
return state
},
token: function(stream, state) {
if (!state.tagName && stream.sol())
state.indented = stream.indentation();
if (stream.eatSpace()) return null;
type = null;
var style = state.tokenize(stream, state);
if ((style || type) && style != "comment") {
setStyle = null;
state.state = state.state(type || style, stream, state);
if (setStyle)
style = setStyle == "error" ? style + " error" : setStyle;
}
return style;
},
indent: function(state, textAfter, fullLine) {
var context = state.context;
// Indent multi-line strings (e.g. css).
if (state.tokenize.isInAttribute) {
if (state.tagStart == state.indented)
return state.stringStartCol + 1;
else
return state.indented + indentUnit;
}
if (context && context.noIndent) return CodeMirror.Pass;
if (state.tokenize != inTag && state.tokenize != inText)
return fullLine ? fullLine.match(/^(\s*)/)[0].length : 0;
// Indent the starts of attribute names.
if (state.tagName) {
if (config.multilineTagIndentPastTag !== false)
return state.tagStart + state.tagName.length + 2;
else
return state.tagStart + indentUnit * (config.multilineTagIndentFactor || 1);
}
if (config.alignCDATA && /<!\[CDATA\[/.test(textAfter)) return 0;
var tagAfter = textAfter && /^<(\/)?([\w_:\.-]*)/.exec(textAfter);
if (tagAfter && tagAfter[1]) { // Closing tag spotted
while (context) {
if (context.tagName == tagAfter[2]) {
context = context.prev;
break;
} else if (config.implicitlyClosed.hasOwnProperty(context.tagName)) {
context = context.prev;
} else {
break;
}
}
} else if (tagAfter) { // Opening tag spotted
while (context) {
var grabbers = config.contextGrabbers[context.tagName];
if (grabbers && grabbers.hasOwnProperty(tagAfter[2]))
context = context.prev;
else
break;
}
}
while (context && context.prev && !context.startOfLine)
context = context.prev;
if (context) return context.indent + indentUnit;
else return state.baseIndent || 0;
},
electricInput: /<\/[\s\w:]+>$/,
blockCommentStart: "<!--",
blockCommentEnd: "-->",
configuration: config.htmlMode ? "html" : "xml",
helperType: config.htmlMode ? "html" : "xml",
skipAttribute: function(state) {
if (state.state == attrValueState)
state.state = attrState
}
};
});
CodeMirror.defineMIME("text/xml", "xml");
CodeMirror.defineMIME("application/xml", "xml");
if (!CodeMirror.mimeModes.hasOwnProperty("text/html"))
CodeMirror.defineMIME("text/html", {name: "xml", htmlMode: true});
});
+134 -95
View File
@@ -17,7 +17,6 @@ var FoniaJS = {
APP_ID: 0,
APP_SID: "",
WEB_HOST: "",
WEB_PATH: "",
WEB_FULLPATH: "",
WEB_MOBILE: 0,
AUTH_LEVEL: 9,
@@ -35,11 +34,10 @@ var FoniaJS = {
this.APP_ID = _adata[0];
this.APP_SID = _adata[1];
this.WEB_HOST = _adata[2];
this.WEB_PATH = _adata[3];
this.WEB_FULLPATH = _adata[4];
this.WEB_MOBILE = _adata[5];
this.AUTH_LEVEL = parseInt(_adata[6]);
this.phpversion = _adata[7];
this.WEB_FULLPATH = _adata[3];
this.WEB_MOBILE = _adata[4];
this.AUTH_LEVEL = parseInt(_adata[5]);
this.phpversion = '';
}
if (typeof(skey) === 'string' && skey !== '') {
_hasil = $.base64.decode(skey);
@@ -62,38 +60,36 @@ var FoniaJS = {
var apar = ["p=" + p];
if (q != null) apar.push("q=" + q);
new Request.JSON({
url: this.WEB_PATH + "auth.php",
url: "auth/menu",
sendParam: apar,
onSuccess: (apop) => {
if (apop.login == false) {
this.showErrorLocale("Fonia.sess_expire");
setTimeout(function(){self.location = FoniaJS.WEB_PATH;}, 1600);
setTimeout(() => { self.location = self.location.href; }, 1600);
return false;
}
if (apop.php == "" || !window[apop.func]) {
this.showErrorLocale("Fonia.page404");
return false;
}
window[apop.func]['PHP'] = this.WEB_PATH + "apps/php/" + apop.php;
window[apop.func]['PHP'] = apop.php;
window[apop.func]['KODE'] = apop.kode;
if (apop.iswindow == true) {
if (IndexJS.loading) IndexJS.loading();
new Request({
url: this.WEB_PATH + "apps/php/" + apop.php,
sendParam: ["data=default"],
onSuccess: (txt) => {
this.showWindow(apop.kode, apop.title, txt, apop.width, apop.button, function(){
new Request.JSON({
url: apop.php + '/index',
onSuccess: (ajson) => {
this.showWindow(apop.kode, apop.title, ajson.html, apop.width, apop.button, () => {
if (typeof window[apop.func]['loading'] === 'function') window[apop.func]['loading'](q);
});
}
}).send();
} else {
$("#pageToolbarBot").html(this.genToolButton(apop.button));
new Request({
url: this.WEB_PATH + "apps/php/" + apop.php,
sendParam: ["data=default"],
onSuccess: (txt) => {
$('#pageContent').html(txt);
new Request.JSON({
url: apop.php + '/index',
onSuccess: (ajson) => {
$('#pageContent').html(ajson.html);
if (typeof window[apop.func]['loading'] === 'function') window[apop.func]['loading'](q);
}
}).send();
@@ -122,13 +118,12 @@ var FoniaJS = {
if ($('#ExitLink').length) {
$('#ExitLink').click(() => {
new Request.JSON({
url: this.WEB_PATH + "apps/php/login.php",
sendParam: ["mode=logout"],
url: "auth/logout",
onFailure: () => {
self.location = (['localhost','127.0.0.1'].indexOf(location.hostname) >= 0) ? this.WEB_PATH : "/";
self.location = self.location.href;
},
onSuccess: (respon) => {
var _nurl = (['localhost','127.0.0.1'].indexOf(location.hostname) >= 0) ? this.WEB_PATH : "/";
var _nurl = self.location.href;
if (typeof respon !== 'undefined' && respon.nexthost !== '/') _nurl = respon.nexthost;
self.location = _nurl;
}
@@ -167,8 +162,8 @@ var FoniaJS = {
$('#butSOK').click(() => {
$('#butSOK').prop('disabled', true);
new Request.JSON({
url: this.WEB_PATH + "auth.php",
sendParam: ["mode=auth", "data=super-check", "UID", "PWD", "SUPER=" + _bsuper, "UOVER=" + _buover],
url: "auth/supervisi",
sendParam: ["data=super-check", "UID", "PWD", "SUPER=" + _bsuper, "UOVER=" + _buover],
onSuccess: (adata) => {
if (adata.status == 1) {
fungcall();
@@ -182,9 +177,9 @@ var FoniaJS = {
$('#butSBatal').click(() => {
if (_ceksuper) {
clearInterval(_ceksuper);
new Request({
url: this.WEB_PATH + "auth.php",
sendParam: ["mode=auth", "data=super-cancel", "KODE=" + ocall.KODE, "REQ_SID=" + this.APP_SID, "REQ=" + _tsid]
new Request.JSON({
url: "auth/supervisi",
sendParam: ["data=super-cancel", "KODE=" + ocall.KODE, "REQ_SID=" + this.APP_SID, "REQ=" + _tsid]
}).send();
}
});
@@ -194,26 +189,26 @@ var FoniaJS = {
$('#Auth_SP2').addClass('d-none');
$('#Auth_SP3').removeClass('d-none');
$('#butSOK').prop('disabled', true);
new Request({
url: this.WEB_PATH + "auth.php",
sendParam: ["mode=auth", "data=super-request", "KODE=" + ocall.KODE, "REQ_SID=" + this.APP_SID, "REQ=" + _tsid, "MSG=" + tmsg]
new Request.JSON({
url: "auth/supervisi",
sendParam: ["data=super-request", "KODE=" + ocall.KODE, "REQ_SID=" + this.APP_SID, "REQ=" + _tsid, "MSG=" + tmsg]
}).send();
var _cobalagi = 5;
_ceksuper = setInterval(() => {
$('#butSBatal').html(this.locale("Fonia.cancel") + " (" + _cobalagi + ")");
if (_cobalagi == 0) {
clearInterval(_ceksuper);
new Request({
url: this.WEB_PATH + "auth.php",
sendParam: ["mode=auth", "data=super-cancel", "KODE=" + ocall.KODE, "REQ_SID=" + this.APP_SID, "REQ=" + _tsid]
new Request.JSON({
url: "auth/supervisi",
sendParam: ["data=super-cancel", "KODE=" + ocall.KODE, "REQ_SID=" + this.APP_SID, "REQ=" + _tsid]
}).send();
this.closeWindow(this.winSAuth);
this.showErrorLocale("Fonia.auth_fail");
return false;
}
new Request.JSON({
url: this.WEB_PATH + "auth.php",
sendParam: ["mode=auth", "data=request-check", "KODE=" + ocall.KODE, "REQ_SID=" + this.APP_SID, "REQ=" + _tsid],
url: "auth/supervisi",
sendParam: ["data=request-check", "KODE=" + ocall.KODE, "REQ_SID=" + this.APP_SID, "REQ=" + _tsid],
onSuccess: (adata) => {
if (adata.status == 1) {
clearInterval(_ceksuper);
@@ -290,48 +285,91 @@ var FoniaJS = {
return smenu;
},
FormDecorated: function() {
$('input').each((i, el) => {
$('input.form-control[class*=integer], input.form-control[class*=angka]').each((i, el) => {
const elm = $(el);
// 16:shift 17:ctrl 18:alt 35:end 36:home 37:left 38:up 39:right 40:down 9:tab 13:enter 27:esc
// 8:backspace 46:delete 45:delete 48-57/96-105:num 110/190:dot 109/189/173:minus 107/187/61:plus
if (elm.hasClass('integer') || elm.hasClass('angka')) {
elm.keydown((e) => {
var key = e.keyCode ?? e.which;
return (jQuery.inArray(key,[8,9,13,46,110,190])!==-1 || (key>=16 && key<=18) || (key>=35 && key<=40) || (key>=48 && key<=57) || (key>=96 && key<=105));
elm.on('keypress keyup blur paste', (e) => {
elm.val(elm.val().replace(/[^\d].+/, ""));
if ((e.which < 48 || e.which > 57)) e.preventDefault();
});
} else if (elm.hasClass('number')) {
elm.keydown((e) => {
var key = e.keyCode ?? e.which;
return (jQuery.inArray(key,[8,9,13,46,110,190,109,189,173])!==-1 || (key>=16 && key<=18) || (key>=35 && key<=40) || (key>=48 && key<=57) || (key>=96 && key<=105));
});
elm.focus((e) => {
$(e.currentTarget).val( FoniaJS.StrToFloat($(e.currentTarget).val()) );
$('input.form-control[class*=double]').each((i, el) => {
const elm = $(el);
elm.on('keypress keyup blur paste', (e) => {
elm.val(elm.val().replace(/[^0-9\.]/g,''));
if (e.type === 'blur') elm.val( FoniaJS.FloatToStr(elm.val(), 2) );
if ((e.which != 46 || elm.val().indexOf('.') != -1) && (e.which < 48 || e.which > 57)) e.preventDefault();
});
elm.blur((e) => {
$(e.currentTarget).val( FoniaJS.FloatToStr($(e.currentTarget).val(), 0) );
elm.on('focus', (e) => {
elm.val( FoniaJS.StrToFloat(elm.val()) );
elm.select();
e.preventDefault();
});
} else if (elm.hasClass('double')) {
elm.keydown((e) => {
var key = e.keyCode ?? e.which;
return (jQuery.inArray(key,[8,9,13,46,110,190,109,189,173])!==-1 || (key>=16 && key<=18) || (key>=35 && key<=40) || (key>=48 && key<=57) || (key>=96 && key<=105));
});
elm.focus((e) => {
$(e.currentTarget).val( FoniaJS.StrToFloat($(e.currentTarget).val()) );
$(e.currentTarget).select();
$('input.form-control[type=number]').each((i, el) => {
const elm = $(el);
elm.on('keypress keyup blur paste', (e) => {
elm.val(elm.val().replace(/[^0-9]/g,''));
if ((e.which != 46 || elm.val().indexOf('.') != -1) && (e.which < 48 || e.which > 57)) e.preventDefault();
});
elm.blur((e) => {
$(e.currentTarget).val( FoniaJS.FloatToStr($(e.currentTarget).val(), 2) );
});
} else if (elm.hasClass('phone')) {
elm.keyup((e) => {
var key = e.keyCode ?? e.which;
return (jQuery.inArray(key,[8,9,13,46,110,190,109,189,173,107,187,61])!==-1 || (key>=16 && key<=18) || (key>=35 && key<=40) || (key>=48 && key<=57) || (key>=96 && key<=105));
});
} else if (elm.hasClass('error') && elm.val()) {
var tmp_str = elm.val();
elm.val('');
FoniaJS.showError(tmp_str);
$('input.form-control, textarea.form-control, select.form-select').each((i, el) => {
const elm = $(el);
const okyup = elm.attr('okyup') ?? '';
const oblur = elm.attr('oblur') ?? '';
const ochan = elm.attr('ochan') ?? '';
elm.on('keyup blur change', (e) => {
if (e.type === 'keyup' && okyup) {
var fnc = okyup.split('.');
if (typeof window[fnc[0]][fnc[1]] === 'function'){
window[fnc[0]][fnc[1]]();
} else console.warn('fungsi '+okyup+' tidak ada !');
}
if (e.type === 'blur' && oblur) {
var fnc = oblur.split('.');
if (typeof window[fnc[0]][fnc[1]] === 'function'){
window[fnc[0]][fnc[1]]();
} else console.warn('fungsi '+oblur+' tidak ada !');
}
if (e.type === 'change' && ochan) {
var fnc = ochan.split('.');
if (typeof window[fnc[0]][fnc[1]] === 'function'){
window[fnc[0]][fnc[1]]();
} else console.warn('fungsi '+ochan+' tidak ada !');
}
e.preventDefault();
});
});
$('input.form-check-input[type=radio]').each((i, el) => {
const elm = $(el);
elm.on('click', () => {
const oclic = elm.attr('ochan') ?? '';
const elp = $('#'+elm.attr('name'));
if (elm.is(':checked')) elp.val(elm.val());
if (oclic) {
var fnc = oclic.split('.');
if (typeof window[fnc[0]][fnc[1]] === 'function'){
window[fnc[0]][fnc[1]]();
} else console.warn('fungsi '+oclic+' tidak ada !');
}
});
});
$('input.form-check-input[type=checkbox]').each((i, el) => {
const elm = $(el);
elm.on('change', () => {
const odata = JSON.parse(elm.attr('odata') ?? '[]');
const ochan = elm.attr('ochan') ?? '';
elm.val(elm.is(':checked') ? odata[0] : odata[1]);
if (ochan) {
var fnc = ochan.split('.');
if (typeof window[fnc[0]][fnc[1]] === 'function'){
window[fnc[0]][fnc[1]]();
} else console.warn('fungsi '+ochan+' tidak ada !');
}
});
});
$('input[class*=error][type=hidden]').each((i, el) => {
const elm = $(el);
this.showError(elm.val());
});
$('.option-tags').each((i, el) => {
const elm = $(el);
@@ -345,7 +383,7 @@ var FoniaJS = {
});
$('[data-toggle="tooltip"]').tooltip();
if('function' == typeof jQuery.fn.datepicker){
$('.pickdate').datepicker({
$('.input-group.date').datepicker({
format: 'dd-mm-yyyy',
weekStart: 1,
language: 'id',
@@ -360,11 +398,6 @@ var FoniaJS = {
RequestParam: function(aparam) {
var tmp_hasil = [];
var tmp_array = aparam;
/*$('input').each((i, el) => {
if (el.id.indexOf('_db')!==-1){
tmp_array.push(el.id);
}
});*/
var tmp_cblist = {};
$('tbody input[id*="cbox"][type="checkbox"]:checked').map((i, b) => {
const arr = b.id.split('_');
@@ -387,15 +420,6 @@ var FoniaJS = {
} else {
tmp_value = ($('#'+nilai).is('.integer, .number, .double')) ? this.StrToFloat(tmp_value) : encodeURIComponent(tmp_value);
}
/*if ($('#'+nilai).hasClass("cgrpbox")) {//not used !
var _tmp_value = "";
$('input').each((i, el) => {
if (el.id.indexOf(nilai + "_cgrpbox")!==-1 && el.checked) {
_tmp_value += "," + el.value;
}
});
tmp_value = _tmp_value.substr(1);
}*/
}
tmp_value = nilai + "=" + tmp_value;
} else {
@@ -794,7 +818,7 @@ class _Request_JSONF extends _Request {
dataFilter: (data) => {
var json = {}, jsono = {'draw':0,'recordsTotal':0,'recordsFiltered':0,'data':[]};
try {
json = jQuery.parseJSON(data);
json = JSON.parse(data);
if (!jQuery.isEmptyObject(json) && json.length > 0){
$(json).each((i, lini) => {
if (lini.type == 'table-live' && lini.id == ini.id) {
@@ -841,7 +865,7 @@ class _Request_JSONF extends _Request {
}
/** end live db **/
if (ini.option.length > 0) opsi.columnDefs.push({responsivePriority:3,targets:-1}, {orderable:false,targets:-1});
if (ini.navi.func_navi == '') opsi.paging = false;
if (ini.navi.no_navi == true) opsi.paging = false;
if (ini.config.scrollbar == true) {
opsi.scrollY = ini.config.scroll_height;
@@ -858,12 +882,26 @@ class _Request_JSONF extends _Request {
}
_navibar += '<div class="row"><div class="col">';
$(ini.navi.button).map((key, val) => {
_navibar += '<button type="button" class="btn rounded-pill '+_bcss+' me-2"'+_dis+' onclick="'+val.func+'();">'+val.label+'</button>';
_navibar += '<button type="button" class="btn rounded-pill '+_bcss+' me-2 navi-btn-'+key+'"'+_dis+'>'+val.label+'</button>';
});
_navibar += '</div></div>';
}
opsi.initComplete = function(settings,json){
if (ini.navi.button) $('#'+ini.id+'Tabel_wrapper div.toolbar').html(_navibar);
if (ini.navi.button) {
$('#'+ini.id+'Tabel_wrapper div.toolbar').html(_navibar);
// apply navi button
if (ini.navi.button.length > 0){
$(ini.navi.button).map((key, val) => {
$('#'+ini.id+'Tabel_wrapper div.toolbar button[class*=navi-btn-'+key+']').on('click', (e) => {
e.preventDefault();
var fnc = val.func.split('.');
if (typeof window[fnc[0]][fnc[1]] === 'function'){
window[fnc[0]][fnc[1]]();
} else console.warn('fungsi '+val.func+' tidak ada !');
});
});
}
}
}
opsi.drawCallback = function(settings){
// apply rowcss to tr/row
@@ -908,16 +946,16 @@ class _Request_JSONF extends _Request {
$(ini.option).map((key, val) => {
if (val.type == 'checkbox'){
$('#'+ini.id+'Tabel thead input[type=checkbox][id*=_cbhead_]').on('change', (e) => {
var _chek = e.currentTarget.checked;
e.currentTarget.value = (e.currentTarget.checked ? val.avalue[0] : val.avalue[1]);
var _chek = e.currentTarget.is(':checked');
e.currentTarget.val(e.currentTarget.is(':checked') ? val.avalue[0] : val.avalue[1]);
$('#'+ini.id+'Tabel tbody input[type=checkbox][id*='+val.field+'_cbox_]').each((i, el) => {
el.checked = _chek;
el.value = (el.checked ? val.avalue[0] : val.avalue[1]);
el.prop('checked', _chek);
el.val(el.is(':checked') ? val.avalue[0] : val.avalue[1]);
});
});
$('#'+ini.id+'Tabel tbody input[type=checkbox][id*=_cbox_]').on('change', (e) => {
e.currentTarget.value = (e.currentTarget.value == val.avalue[1] ? val.avalue[0] : val.avalue[1]);
e.currentTarget.checked = e.currentTarget.value == val.avalue[0];
e.currentTarget.val(e.currentTarget.val() == val.avalue[1] ? val.avalue[0] : val.avalue[1]);
e.currentTarget.prop('checked', e.currentTarget.val() == val.avalue[0]);
});
} else if (val.type == 'button'){
$('#'+ini.id+'Tabel tbody').on('click', '.'+val.icon, (e) => {
@@ -971,6 +1009,7 @@ class _Request_JSONF extends _Request {
tr.addClass('dt-hasChild parent');
}
});
// disnini
}
var otabel = $('#'+ini.id+'Tabel').DataTable(opsi);
}
@@ -981,7 +1020,7 @@ var Request = function (options) {
};
Request.JSON = function (options) {
const _options = Object.assign({}, options, {'dataType':'json'});
const _options = Object.assign({}, options, { 'dataType': 'json' });
return new _Request(_options);
};
-448
View File
@@ -1,448 +0,0 @@
(function (factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery'], factory);
} else if (typeof exports === 'object') {
// Node/CommonJS
factory(require('jquery'));
} else {
// Browser globals
factory(jQuery);
}
}(function ($) {
var ua = navigator.userAgent,
iPhone = /iphone/i.test(ua),
chrome = /chrome/i.test(ua),
android = /android/i.test(ua),
caretTimeoutId;
$.mask = {
//Predefined character definitions
definitions: {
'9': "[0-9]",
'a': "[A-Za-z]",
'*': "[A-Za-z0-9]"
},
autoclear: true,
dataName: "rawMaskFn",
placeholder: '_'
};
$.fn.extend({
//Helper Function for Caret positioning
caret: function(begin, end) {
var range;
if (this.length === 0 || this.is(":hidden") || this.get(0) !== document.activeElement) {
return;
}
if (typeof begin == 'number') {
end = (typeof end === 'number') ? end : begin;
return this.each(function() {
if (this.setSelectionRange) {
this.setSelectionRange(begin, end);
} else if (this.createTextRange) {
range = this.createTextRange();
range.collapse(true);
range.moveEnd('character', end);
range.moveStart('character', begin);
range.select();
}
});
} else {
if (this[0].setSelectionRange) {
begin = this[0].selectionStart;
end = this[0].selectionEnd;
} else if (document.selection && document.selection.createRange) {
range = document.selection.createRange();
begin = 0 - range.duplicate().moveStart('character', -100000);
end = begin + range.text.length;
}
return { begin: begin, end: end };
}
},
unmask: function() {
return this.trigger("unmask");
},
mask: function(mask, settings) {
var input,
defs,
tests,
partialPosition,
firstNonMaskPos,
lastRequiredNonMaskPos,
len,
oldVal;
if (!mask && this.length > 0) {
input = $(this[0]);
var fn = input.data($.mask.dataName)
return fn?fn():undefined;
}
settings = $.extend({
autoclear: $.mask.autoclear,
placeholder: $.mask.placeholder, // Load default placeholder
completed: null
}, settings);
defs = $.mask.definitions;
tests = [];
partialPosition = len = mask.length;
firstNonMaskPos = null;
mask = String(mask);
$.each(mask.split(""), function(i, c) {
if (c == '?') {
len--;
partialPosition = i;
} else if (defs[c]) {
tests.push(new RegExp(defs[c]));
if (firstNonMaskPos === null) {
firstNonMaskPos = tests.length - 1;
}
if(i < partialPosition){
lastRequiredNonMaskPos = tests.length - 1;
}
} else {
tests.push(null);
}
});
return this.trigger("unmask").each(function() {
var input = $(this),
buffer = $.map(
mask.split(""),
function(c, i) {
if (c != '?') {
return defs[c] ? getPlaceholder(i) : c;
}
}),
defaultBuffer = buffer.join(''),
focusText = input.val();
function tryFireCompleted(){
if (!settings.completed) {
return;
}
for (var i = firstNonMaskPos; i <= lastRequiredNonMaskPos; i++) {
if (tests[i] && buffer[i] === getPlaceholder(i)) {
return;
}
}
settings.completed.call(input);
}
function getPlaceholder(i){
if(i < settings.placeholder.length)
return settings.placeholder.charAt(i);
return settings.placeholder.charAt(0);
}
function seekNext(pos) {
while (++pos < len && !tests[pos]);
return pos;
}
function seekPrev(pos) {
while (--pos >= 0 && !tests[pos]);
return pos;
}
function shiftL(begin,end) {
var i,
j;
if (begin<0) {
return;
}
for (i = begin, j = seekNext(end); i < len; i++) {
if (tests[i]) {
if (j < len && tests[i].test(buffer[j])) {
buffer[i] = buffer[j];
buffer[j] = getPlaceholder(j);
} else {
break;
}
j = seekNext(j);
}
}
writeBuffer();
input.caret(Math.max(firstNonMaskPos, begin));
}
function shiftR(pos) {
var i,
c,
j,
t;
for (i = pos, c = getPlaceholder(pos); i < len; i++) {
if (tests[i]) {
j = seekNext(i);
t = buffer[i];
buffer[i] = c;
if (j < len && tests[j].test(t)) {
c = t;
} else {
break;
}
}
}
}
function androidInputEvent(e) {
var curVal = input.val();
var pos = input.caret();
if (oldVal && oldVal.length && oldVal.length > curVal.length ) {
// a deletion or backspace happened
checkVal(true);
while (pos.begin > 0 && !tests[pos.begin-1])
pos.begin--;
if (pos.begin === 0)
{
while (pos.begin < firstNonMaskPos && !tests[pos.begin])
pos.begin++;
}
input.caret(pos.begin,pos.begin);
} else {
var pos2 = checkVal(true);
var lastEnteredValue = curVal.charAt(pos.begin);
if (pos.begin < len){
if(!tests[pos.begin]){
pos.begin++;
if(tests[pos.begin].test(lastEnteredValue)){
pos.begin++;
}
}else{
if(tests[pos.begin].test(lastEnteredValue)){
pos.begin++;
}
}
}
input.caret(pos.begin,pos.begin);
}
tryFireCompleted();
}
function blurEvent(e) {
checkVal();
if (input.val() != focusText)
input.change();
}
function keydownEvent(e) {
if (input.prop("readonly")){
return;
}
var k = e.which || e.keyCode,
pos,
begin,
end;
oldVal = input.val();
//backspace, delete, and escape get special treatment
if (k === 8 || k === 46 || (iPhone && k === 127)) {
pos = input.caret();
begin = pos.begin;
end = pos.end;
if (end - begin === 0) {
begin=k!==46?seekPrev(begin):(end=seekNext(begin-1));
end=k===46?seekNext(end):end;
}
clearBuffer(begin, end);
shiftL(begin, end - 1);
e.preventDefault();
} else if( k === 13 ) { // enter
blurEvent.call(this, e);
} else if (k === 27) { // escape
input.val(focusText);
input.caret(0, checkVal());
e.preventDefault();
}
}
function keypressEvent(e) {
if (input.prop("readonly")){
return;
}
var k = e.which || e.keyCode,
pos = input.caret(),
p,
c,
next;
if (e.ctrlKey || e.altKey || e.metaKey || k < 32) {//Ignore
return;
} else if ( k && k !== 13 ) {
if (pos.end - pos.begin !== 0){
clearBuffer(pos.begin, pos.end);
shiftL(pos.begin, pos.end-1);
}
p = seekNext(pos.begin - 1);
if (p < len) {
c = String.fromCharCode(k);
if (tests[p].test(c)) {
shiftR(p);
buffer[p] = c;
writeBuffer();
next = seekNext(p);
if(android){
//Path for CSP Violation on FireFox OS 1.1
var proxy = function() {
$.proxy($.fn.caret,input,next)();
};
setTimeout(proxy,0);
}else{
input.caret(next);
}
if(pos.begin <= lastRequiredNonMaskPos){
tryFireCompleted();
}
}
}
e.preventDefault();
}
}
function clearBuffer(start, end) {
var i;
for (i = start; i < end && i < len; i++) {
if (tests[i]) {
buffer[i] = getPlaceholder(i);
}
}
}
function writeBuffer() { input.val(buffer.join('')); }
function checkVal(allow) {
//try to place characters where they belong
var test = input.val(),
lastMatch = -1,
i,
c,
pos;
for (i = 0, pos = 0; i < len; i++) {
if (tests[i]) {
buffer[i] = getPlaceholder(i);
while (pos++ < test.length) {
c = test.charAt(pos - 1);
if (tests[i].test(c)) {
buffer[i] = c;
lastMatch = i;
break;
}
}
if (pos > test.length) {
clearBuffer(i + 1, len);
break;
}
} else {
if (buffer[i] === test.charAt(pos)) {
pos++;
}
if( i < partialPosition){
lastMatch = i;
}
}
}
if (allow) {
writeBuffer();
} else if (lastMatch + 1 < partialPosition) {
if (settings.autoclear || buffer.join('') === defaultBuffer) {
// Invalid value. Remove it and replace it with the
// mask, which is the default behavior.
if(input.val()) input.val("");
clearBuffer(0, len);
} else {
// Invalid value, but we opt to show the value to the
// user and allow them to correct their mistake.
writeBuffer();
}
} else {
writeBuffer();
input.val(input.val().substring(0, lastMatch + 1));
}
return (partialPosition ? i : firstNonMaskPos);
}
input.data($.mask.dataName,function(){
return $.map(buffer, function(c, i) {
return tests[i]&&c!=getPlaceholder(i) ? c : null;
}).join('');
});
input
.one("unmask", function() {
input
.off(".mask")
.removeData($.mask.dataName);
})
.on("focus.mask", function() {
if (input.prop("readonly")){
return;
}
clearTimeout(caretTimeoutId);
var pos;
focusText = input.val();
pos = checkVal();
caretTimeoutId = setTimeout(function(){
if(input.get(0) !== document.activeElement){
return;
}
writeBuffer();
if (pos == mask.replace("?","").length) {
input.caret(0, pos);
} else {
input.caret(pos);
}
}, 10);
})
.on("blur.mask", blurEvent)
.on("keydown.mask", keydownEvent)
.on("keypress.mask", keypressEvent)
.on("input.mask paste.mask", function() {
if (input.prop("readonly")){
return;
}
setTimeout(function() {
var pos=checkVal(true);
input.caret(pos);
tryFireCompleted();
}, 0);
});
if (chrome && android)
{
input
.off('input.mask')
.on('input.mask', androidInputEvent);
}
checkVal(); //Perform initial check for existing values
});
}
});
}));
+2 -2
View File
@@ -1,6 +1,6 @@
/*!
autosize 5.0.1
autosize 6.0.1
license: MIT
http://www.jacklmoore.com/autosize
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e||self).autosize=t()}(this,function(){var e,t,n="function"==typeof Map?new Map:(e=[],t=[],{has:function(t){return e.indexOf(t)>-1},get:function(n){return t[e.indexOf(n)]},set:function(n,o){-1===e.indexOf(n)&&(e.push(n),t.push(o))},delete:function(n){var o=e.indexOf(n);o>-1&&(e.splice(o,1),t.splice(o,1))}}),o=function(e){return new Event(e,{bubbles:!0})};try{new Event("test")}catch(e){o=function(e){var t=document.createEvent("Event");return t.initEvent(e,!0,!1),t}}function r(e){var t=n.get(e);t&&t.destroy()}function i(e){var t=n.get(e);t&&t.update()}var l=null;return"undefined"==typeof window||"function"!=typeof window.getComputedStyle?((l=function(e){return e}).destroy=function(e){return e},l.update=function(e){return e}):((l=function(e,t){return e&&Array.prototype.forEach.call(e.length?e:[e],function(e){return function(e){if(e&&e.nodeName&&"TEXTAREA"===e.nodeName&&!n.has(e)){var t,r=null,i=null,l=null,d=function(){e.clientWidth!==i&&c()},u=function(t){window.removeEventListener("resize",d,!1),e.removeEventListener("input",c,!1),e.removeEventListener("keyup",c,!1),e.removeEventListener("autosize:destroy",u,!1),e.removeEventListener("autosize:update",c,!1),Object.keys(t).forEach(function(n){e.style[n]=t[n]}),n.delete(e)}.bind(e,{height:e.style.height,resize:e.style.resize,overflowY:e.style.overflowY,overflowX:e.style.overflowX,wordWrap:e.style.wordWrap});e.addEventListener("autosize:destroy",u,!1),"onpropertychange"in e&&"oninput"in e&&e.addEventListener("keyup",c,!1),window.addEventListener("resize",d,!1),e.addEventListener("input",c,!1),e.addEventListener("autosize:update",c,!1),e.style.overflowX="hidden",e.style.wordWrap="break-word",n.set(e,{destroy:u,update:c}),"vertical"===(t=window.getComputedStyle(e,null)).resize?e.style.resize="none":"both"===t.resize&&(e.style.resize="horizontal"),r="content-box"===t.boxSizing?-(parseFloat(t.paddingTop)+parseFloat(t.paddingBottom)):parseFloat(t.borderTopWidth)+parseFloat(t.borderBottomWidth),isNaN(r)&&(r=0),c()}function a(t){var n=e.style.width;e.style.width="0px",e.style.width=n,e.style.overflowY=t}function s(){if(0!==e.scrollHeight){var t=function(e){for(var t=[];e&&e.parentNode&&e.parentNode instanceof Element;)e.parentNode.scrollTop&&t.push({node:e.parentNode,scrollTop:e.parentNode.scrollTop}),e=e.parentNode;return t}(e),n=document.documentElement&&document.documentElement.scrollTop;e.style.height="",e.style.height=e.scrollHeight+r+"px",i=e.clientWidth,t.forEach(function(e){e.node.scrollTop=e.scrollTop}),n&&(document.documentElement.scrollTop=n)}}function c(){s();var t=Math.round(parseFloat(e.style.height)),n=window.getComputedStyle(e,null),r="content-box"===n.boxSizing?Math.round(parseFloat(n.height)):e.offsetHeight;if(r<t?"hidden"===n.overflowY&&(a("scroll"),s(),r="content-box"===n.boxSizing?Math.round(parseFloat(window.getComputedStyle(e,null).height)):e.offsetHeight):"hidden"!==n.overflowY&&(a("hidden"),s(),r="content-box"===n.boxSizing?Math.round(parseFloat(window.getComputedStyle(e,null).height)):e.offsetHeight),l!==r){l=r;var i=o("autosize:resized");try{e.dispatchEvent(i)}catch(e){}}}}(e)}),e}).destroy=function(e){return e&&Array.prototype.forEach.call(e.length?e:[e],r),e},l.update=function(e){return e&&Array.prototype.forEach.call(e.length?e:[e],i),e}),l});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e||self).autosize=t()}(this,function(){var e=new Map;function t(t){var o=e.get(t);o&&o.destroy()}function o(t){var o=e.get(t);o&&o.update()}var r=null;return"undefined"==typeof window?((r=function(e){return e}).destroy=function(e){return e},r.update=function(e){return e}):((r=function(t,o){return t&&Array.prototype.forEach.call(t.length?t:[t],function(t){return function(t){if(t&&t.nodeName&&"TEXTAREA"===t.nodeName&&!e.has(t)){var o,r=null,n=window.getComputedStyle(t),i=(o=t.value,function(){s({testForHeightReduction:""===o||!t.value.startsWith(o),restoreTextAlign:null}),o=t.value}),l=function(o){t.removeEventListener("autosize:destroy",l),t.removeEventListener("autosize:update",a),t.removeEventListener("input",i),window.removeEventListener("resize",a),Object.keys(o).forEach(function(e){return t.style[e]=o[e]}),e.delete(t)}.bind(t,{height:t.style.height,resize:t.style.resize,textAlign:t.style.textAlign,overflowY:t.style.overflowY,overflowX:t.style.overflowX,wordWrap:t.style.wordWrap});t.addEventListener("autosize:destroy",l),t.addEventListener("autosize:update",a),t.addEventListener("input",i),window.addEventListener("resize",a),t.style.overflowX="hidden",t.style.wordWrap="break-word",e.set(t,{destroy:l,update:a}),a()}function s(e){var o,i,l=e.restoreTextAlign,a=void 0===l?null:l,d=e.testForHeightReduction,u=void 0===d||d,f=n.overflowY;if(0!==t.scrollHeight&&("vertical"===n.resize?t.style.resize="none":"both"===n.resize&&(t.style.resize="horizontal"),u&&(o=function(e){for(var t=[];e&&e.parentNode&&e.parentNode instanceof Element;)e.parentNode.scrollTop&&t.push([e.parentNode,e.parentNode.scrollTop]),e=e.parentNode;return function(){return t.forEach(function(e){var t=e[0],o=e[1];t.style.scrollBehavior="auto",t.scrollTop=o,t.style.scrollBehavior=null})}}(t),t.style.height=""),i="content-box"===n.boxSizing?t.scrollHeight-(parseFloat(n.paddingTop)+parseFloat(n.paddingBottom)):t.scrollHeight+parseFloat(n.borderTopWidth)+parseFloat(n.borderBottomWidth),"none"!==n.maxHeight&&i>parseFloat(n.maxHeight)?("hidden"===n.overflowY&&(t.style.overflow="scroll"),i=parseFloat(n.maxHeight)):"hidden"!==n.overflowY&&(t.style.overflow="hidden"),t.style.height=i+"px",a&&(t.style.textAlign=a),o&&o(),r!==i&&(t.dispatchEvent(new Event("autosize:resized",{bubbles:!0})),r=i),f!==n.overflow&&!a)){var c=n.textAlign;"hidden"===n.overflow&&(t.style.textAlign="start"===c?"end":"start"),s({restoreTextAlign:c,testForHeightReduction:!0})}}function a(){s({testForHeightReduction:!0,restoreTextAlign:null})}}(t)}),t}).destroy=function(e){return e&&Array.prototype.forEach.call(e.length?e:[e],t),e},r.update=function(e){return e&&Array.prototype.forEach.call(e.length?e:[e],o),e}),r});
+4 -4
View File
@@ -284,7 +284,7 @@
};
for (var i = 0; i < images.length; i++) {
if ($.isArray(images[i])) {
if (Array.isArray(images[i])) {
images[i] = widthInsertSort(images[i]);
var chosen = selectBest(containerWidth, containerHeight, images[i]);
chosenImages.push(chosen);
@@ -338,7 +338,7 @@
if (typeof sources === 'undefined') {
return;
}
if (!$.isArray(sources)) {
if (!Array.isArray(sources)) {
sources = [sources];
}
@@ -424,7 +424,7 @@
if (typeof images[i] === 'string') {
processed.push({url: images[i]});
}
else if ($.isArray(images[i])) {
else if (Array.isArray(images[i])) {
processed.push(processImagesArray(images[i]));
}
else {
@@ -556,7 +556,7 @@
* e.g. $.backstretch('/path/to/image.jpg')
* So, we need to turn this back into an array.
*/
this.images = processImagesArray($.isArray(images) ? images : [images]);
this.images = processImagesArray(Array.isArray(images) ? images : [images]);
/**
* Paused-Option
+2 -2
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+3 -3
View File
@@ -1,6 +1,6 @@
/*******************************************************************
Module : /js3/qz/qz-start.js
Module : /js/qz/qz-start.js
Desc. : JS Setup QZ Connection
Created By : Siau Pheng (siaupheng@3fonia.com).
Created Date : May 27th, 2007.
@@ -71,11 +71,11 @@ const _divStatus = '#divQZStatus';
if (typeof qz !== 'undefined') {
qz.security.setSignatureAlgorithm("SHA512");
qz.security.setCertificatePromise((resolve, reject) => {
jQuery.ajax({url:FoniaJS.WEB_PATH+'assets/signing/cert.pem', cache:false, dataType:'text'}).then(resolve, reject);
jQuery.ajax({url:'qz/cert', cache:false, dataType:'text'}).then(resolve, reject);
});
qz.security.setSignaturePromise((toSign) => {
return (resolve, reject) => {
jQuery.post(FoniaJS.WEB_PATH+"assets/signing/sign.php?req="+toSign).then(resolve, reject);
jQuery.ajax('qz/sign/'+toSign).then(resolve, reject);
};
});
qz.websocket.setClosedCallbacks((evt) => {
+435 -41
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
-172
View File
@@ -1,172 +0,0 @@
<?php
/*******************************************************************
Module : /App.php
Desc. : HTML5 Page Generator (jQuery & Bootstrap)
Created By : Siau Pheng (siaupheng@3fonia.com).
Created Date : January 10th, 2008.
Last Modified : July 25th, 2026.
(c) 2008 - 2026, 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/
declare(strict_types=1);
namespace siaupheng\webapp;
final class App {
public $version = "4.1.0";
private $apps = [];
private $auser = [];
private $cache = null;
private $menu = null;
private $reg = null;
protected $__db = null;
protected $__form = null;
public function __construct($db = null){
if (is_resource($db)) { $this->__db = $db; }
else { $this->__db = new \siaupheng\webapp\DB\MySQL(); }
$this->__form = new \siaupheng\webapp\Web\Form($this->__db);
$this->apps = $_SESSION['__WEB_APP'];
if (isset($_SESSION['__WEB_USER'])) {
$this->apps['TEMPLATE'] = "index.php";
$this->auser = $_SESSION['__WEB_USER'];
$this->auser['user_img'] = "profiles/profile.png";
if (file_exists($this->apps['REAL_PATH']."assets/images/profiles/".$this->auser['UserID'].".png")) {
$this->auser['user_img'] = "profiles/".$this->auser['UserID'].".png";
}
}
$this->reg = new \siaupheng\webapp\Web\Register($this->__db);
$this->cache = new \siaupheng\webapp\Data\Cache($this->__db);
$this->menu = new \siaupheng\webapp\Web\Menu($this->__db);
}
public function TampilApp($aoption = []) {
if ($this->reg->reg_check()) {
if (!user_logged()) {
$this->apps['TEMPLATE'] = "login.php";
}
} else {
$this->apps['TEMPLATE'] = "404.php";
}
// gunakan template khusus sesuai request
if (($aoption['PAGE_404']['value'] ?? 0) == 1) {
$this->apps['TEMPLATE'] = "404.php";
}
// loading template file {{}}
$buffer = "";
if (file_exists($this->apps['REAL_PATH']."assets/templates/".$this->apps['TEMPLATE'])) {
$buffer = file_get_contents($this->apps['REAL_PATH']."assets/templates/".$this->apps['TEMPLATE']);
$buffer = preg_replace("/(?:(?:\\/\\*(?:[^*]|(?:\\*+[^*\\/]))*\\*+\\/)|(?:(?<!\\:)\\/\\/. *))/", "", $buffer);
}
$aoption = [...$this->apps, 'CSS_JS' => ""];
// penambahan file css + js + app-js
$aoption['CSS_JS'] = '<link rel="stylesheet" type="text/css" href="'.$this->cache->Main("css").'">'."\n";
$aoption['CSS_JS'] .= '<script type="text/javascript" src="'.$this->cache->Main("js").'"></script>'."\n";
if (user_logged()) $aoption['CSS_JS'] .= '<script type="text/javascript" src="'.$this->cache->Apps().'"></script>'."\n";
$_secret = $aoption['APP_CODE'] .";". $aoption['APP_SID'] .";". $_SERVER['HTTP_HOST'] .";". $aoption['WEB_PATH'] .";". "http://".$_SERVER['HTTP_HOST'].$aoption['WEB_PATH'] .";". isMobile() .";". ($aoption['AUTH_LEVEL']?$aoption['AUTH_LEVEL']:0) .";". $this->version;
$_suser = (user_logged()) ? $this->auser['Username'] .";". $this->auser['UserID'] .";". $this->auser['Grup_MenuID'] .";". $this->auser['Level'] : "nobody;999;999;9";
$aoption['CSS_JS'] .= '<script type="text/javascript" language="javascript">'."\n";
$aoption['CSS_JS'] .= 'FoniaJS.setConfig("'.base64_encode($_secret).'", "'.base64_encode($_suser).'");';
$aoption['CSS_JS'] .= '$(document).ready(function(){';
$tnaviside = ""; $tnavihead = "";
if (user_logged()) {
$aoption['CSS_JS'] .= 'FoniaJS.loadMenu();';
$tnaviside = $this->menu->Menu_Sidebar();
$tnavihead = $this->menu->Menu_Header();
}
$aoption['CSS_JS'] .= '});';
$aoption['CSS_JS'] .= '</script>'."\n";
// informasi tahun aplikasi dan pembuatan menu
if (strpos($buffer, '{{CREATOR_YEAR}}')===false) {
$aoption['REG_YEAR'] = ($aoption['REG_YEAR']!=date('Y')) ? $aoption['REG_YEAR']." - ".date('Y') : $aoption['REG_YEAR'];
} else {
$aoption['CREATOR_YEAR'] = ($aoption['CREATOR_YEAR']!=date('Y')) ? $aoption['CREATOR_YEAR']." - ".date('Y') : $aoption['CREATOR_YEAR'];
}
// perubahan variabel dari data konfigurasi
$aoption['APP_NAME_VER'] = $aoption['APP_NAME']." v".$aoption['APP_VER'];
$aoption['APP_NAMES_VER'] = $aoption['APP_NAMES']." v".$aoption['APP_VER'];
$aoption['APP_NAMES_UP'] = strtoupper($aoption['APP_NAMES'] ?? "");
$aoption['REG_ID'] = $this->reg->reg_id();
$aoption['REG_NAME_UP'] = strtoupper($aoption['REG_NAME'] ?? "");
$aoption['REG_CITY_UP'] = strtoupper($aoption['REG_CITY'] ?? "");
$aoption['USER_IMG'] = $this->auser['user_img'] ?? "";
$aoption['NAVI_SIDEBAR'] = $tnaviside;
$aoption['NAVI_HEADER'] = $tnavihead;
if (isset($this->auser) && is_array($this->auser)) {
$aoption['USER_ID'] = $this->auser['UserID'] ?? "";
$aoption['USER_USER'] = $this->auser['Username'] ?? "";
$aoption['USER_NAME'] = $this->auser['Nama'] ?? "";
$aoption['USER_POSISI'] = $this->auser['Posisi'] ?? "";
// menu modul
$t_modul = "";
if (isset($this->auser['MENU_MODUL']) && is_array($this->auser['MENU_MODUL']) && count($this->auser['MENU_MODUL'])>0) {
$t_modul = '<div class="dropdown-divider"></div>';
if ($_SERVER['SERVER_ADDR'] == "127.0.0.1") {
$href1 = $this->apps['WEB_PATH'].'../';
$href2 = "";
} else {
$_host = $_SERVER['HTTP_ORIGIN'] ?? $_SERVER['HTTP_HOST'] ?? $this->apps['PARENT_SITE'];
$_host = str_replace(['http://','https://'], "", $_host);
if ($this->apps['PARENT_SUB']==true) {
$_subs = explode('.', $_host);
if (count($_subs) > 2) array_shift($_subs);
$href1 = "//";
$href2 = "." . implode('.', $_subs);
} else {
$href1 = "//" . $_host . '/';
$href2 = "";
}
}
foreach ($this->auser['MENU_MODUL'] as $modul) {
$href = $href1.$modul['APP_PATH'].$href2;
$href .= '/?auth='.$_SESSION['APP_TOKEN'];
$t_modul .= '<a class="dropdown-item slink" href="'.$href.'"><i class="'.$modul['Icon'].' me-2"></i> '.$modul['Judul'].'</a>';
}
}
// menu extra
$amodul_ext = $aoption['MENU_MODUL'] ?? [];
if (count($amodul_ext) > 0) {
$t_modul .= '<div class="dropdown-divider"></div>';
foreach ($amodul_ext as $modul) {
$t_modul .= '<a class="dropdown-item slink" id="'.$modul['Id'].'"><i class="'.$modul['Icon'].' me-2"></i> '.$modul['Judul'].'</a>';
}
}
$aoption['MENU_MODUL'] = $t_modul;
}
// penyisipan option (pilihan tahun, tanggal login, dll)
if (count($aoption) > 0) {
foreach ($aoption as $__key => $val) {
$opt_var = $val['value'];
if (strpos($__key, "OPTION")!==false) {
$opt_var = $this->__form->option("_", $__key, $val['value'], true, true, $val['option']);
} else if (strpos($__key, "RADIO")!==false) {
$opt_var = $this->__form->radio("_", $__key, $val['value'], true, true, $val['radio']);
} else if (strpos($__key, "PICKDATE")!==false) {
$opt_var = $this->__form->datebox("_", $__key, $val['value'], true, true);
}
$aoption[$__key] = $opt_var;
}
}
$output = preg_replace_callback('/\{\{([a-zA-Z0-9_]+)\}\}/', fn($matches) => isset($aoption[$matches[1]]) ? $aoption[$matches[1]] : "", $buffer);
echo $output;
}
}
?>
+46 -52
View File
@@ -6,56 +6,68 @@
Desc. : Class Check SQL / Repair Database
Created By : Siau Pheng (siaupheng@3fonia.com).
Created Date : May 11th, 2011.
Last Modified : May 8th, 2021.
Last Modified : August 13th, 2026.
(c) 2011 - 2021, 3FONIA Software; WWW.3FONIA.COM.
(c) 2011 - 2026, 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/
//OK
declare(strict_types=1);
namespace siaupheng\webapp\DB;
use Exception;
use flight\Engine;
use flight\Session;
use flight\database\SimplePdo;
final class CheckSQL {
private $__atabel = [];
private $__aignore = [];
protected $__db = null;
private Array $__atabel = [];
protected Engine $app;
protected SimplePdo $db;
public function __construct($db = null){
if (is_resource($db)) { $this->__db = $db; }
else { $this->__db = new \siaupheng\webapp\DB\MySQL(); }
public function __construct(?Engine $app = null){
$this->app = (empty($app) === true) ? \Flight::app() : $app;
$this->db = $this->app->db();
$this->__db->Query("SELECT TABLE_NAME,ENGINE,TABLE_ROWS FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='".$this->__db->getDBName()."' AND TABLE_TYPE='BASE TABLE'");
while ($this->__db->Next()) {
$this->__atabel[] = array($this->__db->Row("TABLE_NAME"), ' <i>('.$this->__db->Row("ENGINE").')</i>',' <i>('.uang($this->__db->Row("TABLE_ROWS")).' Records)</i>');
$nama_db = $this->db->fetchField('SELECT DATABASE()');
$arow = $this->db->fetchAll("SELECT TABLE_NAME,ENGINE,TABLE_ROWS FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='".$nama_db."' AND TABLE_TYPE='BASE TABLE'");
foreach ($arow as $row) {
$this->__atabel[] = [ $row['TABLE_NAME'], $row['ENGINE'], ' <i>('.$row['ENGINE'].')</i>',' <i>('.$row['TABLE_ROWS'].' Records)</i>' ];
}
}
public function ignore_table() {
$tmp_arr = func_get_args();
if (is_array($tmp_arr[0])) $tmp_arr = $tmp_arr[0];
$this->__aignore = $tmp_arr;
$farray = array_filter($this->__atabel, fn($child) => !in_array($child[0], $tmp_arr));
$this->__atabel = array_values($farray);
}
private function _check_db($atabel=array()) {
$hasil = "";
if (!in_array($atabel[0], $this->__aignore)) {
$pesan = "<span style=\"color:blue;\">OK</span>";
$this->__db->Query("CHECK TABLE ".$atabel[0]);
if ($this->__db->Next()) {
if (strtoupper($this->__db->Row("Msg_text"))<>"OK") {
$pesan = "<span style=\"color:red;\">ERROR</span>";
$this->__db->Query("REPAIR TABLE ".$atabel[0]);
if ($this->__db->Next()) {
if (strtoupper($this->__db->Row("Msg_text"))=="OK") {
$pesan .= " -> <span style=\"color:blue;\">FIXED</span>";
private function _check_db(array $atabel=[]) {
$pesan = '<span style="color:blue;">OK</span>';
$row = $this->db->runQuery('CHECK TABLE '.$atabel[0].' QUICK')->fetch(SimplePdo::FETCH_ASSOC);
if (($row['Msg_text'] ?? '') !== 'OK') {
$pesan = '<span style="color:red;">ERROR</span>';
try {
$row2 = $this->db->runQuery('REPAIR TABLE '.$atabel[0])->fetch(SimplePdo::FETCH_ASSOC);
$pesan .= ' -> Auto Repair <span style="color:blue;">'. (($row2['Msg_text'] ?? '') === 'OK' ? 'FIXED' : 'ERROR') .'</span>';
} catch (Exception $e) {
$pesan .= ' -> Auto Repair <span style="color:red;">' . $e->getMessage() . '</span>';
}
}
return $atabel[0] . $atabel[3] ." ... ". $pesan ."<br>";
}
private function _opti_db(array $atabel=[]) {
$pesan = '<span style="color:orange;">SKIP</span>';
if ($atabel[1] === 'MyISAM') {
$pesan = '<span style="color:blue;">OK</span>';
$row = $this->db->runQuery('OPTIMIZE TABLE '.$atabel[0])->fetch(SimplePdo::FETCH_ASSOC);
if (!in_array(strtoupper($row['Msg_text'] ?? ''), ['OK','TABLE IS ALREADY UP TO DATE'])) $pesan = '<span style="color:red;">ERROR</span>';
}
$hasil = $atabel[0] . $atabel[2] ." ... ". $pesan ."<br>";
}
return $hasil;
return $atabel[0] . $atabel[2] ." ... ". $pesan ."<br>";
}
public function count_db() {
@@ -64,45 +76,27 @@ final class CheckSQL {
public function check_db() {
$hasil = "=== CEK DATABASE ===<br>";
for ($n=0;$n<count($this->__atabel);$n++) {
for ($n=0; $n<count($this->__atabel); $n++) {
$hasil .= $this->_check_db($this->__atabel[$n]);
}
return $hasil;
}
public function check_db_step($n) {
$hasil .= $this->_check_db($this->__atabel[$n]);
}
public function repair_db() {
$hasil = "=== REPAIR DATABASE ===<br>";
for ($n=0;$n<count($this->__atabel);$n++) {
if (!in_array($this->__atabel[$n][0], $this->__aignore)) {
$pesan = "<span style=\"color:blue;\">OK</span>";
$this->__db->Query("REPAIR TABLE ".$this->__atabel[$n][0]);
while ($this->__db->Next()) {
$pesan = (strtoupper($this->__db->Row("Msg_text"))=="OK") ? "<span style=\"color:blue;\">OK</span>" : "<span style=\"color:red;\">ERROR</span>";
}
$hasil .= $this->__atabel[$n][0] . $this->__atabel[$n][1] ." ... ". $pesan ."<br>";
}
}
return $hasil;
return $this->_check_db($this->__atabel[$n]);
}
public function optimize_db() {
$hasil = "=== OPTIMALISASI DATABASE ===<br>";
for ($n=0;$n<count($this->__atabel);$n++) {
if (!in_array($this->__atabel[$n][0], $this->__aignore)) {
$pesan = "<span style=\"color:blue;\">OK</span>";
$this->__db->Query("OPTIMIZE TABLE ".$this->__atabel[$n][0]);
while ($this->__db->Next()) {
$pesan = (strtoupper($this->__db->Row("Msg_text"))=="OK" || strtoupper($this->__db->Row("Msg_text"))=="TABLE IS ALREADY UP TO DATE") ? "<span style=\"color:blue;\">OK</span>" : "<span style=\"color:red;\">ERROR</span>";
}
$hasil .= $this->__atabel[$n][0] . $this->__atabel[$n][1] ." ... ". $pesan ."<br>";
}
$hasil .= $this->_opti_db($this->__atabel[$n]);
}
return $hasil;
}
public function optimize_db_step($n) {
return $this->_opti_db($this->__atabel[$n]);
}
}
?>
-228
View File
@@ -1,228 +0,0 @@
<?php
/*******************************************************************
Module : /DB/MySQL.php
Desc. : Class database MySQL / MariaDB
Created By : Siau Pheng (siaupheng@3fonia.com).
Created Date : February 2nd, 2007.
Last Modified : October 19th, 2023.
(c) 2008 - 2023, 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/
declare(strict_types=1);
namespace siaupheng\webapp\DB;
final class MySQL {
private $cnn;
private $rs = 0;
private $rec = array();
private $row = 0;
private $halt_on_error = 1; //1: halt w message, 2: not halt w message, 3: not halt no message
private $auto_free = 1; //1: free query automatically, 0: must call free method to free query
private $db_config = null;
private $err_num = 0;
private $err_msg = '';
private $debug_msg = 1;
private $ischangingdb = false;
public function __construct() {
if (!is_array($this->db_config)) $this->setConfig();
$this->debug_msg = ($_SERVER['SERVER_ADDR'] == "127.0.0.1") ? 1 : 0;
}
private function setConfig() {
global $APP_DATA;
if (!is_array($APP_DATA)) {
if (file_exists($_SESSION['__WEB_APP']['REAL_PATH']."apps/cfg/mysql.php"))
require_once($_SESSION['__WEB_APP']['REAL_PATH']."apps/cfg/mysql.php");
}
$this->db_config = $APP_DATA;
}
public function getConfig() {
return $this->db_config;
}
function Connect() {
if (!$this->cnn) {
$this->cnn = @mysqli_connect($this->db_config['host'], $this->db_config['user'], $this->db_config['pwd'], $this->db_config['db'], intval($this->db_config['port']), $this->db_config['sock']);
if (!$this->cnn) {
$this->ErrHandler("Connection failed!");
return 0;
} else {
@mysqli_query($this->cnn, "SET NAMES utf8");
@mysqli_query($this->cnn, "SET CHARACTER SET utf8");
@mysqli_query($this->cnn, "SET character_set_connection=utf8");
}
}
return $this->cnn;
}
function Connection() {
return $this->cnn;
}
function ResultSet() {
return $this->rs;
}
function Free() {
if (is_resource($this->rs)) @mysqli_free_result($this->rs);
$this->rs = 0;
$this->row = 0;
$this->rec = array();
$this->err_num = 0;
$this->err_msg = '';
}
function SafeSQL($str) {
if (!$this->cnn) $this->Connect();
return mysqli_real_escape_string($this->cnn, strval($str));
}
function &Query($stqry = "", $dbname = "") {
if ($stqry == "") return 0;
if (!$this->Connect()) return 0;
if ($dbname != "" || $this->ischangingdb) {
if ($dbname != "") {
if (!@mysqli_select_db($this->cnn, $dbname)) {
$this->ErrHandler("Cannot select database!");
return 0;
}
$this->ischangingdb = true;
} else {
if (!@mysqli_select_db($this->cnn, $this->db_config['db'])) {
$this->ErrHandler("Cannot select database!");
return 0;
}
$this->ischangingdb = false;
}
}
if ($this->rs) $this->Free();
$this->rs = @mysqli_query($this->cnn, $stqry);
$this->row = 0;
$this->err_msg = @mysqli_error($this->cnn);
if (!$this->rs) $this->ErrHandler("Invalid SQL!: ".$stqry);
return $this->rs;
}
function Next() {
if (!$this->rs) {
$this->ErrHandler("Cannot move cursor to next record!");
return 0;
}
$this->rec = @mysqli_fetch_array($this->rs, MYSQLI_ASSOC);
$this->row += 1;
$this->err_msg = @mysqli_error($this->cnn);
$result = is_array($this->rec);
if (!$result && $this->auto_free) $this->Free();
return $result;
}
function Reset() {
@mysqli_data_seek($this->rs, 0);
}
function Seek($rownum = 0) {
return @mysqli_data_seek($this->rs, $rownum);
}
function Row($name = "", $defval = "") {
if (isset($this->rec[$name])) {
return (($this->rec[$name] == "") ? $defval : $this->rec[$name]);
} else {
return (($defval != "") ? $defval : "");
}
}
function RowNumeric($name = "", $defval = 0) {
$defval = is_numeric($defval) ? $defval : 0;
if (isset($this->rec[$name])) {
if (is_numeric($this->rec[$name])) return $this->rec[$name];
return $defval;
} else return $defval;
}
function RowFloat($name = "", $defval = 0) {
$defval = is_numeric($defval) ? $defval : 0;
if (isset($this->rec[$name])) {
if ($this->rec[$name]) $defval = $this->rec[$name];
}
return floatval($defval);
}
function AllRow() {
return $this->rec;
}
function ValueArray($colname = "") {
$currrow = $this->row;
@mysqli_data_seek($this->rs, 0);
$result = array();
while ($__row = mysqli_fetch_array($this->rs))
if (isset($__row[$colname])) array_push($result, $__row[$colname]);
@mysqli_data_seek($this->rs, $currrow);
return $result;
}
function ValueArrayFormater($colname = "", $formater = "") {
$currrow = $this->row;
$formater = $formater == ""?$formater = "return \$__row[\$colname];":"return ".str_replace("<value>", "\$__row[\$colname]", $formater).";";
@mysqli_data_seek($this->rs, 0);
$result = array();
while ($__row = mysqli_fetch_array($this->rs))
if (isset($__row[$colname])) array_push($result, eval($formater));
@mysqli_data_seek($this->rs, $currrow);
return $result;
}
function ValueList($colname = "", $delim = ",") {
$result = @$this->ValueArray($colname);
return @implode($delim, $result);
}
function CurrentRow() {
return $this->row;
}
function AffectedRows() {
return @mysqli_affected_rows($this->cnn);
}
function RecordCount() {
return @mysqli_num_rows($this->rs);
}
function NumFields() {
return @mysqli_num_fields($this->rs);
}
function LastInsertID() {
$lastinsertid = -1;
$crs = @mysqli_query($this->cnn, "SELECT LAST_INSERT_ID() AS lastinsertid");
$crow = @mysqli_fetch_array($crs);
if (isset($crow["lastinsertid"])) if (is_numeric($crow["lastinsertid"])) $lastinsertid = $crow["lastinsertid"];
return $lastinsertid;
}
function ErrHandler($err_msg = "") {
$this->err_msg = @mysqli_error($this->cnn);
if ($this->halt_on_error == 3) return;
if ($err_msg == "") $err_msg = "Undefined error!";
if ($this->debug_msg) {
printf('<span style="font-size:1.2em;"><b>MySQL Error : %s</b> %s</span><br>', $this->db_config['db'], $this->err_msg);
printf('<span style="font-size:1.2em;"><b>Database error : </b> %s</span><br>', $err_msg);
}
if ($this->halt_on_error == 1) die("");
}
function getDBName() {
return $this->db_config['db'];
}
}
?>
+122 -75
View File
@@ -6,125 +6,172 @@
Desc. : Class Query database
Created By : Siau Pheng (siaupheng@3fonia.com).
Created Date : February 2nd, 2007.
Last Modified : December 17th, 2023.
Last Modified : August 14th, 2026.
(c) 2008 - 2023, 3FONIA Software; WWW.3FONIA.COM.
(c) 2008 - 2026, 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/
//OK
declare(strict_types=1);
namespace siaupheng\webapp\DB;
use flight\Engine;
use flight\Session;
use flight\database\SimplePdo;
use siaupheng\webapp\Web\Param;
final class SQL {
private $__ttable = "";
private $__afield = array();
private $__avalue = array();
private $__anomor = array();
private $__twhere = "";
protected $__db = null;
private string $_ttable;
private array $_afield = [];
private array $_awhere = [];
protected Engine $app;
protected SimplePdo $db;
public function __construct($db = null){
if (is_resource($db)) { $this->__db = $db; }
else { $this->__db = new \siaupheng\webapp\DB\MySQL(); }
public function __construct(?Engine $app = null){
$this->app = (empty($app) === true) ? \Flight::app() : $app;
$this->db = $this->app->db();
}
public function SafeSQL($ttext = "") {
return $this->__db->SafeSQL($ttext);
public function SafeSQL($ttext = "") {//delete
return $ttext;
}
public function set_table($ttable = "") {
$this->__ttable = $ttable;
public function set_table(string $table = ""): void {
$this->_ttable = $table;
}
public function add_param($tparam = "", $tvalue = null, $bnomor = false) {
$this->__afield[] = $tparam;
$this->__avalue[] = (is_null($tvalue) && isset($_REQUEST[$tparam])) ? $this->__db->SafeSQL($_REQUEST[$tparam]) : $tvalue;
$this->__anomor[] = $bnomor;
public function add_param(string $param = "", string|int|null $value = null, bool $nomor = false): void {
$this->_afield[] = [
'field' => $param,
'value' => (is_null($value) && !empty(Param::Get($param))) ? Param::Get($param) : $value,
'numbe' => $nomor,
];
}
public function add_param_date($tparam = "", $tvalue = null) {
$this->__afield[] = $tparam;
$this->__avalue[] = tgl_sql2str((is_null($tvalue) && isset($_REQUEST[$tparam])) ? $this->__db->SafeSQL($_REQUEST[$tparam]) : $tvalue);
$this->__anomor[] = false;
public function add_param_date(string $param = "", string|null $value = null): void {
$this->_afield[] = [
'field' => $param,
'value' => tgl_sql2str((is_null($value) && !empty(Param::Get($param))) ? Param::Get($param) : $value),
'numbe' => false,
];
}
public function add_param_stamp($tparam = "DateStamp") {
$this->__afield[] = $tparam;
$this->__avalue[] = "NOW()";
$this->__anomor[] = true;
public function add_param_stamp(string $param = "DateStamp"): void {
$this->_afield[] = [
'field' => $param,
'value' => 'NOW()',
'numbe' => true,
];
}
public function add_param_unix() {
$this->__afield[] = "Unix";
$this->__avalue[] = user_unix();
$this->__anomor[] = false;
public function add_param_unix(): void {
$this->_afield[] = [
'field' => 'Unix',
'value' => user_unix(),
'numbe' => false,
];
}
public function add_param_userid($tparam = "UserID") {
$this->__afield[] = $tparam;
$this->__avalue[] = user_id();
$this->__anomor[] = false;
public function add_param_userid(string $param = "UserID"): void {
$this->_afield[] = [
'field' => $param,
'value' => user_id(),
'numbe' => false,
];
}
public function add_where_unix() {
$this->__twhere .= (($this->__twhere=="") ? " WHERE " : " AND ") . "(Unix='".user_unix()."')";
public function add_where_unix(): void {
$this->_awhere[] = [
'field' => 'Unix',
'value' => user_id(),
'numbe' => false,
];
}
public function add_where_date($tfield = "", $tvalue = null) {
$tvalue = ($tvalue == null) ? "0000-00-00" : tgl_sql2str($tvalue);
$this->add_where($tfield, $tvalue);
public function add_where_date(string $field = "", string|null $value = null): void {
$this->_awhere[] = [
'field' => $field,
'value' => (is_null($value)) ? '0000-00-00' : tgl_sql2str($value),
'numbe' => false,
];
}
public function add_where($tfield = "", $tvalue = null) {
$__tvalue = (is_null($tvalue) && isset($_REQUEST[$tfield])) ? $this->__db->SafeSQL($_REQUEST[$tfield]) : $tvalue;
$this->__twhere .= (($this->__twhere=="") ? " WHERE " : " AND ") . "(".$tfield."='".$__tvalue."')";
public function add_where(string $field = "", string|int|null $value = null, bool $nomor = false): void {
$this->_awhere[] = [
'field' => $field,
'value' => (is_null($value) && !empty(Param::Get($field))) ? Param::Get($field) : $value,
'numbe' => $nomor,
];
}
public function clear_param() {
$this->__afield = array();
$this->__avalue = array();
$this->__anomor = array();
public function clear_param(): void {
$this->_afield = [];
}
public function clear_where() {
$this->__twhere = "";
public function clear_where(): void {
$this->_awhere = [];
}
public function InsertDB() {
$tsql = "INSERT INTO ".$this->__ttable." (";
$tfield = "";
$tvalue = "";
for ($i=0; $i<count($this->__afield); $i++) {
$tfield .= ",".$this->__afield[$i];
$tvalue .= ",".(($this->__anomor[$i])?"":"'").$this->__avalue[$i].(($this->__anomor[$i])?"":"'");
public function InsertDB(): void {
$__afield = [];
$__aplace = [];
$__aexec = [];
foreach ($this->_afield as $col) {
$__afield[] = '`'.$col['field'].'`';
if ($col['numbe'] === true) {
$__aplace[] = $col['value'];
} else {
$__aplace[] = '?';
$__aexec[] = $col['value'];
}
$tsql .= substr($tfield,1);
$tsql .= ") VALUES (";
$tsql .= substr($tvalue,1);
$tsql .= ")";
$this->__db->Query($tsql);
}
$tsql = 'INSERT INTO '.$this->_ttable.' ('. implode(',', $__afield) .') VALUES ('. implode(',', $__aplace) .')';
$this->db->runQuery($tsql, $__aexec);
}
public function UpdateDB() {
$tsql = "UPDATE ".$this->__ttable." SET ";
$tfield = "";
for ($i=0; $i<count($this->__afield); $i++) {
$tfield .= ",".$this->__afield[$i]."=".(($this->__anomor[$i])?"":"'").$this->__avalue[$i].(($this->__anomor[$i])?"":"'");
public function UpdateDB(): void {
$__aplace = [];
$__awhere = [];
$__aexec = [];
foreach ($this->_afield as $col) {
if ($col['numbe'] === true) {
$__aplace[] = '`'.$col['field'].'`='. $col['value'];
} else {
$__aplace[] = '`'.$col['field'].'`=?';
$__aexec[] = $col['value'];
}
$tsql .= substr($tfield,1);
$tsql .= ($this->__twhere=="") ? "" : $this->__twhere;
$this->__db->Query($tsql);
}
foreach ($this->_awhere as $col) {
if ($col['numbe'] === true) {
$__awhere[] = '`'.$col['field'].'`='. $col['value'];
} else {
$__awhere[] = '`'.$col['field'].'`=?';
$__aexec[] = $col['value'];
}
}
$tsql = 'UPDATE '.$this->_ttable.' SET '. implode(',', $__aplace) .' WHERE '. implode(' AND ', $__awhere);
$this->db->runQuery($tsql, $__aexec);
}
public function DeleteDB() {
$tsql = "DELETE FROM ".$this->__ttable;
$tsql .= ($this->__twhere=="") ? "" : $this->__twhere;
$this->__db->Query($tsql);
public function DeleteDB(): void {
$__awhere = [];
$__aexec = [];
foreach ($this->_awhere as $col) {
if ($col['numbe'] === true) {
$__awhere[] = '`'.$col['field'].'`='. $col['value'];
} else {
$__awhere[] = '`'.$col['field'].'`=?';
$__aexec[] = $col['value'];
}
}
$tsql = 'DELETE FROM '.$this->_ttable.' WHERE '. implode(' AND ', $__awhere);
$this->db->runQuery($tsql, $__aexec);
}
public function LastInsertID() {
return $this->__db->LastInsertID();
public function LastInsertID(): int {
return $this->db->lastInsertId();
}
}
+103 -100
View File
@@ -3,133 +3,122 @@
/*******************************************************************
Module : /Data/Cache.php
Desc. : Class cache aplikasi
Desc. : Class cache css dan js aplikasi
Created By : Siau Pheng (siaupheng@3fonia.com).
Created Date : March 16th, 2008.
Last Modified : July 25th, 2026.
Last Modified : August 19th, 2026.
(c) 2008 - 2026, 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/
//OK
declare(strict_types=1);
namespace siaupheng\webapp\Data;
use flight\Engine;
use FilesystemIterator;
use MatthiasMullie\Minify;
use SplFileInfo;
final class Cache {
private $__cachedays = 0;
private $__cachedir = "";
private $__cssdir = "";
private $__localedir = "";
private $__jsdir = "";
private $__jsapp = "";
private $__realpath = "";
private $__rootdir = "";
private $__ini = [];
protected $__db = null;
protected Engine $app;
protected array $__asset = [];
public function __construct($db = null){
if (is_resource($db)) { $this->__db = $db; }
else $this->__db = new \siaupheng\webapp\DB\MySQL();
$rootdir = $_SESSION['__WEB_APP']['REAL_PATH'];
$this->__cachedir = $rootdir . 'chunks/';
public function __construct(?Engine $app = null, array $asset = []) {
$this->app = (empty($app) === true) ? Flight::app() : $app;
$this->__asset = $asset;
$rootdir = (defined('PROJECT_ROOT')) ? PROJECT_ROOT : $this->app->get('flight.root_dir');
$this->__cachedir = $rootdir . '/public/chunks/';
$this->__localedir = $rootdir . '/app/locale/';
$this->__jsapp = $rootdir . '/app/scripts/';
$this->__cssdir = __DIR__ . '/../../assets/css/';
$this->__localedir = $rootdir . 'assets/locale/';
$this->__jsdir = __DIR__ . '/../../assets/js/';
$this->__jsapp = $rootdir . 'apps/js/';
$this->__realpath = $rootdir;
$this->__rootdir = $rootdir . '/';
if (!is_dir($this->__cachedir)) mkdir($this->__cachedir, 0755, true);
if (!file_exists($this->__cachedir . "cache.ini")) {
$this->__ini = [
'css' => ['login_stamp'=>"0",'login_file'=>"",'index_stamp'=>"0",'index_file'=>"",'display_stamp'=>"0",'display_file'=>""],
'js' => ['login_stamp'=>"0",'login_file'=>"",'index_stamp'=>"0",'index_file'=>"",'display_stamp'=>"0",'display_file'=>""]
'login' => [ 'stamp' => 0, 'css' => "", 'js' => "", 'app' => "", ],
'index' => [ 'stamp' => 0, 'css' => "", 'js' => "", 'app' => "", ],
'display' => [ 'stamp' => 0, 'css' => "", 'js' => "", 'app' => "", ],
];
$this->save_ini();
}
$this->__ini = parse_ini_file($this->__cachedir . "cache.ini", true);
} else $this->__ini = parse_ini_file($this->__cachedir . "cache.ini", true);
}
private function gen_file($type="css", $mode="index") {
private function gen_file($mode = "index", $type = "css") {
$itime = 0;
$afile = [];
if ($type == "css") {
$_afile = array_unique($GLOBALS['A_CSS']);
$_afile = array_unique($this->__asset['css'][$mode] ?? []);
foreach ($_afile as $__key => $val) {
$afile[] = $this->__cssdir .$val;
if (!file_exists($this->__cssdir . $val)) continue;
$_file = new SplFileInfo($this->__cssdir . $val);
$afile[] = $_file->getRealPath();
$itime += $_file->getMTime();
}
if (file_exists($this->__realpath . 'assets/css/')) {
if ($handle = opendir($this->__realpath . 'assets/css/')) {
while (false !== ($file = readdir($handle))) {
if ($file == '.' || $file == '..' || is_dir($this->__realpath . 'assets/css/'.$file)) continue;
$afile[] = $this->__realpath . 'assets/css/' . $file;
if (is_dir($this->__rootdir . 'app/css/')) {
$iterator = new FilesystemIterator($this->__rootdir . 'app/css/', FilesystemIterator::SKIP_DOTS);
foreach ($iterator as $_file) {
if ($_file->isFile()) {
$afile[] = $_file->getRealPath();
$itime += $_file->getMTime();
}
closedir($handle);
}
}
} else if ($type == "js") {
$_afile = array_unique($GLOBALS['A_JS']);
$_afile = array_unique($this->__asset['js'][$mode] ?? []);
foreach ($_afile as $__key => $val) {
$afile[] = $this->__jsdir .$val;
}
if (file_exists($this->__realpath . 'assets/js/')) {
if ($handle = opendir($this->__realpath . 'assets/js/')) {
while (false !== ($file = readdir($handle))) {
if ($file == '.' || $file == '..' || is_dir($this->__realpath . 'assets/js/'.$file)) continue;
$afile[] = $this->__realpath . 'assets/js/' . $file;
}
closedir($handle);
}
if (!file_exists($this->__jsdir . $val)) continue;
$_file = new SplFileInfo($this->__jsdir . $val);
$afile[] = $_file->getRealPath();
$itime += $_file->getMTime();
}
// add locale file
$ljs = (isset($_SESSION['__WEB_USER']['LOCALE'])?$_SESSION['__WEB_USER']['LOCALE']:$_SESSION['__WEB_APP']['DEF_LOCALE']).".js";
$ljs = ($this->app->session()->get('__WEB_USER')['LOCALE'] ?? $this->app->session()->get('__WEB_APP')['DEF_LOCALE']).'.js';
if (is_dir($this->__localedir)) {
if ($handle = opendir($this->__localedir)) {
while (false !== ($file = readdir($handle))) {
$file = $this->__localedir . $file;
if (substr($file, -5) == $ljs) $afile[] = $this->__localedir .basename(str_replace("\\", "/", $file));
}
closedir($handle);
$iterator = new \FilesystemIterator($this->__localedir, \FilesystemIterator::SKIP_DOTS);
foreach ($iterator as $_file) {
if ($_file->isFile() && str_ends_with($_file->getFilename(), $ljs)) {
$afile[] = $_file->getRealPath();
$itime += $_file->getMTime();
}
}
}
$afile[] = $this->__jsapp . $mode . ".js";
} else if ($type == "app") {
$afile[] = $this->__jsapp ."sys/profile.js";
$afile[] = $this->__jsapp ."sys/chpasswd.js";
$amenu = explode(",", $_SESSION['__WEB_USER']['Menu_Grup'] .",". $_SESSION['__WEB_USER']['Menu']);
$tmenu = implode("','", array_unique($amenu));
$this->__db->Query("SELECT * FROM app_menu WHERE Link<>'' AND Kode IN ('".$tmenu."') ORDER BY Level, Urut");
while ($this->__db->Next()) {
$afile[] = $this->__jsapp . str_replace("php", "js", $this->__db->Row("Link"));
if ($mode === 'index') {
if (is_dir($this->__jsapp)) {
$dirIterator = new \RecursiveDirectoryIterator($this->__jsapp, \RecursiveDirectoryIterator::SKIP_DOTS);
$iterator = new \RecursiveIteratorIterator($dirIterator);
foreach ($iterator as $_file) {
if ($_file->isFile() && !in_array($_file->getFilename(), ['login.js','display.js'])) {
$afile[] = $_file->getRealPath();
$itime += $_file->getMTime();
}
}
return $afile;
}
} else {
if (file_exists($this->__jsapp . $mode . '.js')) {
$_file = new SplFileInfo($this->__jsapp . $mode . '.js');
$afile[] = $_file->getRealPath();
$itime += $_file->getMTime();
}
}
}
return [ $afile, $itime ];
}
private function check_file($afile) {
$lastmod = 0;
foreach ($afile as $nfile) {
if (file_exists($nfile)) {
$lastmod += filemtime($nfile);
}
}
if ($this->__cachedays > 0) {
if ($handle = opendir($this->__cachedir)) {
while (false !== ($file = readdir($handle))) {
if ($file == '.' || $file == '..' || is_dir($this->__cachedir.$file)) continue;
if ((time()-filemtime($this->__cachedir.$file)) > (86400*$this->__cachedays)) {
unlink($this->__cachedir . $file);
}
}
closedir($handle);
}
}
return $lastmod;
}
private function create_cache($type="css", $mode="index", $afile=[], $lastmod=0) {
private function create_cache($type = "css", $afile = [], $cachefile = "") {
$contents = ''; $smini = null;
$bpublic = ($_SERVER['SERVER_ADDR'] == "127.0.0.1") ? false : true;
$bpublic = ($this->app->request()->ip === '127.0.0.1') ? false : true;
if ($bpublic == true) {
if ($type=="css") {
$smini = new Minify\CSS;
@@ -147,15 +136,10 @@ final class Cache {
}
}
if ($bpublic) $contents = $smini->minify();
$cachefile = md5($mode . $lastmod) . ($type=="app"?".app":"") . ($type=="css" ? ".css" : ".js");
file_put_contents($this->__cachedir . $cachefile, $contents);
if ($type == "app") return;
$this->__ini[$type][$mode.'_stamp'] = $lastmod;
$this->__ini[$type][$mode.'_file'] = $cachefile;
$this->save_ini();
}
private function save_ini(){
private function save_ini() {
$content = "";
foreach ($this->__ini as $key => $elem) {
$content .= ($content==""?"":"\n"). "[".$key."]\n";
@@ -167,27 +151,46 @@ final class Cache {
file_put_contents($this->__cachedir . "cache.ini", $content);
}
public function Main($type="css", $mode="") {
if ($mode == "") $mode = "login";
if (($_SESSION['__WEB_USER']['UserID'] ?? 0) > 0) $mode = "index";
$afile = $this->gen_file($type, $mode);
$lastmod = $this->check_file($afile);
if ($lastmod <> intval($this->__ini[$type][$mode.'_stamp']) || !file_exists($this->__cachedir . $this->__ini[$type][$mode.'_file'])) {
$this->create_cache($type, $mode, $afile, $lastmod);
public function Cache($mode = "index") {
$is_modif = false;
foreach (['css','js','app'] as $type) {
[ $afile, $lastmod ] = $this->gen_file($mode, $type);
$cachefile = md5($mode . $type . $lastmod) . ($type=='css'?'.css':'.js');
if (!file_exists($this->__cachedir . $cachefile) || ((time()-(int)$this->__ini[$mode]['stamp']) > (86400*14))) {
$this->create_cache($type, $afile, $cachefile);
$this->__ini[$mode][$type] = $cachefile;
$this->__ini[$mode]['stamp'] = time();
$is_modif = true;
}
}
if ($is_modif === true) $this->save_ini();
$acache = [ 'CSS' => [], 'JS' => [], 'JSX' => [] ];
foreach ($this->__ini[$mode] as $_type => $_file) {
if ($_type == 'stamp') continue;
if (file_exists($this->__cachedir . $_file)) {
if ($_type === 'css') {
$acache['CSS'][] = 'chunks/' . $_file;
} else $acache['JS'][] = 'chunks/' . $_file;
}
return $_SESSION['__WEB_APP']['WEB_PATH'] ."chunks/". $this->__ini[$type][$mode.'_file'];
}
public function Apps() {
$id_user = (isset($_SESSION['__WEB_USER']) && is_array($_SESSION['__WEB_USER'])) ? $_SESSION['__WEB_USER']['UserID'] : 0;
$afile = $this->gen_file("app", $id_user);
$lastmod = $this->check_file($afile);
$appfile = md5($id_user . $lastmod) . ".app.js";
if (!file_exists($this->__cachedir . $appfile)) {
$this->create_cache("app", $id_user, $afile, $lastmod);
}
return $_SESSION['__WEB_APP']['WEB_PATH'] ."chunks/". $appfile;
$session = $this->app->session();
$aoption = $session->get('__WEB_APP');
$auser = $session->get('__WEB_USER');
$nonce = $this->app->get('csp_nonce');
$_secret = $aoption['APP_CODE'] .";". $aoption['APP_SID'] .";". $this->app->request()->getVar('HTTP_HOST') .";". "http://".$this->app->request()->getVar('HTTP_HOST') .";". isMobile() .";". ($aoption['AUTH_LEVEL']?$aoption['AUTH_LEVEL']:0);
$_suser = (user_logged()) ? $auser['Username'] .";". $auser['UserID'] .";". $auser['Grup_MenuID'] .";". $auser['Level'] : "nobody;999;999;9";
$acache['JSX'][] = '<script nonce="'.$nonce.'" type="text/javascript">';
$acache['JSX'][] = 'FoniaJS.setConfig("'.base64_encode($_secret).'", "'.base64_encode($_suser).'");';
$acache['JSX'][] = '$(document).ready(function(){';
if (user_logged()) $acache['JSX'][] = 'FoniaJS.loadMenu();';
$acache['JSX'][] = '});';
$acache['JSX'][] = '</script>';
return $acache;
}
}
?>
-75
View File
@@ -1,75 +0,0 @@
<?php
/*******************************************************************
Module : /Display.php
Desc. : HTML5 Page Generator (jQuery & Bootstrap)
Created By : Siau Pheng (siaupheng@3fonia.com).
Created Date : January 10th, 2008.
Last Modified : July 25th, 2026.
(c) 2008 - 2026, 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/
declare(strict_types=1);
namespace siaupheng\webapp;
final class Display {
public $version = "1.1.0";
private $apps = [];
private $cache = null;
protected $__db = null;
public function __construct($db = null){
if (is_resource($db)) { $this->__db = $db; }
else { $this->__db = new \siaupheng\webapp\DB\MySQL(); }
$this->apps = $_SESSION['__WEB_APP'];
if (($this->apps['TEMPLATE'] ?? "") == "") $this->apps['TEMPLATE'] = "display.php";
$this->cache = new \siaupheng\webapp\Data\Cache($this->__db);
}
public function TampilDisplay() {
// loading template file {{}}
$buffer = "";
if (file_exists($this->apps['REAL_PATH']."assets/templates/".$this->apps['TEMPLATE'])) {
$buffer = file_get_contents($this->apps['REAL_PATH']."assets/templates/".$this->apps['TEMPLATE']);
$buffer = preg_replace("/(?:(?:\\/\\*(?:[^*]|(?:\\*+[^*\\/]))*\\*+\\/)|(?:(?<!\\:)\\/\\/. *))/", "", $buffer);
}
$aoption = [...$this->apps, 'CSS_JS' => ""];
// penambahan file css + js + app-js
$aoption['CSS_JS'] = '<link rel="stylesheet" type="text/css" href="'.$this->cache->Main("css", "display").'">'."\n";
$aoption['CSS_JS'] .= '<script type="text/javascript" src="'.$this->cache->Main("js", "display").'"></script>'."\n";
$_secret = $aoption['APP_DISPLAY'] .";". $aoption['APP_SID'] .";". $_SERVER['HTTP_HOST'] .";". $aoption['WEB_PATH'] .";". "http://".$_SERVER['HTTP_HOST'].$aoption['WEB_PATH'] .";". isMobile() .";". ($aoption['AUTH_LEVEL']?$aoption['AUTH_LEVEL']:0) .";". $this->version;
$_suser = "nobody;999;999;9";
$aoption['CSS_JS'] .= '<script type="text/javascript" language="javascript">'."\n";
$aoption['CSS_JS'] .= 'FoniaJS.setConfig("'.base64_encode($_secret).'", "'.base64_encode($_suser).'");';
$aoption['CSS_JS'] .= '</script>'."\n";
// informasi tahun aplikasi dan pembuatan menu
if (strpos($buffer, '{{CREATOR_YEAR}}')===false) {
$aoption['REG_YEAR'] = ($aoption['REG_YEAR']!=date('Y')) ? $aoption['REG_YEAR']." - ".date('Y') : $aoption['REG_YEAR'];
} else {
$aoption['CREATOR_YEAR'] = ($aoption['CREATOR_YEAR']!=date('Y')) ? $aoption['CREATOR_YEAR']." - ".date('Y') : $aoption['CREATOR_YEAR'];
}
// perubahan variabel dari data konfigurasi
$aoption['APP_NAME_VER'] = $aoption['APP_NAME']." v".$aoption['APP_VER'];
$aoption['APP_NAMES_VER'] = $aoption['APP_NAMES']." v".$aoption['APP_VER'];
$aoption['APP_NAMES_UP'] = strtoupper($aoption['APP_NAMES'] ?? "");
$aoption['REG_NAME_UP'] = strtoupper($aoption['REG_NAME'] ?? "");
$aoption['REG_CITY_UP'] = strtoupper($aoption['REG_CITY'] ?? "");
$output = preg_replace_callback('/\{\{([a-zA-Z0-9_]+)\}\}/', fn($matches) => isset($aoption[$matches[1]]) ? $aoption[$matches[1]] : "", $buffer);
echo $output;
}
}
?>
+9 -9
View File
@@ -12,51 +12,51 @@
*******************************************************************/
//OK
declare(strict_types=1);
if (!function_exists('user_level')) {
function user_level($level = 9) {
if ($_SESSION['__WEB_USER']['Level'] <= $level) return true;
if (Flight::session()->get('__WEB_USER', ['Level'=>9]) <= $level) return true;
return false;
}
}
if (!function_exists('user_level_not')) {
function user_level_not($level = 9) {
if ($_SESSION['__WEB_USER']['Level'] !== $level) return true;
if (Flight::session()->get('__WEB_USER', ['Level'=>9]) !== $level) return true;
return false;
}
}
if (!function_exists('user_logged')) {
function user_logged() {
if (isset($_SESSION['__WEB_USER'])) return true;
return false;
return !empty(Flight::session()->get('__WEB_USER'));
}
}
if (!function_exists('user_id')) {
function user_id($idigit = 0) {
if ($idigit > 0) return isi_nol($_SESSION['__WEB_USER']['UserID'], $idigit);
return $_SESSION['__WEB_USER']['UserID'];
if ($idigit > 0) return isi_nol((int)Flight::session()->get('__WEB_USER', ['UserID'=>0])['UserID'], $idigit);
return (int)Flight::session()->get('__WEB_USER', ['UserID'=>0])['UserID'];
}
}
if (!function_exists('user_user')) {
function user_user() {
return $_SESSION['__WEB_USER']['Username'];
return (string)Flight::session()->get('__WEB_USER', ['Username'=>''])['Username'];
}
}
if (!function_exists('user_unix')) {
function user_unix() {
return $_SESSION['__WEB_USER']['UNIX'];
return (string)Flight::session()->get('__WEB_USER', ['UNIX'=>'0'])['UNIX'];
}
}
if (!function_exists('user_nama')) {
function user_nama() {
return $_SESSION['__WEB_USER']['Nama'];
return (string)Flight::session()->get('__WEB_USER', ['Nama'=>''])['Nama'];
}
}
-35
View File
@@ -1,35 +0,0 @@
<?php
/*******************************************************************
Module : /Function/JSON.php
Desc. : Fungsi Custom JSON
Created By : Siau Pheng (siaupheng@3fonia.com).
Created Date : April 14th, 2012.
Last Modified : April 29th, 2022.
(c) 2012 - 2022, 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/
declare(strict_types=1);
if (!function_exists('is_json')) {
function is_json($string) {
json_decode($string);
return json_last_error() === JSON_ERROR_NONE;
}
}
if (!function_exists('send_json')) {
function send_json($ajson = array(), $bempty = false) {
if (count($ajson) > 0 || $bempty == true) {
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Content-type: application/json');
echo json_encode($ajson);
}
}
}
?>
+16 -7
View File
@@ -16,9 +16,9 @@ declare(strict_types=1);
/*************************** FORMAT ANGKA / CURRENCY *****************************/
if (!function_exists('rupiah')) {
function rupiah($angka = 0, $desi = 0) {
return number_format(doubleval($angka), intval($desi), ",", ".");
if (!function_exists('rupiah')) {//oke
function rupiah(string|float $angka = 0, int $desi = 0) {
return number_format((float)$angka, $desi, ",", ".");
}
}
@@ -58,10 +58,10 @@ if (!function_exists('kurung2')) {
}
}
if (!function_exists('uang')) {
function uang($angka = 0, $desi = 0) {
$angka = str_replace(",","",$angka);
return number_format(doubleval($angka), intval($desi));
if (!function_exists('uang')) {//oke
function uang(string|float $angka = '0', int $desi = 0) {
$angka = str_replace(",", "", (string)$angka);
return number_format((float)$angka, $desi);
}
}
@@ -350,4 +350,13 @@ if (!function_exists('format_bytes')) {
}
}
if (!function_exists('random_color')) {
function random_color($trans = "0.6") {
$col_r = mt_rand( 0, 255 );
$col_g = mt_rand( 0, 255 );
$col_b = mt_rand( 0, 255 );
return "rgba(".$col_r.",".$col_g.",".$col_b.",".$trans.")";
}
}
?>
+55 -60
View File
@@ -3,7 +3,7 @@
/*******************************************************************
Module : /Web/Auth.php
Desc. : Fungsi login dan user checking
Desc. : Class login dan user checking
Created By : Siau Pheng (siaupheng@3fonia.com).
Created Date : March 16th, 2008.
Last Modified : April 3rd, 2022.
@@ -12,126 +12,121 @@
*******************************************************************/
//OK
declare(strict_types=1);
namespace siaupheng\webapp\Web;
final class Auth {
private $__id_reg = 0;
protected $__db = null;
use flight\Engine;
use flight\Session;
use flight\database\SimplePdo;
public function __construct($db = null){
if (is_resource($db)) { $this->__db = $db; }
else { $this->__db = new \siaupheng\webapp\DB\MySQL(); }
$this->__id_reg = $_SESSION['__WEB_APP']['REG_ID'];
final class Auth {
private int $__id_reg = 0;
protected Engine $app;
protected SimplePdo $db;
protected Session $session;
public function __construct(?Engine $app = null){
$this->app = (empty($app) === true) ? \Flight::app() : $app;
$this->db = $this->app->db();
$this->session = $this->app->session();
$this->__id_reg = (int)$this->session->get('__WEB_APP', ['REG_ID'=>0])['REG_ID'];
}
public function set_id_reg($id = 0) {
if ($id > 0) $this->__id_reg = $id;
if ($id > 0) $this->__id_reg = (int)$id;
}
public function user_check($user, $pass) {
$i_hasil = 0;
$this->__db->Query("SELECT COUNT(*) Ada FROM app_operator WHERE Username='".$this->__db->safeSQL($user)."' AND Password=MD5('".$this->__db->safeSQL($pass)."') AND Aktif=1");
if ($this->__db->Next()) $i_hasil = $this->__db->Row("Ada", 0);
$i_hasil = $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($user) {
$adata = [];
$this->__db->Query("SELECT *,DECODE(Menu,'".$this->__id_reg."') Menu2 FROM app_operator WHERE Username='".$this->__db->SafeSQL($user)."'");
if ($this->__db->Next()) {
$adata = $this->__db->AllRow();
$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']);
}
if (!isset($_SESSION['APP_TOKEN'])) {
if (empty($this->session->get('APP_TOKEN'))) {
$_token = $this->genToken(60);
$_SESSION['APP_TOKEN'] = $_token;
$this->__db->Query("INSERT INTO app_token SET Token='".$_token."',UserID='".$adata['UserID']."',IP='".$_SERVER['REMOTE_ADDR']."'");
$this->session->set('APP_TOKEN', $_token);
$this->db->insert('app_token', [ 'Token' => $_token, 'UserID' => $adata['UserID'], 'IP' => $this->app->request()->ip ]);
}
if (intval($adata['Grup_MenuID']) > 0) $adata['Menu_Grup'] = $this->user_allmenu($adata['Grup_MenuID']);
if ((int)$adata['Grup_MenuID'] > 0) $adata['Menu_Grup'] = $this->user_allmenu($adata['Grup_MenuID']);
$adata['UNIX'] = time();
$adata['LOCALE'] = $_SESSION['__WEB_APP']['DEF_LOCALE'];
$adata['LOCALE'] = $this->session->get('__WEB_APP', ['DEF_LOCALE'=>'id'])['DEF_LOCALE'];
return $adata;
}
public function gen_module_menu() {
$amodul = []; $aallow = [];
if ($_SESSION['__WEB_APP']['APP_MODULE']) {
$this->__db->Query("SELECT * FROM app_menu_grup WHERE Grup_MenuID='".$_SESSION['__WEB_USER']['Grup_MenuID']."' LIMIT 1");
if ($this->__db->Next()) $aallow = ($this->__db->Row("Modul_Akses")=="") ? array() : explode(",", $this->__db->Row("Modul_Akses"));
$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']]);
$aallow = explode(",", $tallow);
if (count($aallow) > 0) {
$this->__db->Query("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 ($this->__db->Next()) {
if (!in_array($this->__db->Row("Modul"), $aallow) || $this->__db->Row("Modul")==$_SESSION['__WEB_APP']['APP_MODULE']) continue;
$amodul[] = $this->__db->AllRow();
$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;
$amodul[] = $row;
}
}
}
$_SESSION['__WEB_USER']['MENU_MODUL'] = $amodul;
$auser = $this->session->get('__WEB_USER', []);
$auser['MENU_MODUL'] = $amodul;
$this->session->set('__WEB_USER', $auser);
}
public function user_allmenu($id_grup = 0) {
$allmenu = "";
$this->__db->Query("SELECT DECODE(Menu,'".$this->__id_reg."') MenuX FROM app_menu_grup WHERE Grup_MenuID='".$id_grup."'");
if ($this->__db->Next()) $allmenu = $this->__db->Row("MenuX");
public function user_allmenu(int $id_grup = 0) {
$allmenu = $this->db->fetchField('SELECT DECODE(Menu,?) MenuX FROM app_menu_grup WHERE Grup_MenuID=?', [$this->__id_reg, $id_grup]);
return $allmenu;
}
public function user_check_level($user, $level = 9) {
$i_hasil = 0;
$this->__db->Query("SELECT COUNT(*) Ada FROM app_operator WHERE Username='".$this->__db->safeSQL($user)."' AND Level<='".$this->__db->safeSQL($level)."' AND Aktif=1");
if ($this->__db->Next()) $i_hasil = $this->__db->Row("Ada", 0);
$i_hasil = $this->db->fetchField('SELECT COUNT(*) FROM app_operator WHERE Username=? AND Level<=? AND Aktif=1', [$user, $level]);
return ($i_hasil > 0 ? true : false);
}
public function user_log() {
if ($_SESSION['__WEB_APP']['USER_LOG'] == false) return;
$a_hasil = array();
$this->__db->Query("SELECT * FROM app_logs WHERE UserID='".user_id()."' ORDER BY Last_Date DESC LIMIT 1");
if ($this->__db->Next()) $a_hasil = $this->__db->AllRow();
$a_hasil = $this->db->fetchRow('SELECT * FROM app_logs WHERE UserID=? ORDER BY Last_Date DESC LIMIT 1', [user_id()])->getData();
if (count($a_hasil) > 0) {
$this->__db->Query("UPDATE app_operator SET Last_IP='".$a_hasil['Last_IP']."',Last_Date='".$a_hasil['Last_Date']."' WHERE UserID='".user_id()."'");
$this->db->update('app_operator', [ 'Last_IP' => $a_hasil['Last_IP'], 'Last_Date' => $a_hasil['Last_Date'] ], 'UserID=?', [user_id()]);
}
$this->__db->Query("INSERT IGNORE INTO app_logs SELECT UserID,Token,IP,DateStamp FROM app_token WHERE Token='".$_SESSION['APP_TOKEN']."'");
$this->db->runQuery('INSERT IGNORE INTO app_logs SELECT UserID,Token,IP,DateStamp FROM app_token WHERE Token=?', [$this->session->get('APP_TOKEN')]);
}
public function logout() {
$this->__db->Query("DELETE FROM app_token WHERE Token='".$_SESSION['APP_TOKEN']."'");
$this->db->delete('app_token', 'Token=?', [$this->session->get('APP_TOKEN')]);
}
public function token_check() {
$hasil = false;
$this->__db->Query("SELECT * FROM app_token WHERE Token='".$_SESSION['APP_TOKEN']."'");
if ($this->__db->Next()) $hasil = true;
if ($hasil == true) $this->__db->Query("UPDATE app_token SET DateStamp=NOW() WHERE Token='".$_SESSION['APP_TOKEN']."'");
public function token_check(string $token) {
$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')]);
return $hasil;
}
public function token_update() {
$this->__db->Query("UPDATE app_token SET DateStamp=NOW() WHERE Token='".$_SESSION['APP_TOKEN']."'");
$this->db->update('app_token', ['DateStamp' => 'NOW()'], 'Token=?', [$app->session->get('APP_TOKEN')]);
}
public function redirect($appUrl) {
public function redirect(string $appUrl) {
$source = parse_url($appUrl);
$desti = "";
$this->__db->Query("SELECT * FROM app_host WHERE Nama_Host='".$source['host']."'");
if ($this->__db->Next()) {
$desti = $source['scheme'].$source['host'].$source['path'].'?'.'auth='.$_SESSION['APP_TOKEN'];
$hasil = (bool)$this->db->fetchField('SELECT 1 FROM app_host WHERE Nama_Host=?', [$source['host']]);
if ($hasil === true) {
$desti = $source['scheme'].$source['host'].$source['path'].'?'.'auth='.$app->session->get('APP_TOKEN');
}
return $desti;
}
private function genToken($length = 16) {
private function genToken(int $length = 16) {
$pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
return substr(str_shuffle(str_repeat($pool, 5)), 0, $length);
}
public function getUserByToken($token) {
$hasil = "";
$this->__db->Query("SELECT * FROM app_operator WHERE UserID IN (SELECT UserID FROM app_token WHERE Token='".$token."') LIMIT 1");
if ($this->__db->Next()) $hasil = $this->__db->Row("Username");
public function getUserByToken(string $token) {
$hasil = $this->db->fetchField('SELECT Username FROM app_operator WHERE UserID IN (SELECT UserID FROM app_token WHERE Token=?) LIMIT 1', [$token ??$app->session->get('APP_TOKEN')]);
return $hasil;
}
}
+177 -233
View File
@@ -6,43 +6,51 @@
Desc. : Form Generator (jQuery & Bootstrap)
Created By : Siau Pheng (siaupheng@3fonia.com).
Created Date : February 27th, 2008.
Last Modified : December 26th, 2025.
Last Modified : August 19th, 2026.
(c) 2008 - 2025, 3FONIA Software; WWW.3FONIA.COM.
(c) 2008 - 2026, 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/
//OK
declare(strict_types=1);
namespace siaupheng\webapp\Web;
final class Form {
private $__aform = array();
private $__ahide = array();
private $__button = null;
private $__nbtnsize = 2;
protected $__db = null;
use flight\Engine;
use flight\Session;
use flight\database\SimplePdo;
public function __construct($db = null){
if (is_resource($db)) { $this->__db = $db; }
else { $this->__db = new \siaupheng\webapp\DB\MySQL(); }
$this->__button = new Button();
final class Form {
private $__aform = [];
private $__ahide = [];
protected Engine $app;
protected SimplePdo $db;
protected Session $session;
public function __construct(?Engine $app = null){
$this->app = (empty($app) === true) ? \Flight::app() : $app;
$this->db = $this->app->db();
$this->session = $this->app->session();
}
public function option($tlabel="", $tfield, $tvalue=null, $benable=true, $breq=false, $aarr=array(), $thelp="", $tchange=null, $bmulti=false, $bgroup=false) {
$_enab = ($benable==true) ? "" : ' disabled=true';
$_req = ($breq==true) ? " required=true" : "";
$_change = ($tchange==null) ? '' : ' onchange="'.$tchange.'"';
$_multi = ($bmulti==true) ? ' multiple' : '';
$tout = '<select class="form-select option-tags" id="'.$tfield.'" name="'.$tfield.'"'.$_enab.$_change.$_req.$_multi.' >';
if (count($aarr)>0) {
public function option(string $label, string $field, string|int|null $value=null, bool $enable=true, bool $req=false, array $arr=[], ?string $help=null, ?string $change=null, bool $multi=false, bool $group=false): string {//oke
$_opsi = '';
if (!empty($change)) $_opsi .= ' ochan="'.$change.'"';
if ($enable===false) $_opsi .= ' disabled=true';
if ($req===true) $_opsi .= ' required=true';
if ($multi===true) $_opsi .= ' multiple';
$tout = '<select class="form-select option-tags" id="'.$field.'" name="'.$field.'"'.$_opsi.' >';
if (count($arr)>0) {
$n_group = 0;
foreach ($aarr as $key => $val) {
$aval = [$value];
if ($multi===true) $aval = explode(",", ($value ?? "0"));
foreach ($arr as $key => $val) {
$_val2 = $val; $olabel = "";
if (is_array($val)) {
$_val2 = $val[0];
if ($bgroup) {
if (1==$val[1]) {
if ($group) {
if (1 == $val[1]) {
if (0 < $n_group++) $tout .= '</optgroup>';
$tout .= '<optgroup label="'.$_val2.'">';
continue;
@@ -52,274 +60,210 @@ final class Form {
}
}
$tout .= '<option value="'.$key.'"'.$olabel;
$aval = array($tvalue);
if ($bmulti==true) $aval = explode(",", ($tvalue ?? "0"));
$tout .= (in_array($key, $aval)) ? ' selected="selected"' : "";
$tout .= '>'.$_val2.'</option>';
}
if ($bgroup && $n_group>0) $tout .= '</optgroup>';
if ($group && $n_group>0) $tout .= '</optgroup>';
}
$tout .= '</select>';
$this->__aform[$tfield] = array('label'=>$tlabel, 'help'=>$thelp, 'form'=>$tout);
$this->__aform[$field] = [ 'label' => $label, 'help' => $help, 'form' => $tout ];
return $tout;
}
public function option_db($tlabel="", $tfield, $tvalue=null, $benable=true, $breq=false, $ttable=null, $afield=null, $twhere=null, $addarray=null, $thelp=null, $tchange=null, $bmulti=false) {
$afield = ($afield==null) ? array("ID", "Nama", "Label") : $afield;
$_twhere = ($twhere==null) ? "" : " WHERE ".$twhere;
$_twhere .= ($twhere===null || stripos($twhere,"ORDER BY")===false) ? " ORDER BY ".$afield[1] : "";
public function option_db(string $label, string $field, string|int|null $value=null, bool $enable=true, bool $req=false, ?string $table=null, ?array $afield=null, ?string $where=null, ?array $aarray=null, ?string $help=null, ?string $change=null, bool $multi=false): string {//oke
$_twhere = '';
if (!is_array($afield)) $afield = ["ID", "Nama", "Label"];
if (!empty($where)) {
$_twhere = ' WHERE '.$where;
$_twhere .= (stripos($twhere,"ORDER BY")===false) ? ' ORDER BY '.$afield[1] : '';
}
$ahasil = [];
if (is_array($addarray)) $ahasil[$addarray[0]] = (!isset($afield[2])) ? $addarray[1] : [$addarray[1], $addarray[2]];
if ($ttable<>null) {
$this->__db->Query("SELECT ".implode(",", $afield)." FROM ".$ttable.$_twhere);
while ($this->__db->Next()) {
$ahasil[$this->__db->Row($afield[0])] = (!isset($afield[2])) ? $this->__db->Row($afield[1]) : [$this->__db->Row($afield[1]), $this->__db->Row($afield[2])];
if (is_array($aarray)) $ahasil[$aarray[0]] = (!isset($afield[2])) ? $aarray[1] : [$aarray[1], $aarray[2]];
if (!empty($table)) {
$aopsi = $this->db->fetchAll("SELECT ".implode(",", $afield)." FROM ".$table.$_twhere);
foreach ($aopsi as $opsi) {
$ahasil[$opsi[$afield[0]]] = (!isset($afield[2])) ? $opsi[$afield[1]] : [$opsi[$afield[1]], $opsi[$afield[2]]];
}
}
$tout = $this->option($tlabel, $tfield, $tvalue, $benable, $breq, $ahasil, $thelp, $tchange, $bmulti);
return $this->option($label, $field, $value, $enable, $req, $ahasil, $help, $change, $multi);
}
public function option_que(string $label, string $field, string|int|null $value=null, bool $enable=true, bool $req=false, ?string $query=null, ?array $afield=null, ?array $aarray=null, ?string $help=null, ?string $change=null): string {//oke
if (!is_array($afield)) $afield = ["ID", "Nama", "Label"];
$ahasil = [];
if (is_array($aarray)) $ahasil[$aarray[0]] = (!isset($afield[2])) ? $aarray[1] : [$aarray[1], $aarray[2]];
if (!empty($query)) {
$stat = $this->db->runQuery($query);
while ($row = $stat->fetch()) {
$ahasil[$row[$afield[0]]] = (!isset($afield[2])) ? $row[$afield[1]] : [$row[$afield[1]], $row[$afield[2]]];
}
}
return $this->option($label, $field, $value, $enable, $req, $ahasil, $help, $change);
}
public function option_jkl(string $label, string $field, string|int|null $value=null, bool $enable=true, bool $req=false, ?string $help=null, ?string $change=null): string {//oke
return $this->option($label, $field, $value, $enable, $req, ["L" => "Laki-Laki", "P" => "Perempuan"], $help, $change);
}
public function option_ulevel(string $label, string $field, int $value=9, bool $enable=true, bool $req=false, ?string $help=null, ?string $change=null): string {//oke
return $this->option($label, $field, $value, $enable, $req, $this->session->get('__WEB_APP')['USER_LEVEL'], $help, $change);
}
public function radio(string $label, string $field, string|int|null $value=null, bool $enable=true, bool $req=false, array $arr=[], ?string $help=null, ?string $change=null): string {//oke
$_val = array_values($arr);
if (empty($value)) $value = $_val[0];
$_opsi = '';
if (!empty($change)) $_opsi .= ' ochan="'.$change.'"';
if ($enable===false) $_opsi .= ' disabled=true';
if ($req===true) $_opsi .= ' required=true';
$tout = '<input type="hidden" id="'.$field.'" value="'.$value.'" />';
if (count($arr)>0) {
foreach ($arr as $key => $val) {
$tout .= '<div class="col-form-label form-check form-check-inline me-2"><input class="form-check-input" id="'.$field.$key.'" type="radio" value="'.$key.'" name="'.$field.'"'.$_opsi;
$tout .= ($key == $value) ? ' checked="checked"' : '';
$tout .= '><label class="form-check-label" for="'.$field.$key.'">'.$val.'</label></div>';
}
}
$this->__aform[$field] = [ 'label' => $label, 'help' => $help, 'form' => $tout ];
return $tout;
}
public function option_que($tlabel="", $tfield, $tvalue=null, $benable=true, $breq=false, $tquery=null, $afield=null, $addarray=null, $thelp="", $tchange=null) {
$afield = ($afield==null) ? array("ID", "Nama", "Label") : $afield;
$ahasil = array();
if (is_array($addarray)) $ahasil[$addarray[0]] = (!isset($afield[2])) ? $addarray[1] : array($addarray[1], $addarray[2]);
if ($tquery<>null) {
$this->__db->Query($tquery);
while ($this->__db->Next()) {
$ahasil[$this->__db->Row($afield[0])] = (!isset($afield[2])) ? $this->__db->Row($afield[1]) : array($this->__db->Row($afield[1]), $this->__db->Row($afield[2]));
}
}
$tout = $this->option($tlabel, $tfield, $tvalue, $benable, $breq, $ahasil, $thelp, $tchange);
return $tout;
public function radio_jkl(string $label, string $field, ?string $value=null, bool $enable=true, bool $req=false, ?string $help=null, ?string $change=null): string {//oke
return $this->radio($label, $field, $value, $enable, $req, ["L" => "Laki-Laki", "P" => "Perempuan"], $help, $change);
}
public function option_jkl($tlabel="", $tfield, $tvalue=null, $benable=true, $breq=false, $thelp="", $tchange=null) {
$akel = array("L" => "Laki-Laki", "P" => "Perempuan");
$tout = $this->option($tlabel, $tfield, $tvalue, $benable, $breq, $akel, $thelp, $tchange);
return $tout;
public function radio_gd(string $label, string $field, ?string $value=null, bool $enable=true, bool $req=false, ?string $help=null, ?string $change=null): string {//oke
if (!empty($value)) $value = 'X';
return $this->radio($label, $field, $value, $enable, $req, ["A"=>"A", "B"=>"B", "AB"=>"AB", "O"=>"O", "X"=>"NONE"], $help, $change);
}
public function option_ulevel($tlabel="", $tfield, $tvalue=9, $benable=true, $breq=false, $thelp="", $tchange=null) {
$tout = $this->option($tlabel, $tfield, $tvalue, $benable, $breq, $_SESSION['__WEB_APP']['USER_LEVEL'], $thelp, $tchange);
return $tout;
}
public function radio($tlabel="", $tfield, $tvalue=null, $benable=true, $breq=false, $aarr=array(), $thelp="", $tchange=null) {
if ($tvalue == null) {
$tmp_key = array_keys($aarr);
$tvalue = $tmp_key[0];
}
$_enab = ($benable==true) ? "" : ' disabled=true';
$_req = ($breq==true) ? " required=true" : "";
$_change = ($tchange==null) ? "" : ' onchange="'.$tchange.'"';
$tout = '<input type="hidden" id="'.$tfield.'" value="'.$tvalue.'" />';
if (count($aarr)>0) {
foreach ($aarr as $key => $val) {
$tout .= '<div class="form-check form-check-inline me-2"><input class="form-check-input" id="'.$tfield.$key.'" type="radio" value="'.$key.'" name="'.$tfield.'"';
$tout .= ($key == $tvalue) ? ' checked="checked"' : '';
$tout .= ' onclick="if(this.checked)$(\'#'.$tfield.'\').val(this.value);"'.$_enab.$_change.$_req;
$tout .= '><label class="form-check-label" for="'.$tfield.$key.'">'.$val.'</label></div>';
}
}
$this->__aform[$tfield] = array('label'=>$tlabel, 'help'=>$thelp, 'form'=>$tout);
return $tout;
}
public function radio_jkl($tlabel="", $tfield, $tvalue=null, $benable=true, $breq=false, $thelp="", $tchange=null) {
$tout = $this->radio($tlabel, $tfield, $tvalue, $benable, $breq, array("L" => "Laki-Laki", "P" => "Perempuan"), $thelp, $tchange);
return $tout;
}
public function radio_gd($tlabel="", $tfield, $tvalue=null, $benable=true, $breq=false, $thelp="", $tchange=null) {
$tvalue = ($tvalue=="") ? "X" : $tvalue;
$tout = $this->radio($tlabel, $tfield, $tvalue, $benable, $breq, array("A"=>"A", "B"=>"B", "AB"=>"AB", "O"=>"O", "X"=>"NONE"), $thelp, $tchange);
return $tout;
}
public function checkbox($tlabel="", $tfield, $tvalue=null, $benable=true, $breq=false, $avalue=array(), $thelp="", $tchange=null) {
$bhasil = ((is_string($tvalue) && in_array($tvalue,array("N","T","0"))) or (is_numeric($tvalue) && $tvalue==0) or (is_bool($tvalue) && $tvalue===false) or empty($tvalue)) ? true : false;
$_enab = ($benable==true) ? "" : ' disabled=true';
$_req = ($breq==true) ? " required=true" : "";
$_change = ' onchange="this.value=(this.checked)?\''.$avalue[0].'\':\''.$avalue[1].'\';'.($tchange==null?'':$tchange).'"';
$tout = '<input type="checkbox" class="form-check-input" id="'.$tfield.'" name="'.$tfield.'" value="'.($bhasil?$avalue[1]:$avalue[0]).'"'.$_enab.$_change.$_req;
$tout .= ($bhasil==false) ? ' checked="checked"' : '';
$tout .= '>';
$this->__aform[$tfield] = array('label'=>$tlabel, 'help'=>$thelp, 'form'=>$tout);
return $tout;
}
public function switch($tlabel="", $tfield, $tvalue=null, $benable=true, $breq=false, $aarr=array(), $thelp="", $tchange=null) {
$_val = array_values($aarr);
$_enab = ($benable==true) ? "" : ' disabled=true';
$_req = ($breq==true) ? " required=true" : "";
$_change = ($tchange==null) ? ' onchange="this.value=(this.checked)?\''.$_val[0].'\':\''.$_val[1].'\';"' : ' onchange="this.value=(this.checked)?\''.$_val[0].'\':\''.$_val[1].'\';'.$tchange.'"';
$tout = '<div class="form-check form-switch"><input class="form-check-input me-0" id="'.$tfield.'" name="'.$tfield.'" type="checkbox" role="switch" value="'.$tvalue.'"'.$_enab.$_change.$_req;
$tout .= ($_val[0] == $tvalue) ? ' checked="checked"' : '';
public function checkbox(string $label, string $field, string|int|null $value=null, bool $enable=true, bool $req=false, array $arr=[], ?string $help=null, ?string $change=null): string {//oke
$_val = array_values($arr);
if (empty($value)) $value = $_val[1];
$_opsi = ' odata="'.htmlspecialchars(json_encode($arr)).'"';
if (!empty($change)) $_opsi .= ' ochan="'.$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;
$tout .= ($_val[0] == $value) ? ' checked="checked"' : '';
$tout .= '></div>';
$this->__aform[$tfield] = array('label'=>$tlabel, 'help'=>$thelp, 'form'=>$tout);
$this->__aform[$field] = [ 'label' => $label, 'help' => $help, 'form' => $tout];
return $tout;
}
//todo: belum diupgrade !!
public function group_cbox($tfield, $tkey=null, $tclass=null, $ttable=null, $afield=null, $ncol=2) {
if ($ttable==null) return;
$avalue = explode(",", $tkey);
$afield = ($afield==null) ? array("ID", "Nama") : $afield;
$_twhere = ($twhere=="") ? " ORDER BY ".$afield[0] : " WHERE ".$twhere;
$tout = "<input id=\"".$tfield."\" value=\"".$tkey."\" type='hidden' class='cgrpbox' /><table width='100%' style='margin:1px 0;padding:2px 2px;'><tr>";
$nkol = 1;
$this->__db->Query("SELECT ".implode(",", $afield)." FROM ".$ttable.$_twhere);
while ($this->__db->Next()) {
$tout .= "<td width='".round(100/$ncol)."%'><label><input type='checkbox' id='".$tfield."_cgrpbox_".$this->__db->Row($afield[0])."' value='".$this->__db->Row($afield[0])."'";
for ($i=0; $i<count($avalue); $i++) {
if ($avalue[$i]==$this->__db->Row($afield[0])) {
$tout .= " checked=\"checked\"";
break;
}
}
$tout .= " class='text ".$tclass."' />&nbsp;".$this->__db->Row($afield[1])."</label></td>";
if ($nkol==$ncol) {
$tout .= "</tr><tr>";
$nkol = 0;
}
$nkol++;
}
$tout .= "</tr></table>";
$this->__aform[$tfield] = $tout;
public function switch(string $label, string $field, string|int|null $value=null, bool $enable=true, bool $req=false, array $arr=[], ?string $help=null, ?string $change=null): string {//oke
$_val = array_values($arr);
if (empty($value)) $value = $_val[1];
$_opsi = ' odata="'.htmlspecialchars(json_encode($arr)).'"';
if (!empty($change)) $_opsi .= ' ochan="'.$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;
$tout .= ($_val[0] == $value) ? ' checked="checked"' : '';
$tout .= '></div>';
$this->__aform[$field] = [ 'label' => $label, 'help' => $help, 'form' => $tout ];
return $tout;
}
public function textbox($tlabel="", $tfield, $tvalue=null, $benable=true, $breq=false, $ttype="text", $holdtxt=null, $nmaxsize=null, $thelp="", $tkeyup=null, $tblur=null) {
$_enab = ($benable==true) ? "" : ' readonly';
$_req = ($breq==true) ? " required=true" : "";
$_max = ($nmaxsize==null) ? "" : ' maxlength="'.$nmaxsize.'"';
$_keyup = ($tkeyup==null) ? "" : ' onkeyup="'.$tkeyup.'"';
$_blur = ($tblur==null) ? "" : ' onblur="'.$tblur.'"';
$_holdtxt = ($holdtxt==null) ? "" : ' placeholder="'.$holdtxt.'"';
$_tclass = "";
if (in_array($ttype,array("pickdate","picktime"))) {
$_tclass = ' '.$ttype;
$ttype = "text";
public function textbox(string $label, string $field, string|int|null $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 {//oke
$_opsi = '';
if (!empty($keyup)) $_opsi .= ' okyup="'.$keyup.'"';
if (!empty($blur)) $_opsi .= ' oblur="'.$blur.'"';
if (!empty($holdtxt)) $_opsi .= ' placeholder="'.$holdtxt.'"';
if (!empty($maxsize)) $_opsi .= ' maxlength="'.$maxsize.'"';
if ($enable===false) $_opsi .= ' readonly';
if ($req===true) $_opsi .= ' required=true';
$_tclass = '';
if (in_array($type, ['pickdate','picktime','integer','angka','double'])) {
$_tclass = ' '.$type;
if ($type === 'double') $value = uang2($value);
$type = "text";
}
if (in_array($ttype,array("double"))) {
$_tclass = ' '.$ttype;
$tvalue = uang2($tvalue);
}
$tout = '<input type="'.$ttype.'" class="form-control'.$_tclass.'" id="'.$tfield.'" name="'.$tfield.'" value="'.$tvalue.'"'.$_enab.$_max.$_keyup.$_blur.$_holdtxt.$_req.' />';
$this->__aform[$tfield] = array('label'=>$tlabel, 'help'=>$thelp, 'form'=>$tout);
$tout = '<input type="'.$type.'" class="form-control'.$_tclass.'" id="'.$field.'" name="'.$field.'" value="'.$value.'"'.$_opsi.' />';
$this->__aform[$field] = [ 'label' => $label, 'help' => $help, 'form' => $tout ];
return $tout;
}
public function textauto($tlabel="", $tfield, $avalue=['value'=>0,'text'=>""], $benable=true, $breq=false, $holdtxt=null, $nmaxsize=null, $thelp="") {
$_enab = ($benable==true) ? "" : ' disabled=true';
$_req = ($breq==true) ? " required=true" : "";
$_max = ($nmaxsize==null) ? "" : ' maxlength="'.$nmaxsize.'"';
$_holdtxt = ($holdtxt==null) ? "" : ' placeholder="'.$holdtxt.'"';
$tout = '<input type="search" class="form-control" id="'.$tfield.'" name="'.$tfield.'" value="'.$avalue['text'].'"'.$_enab.$_max.$_holdtxt.$_req.' autocomplete="off" />';
$this->__aform[$tfield] = array('label'=>$tlabel, 'help'=>$thelp, 'form'=>$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 {//oke
$_opsi = '';
if (!empty($holdtxt)) $_opsi .= ' placeholder="'.$holdtxt.'"';
if (!empty($maxsize)) $_opsi .= ' maxlength="'.$maxsize.'"';
if ($enable===false) $_opsi .= ' disabled=true';
if ($req===true) $_opsi .= ' required=true';
$tout = '<input type="search" class="form-control" id="'.$field.'" name="'.$field.'" value="'.$avalue['text'].'"'.$_opsi.' autocomplete="off" />';
$this->__aform[$field] = [ 'label' => $label, 'help' => $help, 'form' => $tout];
return $tout;
}
public function datebox($tlabel="", $tfield, $tvalue=null, $benable=true, $breq=false, $thelp="", $tkeyup=null, $tblur=null) {
if ($tvalue<>null) $tvalue = tgl_sql2str($tvalue);
$tout = '<div class="input-group">';
$tout .= $this->textbox($tlabel, $tfield, $tvalue, $benable, $breq, "pickdate", "dd-mm-yyyy", 12, $thelp, $tkeyup, $tblur);
$tout .= '<span class="input-group-text"><i class="bi-calendar4"></i></span></div>';
$this->__aform[$tfield] = array('label'=>$tlabel, 'help'=>$thelp, 'form'=>$tout);
public function datebox(string $label, string $field, ?string $value=null, bool $enable=true, bool $req=false, ?string $help=null, ?string $keyup=null, ?string $blur=null): string {//oke
if (!empty($value)) $value = tgl_sql2str($value);
$tout = '<div class="input-group date">';
$tout .= $this->textbox($label, $field, $value, $enable, $req, "pickdate", "dd-mm-yyyy", null, $help, $keyup, $blur);
$tout .= '<span class="input-group-text input-group-addon"><i class="bi-calendar4"></i></span></div>';
$this->__aform[$field] = [ 'label' => $label, 'help' => $help, 'form' => $tout];
return $tout;
}
public function timebox($tlabel="", $tfield, $tvalue=null, $benable=true, $breq=false, $thelp="", $tkeyup=null, $tblur=null) {
$tout = $this->textbox($tlabel, $tfield, $tvalue, $benable, $breq, "picktime", "hh:mm:ss", 10, $thelp, $tkeyup, $tblur);
public function timebox(string $label, string $field, ?string $value=null, bool $enable=true, bool $req=false, ?string $help=null, ?string $keyup=null, ?string $blur=null): string {//oke
return $this->textbox($label, $field, $value, $enable, $req, "picktime", "hh:mm:ss", 10, $help, $keyup, $blur);
}
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 {//oke
$_opsi = '';
if (!empty($keyup)) $_opsi .= ' okyup="'.$keyup.'"';
if (!empty($blur)) $_opsi .= ' oblur="'.$blur.'"';
if (!empty($holdtxt)) $_opsi .= ' placeholder="'.$holdtxt.'"';
if ($enable===false) $_opsi .= ' disabled=true';
if ($req===true) $_opsi .= ' required=true';
$tout = '<textarea class="form-control" id="'.$field.'" name="'.$field.'" rows="'.$rows.'"'.$_opsi.' >'.$value.'</textarea>';
$this->__aform[$field] = [ 'label' => $label, 'help' => $help, 'form' => $tout];
return $tout;
}
public function textarea($tlabel="", $tfield, $tvalue=null, $benable=true, $breq=false, $nrows=1, $holdtxt=null, $thelp="", $tkeyup=null, $tblur=null) {
$_enab = ($benable==true) ? "" : ' disabled=true';
$_req = ($breq==true) ? " required=true" : "";
$_rows = ($nrows==null) ? "" : ' rows="'.$nrows.'"';
$_keyup = ($tkeyup==null) ? "" : ' onkeyup="'.$tkeyup.'"';
$_blur = ($tblur==null) ? "" : ' onblur="'.$tblur.'"';
$_holdtxt = ($holdtxt==null) ? "" : ' placeholder="'.$holdtxt.'"';
$tout = '<textarea class="form-control" id="'.$tfield.'" name="'.$tfield.'"'.$_enab.$_rows.$_keyup.$_blur.$_holdtxt.$_req.' >'.$tvalue.'</textarea>';
$this->__aform[$tfield] = array('label'=>$tlabel, 'help'=>$thelp, 'form'=>$tout);
public function plaintext(string $label, string $field, string|int|null $value=null): string {//oke
$tout = '<input type="text" class="form-control-plaintext" id="'.$field.'" name="'.$field.'" value="'.$value.'" readonly />';
$this->__aform[$field] = ['label' => $label, 'help' => "", 'form' => $tout];
return $tout;
}
public function plaintext($tlabel="", $tfield, $tvalue=null) {
$tout = '<input type="text" class="form-control-plaintext" id="'.$tfield.'" name="'.$tfield.'" value="'.$tvalue.'" readonly />';
$this->__aform[$tfield] = array('label'=>$tlabel, 'help'=>"", 'form'=>$tout);
public function password(string $label, string $field, ?string $value=null, bool $enable=true, bool $req=false, ?string $holdtxt=null, ?int $maxsize=null, ?string $help=null, ?string $keyup=null): string {//oke
return $this->textbox($label, $field, $value, $enable, $req, "password", $holdtxt, $maxsize, $help, $keyup, null);
}
public function color(string $label, string $field, ?string $value=null, bool $enable=true, bool $req=false, ?string $help=null, ?string $change=null): string {//oke
$_opsi = '';
if (!empty($change)) $_opsi .= ' ochan="'.$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.' />';
$this->__aform[$field] = ['label' => $label, 'help' => $help, 'form' => $tout];
return $tout;
}
public function password($tlabel="", $tfield, $tvalue="", $benable=true, $breq=false, $holdtxt=null, $nmaxsize=null, $thelp="", $tkeyup=null) {
$tout = $this->textbox($tlabel, $tfield, $tvalue, $benable, $breq, "password", $holdtxt, $nmaxsize, $thelp, $tkeyup, $tblur);
return $tout;
}
public function color($tlabel="", $tfield, $tvalue=null, $benable=true, $breq=false, $thelp="", $tchange=null) {
$_enab = ($benable==true) ? "" : ' disabled=true';
$_req = ($breq==true) ? " required=true" : "";
$_change = ($tchange==null) ? '' : ' onchange="'.$tchange.'"';
$tout = '<input type="color" class="form-control form-control-color" id="'.$tfield.'" name="'.$tfield.'" value="'.$tvalue.'"'.$_enab.$_change.$_req.' />';
$this->__aform[$tfield] = array('label'=>$tlabel, 'help'=>$thelp, 'form'=>$tout);
return $tout;
}
public function hidden($tfield, $tvalue="", $tclass="text") {
$tout = '<input type="hidden" id="'.$tfield.'" value="'.$tvalue.'" class="'.$tclass.'" />';
$this->__ahide[$tfield] = $tout;
public function hidden(string $field, string|int|null $value=null, string $class="text"): string {//oke
$tout = '<input type="hidden" id="'.$field.'" value="'.$value.'" class="'.$class.'" />';
$this->__ahide[$field] = $tout;
return $tout;
}
public function clear() {
$this->__aform = array();
$this->__aform = [];
}
public function show($tstr) {
if ($tstr === 0) $tstr = 4;//default
$col_left = 'col-sm-' . ($tstr+2) . ' col-lg-' . $tstr;
$col_right = 'col-sm-' . (10-$tstr) . ' col-lg-' . (12-$tstr);
$tres = '';
foreach ($this->__aform as $_key => $_val) {
$tval = '<div class="row mb-1"><label class="col-sm-5 col-lg-4 col-form-label" for="'.$_key.'">'.$_val['label'].'</label><div class="col-sm-7 col-lg-8">'.$_val['form'].($_val['help']==""?'':'<span class="help-block"><small>'.$_val['help'].'</small></span>').'</div></div>';
$tstr = str_replace("_".$_key."_", $tval, $tstr);
}
$txtbtn = $this->__button->Button($this->__nbtnsize);
if (""<>$txtbtn) {
$tstr .= '<div class="row mb-1"><div class="col"><hr class="my-2"></div></div>';
$tstr .= $txtbtn;
$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>'));
}
foreach ($this->__ahide as $_key => $_val) {
$tstr = str_replace("_".$_key."_", $_val, $tstr);
$tres .= $_val;
}
$tstr = str_replace("\n", "", $tstr);
$tstr = str_replace("\t", "", $tstr);
echo $tstr;
return $tres;
}
public function btn_separator() {
$this->__button->separator();
}
public function btn_primary($id="", $label="", $bmiss=false) {
$this->__button->primary($id, $label, $bmiss);
}
public function btn_info($id="", $label="", $bmiss=false) {
$this->__button->info($id, $label, $bmiss);
}
public function btn_danger($id="", $label="", $bmiss=false) {
$this->__button->danger($id, $label, $bmiss);
}
public function btn_warning($id="", $label="", $bmiss=false) {
$this->__button->warning($id, $label, $bmiss);
}
public function btn_success($id="", $label="", $bmiss=false) {
$this->__button->success($id, $label, $bmiss);
}
public function btn_secondary($id="", $label="", $bmiss=false) {
$this->__button->secondary($id, $label, $bmiss);
}
public function Button($size=2) {
$this->__nbtnsize = $size;
}
}
?>
+40 -45
View File
@@ -12,45 +12,43 @@
*******************************************************************/
//OK
declare(strict_types=1);
namespace siaupheng\webapp\Web;
use flight\Engine;
use flight\Session;
use flight\database\SimplePdo;
final class Menu {
protected $__db = null;
protected Engine $app;
protected SimplePdo $db;
protected Session $session;
public function __construct($db = null){
$this->__db = $db ?? new \siaupheng\webapp\DB\MySQL();
public function __construct(?Engine $app = null){
$this->app = (empty($app) === true) ? \Flight::app() : $app;
$this->db = $this->app->db();
$this->session = $this->app->session();
}
private function Menu_Query($qry = "", $order = "Kode") {
$twhere = ($qry!="") ? "WHERE ".$qry : "";
$this->__db->Query("SELECT * FROM app_menu ".$twhere." ORDER BY ".$order." ASC");
$ahasil = array();
while ($this->__db->Next()) {
$ahasil[] = $this->__db->AllRow();
}
return $ahasil;
}
public function Menu_Sidebar() {//oke
$a_modul = array();
$is_modul = (($_SESSION['__WEB_APP']['APP_MODULE'] ?? "") <> "") ? true : false;
public function Menu_Sidebar() {
$a_modul = [];
$is_modul = ($this->session->get('__WEB_APP', ['APP_MODULE'=>''])['APP_MODULE'] <> '') ? true : false;
if ($is_modul == true) {
$a_modul[] = $_SESSION['__WEB_APP']['APP_MODULE'];
$a_modul[] = $this->session->get('__WEB_APP')['APP_MODULE'];
} else {
$atmp = $this->Menu_Query("Level=0 AND Aktif=1 AND Modul<>'IND'", "Urut");
for ($i=0; $i<count($atmp); $i++) {
$a_modul[] = $atmp[$i]['Modul'];
$atmp = $this->db->fetchAll('SELECT * FROM app_menu WHERE Level=0 AND Aktif=1 AND Modul<>"IND" ORDER BY Urut');
foreach ($atmp as $tmp) {
$a_modul[] = $tmp['Modul'];
}
}
$my_menu = array_unique(array_filter(explode(",", $_SESSION['__WEB_USER']['Menu_Grup'].",".$_SESSION['__WEB_USER']['Menu'])));
$tsql = " AND Modul IN ('".implode("','",$a_modul)."')";
$tsql .= ($is_modul == true) ? " AND Level>0" : "";
$tsql .= " AND Kode IN ('".implode("','",$my_menu)."')";
$my_menu = array_unique(array_filter(explode(",", $this->session->get('__WEB_USER', ['Menu_Grup'=>''])['Menu_Grup'].",".$this->session->get('__WEB_USER', ['Menu'=>''])['Menu'])));
$tsql = 'SELECT * FROM app_menu WHERE Aktif=1 AND Modul IN (?) AND Kode IN (?)';
if ($is_modul == true) $tsql .= ' AND Level>0';
$amodul = $this->Menu_Query("Aktif=1".$tsql, "Kode");
$amodul = $this->db->fetchAll($tsql . ' ORDER BY Kode', [$a_modul, $my_menu]);
$thasil = '';
$last_level = 0;
@@ -72,26 +70,25 @@ final class Menu {
return $thasil;
}
public function Menu_Header() {//oke
$a_modul = array();
$is_modul = (($_SESSION['__WEB_APP']['APP_MODULE'] ?? "") <> "") ? true : false;
public function Menu_Header() {
$a_modul = [];
$is_modul = ($this->session->get('__WEB_APP', ['APP_MODULE'=>''])['APP_MODULE'] <> '') ? true : false;
$mulai_level = 0;
if ($is_modul == true) {
$a_modul[] = $_SESSION['__WEB_APP']['APP_MODULE'];
$a_modul[] = $this->session->get('__WEB_APP')['APP_MODULE'];
$mulai_level = 1;
} else {
$atmp = $this->Menu_Query("Level=0 AND Aktif=1 AND Modul<>'IND'", "Urut");
for ($i=0; $i<count($atmp); $i++) {
$a_modul[] = $atmp[$i]['Modul'];
$atmp = $this->db->fetchAll('SELECT * FROM app_menu WHERE Level=0 AND Aktif=1 AND Modul<>"IND" ORDER BY Urut');
foreach ($atmp as $tmp) {
$a_modul[] = $tmp['Modul'];
}
}
$my_menu = array_unique(array_filter(explode(",", $_SESSION['__WEB_USER']['Menu_Grup'].",".$_SESSION['__WEB_USER']['Menu'])));
$tsql = " AND Modul IN ('".implode("','",$a_modul)."')";
$tsql .= ($is_modul == true) ? " AND Level>0" : "";
$tsql .= " AND Kode IN ('".implode("','",$my_menu)."')";
$my_menu = array_unique(array_filter(explode(",", $this->session->get('__WEB_USER', ['Menu_Grup'=>''])['Menu_Grup'].",".$this->session->get('__WEB_USER', ['Menu'=>''])['Menu'])));
$tsql = 'SELECT * FROM app_menu WHERE Aktif=1 AND Modul IN (?) AND Kode IN (?)';
if ($is_modul == true) $tsql .= ' AND Level>0';
$amodul = $this->Menu_Query("Aktif=1".$tsql, "Kode");
$amodul = $this->db->fetchAll($tsql . ' ORDER BY Kode', [$a_modul, $my_menu]);
$thasil = '';
$last_level = 0;
@@ -119,23 +116,22 @@ final class Menu {
return $thasil;
}
static function MenuJSON($db = null, $page = "", $tquery = "") {//oke
$_mdb = $db ?? new \siaupheng\webapp\DB\MySQL();
static function MenuJSON($db = null, $page = "", $tquery = "") {
$_mdb = (empty($db) === true) ? new SimplePdo() : $db;
$_query = ($tquery=="") ? "" : ",'".$tquery."'";
$ajson = ['login' => true];
$apage = ['Link' => ""];
$acus_page = [
'SYSP' => ['Kode'=>"SYSP", 'Judul'=>"Profil Pengguna", 'Link'=>"sys/profile.php", 'JS'=>"SYSProfileJS", 'Width'=>600, 'Button'=>'[{},{"i":"butBatal"},{"i":"butSave","v":"Simpan","c":"success"}]'],
'SYSC' => ['Kode'=>"SYSC", 'Judul'=>"Ubah Password", 'Link'=>"sys/chpasswd.php", 'JS'=>"SYSChpasswdJS", 'Width'=>500, 'Button'=>'[{},{"i":"butBatal"},{"i":"butSave","v":"Simpan","c":"success"}]']
'SYSP' => ['Kode'=>"SYSP", 'Judul'=>"Profil Pengguna", 'Link'=>"system/profile", 'JS'=>"SYSProfileJS", 'Width'=>600, 'Button'=>'[{},{"i":"butBatal"},{"i":"butSave","v":"Simpan","c":"success"}]'],
'SYSC' => ['Kode'=>"SYSC", 'Judul'=>"Ubah Password", 'Link'=>"system/chpasswd", 'JS'=>"SYSChpasswdJS", 'Width'=>500, 'Button'=>'[{},{"i":"butBatal"},{"i":"butSave","v":"Simpan","c":"success"}]']
];
if ($acus_page[$page] ?? false) {
$apage = $acus_page[$page];
} else if ($page <> "") {
$_mdb->Query("SELECT * FROM app_menu WHERE Kode='".$page."'");
if ($_mdb->Next()) $apage = $_mdb->AllRow();
$apage['Width'] = intval($apage['Width']);
$apage = $_mdb->fetchRow('SELECT * FROM app_menu WHERE Kode=?', [$page]);
$apage['Width'] = (int)$apage['Width'];
}
$ajson['iswindow'] = ($apage['Width'] > 0) ? true : false;
@@ -146,7 +142,6 @@ final class Menu {
$ajson['func'] = $apage['JS'];
$ajson['kode'] = $apage['Kode'];
if (!file_exists($_SESSION['__WEB_APP']['REAL_PATH']."apps/php/".$apage['Link'])) $ajson['php'] = "";
return $ajson;
}
}
+10 -13
View File
@@ -6,16 +6,19 @@
Desc. : Class data parameter dari client side
Created By : Siau Pheng (siaupheng@3fonia.com).
Created Date : November 14th, 2013.
Last Modified : May 8th, 2021.
Last Modified : August 8th, 2026.
(c) 2013 - 2021, 3FONIA Software; WWW.3FONIA.COM.
(c) 2013 - 2026, 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/
//OK
declare(strict_types=1);
namespace siaupheng\webapp\Web;
use \flight\Engine;
final class Param {
private static $__ahasil = [];
@@ -24,7 +27,9 @@ final class Param {
}
private static function __data() {
$_asumber = array_merge($_REQUEST, $_POST, $_GET);
global $app;
if (empty($app)) $app = \Flight::app();
$_asumber = array_merge($app->request()->query->getData(), $app->request()->data->getData());
foreach ($_asumber as $__key => $__val) {
self::$__ahasil[$__key] = self::safeSQL($__val);
}
@@ -56,16 +61,8 @@ final class Param {
return self::$__ahasil;
}
public static function Get_ArrayCBOX() {//note: bisa tidak dipakai lagi
if (count(self::$__ahasil)==0) self::__data();
$_ahasil = [];
foreach (self::$__ahasil as $__key => $__val) {
if (strpos($__key, "_cbox_")>0) {
$_tmpkey = substr($__key, strpos($__key, "_cbox_")+6);
$_ahasil[$_tmpkey] = $__val;
}
}
return $_ahasil;
public static function Get_ArrayCBOX() {//delete
return [];
}
}
+25 -17
View File
@@ -6,41 +6,49 @@
Desc. : Class Registrasi Aplikasi
Created By : Siau Pheng (siaupheng@3fonia.com).
Created Date : November 23th, 2011.
Last Modified : May 6th, 2021.
Last Modified : August 11th, 2026.
(c) 2011 - 2021, 3FONIA Software; WWW.3FONIA.COM.
(c) 2011 - 2026, 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/
//OK
declare(strict_types=1);
namespace siaupheng\webapp\Web;
final class Register {
protected $__db = null;
use flight\Engine;
use flight\database\SimplePdo;
public function __construct($db = null){
if (is_resource($db)) { $this->__db = $db; }
else { $this->__db = new \siaupheng\webapp\DB\MySQL(); }
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();
}
static public function reg_id() {
$id = $_SESSION['__WEB_APP']['REG_ID'] ?? "";
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));
}
static public function reg_code() {
$id = $_SESSION['__WEB_APP']['REG_CODE'];
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 function reg_check() {
$isreg = false;
$this->__db->Query("SELECT UPPER(CONVERT(MD5(CONCAT(REG_YEAR,CONVERT(MD5(CONCAT(REG_ID,REG_NAME)) using latin1),REG_ID,REG_NAME)) using latin1)) KODE_REGISTER FROM app_config WHERE REG_ID='".$_SESSION['__WEB_APP']['APP_CODE']."' LIMIT 1");
if ($this->__db->Next()) {
if ($this->__db->Row("KODE_REGISTER","")==$_SESSION['__WEB_APP']['REG_CODE']) $isreg = true;
public static function reg_check() {
$webapp = (array)\Flight::app()->session()->get('__WEB_APP');
return (bool)(isset($webapp['REG_STATUS']) && $webapp['REG_STATUS']) ?? false;
}
return $isreg;
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 ];
}
}
+145 -152
View File
@@ -6,214 +6,201 @@
Desc. : HTML Table (jQuery & Bootstrap)
Created By : Siau Pheng (siaupheng@3fonia.com).
Created Date : January 16th, 2008.
Last Modified : January 26th, 2026.
Last Modified : August 16th, 2026.
(c) 2008 - 2026, 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/
//OK
declare(strict_types=1);
namespace siaupheng\webapp\Web;
use flight\Engine;
use flight\database\SimplePdo;
final class Table {
private $__ttable = "";
private $__tfield = "";
private $__twhere = "";
private $__tquery = "";
private $__tquery_footer = "";
private $__aheader = [];
private $__aparam = [];
private $__tfooter = "";
private $__afield = [];
private $__astyle = [];
private $__aformat = [];
private $__afooter = [];
private $__aotype = [];
private $__arowcol = [];
private $__arow_func = [];
private $__tfunc_select = "";
private $__tfunc_navi = "";
private $__bno_navi = false;
private $__btxtbutton = false;
private $__bnobutton = false;
private $__bscrollbar = false;
private $__acontrol = ['field'=>false, 'value'=>""];
private $__acontrol = [ 'field' => false, 'value' => "" ];
private $__acbox = [];
private $__aoption = [];
private $__npage_rec = 10;
private $__nreclimit = 0;
private $__nscrollheight = 0;
private $__ord_field = "";
private $__ord_dir = "A";
private $__tcss = "";
private $__livedata = false;
protected $__cdb = null;
protected $__cpa = null;
protected Engine $app;
protected SimplePdo $db;
protected array $data;
public function __construct($db = null){
if (is_resource($db)) { $this->__cdb = $db; }
else { $this->__cdb = new \siaupheng\webapp\DB\MySQL(); }
$this->__cpa = new \siaupheng\webapp\Web\Param();
public function __construct(?Engine $app = null) {
$this->app = (empty($app) === true) ? \Flight::app() : $app;
$this->db = $this->app->db();
$this->data = $this->app->request()->data->getData();
}
public function set_table($ttable = "", $tfield = "", $twhere = "") {
$this->__ttable = $ttable;
if ($tfield != "") $this->__tfield = $tfield;
if ($twhere != "") $this->__twhere = $twhere;
public function set_table(string $table = "", string $field = "", string $where = "", array $params = []): void {
$this->__ttable = $table;
$this->__aparam = $params;
if (!empty($field)) $this->__tfield = $field;
if (!empty($where)) $this->__twhere = $where;
}
public function set_query($tquery = "") {
$this->__tquery = $tquery;
public function set_footer(string $field = ""): void {
$this->__tfooter = $field;
}
public function set_query_footer($tquery = "") {
$this->__tquery_footer = $tquery;
public function set_css(string $css = ""): void {
$this->__tcss = $css;
}
public function set_css($tcss = "") {
$this->__tcss = $tcss;
public function set_field_order(string $field = "", string $order = "A"): void {
$this->__ord_field = $field;
$this->__ord_dir = $order;
}
public function set_limit($nlimit = 0) {
$this->__nreclimit = $nlimit;
public function set_textbtn(bool $istxt = true): void {
$this->__btxtbutton = $istxt;
}
public function set_field_order($tfield = "", $torder = "A") {
$this->__ord_field = $tfield;
$this->__ord_dir = $torder;
public function set_scrollbar(bool $isscroll = true, int $height = 200): void {
$this->__bscrollbar = $isscroll;
$this->__nscrollheight = $height;
}
public function set_textbtn($bistxt = true) {
$this->__btxtbutton = $bistxt;
public function set_row_color(string $field = "", string $val = "", string $css = ""): void {
if (epmty($field)) return;
$this->__arowcol[] = [ 'F' => $field, 'V' => $val, 'C' => $css ];
}
public function set_scrollbar($bisscroll = true, $nheight = 200) {
$this->__bscrollbar = $bisscroll;
$this->__nscrollheight = $nheight;
public function set_func_navi(string $func = ""): void {//compatible
$this->__bno_navi = ($func === '');
}
public function set_row_color($tfield = "", $tval = "", $tcss = "") {
if ($tfield=="") return;
$this->__arowcol[] = ['F'=>$tfield, 'V'=>$tval, 'C'=>$tcss];
public function set_navi_off(): void {
$this->__bno_navi = true;
}
public function set_func_navi($tfunc = "") {
$this->__tfunc_navi = $tfunc;
public function set_func_select(string $func = ""): void {
$this->__tfunc_select = $func;
}
public function set_func_select($tfunc = "") {
$this->__tfunc_select = $tfunc;
public function set_func_btn(string $func = "", string $label = ""): void {
$this->__arow_func[] = [ 'label' => $label, 'func' => $func ];
}
public function set_func_btn($tfunc = "", $tlabel = "") {
$this->__arow_func[] = ['label' => $tlabel, 'func' => $tfunc];
public function set_row_control(string $field = "", string $value = "Y"): void {
$this->__acontrol['field'] = $field;
$this->__acontrol['value'] = $value;
}
public function set_row_control($tfield = "", $tvalue = "Y") {
$this->__acontrol['field'] = $tfield;
$this->__acontrol['value'] = $tvalue;
public function add_row_form(string $icon = "pencil", string $label = "", string $func = "", string $field = "", string $value = ""): void {
$this->__aoption[] = [ 'type' => "button-dt", 'func' => $func, 'icon' => $icon, 'label' => $label, 'field' => $field, 'value' => $value ];
}
public function add_row_form($ticon = "pencil", $tlabel = "", $tfunc = "", $tfield = "", $tvalue = "") {
if ($tfunc == "") {
$this->__aoption[] = ['type' => "button-dt", 'func' => $tlabel, 'icon' => "pencil", 'label' => $ticon];
} else {//todo: new format with icon, upgrade all later !
$this->__aoption[] = ['type' => "button-dt", 'func' => $tfunc, 'icon' => $ticon, 'label' => $tlabel, 'field' => $tfield, 'value' => $tvalue];
}
public function add_row_btn(string $icon = "", string $label = "", string $func = "", string $field = "", string|int $value = "", string $field_css = "", array $avalue_css = []): void {
$this->__aoption[] = [ 'type' => 'button', 'func' => $func, 'icon' => $icon, 'label' => $label, 'field' => $field, 'value' => (string)$value, 'field_css' => $field_css, 'avalue_css' => $avalue_css ];
}
public function add_row_btn($ticon = "", $tlabel = "", $tfunc = "", $tfield = "", $tvalue = "", $tfield_css = "", $avalue_css = []) {
$this->__aoption[] = ['type' => "button", 'func' => $tfunc, 'icon' => $ticon, 'label' => $tlabel, 'field' => $tfield, 'value' => $tvalue, 'field_css' => $tfield_css, 'avalue_css' => $avalue_css];
public function add_row_del(string $label = "", string $func = "", string $field = "Unix", string $value = ""): void {
$this->__aoption[] = [ 'type' => 'button', 'func' => $func, 'icon' => 'x', 'label' => $label, 'field' => $field, 'value' => $value ];
}
public function add_row_del($tlabel = "", $tfunc = "", $tfield = "Unix", $tvalue = "") {
$this->__aoption[] = ['type' => "button", 'func' => $tfunc, 'icon' => "x", 'label' => $tlabel, 'field' => $tfield, 'value' => $tvalue];
public function add_row_edit(string $label = "", string $func = ""): void {
$this->add_row_btn('clipboard', $label, $func);
}
public function add_row_edit($tlabel = "", $tfunc = "") {
$this->add_row_btn("note", $tlabel, $tfunc);
public function add_row_checkbox(string $field = "ID", string $control = "Edit", array $value = ['Y','N']): void {
$this->__acbox = [ 'field' => $field, 'control' => $control, 'avalue' => $value ];
$this->__aoption[] = ['type' => "checkbox", 'field' => $field, 'avalue' => $value];
}
public function add_row_checkbox($tfield = "ID", $tcontrol = "Edit", $avalue = ["Y","N"]) {
$this->__acbox['field'] = $tfield;
$this->__acbox['control'] = $tcontrol;
$this->__acbox['avalue'] = $avalue;
$this->__aoption[] = ['type' => "checkbox", 'field' => $tfield, 'avalue' => $avalue];
}
public function no_button() {
public function no_button(): void {
$this->__bnobutton = true;
}
public function add_field($tfield = "", $theader = "", $tstyle = "l", $tformat = "", $tfooter = "", $totype = "") {
$this->__aheader[] = $theader;
$this->__afield[] = $tfield;
$this->__astyle[] = $tstyle;
$this->__aformat[] = $tformat;
$this->__afooter[] = $tfooter;
$this->__aotype[] = $totype;
public function add_field(string $field = "", string $header = "", string $style = "l", string $format = "", string $footer = "", string $otype = ""): void {
$this->__afield[] = [ 'a' => $field, 'h' => $header, 's' => $style, 'f' => $format, 't' => $footer, 'o' => $otype ];
}
public function json_table($nama_tabel = "tabel_", $baris_tabel = 10) {
$adata = []; $njml_kol = 0;
public function json_table(string $nama_tabel = "tabel_", int $baris_tabel = 10): array {
$this->prepare_query();
$adata = [];
// adding header
for ($i=0; $i<count($this->__afield); $i++) {
$adata['header'][] = ['f'=>$this->__astyle[$i], 'o'=>$this->__afield[$i], 'c'=>$this->__aheader[$i], 's'=>$this->__aotype[$i]];
$njml_kol += ($this->__astyle[$i]=="hidden") ? 0 : 1;
foreach ($this->__afield as $col) {
$adata['header'][] = [ 'f' => $col['s'], 'o' => $col['a'], 'c' => $col['h'], 's' => $col['o'] ];
}
// adding footer
if ($this->__tquery_footer) {
$this->__cdb->Query($this->__tquery_footer);
$this->__cdb->Next();
for ($i=0; $i<count($this->__afield); $i++) {
$tval = $this->__cdb->Row($this->__afield[$i], 0);
if (is_array($this->__afooter[$i])) {
$tval2 = $this->__afooter[$i][$tval];
} else if (!is_null($this->__afooter[$i]) && function_exists($this->__afooter[$i])) {
$tval2 = call_user_func($this->__afooter[$i], $tval);
} else {
$tval2 = ($this->__afooter[$i]<>"") ? $this->__afooter[$i] : $tval;
if (!empty($this->__tfooter)) {
$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 (is_array($col['t'])) {
$tval2 = $col['t'][$tval] ?? '';
} else if (function_exists($col['t'])) {
$tval2 = call_user_func($col['t'], $tval);
}
$adata['footer'][] = ['c'=>$tval2];
} else {
$tval2 = $tval;
}
$adata['footer'][] = [ 'c' => $tval2 ];
}
}
$acontent = [];
if (!$this->__livedata) {
$this->__cdb->Query($this->__tquery);
while ($this->__cdb->Next()) {
$stat = $this->db->runQuery("SELECT ".$this->__tfield." FROM ".$this->__ttable.$this->__twhere, $this->__aparam);
while ($row = $stat->fetch(SimplePdo::FETCH_ASSOC)) {
$abaris = [];
$aoption = ['button'=>[]];
if (count($this->__aoption)>0) {
if ((($this->__acontrol['field']===false) || ($this->__cdb->Row($this->__acontrol['field'])==$this->__acontrol['value'])) && $this->__bnobutton===false) {
if ((($this->__acontrol['field']===false) || ($row[$this->__acontrol['field']]===$this->__acontrol['value'])) && $this->__bnobutton===false) {
// adding all option
for ($i=0; $i<count($this->__aoption); $i++) {
if (in_array($this->__aoption[$i]['type'], ["button","button-dt"])) {
if (!isset($this->__aoption[$i]['field'])) continue;
if (($this->__aoption[$i]['field']!="") && ($this->__cdb->Row($this->__aoption[$i]['field'])<>(trim("".$this->__aoption[$i]['value'])!="" ? $this->__aoption[$i]['value'] : $_SESSION['__WEB_USER']['UNIX']))) {} else {
$aoption['button'][] = [$this->__aoption[$i]['icon'], (empty($this->__aoption[$i]['field_css'])?'':$this->__aoption[$i]['avalue_css'][$this->__cdb->Row($this->__aoption[$i]['field_css'])]??'')];
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 {
$aoption['button'][] = [ $opsi['icon'], (empty($opsi['field_css'])?'':$opsi['avalue_css'][$row[$opsi['field_css']]]??'') ];
}
}
}
// adding checkbox option
if (array_key_exists("field", $this->__acbox)) {
$aoption['checkbox']['field'] = $this->__cdb->Row($this->__acbox['field']);
$aoption['checkbox']['value'] = $this->__cdb->Row($this->__acbox['control']);
if (array_key_exists('field', $this->__acbox)) {
$aoption['checkbox']['field'] = $row[$this->__acbox['field']];
$aoption['checkbox']['value'] = $row[$this->__acbox['control']];
}
}
}
if (count($this->__arowcol)>0) {//up: 2014-06-13
for ($i=0; $i<count($this->__arowcol); $i++) {
if ($this->__cdb->Row($this->__arowcol[$i]['F']) == $this->__arowcol[$i]['V']) $aoption['rowcss'] = $this->__arowcol[$i]['C'];
if (count($this->__arowcol) > 0) {
foreach ($this->__arowcol as $rcol) {
if ($row[$rcol['F']] == $rcol['V']) $aoption['rowcss'] = $rcol['C'];
}
}
$abaris[] = $aoption;
for ($i=0; $i<count($this->__afield); $i++) {
$tval = stripslashes($this->__cdb->Row($this->__afield[$i]));//up: 2015-01-05
if (is_array($this->__aformat[$i])) {
$tval = $this->__aformat[$i][$tval];
} else if (!is_null($this->__aformat[$i]) && function_exists($this->__aformat[$i])) {
$tval = call_user_func($this->__aformat[$i], $tval);
foreach ($this->__afield as $col) {
$tval = $row[$col['a']];
if (is_array($col['f'])) {
$tval = $col['f'][$tval];
} else if (!is_null($col['f']) && function_exists($col['f'])) {
$tval = call_user_func($col['f'], $tval);
} else if (is_string($tval)) {
$tval = stripslashes($tval);
}
$abaris[] = $tval;
}
@@ -222,80 +209,82 @@ final class Table {
}
// navigator
$anavi = [ 'func_navi' => $this->__tfunc_navi, 'button' => $this->__arow_func ];
$anavi = [ 'no_navi' => $this->__bno_navi, 'button' => $this->__arow_func ];
$adata['type'] = "table";
$adata['id'] = $nama_tabel;
$adata['config'] = ['css' => $this->__tcss, 'row_count' => $baris_tabel, 'func_select' => $this->__tfunc_select, 'nobutton' => $this->__bnobutton, 'txtbutton' => $this->__btxtbutton, 'scrollbar' => $this->__bscrollbar, 'scroll_height' => $this->__nscrollheight, 'sort_col' => $this->__ord_field, 'sort_dir' => $this->__ord_dir, 'live' => $this->__livedata];
$adata['option'] = [];
foreach ($this->__aoption as $aval) {
if ($aval['type']!=="checkbox") unset($aval['field']); unset($aval['value']); unset($aval['field_css']); unset($aval['value_css']); $adata['option'][] = $aval;
if ($aval['type'] !== 'checkbox') unset($aval['field'], $aval['value'], $aval['field_css'], $aval['avalue_css']);
$adata['option'][] = $aval;
}
$adata['navi'] = $anavi;
$adata['content'] = $acontent;
return $adata;
}
public function db_table($nama_tabel = "tabel_", $baris_tabel = 10) {
$adata = [];
$this->__livedata = true;
public function db_table(string $nama_tabel = "tabel_", int $baris_tabel = 10): array {
$this->prepare_query();
$id_draw = intval($this->__cpa->Get("draw", 0));
$i_start = intval($this->__cpa->Get("start", 0));
$i_length = intval($this->__cpa->Get("length", 0));
$i_order = $this->__cpa->Get("order", 0);
$this->__livedata = true;
$adata = [];
$id_draw = (int) ($this->data['draw'] ?? 0);
$i_start = (int) ($this->data['start'] ?? 0);
$i_length = (int) ($this->data['length'] ?? 0);
$a_order = (array) ($this->data['order'] ?? []);
if ($id_draw > 0) {
$record = 0;
$this->__cdb->Query("SELECT COUNT(*) Item FROM ".$this->__ttable.$this->__twhere);
if ($this->__cdb->Next()) $record = intval($this->__cdb->Row("Item", 0));
$record = (int)$this->db->fetchField("SELECT COUNT(*) FROM ".$this->__ttable.$this->__twhere, $this->__aparam) ?? 0;
$adata['type'] = "table-live";
$adata['id'] = $nama_tabel;
$adata['config'] = ['draw' => $id_draw, 'recordsTotal' => $record, 'recordsFiltered' => $record];
$adata['config'] = [ 'draw' => $id_draw, 'recordsTotal' => $record, 'recordsFiltered' => $record ];
$t_order = "ASC";
if ($i_order <> 0) {
$t_order = ($i_order[0]['dir']=="asc") ? "ASC" : "DESC";
$i_order = $i_order[0]['column'];
if (count($a_order) > 0) {
$t_order = ($a_order[0]['dir']=="asc") ? "ASC" : "DESC";
$c_order = $a_order[0]['column'];
}
if (($i_length > $record) || ($i_start >= $record) || ($record <= 10)) $i_length = -1;
$sql_limit = ($i_start>=0 && $i_length != -1) ? " LIMIT ".$i_start.", ".$i_length : "";
$sql_order = ($this->__afield[$i_order]) ? " ORDER BY ".$this->__afield[$i_order]." ".$t_order : "";
$sql_order = ($this->__afield[$c_order]) ? " ORDER BY ".$this->__afield[$c_order]['a']." ".$t_order : "";
$adata['data'] = [];
$this->__cdb->Query("SELECT ".$this->__tfield." FROM ".$this->__ttable.$this->__twhere.$sql_order.$sql_limit);
while ($this->__cdb->Next()) {
$stat = $this->db->runQuery("SELECT ".$this->__tfield." FROM ".$this->__ttable.$this->__twhere.$sql_order.$sql_limit, $this->__aparam);
while ($row = $stat->fetch(SimplePdo::FETCH_ASSOC)) {
$abaris = [];
$aoption = ['button'=>[]];
if (count($this->__aoption)>0) {
if ((($this->__acontrol['field']===false) || ($this->__cdb->Row($this->__acontrol['field'])==$this->__acontrol['value'])) && $this->__bnobutton===false) {
if ((($this->__acontrol['field']===false) || ($row[$this->__acontrol['field']]==$this->__acontrol['value'])) && $this->__bnobutton===false) {
// adding all option
for ($i=0; $i<count($this->__aoption); $i++) {
if (in_array($this->__aoption[$i]['type'], ["button","button-dt"])) {
if (($this->__aoption[$i]['field']!="") && ($this->__cdb->Row($this->__aoption[$i]['field'])<>(trim("".$this->__aoption[$i]['value'])!="" ? $this->__aoption[$i]['value'] : $_SESSION['__WEB_USER']['UNIX']))) {} else {
$aoption['button'][] = [$this->__aoption[$i]['icon'], (empty($this->__aoption[$i]['field_css'])?'':$this->__aoption[$i]['avalue_css'][$this->__cdb->Row($this->__aoption[$i]['field_css'])]??'')];
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 {
$aoption['button'][] = [ $opsi['icon'], (empty($opsi['field_css'])?'':$opsi['avalue_css'][$row[$opsi['field_css']]]??'') ];
}
}
}
// adding checkbox option
if (array_key_exists("field", $this->__acbox)) {
$aoption['checkbox']['field'] = $this->__cdb->Row($this->__acbox['field']);
$aoption['checkbox']['value'] = $this->__cdb->Row($this->__acbox['control']);
if (array_key_exists('field', $this->__acbox)) {
$aoption['checkbox']['field'] = $row[$this->__acbox['field']];
$aoption['checkbox']['value'] = $row[$this->__acbox['control']];
}
}
}
if (count($this->__arowcol)>0) {//up: 2014-06-13
for ($i=0; $i<count($this->__arowcol); $i++) {
if ($this->__cdb->Row($this->__arowcol[$i]['F']) == $this->__arowcol[$i]['V']) $aoption['rowcss'] = $this->__arowcol[$i]['C'];
if (count($this->__arowcol)>0) {
foreach ($this->__arowcol as $rcol) {
if ($row[$rcol['F']] == $rcol['V']) $aoption['rowcss'] = $rcol['C'];
}
}
$abaris[] = $aoption;
for ($i=0; $i<count($this->__afield); $i++) {
$tval = stripslashes($this->__cdb->Row($this->__afield[$i]));//up: 2015-01-05
if (is_array($this->__aformat[$i])) {
$tval = $this->__aformat[$i][$tval];
} else if (!is_null($this->__aformat[$i]) && function_exists($this->__aformat[$i])) {
$tval = call_user_func($this->__aformat[$i], $tval);
foreach ($this->__afield as $col) {
$tval = $row[$col['a']];
if (is_array($col['f'])) {
$tval = $col['f'][$tval];
} else if (!is_null($col['f']) && function_exists($col['f'])) {
$tval = call_user_func($col['f'], $tval);
} else if (is_string($tval)) {
$tval = stripslashes($tval);
}
$abaris[] = $tval;
}
@@ -308,9 +297,13 @@ final class Table {
}
private function prepare_query() {
if ($this->__tfield == "") $this->__tfield = "`".implode('`,`', $this->__afield)."`";
if ($this->__twhere != "") $this->__twhere = " WHERE " . $this->__twhere;
if (empty($this->__tfield)) $this->__tfield = '`'. implode('`,`', array_column($this->__afield, 'a')) .'`';
if (!empty($this->__twhere)) $this->__twhere = ' WHERE ' . $this->__twhere;
}
//public function set_query($tquery = "") {}
//public function set_limit($nlimit = 0) {}
}
?>
+25 -16
View File
@@ -6,26 +6,31 @@
Desc. : Class Update Aplikasi Otomatis
Created By : Siau Pheng (siaupheng@3fonia.com).
Created Date : June 14th, 2013.
Last Modified : March 3rd, 2026.
Last Modified : August 12th, 2026.
(c) 2013 - 2026, 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/
//OK
declare(strict_types=1);
namespace siaupheng\webapp\Web;
final class Update {
protected $__conf = [];
protected $is_git = false;
use flight\Engine;
public function __construct(){
$this->__conf = $_SESSION['__WEB_APP'];
$this->get_current();
final class Update {
protected Array $__conf = [];
protected Bool $is_git = false;
protected Engine $app;
public function __construct(?Engine $app = null){
$this->app = (empty($app) === true) ? \Flight::app() : $app;
$this->__conf = $app->session()->get('__WEB_APP');
$this->current();
}
public function get_current() {
public function current() {
$_target = $this->__conf['REAL_PATH'];
if (isset($_target)) chdir($_target);
@@ -33,16 +38,16 @@ final class Update {
$output = shell_exec("git log -1 --pretty=format:\"%H||%s||%ci\" --abbrev-commit 2>&1");
if ($output) {
$_ainfo = explode("||", $output);
$this->__conf['GIT_SHA1'] = $_ainfo[0];
$this->__conf['GIT_DATE'] = $_ainfo[2];
$this->__conf['GIT_SHA1'] = $_ainfo[0] ?? '';
$this->__conf['GIT_DATE'] = $_ainfo[2] ?? '';
$this->is_git = true;
}
$output = shell_exec("git config --get remote.origin.url 2>&1");
if ($output) {
$output = str_replace(["http://","https://",".git"], "", $output);
$_ainfo = explode("/", trim($output));
$this->__conf['GIT_OWNER'] = $_ainfo[1];
$this->__conf['GIT_REPO'] = $_ainfo[2];
$this->__conf['GIT_OWNER'] = $_ainfo[1] ?? '';
$this->__conf['GIT_REPO'] = $_ainfo[2] ?? '';
}
$output = shell_exec("git branch --show-current 2>&1");
if ($output) {
@@ -52,15 +57,19 @@ final class Update {
}
}
public function check_update() {
public function check() {
$_ainfo['cur_version'] = $this->__conf['APP_BUILD'];
$_ainfo['cur_sha'] = substr($this->__conf['GIT_SHA1'], 0, 10);
$_ainfo['cur_sha1'] = $this->__conf['GIT_SHA1'];
$_ainfo['cur_date'] = $this->__conf['GIT_DATE'];
$_ainfo['svr_status'] = 0;
$_ainfo['svr_message'] = "Server Offline";
$_ainfo['new_sha'] = 'check git config';
$_ainfo['new_sha1'] = $this->__conf['GIT_SHA1'];
$_ainfo['new_date'] = '';
$_ainfo['new_message'] = 'check git config';
if (!$this->is_git) return $_ainfo;
if (!$this->is_git || empty($this->__conf['GIT_OWNER']) || empty($this->__conf['GIT_REPO'])) return $_ainfo;
try {
$_url = "https://git.trifonia.cloud/api/v1/repos/".$this->__conf['GIT_OWNER']."/".$this->__conf['GIT_REPO']."/commits?limit=1";
@@ -80,7 +89,7 @@ final class Update {
return $_ainfo;
}
public function go_update() {
public function go() {
$_target = $this->__conf['REAL_PATH'];
$_branch = $this->__conf['GIT_BRANCH'] ?? "main";
if (isset($_target)) {
@@ -90,7 +99,7 @@ final class Update {
} else return ['success'=>false,'message'=>"Tanpa REAL_PATH !"];
}
public function update_mysql() {
public function mysql() {
}
}