Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bb5276ee44 | ||
|
|
9c242ed1b9 | ||
|
|
0fcbe91ea2 | ||
|
|
ee4417fc52 | ||
|
|
ee1dafd8d8 | ||
|
|
96104095d0 | ||
|
|
a311552c56 | ||
|
|
f694539a0b | ||
|
|
2f1388494f | ||
|
|
06fe9657e2 | ||
|
|
d4e5f92277 | ||
|
|
b2c0a57924 | ||
|
|
5522348c8a | ||
|
|
ed01d248ec | ||
|
|
899ddc011c | ||
|
|
a86eaf0f02 |
@@ -109,8 +109,9 @@ return [
|
||||
// ignore the old qq tests
|
||||
'www/admin/qq_file_upload_front.php',
|
||||
'www/admin/qq_file_upload_ajax.php',
|
||||
// symlink files for msarty
|
||||
// symlink ignore
|
||||
'www/lib/smarty-3.1.30/SmartyBC.class.php',
|
||||
'www/lib/htmlMimeMail-2.5.1/HtmlMimeMailCreate.php',
|
||||
],
|
||||
|
||||
// what not to show as problem
|
||||
|
||||
@@ -4,7 +4,7 @@ function/set_generic.sql
|
||||
function/random_string.sql
|
||||
function/set_edit_generic.sql
|
||||
function/edit_set_access_uid.sql
|
||||
function/edit_log_partition_trigger.sql
|
||||
function/edit_log_partition_insert.sql
|
||||
# generic tables
|
||||
table/edit_temp_files.sql
|
||||
table/edit_generic.sql
|
||||
@@ -30,7 +30,6 @@ trigger/trg_edit_access_right.sql
|
||||
trigger/trg_edit_access.sql
|
||||
trigger/trg_edit_access_data.sql
|
||||
trigger/trg_edit_access_user.sql
|
||||
trigger/trg_edit_generic.sql
|
||||
trigger/trg_edit_group.sql
|
||||
trigger/trg_edit_language.sql
|
||||
trigger/trg_edit_log.sql
|
||||
|
||||
@@ -15,22 +15,20 @@ function_name="set_generic";
|
||||
#sql_path_prep=`echo $sql_path | sed -e "s/\///g"`;
|
||||
|
||||
# goes for each file and strips headers and endings, and creates trigger name
|
||||
for name in $sql_path*;
|
||||
do
|
||||
for name in $sql_path*; do
|
||||
echo "Wokring on $name";
|
||||
# strip ending
|
||||
# t_name=`echo $name | sed -e 's/.sql$//g' | sed -e "s/^$sql_path_prep//g" | sed -e 's/\///g'`;
|
||||
t_name=`echo $name | sed -e 's/^.*\///g' | sed -e 's/.sql$//g'`;
|
||||
# clean all beginnings
|
||||
for prefix in $file_prefix;
|
||||
do
|
||||
for prefix in $file_prefix; do
|
||||
prefix=$prefix"_";
|
||||
t_name=`echo $t_name | sed -e "s/\$prefix//g"`;
|
||||
done;
|
||||
|
||||
# those tables don't need a trigger
|
||||
# edit_generic
|
||||
# generic
|
||||
# those tables don't need a trigger
|
||||
# edit_generic
|
||||
# generic
|
||||
|
||||
# copy the trigger template to the target
|
||||
trg_filename=$trigger_path$trigger_prefix"_"$t_name".sql";
|
||||
|
||||
@@ -14,17 +14,14 @@ file_prefix="trg";
|
||||
trigger_prefix="trg";
|
||||
index_prefix="idx";
|
||||
|
||||
for file in `cat ORDER`;
|
||||
do
|
||||
if [ -f $file ];
|
||||
then
|
||||
for file in `cat ORDER`; do
|
||||
if [ -f $file ]; then
|
||||
# write them into a var, so we can re order them in the other way
|
||||
new_order=$file" "$new_order;
|
||||
fi;
|
||||
done;
|
||||
|
||||
for file in $new_order;
|
||||
do
|
||||
for file in $new_order; do
|
||||
sqltype=`echo $file | egrep "table/"`;
|
||||
trgtype=`echo $file | egrep "trigger/"`;
|
||||
idxtype=`echo $file | egrep "index/"`;
|
||||
@@ -32,43 +29,34 @@ do
|
||||
datatype=`echo $file | egrep "data/"`;
|
||||
# remove all around to get table name
|
||||
t_file=`echo $file | sed -e 's/^.*\///g' | sed -e 's/.sql$//g'`;
|
||||
for prefix in $file_prefix;
|
||||
do
|
||||
for prefix in $file_prefix; do
|
||||
prefix=$prefix"_";
|
||||
t_file=`echo $t_file | sed -e "s/\$prefix//g"`;
|
||||
done;
|
||||
# copy the trigger template to the target
|
||||
|
||||
for path in $schemas;
|
||||
do
|
||||
if [ $sqltype ];
|
||||
then
|
||||
for path in $schemas; do
|
||||
if [ $sqltype ]; then
|
||||
echo "SQL "$path"."$t_file;
|
||||
echo "DROP TABLE "$path"."$t_file" CASCADE;" | psql -U $user -h $host $db
|
||||
fi;
|
||||
if [ $trgtype ];
|
||||
then
|
||||
if [ $trgtype ]; then
|
||||
trigger=$trigger_prefix"_"$t_file;
|
||||
echo "TRG $trigger TBL "$path".$t_file";
|
||||
echo "DROP TRIGGER "$path".$trigger ON "$t_file" CASCADE;" | psql -U $user -h $host $db
|
||||
fi;
|
||||
if [ $fcttype ];
|
||||
then
|
||||
if [ $fcttype ]; then
|
||||
echo "FCT "$path"."$t_file;
|
||||
echo "DROP FUNCTION "$path"."$t_file"();" | psql -U $user -h $host $db
|
||||
fi;
|
||||
if [ $idxtype ];
|
||||
then
|
||||
if [ $idxtype ]; then
|
||||
index=$index_prefix"_"$t_file;
|
||||
# echo "IDX "$t_file;
|
||||
# echo "DROP INDEX $index ON $t_file;" | psql -U $user -h $host $db
|
||||
# echo "IDX "$t_file;
|
||||
# echo "DROP INDEX $index ON $t_file;" | psql -U $user -h $host $db
|
||||
fi;
|
||||
if [ $datatype ];
|
||||
then
|
||||
if [ $datatype ]; then
|
||||
echo "DATA "$t_file;
|
||||
# echo "DROP FUNCTION "$t_file"();" | psql -U $user -h $host $db
|
||||
# echo "DROP FUNCTION "$t_file"();" | psql -U $user -h $host $db
|
||||
fi;
|
||||
|
||||
# psql -U cms_user -h 192.168.12.14 -f $file CMSv2
|
||||
done;
|
||||
done;
|
||||
|
||||
2
4dev/database/log/.gitignore
vendored
Normal file
2
4dev/database/log/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
4
4dev/database/trigger/trg_set_edit_access_uid.sql
Normal file
4
4dev/database/trigger/trg_set_edit_access_uid.sql
Normal file
@@ -0,0 +1,4 @@
|
||||
-- DROP TRIGGER trg_set_edit_access_uid ON edit_access;
|
||||
CREATE TRIGGER trg_set_edit_access_uid
|
||||
BEFORE INSERT OR UPDATE ON edit_access
|
||||
FOR EACH ROW EXECUTE PROCEDURE set_edit_access_uid();
|
||||
17
phpstan.neon
17
phpstan.neon
@@ -5,14 +5,17 @@ parameters:
|
||||
level: 1
|
||||
paths:
|
||||
- %currentWorkingDirectory%/www
|
||||
#bootstrap: %currentWorkingDirectory%/phpstan-bootstrap.php
|
||||
#bootstrap: phpstan-bootstrap.php
|
||||
autoload_directories:
|
||||
autoload_files:
|
||||
bootstrapFiles:
|
||||
- %currentWorkingDirectory%/phpstan-bootstrap.php
|
||||
scanDirectories:
|
||||
- www/lib/Smarty
|
||||
scanFiles:
|
||||
- www/configs/config.php
|
||||
- www/configs/config.master.php
|
||||
- www/lib/autoloader.php
|
||||
- www/vendor/autoload.php
|
||||
- www/lib/Smarty/Autoloader.php
|
||||
- www/lib/CoreLibs/Template/SmartyExtend.php
|
||||
excludes_analyse:
|
||||
# no check admin
|
||||
- www/admin/qq_file_upload_front.php
|
||||
@@ -40,10 +43,12 @@ parameters:
|
||||
- www/tmp
|
||||
- www/lib/pChart
|
||||
- www/lib/pChart2.1.4
|
||||
- www/lib/Smarty/
|
||||
- www/lib/smarty-3.1.30/
|
||||
- www/lib/Smarty
|
||||
- www/lib/smarty-3.1.30
|
||||
# ignore composer
|
||||
- www/vendor
|
||||
# ignore the smartyextend
|
||||
- www/lib/CoreLibs/Template/SmartyExtend.php
|
||||
# ignore errores with
|
||||
# ignoreErrors:
|
||||
#- 'error regex'
|
||||
|
||||
@@ -213,6 +213,16 @@ print "RETURN DATA FOR search_path: ".$data."<br>";
|
||||
$status = $basic->dbExec("INSERT INTO test.schema_test (contents, id) VALUES ('TIME: ".time()."', ".rand(1, 10).")");
|
||||
print "OTHER SCHEMA INSERT STATUS: ".$status." | PK NAME: ".$basic->pk_name.", PRIMARY KEY: ".$basic->insert_id."<br>";
|
||||
|
||||
print "<b>NULL TEST DB READ</b><br>";
|
||||
$q = "SELECT uid, null_varchar, null_int FROM test_null_data WHERE uid = 'A'";
|
||||
$res = $basic->dbReturnRow($q);
|
||||
var_dump($res);
|
||||
print "RES: ".$basic->printAr($res)."<br>";
|
||||
print "ISSET: ".isset($res['null_varchar'])."<br>";
|
||||
print "EMPTY: ".empty($res['null_varchar'])."<br>";
|
||||
|
||||
// data read test
|
||||
|
||||
// time string thest
|
||||
$timestamp = 5887998.33445;
|
||||
$time_string = $basic->timeStringFormat($timestamp);
|
||||
|
||||
@@ -52,6 +52,7 @@ $options = array (
|
||||
|
||||
if (is_object($smarty)) {
|
||||
$smarty->DATA['drop_down_test'] = $options;
|
||||
$smarty->DATA['loop_start'] = 2;
|
||||
// require BASE.INCLUDES.'admin_smarty.php';
|
||||
$smarty->setSmartyVarsAdmin();
|
||||
}
|
||||
|
||||
@@ -169,6 +169,8 @@ define('PUBLIC_SCHEMA', 'public');
|
||||
define('DEV_SCHEMA', 'public');
|
||||
define('TEST_SCHEMA', 'public');
|
||||
define('LIVE_SCHEMA', 'public');
|
||||
define('GLOBAL_DB_SCHEMA', '');
|
||||
define('LOGIN_DB_SCHEMA', '');
|
||||
|
||||
/************* CORE HOST SETTINGS *****************/
|
||||
if (file_exists(BASE.CONFIGS.'config.host.php')) {
|
||||
|
||||
@@ -102,7 +102,7 @@ if ($form->my_page_name == 'edit_order') {
|
||||
if (!isset($position)) {
|
||||
$position = array();
|
||||
}
|
||||
$row_data_id = $_POST['row_data_id'];
|
||||
$row_data_id = $_POST['row_data_id'] ?? [];
|
||||
$original_id = $row_data_id;
|
||||
if (count($position)) {
|
||||
$row_data_order = $_POST['row_data_order'];
|
||||
@@ -116,8 +116,8 @@ if ($form->my_page_name == 'edit_order') {
|
||||
// this gets the old before (moves one "up")
|
||||
// is done for every element in row
|
||||
// echo "A: ".$row_data_id[$position[$i]]." (".$row_data_order[$position[$i]].") -- ".$row_data_id[$position[$i]-1]." (".$row_data_order[$position[$i]-1].")<br>";
|
||||
$temp_id = $row_data_id[$position[$i]];
|
||||
$row_data_id[$position[$i]] = $row_data_id[$position[$i] - 1];
|
||||
$temp_id = $row_data_id[$position[$i]] ?? null;
|
||||
$row_data_id[$position[$i]] = $row_data_id[$position[$i] - 1] ?? null;
|
||||
$row_data_id[$position[$i] - 1] = $temp_id;
|
||||
// echo "A: ".$row_data_id[$position[$i]]." (".$row_data_order[$position[$i]].") -- ".$row_data_id[$position[$i]-1]." (".$row_data_order[$position[$i]-1].")<br>";
|
||||
} // for
|
||||
@@ -129,8 +129,8 @@ if ($form->my_page_name == 'edit_order') {
|
||||
// same as up, just up in other way, starts from bottom (last element) and moves "up"
|
||||
// element before actuel gets temp, this element, becomes element after this,
|
||||
// element after this, gets this
|
||||
$temp_id = $row_data_id[$position[$i] + 1];
|
||||
$row_data_id[$position[$i] + 1] = $row_data_id[$position[$i]];
|
||||
$temp_id = $row_data_id[$position[$i] + 1] ?? null;
|
||||
$row_data_id[$position[$i] + 1] = $row_data_id[$position[$i]] ?? null;
|
||||
$row_data_id[$position[$i]] = $temp_id;
|
||||
} // for
|
||||
} // if down
|
||||
@@ -140,8 +140,10 @@ if ($form->my_page_name == 'edit_order') {
|
||||
(isset($down) && ($position[count($position) - 1] != (count($row_data_id) - 1)))
|
||||
) {
|
||||
for ($i = 0; $i < count($row_data_id); $i ++) {
|
||||
$q = "UPDATE ".$table_name." SET order_number = ".$row_data_order[$i]." WHERE ".$table_name."_id = ".$row_data_id[$i];
|
||||
$q = $form->dbExec($q);
|
||||
if (isset($row_data_order[$i]) && isset($row_data_id[$i])) {
|
||||
$q = "UPDATE ".$table_name." SET order_number = ".$row_data_order[$i]." WHERE ".$table_name."_id = ".$row_data_id[$i];
|
||||
$q = $form->dbExec($q);
|
||||
}
|
||||
} // for all article ids ...
|
||||
} // if write
|
||||
} // if there is something to move
|
||||
@@ -187,7 +189,9 @@ if ($form->my_page_name == 'edit_order') {
|
||||
// list of points to order
|
||||
for ($j = 0; $j < count($position); $j++) {
|
||||
// if matches, put into select array
|
||||
if ($original_id[$position[$j]] == $row_data[$i]['id']) {
|
||||
if (isset($original_id[$position[$j]]) && isset($row_data[$i]['id']) &&
|
||||
$original_id[$position[$j]] == $row_data[$i]['id']
|
||||
) {
|
||||
$options_selected[] = $i;
|
||||
}
|
||||
}
|
||||
@@ -301,7 +305,7 @@ if ($form->my_page_name == 'edit_order') {
|
||||
(!$data['hostname'] || strstr($data['hostname'], CONTENT_PATH) !== false)
|
||||
))
|
||||
) {
|
||||
$position = $j;
|
||||
$position = $i;
|
||||
$menu_data[$i]['position'] = 1;
|
||||
$menu_data[$i]['popup'] = 0;
|
||||
} else {
|
||||
@@ -326,7 +330,7 @@ if ($form->my_page_name == 'edit_order') {
|
||||
} // for
|
||||
// $form->debug('MENU ARRAY', $form->printAr($menu_data));
|
||||
$DATA['menu_data'] = $menu_data;
|
||||
$DATA['page_name'] = $menuarray[$position]['page_name'];
|
||||
$DATA['page_name'] = $menuarray[$position]['page_name'] ?? '-Undefined ['.$position.'] -';
|
||||
$L_TITLE = $DATA['page_name'];
|
||||
// html title
|
||||
$HEADER['HTML_TITLE'] = $form->l->__($L_TITLE);
|
||||
|
||||
@@ -12,13 +12,19 @@
|
||||
<div class="jq-container">
|
||||
<div id="jq-test" class="jp-test">
|
||||
<div id="test-div" class="test-div">
|
||||
Some content ehre or asdfasdfasf
|
||||
Some content here or asdfasdfasf
|
||||
</div>
|
||||
<div id="translate-div">
|
||||
TRANSLATION SMARTY: {t}I should be translated{/t}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="loop-test">
|
||||
<div>LOOP TEST</div>
|
||||
{section name=page_list start=1 loop=$loop_start+1}
|
||||
<div>LOOP OUTPUT: {$smarty.section.page_list.index}</div>
|
||||
{/section}
|
||||
</div>
|
||||
{* progresss indicator *}
|
||||
<div id="indicator"></div>
|
||||
{* the action confirm box *}
|
||||
|
||||
@@ -382,7 +382,7 @@ input[type="text"]:focus, textarea:focus, select:focus {
|
||||
left: 0;
|
||||
top: 0;
|
||||
position: absolute;
|
||||
z-index: 100;
|
||||
z-index: 1000;
|
||||
}
|
||||
/* Animation for above progress */
|
||||
@keyframes rotate {
|
||||
|
||||
@@ -12,6 +12,10 @@ if (!DEBUG) {
|
||||
});
|
||||
}*/
|
||||
|
||||
// open overlay boxes counter
|
||||
var GL_OB_S = 10;
|
||||
var GL_OB_BASE = 10;
|
||||
|
||||
/**
|
||||
* opens a popup window with winName and given features (string)
|
||||
* @param {String} theURL the url
|
||||
@@ -121,8 +125,7 @@ function setCenter(id, left, top)
|
||||
function goToPos(element, offset = 0)
|
||||
{
|
||||
try {
|
||||
if ($('#' + element).length)
|
||||
{
|
||||
if ($('#' + element).length) {
|
||||
$('body,html').animate({
|
||||
scrollTop: $('#' + element).offset().top - offset
|
||||
}, 500);
|
||||
@@ -339,6 +342,31 @@ function valueInObject(object, value)
|
||||
// }) ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* true deep copy for Javascript objects
|
||||
* if Object.assign({}, obj) is not working (shallow)
|
||||
* or if JSON.parse(JSON.stringify(obj)) is failing
|
||||
* @param {Object} inObject Object to copy
|
||||
* @return {Object} Copied Object
|
||||
*/
|
||||
function deepCopyFunction(inObject)
|
||||
{
|
||||
var outObject, value, key;
|
||||
if (typeof inObject !== "object" || inObject === null) {
|
||||
return inObject; // Return the value if inObject is not an object
|
||||
}
|
||||
// Create an array or object to hold the values
|
||||
outObject = Array.isArray(inObject) ? [] : {};
|
||||
// loop over ech entry in object
|
||||
for (key in inObject) {
|
||||
value = inObject[key];
|
||||
// Recursively (deep) copy for nested objects, including arrays
|
||||
outObject[key] = deepCopyFunction(value);
|
||||
}
|
||||
|
||||
return outObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* checks if a DOM element actually exists
|
||||
* @param {String} id Element id to check for
|
||||
@@ -394,6 +422,20 @@ function errorCatch(err)
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************
|
||||
* OLD action indicator and overlay boxes calls
|
||||
* DO NOT USE
|
||||
* actionIndicator -> showActionIndicator
|
||||
* actionIndicator -> hideActionIndicator
|
||||
* actionIndicatorShow -> showActionIndicator
|
||||
* actionIndicatorHide -> hideActionIndicator
|
||||
* overlayBoxShow -> showOverlayBoxLayers
|
||||
* overlayBoxHide -> hideOverlayBoxLayers
|
||||
* setOverlayBox -> showOverlayBoxLayers
|
||||
* hideOverlayBox -> hideOverlayBoxLayers
|
||||
* ClearCall -> ClearCallActionBox
|
||||
* ***********************************************************/
|
||||
|
||||
/**
|
||||
* show or hide the "do" overlay
|
||||
* @param {String} loc location name for action indicator
|
||||
@@ -402,10 +444,10 @@ function errorCatch(err)
|
||||
*/
|
||||
function actionIndicator(loc, overlay = true)
|
||||
{
|
||||
if ($('#overlayBox').is(':visible')) {
|
||||
if ($('#indicator').is(':visible')) {
|
||||
actionIndicatorHide(loc, overlay);
|
||||
} else {
|
||||
actionIndicatorShow(loc, overlay);
|
||||
actionIndicatorShow(loc, overlay);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -418,9 +460,11 @@ function actionIndicator(loc, overlay = true)
|
||||
*/
|
||||
function actionIndicatorShow(loc, overlay = true)
|
||||
{
|
||||
console.log('Indicator: SHOW [%s]', loc);
|
||||
// console.log('Indicator: SHOW [%s]', loc);
|
||||
if (!$('#indicator').is(':visible')) {
|
||||
$('#indicator').addClass('progress');
|
||||
if (!$('#indicator').hasClass('progress')) {
|
||||
$('#indicator').addClass('progress');
|
||||
}
|
||||
setCenter('indicator', true, true);
|
||||
$('#indicator').show();
|
||||
}
|
||||
@@ -438,16 +482,15 @@ function actionIndicatorShow(loc, overlay = true)
|
||||
*/
|
||||
function actionIndicatorHide(loc, overlay = true)
|
||||
{
|
||||
console.log('Indicator: HIDE [%s]', loc);
|
||||
// console.log('Indicator: HIDE [%s]', loc);
|
||||
$('#indicator').hide();
|
||||
$('#indicator').removeClass('progress');
|
||||
if (overlay === true) {
|
||||
overlayBoxHide();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* shows the overlay box
|
||||
* shows the overlay box or if already visible, bumps the zIndex to 100
|
||||
*/
|
||||
function overlayBoxShow()
|
||||
{
|
||||
@@ -456,16 +499,17 @@ function overlayBoxShow()
|
||||
$('#overlayBox').css('zIndex', '100');
|
||||
} else {
|
||||
$('#overlayBox').show();
|
||||
$('#overlayBox').css('zIndex', '98');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* hides the overlay box
|
||||
* hides the overlay box or if zIndex is 100 bumps it down to previous level
|
||||
*/
|
||||
function overlayBoxHide()
|
||||
{
|
||||
// if the overlay box z-index is 100, do no hide, but set to 98
|
||||
if ($('#overlayBox').css('zIndex') == 100) {
|
||||
if ($('#overlayBox').css('zIndex') >= 100) {
|
||||
$('#overlayBox').css('zIndex', '98');
|
||||
} else {
|
||||
$('#overlayBox').hide();
|
||||
@@ -482,16 +526,180 @@ function setOverlayBox()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* opposite of set, always hides overlay box
|
||||
*/
|
||||
function hideOverlayBox()
|
||||
{
|
||||
if ($('#overlayBox').is(':visible')) {
|
||||
$('#overlayBox').hide();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* the abort call, clears the action box and hides it and the overlay box
|
||||
*/
|
||||
function ClearCall()
|
||||
{
|
||||
$('#actionBox').innerHTML = '';
|
||||
$('#actionBox').html('');
|
||||
$('#actionBox').hide();
|
||||
$('#overlayBox').hide();
|
||||
}
|
||||
|
||||
/*************************************************************
|
||||
* NEW action indicator and overlay box calls
|
||||
* USE THIS
|
||||
* ***********************************************************/
|
||||
|
||||
/**
|
||||
* show action indicator
|
||||
* - checks if not existing and add
|
||||
* - only shows if not visible (else ignore)
|
||||
* - overlaybox check is called and shown on a fixzed
|
||||
* zIndex of 1000
|
||||
* - indicator is page centered
|
||||
* @param {String} loc ID string, only used for console log
|
||||
*/
|
||||
function showActionIndicator(loc)
|
||||
{
|
||||
// console.log('Indicator: SHOW [%s]', loc);
|
||||
// check if indicator element exists
|
||||
if ($('#indicator').length == 0) {
|
||||
var el = document.createElement('div');
|
||||
el.className = 'progress hide';
|
||||
el.id = 'indicator';
|
||||
$('body').append(el);
|
||||
} else if (!$('#indicator').hasClass('progress')) {
|
||||
$('#indicator').addClass('progress');
|
||||
}
|
||||
// indicator not visible
|
||||
if (!$('#indicator').is(':visible')) {
|
||||
// check if overlay box element exits
|
||||
checkOverlayExists();
|
||||
// if not visible show
|
||||
if (!$('#overlayBox').is(':visible')) {
|
||||
$('#overlayBox').show();
|
||||
}
|
||||
// always set to 1000 zIndex to be top
|
||||
$('#overlayBox').css('zIndex', 1000);
|
||||
// show indicator
|
||||
$('#indicator').show();
|
||||
// center it
|
||||
setCenter('indicator', true, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* hide action indicator, if it is visiable
|
||||
* If the global variable GL_OB_S is > 10 then
|
||||
* the overlayBox is not hidden but the zIndex
|
||||
* is set to this value
|
||||
* @param {String} loc ID string, only used for console log
|
||||
*/
|
||||
function hideActionIndicator(loc)
|
||||
{
|
||||
// console.log('Indicator: HIDE [%s]', loc);
|
||||
// check if indicator is visible
|
||||
if ($('#indicator').is(':visible')) {
|
||||
// hide indicator
|
||||
$('#indicator').hide();
|
||||
// if global overlay box count is > 0
|
||||
// then set it to this level and keep
|
||||
if (GL_OB_S > GL_OB_BASE) {
|
||||
$('#overlayBox').css('zIndex', GL_OB_S);
|
||||
} else {
|
||||
// else hide overlay box and set zIndex to 0
|
||||
$('#overlayBox').hide();
|
||||
$('#overlayBox').css('zIndex', GL_OB_BASE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* checks if overlayBox exists, if not it is
|
||||
* added as hidden item at the body end
|
||||
*/
|
||||
function checkOverlayExists()
|
||||
{
|
||||
// check if overlay box exists, if not create it
|
||||
if ($('#overlayBox').length == 0) {
|
||||
var el = document.createElement('div');
|
||||
el.className = 'overlayBoxElement hide';
|
||||
el.id = 'overlayBox';
|
||||
$('body').append(el);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* show overlay box
|
||||
* if not visible show and set zIndex to 10 (GL_OB_BASE)
|
||||
* if visible, add +1 to the GL_OB_S variable and
|
||||
* up zIndex by this value
|
||||
*/
|
||||
function showOverlayBoxLayers(el_id)
|
||||
{
|
||||
// console.log('SHOW overlaybox: %s', GL_OB_S);
|
||||
// if overlay box is not visible show and set zIndex to 0
|
||||
if (!$('#overlayBox').is(':visible')) {
|
||||
$('#overlayBox').show();
|
||||
$('#overlayBox').css('zIndex', GL_OB_BASE);
|
||||
// also set start variable to 0
|
||||
GL_OB_S = GL_OB_BASE;
|
||||
}
|
||||
// up the overlay box counter by 1
|
||||
GL_OB_S ++;
|
||||
// set zIndex
|
||||
$('#overlayBox').css('zIndex', GL_OB_S);
|
||||
// if element given raise zIndex and show
|
||||
if (el_id) {
|
||||
if ($('#' + el_id).length > 0) {
|
||||
$('#' + el_id).css('zIndex', GL_OB_S + 1);
|
||||
$('#' + el_id).show();
|
||||
}
|
||||
}
|
||||
// console.log('SHOW overlaybox NEW zIndex: %s', $('#overlayBox').css('zIndex'));
|
||||
}
|
||||
|
||||
/**
|
||||
* hide overlay box
|
||||
* lower GL_OB_S value by -1
|
||||
* if we are 10 (GL_OB_BASE) or below hide the overlayIndex
|
||||
* and set zIndex and GL_OB_S to 0
|
||||
* else just set zIndex to the new GL_OB_S value
|
||||
* @param {String} el_id Target to hide layer
|
||||
*/
|
||||
function hideOverlayBoxLayers(el_id)
|
||||
{
|
||||
// console.log('HIDE overlaybox: %s', GL_OB_S);
|
||||
// remove on layer
|
||||
GL_OB_S --;
|
||||
// if 0 or lower (overflow) hide it and
|
||||
// set zIndex to 0
|
||||
if (GL_OB_S <= GL_OB_BASE) {
|
||||
GL_OB_S = GL_OB_BASE;
|
||||
$('#overlayBox').hide();
|
||||
$('#overlayBox').css('zIndex', GL_OB_BASE);
|
||||
} else {
|
||||
// if OB_S > 0 then set new zIndex
|
||||
$('#overlayBox').css('zIndex', GL_OB_S);
|
||||
}
|
||||
if (el_id) {
|
||||
$('#' + el_id).hide();
|
||||
$('#' + el_id).css('zIndex', 0);
|
||||
}
|
||||
// console.log('HIDE overlaybox NEW zIndex: %s', $('#overlayBox').css('zIndex'));
|
||||
}
|
||||
|
||||
/**
|
||||
* only for single action box
|
||||
*/
|
||||
function clearCallActionBox()
|
||||
{
|
||||
$('#actionBox').html('');
|
||||
$('#actionBox').hide();
|
||||
hideOverlayBoxLayers();
|
||||
}
|
||||
|
||||
// *** DOM MANAGEMENT FUNCTIONS
|
||||
/**
|
||||
* reates object for DOM element creation flow
|
||||
@@ -558,6 +766,21 @@ function aelx(base, ...attach)
|
||||
return base;
|
||||
}
|
||||
|
||||
/**
|
||||
* same as aelx, but instead of using objects as parameters
|
||||
* get an array of objects to attach
|
||||
* @param {Object} base object to where we attach the elements
|
||||
* @param {Array} attach array of objects to attach
|
||||
* @return {Object} "none", technically there is no return needed, global attach
|
||||
*/
|
||||
function aelxar(base, attach)
|
||||
{
|
||||
for (var i = 0; i < attach.length; i ++) {
|
||||
base.sub.push(Object.assign({}, attach[i]));
|
||||
}
|
||||
return base;
|
||||
}
|
||||
|
||||
/**
|
||||
* resets the sub elements of the base element given
|
||||
* @param {Object} base cel created element
|
||||
|
||||
@@ -176,7 +176,7 @@ function setCenter(id, left, top)
|
||||
var viewport = getWindowSize();
|
||||
var offset = getScrollOffset();
|
||||
|
||||
console.log('Id %s, type: %s, dimensions %s x %s, viewport %s x %s', id, type, dimensions.width, dimensions.height, viewport.width, viewport.height);
|
||||
// console.log('Id %s, type: %s, dimensions %s x %s, viewport %s x %s', id, type, dimensions.width, dimensions.height, viewport.width, viewport.height);
|
||||
// console.log('Scrolloffset left: %s, top: %s', offset.left, offset.top);
|
||||
// console.log('Left: %s, Top: %s (%s)', parseInt((viewport.width / 2) - (dimensions.width / 2) + offset.left), parseInt((viewport.height / 2) - (dimensions.height / 2) + offset.top), parseInt((viewport.height / 2) - (dimensions.height / 2)));
|
||||
if (left) {
|
||||
@@ -201,8 +201,7 @@ function setCenter(id, left, top)
|
||||
function goToPos(element, offset = 0)
|
||||
{
|
||||
try {
|
||||
if ($(element))
|
||||
{
|
||||
if ($(element)) {
|
||||
// get the element pos
|
||||
var pos = $(element).cumulativeOffset();
|
||||
// if not top element and no offset given, set auto offset for top element
|
||||
@@ -485,7 +484,7 @@ function actionIndicator(loc = '')
|
||||
*/
|
||||
function actionIndicatorShow(loc = '')
|
||||
{
|
||||
console.log('Indicator: SHOW [%s]', loc);
|
||||
// console.log('Indicator: SHOW [%s]', loc);
|
||||
$('indicator').addClassName('progress');
|
||||
setCenter('indicator', true, true);
|
||||
$('indicator').show();
|
||||
@@ -499,14 +498,14 @@ function actionIndicatorShow(loc = '')
|
||||
*/
|
||||
function actionIndicatorHide(loc = '')
|
||||
{
|
||||
console.log('Indicator: HIDE [%s]', loc);
|
||||
// console.log('Indicator: HIDE [%s]', loc);
|
||||
$('indicator').hide();
|
||||
$('indicator').removeClassName('progress');
|
||||
overlayBoxHide();
|
||||
}
|
||||
|
||||
/**
|
||||
* shows the overlay box
|
||||
* shows the overlay box or if already visible, bumps the zIndex to 100
|
||||
*/
|
||||
function overlayBoxShow()
|
||||
{
|
||||
@@ -519,7 +518,7 @@ function overlayBoxShow()
|
||||
}
|
||||
|
||||
/**
|
||||
* hides the overlay box
|
||||
* hides the overlay box or if zIndex is 100 bumps it down to previous level
|
||||
*/
|
||||
function overlayBoxHide()
|
||||
{
|
||||
@@ -544,6 +543,16 @@ function setOverlayBox()
|
||||
$('overlayBox').show();
|
||||
}
|
||||
|
||||
/**
|
||||
* opposite of set, always hides overlay box
|
||||
*/
|
||||
function hideOverlayBox()
|
||||
{
|
||||
if ($('overlayBox').visible()) {
|
||||
$('overlayBox').hide();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* the abort call, clears the action box and hides it and the overlay box
|
||||
*/
|
||||
@@ -618,6 +627,21 @@ function aelx(base, ...attach)
|
||||
return base;
|
||||
}
|
||||
|
||||
/**
|
||||
* same as aelx, but instead of using objects as parameters
|
||||
* get an array of objects to attach
|
||||
* @param {Object} base object to where we attach the elements
|
||||
* @param {Array} attach array of objects to attach
|
||||
* @return {Object} "none", technically there is no return needed, global attach
|
||||
*/
|
||||
function aelxar(base, attach)
|
||||
{
|
||||
attach.each(function(t) {
|
||||
base.sub.push(Object.assign({}, t));
|
||||
});
|
||||
return base;
|
||||
}
|
||||
|
||||
/**
|
||||
* resets the sub elements of the base element given
|
||||
* @param {Object} base cel created element
|
||||
|
||||
@@ -53,7 +53,8 @@
|
||||
]
|
||||
},
|
||||
time_24hr: true,
|
||||
rangeSeparator: ' から '
|
||||
rangeSeparator: " から ",
|
||||
firstDayOfWeek: 1
|
||||
};
|
||||
fp.l10ns.ja = Japanese;
|
||||
var ja = fp.l10ns;
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -161,8 +161,7 @@ class Login extends \CoreLibs\DB\IO
|
||||
|
||||
// if we have a search path we need to set it, to use the correct DB to login
|
||||
// check what schema to use. if there is a login schema use this, else check if there is a schema set in the config, or fall back to DB_SCHEMA if this exists, if this also does not exists use public schema
|
||||
if (defined('LOGIN_DB_SCHEMA')) {
|
||||
/** @phan-suppress-next-line PhanUndeclaredConstant */
|
||||
if (defined('LOGIN_DB_SCHEMA') && LOGIN_DB_SCHEMA) {
|
||||
$SCHEMA = LOGIN_DB_SCHEMA;
|
||||
} elseif (isset($db_config['db_schema']) && $db_config['db_schema']) {
|
||||
$SCHEMA = $db_config['db_schema'];
|
||||
@@ -598,7 +597,7 @@ class Login extends \CoreLibs\DB\IO
|
||||
// unset mem limit if debug is set to 1
|
||||
// if (($GLOBALS["DEBUG_ALL"] || $GLOBALS["DB_DEBUG"] || $_SESSION["DEBUG_ALL"] || $_SESSION["DB_DEBUG"]) && ini_get('memory_limit') != -1)
|
||||
// ini_set('memory_limit', -1);
|
||||
if ($res['filename'] == $this->page_name) {
|
||||
if (isset($res['filename']) && $res['filename'] == $this->page_name) {
|
||||
$this->permission_okay = true;
|
||||
} else {
|
||||
$this->login_error = 103;
|
||||
|
||||
@@ -169,8 +169,7 @@ class Backend extends \CoreLibs\DB\IO
|
||||
}
|
||||
|
||||
// check schema
|
||||
if (defined('LOGIN_DB_SCHEMA')) {
|
||||
/** @phan-suppress-next-line PhanUndeclaredConstant */
|
||||
if (defined('LOGIN_DB_SCHEMA') && LOGIN_DB_SCHEMA) {
|
||||
$SCHEMA = LOGIN_DB_SCHEMA;
|
||||
} elseif ($this->dbGetSchema()) {
|
||||
$SCHEMA = $this->dbGetSchema();
|
||||
@@ -256,7 +255,6 @@ class Backend extends \CoreLibs\DB\IO
|
||||
$type = 'popup';
|
||||
} else {
|
||||
$type = 'normal';
|
||||
/** @phan-suppress-next-line PhanTypeArraySuspicious */
|
||||
$data['popup'] = 0;
|
||||
}
|
||||
$query_string = '';
|
||||
@@ -342,6 +340,7 @@ class Backend extends \CoreLibs\DB\IO
|
||||
if ($filename === null) {
|
||||
return $enabled;
|
||||
}
|
||||
/** @phan-suppress-next-line PhanNoopSwitchCases */
|
||||
switch ($filename) {
|
||||
default:
|
||||
$enabled = true;
|
||||
@@ -443,8 +442,7 @@ class Backend extends \CoreLibs\DB\IO
|
||||
string $associate = null,
|
||||
string $file = null
|
||||
): void {
|
||||
if (defined('GLOBAL_DB_SCHEMA')) {
|
||||
/** @phan-suppress-next-line PhanUndeclaredConstant */
|
||||
if (defined('GLOBAL_DB_SCHEMA') && GLOBAL_DB_SCHEMA) {
|
||||
$SCHEMA = GLOBAL_DB_SCHEMA;
|
||||
} elseif ($this->dbGetSchema()) {
|
||||
$SCHEMA = $this->dbGetSchema();
|
||||
|
||||
@@ -866,64 +866,64 @@ class Basic
|
||||
*/
|
||||
private function writeErrorMsg(string $level, string $error_string): void
|
||||
{
|
||||
if ($this->doDebugTrigger('debug', $level)) {
|
||||
// only write if write is requested
|
||||
if ($this->doDebugTrigger('print', $level)) {
|
||||
// replace all html tags
|
||||
// $error_string = preg_replace("/(<\/?)(\w+)([^>]*>)/", "##\\2##", $error_string);
|
||||
// $error_string = preg_replace("/(<\/?)(\w+)([^>]*>)/", "", $error_string);
|
||||
// replace special line break tag
|
||||
// $error_string = str_replace('<!--#BR#-->', "\n", $error_string);
|
||||
// only write if write is requested
|
||||
if ($this->doDebugTrigger('debug', $level) &&
|
||||
$this->doDebugTrigger('print', $level)
|
||||
) {
|
||||
// replace all html tags
|
||||
// $error_string = preg_replace("/(<\/?)(\w+)([^>]*>)/", "##\\2##", $error_string);
|
||||
// $error_string = preg_replace("/(<\/?)(\w+)([^>]*>)/", "", $error_string);
|
||||
// replace special line break tag
|
||||
// $error_string = str_replace('<!--#BR#-->', "\n", $error_string);
|
||||
|
||||
// init output variable
|
||||
$output = $error_string; // output formated error string to output file
|
||||
// init base file path
|
||||
$fn = BASE.LOG.$this->log_print_file.'.'.$this->log_file_name_ext;
|
||||
// log ID prefix settings, if not valid, replace with empty
|
||||
if (preg_match("/^[A-Za-z0-9]+$/", $this->log_file_id)) {
|
||||
$rpl_string = '_'.$this->log_file_id;
|
||||
} else {
|
||||
$rpl_string = '';
|
||||
// init output variable
|
||||
$output = $error_string; // output formated error string to output file
|
||||
// init base file path
|
||||
$fn = BASE.LOG.$this->log_print_file.'.'.$this->log_file_name_ext;
|
||||
// log ID prefix settings, if not valid, replace with empty
|
||||
if (preg_match("/^[A-Za-z0-9]+$/", $this->log_file_id)) {
|
||||
$rpl_string = '_'.$this->log_file_id;
|
||||
} else {
|
||||
$rpl_string = '';
|
||||
}
|
||||
$fn = str_replace('##LOGID##', $rpl_string, $fn); // log id (like a log file prefix)
|
||||
|
||||
if ($this->log_per_run) {
|
||||
if (isset($GLOBALS['LOG_FILE_UNIQUE_ID'])) {
|
||||
$this->log_file_unique_id = $GLOBALS['LOG_FILE_UNIQUE_ID'];
|
||||
}
|
||||
$fn = str_replace('##LOGID##', $rpl_string, $fn); // log id (like a log file prefix)
|
||||
|
||||
if ($this->log_per_run) {
|
||||
if (isset($GLOBALS['LOG_FILE_UNIQUE_ID'])) {
|
||||
$this->log_file_unique_id = $GLOBALS['LOG_FILE_UNIQUE_ID'];
|
||||
}
|
||||
if (!$this->log_file_unique_id) {
|
||||
$GLOBALS['LOG_FILE_UNIQUE_ID'] = $this->log_file_unique_id = date('Y-m-d_His').'_U_'.substr(hash('sha1', uniqid((string)mt_rand(), true)), 0, 8);
|
||||
}
|
||||
$rpl_string = '_'.$this->log_file_unique_id; // add 8 char unique string
|
||||
} else {
|
||||
$rpl_string = !$this->log_print_file_date ? '' : '_'.date('Y-m-d'); // add date to file
|
||||
if (!$this->log_file_unique_id) {
|
||||
$GLOBALS['LOG_FILE_UNIQUE_ID'] = $this->log_file_unique_id = date('Y-m-d_His').'_U_'.substr(hash('sha1', uniqid((string)mt_rand(), true)), 0, 8);
|
||||
}
|
||||
$fn = str_replace('##DATE##', $rpl_string, $fn); // create output filename
|
||||
$rpl_string = '_'.$this->log_file_unique_id; // add 8 char unique string
|
||||
} else {
|
||||
$rpl_string = !$this->log_print_file_date ? '' : '_'.date('Y-m-d'); // add date to file
|
||||
}
|
||||
$fn = str_replace('##DATE##', $rpl_string, $fn); // create output filename
|
||||
|
||||
$rpl_string = !$this->log_per_level ? '' : '_'.$level; // if request to write to one file
|
||||
$fn = str_replace('##LEVEL##', $rpl_string, $fn); // create output filename
|
||||
$rpl_string = !$this->log_per_level ? '' : '_'.$level; // if request to write to one file
|
||||
$fn = str_replace('##LEVEL##', $rpl_string, $fn); // create output filename
|
||||
|
||||
$rpl_string = !$this->log_per_class ? '' : '_'.str_replace('\\', '-', get_class($this)); // set sub class settings
|
||||
$fn = str_replace('##CLASS##', $rpl_string, $fn); // create output filename
|
||||
$rpl_string = !$this->log_per_class ? '' : '_'.str_replace('\\', '-', get_class($this)); // set sub class settings
|
||||
$fn = str_replace('##CLASS##', $rpl_string, $fn); // create output filename
|
||||
|
||||
$rpl_string = !$this->log_per_page ? '' : '_'.$this->getPageName(1); // if request to write to one file
|
||||
$fn = str_replace('##PAGENAME##', $rpl_string, $fn); // create output filename
|
||||
$rpl_string = !$this->log_per_page ? '' : '_'.$this->getPageName(1); // if request to write to one file
|
||||
$fn = str_replace('##PAGENAME##', $rpl_string, $fn); // create output filename
|
||||
|
||||
// write to file
|
||||
// first check if max file size is is set and file is bigger
|
||||
if ($this->log_max_filesize > 0 && ((filesize($fn) / 1024) > $this->log_max_filesize)) {
|
||||
// for easy purpose, rename file only to attach timestamp, nur sequence numbering
|
||||
rename($fn, $fn.'.'.date("YmdHis"));
|
||||
}
|
||||
$fp = fopen($fn, 'a');
|
||||
if ($fp !== false) {
|
||||
fwrite($fp, $output);
|
||||
fclose($fp);
|
||||
} else {
|
||||
echo "<!-- could not open file: $fn //-->";
|
||||
}
|
||||
} // do write to file
|
||||
}
|
||||
// write to file
|
||||
// first check if max file size is is set and file is bigger
|
||||
if ($this->log_max_filesize > 0 && ((filesize($fn) / 1024) > $this->log_max_filesize)) {
|
||||
// for easy purpose, rename file only to attach timestamp, nur sequence numbering
|
||||
rename($fn, $fn.'.'.date("YmdHis"));
|
||||
}
|
||||
$fp = fopen($fn, 'a');
|
||||
if ($fp !== false) {
|
||||
fwrite($fp, $output);
|
||||
fclose($fp);
|
||||
} else {
|
||||
echo "<!-- could not open file: $fn //-->";
|
||||
}
|
||||
} // do write to file
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1808,6 +1808,7 @@ class Basic
|
||||
*/
|
||||
public static function stringByteFormat($number, bool $dot_thousand = false)
|
||||
{
|
||||
$matches = [];
|
||||
// detects up to exo bytes
|
||||
preg_match("/([\d.,]*)\s?(eb|pb|tb|gb|mb|kb|e|p|t|g|m|k|b)$/", strtolower($number), $matches);
|
||||
if (isset($matches[1]) && isset($matches[2])) {
|
||||
@@ -2181,6 +2182,8 @@ class Basic
|
||||
}
|
||||
// if type is not in the list, but returns as PDF, we need to convert to JPEG before
|
||||
if (!$type) {
|
||||
$output = [];
|
||||
$return = null;
|
||||
// is this a PDF, if no, return from here with nothing
|
||||
$convert_prefix = 'png:';
|
||||
# TEMP convert to PNG, we then override the file name
|
||||
@@ -2562,17 +2565,33 @@ class Basic
|
||||
}
|
||||
|
||||
/**
|
||||
* detects the source encoding of the string and if doesn't match to the given target encoding it convert is
|
||||
* detects the source encoding of the string and if doesn't match
|
||||
* to the given target encoding it convert is
|
||||
* if source encoding is set and auto check is true (default) a second
|
||||
* check is done so that the source string encoding actually matches
|
||||
* will be skipped if source encoding detection is ascii
|
||||
* @param string $string string to convert
|
||||
* @param string $to_encoding target encoding
|
||||
* @param string $source_encoding optional source encoding, will try to auto detect
|
||||
* @param bool $auto_check default true, if source encoding is set
|
||||
* check that the source is actually matching
|
||||
* to what we sav the source is
|
||||
* @return string encoding converted string
|
||||
*/
|
||||
public static function convertEncoding(string $string, string $to_encoding, string $source_encoding = ''): string
|
||||
public static function convertEncoding(string $string, string $to_encoding, string $source_encoding = '', bool $auto_check = true): string
|
||||
{
|
||||
// set if not given
|
||||
if (!$source_encoding) {
|
||||
$source_encoding = mb_detect_encoding($string);
|
||||
} else {
|
||||
$_source_encoding = mb_detect_encoding($string);
|
||||
}
|
||||
if ($auto_check === true &&
|
||||
isset($_source_encoding) &&
|
||||
$_source_encoding == $source_encoding
|
||||
) {
|
||||
// trigger check if we have override source encoding.
|
||||
// if different (_source is all but not ascii) then trigger skip if matching
|
||||
}
|
||||
if ($source_encoding != $to_encoding) {
|
||||
if ($source_encoding) {
|
||||
|
||||
@@ -288,6 +288,7 @@ class IO extends \CoreLibs\Basic
|
||||
|
||||
// endless loop protection
|
||||
private $MAX_QUERY_CALL;
|
||||
private $DEFAULT_MAX_QUERY_CALL = 20; // default
|
||||
private $query_called = array();
|
||||
// error string
|
||||
protected $error_string = array();
|
||||
@@ -357,6 +358,8 @@ class IO extends \CoreLibs\Basic
|
||||
$this->error_string['40'] = 'Query async call failed.';
|
||||
$this->error_string['41'] = 'Connection is busy with a different query. Cannot execute.';
|
||||
$this->error_string['42'] = 'Cannot check for async query, none has been started yet.';
|
||||
$this->error_string['50'] = 'Setting max query call to -1 will disable loop protection for all subsequent runs';
|
||||
$this->error_string['51'] = 'Max query call needs to be set to at least 1';
|
||||
|
||||
// set debug, either via global var, or debug var during call
|
||||
$this->db_debug = false;
|
||||
@@ -633,6 +636,7 @@ class IO extends \CoreLibs\Basic
|
||||
*/
|
||||
private function __dbReturnTable(string $query): array
|
||||
{
|
||||
$matches = [];
|
||||
if (preg_match("/^SELECT /i", $query)) {
|
||||
preg_match("/ (FROM) (([\w_]+)\.)?([\w_]+) /i", $query, $matches);
|
||||
} else {
|
||||
@@ -655,6 +659,7 @@ class IO extends \CoreLibs\Basic
|
||||
*/
|
||||
private function __dbPrepareExec(string $query, string $pk_name)
|
||||
{
|
||||
$matches= [];
|
||||
// to either use the returning method or the guess method for getting primary keys
|
||||
$this->returning_id = false;
|
||||
// set the query
|
||||
@@ -729,7 +734,10 @@ class IO extends \CoreLibs\Basic
|
||||
$this->query_called[$md5] = 0;
|
||||
}
|
||||
// count up the run, if this is run more than the max_run then exit with error
|
||||
if ($this->query_called[$md5] > $this->MAX_QUERY_CALL) {
|
||||
// if set to -1, then ignore it
|
||||
if ($this->MAX_QUERY_CALL != -1 &&
|
||||
$this->query_called[$md5] > $this->MAX_QUERY_CALL
|
||||
) {
|
||||
$this->error_id = 30;
|
||||
$this->__dbError();
|
||||
$this->__dbDebug('db', $this->query, 'dbExec', 'Q[nc]');
|
||||
@@ -855,6 +863,52 @@ class IO extends \CoreLibs\Basic
|
||||
return $this->db_debug;
|
||||
}
|
||||
|
||||
/**
|
||||
* set max query calls, set to --1 to disable loop
|
||||
* protection. this will generate a warning
|
||||
* empty call (null) will reset to default
|
||||
* @param int|null $max_calls Set the max loops allowed
|
||||
* @return bool True for succesfull set
|
||||
*/
|
||||
public function dbSetMaxQueryCall(?int $max_calls = null): bool
|
||||
{
|
||||
$success = false;
|
||||
// if null then reset to default
|
||||
if ($max_calls === null) {
|
||||
$max_calls = $this->DEFAULT_MAX_QUERY_CALL;
|
||||
}
|
||||
// if -1 then disable loop check
|
||||
// DANGEROUS, WARN USER
|
||||
if ($max_calls == -1) {
|
||||
$this->warning_id = 50;
|
||||
$this->__dbError();
|
||||
}
|
||||
// negative or 0
|
||||
if ($max_calls < -1 || $max_calls == 0) {
|
||||
$this->error_id = 51;
|
||||
$this->__dbError();
|
||||
// early abort
|
||||
return false;
|
||||
}
|
||||
// ok entry, set
|
||||
if ($max_calls == -1 ||
|
||||
$max_calls > 0
|
||||
) {
|
||||
$this->MAX_QUERY_CALL = $max_calls;
|
||||
$succes = true;
|
||||
}
|
||||
return $success;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns current set max query calls for loop avoidance
|
||||
* @return int Integer number, if -1 the loop check is disabled
|
||||
*/
|
||||
public function dbGetMaxQueryCall(): int
|
||||
{
|
||||
return $this->MAX_QUERY_CALL;
|
||||
}
|
||||
|
||||
/**
|
||||
* resets the call times for the max query called to 0
|
||||
* USE CAREFULLY: rather make the query prepare -> execute
|
||||
@@ -1454,6 +1508,7 @@ class IO extends \CoreLibs\Basic
|
||||
*/
|
||||
public function dbPrepare(string $stm_name, string $query, string $pk_name = '')
|
||||
{
|
||||
$matches = [];
|
||||
if (!$query) {
|
||||
$this->error_id = 11;
|
||||
$this->__dbError();
|
||||
@@ -1507,6 +1562,7 @@ class IO extends \CoreLibs\Basic
|
||||
$this->prepare_cursor[$stm_name]['pk_name'] = $pk_name;
|
||||
}
|
||||
}
|
||||
$match = [];
|
||||
// search for $1, $2, in the query and push it into the control array
|
||||
preg_match_all('/(\$[0-9]{1,})/', $query, $match);
|
||||
$this->prepare_cursor[$stm_name]['count'] = count($match[1]);
|
||||
@@ -1665,6 +1721,7 @@ class IO extends \CoreLibs\Basic
|
||||
*/
|
||||
public function dbCompareVersion(string $compare): bool
|
||||
{
|
||||
$matches = [];
|
||||
// compare has =, >, < prefix, and gets stripped, if the rest is not X.Y format then error
|
||||
preg_match("/^([<>=]{1,})(\d{1,})\.(\d{1,})/", $compare, $matches);
|
||||
$compare = $matches[1];
|
||||
@@ -1909,10 +1966,10 @@ class IO extends \CoreLibs\Basic
|
||||
*/
|
||||
public function dbTimeFormat(string $age, bool $show_micro = false): string
|
||||
{
|
||||
$matches = [];
|
||||
// in string (datetime diff): 1786 days 22:11:52.87418
|
||||
// or (age): 4 years 10 mons 21 days 12:31:11.87418
|
||||
// also -09:43:54.781021 or without - prefix
|
||||
|
||||
preg_match("/(.*)?(\d{2}):(\d{2}):(\d{2})(\.(\d+))/", $age, $matches);
|
||||
|
||||
$prefix = $matches[1] != '-' ? $matches[1] : '';
|
||||
|
||||
@@ -311,7 +311,7 @@ class PgSQL
|
||||
$q .= "AND indisprimary";
|
||||
$cursor = $this->__dbQuery($q);
|
||||
if ($cursor) {
|
||||
return $this->__dbFetchArray($cursor)['column_name'];
|
||||
return $this->__dbFetchArray($cursor)['column_name'] ?? false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -829,7 +829,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
$data['checked'] = 0;
|
||||
for ($i = (count($this->table_array[$element_name]['element_list']) - 1); $i >= 0; $i --) {
|
||||
$data['value'][] = $i;
|
||||
$data['output'][] = $this->table_array[$element_name]['element_list'][$i];
|
||||
$data['output'][] = $this->table_array[$element_name]['element_list'][$i] ?? null;
|
||||
$data['name'] = $element_name;
|
||||
if (isset($this->table_array[$element_name]['value']) &&
|
||||
(($i && $this->table_array[$element_name]['value']) ||
|
||||
@@ -1234,9 +1234,9 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
} elseif ($data_array['type'] == 'radio_group' && !isset($_POST[$prfx.$el_name])) {
|
||||
// radio group and set where one not active
|
||||
// $this->debug('edit_error_chk', 'RADIO GROUP');
|
||||
$row_okay[$_POST[$prfx.$el_name][$i]] = 0;
|
||||
$default_wrong[$_POST[$prfx.$el_name][$i]] = 1;
|
||||
$error[$_POST[$prfx.$el_name][$i]] = 1;
|
||||
$row_okay[$_POST[$prfx.$el_name][$i] ?? 0] = 0;
|
||||
$default_wrong[$_POST[$prfx.$el_name][$i] ?? 0] = 1;
|
||||
$error[$_POST[$prfx.$el_name][$i] ?? 0] = 1;
|
||||
} elseif (isset($_POST[$prfx.$el_name][$i]) && !isset($error[$i])) {
|
||||
// $this->debug('edit_error_chk', '[$i]');
|
||||
$element_set[$i] = 1;
|
||||
@@ -1646,7 +1646,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
// data part, read from where [POST]
|
||||
// radio group selections (only one can be active)
|
||||
if ($data_array['type'] == 'radio_group') {
|
||||
if ($i == $_POST[$prfx.$el_name]) {
|
||||
if (isset($_POST[$prfx.$el_name]) && $i == $_POST[$prfx.$el_name]) {
|
||||
$_value = $i + 1;
|
||||
} else {
|
||||
$_value = 'NULL';
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
xmlns="https://getpsalm.org/schema/config"
|
||||
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
|
||||
autoloader="lib/autoloader.php"
|
||||
errorLevel="8"
|
||||
>
|
||||
<projectFiles>
|
||||
<file name="admin/class_test.php" />
|
||||
@@ -28,7 +29,8 @@
|
||||
<directory name="tmp" />
|
||||
<directory name="log" />
|
||||
<directory name="media" />
|
||||
<directory name="lib/pChart" />
|
||||
<directory name="lib/FileUpload" />
|
||||
<directory name="lib/pChart" />
|
||||
<directory name="lib/pChart2.1.4" />
|
||||
<directory name="lib/Smarty" />
|
||||
<directory name="lib/smarty-3.1.30" />
|
||||
|
||||
Reference in New Issue
Block a user