Remove \Basic class from all other Class extensions
If not created Logger class will be auto created in \DB\IO Recommended to run a CoreLibs\Debug\Logging([...]); and use this class for all ACL\Login, Admin\Backend, DB\IO, Output\Form\Generate calls. Last parameter after DB CONFIG is the log parameter Session create has been moved to a new Create\Session class from the \Basic class and MUST be started before using ACL\Login. Currently ACL\Login will fallback and start it if no session is yet started. See the Readme.md file for which classes use _SESSION data In future the _SESSION settings should be moved to some wrapper class for this so we can unit test sessions Only Output\Form\Generate class call has the new changed with the second parameter no longer beeing the table width setting but the class setting. But as this is a semi retired class and only used for edit_base this is not 100% breaking. All other classes can be used as is and have internal fallback to run as before. Deprecation messages will be added later.
This commit is contained in:
104
4dev/tests/CoreLibsCreateSessionTest.php
Normal file
104
4dev/tests/CoreLibsCreateSessionTest.php
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace tests;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test class for Create\Session
|
||||||
|
* @coversDefaultClass \CoreLibs\Create\Session
|
||||||
|
* @testdox \CoreLibs\Create\Session method tests
|
||||||
|
*/
|
||||||
|
final class CoreLibsCreateSessionTest extends TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function sessionProvider(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'session parameter' => [
|
||||||
|
'sessionNameParameter',
|
||||||
|
'p',
|
||||||
|
'sessionNameParameter',
|
||||||
|
'/^\w+$/'
|
||||||
|
],
|
||||||
|
'session globals' => [
|
||||||
|
'sessionNameGlobals',
|
||||||
|
'g',
|
||||||
|
'sessionNameGlobals',
|
||||||
|
'/^\w+$/'
|
||||||
|
],
|
||||||
|
'session constant' => [
|
||||||
|
'sessionNameConstant',
|
||||||
|
'c',
|
||||||
|
'sessionNameConstant',
|
||||||
|
'/^\w+$/'
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
if (session_id()) {
|
||||||
|
session_destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @dataProvider sessionProvider
|
||||||
|
* @testdox startSession $input name for $type will be $expected_n with $expected_i [$_dataName]
|
||||||
|
*
|
||||||
|
* @param string $input
|
||||||
|
* @param string $type
|
||||||
|
* @param string|bool $expected_n
|
||||||
|
* @param string|bool $expected_i
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testStartSession(string $input, string $type, $expected_n, $expected_i): void
|
||||||
|
{
|
||||||
|
/* $session_id = '';
|
||||||
|
switch ($type) {
|
||||||
|
case 'p':
|
||||||
|
$session_id = \CoreLibs\Create\Session::startSession($input);
|
||||||
|
break;
|
||||||
|
case 'g':
|
||||||
|
$GLOBALS['SET_SESSION_NAME'] = $input;
|
||||||
|
$session_id = \CoreLibs\Create\Session::startSession();
|
||||||
|
break;
|
||||||
|
case 'c':
|
||||||
|
define('SET_SESSION_NAME', $input);
|
||||||
|
$session_id = \CoreLibs\Create\Session::startSession();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$this->assertMatchesRegularExpression(
|
||||||
|
$expected_i,
|
||||||
|
(string)$session_id
|
||||||
|
);
|
||||||
|
$this->assertMatchesRegularExpression(
|
||||||
|
$expected_i,
|
||||||
|
(string)\CoreLibs\Create\Session::getSessionId()
|
||||||
|
);
|
||||||
|
$this->assertEquals(
|
||||||
|
$expected_n,
|
||||||
|
\CoreLibs\Create\Session::getSessionName()
|
||||||
|
);
|
||||||
|
if ($type == 'g') {
|
||||||
|
unset($GLOBALS['SET_SESSION_NAME']);
|
||||||
|
} */
|
||||||
|
$this->markTestSkipped('No implementation for Create\Session. Cannot run session_start in CLI');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// __END__
|
||||||
@@ -23,21 +23,27 @@ final class CoreLibsDebugLoggingTest extends TestCase
|
|||||||
'log_folder' => '/tmp'
|
'log_folder' => '/tmp'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'log_folder' => '/tmp/'
|
'log_folder' => '/tmp/',
|
||||||
|
'debug_all' => false,
|
||||||
|
'print_all' => false,
|
||||||
],
|
],
|
||||||
[]
|
[]
|
||||||
],
|
],
|
||||||
'nothing set' => [
|
'nothing set' => [
|
||||||
null,
|
null,
|
||||||
[
|
[
|
||||||
'log_folder' => getcwd() . DIRECTORY_SEPARATOR
|
'log_folder' => getcwd() . DIRECTORY_SEPARATOR,
|
||||||
|
'debug_all' => false,
|
||||||
|
'print_all' => false,
|
||||||
],
|
],
|
||||||
[]
|
[]
|
||||||
],
|
],
|
||||||
'no options set, constant set' => [
|
'no options set, constant set' => [
|
||||||
null,
|
null,
|
||||||
[
|
[
|
||||||
'log_folder' => '/tmp/'
|
'log_folder' => '/tmp/',
|
||||||
|
'debug_all' => false,
|
||||||
|
'print_all' => false,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'constant' => [
|
'constant' => [
|
||||||
@@ -46,6 +52,19 @@ final class CoreLibsDebugLoggingTest extends TestCase
|
|||||||
]
|
]
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
'standard test set' => [
|
||||||
|
[
|
||||||
|
'log_folder' => '/tmp',
|
||||||
|
'debug_all' => true,
|
||||||
|
'print_all' => true,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'log_folder' => '/tmp/',
|
||||||
|
'debug_all' => true,
|
||||||
|
'print_all' => true,
|
||||||
|
],
|
||||||
|
[]
|
||||||
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,11 +95,21 @@ final class CoreLibsDebugLoggingTest extends TestCase
|
|||||||
$this->log = new \CoreLibs\Debug\Logging($options);
|
$this->log = new \CoreLibs\Debug\Logging($options);
|
||||||
}
|
}
|
||||||
// check that settings match
|
// check that settings match
|
||||||
// print "LOG: " . $this->log->getSetting('log_folder') . "\n";
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$expected['log_folder'],
|
$expected['log_folder'],
|
||||||
$this->log->getSetting('log_folder')
|
$this->log->getSetting('log_folder')
|
||||||
);
|
);
|
||||||
|
$this->assertEquals(
|
||||||
|
$expected['debug_all'],
|
||||||
|
$this->log->getSetting('debug_all')
|
||||||
|
);
|
||||||
|
$this->assertEquals(
|
||||||
|
$expected['print_all'],
|
||||||
|
$this->log->getSetting('print_all')
|
||||||
|
);
|
||||||
|
print "LOG: " . $this->log->getSetting('log_folder') . "\n";
|
||||||
|
print "DEBUG: " . $this->log->getSetting('debug_all') . "\n";
|
||||||
|
print "PRINT: " . $this->log->getSetting('print_all') . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// setting tests
|
// setting tests
|
||||||
|
|||||||
38
README.md
38
README.md
@@ -22,7 +22,8 @@ There are three branches:
|
|||||||
|
|
||||||
### master
|
### master
|
||||||
|
|
||||||
The active branch, which is the namespace branch
|
The active branch, which is the namespace branch.
|
||||||
|
Currently compatible with PHP 7.4 and 8.0
|
||||||
|
|
||||||
### legacy
|
### legacy
|
||||||
|
|
||||||
@@ -48,3 +49,38 @@ pslam is setup but not configured
|
|||||||
|
|
||||||
With phpunit (`4dev/checking/phpunit.sh`)
|
With phpunit (`4dev/checking/phpunit.sh`)
|
||||||
`phpunit -c $phpunit.xml 4dev/tests/`
|
`phpunit -c $phpunit.xml 4dev/tests/`
|
||||||
|
|
||||||
|
|
||||||
|
## Other Notes
|
||||||
|
|
||||||
|
### Session used
|
||||||
|
|
||||||
|
The following classes use _SESSION
|
||||||
|
The main one is ACL\Login, this class will fail without a session started
|
||||||
|
|
||||||
|
* \CoreLibs\ACL\Login
|
||||||
|
* \CoreLibs\Admin\Backend
|
||||||
|
* \CoreLibs\Output\Form\Generate
|
||||||
|
* \CoreLibs\Output\Form\Token
|
||||||
|
* \CoreLibs\Template\SmartyExtend
|
||||||
|
|
||||||
|
### Class extends
|
||||||
|
|
||||||
|
The following classes extend these classes
|
||||||
|
|
||||||
|
* \CoreLibs\ACL\Login extends \CoreLibs\DB\IO
|
||||||
|
* \CoreLibs\Admin\Backend extends \CoreLibs\DB\IO
|
||||||
|
* \CoreLibs\DB\Extended\ArrayIO extends \CoreLibs\DB\IO
|
||||||
|
* \CoreLibs\Output\Form\Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||||
|
* \CoreLibs\Template\SmartyExtend extends SmartyBC
|
||||||
|
|
||||||
|
### Class used
|
||||||
|
|
||||||
|
The following classes use the following classes
|
||||||
|
|
||||||
|
* \CoreLibs\ACL\Login uses \CoreLibs\Debug\Logger, \CoreLibs\Language\L10n
|
||||||
|
* \CoreLibs\DB\IO uses \CoreLibs\Debug\Logger, \CoreLibs\DB\SQL\PgSQL
|
||||||
|
* \CoreLibs\Admin\Backend uses \CoreLibs\Debug\Logger, \CoreLibs\Language\L10n
|
||||||
|
* \CoreLibs\Output\Form\Generate uses \CoreLibs\Debug\Logger, \CoreLibs\Language\L10n
|
||||||
|
* \CoreLibs\Template\SmartyExtend uses \CoreLibs\Language\L10n
|
||||||
|
* \CoreLibs\Language\L10n uses FileReader, GetTextReader
|
||||||
|
|||||||
@@ -31,8 +31,18 @@ if (!defined('SET_SESSION_NAME')) {
|
|||||||
$LOG_FILE_ID = 'classTest-admin';
|
$LOG_FILE_ID = 'classTest-admin';
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
|
|
||||||
$basic = new CoreLibs\Basic();
|
$log = new CoreLibs\Debug\Logging([
|
||||||
$backend = new CoreLibs\Admin\Backend(DB_CONFIG);
|
'log_folder' => BASE . LOG,
|
||||||
|
'file_id' => $LOG_FILE_ID,
|
||||||
|
// add file date
|
||||||
|
'print_file_date' => true,
|
||||||
|
// set debug and print flags
|
||||||
|
'debug_all' => $DEBUG_ALL ?? false,
|
||||||
|
'echo_all' => $ECHO_ALL ?? false,
|
||||||
|
'print_all' => $PRINT_ALL ?? false,
|
||||||
|
]);
|
||||||
|
$basic = new CoreLibs\Basic($log);
|
||||||
|
$backend = new CoreLibs\Admin\Backend(DB_CONFIG, $log);
|
||||||
|
|
||||||
print "<html><head><title>TEST CLASS: ADMIN BACKEND</title><head>";
|
print "<html><head><title>TEST CLASS: ADMIN BACKEND</title><head>";
|
||||||
print "<body>";
|
print "<body>";
|
||||||
@@ -47,7 +57,7 @@ print "Messaes: " . \CoreLibs\Debug\Support::printAr($this->messages) . "<br>";
|
|||||||
print "ADBPRINTDATETIME:<br>" . $backend->adbPrintDateTime(2021, 6, 21, 6, 38, '_test') . "<br>";
|
print "ADBPRINTDATETIME:<br>" . $backend->adbPrintDateTime(2021, 6, 21, 6, 38, '_test') . "<br>";
|
||||||
|
|
||||||
// error message
|
// error message
|
||||||
print $basic->log->printErrorMsg();
|
print $log->printErrorMsg();
|
||||||
|
|
||||||
print "</body></html>";
|
print "</body></html>";
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,17 @@ ob_end_flush();
|
|||||||
use CoreLibs\Combined\ArrayHandler;
|
use CoreLibs\Combined\ArrayHandler;
|
||||||
use CoreLibs\Debug\Support as DgS;
|
use CoreLibs\Debug\Support as DgS;
|
||||||
|
|
||||||
$basic = new CoreLibs\Basic();
|
$log = new CoreLibs\Debug\Logging([
|
||||||
|
'log_folder' => BASE . LOG,
|
||||||
|
'file_id' => $LOG_FILE_ID,
|
||||||
|
// add file date
|
||||||
|
'print_file_date' => true,
|
||||||
|
// set debug and print flags
|
||||||
|
'debug_all' => $DEBUG_ALL ?? false,
|
||||||
|
'echo_all' => $ECHO_ALL ?? false,
|
||||||
|
'print_all' => $PRINT_ALL ?? false,
|
||||||
|
]);
|
||||||
|
$basic = new CoreLibs\Basic($log);
|
||||||
// $_array = new CoreLibs\Combined\ArrayHandler();
|
// $_array = new CoreLibs\Combined\ArrayHandler();
|
||||||
// $array_class = 'CoreLibs\Combination\ArrayHandler';
|
// $array_class = 'CoreLibs\Combination\ArrayHandler';
|
||||||
|
|
||||||
@@ -207,7 +217,7 @@ $output = \CoreLibs\Combined\ArrayHandler::genAssocArray($db_array, $key, $value
|
|||||||
print "OUTPUT: " . \CoreLibs\Debug\Support::printAr($output) . "<br>";
|
print "OUTPUT: " . \CoreLibs\Debug\Support::printAr($output) . "<br>";
|
||||||
|
|
||||||
// error message
|
// error message
|
||||||
print $basic->log->printErrorMsg();
|
print $log->printErrorMsg();
|
||||||
|
|
||||||
print "</body></html>";
|
print "</body></html>";
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,17 @@ ob_end_flush();
|
|||||||
|
|
||||||
use CoreLibs\Convert\Byte;
|
use CoreLibs\Convert\Byte;
|
||||||
|
|
||||||
$basic = new CoreLibs\Basic();
|
$log = new CoreLibs\Debug\Logging([
|
||||||
|
'log_folder' => BASE . LOG,
|
||||||
|
'file_id' => $LOG_FILE_ID,
|
||||||
|
// add file date
|
||||||
|
'print_file_date' => true,
|
||||||
|
// set debug and print flags
|
||||||
|
'debug_all' => $DEBUG_ALL ?? false,
|
||||||
|
'echo_all' => $ECHO_ALL ?? false,
|
||||||
|
'print_all' => $PRINT_ALL ?? false,
|
||||||
|
]);
|
||||||
|
$basic = new CoreLibs\Basic($log);
|
||||||
$byte_class = 'CoreLibs\Convert\Byte';
|
$byte_class = 'CoreLibs\Convert\Byte';
|
||||||
|
|
||||||
print "<html><head><title>TEST CLASS: BYTE CONVERT</title><head>";
|
print "<html><head><title>TEST CLASS: BYTE CONVERT</title><head>";
|
||||||
@@ -104,7 +114,7 @@ print "BYTE TO: $byte: ".$basic->humanReadableByteFormat($byte)."<br>";
|
|||||||
print "BYTE FROM: $string: ".$basic->stringByteFormat($string)."<br>"; */
|
print "BYTE FROM: $string: ".$basic->stringByteFormat($string)."<br>"; */
|
||||||
|
|
||||||
// error message
|
// error message
|
||||||
print $basic->log->printErrorMsg();
|
print $log->printErrorMsg();
|
||||||
|
|
||||||
print "</body></html>";
|
print "</body></html>";
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,17 @@ ob_end_flush();
|
|||||||
use CoreLibs\Convert\Colors;
|
use CoreLibs\Convert\Colors;
|
||||||
use CoreLibs\Debug\Support as DgS;
|
use CoreLibs\Debug\Support as DgS;
|
||||||
|
|
||||||
$basic = new CoreLibs\Basic();
|
$log = new CoreLibs\Debug\Logging([
|
||||||
|
'log_folder' => BASE . LOG,
|
||||||
|
'file_id' => $LOG_FILE_ID,
|
||||||
|
// add file date
|
||||||
|
'print_file_date' => true,
|
||||||
|
// set debug and print flags
|
||||||
|
'debug_all' => $DEBUG_ALL ?? false,
|
||||||
|
'echo_all' => $ECHO_ALL ?? false,
|
||||||
|
'print_all' => $PRINT_ALL ?? false,
|
||||||
|
]);
|
||||||
|
$basic = new CoreLibs\Basic($log);
|
||||||
$color_class = 'CoreLibs\Convert\Colors';
|
$color_class = 'CoreLibs\Convert\Colors';
|
||||||
|
|
||||||
print "<html><head><title>TEST CLASS: COLORS</title><head>";
|
print "<html><head><title>TEST CLASS: COLORS</title><head>";
|
||||||
@@ -70,7 +80,7 @@ print "S::COLOR hsb->rgb: $hsb[0], $hsb[1], $hsb[2]: "
|
|||||||
// TODO: run compare check input must match output
|
// TODO: run compare check input must match output
|
||||||
|
|
||||||
// error message
|
// error message
|
||||||
print $basic->log->printErrorMsg();
|
print $log->printErrorMsg();
|
||||||
|
|
||||||
print "</body></html>";
|
print "</body></html>";
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,17 @@ ob_end_flush();
|
|||||||
use CoreLibs\Combined\DateTime;
|
use CoreLibs\Combined\DateTime;
|
||||||
use CoreLibs\Debug\Support as DgS;
|
use CoreLibs\Debug\Support as DgS;
|
||||||
|
|
||||||
$basic = new CoreLibs\Basic();
|
$log = new CoreLibs\Debug\Logging([
|
||||||
|
'log_folder' => BASE . LOG,
|
||||||
|
'file_id' => $LOG_FILE_ID,
|
||||||
|
// add file date
|
||||||
|
'print_file_date' => true,
|
||||||
|
// set debug and print flags
|
||||||
|
'debug_all' => $DEBUG_ALL ?? false,
|
||||||
|
'echo_all' => $ECHO_ALL ?? false,
|
||||||
|
'print_all' => $PRINT_ALL ?? false,
|
||||||
|
]);
|
||||||
|
$basic = new CoreLibs\Basic($log);
|
||||||
$datetime_class = 'CoreLibs\Combined\DateTime';
|
$datetime_class = 'CoreLibs\Combined\DateTime';
|
||||||
|
|
||||||
print "<html><head><title>TEST CLASS: DATE/TIME</title><head>";
|
print "<html><head><title>TEST CLASS: DATE/TIME</title><head>";
|
||||||
@@ -152,7 +162,7 @@ print "CALCDAYSINTERVAL(named): $compare_date[0] = $compare_date[1]: "
|
|||||||
. DgS::printAr($basic->calcDaysInterval($compare_date[0], $compare_date[1], true))."<br>"; */
|
. DgS::printAr($basic->calcDaysInterval($compare_date[0], $compare_date[1], true))."<br>"; */
|
||||||
|
|
||||||
// error message
|
// error message
|
||||||
print $basic->log->printErrorMsg();
|
print $log->printErrorMsg();
|
||||||
|
|
||||||
print "</body></html>";
|
print "</body></html>";
|
||||||
|
|
||||||
|
|||||||
@@ -32,8 +32,20 @@ $LOG_FILE_ID = 'classTest-db';
|
|||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
|
|
||||||
use CoreLibs\Debug\Support as DgS;
|
use CoreLibs\Debug\Support as DgS;
|
||||||
|
use CoreLibs\DB\IO as DbIo;
|
||||||
|
|
||||||
$db = $basic = new CoreLibs\Admin\Backend(DB_CONFIG);
|
$log = new CoreLibs\Debug\Logging([
|
||||||
|
'log_folder' => BASE . LOG,
|
||||||
|
'file_id' => $LOG_FILE_ID,
|
||||||
|
// add file date
|
||||||
|
'print_file_date' => true,
|
||||||
|
// set debug and print flags
|
||||||
|
'debug_all' => $DEBUG_ALL ?? false,
|
||||||
|
'echo_all' => $ECHO_ALL ?? false,
|
||||||
|
'print_all' => $PRINT_ALL ?? false,
|
||||||
|
]);
|
||||||
|
$basic = new CoreLibs\Basic($log);
|
||||||
|
$db = new CoreLibs\Admin\Backend(DB_CONFIG, $log);
|
||||||
|
|
||||||
// NEXT STEP
|
// NEXT STEP
|
||||||
// $basic = new CoreLibs\Basic();
|
// $basic = new CoreLibs\Basic();
|
||||||
@@ -46,13 +58,15 @@ print "<html><head><title>TEST CLASS: DB</title><head>";
|
|||||||
print "<body>";
|
print "<body>";
|
||||||
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||||
|
|
||||||
|
print "LOGFILE NAME: " . $db->log->getSetting('log_file_name') . "<br>";
|
||||||
|
print "LOGFILE ID: " . $db->log->getSetting('log_file_id') . "<br>";
|
||||||
print "DBINFO: " . $db->dbInfo() . "<br>";
|
print "DBINFO: " . $db->dbInfo() . "<br>";
|
||||||
echo "DB_CONFIG_SET constant: <pre>" . print_r(DB_CONFIG, true) . "</pre><br>";
|
echo "DB_CONFIG_SET constant: <pre>" . print_r(DB_CONFIG, true) . "</pre><br>";
|
||||||
|
|
||||||
// DB client encoding
|
// DB client encoding
|
||||||
print "DB Client encoding: " . $db->dbGetEncoding() . "<br>";
|
print "DB Client encoding: " . $db->dbGetEncoding() . "<br>";
|
||||||
|
|
||||||
while (is_array($res = $db->dbReturn("SELECT * FROM max_test", 0, true))) {
|
while (is_array($res = $db->dbReturn("SELECT * FROM max_test", DbIo::USE_CACHE, true))) {
|
||||||
print "TIME: " . $res['time'] . "<br>";
|
print "TIME: " . $res['time'] . "<br>";
|
||||||
}
|
}
|
||||||
print "CACHED DATA: <pre>" . print_r($db->cursor_ext, true) . "</pre><br>";
|
print "CACHED DATA: <pre>" . print_r($db->cursor_ext, true) . "</pre><br>";
|
||||||
@@ -324,7 +338,7 @@ print "ISSET: " . isset($res['null_varchar']) . "<br>";
|
|||||||
print "EMPTY: " . empty($res['null_varchar']) . "<br>";
|
print "EMPTY: " . empty($res['null_varchar']) . "<br>";
|
||||||
|
|
||||||
// error message
|
// error message
|
||||||
print $basic->log->printErrorMsg();
|
print $log->printErrorMsg();
|
||||||
|
|
||||||
print "</body></html>";
|
print "</body></html>";
|
||||||
|
|
||||||
|
|||||||
@@ -63,6 +63,31 @@ print "C->DEBUG: " . $debug->debug('CLASS-TEST-DEBUG', 'Class Test Debug') . "<b
|
|||||||
print "C->DEBUG(html): " . $debug->debug('CLASS-TEST-DEBUG', 'HTML TAG<br><b>BOLD</b>') . "<br>";
|
print "C->DEBUG(html): " . $debug->debug('CLASS-TEST-DEBUG', 'HTML TAG<br><b>BOLD</b>') . "<br>";
|
||||||
print "C->DEBUG(html,strip): " . $debug->debug('CLASS-TEST-DEBUG', 'HTML TAG<br><b>BOLD</b>', true) . "<br>";
|
print "C->DEBUG(html,strip): " . $debug->debug('CLASS-TEST-DEBUG', 'HTML TAG<br><b>BOLD</b>', true) . "<br>";
|
||||||
print "C->PRINTERRORMSG: <br>" . $debug->printErrorMsg() . "<br>";
|
print "C->PRINTERRORMSG: <br>" . $debug->printErrorMsg() . "<br>";
|
||||||
|
|
||||||
|
echo "<b>OPTIONS DEBUG CALL</b><br>";
|
||||||
|
|
||||||
|
// new log type with options
|
||||||
|
$new_log = new CoreLibs\Debug\Logging([
|
||||||
|
'log_folder' => '../log/',
|
||||||
|
'file_id' => 'DebugTestNewLogger',
|
||||||
|
// add file date
|
||||||
|
'print_file_date' => true,
|
||||||
|
// split into level (debug code)
|
||||||
|
'per_level' => false,
|
||||||
|
// per class called
|
||||||
|
'per_class' => false,
|
||||||
|
// per page
|
||||||
|
'per_page' => false,
|
||||||
|
// for each page call
|
||||||
|
'per_run' => false,
|
||||||
|
// set debug and print flags
|
||||||
|
'debug_all' => true,
|
||||||
|
'echo_all' => true,
|
||||||
|
'print_all' => true,
|
||||||
|
]);
|
||||||
|
$new_log->debug('OPTIONS TYPE', 'New Type error');
|
||||||
|
print "OPTIONS LOGGER:<br>" . $new_log->printErrorMsg();
|
||||||
|
|
||||||
echo "<b>CLASS DEBUG CALL</b><br>";
|
echo "<b>CLASS DEBUG CALL</b><br>";
|
||||||
|
|
||||||
// @codingStandardsIgnoreLine
|
// @codingStandardsIgnoreLine
|
||||||
|
|||||||
@@ -32,7 +32,17 @@ ob_end_flush();
|
|||||||
use CoreLibs\Check\Email;
|
use CoreLibs\Check\Email;
|
||||||
use CoreLibs\Debug\Support as DgS;
|
use CoreLibs\Debug\Support as DgS;
|
||||||
|
|
||||||
$basic = new CoreLibs\Basic();
|
$log = new CoreLibs\Debug\Logging([
|
||||||
|
'log_folder' => BASE . LOG,
|
||||||
|
'file_id' => $LOG_FILE_ID,
|
||||||
|
// add file date
|
||||||
|
'print_file_date' => true,
|
||||||
|
// set debug and print flags
|
||||||
|
'debug_all' => $DEBUG_ALL ?? false,
|
||||||
|
'echo_all' => $ECHO_ALL ?? false,
|
||||||
|
'print_all' => $PRINT_ALL ?? false,
|
||||||
|
]);
|
||||||
|
$basic = new CoreLibs\Basic($log);
|
||||||
|
|
||||||
print "<html><head><title>TEST CLASS: HTML/ELEMENTS</title><head>";
|
print "<html><head><title>TEST CLASS: HTML/ELEMENTS</title><head>";
|
||||||
print "<body>";
|
print "<body>";
|
||||||
@@ -78,7 +88,7 @@ foreach ($email as $s_email) {
|
|||||||
} */
|
} */
|
||||||
|
|
||||||
// error message
|
// error message
|
||||||
print $basic->log->printErrorMsg();
|
print $log->printErrorMsg();
|
||||||
|
|
||||||
print "</body></html>";
|
print "</body></html>";
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,17 @@ ob_end_flush();
|
|||||||
|
|
||||||
use CoreLibs\Language\Encoding;
|
use CoreLibs\Language\Encoding;
|
||||||
|
|
||||||
$basic = new CoreLibs\Basic();
|
$log = new CoreLibs\Debug\Logging([
|
||||||
|
'log_folder' => BASE . LOG,
|
||||||
|
'file_id' => $LOG_FILE_ID,
|
||||||
|
// add file date
|
||||||
|
'print_file_date' => true,
|
||||||
|
// set debug and print flags
|
||||||
|
'debug_all' => $DEBUG_ALL ?? false,
|
||||||
|
'echo_all' => $ECHO_ALL ?? false,
|
||||||
|
'print_all' => $PRINT_ALL ?? false,
|
||||||
|
]);
|
||||||
|
$basic = new CoreLibs\Basic($log);
|
||||||
$_encoding = new CoreLibs\Language\Encoding();
|
$_encoding = new CoreLibs\Language\Encoding();
|
||||||
$encoding_class = 'CoreLibs\Language\Encoding';
|
$encoding_class = 'CoreLibs\Language\Encoding';
|
||||||
|
|
||||||
@@ -93,7 +103,7 @@ print "CONV ENCODING: $_string: ".$basic->convertEncoding($_string, 'ISO-2022-JP
|
|||||||
print "D/__MBMIMEENCODE: ".$basic->__mbMimeEncode('Some Text', 'UTF-8')."<br>"; */
|
print "D/__MBMIMEENCODE: ".$basic->__mbMimeEncode('Some Text', 'UTF-8')."<br>"; */
|
||||||
|
|
||||||
// error message
|
// error message
|
||||||
print $basic->log->printErrorMsg();
|
print $basic->printErrorMsg();
|
||||||
|
|
||||||
print "</body></html>";
|
print "</body></html>";
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,17 @@ ob_end_flush();
|
|||||||
|
|
||||||
use CoreLibs\Check\File;
|
use CoreLibs\Check\File;
|
||||||
|
|
||||||
$basic = new CoreLibs\Basic();
|
$log = new CoreLibs\Debug\Logging([
|
||||||
|
'log_folder' => BASE . LOG,
|
||||||
|
'file_id' => $LOG_FILE_ID,
|
||||||
|
// add file date
|
||||||
|
'print_file_date' => true,
|
||||||
|
// set debug and print flags
|
||||||
|
'debug_all' => $DEBUG_ALL ?? false,
|
||||||
|
'echo_all' => $ECHO_ALL ?? false,
|
||||||
|
'print_all' => $PRINT_ALL ?? false,
|
||||||
|
]);
|
||||||
|
$basic = new CoreLibs\Basic($log);
|
||||||
|
|
||||||
print "<html><head><title>TEST CLASS: FILE</title><head>";
|
print "<html><head><title>TEST CLASS: FILE</title><head>";
|
||||||
print "<body>";
|
print "<body>";
|
||||||
@@ -43,7 +53,7 @@ $file = getcwd() . DIRECTORY_SEPARATOR . 'class_test.file.php';
|
|||||||
print "GETLINESFROMFILE: $file: " . File::getLinesFromFile($file) . "<br>";
|
print "GETLINESFROMFILE: $file: " . File::getLinesFromFile($file) . "<br>";
|
||||||
|
|
||||||
// error message
|
// error message
|
||||||
print $basic->log->printErrorMsg();
|
print $log->printErrorMsg();
|
||||||
|
|
||||||
print "</body></html>";
|
print "</body></html>";
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,17 @@ ob_end_flush();
|
|||||||
|
|
||||||
use CoreLibs\Create\Hash;
|
use CoreLibs\Create\Hash;
|
||||||
|
|
||||||
$basic = new CoreLibs\Basic();
|
$log = new CoreLibs\Debug\Logging([
|
||||||
|
'log_folder' => BASE . LOG,
|
||||||
|
'file_id' => $LOG_FILE_ID,
|
||||||
|
// add file date
|
||||||
|
'print_file_date' => true,
|
||||||
|
// set debug and print flags
|
||||||
|
'debug_all' => $DEBUG_ALL ?? false,
|
||||||
|
'echo_all' => $ECHO_ALL ?? false,
|
||||||
|
'print_all' => $PRINT_ALL ?? false,
|
||||||
|
]);
|
||||||
|
$basic = new CoreLibs\Basic($log);
|
||||||
$hash_class = 'CoreLibs\Create\Hash';
|
$hash_class = 'CoreLibs\Create\Hash';
|
||||||
|
|
||||||
// define a list of from to color sets for conversion test
|
// define a list of from to color sets for conversion test
|
||||||
@@ -58,7 +68,7 @@ print "D/__SHA1SHORT(off): $to_crc: ".$basic->__sha1short($to_crc)."<br>";
|
|||||||
print "D/__hash(d): $to_crc: ".$basic->__hash($to_crc)."<br>"; */
|
print "D/__hash(d): $to_crc: ".$basic->__hash($to_crc)."<br>"; */
|
||||||
|
|
||||||
// error message
|
// error message
|
||||||
print $basic->log->printErrorMsg();
|
print $log->printErrorMsg();
|
||||||
|
|
||||||
print "</body></html>";
|
print "</body></html>";
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,17 @@ ob_end_flush();
|
|||||||
use CoreLibs\Convert\Html;
|
use CoreLibs\Convert\Html;
|
||||||
use CoreLibs\Output\Form\Elements;
|
use CoreLibs\Output\Form\Elements;
|
||||||
|
|
||||||
$basic = new CoreLibs\Basic();
|
$log = new CoreLibs\Debug\Logging([
|
||||||
|
'log_folder' => BASE . LOG,
|
||||||
|
'file_id' => $LOG_FILE_ID,
|
||||||
|
// add file date
|
||||||
|
'print_file_date' => true,
|
||||||
|
// set debug and print flags
|
||||||
|
'debug_all' => $DEBUG_ALL ?? false,
|
||||||
|
'echo_all' => $ECHO_ALL ?? false,
|
||||||
|
'print_all' => $PRINT_ALL ?? false,
|
||||||
|
]);
|
||||||
|
$basic = new CoreLibs\Basic($log);
|
||||||
$_html = new CoreLibs\Convert\Html();
|
$_html = new CoreLibs\Convert\Html();
|
||||||
$_elements = new CoreLibs\Output\Form\Elements();
|
$_elements = new CoreLibs\Output\Form\Elements();
|
||||||
$html_class = 'CoreLibs\Convert\Html';
|
$html_class = 'CoreLibs\Convert\Html';
|
||||||
@@ -109,7 +119,7 @@ print "LB remove: " . \CoreLibs\Convert\Html::removeLB($text) . "<br>";
|
|||||||
print "LB remove: " . \CoreLibs\Convert\Html::removeLB($text, '##BR##') . "<br>";
|
print "LB remove: " . \CoreLibs\Convert\Html::removeLB($text, '##BR##') . "<br>";
|
||||||
|
|
||||||
// error message
|
// error message
|
||||||
print $basic->log->printErrorMsg();
|
print $log->printErrorMsg();
|
||||||
|
|
||||||
print "</body></html>";
|
print "</body></html>";
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,17 @@ ob_end_flush();
|
|||||||
|
|
||||||
use CoreLibs\Output\Image;
|
use CoreLibs\Output\Image;
|
||||||
|
|
||||||
$basic = new CoreLibs\Basic();
|
$log = new CoreLibs\Debug\Logging([
|
||||||
|
'log_folder' => BASE . LOG,
|
||||||
|
'file_id' => $LOG_FILE_ID,
|
||||||
|
// add file date
|
||||||
|
'print_file_date' => true,
|
||||||
|
// set debug and print flags
|
||||||
|
'debug_all' => $DEBUG_ALL ?? false,
|
||||||
|
'echo_all' => $ECHO_ALL ?? false,
|
||||||
|
'print_all' => $PRINT_ALL ?? false,
|
||||||
|
]);
|
||||||
|
$basic = new CoreLibs\Basic($log);
|
||||||
$_image = new CoreLibs\Output\Image();
|
$_image = new CoreLibs\Output\Image();
|
||||||
$image_class = 'CoreLibs\Output\Image';
|
$image_class = 'CoreLibs\Output\Image';
|
||||||
|
|
||||||
@@ -112,7 +122,7 @@ echo "<div>S::CREATETHUMBNAILSIMPLE: ".basename($image).": WIDTH: $thumb_width<b
|
|||||||
. $basic->createThumbnailSimple($image, $thumb_width)."></div>"; */
|
. $basic->createThumbnailSimple($image, $thumb_width)."></div>"; */
|
||||||
|
|
||||||
// error message
|
// error message
|
||||||
print $basic->log->printErrorMsg();
|
print $log->printErrorMsg();
|
||||||
|
|
||||||
print "</body></html>";
|
print "</body></html>";
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,17 @@ ob_end_flush();
|
|||||||
use CoreLibs\Convert\Json;
|
use CoreLibs\Convert\Json;
|
||||||
use CoreLibs\Debug\Support as DgS;
|
use CoreLibs\Debug\Support as DgS;
|
||||||
|
|
||||||
$basic = new CoreLibs\Basic();
|
$log = new CoreLibs\Debug\Logging([
|
||||||
|
'log_folder' => BASE . LOG,
|
||||||
|
'file_id' => $LOG_FILE_ID,
|
||||||
|
// add file date
|
||||||
|
'print_file_date' => true,
|
||||||
|
// set debug and print flags
|
||||||
|
'debug_all' => $DEBUG_ALL ?? false,
|
||||||
|
'echo_all' => $ECHO_ALL ?? false,
|
||||||
|
'print_all' => $PRINT_ALL ?? false,
|
||||||
|
]);
|
||||||
|
$basic = new CoreLibs\Basic($log);
|
||||||
$json_class = 'CoreLibs\Convert\Json';
|
$json_class = 'CoreLibs\Convert\Json';
|
||||||
|
|
||||||
// define a list of from to color sets for conversion test
|
// define a list of from to color sets for conversion test
|
||||||
@@ -74,7 +84,7 @@ print "E-JSON ERROR: ".$basic->jsonGetLastError().": ".$basic->jsonGetLastError(
|
|||||||
// print "S::JSON ERROR: " . Jason::jsonGetLastError() . ": " . Jason::jsonGetLastError(true) . "<br>";
|
// print "S::JSON ERROR: " . Jason::jsonGetLastError() . ": " . Jason::jsonGetLastError(true) . "<br>";
|
||||||
|
|
||||||
// error message
|
// error message
|
||||||
print $basic->log->printErrorMsg();
|
print $log->printErrorMsg();
|
||||||
|
|
||||||
print "</body></html>";
|
print "</body></html>";
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,17 @@ if (!defined('SET_SESSION_NAME')) {
|
|||||||
$LOG_FILE_ID = 'classTest-math';
|
$LOG_FILE_ID = 'classTest-math';
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
|
|
||||||
$basic = new CoreLibs\Basic();
|
$log = new CoreLibs\Debug\Logging([
|
||||||
|
'log_folder' => BASE . LOG,
|
||||||
|
'file_id' => $LOG_FILE_ID,
|
||||||
|
// add file date
|
||||||
|
'print_file_date' => true,
|
||||||
|
// set debug and print flags
|
||||||
|
'debug_all' => $DEBUG_ALL ?? false,
|
||||||
|
'echo_all' => $ECHO_ALL ?? false,
|
||||||
|
'print_all' => $PRINT_ALL ?? false,
|
||||||
|
]);
|
||||||
|
$basic = new CoreLibs\Basic($log);
|
||||||
$_math = new CoreLibs\Convert\Math();
|
$_math = new CoreLibs\Convert\Math();
|
||||||
$math_class = 'CoreLibs\Convert\Math';
|
$math_class = 'CoreLibs\Convert\Math';
|
||||||
|
|
||||||
@@ -57,7 +67,7 @@ print "FLOORP: ".$basic->floorp(5123456, -3)."<br>";
|
|||||||
print "INITNUMERIC: ".$basic->initNumeric('123')."<br>"; */
|
print "INITNUMERIC: ".$basic->initNumeric('123')."<br>"; */
|
||||||
|
|
||||||
// error message
|
// error message
|
||||||
print $basic->log->printErrorMsg();
|
print $log->printErrorMsg();
|
||||||
|
|
||||||
print "</body></html>";
|
print "</body></html>";
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,17 @@ if (!defined('SET_SESSION_NAME')) {
|
|||||||
$LOG_FILE_ID = 'classTest-mime';
|
$LOG_FILE_ID = 'classTest-mime';
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
|
|
||||||
$basic = new CoreLibs\Basic();
|
$log = new CoreLibs\Debug\Logging([
|
||||||
|
'log_folder' => BASE . LOG,
|
||||||
|
'file_id' => $LOG_FILE_ID,
|
||||||
|
// add file date
|
||||||
|
'print_file_date' => true,
|
||||||
|
// set debug and print flags
|
||||||
|
'debug_all' => $DEBUG_ALL ?? false,
|
||||||
|
'echo_all' => $ECHO_ALL ?? false,
|
||||||
|
'print_all' => $PRINT_ALL ?? false,
|
||||||
|
]);
|
||||||
|
$basic = new CoreLibs\Basic($log);
|
||||||
$_mime = new CoreLibs\Convert\MimeAppName();
|
$_mime = new CoreLibs\Convert\MimeAppName();
|
||||||
|
|
||||||
print "<html><head><title>TEST CLASS: MIME</title><head>";
|
print "<html><head><title>TEST CLASS: MIME</title><head>";
|
||||||
@@ -61,7 +71,7 @@ $mime = 'fake/mime';
|
|||||||
$basic->mimeSetAppName($mime, 'This is a fake mime');
|
$basic->mimeSetAppName($mime, 'This is a fake mime');
|
||||||
print "MIME $mime: ".$basic->mimeGetAppName($mime)."<br>"; */
|
print "MIME $mime: ".$basic->mimeGetAppName($mime)."<br>"; */
|
||||||
|
|
||||||
print $basic->log->printErrorMsg();
|
print $log->printErrorMsg();
|
||||||
|
|
||||||
print "</body></html>";
|
print "</body></html>";
|
||||||
|
|
||||||
|
|||||||
@@ -57,8 +57,18 @@ $table_arrays[\CoreLibs\Get\System::getPageName(1)] = [
|
|||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
$basic = new CoreLibs\Basic();
|
$log = new CoreLibs\Debug\Logging([
|
||||||
$form = new CoreLibs\Output\Form\Generate(DB_CONFIG);
|
'log_folder' => BASE . LOG,
|
||||||
|
'file_id' => $LOG_FILE_ID,
|
||||||
|
// add file date
|
||||||
|
'print_file_date' => true,
|
||||||
|
// set debug and print flags
|
||||||
|
'debug_all' => $DEBUG_ALL ?? false,
|
||||||
|
'echo_all' => $ECHO_ALL ?? false,
|
||||||
|
'print_all' => $PRINT_ALL ?? false,
|
||||||
|
]);
|
||||||
|
$basic = new CoreLibs\Basic($log);
|
||||||
|
$form = new CoreLibs\Output\Form\Generate(DB_CONFIG, $log);
|
||||||
// $db = new CoreLibs\DB\IO(DB_CONFIG, $basic->log);
|
// $db = new CoreLibs\DB\IO(DB_CONFIG, $basic->log);
|
||||||
|
|
||||||
print "<html><head><title>TEST CLASS: FORM GENERATE</title><head>";
|
print "<html><head><title>TEST CLASS: FORM GENERATE</title><head>";
|
||||||
@@ -70,7 +80,7 @@ print "MOBILE PHONE: " . $form->mobile_phone . "<br>";
|
|||||||
print "MY PAGE NAME: " . $form->my_page_name . "<br>";
|
print "MY PAGE NAME: " . $form->my_page_name . "<br>";
|
||||||
|
|
||||||
// error message
|
// error message
|
||||||
print $basic->log->printErrorMsg();
|
print $log->printErrorMsg();
|
||||||
|
|
||||||
print "</body></html>";
|
print "</body></html>";
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,17 @@ ob_end_flush();
|
|||||||
|
|
||||||
use CoreLibs\Check\Password as PwdChk;
|
use CoreLibs\Check\Password as PwdChk;
|
||||||
|
|
||||||
$basic = new CoreLibs\Basic();
|
$log = new CoreLibs\Debug\Logging([
|
||||||
|
'log_folder' => BASE . LOG,
|
||||||
|
'file_id' => $LOG_FILE_ID,
|
||||||
|
// add file date
|
||||||
|
'print_file_date' => true,
|
||||||
|
// set debug and print flags
|
||||||
|
'debug_all' => $DEBUG_ALL ?? false,
|
||||||
|
'echo_all' => $ECHO_ALL ?? false,
|
||||||
|
'print_all' => $PRINT_ALL ?? false,
|
||||||
|
]);
|
||||||
|
$basic = new CoreLibs\Basic($log);
|
||||||
$_password = new CoreLibs\Check\Password();
|
$_password = new CoreLibs\Check\Password();
|
||||||
$password_class = 'CoreLibs\Check\Password';
|
$password_class = 'CoreLibs\Check\Password';
|
||||||
|
|
||||||
@@ -63,7 +73,7 @@ print "PASSWORD VERIFY: ".(string)$basic->passwordVerify($password, $enc_passwor
|
|||||||
print "PASSWORD REHASH: ".(string)$basic->passwordRehashCheck($enc_password)."<br>"; */
|
print "PASSWORD REHASH: ".(string)$basic->passwordRehashCheck($enc_password)."<br>"; */
|
||||||
|
|
||||||
// error message
|
// error message
|
||||||
print $basic->log->printErrorMsg();
|
print $log->printErrorMsg();
|
||||||
|
|
||||||
print "</body></html>";
|
print "</body></html>";
|
||||||
|
|
||||||
|
|||||||
@@ -29,8 +29,18 @@ if (!defined('SET_SESSION_NAME')) {
|
|||||||
$LOG_FILE_ID = 'classTest';
|
$LOG_FILE_ID = 'classTest';
|
||||||
|
|
||||||
// init login & backend class
|
// init login & backend class
|
||||||
$login = new CoreLibs\ACL\Login(DB_CONFIG);
|
$log = new CoreLibs\Debug\Logging([
|
||||||
$basic = new CoreLibs\Admin\Backend(DB_CONFIG);
|
'log_folder' => BASE . LOG,
|
||||||
|
'file_id' => $LOG_FILE_ID,
|
||||||
|
// add file date
|
||||||
|
'print_file_date' => true,
|
||||||
|
// set debug and print flags
|
||||||
|
'debug_all' => $DEBUG_ALL ?? false,
|
||||||
|
'echo_all' => $ECHO_ALL ?? false,
|
||||||
|
'print_all' => $PRINT_ALL ?? false,
|
||||||
|
]);
|
||||||
|
$login = new CoreLibs\ACL\Login(DB_CONFIG, $log);
|
||||||
|
$basic = new CoreLibs\Admin\Backend(DB_CONFIG, $log);
|
||||||
$basic->dbInfo(true);
|
$basic->dbInfo(true);
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
|
|
||||||
@@ -103,13 +113,13 @@ foreach (['debug', 'echo', 'print'] as $type) {
|
|||||||
print strtoupper($type) . ' OUT ALL: ' . $basic->log->getLogLevelAll($type) . '<br>';
|
print strtoupper($type) . ' OUT ALL: ' . $basic->log->getLogLevelAll($type) . '<br>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$basic->log->debug('SOME MARK', 'Some error output');
|
$log->debug('SOME MARK', 'Some error output');
|
||||||
|
|
||||||
// INTERNAL SET
|
// INTERNAL SET
|
||||||
print "EDIT ACCESS ID: " . $basic->edit_access_id . "<br>";
|
print "EDIT ACCESS ID: " . $basic->edit_access_id . "<br>";
|
||||||
if (is_object($login)) {
|
if (is_object($login)) {
|
||||||
// print "ACL: <br>".$basic->print_ar($login->acl)."<br>";
|
// print "ACL: <br>".$basic->print_ar($login->acl)."<br>";
|
||||||
$basic->log->debug('ACL', "ACL: " . \CoreLibs\Debug\Support::printAr($login->acl));
|
$log->debug('ACL', "ACL: " . \CoreLibs\Debug\Support::printAr($login->acl));
|
||||||
// print "DEFAULT ACL: <br>".$basic->print_ar($login->default_acl_list)."<br>";
|
// print "DEFAULT ACL: <br>".$basic->print_ar($login->default_acl_list)."<br>";
|
||||||
// print "DEFAULT ACL: <br>".$basic->print_ar($login->default_acl_list)."<br>";
|
// print "DEFAULT ACL: <br>".$basic->print_ar($login->default_acl_list)."<br>";
|
||||||
// $result = array_flip(
|
// $result = array_flip(
|
||||||
@@ -140,7 +150,7 @@ print "SERVER HOST: " . $_SERVER['HTTP_HOST'] . "<br>";
|
|||||||
|
|
||||||
// print error messages
|
// print error messages
|
||||||
// print $login->log->printErrorMsg();
|
// print $login->log->printErrorMsg();
|
||||||
print $basic->log->printErrorMsg();
|
print $log->printErrorMsg();
|
||||||
|
|
||||||
print "</body></html>";
|
print "</body></html>";
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,17 @@ ob_end_flush();
|
|||||||
|
|
||||||
use CoreLibs\Check\PhpVersion;
|
use CoreLibs\Check\PhpVersion;
|
||||||
|
|
||||||
$basic = new CoreLibs\Basic();
|
$log = new CoreLibs\Debug\Logging([
|
||||||
|
'log_folder' => BASE . LOG,
|
||||||
|
'file_id' => $LOG_FILE_ID,
|
||||||
|
// add file date
|
||||||
|
'print_file_date' => true,
|
||||||
|
// set debug and print flags
|
||||||
|
'debug_all' => $DEBUG_ALL ?? false,
|
||||||
|
'echo_all' => $ECHO_ALL ?? false,
|
||||||
|
'print_all' => $PRINT_ALL ?? false,
|
||||||
|
]);
|
||||||
|
$basic = new CoreLibs\Basic($log);
|
||||||
$_phpv = new CoreLibs\Check\PhpVersion();
|
$_phpv = new CoreLibs\Check\PhpVersion();
|
||||||
$phpv_class = 'CoreLibs\Check\PhpVersion';
|
$phpv_class = 'CoreLibs\Check\PhpVersion';
|
||||||
|
|
||||||
@@ -63,7 +73,7 @@ print "U-S::MIN: $min_version: " . (string)PhpVersion::checkPHPVersion($min_vers
|
|||||||
// print "MIN: $min_version: ".(string)$basic->checkPHPVersion($min_version)."<br>";
|
// print "MIN: $min_version: ".(string)$basic->checkPHPVersion($min_version)."<br>";
|
||||||
|
|
||||||
// error message
|
// error message
|
||||||
print $basic->log->printErrorMsg();
|
print $log->printErrorMsg();
|
||||||
|
|
||||||
print "</body></html>";
|
print "</body></html>";
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,17 @@ ob_end_flush();
|
|||||||
|
|
||||||
use CoreLibs\Create\RandomKey;
|
use CoreLibs\Create\RandomKey;
|
||||||
|
|
||||||
$basic = new CoreLibs\Basic();
|
$log = new CoreLibs\Debug\Logging([
|
||||||
|
'log_folder' => BASE . LOG,
|
||||||
|
'file_id' => $LOG_FILE_ID,
|
||||||
|
// add file date
|
||||||
|
'print_file_date' => true,
|
||||||
|
// set debug and print flags
|
||||||
|
'debug_all' => $DEBUG_ALL ?? false,
|
||||||
|
'echo_all' => $ECHO_ALL ?? false,
|
||||||
|
'print_all' => $PRINT_ALL ?? false,
|
||||||
|
]);
|
||||||
|
$basic = new CoreLibs\Basic($log);
|
||||||
$array_class = 'CoreLibs\Create\RandomKey';
|
$array_class = 'CoreLibs\Create\RandomKey';
|
||||||
|
|
||||||
print "<html><head><title>TEST CLASS: RANDOM KEY</title><head>";
|
print "<html><head><title>TEST CLASS: RANDOM KEY</title><head>";
|
||||||
@@ -51,7 +61,7 @@ print "C->RANDOMKEYGEN(auto): " . $_array->randomKeyGen() . "<br>";
|
|||||||
// print "D\RANDOMKEYGEN(auto): ".$basic->randomKeyGen()."<br>";
|
// print "D\RANDOMKEYGEN(auto): ".$basic->randomKeyGen()."<br>";
|
||||||
|
|
||||||
// error message
|
// error message
|
||||||
print $basic->log->printErrorMsg();
|
print $log->printErrorMsg();
|
||||||
|
|
||||||
print "</body></html>";
|
print "</body></html>";
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,17 @@ ob_end_flush();
|
|||||||
|
|
||||||
use CoreLibs\Debug\RunningTime;
|
use CoreLibs\Debug\RunningTime;
|
||||||
|
|
||||||
$basic = new CoreLibs\Basic();
|
$log = new CoreLibs\Debug\Logging([
|
||||||
|
'log_folder' => BASE . LOG,
|
||||||
|
'file_id' => $LOG_FILE_ID,
|
||||||
|
// add file date
|
||||||
|
'print_file_date' => true,
|
||||||
|
// set debug and print flags
|
||||||
|
'debug_all' => $DEBUG_ALL ?? false,
|
||||||
|
'echo_all' => $ECHO_ALL ?? false,
|
||||||
|
'print_all' => $PRINT_ALL ?? false,
|
||||||
|
]);
|
||||||
|
$basic = new CoreLibs\Basic($log);
|
||||||
|
|
||||||
print "<html><head><title>TEST CLASS: RUNNING IMTE</title><head>";
|
print "<html><head><title>TEST CLASS: RUNNING IMTE</title><head>";
|
||||||
print "<body>";
|
print "<body>";
|
||||||
@@ -59,7 +69,7 @@ echo "RANDOM KEY [default]: ".$basic->randomKeyGen()."<br>";
|
|||||||
echo "TIMED [hr]: ".$basic->hrRunningTime()."<br>"; */
|
echo "TIMED [hr]: ".$basic->hrRunningTime()."<br>"; */
|
||||||
|
|
||||||
// error message
|
// error message
|
||||||
print $basic->log->printErrorMsg();
|
print $log->printErrorMsg();
|
||||||
|
|
||||||
print "</body></html>";
|
print "</body></html>";
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,17 @@ if (!defined('SET_SESSION_NAME')) {
|
|||||||
$LOG_FILE_ID = 'classTest-smarty';
|
$LOG_FILE_ID = 'classTest-smarty';
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
|
|
||||||
$basic = new CoreLibs\Basic();
|
$log = new CoreLibs\Debug\Logging([
|
||||||
|
'log_folder' => BASE . LOG,
|
||||||
|
'file_id' => $LOG_FILE_ID,
|
||||||
|
// add file date
|
||||||
|
'print_file_date' => true,
|
||||||
|
// set debug and print flags
|
||||||
|
'debug_all' => $DEBUG_ALL ?? false,
|
||||||
|
'echo_all' => $ECHO_ALL ?? false,
|
||||||
|
'print_all' => $PRINT_ALL ?? false,
|
||||||
|
]);
|
||||||
|
$basic = new CoreLibs\Basic($log);
|
||||||
$smarty = new CoreLibs\Template\SmartyExtend();
|
$smarty = new CoreLibs\Template\SmartyExtend();
|
||||||
// for testing with or without CMS
|
// for testing with or without CMS
|
||||||
// $cms = new CoreLibs\Admin\Backend(DB_CONFIG);
|
// $cms = new CoreLibs\Admin\Backend(DB_CONFIG);
|
||||||
@@ -90,7 +100,7 @@ $smarty->DATA['loop_start'] = 2;
|
|||||||
$smarty->setSmartyVarsAdmin();
|
$smarty->setSmartyVarsAdmin();
|
||||||
|
|
||||||
// error message
|
// error message
|
||||||
print $basic->log->printErrorMsg();
|
print $log->printErrorMsg();
|
||||||
|
|
||||||
print "</body></html>";
|
print "</body></html>";
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,17 @@ ob_end_flush();
|
|||||||
use CoreLibs\Get\System;
|
use CoreLibs\Get\System;
|
||||||
use CoreLibs\Debug\Support as DgS;
|
use CoreLibs\Debug\Support as DgS;
|
||||||
|
|
||||||
$basic = new CoreLibs\Basic();
|
$log = new CoreLibs\Debug\Logging([
|
||||||
|
'log_folder' => BASE . LOG,
|
||||||
|
'file_id' => $LOG_FILE_ID,
|
||||||
|
// add file date
|
||||||
|
'print_file_date' => true,
|
||||||
|
// set debug and print flags
|
||||||
|
'debug_all' => $DEBUG_ALL ?? false,
|
||||||
|
'echo_all' => $ECHO_ALL ?? false,
|
||||||
|
'print_all' => $PRINT_ALL ?? false,
|
||||||
|
]);
|
||||||
|
$basic = new CoreLibs\Basic($log);
|
||||||
|
|
||||||
print "<html><head><title>TEST CLASS: SYSTEM</title><head>";
|
print "<html><head><title>TEST CLASS: SYSTEM</title><head>";
|
||||||
print "<body>";
|
print "<body>";
|
||||||
@@ -49,6 +59,6 @@ print "FILEUPLOADERRORMESSAGE(UPLOAD_ERR_CANT_WRITE): "
|
|||||||
. System::fileUploadErrorMessage(UPLOAD_ERR_CANT_WRITE) . "<br>";
|
. System::fileUploadErrorMessage(UPLOAD_ERR_CANT_WRITE) . "<br>";
|
||||||
|
|
||||||
// error message
|
// error message
|
||||||
print $basic->log->printErrorMsg();
|
print $log->printErrorMsg();
|
||||||
|
|
||||||
print "</body></html>";
|
print "</body></html>";
|
||||||
|
|||||||
@@ -29,7 +29,17 @@ if (!defined('SET_SESSION_NAME')) {
|
|||||||
$LOG_FILE_ID = 'classTest-token';
|
$LOG_FILE_ID = 'classTest-token';
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
|
|
||||||
$basic = new CoreLibs\Basic();
|
$log = new CoreLibs\Debug\Logging([
|
||||||
|
'log_folder' => BASE . LOG,
|
||||||
|
'file_id' => $LOG_FILE_ID,
|
||||||
|
// add file date
|
||||||
|
'print_file_date' => true,
|
||||||
|
// set debug and print flags
|
||||||
|
'debug_all' => $DEBUG_ALL ?? false,
|
||||||
|
'echo_all' => $ECHO_ALL ?? false,
|
||||||
|
'print_all' => $PRINT_ALL ?? false,
|
||||||
|
]);
|
||||||
|
$basic = new CoreLibs\Basic($log);
|
||||||
$_token = new CoreLibs\Output\Form\Token();
|
$_token = new CoreLibs\Output\Form\Token();
|
||||||
$token_class = 'CoreLibs\Output\Form\Token';
|
$token_class = 'CoreLibs\Output\Form\Token';
|
||||||
|
|
||||||
@@ -54,7 +64,7 @@ print "TOKEN: $token: (ID) ".$token_id." => (S) ".$_SESSION[$token]."<br>";
|
|||||||
print "VALIDATE: $token: ".(string)$basic->validateFormToken($token_id, $token)."<br>"; */
|
print "VALIDATE: $token: ".(string)$basic->validateFormToken($token_id, $token)."<br>"; */
|
||||||
|
|
||||||
// error message
|
// error message
|
||||||
print $basic->log->printErrorMsg();
|
print $log->printErrorMsg();
|
||||||
|
|
||||||
print "</body></html>";
|
print "</body></html>";
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,17 @@ if (!defined('SET_SESSION_NAME')) {
|
|||||||
$LOG_FILE_ID = 'classTest-uids';
|
$LOG_FILE_ID = 'classTest-uids';
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
|
|
||||||
$basic = new CoreLibs\Basic();
|
$log = new CoreLibs\Debug\Logging([
|
||||||
|
'log_folder' => BASE . LOG,
|
||||||
|
'file_id' => $LOG_FILE_ID,
|
||||||
|
// add file date
|
||||||
|
'print_file_date' => true,
|
||||||
|
// set debug and print flags
|
||||||
|
'debug_all' => $DEBUG_ALL ?? false,
|
||||||
|
'echo_all' => $ECHO_ALL ?? false,
|
||||||
|
'print_all' => $PRINT_ALL ?? false,
|
||||||
|
]);
|
||||||
|
$basic = new CoreLibs\Basic($log);
|
||||||
$_uids = new CoreLibs\Create\Uids();
|
$_uids = new CoreLibs\Create\Uids();
|
||||||
$uids_class = 'CoreLibs\Create\Uids';
|
$uids_class = 'CoreLibs\Create\Uids';
|
||||||
|
|
||||||
@@ -52,7 +62,7 @@ print "S::UNIQID (sha256): " . $uids_class::uniqId('sha256') . "<br>";
|
|||||||
print "/DUNIQID (d): ".$basic->uniqId()."<br>"; */
|
print "/DUNIQID (d): ".$basic->uniqId()."<br>"; */
|
||||||
|
|
||||||
// error message
|
// error message
|
||||||
print $basic->log->printErrorMsg();
|
print $log->printErrorMsg();
|
||||||
|
|
||||||
print "</body></html>";
|
print "</body></html>";
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ $DB_CONFIG = [
|
|||||||
'db_schema' => 'public',
|
'db_schema' => 'public',
|
||||||
'db_type' => 'pgsql',
|
'db_type' => 'pgsql',
|
||||||
'db_encoding' => '',
|
'db_encoding' => '',
|
||||||
'db_ssl' => 'allow' // allow, disable, require, prefer
|
'db_ssl' => 'allow', // allow, disable, require, prefer
|
||||||
|
'db_debug' => true, // turn on logging or not
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -46,12 +46,33 @@ if ($AJAX_PAGE && !$ZIP_STREAM) {
|
|||||||
//------------------------------ basic variable settings start
|
//------------------------------ basic variable settings start
|
||||||
|
|
||||||
//------------------------------ class init start
|
//------------------------------ class init start
|
||||||
|
// create logger
|
||||||
|
$log = new CoreLibs\Debug\Logging([
|
||||||
|
'log_folder' => BASE . LOG,
|
||||||
|
'file_id' => LOG_FILE_ID,
|
||||||
|
'print_file_date' => true,
|
||||||
|
'per_class' => true,
|
||||||
|
'debug_all' => $DEBUG_ALL,
|
||||||
|
'echo_all' => $ECHO_ALL,
|
||||||
|
'print_all' => $PRINT_ALL,
|
||||||
|
]);
|
||||||
|
// automatic hide for DEBUG messages on live server
|
||||||
|
// can be overridden when setting DEBUG_ALL_OVERRIDE on top of the script
|
||||||
|
// (for emergency debugging of one page only)
|
||||||
|
if ((TARGET == 'live' || TARGET == 'remote') && !empty($DEBUG_ALL_OVERRIDE)) {
|
||||||
|
foreach (['debug', 'echo', 'print'] as $target) {
|
||||||
|
$log->setLogLevelAll($target, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// start session
|
||||||
|
CoreLibs\Create\Session::startSession();
|
||||||
// login & page access check
|
// login & page access check
|
||||||
$login = new CoreLibs\ACL\Login(DB_CONFIG);
|
$login = new CoreLibs\ACL\Login(DB_CONFIG, $log);
|
||||||
// create smarty object
|
// create smarty object
|
||||||
$smarty = new CoreLibs\Template\SmartyExtend();
|
$smarty = new CoreLibs\Template\SmartyExtend();
|
||||||
// create new DB class
|
// create new DB class
|
||||||
$cms = new CoreLibs\Admin\Backend(DB_CONFIG);
|
$log->setLogPer('class', false);
|
||||||
|
$cms = new CoreLibs\Admin\Backend(DB_CONFIG, $log);
|
||||||
// the menu show flag (what menu to show)
|
// the menu show flag (what menu to show)
|
||||||
$cms->menu_show_flag = 'main';
|
$cms->menu_show_flag = 'main';
|
||||||
// db nfo
|
// db nfo
|
||||||
@@ -65,12 +86,12 @@ ob_end_flush();
|
|||||||
//------------------------------ logging start
|
//------------------------------ logging start
|
||||||
// log backend data
|
// log backend data
|
||||||
// data part creation
|
// data part creation
|
||||||
$data = array(
|
$data = [
|
||||||
'_SESSION' => $_SESSION,
|
'_SESSION' => $_SESSION,
|
||||||
'_GET' => $_GET,
|
'_GET' => $_GET,
|
||||||
'_POST' => $_POST,
|
'_POST' => $_POST,
|
||||||
'_FILES' => $_FILES
|
'_FILES' => $_FILES
|
||||||
);
|
];
|
||||||
// log action
|
// log action
|
||||||
// no log if login
|
// no log if login
|
||||||
if (!$login->login) {
|
if (!$login->login) {
|
||||||
@@ -78,14 +99,7 @@ if (!$login->login) {
|
|||||||
}
|
}
|
||||||
//------------------------------ logging end
|
//------------------------------ logging end
|
||||||
|
|
||||||
// automatic hide for DEBUG messages on live server
|
// pass on DEBUG flag to JS via smarty variable
|
||||||
// can be overridden when setting DEBUG_ALL_OVERRIDE on top of the script (for emergency debugging of one page only)
|
|
||||||
if ((TARGET == 'live' || TARGET == 'remote') && !empty($DEBUG_ALL_OVERRIDE)) {
|
|
||||||
foreach (['debug', 'echo', 'print'] as $target) {
|
|
||||||
$login->log->setLogLevelAll($target, false);
|
|
||||||
$cms->log->setLogLevelAll($target, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$smarty->DATA['JS_DEBUG'] = DEBUG;
|
$smarty->DATA['JS_DEBUG'] = DEBUG;
|
||||||
|
|
||||||
// __END__
|
// __END__
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
$DEBUG_ALL = true;
|
$DEBUG_ALL = true;
|
||||||
$PRINT_ALL = true;
|
$PRINT_ALL = true;
|
||||||
|
$ECHO_ALL = false;
|
||||||
$DB_DEBUG = true;
|
$DB_DEBUG = true;
|
||||||
|
|
||||||
// TODO: only extract _POST data that is needed
|
// TODO: only extract _POST data that is needed
|
||||||
@@ -33,7 +34,7 @@ extract($_POST, EXTR_SKIP);
|
|||||||
ob_start();
|
ob_start();
|
||||||
require 'config.php';
|
require 'config.php';
|
||||||
// set session name here
|
// set session name here
|
||||||
$SET_SESSION_NAME = EDIT_SESSION_NAME;
|
// $SET_SESSION_NAME = EDIT_SESSION_NAME;
|
||||||
// overrride debug flags
|
// overrride debug flags
|
||||||
if (!DEBUG) {
|
if (!DEBUG) {
|
||||||
$DEBUG_ALL = false;
|
$DEBUG_ALL = false;
|
||||||
@@ -44,11 +45,26 @@ if (!DEBUG) {
|
|||||||
|
|
||||||
// should be utf8
|
// should be utf8
|
||||||
header("Content-type: text/html; charset=" . DEFAULT_ENCODING);
|
header("Content-type: text/html; charset=" . DEFAULT_ENCODING);
|
||||||
|
// set session
|
||||||
|
\CoreLibs\Create\Session::startSession(EDIT_SESSION_NAME);
|
||||||
|
// init logger
|
||||||
|
$log = new CoreLibs\Debug\Logging([
|
||||||
|
'log_folder' => BASE . LOG,
|
||||||
|
'file_id' => LOG_FILE_ID . 'EditBase',
|
||||||
|
'print_file_date' => true,
|
||||||
|
'per_class' => true,
|
||||||
|
'debug_all' => $DEBUG_ALL,
|
||||||
|
'echo_all' => $ECHO_ALL,
|
||||||
|
'print_all' => $PRINT_ALL,
|
||||||
|
]);
|
||||||
|
// login page
|
||||||
|
$login = new CoreLibs\ACL\Login(DB_CONFIG, $log);
|
||||||
|
// flush and start
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
$login = new CoreLibs\ACL\Login(DB_CONFIG);
|
// turn off set log per class
|
||||||
|
$log->setLogPer('class', false);
|
||||||
// create form class
|
// create form class
|
||||||
$form = new CoreLibs\Output\Form\Generate(DB_CONFIG);
|
$form = new CoreLibs\Output\Form\Generate(DB_CONFIG, $log);
|
||||||
if ($form->mobile_phone) {
|
if ($form->mobile_phone) {
|
||||||
echo "I am sorry, but this page cannot be viewed by a mobile phone";
|
echo "I am sorry, but this page cannot be viewed by a mobile phone";
|
||||||
exit;
|
exit;
|
||||||
|
|||||||
@@ -117,6 +117,8 @@ class Login extends \CoreLibs\DB\IO
|
|||||||
private $max_login_error_count = -1;
|
private $max_login_error_count = -1;
|
||||||
/** @var array<string> */
|
/** @var array<string> */
|
||||||
private $lock_deny_users = [];
|
private $lock_deny_users = [];
|
||||||
|
/** @var string */
|
||||||
|
private $page_name;
|
||||||
|
|
||||||
// if we have password change we need to define some rules
|
// if we have password change we need to define some rules
|
||||||
/** @var int */
|
/** @var int */
|
||||||
@@ -160,13 +162,20 @@ class Login extends \CoreLibs\DB\IO
|
|||||||
/**
|
/**
|
||||||
* constructor, does ALL, opens db, works through connection checks, closes itself
|
* constructor, does ALL, opens db, works through connection checks, closes itself
|
||||||
* @param array<mixed> $db_config db config array
|
* @param array<mixed> $db_config db config array
|
||||||
|
* @param \CoreLibs\Debug\Logging|null $log Logging class, if null, auto set
|
||||||
|
* @param \CoreLibs\Language\L10n|null $l10n l10n language class, if null, auto set
|
||||||
*/
|
*/
|
||||||
public function __construct(array $db_config)
|
public function __construct(
|
||||||
{
|
array $db_config,
|
||||||
|
?\CoreLibs\Debug\Logging $log = null,
|
||||||
|
?\CoreLibs\Language\L10n $l10n = null
|
||||||
|
) {
|
||||||
// create db connection and init base class
|
// create db connection and init base class
|
||||||
parent::__construct($db_config);
|
parent::__construct($db_config, $log ?? new \CoreLibs\Debug\Logging());
|
||||||
// log login data for this class only
|
// log login data for this class only
|
||||||
$this->log->setLogPer('class', true);
|
$this->log->setLogPer('class', true);
|
||||||
|
// set internal page name
|
||||||
|
$this->page_name = \CoreLibs\Get\System::getPageName();
|
||||||
// set db special errors
|
// set db special errors
|
||||||
if ($this->db_init_error === true) {
|
if ($this->db_init_error === true) {
|
||||||
echo 'Could not connect to DB<br>';
|
echo 'Could not connect to DB<br>';
|
||||||
@@ -174,7 +183,10 @@ class Login extends \CoreLibs\DB\IO
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// no session could be found at all
|
// initial the session if there is no session running already
|
||||||
|
// TODO: move that to outside
|
||||||
|
\CoreLibs\Create\Session::startSession();
|
||||||
|
// check if session exists
|
||||||
if (!session_id()) {
|
if (!session_id()) {
|
||||||
echo '<b>Session not started!</b><br>Use \'session_start();\'.<br>';
|
echo '<b>Session not started!</b><br>Use \'session_start();\'.<br>';
|
||||||
echo 'For less problems with other session, you can set a session name with \'session_name("name");\'.<br>';
|
echo 'For less problems with other session, you can set a session name with \'session_name("name");\'.<br>';
|
||||||
@@ -202,7 +214,7 @@ class Login extends \CoreLibs\DB\IO
|
|||||||
} else {
|
} else {
|
||||||
$lang = defined('SITE_LANG') ? SITE_LANG : DEFAULT_LANG;
|
$lang = defined('SITE_LANG') ? SITE_LANG : DEFAULT_LANG;
|
||||||
}
|
}
|
||||||
$this->l = new \CoreLibs\Language\L10n($lang);
|
$this->l = $l10n ?? new \CoreLibs\Language\L10n($lang);
|
||||||
|
|
||||||
// if we have a search path we need to set it, to use the correct DB to login
|
// 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
|
// check what schema to use. if there is a login schema use this, else check
|
||||||
|
|||||||
@@ -73,6 +73,8 @@ class Backend extends \CoreLibs\DB\IO
|
|||||||
// the current active edit access id
|
// the current active edit access id
|
||||||
/** @var int */
|
/** @var int */
|
||||||
public $edit_access_id;
|
public $edit_access_id;
|
||||||
|
/** @var string */
|
||||||
|
public $page_name;
|
||||||
// error/warning/info messages
|
// error/warning/info messages
|
||||||
/** @var array<mixed> */
|
/** @var array<mixed> */
|
||||||
public $messages = [];
|
public $messages = [];
|
||||||
@@ -108,15 +110,25 @@ class Backend extends \CoreLibs\DB\IO
|
|||||||
/**
|
/**
|
||||||
* main class constructor
|
* main class constructor
|
||||||
* @param array<mixed> $db_config db config array
|
* @param array<mixed> $db_config db config array
|
||||||
|
* @param \CoreLibs\Debug\Logging|null $log Logging class, default set if not set
|
||||||
*/
|
*/
|
||||||
public function __construct(array $db_config)
|
public function __construct(
|
||||||
{
|
array $db_config,
|
||||||
|
?\CoreLibs\Debug\Logging $log = null
|
||||||
|
) {
|
||||||
|
// set to log not per class
|
||||||
|
if ($log !== null) {
|
||||||
|
$log->setLogPer('class', false);
|
||||||
|
}
|
||||||
$this->setLangEncoding();
|
$this->setLangEncoding();
|
||||||
// get the language sub class & init it
|
// get the language sub class & init it
|
||||||
$this->l = new \CoreLibs\Language\L10n($this->lang);
|
$this->l = new \CoreLibs\Language\L10n($this->lang);
|
||||||
|
|
||||||
// init the database class
|
// init the database class
|
||||||
parent::__construct($db_config);
|
parent::__construct($db_config, $log ?? new \CoreLibs\Debug\Logging());
|
||||||
|
|
||||||
|
// set the page name
|
||||||
|
$this->page_name = \CoreLibs\Get\System::getPageName();
|
||||||
|
|
||||||
// set the action ids
|
// set the action ids
|
||||||
foreach ($this->action_list as $_action) {
|
foreach ($this->action_list as $_action) {
|
||||||
|
|||||||
@@ -77,21 +77,19 @@ class Basic
|
|||||||
/** @var array<mixed> */
|
/** @var array<mixed> */
|
||||||
public $data_path = [];
|
public $data_path = [];
|
||||||
|
|
||||||
// session name
|
|
||||||
/** @var string */
|
|
||||||
private $session_name = '';
|
|
||||||
/** @var string */
|
|
||||||
private $session_id = ''; /** @phpstan-ignore-line */
|
|
||||||
|
|
||||||
// ajax flag
|
// ajax flag
|
||||||
/** @var bool */
|
/** @var bool */
|
||||||
protected $ajax_page_flag = false;
|
protected $ajax_page_flag = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* main Basic constructor to init and check base settings
|
* main Basic constructor to init and check base settings
|
||||||
|
* @param \CoreLibs\Debug\Logging|null $log Logging class
|
||||||
|
* @param string|null $session_name Set session name
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct(
|
||||||
{
|
\CoreLibs\Debug\Logging $log = null,
|
||||||
|
?string $session_name = null
|
||||||
|
) {
|
||||||
// TODO make check dynamic for entries we MUST have depending on load type
|
// TODO make check dynamic for entries we MUST have depending on load type
|
||||||
// before we start any work, we should check that all MUST constants are defined
|
// before we start any work, we should check that all MUST constants are defined
|
||||||
$abort = false;
|
$abort = false;
|
||||||
@@ -117,6 +115,9 @@ class Basic
|
|||||||
die('Core Constant missing. Check config file.');
|
die('Core Constant missing. Check config file.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// logging interface moved here (->debug is now ->log->debug)
|
||||||
|
$this->log = $log ?? new \CoreLibs\Debug\Logging();
|
||||||
|
|
||||||
// set ajax page flag based on the AJAX_PAGE varaibles
|
// set ajax page flag based on the AJAX_PAGE varaibles
|
||||||
// convert to true/false so if AJAX_PAGE is 0 or false it is
|
// convert to true/false so if AJAX_PAGE is 0 or false it is
|
||||||
// always boolean false
|
// always boolean false
|
||||||
@@ -136,8 +137,6 @@ class Basic
|
|||||||
$this->page_name = \CoreLibs\Get\System::getPageName();
|
$this->page_name = \CoreLibs\Get\System::getPageName();
|
||||||
// set host name
|
// set host name
|
||||||
list($this->host_name , $this->host_port) = \CoreLibs\Get\System::getHostName();
|
list($this->host_name , $this->host_port) = \CoreLibs\Get\System::getHostName();
|
||||||
// logging interface moved here (->debug is now ->log->debug)
|
|
||||||
$this->log = new \CoreLibs\Debug\Logging();
|
|
||||||
|
|
||||||
// set the regex for checking emails
|
// set the regex for checking emails
|
||||||
/** @deprecated */
|
/** @deprecated */
|
||||||
@@ -147,25 +146,7 @@ class Basic
|
|||||||
$this->email_regex_check = \CoreLibs\Check\Email::getEmailRegexCheck();
|
$this->email_regex_check = \CoreLibs\Check\Email::getEmailRegexCheck();
|
||||||
|
|
||||||
// initial the session if there is no session running already
|
// initial the session if there is no session running already
|
||||||
if (!session_id()) {
|
\CoreLibs\Create\Session::startSession($session_name);
|
||||||
// check if we have an external session name given, else skip this step
|
|
||||||
if (defined('SET_SESSION_NAME')) {
|
|
||||||
// set the session name for possible later check
|
|
||||||
$this->session_name = SET_SESSION_NAME;
|
|
||||||
}
|
|
||||||
// override with global if set
|
|
||||||
if (isset($GLOBALS['SET_SESSION_NAME'])) {
|
|
||||||
$this->session_name = $GLOBALS['SET_SESSION_NAME'];
|
|
||||||
}
|
|
||||||
// if set, set special session name
|
|
||||||
if ($this->session_name) {
|
|
||||||
session_name($this->session_name);
|
|
||||||
}
|
|
||||||
// start session
|
|
||||||
session_start();
|
|
||||||
// set internal session id, we can use that later for protection check
|
|
||||||
$this->session_id = (string)session_id();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
74
www/lib/CoreLibs/Create/Session.php
Normal file
74
www/lib/CoreLibs/Create/Session.php
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* start a php sesseion
|
||||||
|
* name can be given via startSession parameter
|
||||||
|
* if not set tries to read $SET_SESSION_NAME from global
|
||||||
|
* if this is not set tries to read SET_SESSION_NAME constant
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace CoreLibs\Create;
|
||||||
|
|
||||||
|
class Session
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* init a session
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @param string|null $session_name
|
||||||
|
* @return string|bool
|
||||||
|
*/
|
||||||
|
public static function startSession(?string $session_name = null)
|
||||||
|
{
|
||||||
|
// initial the session if there is no session running already
|
||||||
|
if (!session_id()) {
|
||||||
|
$session_name = $session_name ?? $GLOBALS['SET_SESSION_NAME'] ?? '';
|
||||||
|
// check if we have an external session name given, else skip this step
|
||||||
|
if (
|
||||||
|
empty($session_name) &&
|
||||||
|
defined('SET_SESSION_NAME') &&
|
||||||
|
!empty(SET_SESSION_NAME)
|
||||||
|
) {
|
||||||
|
// set the session name for possible later check
|
||||||
|
$session_name = SET_SESSION_NAME;
|
||||||
|
}
|
||||||
|
// if set, set special session name
|
||||||
|
if (!empty($session_name)) {
|
||||||
|
session_name($session_name);
|
||||||
|
}
|
||||||
|
// start session
|
||||||
|
session_start();
|
||||||
|
}
|
||||||
|
return self::getSessionId();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @return string|bool
|
||||||
|
*/
|
||||||
|
public static function getSessionId()
|
||||||
|
{
|
||||||
|
return session_id();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @return string|bool
|
||||||
|
*/
|
||||||
|
public static function getSessionName()
|
||||||
|
{
|
||||||
|
return session_name();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// __END__
|
||||||
@@ -53,11 +53,16 @@ class ArrayIO extends \CoreLibs\DB\IO
|
|||||||
* @param array<mixed> $db_config db connection config
|
* @param array<mixed> $db_config db connection config
|
||||||
* @param array<mixed> $table_array table array config
|
* @param array<mixed> $table_array table array config
|
||||||
* @param string $table_name table name string
|
* @param string $table_name table name string
|
||||||
|
* @param \CoreLibs\Debug\Logging|null $log Logging class, default set if not set
|
||||||
*/
|
*/
|
||||||
public function __construct(array $db_config, array $table_array, string $table_name)
|
public function __construct(
|
||||||
{
|
array $db_config,
|
||||||
|
array $table_array,
|
||||||
|
string $table_name,
|
||||||
|
\CoreLibs\Debug\Logging $log = null
|
||||||
|
) {
|
||||||
// instance db_io class
|
// instance db_io class
|
||||||
parent::__construct($db_config);
|
parent::__construct($db_config, $log ?? new \CoreLibs\Debug\Logging());
|
||||||
// more error vars for this class
|
// more error vars for this class
|
||||||
$this->error_string['91'] = 'No Primary Key given';
|
$this->error_string['91'] = 'No Primary Key given';
|
||||||
$this->error_string['92'] = 'Could not run Array Query';
|
$this->error_string['92'] = 'Could not run Array Query';
|
||||||
|
|||||||
@@ -101,7 +101,7 @@
|
|||||||
* - used for recursive function [var might disappear if I have time to recode the recursive function]
|
* - used for recursive function [var might disappear if I have time to recode the recursive function]
|
||||||
*
|
*
|
||||||
* PUBLIC METHODS
|
* PUBLIC METHODS
|
||||||
* $mixed db_return($query,$reset=0)
|
* $mixed db_return($query,$reset=self::USE_CACHE)
|
||||||
* - executes query, returns data & caches it (1 = reset/destroy, 2 = reset/cache, 3 = reset/no cache)
|
* - executes query, returns data & caches it (1 = reset/destroy, 2 = reset/cache, 3 = reset/no cache)
|
||||||
* 1/0 db_cache_reset($query)
|
* 1/0 db_cache_reset($query)
|
||||||
* - resets the cache for one query
|
* - resets the cache for one query
|
||||||
@@ -252,8 +252,21 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace CoreLibs\DB;
|
namespace CoreLibs\DB;
|
||||||
|
|
||||||
class IO extends \CoreLibs\Basic
|
class IO
|
||||||
{
|
{
|
||||||
|
// 0: normal read, store in cache
|
||||||
|
// 1: read cache, clean at the end
|
||||||
|
// 2: read new, clean at end
|
||||||
|
// 3: never cache
|
||||||
|
/** @var int */
|
||||||
|
public const USE_CACHE = 0;
|
||||||
|
/** @var int */
|
||||||
|
public const CLEAR_CACHE = 1;
|
||||||
|
/** @var int */
|
||||||
|
public const READ_NEW = 2;
|
||||||
|
/** @var int */
|
||||||
|
public const NO_CACHE = 3;
|
||||||
|
|
||||||
// recommend to set private/protected and only allow setting via method
|
// recommend to set private/protected and only allow setting via method
|
||||||
// can bet set from outside
|
// can bet set from outside
|
||||||
// encoding to
|
// encoding to
|
||||||
@@ -265,8 +278,8 @@ class IO extends \CoreLibs\Basic
|
|||||||
// basic vars
|
// basic vars
|
||||||
/** @var resource|bool|int|null */
|
/** @var resource|bool|int|null */
|
||||||
private $dbh; // the dbh handler, if disconnected by command is null, bool:false/int:-1 on error,
|
private $dbh; // the dbh handler, if disconnected by command is null, bool:false/int:-1 on error,
|
||||||
/** @var int|bool */
|
/** @var bool */
|
||||||
public $db_debug; // DB_DEBUG ... (if set prints out debug msgs) [should be bool only]
|
public $db_debug = false; // DB_DEBUG ... (if set prints out debug msgs)
|
||||||
/** @var string */
|
/** @var string */
|
||||||
private $db_name; // the DB connected to
|
private $db_name; // the DB connected to
|
||||||
/** @var string */
|
/** @var string */
|
||||||
@@ -320,12 +333,11 @@ class IO extends \CoreLibs\Basic
|
|||||||
// sub include with the database functions
|
// sub include with the database functions
|
||||||
/** @var \CoreLibs\DB\SQL\PgSQL */
|
/** @var \CoreLibs\DB\SQL\PgSQL */
|
||||||
private $db_functions;
|
private $db_functions;
|
||||||
|
|
||||||
// endless loop protection
|
// endless loop protection
|
||||||
/** @var int */
|
/** @var int */
|
||||||
private $MAX_QUERY_CALL;
|
private $MAX_QUERY_CALL;
|
||||||
/** @var int */
|
/** @var int */
|
||||||
private $DEFAULT_MAX_QUERY_CALL = 20; // default
|
private const DEFAULT_MAX_QUERY_CALL = 20; // default
|
||||||
/** @var array<mixed> */
|
/** @var array<mixed> */
|
||||||
private $query_called = [];
|
private $query_called = [];
|
||||||
// error string
|
// error string
|
||||||
@@ -347,20 +359,21 @@ class IO extends \CoreLibs\Basic
|
|||||||
// if a sync is running holds the md5 key of the query
|
// if a sync is running holds the md5 key of the query
|
||||||
/** @var string */
|
/** @var string */
|
||||||
private $async_running;
|
private $async_running;
|
||||||
|
// logging class, must be public so settings can be changed
|
||||||
|
/** @var \CoreLibs\Debug\Logging */
|
||||||
|
public $log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* main DB concstructor with auto connection to DB and failure set on failed connection
|
* main DB concstructor with auto connection to DB and failure set on failed connection
|
||||||
* @param array<mixed> $db_config DB configuration array
|
* @param array<mixed> $db_config DB configuration array
|
||||||
|
* @param \CoreLibs\Debug\Logging|null $log Logging class
|
||||||
*/
|
*/
|
||||||
public function __construct(array $db_config)
|
public function __construct(
|
||||||
{
|
array $db_config,
|
||||||
// start basic class
|
?\CoreLibs\Debug\Logging $log = null
|
||||||
parent::__construct();
|
) {
|
||||||
// dummy init array for db config if not array
|
// attach logger
|
||||||
if (!is_array($db_config)) {
|
$this->log = $log ?? new \CoreLibs\Debug\Logging();
|
||||||
$db_config = [];
|
|
||||||
}
|
|
||||||
// TODO: check must set CONSTANTS
|
|
||||||
// sets the names (for connect/reconnect)
|
// sets the names (for connect/reconnect)
|
||||||
$this->db_name = $db_config['db_name'] ?? '';
|
$this->db_name = $db_config['db_name'] ?? '';
|
||||||
$this->db_user = $db_config['db_user'] ?? '';
|
$this->db_user = $db_config['db_user'] ?? '';
|
||||||
@@ -372,12 +385,14 @@ class IO extends \CoreLibs\Basic
|
|||||||
$this->db_encoding = !empty($db_config['db_encoding']) ? $db_config['db_encoding'] : '';
|
$this->db_encoding = !empty($db_config['db_encoding']) ? $db_config['db_encoding'] : '';
|
||||||
$this->db_type = $db_config['db_type'] ?? '';
|
$this->db_type = $db_config['db_type'] ?? '';
|
||||||
$this->db_ssl = !empty($db_config['db_ssl']) ? $db_config['db_ssl'] : 'allow';
|
$this->db_ssl = !empty($db_config['db_ssl']) ? $db_config['db_ssl'] : 'allow';
|
||||||
|
// set debug, either via global var, or from config, else set to false
|
||||||
|
$this->dbSetDebug($GLOBALS['DB_DEBUG'] ?? $db_config['db_debug'] ?? false);
|
||||||
|
|
||||||
// set the target encoding to the DEFAULT_ENCODING if it is one of them: EUC, Shift_JIS, UTF-8
|
// set the target encoding to the DEFAULT_ENCODING if it is one of them: EUC, Shift_JIS, UTF-8
|
||||||
// @ the moment set only from outside
|
// @ the moment set only from outside
|
||||||
|
|
||||||
// set loop protection max count
|
// set loop protection max count
|
||||||
$this->MAX_QUERY_CALL = 20;
|
$this->MAX_QUERY_CALL = self::DEFAULT_MAX_QUERY_CALL;
|
||||||
|
|
||||||
// error & debug stuff, error & warning ids are the same, its just in which var they get written
|
// error & debug stuff, error & warning ids are the same, its just in which var they get written
|
||||||
$this->error_string['10'] = 'Could not load DB interface functions';
|
$this->error_string['10'] = 'Could not load DB interface functions';
|
||||||
@@ -409,13 +424,6 @@ class IO extends \CoreLibs\Basic
|
|||||||
$this->error_string['50'] = 'Setting max query call to -1 will disable loop protection for all subsequent runs';
|
$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';
|
$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;
|
|
||||||
// global overrules local
|
|
||||||
if (isset($GLOBALS['DB_DEBUG'])) {
|
|
||||||
$this->db_debug = $GLOBALS['DB_DEBUG'];
|
|
||||||
}
|
|
||||||
|
|
||||||
// based on $this->db_type
|
// based on $this->db_type
|
||||||
// here we need to load the db pgsql include one
|
// here we need to load the db pgsql include one
|
||||||
// How can we do this dynamic? eg for non PgSQL
|
// How can we do this dynamic? eg for non PgSQL
|
||||||
@@ -444,7 +452,6 @@ class IO extends \CoreLibs\Basic
|
|||||||
public function __destruct()
|
public function __destruct()
|
||||||
{
|
{
|
||||||
$this->__closeDB();
|
$this->__closeDB();
|
||||||
// parent::__destruct();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// *************************************************************
|
// *************************************************************
|
||||||
@@ -982,18 +989,16 @@ class IO extends \CoreLibs\Basic
|
|||||||
* the previous setting to either then on or off
|
* the previous setting to either then on or off
|
||||||
* else override with boolean true/false
|
* else override with boolean true/false
|
||||||
* @param bool|null $debug true/false or null for no set
|
* @param bool|null $debug true/false or null for no set
|
||||||
* @return int debug flag in int
|
* @return bool debug flag in int
|
||||||
*/
|
*/
|
||||||
public function dbSetDebug($debug = null): int
|
public function dbSetDebug($debug = null): bool
|
||||||
{
|
{
|
||||||
if ($debug === true) {
|
if ($debug === true) {
|
||||||
$this->db_debug = 1;
|
$this->db_debug = true;
|
||||||
} elseif ($debug === false) {
|
} elseif ($debug === false) {
|
||||||
$this->db_debug = 0;
|
$this->db_debug = false;
|
||||||
} elseif ($this->db_debug) {
|
} elseif ($this->db_debug === null) {
|
||||||
$this->db_debug = 0;
|
$this->db_debug = false;
|
||||||
} else {
|
|
||||||
$this->db_debug = 1;
|
|
||||||
}
|
}
|
||||||
return $this->db_debug;
|
return $this->db_debug;
|
||||||
}
|
}
|
||||||
@@ -1006,7 +1011,7 @@ class IO extends \CoreLibs\Basic
|
|||||||
* @param bool|null $debug Flag to turn debug on off
|
* @param bool|null $debug Flag to turn debug on off
|
||||||
* @return bool True for debug is on, False for off
|
* @return bool True for debug is on, False for off
|
||||||
*/
|
*/
|
||||||
public function dbToggleDebug(?bool $debug = null)
|
public function dbToggleDebug(?bool $debug = null): bool
|
||||||
{
|
{
|
||||||
if ($debug !== null) {
|
if ($debug !== null) {
|
||||||
$this->db_debug = $debug;
|
$this->db_debug = $debug;
|
||||||
@@ -1028,7 +1033,7 @@ class IO extends \CoreLibs\Basic
|
|||||||
$success = false;
|
$success = false;
|
||||||
// if null then reset to default
|
// if null then reset to default
|
||||||
if ($max_calls === null) {
|
if ($max_calls === null) {
|
||||||
$max_calls = $this->DEFAULT_MAX_QUERY_CALL;
|
$max_calls = self::DEFAULT_MAX_QUERY_CALL;
|
||||||
}
|
}
|
||||||
// if -1 then disable loop check
|
// if -1 then disable loop check
|
||||||
// DANGEROUS, WARN USER
|
// DANGEROUS, WARN USER
|
||||||
@@ -1272,17 +1277,18 @@ class IO extends \CoreLibs\Basic
|
|||||||
* (wheres 1 reads cache AND destroys at end of read)
|
* (wheres 1 reads cache AND destroys at end of read)
|
||||||
* - if set to 3, after EACH row, the data will be reset,
|
* - if set to 3, after EACH row, the data will be reset,
|
||||||
* no caching is done except for basic (count, etc)
|
* no caching is done except for basic (count, etc)
|
||||||
* @param string $query Query string
|
* @param string $query Query string
|
||||||
* @param int $reset reset status:
|
* @param int $reset reset status:
|
||||||
* 1: read cache, clean at the end
|
* USE_CACHE/0: normal read from cache on second run
|
||||||
* 2: read new, clean at end
|
* CLEAR_CACHE/1: read cache, clean at the end
|
||||||
* 3: never cache
|
* READ_NEW/2: read new, clean at end
|
||||||
* @param bool $assoc_only true to only returned the named and not
|
* NO_CACHE/3: never cache
|
||||||
* index position ones
|
* @param bool $assoc_only True to only returned the named and not
|
||||||
* @return array<mixed>|bool return array data or false on error/end
|
* index position ones
|
||||||
|
* @return array<mixed>|bool return array data or false on error/end
|
||||||
* @#suppress PhanTypeMismatchDimFetch
|
* @#suppress PhanTypeMismatchDimFetch
|
||||||
*/
|
*/
|
||||||
public function dbReturn(string $query, int $reset = 0, bool $assoc_only = false)
|
public function dbReturn(string $query, int $reset = self::USE_CACHE, bool $assoc_only = false)
|
||||||
{
|
{
|
||||||
if (!$query) {
|
if (!$query) {
|
||||||
$this->error_id = 11;
|
$this->error_id = 11;
|
||||||
@@ -1445,11 +1451,18 @@ class IO extends \CoreLibs\Basic
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// return row, if last && reset, then unset the hole md5 array
|
// return row, if last && reset, then unset the hole md5 array
|
||||||
if (!$return && ($reset == 1 || $reset == 3) && $this->cursor_ext[$md5]['pos']) {
|
if (
|
||||||
|
!$return &&
|
||||||
|
($reset == self::CLEAR_CACHE || $reset == self::NO_CACHE) &&
|
||||||
|
$this->cursor_ext[$md5]['pos']
|
||||||
|
) {
|
||||||
// unset only the field names here of course
|
// unset only the field names here of course
|
||||||
$this->cursor_ext[$md5]['field_names'] = null;
|
$this->cursor_ext[$md5]['field_names'] = null;
|
||||||
$this->cursor_ext[$md5]['pos'] = 0;
|
$this->cursor_ext[$md5]['pos'] = 0;
|
||||||
} elseif (!$return && $reset == 2 && $this->cursor_ext[$md5]['pos']) {
|
} elseif (
|
||||||
|
!$return && $reset == self::READ_NEW &&
|
||||||
|
$this->cursor_ext[$md5]['pos']
|
||||||
|
) {
|
||||||
// at end of read reset pos & set cursor to 1 (so it does not get lost in session transfer)
|
// at end of read reset pos & set cursor to 1 (so it does not get lost in session transfer)
|
||||||
$this->cursor_ext[$md5]['pos'] = 0;
|
$this->cursor_ext[$md5]['pos'] = 0;
|
||||||
$this->cursor_ext[$md5]['cursor'] = 1;
|
$this->cursor_ext[$md5]['cursor'] = 1;
|
||||||
@@ -1461,7 +1474,7 @@ class IO extends \CoreLibs\Basic
|
|||||||
$this->cursor_ext[$md5]['pos'] ++;
|
$this->cursor_ext[$md5]['pos'] ++;
|
||||||
$this->cursor_ext[$md5]['read_rows'] ++;
|
$this->cursor_ext[$md5]['read_rows'] ++;
|
||||||
// if reset is <3 caching is done, else no
|
// if reset is <3 caching is done, else no
|
||||||
if ($reset < 3) {
|
if ($reset < self::NO_CACHE) {
|
||||||
$temp = [];
|
$temp = [];
|
||||||
foreach ($return as $field_name => $data) {
|
foreach ($return as $field_name => $data) {
|
||||||
$temp[$field_name] = $data;
|
$temp[$field_name] = $data;
|
||||||
|
|||||||
@@ -24,8 +24,16 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace CoreLibs\Debug;
|
namespace CoreLibs\Debug;
|
||||||
|
|
||||||
|
use CoreLibs\Debug\Support;
|
||||||
|
use CoreLibs\Create\Hash;
|
||||||
|
use CoreLibs\Get\System;
|
||||||
|
use CoreLibs\Convert\Html;
|
||||||
|
|
||||||
class Logging
|
class Logging
|
||||||
{
|
{
|
||||||
|
// options
|
||||||
|
/** @var array<mixed> */
|
||||||
|
private $options = [];
|
||||||
// page and host name
|
// page and host name
|
||||||
/** @var string */
|
/** @var string */
|
||||||
private $page_name;
|
private $page_name;
|
||||||
@@ -66,12 +74,16 @@ class Logging
|
|||||||
private $log_folder = '';
|
private $log_folder = '';
|
||||||
/** @var string */
|
/** @var string */
|
||||||
private $log_file_name_ext = 'log'; // use this for date rotate
|
private $log_file_name_ext = 'log'; // use this for date rotate
|
||||||
|
/** @var string */
|
||||||
|
private $log_file_name = '';
|
||||||
/** @var int */
|
/** @var int */
|
||||||
private $log_max_filesize = 0; // set in kilobytes
|
private $log_max_filesize = 0; // set in kilobytes
|
||||||
/** @var string */
|
/** @var string */
|
||||||
private $log_print_file = 'error_msg##LOGID####LEVEL####CLASS####PAGENAME####DATE##';
|
private $log_print_file = 'error_msg##LOGID####LEVEL####CLASS####PAGENAME####DATE##';
|
||||||
/** @var string */
|
/** @var string */
|
||||||
private $log_file_unique_id; // a unique ID set only once for call derived from this class
|
private $log_file_unique_id; // a unique ID set only once for call derived from this class
|
||||||
|
/** @var string */
|
||||||
|
private $log_file_date = ''; // Y-m-d file in file name
|
||||||
/** @var bool */
|
/** @var bool */
|
||||||
private $log_print_file_date = true; // if set add Y-m-d and do automatic daily rotation
|
private $log_print_file_date = true; // if set add Y-m-d and do automatic daily rotation
|
||||||
/** @var string */
|
/** @var string */
|
||||||
@@ -88,30 +100,82 @@ class Logging
|
|||||||
/** @var float */
|
/** @var float */
|
||||||
private $script_starttime;
|
private $script_starttime;
|
||||||
|
|
||||||
public function __construct()
|
/**
|
||||||
|
* Init logger
|
||||||
|
*
|
||||||
|
* global vars that can be used
|
||||||
|
* - BASE
|
||||||
|
* - LOG
|
||||||
|
* - LOG_FILE_ID
|
||||||
|
* options array layout
|
||||||
|
* - log_folder:
|
||||||
|
* - print_file_date:
|
||||||
|
* - file_id:
|
||||||
|
* - unique_id:
|
||||||
|
* - log_per_level:
|
||||||
|
* - log_per_class:
|
||||||
|
* - log_per_page:
|
||||||
|
* - log_per_run:
|
||||||
|
* - debug_all:
|
||||||
|
* - echo_all:
|
||||||
|
* - print_all:
|
||||||
|
* - debug (array):
|
||||||
|
* - echo (array):
|
||||||
|
* - print (array):
|
||||||
|
* - debug_not (array):
|
||||||
|
* - echo_not (array):
|
||||||
|
* - print_not (array):
|
||||||
|
*
|
||||||
|
* @param array<mixed> $options Array with settings options
|
||||||
|
*/
|
||||||
|
public function __construct(array $options = [])
|
||||||
{
|
{
|
||||||
// check must set constants
|
// copy the options over
|
||||||
if (defined('BASE') && defined('LOG')) {
|
$this->options = $options;
|
||||||
|
// set log folder from options
|
||||||
|
$this->log_folder = $this->options['log_folder'] ?? '';
|
||||||
|
// legacy flow, check must set constants
|
||||||
|
if (empty($this->log_folder) && defined('BASE') && defined('LOG')) {
|
||||||
|
// make sure this is writeable, else skip
|
||||||
$this->log_folder = BASE . LOG;
|
$this->log_folder = BASE . LOG;
|
||||||
} else {
|
}
|
||||||
// fallback + warning
|
// fallback + notice
|
||||||
trigger_error('constant BASE or LOG are not defined, fallback to getcwd()', E_USER_WARNING);
|
if (empty($this->log_folder)) {
|
||||||
$this->log_folder = getcwd() . DS;
|
/* trigger_error(
|
||||||
|
'options or constant not set or folder not writable. fallback to: ' . getcwd(),
|
||||||
|
E_USER_NOTICE
|
||||||
|
); */
|
||||||
|
$this->log_folder = getcwd() . DIRECTORY_SEPARATOR;
|
||||||
|
}
|
||||||
|
// if folder is not writeable, abort
|
||||||
|
if (!is_writeable($this->log_folder)) {
|
||||||
|
trigger_error(
|
||||||
|
'Folder: ' . $this->log_folder . ' is not writeable for logging',
|
||||||
|
E_USER_ERROR
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// check if log_folder has a trailing /
|
||||||
|
if (substr($this->log_folder, -1, 1) != DIRECTORY_SEPARATOR) {
|
||||||
|
$this->log_folder .= DIRECTORY_SEPARATOR;
|
||||||
}
|
}
|
||||||
// running time start for script
|
// running time start for script
|
||||||
$this->script_starttime = microtime(true);
|
$this->script_starttime = microtime(true);
|
||||||
// set per run UID for logging
|
// set per run UID for logging
|
||||||
$this->running_uid = \CoreLibs\Create\Hash::__uniqId();
|
$this->running_uid = Hash::__uniqId();
|
||||||
// set the page name
|
// set the page name
|
||||||
$this->page_name = \CoreLibs\Get\System::getPageName();
|
$this->page_name = System::getPageName();
|
||||||
// set host name
|
// set host name
|
||||||
list($this->host_name , $this->host_port) = \CoreLibs\Get\System::getHostName();
|
list($this->host_name , $this->host_port) = System::getHostName();
|
||||||
// add port to host name if not port 80
|
// add port to host name if not port 80
|
||||||
if ($this->host_port != 80) {
|
if ($this->host_port != 80) {
|
||||||
$this->host_name .= ':' . $this->host_port;
|
$this->host_name .= ':' . $this->host_port;
|
||||||
}
|
}
|
||||||
// can be overridden with basicSetLogFileId
|
|
||||||
if (isset($GLOBALS['LOG_FILE_ID'])) {
|
// can be overridden with basicSetLogFileId later
|
||||||
|
if (!empty($this->options['file_id'])) {
|
||||||
|
$this->basicSetLogId($this->options['file_id'] ?? '');
|
||||||
|
} elseif (!empty($GLOBALS['LOG_FILE_ID'])) {
|
||||||
|
// legacy flow, should be removed and only set via options
|
||||||
$this->basicSetLogId($GLOBALS['LOG_FILE_ID']);
|
$this->basicSetLogId($GLOBALS['LOG_FILE_ID']);
|
||||||
} elseif (defined('LOG_FILE_ID')) {
|
} elseif (defined('LOG_FILE_ID')) {
|
||||||
$this->basicSetLogId(LOG_FILE_ID);
|
$this->basicSetLogId(LOG_FILE_ID);
|
||||||
@@ -132,38 +196,90 @@ class Logging
|
|||||||
{
|
{
|
||||||
// if given via parameters, only for all
|
// if given via parameters, only for all
|
||||||
// globals overrule given settings, for one (array), eg $ECHO['db'] = 1;
|
// globals overrule given settings, for one (array), eg $ECHO['db'] = 1;
|
||||||
if (isset($GLOBALS['DEBUG']) && is_array($GLOBALS['DEBUG'])) {
|
if (isset($this->options['debug']) && is_array($this->options['debug'])) {
|
||||||
|
$this->debug_output = $this->options['debug'];
|
||||||
|
} elseif (isset($GLOBALS['DEBUG']) && is_array($GLOBALS['DEBUG'])) {
|
||||||
$this->debug_output = $GLOBALS['DEBUG'];
|
$this->debug_output = $GLOBALS['DEBUG'];
|
||||||
}
|
}
|
||||||
if (isset($GLOBALS['ECHO']) && is_array($GLOBALS['ECHO'])) {
|
if (isset($this->options['echo']) && is_array($this->options['echo'])) {
|
||||||
|
$this->debug_output = $this->options['echo'];
|
||||||
|
} elseif (isset($GLOBALS['ECHO']) && is_array($GLOBALS['ECHO'])) {
|
||||||
$this->echo_output = $GLOBALS['ECHO'];
|
$this->echo_output = $GLOBALS['ECHO'];
|
||||||
}
|
}
|
||||||
if (isset($GLOBALS['PRINT']) && is_array($GLOBALS['PRINT'])) {
|
if (isset($this->options['print']) && is_array($this->options['print'])) {
|
||||||
|
$this->debug_output = $this->options['print'];
|
||||||
|
} elseif (isset($GLOBALS['PRINT']) && is_array($GLOBALS['PRINT'])) {
|
||||||
$this->print_output = $GLOBALS['PRINT'];
|
$this->print_output = $GLOBALS['PRINT'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// exclude these ones from output
|
// exclude these ones from output
|
||||||
if (isset($GLOBALS['DEBUG_NOT']) && is_array($GLOBALS['DEBUG_NOT'])) {
|
if (isset($this->options['debug_not']) && is_array($this->options['debug_not'])) {
|
||||||
|
$this->debug_output = $this->options['debug_not'];
|
||||||
|
} elseif (isset($GLOBALS['DEBUG_NOT']) && is_array($GLOBALS['DEBUG_NOT'])) {
|
||||||
$this->debug_output_not = $GLOBALS['DEBUG_NOT'];
|
$this->debug_output_not = $GLOBALS['DEBUG_NOT'];
|
||||||
}
|
}
|
||||||
if (isset($GLOBALS['ECHO_NOT']) && is_array($GLOBALS['ECHO_NOT'])) {
|
if (isset($this->options['echo_not']) && is_array($this->options['echo_not'])) {
|
||||||
|
$this->debug_output = $this->options['echo_not'];
|
||||||
|
} elseif (isset($GLOBALS['ECHO_NOT']) && is_array($GLOBALS['ECHO_NOT'])) {
|
||||||
$this->echo_output_not = $GLOBALS['ECHO_NOT'];
|
$this->echo_output_not = $GLOBALS['ECHO_NOT'];
|
||||||
}
|
}
|
||||||
if (isset($GLOBALS['PRINT_NOT']) && is_array($GLOBALS['PRINT_NOT'])) {
|
if (isset($this->options['print_not']) && is_array($this->options['print_not'])) {
|
||||||
|
$this->debug_output = $this->options['print_not'];
|
||||||
|
} elseif (isset($GLOBALS['PRINT_NOT']) && is_array($GLOBALS['PRINT_NOT'])) {
|
||||||
$this->print_output_not = $GLOBALS['PRINT_NOT'];
|
$this->print_output_not = $GLOBALS['PRINT_NOT'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// all overrule
|
// all overrule
|
||||||
$this->debug_output_all = $GLOBALS['DEBUG_ALL'] ?? false;
|
$this->debug_output_all =
|
||||||
$this->echo_output_all = $GLOBALS['ECHO_ALL'] ?? false;
|
$this->options['debug_all'] ??
|
||||||
$this->print_output_all = $GLOBALS['PRINT_ALL'] ?? false;
|
$GLOBALS['DEBUG_ALL'] ??
|
||||||
|
false;
|
||||||
|
$this->echo_output_all =
|
||||||
|
$this->options['echo_all'] ??
|
||||||
|
$GLOBALS['ECHO_ALL'] ??
|
||||||
|
false;
|
||||||
|
$this->print_output_all =
|
||||||
|
$this->options['print_all'] ??
|
||||||
|
$GLOBALS['PRINT_ALL'] ??
|
||||||
|
false;
|
||||||
|
|
||||||
// GLOBAL rules for log writing
|
// GLOBAL rules for log writing
|
||||||
$this->log_print_file_date = $GLOBALS['LOG_PRINT_FILE_DATE'] ?? true;
|
$this->log_print_file_date =
|
||||||
$this->log_per_level = $GLOBALS['LOG_PER_LEVEL'] ?? false;
|
$this->options['print_file_date'] ??
|
||||||
$this->log_per_class = $GLOBALS['LOG_PER_CLASS'] ?? false;
|
$GLOBALS['LOG_PRINT_FILE_DATE'] ??
|
||||||
$this->log_per_page = $GLOBALS['LOG_PER_PAGE'] ?? false;
|
true;
|
||||||
$this->log_per_run = $GLOBALS['LOG_PER_RUN'] ?? false;
|
$this->log_per_level =
|
||||||
|
$this->options['per_level'] ??
|
||||||
|
$GLOBALS['LOG_PER_LEVEL'] ??
|
||||||
|
false;
|
||||||
|
$this->log_per_class =
|
||||||
|
$this->options['per_class'] ??
|
||||||
|
$GLOBALS['LOG_PER_CLASS'] ??
|
||||||
|
false;
|
||||||
|
$this->log_per_page =
|
||||||
|
$this->options['per_page'] ??
|
||||||
|
$GLOBALS['LOG_PER_PAGE'] ??
|
||||||
|
false;
|
||||||
|
$this->log_per_run =
|
||||||
|
$this->options['per_run'] ??
|
||||||
|
$GLOBALS['LOG_PER_RUN'] ??
|
||||||
|
false;
|
||||||
|
// set log per date
|
||||||
|
if ($this->log_print_file_date) {
|
||||||
|
$this->log_file_date = date('Y-m-d');
|
||||||
|
}
|
||||||
|
// set per run ID
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -238,18 +354,13 @@ class Logging
|
|||||||
) {
|
) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// 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
|
// init output variable
|
||||||
$output = $error_string; // output formated error string to output file
|
$output = $error_string; // output formated error string to output file
|
||||||
// init base file path
|
// init base file path
|
||||||
$fn = $this->log_folder . $this->log_print_file . '.' . $this->log_file_name_ext;
|
$fn = $this->log_folder . $this->log_print_file . '.' . $this->log_file_name_ext;
|
||||||
// log ID prefix settings, if not valid, replace with empty
|
// log ID prefix settings, if not valid, replace with empty
|
||||||
if (preg_match("/^[A-Za-z0-9]+$/", $this->log_file_id)) {
|
if (!empty($this->log_file_id)) {
|
||||||
$rpl_string = '_' . $this->log_file_id;
|
$rpl_string = '_' . $this->log_file_id;
|
||||||
} else {
|
} else {
|
||||||
$rpl_string = '';
|
$rpl_string = '';
|
||||||
@@ -257,17 +368,9 @@ class Logging
|
|||||||
$fn = str_replace('##LOGID##', $rpl_string, $fn); // log id (like a log file prefix)
|
$fn = str_replace('##LOGID##', $rpl_string, $fn); // log id (like a log file prefix)
|
||||||
|
|
||||||
if ($this->log_per_run) {
|
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
|
$rpl_string = '_' . $this->log_file_unique_id; // add 8 char unique string
|
||||||
} else {
|
} elseif ($this->log_print_file_date) {
|
||||||
$rpl_string = !$this->log_print_file_date ? '' : '_' . date('Y-m-d'); // add date to file
|
$rpl_string = '_' . $this->log_file_date; // add date to file
|
||||||
}
|
}
|
||||||
$fn = str_replace('##DATE##', $rpl_string, $fn); // create output filename
|
$fn = str_replace('##DATE##', $rpl_string, $fn); // create output filename
|
||||||
|
|
||||||
@@ -276,11 +379,13 @@ class Logging
|
|||||||
// set per class, but don't use get_class as we will only get self
|
// set per class, but don't use get_class as we will only get self
|
||||||
$rpl_string = !$this->log_per_class ? '' : '_'
|
$rpl_string = !$this->log_per_class ? '' : '_'
|
||||||
// set sub class settings
|
// set sub class settings
|
||||||
. str_replace('\\', '-', \CoreLibs\Debug\Support::getCallerClass());
|
. str_replace('\\', '-', Support::getCallerClass());
|
||||||
$fn = str_replace('##CLASS##', $rpl_string, $fn); // create output filename
|
$fn = str_replace('##CLASS##', $rpl_string, $fn); // create output filename
|
||||||
|
|
||||||
// if request to write to one file
|
// if request to write to one file
|
||||||
$rpl_string = !$this->log_per_page ? '' : '_' . \CoreLibs\Get\System::getPageName(1);
|
$rpl_string = !$this->log_per_page ?
|
||||||
|
'' :
|
||||||
|
'_' . System::getPageName(System::NO_EXTENSION);
|
||||||
$fn = str_replace('##PAGENAME##', $rpl_string, $fn); // create output filename
|
$fn = str_replace('##PAGENAME##', $rpl_string, $fn); // create output filename
|
||||||
|
|
||||||
// write to file
|
// write to file
|
||||||
@@ -289,32 +394,30 @@ class Logging
|
|||||||
// for easy purpose, rename file only to attach timestamp, nur sequence numbering
|
// for easy purpose, rename file only to attach timestamp, nur sequence numbering
|
||||||
rename($fn, $fn . '.' . date("YmdHis"));
|
rename($fn, $fn . '.' . date("YmdHis"));
|
||||||
}
|
}
|
||||||
$fp = fopen($fn, 'a');
|
$this->log_file_name = $fn;
|
||||||
|
$fp = fopen($this->log_file_name, 'a');
|
||||||
if ($fp !== false) {
|
if ($fp !== false) {
|
||||||
fwrite($fp, $output);
|
fwrite($fp, $output);
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
} else {
|
} else {
|
||||||
echo "<!-- could not open file: $fn //-->";
|
echo "<!-- could not open file: " . $this->log_file_name . " //-->";
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Superseeded by \CoreLibs\Debug\Support::getCallerClass() calls
|
|
||||||
*
|
|
||||||
* @return string Class name where called
|
|
||||||
* @deprecated Use \CoreLibs\Debug\Support::getCallerClass() insteader
|
|
||||||
*/
|
|
||||||
private function getCallerClass(): string
|
|
||||||
{
|
|
||||||
// get the last class entry and wrie that
|
|
||||||
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
|
||||||
// make sure if false it is an array and then check if not class set return empty string
|
|
||||||
return (end($backtrace) ?: [])['class'] ?? '';
|
|
||||||
}
|
|
||||||
|
|
||||||
// *** PUBLIC ***
|
// *** PUBLIC ***
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Temporary method to read all class variables for testing purpose
|
||||||
|
* @param string $name
|
||||||
|
* @return mixed can be anything, bool, string, int, array
|
||||||
|
*/
|
||||||
|
public function getSetting(string $name): mixed
|
||||||
|
{
|
||||||
|
// for debug purpose only
|
||||||
|
return $this->{$name};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sets the internal log file prefix id
|
* sets the internal log file prefix id
|
||||||
* string must be a alphanumeric string
|
* string must be a alphanumeric string
|
||||||
@@ -324,12 +427,51 @@ class Logging
|
|||||||
*/
|
*/
|
||||||
public function basicSetLogId(string $string): string
|
public function basicSetLogId(string $string): string
|
||||||
{
|
{
|
||||||
if (preg_match("/^\w+$/", $string)) {
|
if (preg_match("/^[\w\-]+$/", $string)) {
|
||||||
$this->log_file_id = $string;
|
$this->log_file_id = $string;
|
||||||
}
|
}
|
||||||
return $this->log_file_id;
|
return $this->log_file_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* return current set log file id
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getLogId(): string
|
||||||
|
{
|
||||||
|
return $this->log_file_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* old name for setLogLevel
|
||||||
|
* @param string $type debug, echo, print
|
||||||
|
* @param string $flag on/off
|
||||||
|
* array $array of levels to turn on/off debug
|
||||||
|
* @return bool Return false if type or flag is invalid
|
||||||
|
*/
|
||||||
|
public function debugFor(string $type, string $flag): bool
|
||||||
|
{
|
||||||
|
/** @phan-suppress-next-line PhanTypeMismatchArgumentReal, PhanParamTooFew @phpstan-ignore-next-line */
|
||||||
|
return $this->setLogLevel(...[func_get_args()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set log level settings for All types
|
||||||
|
* if invalid type, skip
|
||||||
|
* @param string $type Type to get: debug, echo, print
|
||||||
|
* @param bool $set True or False
|
||||||
|
* @return bool Return false if type invalid
|
||||||
|
*/
|
||||||
|
public function setLogLevelAll(string $type, bool $set): bool
|
||||||
|
{
|
||||||
|
// skip set if not valid
|
||||||
|
if (!in_array($type, ['debug', 'echo', 'print'])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$this->{$type . '_output_all'} = $set;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get the current log level setting for All level blocks
|
* get the current log level setting for All level blocks
|
||||||
* @param string $type Type to get: debug, echo, print
|
* @param string $type Type to get: debug, echo, print
|
||||||
@@ -344,35 +486,6 @@ class Logging
|
|||||||
return $this->{$type . '_output_all'};
|
return $this->{$type . '_output_all'};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* set log level settings for All types
|
|
||||||
* if invalid type, skip
|
|
||||||
* @param string $type Type to get: debug, echo, print
|
|
||||||
* @param bool $set True or False
|
|
||||||
* @return void No return
|
|
||||||
*/
|
|
||||||
public function setLogLevelAll(string $type, bool $set): void
|
|
||||||
{
|
|
||||||
// skip set if not valid
|
|
||||||
if (!in_array($type, ['debug', 'echo', 'print'])) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$this->{$type . '_output_all'} = $set;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* old name for setLogLevel
|
|
||||||
* @param string $type debug, echo, print
|
|
||||||
* @param string $flag on/off
|
|
||||||
* array $array of levels to turn on/off debug
|
|
||||||
* @return void has no return
|
|
||||||
*/
|
|
||||||
public function debugFor(string $type, string $flag): void
|
|
||||||
{
|
|
||||||
/** @phan-suppress-next-line PhanTypeMismatchArgumentReal, PhanParamTooFew @phpstan-ignore-next-line */
|
|
||||||
$this->setLogLevel(...[func_get_args()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* passes list of level names, to turn on debug
|
* passes list of level names, to turn on debug
|
||||||
* eg $foo->debugFor('print', 'on', ['LOG', 'DEBUG', 'INFO']);
|
* eg $foo->debugFor('print', 'on', ['LOG', 'DEBUG', 'INFO']);
|
||||||
@@ -380,17 +493,17 @@ class Logging
|
|||||||
* @param string $type debug, echo, print
|
* @param string $type debug, echo, print
|
||||||
* @param string $flag on/off
|
* @param string $flag on/off
|
||||||
* array $array of levels to turn on/off debug
|
* array $array of levels to turn on/off debug
|
||||||
* @return void has no return
|
* @return bool Return false if type or falg invalid
|
||||||
*/
|
*/
|
||||||
public function setLogLevel(string $type, string $flag): void
|
public function setLogLevel(string $type, string $flag): bool
|
||||||
{
|
{
|
||||||
// abort if not valid type
|
// abort if not valid type
|
||||||
if (!in_array($type, ['debug', 'echo', 'print'])) {
|
if (!in_array($type, ['debug', 'echo', 'print'])) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
// invalid flag type
|
// invalid flag type
|
||||||
if (!in_array($flag, ['on', 'off'])) {
|
if (!in_array($flag, ['on', 'off'])) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
$debug_on = func_get_args();
|
$debug_on = func_get_args();
|
||||||
array_shift($debug_on); // kick out type
|
array_shift($debug_on); // kick out type
|
||||||
@@ -401,6 +514,7 @@ class Logging
|
|||||||
$this->{$switch}[$level] = true;
|
$this->{$switch}[$level] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -438,14 +552,15 @@ class Logging
|
|||||||
* - run: for each run
|
* - run: for each run
|
||||||
* @param string $type Type to get: level, class, page, run
|
* @param string $type Type to get: level, class, page, run
|
||||||
* @param bool $set True or False
|
* @param bool $set True or False
|
||||||
* @return void
|
* @return bool Return false if type invalid
|
||||||
*/
|
*/
|
||||||
public function setLogPer(string $type, bool $set): void
|
public function setLogPer(string $type, bool $set): bool
|
||||||
{
|
{
|
||||||
if (!in_array($type, ['level', 'class', 'page', 'run'])) {
|
if (!in_array($type, ['level', 'class', 'page', 'run'])) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
$this->{'log_per_' . $type} = $set;
|
$this->{'log_per_' . $type} = $set;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -493,16 +608,16 @@ class Logging
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// get the last class entry and wrie that
|
// get the last class entry and wrie that
|
||||||
$class = \CoreLibs\Debug\Support::getCallerClass();
|
$class = Support::getCallerClass();
|
||||||
// get timestamp
|
// get timestamp
|
||||||
$timestamp = \CoreLibs\Debug\Support::printTime();
|
$timestamp = Support::printTime();
|
||||||
// same string put for print (no html data inside)
|
// same string put for print (no html data inside)
|
||||||
// write to file if set
|
// write to file if set
|
||||||
$this->writeErrorMsg(
|
$this->writeErrorMsg(
|
||||||
$level,
|
$level,
|
||||||
'[' . $timestamp . '] '
|
'[' . $timestamp . '] '
|
||||||
. '[' . $this->host_name . '] '
|
. '[' . $this->host_name . '] '
|
||||||
. '[' . \CoreLibs\Get\System::getPageName(2) . '] '
|
. '[' . System::getPageName(System::FULL_PATH) . '] '
|
||||||
. '[' . $this->running_uid . '] '
|
. '[' . $this->running_uid . '] '
|
||||||
. '{' . $class . '} '
|
. '{' . $class . '} '
|
||||||
. '<' . $level . '> - '
|
. '<' . $level . '> - '
|
||||||
@@ -544,7 +659,7 @@ class Logging
|
|||||||
. str_replace(
|
. str_replace(
|
||||||
['##HTMLPRE##', '##/HTMLPRE##'],
|
['##HTMLPRE##', '##/HTMLPRE##'],
|
||||||
['<pre>', '</pre>'],
|
['<pre>', '</pre>'],
|
||||||
\CoreLibs\Convert\Html::htmlent($string)
|
Html::htmlent($string)
|
||||||
)
|
)
|
||||||
. "</div><!--#BR#-->";
|
. "</div><!--#BR#-->";
|
||||||
}
|
}
|
||||||
@@ -583,7 +698,7 @@ class Logging
|
|||||||
if ($this->doDebugTrigger('echo', $level)) {
|
if ($this->doDebugTrigger('echo', $level)) {
|
||||||
$string_output .= '<div style="font-size: 12px;">'
|
$string_output .= '<div style="font-size: 12px;">'
|
||||||
. '[<span style="font-style: italic; color: #c56c00;">' . $level . '</span>] '
|
. '[<span style="font-style: italic; color: #c56c00;">' . $level . '</span>] '
|
||||||
. ($string ? "<b>**** " . \CoreLibs\Convert\Html::htmlent($string) . " ****</br>\n" : "")
|
. ($string ? "<b>**** " . Html::htmlent($string) . " ****</br>\n" : "")
|
||||||
. '</div>'
|
. '</div>'
|
||||||
. join('', $temp_debug_output);
|
. join('', $temp_debug_output);
|
||||||
} // echo it out
|
} // echo it out
|
||||||
@@ -596,7 +711,7 @@ class Logging
|
|||||||
. 'border-bottom: 1px solid black; margin: 10px 0 10px 0; '
|
. 'border-bottom: 1px solid black; margin: 10px 0 10px 0; '
|
||||||
. 'background-color: white; color: black;">'
|
. 'background-color: white; color: black;">'
|
||||||
. '<div style="font-size: 12px;">{<span style="font-style: italic; color: #928100;">'
|
. '<div style="font-size: 12px;">{<span style="font-style: italic; color: #928100;">'
|
||||||
. \CoreLibs\Debug\Support::getCallerClass() . '</span>}</div>';
|
. Support::getCallerClass() . '</span>}</div>';
|
||||||
$string_output = $string_prefix . $string_output
|
$string_output = $string_prefix . $string_output
|
||||||
. '<div><span style="font-style: italic; color: #108db3;">Script Run Time:</span> '
|
. '<div><span style="font-style: italic; color: #108db3;">Script Run Time:</span> '
|
||||||
. $script_end . '</div>'
|
. $script_end . '</div>'
|
||||||
|
|||||||
@@ -49,7 +49,6 @@ class L10n
|
|||||||
*/
|
*/
|
||||||
public function __construct(string $lang = '', string $path = '')
|
public function __construct(string $lang = '', string $path = '')
|
||||||
{
|
{
|
||||||
// parent::__construct();
|
|
||||||
if (!$lang) {
|
if (!$lang) {
|
||||||
$this->lang = 'en';
|
$this->lang = 'en';
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -218,6 +218,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace CoreLibs\Output\Form;
|
namespace CoreLibs\Output\Form;
|
||||||
|
|
||||||
|
use CoreLibs\Get\System;
|
||||||
|
|
||||||
class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||||
{
|
{
|
||||||
// for the load statetment describes which elements from
|
// for the load statetment describes which elements from
|
||||||
@@ -251,6 +253,8 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
|||||||
public $my_page_name; // the name of the page without .php extension
|
public $my_page_name; // the name of the page without .php extension
|
||||||
/** @var bool */
|
/** @var bool */
|
||||||
public $mobile_phone = false;
|
public $mobile_phone = false;
|
||||||
|
/** @var string */
|
||||||
|
public $email_regex;
|
||||||
// buttons and checkboxes
|
// buttons and checkboxes
|
||||||
/** @var string */
|
/** @var string */
|
||||||
public $archive;
|
public $archive;
|
||||||
@@ -294,14 +298,16 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
|||||||
/**
|
/**
|
||||||
* construct form generator
|
* construct form generator
|
||||||
* @param array<mixed> $db_config db config array
|
* @param array<mixed> $db_config db config array
|
||||||
* @param int|integer $table_width table/div width (default 750)
|
* @param \CoreLibs\Debug\Logging|null $log Logging class
|
||||||
*/
|
*/
|
||||||
public function __construct(array $db_config, int $table_width = 750)
|
public function __construct(
|
||||||
{
|
array $db_config,
|
||||||
|
\CoreLibs\Debug\Logging $log = null
|
||||||
|
) {
|
||||||
global $table_arrays;
|
global $table_arrays;
|
||||||
// replace any non valid variable names
|
// replace any non valid variable names
|
||||||
// TODO extracft only alphanumeric and _ after . to _ replacement
|
// TODO extract only alphanumeric and _ after . to _ replacement
|
||||||
$this->my_page_name = str_replace(['.'], '_', \CoreLibs\Get\System::getPageName(1));
|
$this->my_page_name = str_replace(['.'], '_', System::getPageName(System::NO_EXTENSION));
|
||||||
$this->setLangEncoding();
|
$this->setLangEncoding();
|
||||||
// init the language class
|
// init the language class
|
||||||
$this->l = new \CoreLibs\Language\L10n($this->lang);
|
$this->l = new \CoreLibs\Language\L10n($this->lang);
|
||||||
@@ -312,13 +318,13 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
|||||||
if (
|
if (
|
||||||
/* isset($GLOBALS['table_arrays']) &&
|
/* isset($GLOBALS['table_arrays']) &&
|
||||||
is_array($GLOBALS['table_arrays']) &&
|
is_array($GLOBALS['table_arrays']) &&
|
||||||
isset($GLOBALS['table_arrays'][\CoreLibs\Get\System::getPageName(1)]) &&
|
isset($GLOBALS['table_arrays'][System::getPageName(System::NO_EXTENSION)]) &&
|
||||||
is_array($GLOBALS['table_arrays'][\CoreLibs\Get\System::getPageName(1)]) */
|
is_array($GLOBALS['table_arrays'][System::getPageName(System::NO_EXTENSION)]) */
|
||||||
isset($table_arrays[\CoreLibs\Get\System::getPageName(1)]) &&
|
isset($table_arrays[System::getPageName(System::NO_EXTENSION)]) &&
|
||||||
is_array($table_arrays[\CoreLibs\Get\System::getPageName(1)])
|
is_array($table_arrays[System::getPageName(System::NO_EXTENSION)])
|
||||||
) {
|
) {
|
||||||
// $config_array = $GLOBALS['table_arrays'][\CoreLibs\Get\System::getPageName(1)];
|
// $config_array = $GLOBALS['table_arrays'][System::getPageName(1)];
|
||||||
$config_array = $table_arrays[\CoreLibs\Get\System::getPageName(1)];
|
$config_array = $table_arrays[System::getPageName(1)];
|
||||||
} else {
|
} else {
|
||||||
// WARNING: auto spl load does not work with this as it is an array and not a function/object
|
// WARNING: auto spl load does not work with this as it is an array and not a function/object
|
||||||
// check if this is the old path or the new path
|
// check if this is the old path or the new path
|
||||||
@@ -346,9 +352,17 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// don't log per class
|
||||||
|
if ($log !== null) {
|
||||||
|
$log->setLogPer('class', false);
|
||||||
|
}
|
||||||
// start the array_io class which will start db_io ...
|
// start the array_io class which will start db_io ...
|
||||||
parent::__construct($db_config, $config_array['table_array'], $config_array['table_name']);
|
parent::__construct(
|
||||||
|
$db_config,
|
||||||
|
$config_array['table_array'],
|
||||||
|
$config_array['table_name'],
|
||||||
|
$log ?? new \CoreLibs\Debug\Logging()
|
||||||
|
);
|
||||||
// here should be a check if the config_array is correct ...
|
// here should be a check if the config_array is correct ...
|
||||||
if (isset($config_array['show_fields']) && is_array($config_array['show_fields'])) {
|
if (isset($config_array['show_fields']) && is_array($config_array['show_fields'])) {
|
||||||
$this->field_array = $config_array['show_fields'];
|
$this->field_array = $config_array['show_fields'];
|
||||||
@@ -371,9 +385,6 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// layout
|
|
||||||
$this->table_width = $table_width;
|
|
||||||
|
|
||||||
// set button vars
|
// set button vars
|
||||||
$this->archive = $_POST['archive'] ?? '';
|
$this->archive = $_POST['archive'] ?? '';
|
||||||
$this->new = $_POST['new'] ?? '';
|
$this->new = $_POST['new'] ?? '';
|
||||||
@@ -411,6 +422,9 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
|||||||
'delete' => 100
|
'delete' => 100
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set email regex
|
||||||
|
$this->email_regex = \CoreLibs\Check\Email::getEmailRegex();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* sets a form token in the _SESSION variable
|
* sets a form token in the _SESSION variable
|
||||||
|
* session must be started for this to work
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|||||||
1
www/vendor/composer/autoload_classmap.php
vendored
1
www/vendor/composer/autoload_classmap.php
vendored
@@ -26,6 +26,7 @@ return array(
|
|||||||
'CoreLibs\\Convert\\MimeAppName' => $baseDir . '/lib/CoreLibs/Convert/MimeAppName.php',
|
'CoreLibs\\Convert\\MimeAppName' => $baseDir . '/lib/CoreLibs/Convert/MimeAppName.php',
|
||||||
'CoreLibs\\Create\\Hash' => $baseDir . '/lib/CoreLibs/Create/Hash.php',
|
'CoreLibs\\Create\\Hash' => $baseDir . '/lib/CoreLibs/Create/Hash.php',
|
||||||
'CoreLibs\\Create\\RandomKey' => $baseDir . '/lib/CoreLibs/Create/RandomKey.php',
|
'CoreLibs\\Create\\RandomKey' => $baseDir . '/lib/CoreLibs/Create/RandomKey.php',
|
||||||
|
'CoreLibs\\Create\\Session' => $baseDir . '/lib/CoreLibs/Create/Session.php',
|
||||||
'CoreLibs\\Create\\Uids' => $baseDir . '/lib/CoreLibs/Create/Uids.php',
|
'CoreLibs\\Create\\Uids' => $baseDir . '/lib/CoreLibs/Create/Uids.php',
|
||||||
'CoreLibs\\DB\\Extended\\ArrayIO' => $baseDir . '/lib/CoreLibs/DB/Extended/ArrayIO.php',
|
'CoreLibs\\DB\\Extended\\ArrayIO' => $baseDir . '/lib/CoreLibs/DB/Extended/ArrayIO.php',
|
||||||
'CoreLibs\\DB\\IO' => $baseDir . '/lib/CoreLibs/DB/IO.php',
|
'CoreLibs\\DB\\IO' => $baseDir . '/lib/CoreLibs/DB/IO.php',
|
||||||
|
|||||||
1
www/vendor/composer/autoload_static.php
vendored
1
www/vendor/composer/autoload_static.php
vendored
@@ -91,6 +91,7 @@ class ComposerStaticInit10fe8fe2ec4017b8644d2b64bcf398b9
|
|||||||
'CoreLibs\\Convert\\MimeAppName' => __DIR__ . '/../..' . '/lib/CoreLibs/Convert/MimeAppName.php',
|
'CoreLibs\\Convert\\MimeAppName' => __DIR__ . '/../..' . '/lib/CoreLibs/Convert/MimeAppName.php',
|
||||||
'CoreLibs\\Create\\Hash' => __DIR__ . '/../..' . '/lib/CoreLibs/Create/Hash.php',
|
'CoreLibs\\Create\\Hash' => __DIR__ . '/../..' . '/lib/CoreLibs/Create/Hash.php',
|
||||||
'CoreLibs\\Create\\RandomKey' => __DIR__ . '/../..' . '/lib/CoreLibs/Create/RandomKey.php',
|
'CoreLibs\\Create\\RandomKey' => __DIR__ . '/../..' . '/lib/CoreLibs/Create/RandomKey.php',
|
||||||
|
'CoreLibs\\Create\\Session' => __DIR__ . '/../..' . '/lib/CoreLibs/Create/Session.php',
|
||||||
'CoreLibs\\Create\\Uids' => __DIR__ . '/../..' . '/lib/CoreLibs/Create/Uids.php',
|
'CoreLibs\\Create\\Uids' => __DIR__ . '/../..' . '/lib/CoreLibs/Create/Uids.php',
|
||||||
'CoreLibs\\DB\\Extended\\ArrayIO' => __DIR__ . '/../..' . '/lib/CoreLibs/DB/Extended/ArrayIO.php',
|
'CoreLibs\\DB\\Extended\\ArrayIO' => __DIR__ . '/../..' . '/lib/CoreLibs/DB/Extended/ArrayIO.php',
|
||||||
'CoreLibs\\DB\\IO' => __DIR__ . '/../..' . '/lib/CoreLibs/DB/IO.php',
|
'CoreLibs\\DB\\IO' => __DIR__ . '/../..' . '/lib/CoreLibs/DB/IO.php',
|
||||||
|
|||||||
Reference in New Issue
Block a user