Compare commits
10 Commits
v9.26.5
...
5e21ead6fa
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5e21ead6fa | ||
|
|
07fbd13213 | ||
|
|
44b825310a | ||
|
|
2c234ccef6 | ||
|
|
b493b3c4fd | ||
|
|
e7dd96b5d9 | ||
|
|
bcde36ac17 | ||
|
|
8bde34ec7d | ||
|
|
a345d71306 | ||
|
|
0ff6294faa |
43
.eslintrc.js
43
.eslintrc.js
@@ -1,43 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
'env': {
|
|
||||||
'browser': true,
|
|
||||||
'es6': true,
|
|
||||||
'commonjs': true,
|
|
||||||
'jquery': true
|
|
||||||
},
|
|
||||||
'extends': 'eslint:recommended',
|
|
||||||
'parserOptions': {
|
|
||||||
'ecmaVersion': 6
|
|
||||||
},
|
|
||||||
'rules': {
|
|
||||||
'indent': [
|
|
||||||
'error',
|
|
||||||
'tab',
|
|
||||||
{
|
|
||||||
'SwitchCase': 1
|
|
||||||
}
|
|
||||||
],
|
|
||||||
'linebreak-style': [
|
|
||||||
'error',
|
|
||||||
'unix'
|
|
||||||
],
|
|
||||||
'quotes': [
|
|
||||||
'error',
|
|
||||||
'single'
|
|
||||||
],
|
|
||||||
'semi': [
|
|
||||||
'error',
|
|
||||||
'always'
|
|
||||||
],
|
|
||||||
'no-console': 'off',
|
|
||||||
'no-unused-vars': [
|
|
||||||
'error', {
|
|
||||||
'vars': 'all',
|
|
||||||
'args': 'after-used',
|
|
||||||
'ignoreRestSiblings': false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
// Requires eslint >= v8.14.0
|
|
||||||
'no-constant-binary-expression': 'error'
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -48,7 +48,7 @@ header("Content-Type: application/json; charset=UTF-8");
|
|||||||
if (!empty($http_headers['HTTP_AUTHORIZATION']) && !empty($http_headers['HTTP_RUNAUTHTEST'])) {
|
if (!empty($http_headers['HTTP_AUTHORIZATION']) && !empty($http_headers['HTTP_RUNAUTHTEST'])) {
|
||||||
header("HTTP/1.1 401 Unauthorized");
|
header("HTTP/1.1 401 Unauthorized");
|
||||||
print buildContent($http_headers, '{"code": 401, "content": {"Error": "Not Authorized"}}');
|
print buildContent($http_headers, '{"code": 401, "content": {"Error": "Not Authorized"}}');
|
||||||
exit;
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if server request type is get set file_get to null -> no body
|
// if server request type is get set file_get to null -> no body
|
||||||
@@ -57,7 +57,7 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") {
|
|||||||
} elseif (($file_get = file_get_contents('php://input')) === false) {
|
} elseif (($file_get = file_get_contents('php://input')) === false) {
|
||||||
header("HTTP/1.1 404 Not Found");
|
header("HTTP/1.1 404 Not Found");
|
||||||
print buildContent($http_headers, '{"code": 404, "content": {"Error": "file_get_contents failed"}}');
|
print buildContent($http_headers, '{"code": 404, "content": {"Error": "file_get_contents failed"}}');
|
||||||
exit;
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
print buildContent($http_headers, $file_get);
|
print buildContent($http_headers, $file_get);
|
||||||
|
|||||||
@@ -3692,7 +3692,7 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function preparedProviderValue(): array
|
public function providerDbGetPrepareCursorValue(): array
|
||||||
{
|
{
|
||||||
// 1: query (can be empty for do not set)
|
// 1: query (can be empty for do not set)
|
||||||
// 2: stm name
|
// 2: stm name
|
||||||
@@ -3736,7 +3736,7 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
* test return prepare cursor errors
|
* test return prepare cursor errors
|
||||||
*
|
*
|
||||||
* @covers ::dbGetPrepareCursorValue
|
* @covers ::dbGetPrepareCursorValue
|
||||||
* @dataProvider preparedProviderValue
|
* @dataProvider providerDbGetPrepareCursorValue
|
||||||
* @testdox prepared query $stm_name with $key expect error id $error_id [$_dataName]
|
* @testdox prepared query $stm_name with $key expect error id $error_id [$_dataName]
|
||||||
*
|
*
|
||||||
* @param string $query
|
* @param string $query
|
||||||
@@ -3769,6 +3769,94 @@ final class CoreLibsDBIOTest extends TestCase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function providerDbPreparedCursorStatus(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'empty statement pararm' => [
|
||||||
|
'query' => 'SELECT row_int, uid FROM table_with_primary_key',
|
||||||
|
'stm_name' => 'test_stm_a',
|
||||||
|
'check_stm_name' => '',
|
||||||
|
'check_query' => '',
|
||||||
|
'expected' => false
|
||||||
|
],
|
||||||
|
'different stm_name' => [
|
||||||
|
'query' => 'SELECT row_int, uid FROM table_with_primary_key',
|
||||||
|
'stm_name' => 'test_stm_b',
|
||||||
|
'check_stm_name' => 'other_name',
|
||||||
|
'check_query' => '',
|
||||||
|
'expected' => 0
|
||||||
|
],
|
||||||
|
'same stm_name' => [
|
||||||
|
'query' => 'SELECT row_int, uid FROM table_with_primary_key',
|
||||||
|
'stm_name' => 'test_stm_c',
|
||||||
|
'check_stm_name' => 'test_stm_c',
|
||||||
|
'check_query' => '',
|
||||||
|
'expected' => 1
|
||||||
|
],
|
||||||
|
'same stm_name and query' => [
|
||||||
|
'query' => 'SELECT row_int, uid FROM table_with_primary_key',
|
||||||
|
'stm_name' => 'test_stm_d',
|
||||||
|
'check_stm_name' => 'test_stm_d',
|
||||||
|
'check_query' => 'SELECT row_int, uid FROM table_with_primary_key',
|
||||||
|
'expected' => 2
|
||||||
|
],
|
||||||
|
'same stm_name and different query' => [
|
||||||
|
'query' => 'SELECT row_int, uid FROM table_with_primary_key',
|
||||||
|
'stm_name' => 'test_stm_e',
|
||||||
|
'check_stm_name' => 'test_stm_e',
|
||||||
|
'check_query' => 'SELECT row_int, uid, row_int FROM table_with_primary_key',
|
||||||
|
'expected' => 1
|
||||||
|
],
|
||||||
|
'insert query test' => [
|
||||||
|
'query' => 'INSERT INTO table_with_primary_key (row_int, uid) VALUES ($1, $2)',
|
||||||
|
'stm_name' => 'test_stm_f',
|
||||||
|
'check_stm_name' => 'test_stm_f',
|
||||||
|
'check_query' => 'INSERT INTO table_with_primary_key (row_int, uid) VALUES ($1, $2)',
|
||||||
|
'expected' => 2
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test cursor status for prepared statement
|
||||||
|
*
|
||||||
|
* @covers ::dbPreparedCursorStatus
|
||||||
|
* @dataProvider providerDbPreparedCursorStatus
|
||||||
|
* @testdox Check prepared $stm_name ($check_stm_name) status is $expected [$_dataName]
|
||||||
|
*
|
||||||
|
* @param string $query
|
||||||
|
* @param string $stm_name
|
||||||
|
* @param string $check_stm_name
|
||||||
|
* @param string $check_query
|
||||||
|
* @param bool|int $expected
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testDbPreparedCursorStatus(
|
||||||
|
string $query,
|
||||||
|
string $stm_name,
|
||||||
|
string $check_stm_name,
|
||||||
|
string $check_query,
|
||||||
|
bool|int $expected
|
||||||
|
): void {
|
||||||
|
$db = new \CoreLibs\DB\IO(
|
||||||
|
self::$db_config['valid'],
|
||||||
|
self::$log
|
||||||
|
);
|
||||||
|
$db->dbPrepare($stm_name, $query);
|
||||||
|
// $db->dbExecute($stm_name);
|
||||||
|
$this->assertEquals(
|
||||||
|
$expected,
|
||||||
|
$db->dbPreparedCursorStatus($check_stm_name, $check_query),
|
||||||
|
'check prepared stement cursor status'
|
||||||
|
);
|
||||||
|
unset($db);
|
||||||
|
}
|
||||||
|
|
||||||
// - schema set/get tests
|
// - schema set/get tests
|
||||||
// dbGetSchema, dbSetSchema
|
// dbGetSchema, dbSetSchema
|
||||||
|
|
||||||
|
|||||||
@@ -969,44 +969,76 @@ final class CoreLibsUrlRequestsCurlTest extends TestCase
|
|||||||
"query" => ["foo-get" => "bar"]
|
"query" => ["foo-get" => "bar"]
|
||||||
]);
|
]);
|
||||||
$this->assertEquals("200", $response["code"], "multi call: get response code not matching");
|
$this->assertEquals("200", $response["code"], "multi call: get response code not matching");
|
||||||
$this->assertEquals(
|
if (PHP_VERSION_ID >= 80400) {
|
||||||
'{"HEADERS":{"HTTP_USER_AGENT":"CoreLibsUrlRequestCurl\/1",'
|
$this->assertEquals(
|
||||||
. '"HTTP_FIRST_CALL":"get","HTTP_ACCEPT":"*\/*",'
|
'{"HEADERS":{"HTTP_HOST":"soba.egplusww.jp",'
|
||||||
. '"HTTP_HOST":"soba.egplusww.jp"},'
|
. '"HTTP_USER_AGENT":"CoreLibsUrlRequestCurl\/1","HTTP_FIRST_CALL":"get",'
|
||||||
. '"REQUEST_TYPE":"GET",'
|
. '"HTTP_ACCEPT":"*\/*"},"REQUEST_TYPE":"GET","PARAMS":{"foo-get":"bar"},"BODY":null}',
|
||||||
. '"PARAMS":{"foo-get":"bar"},"BODY":null}',
|
$response['content'],
|
||||||
$response['content'],
|
'multi call: get content not matching'
|
||||||
'multi call: get content not matching'
|
);
|
||||||
);
|
} else {
|
||||||
|
$this->assertEquals(
|
||||||
|
'{"HEADERS":{"HTTP_USER_AGENT":"CoreLibsUrlRequestCurl\/1",'
|
||||||
|
. '"HTTP_FIRST_CALL":"get","HTTP_ACCEPT":"*\/*",'
|
||||||
|
. '"HTTP_HOST":"soba.egplusww.jp"},'
|
||||||
|
. '"REQUEST_TYPE":"GET",'
|
||||||
|
. '"PARAMS":{"foo-get":"bar"},"BODY":null}',
|
||||||
|
$response['content'],
|
||||||
|
'multi call: get content not matching'
|
||||||
|
);
|
||||||
|
}
|
||||||
// post
|
// post
|
||||||
$response = $curl->post($this->url_basic, [
|
$response = $curl->post($this->url_basic, [
|
||||||
"headers" => ["second-call" => "post"],
|
"headers" => ["second-call" => "post"],
|
||||||
"body" => ["foo-post" => "baz"]
|
"body" => ["foo-post" => "baz"]
|
||||||
]);
|
]);
|
||||||
$this->assertEquals("200", $response["code"], "multi call: post response code not matching");
|
$this->assertEquals("200", $response["code"], "multi call: post response code not matching");
|
||||||
$this->assertEquals(
|
if (PHP_VERSION_ID >= 80400) {
|
||||||
'{"HEADERS":{"HTTP_USER_AGENT":"CoreLibsUrlRequestCurl\/1",'
|
$this->assertEquals(
|
||||||
. '"HTTP_SECOND_CALL":"post","HTTP_ACCEPT":"*\/*",'
|
'{"HEADERS":{"HTTP_HOST":"soba.egplusww.jp",'
|
||||||
. '"HTTP_HOST":"soba.egplusww.jp"},'
|
. '"HTTP_USER_AGENT":"CoreLibsUrlRequestCurl\/1",'
|
||||||
. '"REQUEST_TYPE":"POST",'
|
. '"HTTP_SECOND_CALL":"post","HTTP_ACCEPT":"*\/*"},'
|
||||||
. '"PARAMS":[],"BODY":{"foo-post":"baz"}}',
|
. '"REQUEST_TYPE":"POST","PARAMS":[],"BODY":{"foo-post":"baz"}}',
|
||||||
$response['content'],
|
$response['content'],
|
||||||
'multi call: post content not matching'
|
'multi call: post content not matching'
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
$this->assertEquals(
|
||||||
|
'{"HEADERS":{"HTTP_USER_AGENT":"CoreLibsUrlRequestCurl\/1",'
|
||||||
|
. '"HTTP_SECOND_CALL":"post","HTTP_ACCEPT":"*\/*",'
|
||||||
|
. '"HTTP_HOST":"soba.egplusww.jp"},'
|
||||||
|
. '"REQUEST_TYPE":"POST",'
|
||||||
|
. '"PARAMS":[],"BODY":{"foo-post":"baz"}}',
|
||||||
|
$response['content'],
|
||||||
|
'multi call: post content not matching'
|
||||||
|
);
|
||||||
|
}
|
||||||
// delete
|
// delete
|
||||||
$response = $curl->delete($this->url_basic, [
|
$response = $curl->delete($this->url_basic, [
|
||||||
"headers" => ["third-call" => "delete"],
|
"headers" => ["third-call" => "delete"],
|
||||||
]);
|
]);
|
||||||
$this->assertEquals("200", $response["code"], "multi call: delete response code not matching");
|
$this->assertEquals("200", $response["code"], "multi call: delete response code not matching");
|
||||||
$this->assertEquals(
|
if (PHP_VERSION_ID >= 80400) {
|
||||||
'{"HEADERS":{"HTTP_USER_AGENT":"CoreLibsUrlRequestCurl\/1",'
|
$this->assertEquals(
|
||||||
. '"HTTP_THIRD_CALL":"delete","HTTP_ACCEPT":"*\/*",'
|
'{"HEADERS":{"HTTP_HOST":"soba.egplusww.jp",'
|
||||||
. '"HTTP_HOST":"soba.egplusww.jp"},'
|
. '"HTTP_USER_AGENT":"CoreLibsUrlRequestCurl\/1",'
|
||||||
. '"REQUEST_TYPE":"DELETE",'
|
. '"HTTP_THIRD_CALL":"delete","HTTP_ACCEPT":"*\/*"},'
|
||||||
. '"PARAMS":[],"BODY":[]}',
|
. '"REQUEST_TYPE":"DELETE","PARAMS":[],"BODY":[]}',
|
||||||
$response['content'],
|
$response['content'],
|
||||||
'multi call: delete content not matching'
|
'multi call: delete content not matching'
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
$this->assertEquals(
|
||||||
|
'{"HEADERS":{"HTTP_USER_AGENT":"CoreLibsUrlRequestCurl\/1",'
|
||||||
|
. '"HTTP_THIRD_CALL":"delete","HTTP_ACCEPT":"*\/*",'
|
||||||
|
. '"HTTP_HOST":"soba.egplusww.jp"},'
|
||||||
|
. '"REQUEST_TYPE":"DELETE",'
|
||||||
|
. '"PARAMS":[],"BODY":[]}',
|
||||||
|
$response['content'],
|
||||||
|
'multi call: delete content not matching'
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: auth header set via config
|
// MARK: auth header set via config
|
||||||
|
|||||||
59
eslint.config.mjs
Normal file
59
eslint.config.mjs
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
import globals from 'globals';
|
||||||
|
import pluginJs from '@eslint/js';
|
||||||
|
|
||||||
|
/*
|
||||||
|
module.exports = {
|
||||||
|
'env': {
|
||||||
|
'browser': true,
|
||||||
|
'es6': true,
|
||||||
|
'commonjs': true,
|
||||||
|
'jquery': true
|
||||||
|
},
|
||||||
|
'extends': 'eslint:recommended',
|
||||||
|
'parserOptions': {
|
||||||
|
'ecmaVersion': 6
|
||||||
|
},
|
||||||
|
// rules copied
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @type {import('eslint').Linter.Config[]} */
|
||||||
|
export default [
|
||||||
|
{languageOptions: { globals: globals.browser }},
|
||||||
|
pluginJs.configs.recommended,
|
||||||
|
{
|
||||||
|
'rules': {
|
||||||
|
'indent': [
|
||||||
|
'error',
|
||||||
|
'tab',
|
||||||
|
{
|
||||||
|
'SwitchCase': 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'linebreak-style': [
|
||||||
|
'error',
|
||||||
|
'unix'
|
||||||
|
],
|
||||||
|
// 'quotes': [
|
||||||
|
// 'error',
|
||||||
|
// 'single'
|
||||||
|
// ],
|
||||||
|
'semi': [
|
||||||
|
'error',
|
||||||
|
'always'
|
||||||
|
],
|
||||||
|
'no-console': 'off',
|
||||||
|
'no-unused-vars': [
|
||||||
|
'error', {
|
||||||
|
'vars': 'all',
|
||||||
|
'args': 'after-used',
|
||||||
|
'ignoreRestSiblings': false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
// Requires eslint >= v8.14.0
|
||||||
|
'no-constant-binary-expression': 'error'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
// __END__
|
||||||
@@ -1,9 +1,11 @@
|
|||||||
|
// https://www.typescriptlang.org/tsconfig/#compilerOptions
|
||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"module": "ESNext",
|
"module": "ESNext",
|
||||||
"moduleResolution": "Node",
|
"moduleResolution": "Node",
|
||||||
"target": "ES2020",
|
"target": "ES2020",
|
||||||
"jsx": "react",
|
"jsx": "react",
|
||||||
|
"checkJs": true,
|
||||||
"allowImportingTsExtensions": true,
|
"allowImportingTsExtensions": true,
|
||||||
"strictNullChecks": true,
|
"strictNullChecks": true,
|
||||||
"strictFunctionTypes": true
|
"strictFunctionTypes": true
|
||||||
|
|||||||
1567
package-lock.json
generated
Normal file
1567
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
17
package.json
Normal file
17
package.json
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"name": "core-libraries",
|
||||||
|
"version": "9.26.8",
|
||||||
|
"main": "",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"author": "Clemens Schwaighofer",
|
||||||
|
"license": "",
|
||||||
|
"description": "Core Libraries",
|
||||||
|
"devDependencies": {
|
||||||
|
"@eslint/js": "^9.20.0",
|
||||||
|
"esbuild": "^0.25.0",
|
||||||
|
"eslint": "^9.20.1",
|
||||||
|
"globals": "^15.15.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -52,7 +52,7 @@ header("Content-Type: application/json; charset=UTF-8");
|
|||||||
if (!empty($http_headers['HTTP_AUTHORIZATION']) && !empty($http_headers['HTTP_RUNAUTHTEST'])) {
|
if (!empty($http_headers['HTTP_AUTHORIZATION']) && !empty($http_headers['HTTP_RUNAUTHTEST'])) {
|
||||||
header("HTTP/1.1 401 Unauthorized");
|
header("HTTP/1.1 401 Unauthorized");
|
||||||
print buildContent($http_headers, '{"code": 401, "content": {"Error": "Not Authorized"}}');
|
print buildContent($http_headers, '{"code": 401, "content": {"Error": "Not Authorized"}}');
|
||||||
exit;
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if server request type is get set file_get to null -> no body
|
// if server request type is get set file_get to null -> no body
|
||||||
@@ -61,7 +61,7 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") {
|
|||||||
} elseif (($file_get = file_get_contents('php://input')) === false) {
|
} elseif (($file_get = file_get_contents('php://input')) === false) {
|
||||||
header("HTTP/1.1 404 Not Found");
|
header("HTTP/1.1 404 Not Found");
|
||||||
print buildContent($http_headers, '{"code": 404, "content": {"Error": "file_get_contents failed"}}');
|
print buildContent($http_headers, '{"code": 404, "content": {"Error": "file_get_contents failed"}}');
|
||||||
exit;
|
exit(1);
|
||||||
}
|
}
|
||||||
// str_replace('\"', '"', trim($file_get, '"'));
|
// str_replace('\"', '"', trim($file_get, '"'));
|
||||||
|
|
||||||
|
|||||||
@@ -707,6 +707,17 @@ if (
|
|||||||
} else {
|
} else {
|
||||||
print "[PGB] [3] pgb_sel_test_foo prepare OK<br>";
|
print "[PGB] [3] pgb_sel_test_foo prepare OK<br>";
|
||||||
}
|
}
|
||||||
|
$stm_status = $db->dbPreparedCursorStatus('');
|
||||||
|
print "[PGB] Empty statement name: " . $log->prAr($stm_status) . "<br>";
|
||||||
|
$stm_status = $db->dbPreparedCursorStatus('pgb_sel_test_foobar');
|
||||||
|
print "[PGB] Prepared name not match status: $stm_status<br>";
|
||||||
|
$stm_status = $db->dbPreparedCursorStatus('pgb_sel_test_foo');
|
||||||
|
print "[PGB] Prepared name match status: $stm_status<br>";
|
||||||
|
$stm_status = $db->dbPreparedCursorStatus('pgb_sel_test_foo', $q_prep);
|
||||||
|
print "[PGB] prepared exists and query match status: $stm_status<br>";
|
||||||
|
$stm_status = $db->dbPreparedCursorStatus('pgb_sel_test_foo', "SELECT * FROM test_foo");
|
||||||
|
print "[PGB] prepared exists and query not match status: $stm_status<br>";
|
||||||
|
|
||||||
$db_pgb->dbClose();
|
$db_pgb->dbClose();
|
||||||
|
|
||||||
# db write class test
|
# db write class test
|
||||||
|
|||||||
@@ -57,6 +57,51 @@ fclose($fp);
|
|||||||
$out = \CoreLibs\DeprecatedHelper\Deprecated84::str_getcsv("A,B,C");
|
$out = \CoreLibs\DeprecatedHelper\Deprecated84::str_getcsv("A,B,C");
|
||||||
print "str_getcsv: <pre>" . print_r($out, true) . "</pre>";
|
print "str_getcsv: <pre>" . print_r($out, true) . "</pre>";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* temporary different CSV function, because fgetcsv seems to be broken on some systems
|
||||||
|
* (does not read out japanese text)
|
||||||
|
*
|
||||||
|
* @param string $string full line for csv split
|
||||||
|
* @param string $encoding optional, if given, converts string to the internal encoding
|
||||||
|
* before we do anything
|
||||||
|
* @param string $delimiter sepperate character, default ','
|
||||||
|
* @param string $enclosure string line marker, default '"'
|
||||||
|
* @param string $flag INTERN | EXTERN. if INTERN uses the PHP function, else uses explode
|
||||||
|
* @return array<int,string|null> array with split data from input line
|
||||||
|
*/
|
||||||
|
function mtParseCSV(
|
||||||
|
string $string,
|
||||||
|
string $encoding = '',
|
||||||
|
string $delimiter = ',',
|
||||||
|
string $enclosure = '"',
|
||||||
|
string $flag = 'INTERN'
|
||||||
|
): array {
|
||||||
|
$lines = [];
|
||||||
|
if ($encoding) {
|
||||||
|
$string = \CoreLibs\Convert\Encoding::convertEncoding(
|
||||||
|
$string,
|
||||||
|
'UTF-8',
|
||||||
|
$encoding
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if ($flag == 'INTERN') {
|
||||||
|
// split with PHP function
|
||||||
|
$lines = str_getcsv($string, $delimiter, $enclosure);
|
||||||
|
} else {
|
||||||
|
// split up with delimiter
|
||||||
|
$lines = explode(',', $string) ?: [];
|
||||||
|
}
|
||||||
|
// strip " from beginning and end of line
|
||||||
|
for ($i = 0; $i < count($lines); $i++) {
|
||||||
|
// remove line breaks
|
||||||
|
$lines[$i] = preg_replace("/\r\n?/", '', (string)$lines[$i]) ?? '';
|
||||||
|
// lingering " at the beginning and end of the line
|
||||||
|
$lines[$i] = preg_replace("/^\"/", '', (string)$lines[$i]) ?? '';
|
||||||
|
$lines[$i] = preg_replace("/\"$/", '', (string)$lines[$i]) ?? '';
|
||||||
|
}
|
||||||
|
return $lines;
|
||||||
|
}
|
||||||
|
|
||||||
print "</body></html>";
|
print "</body></html>";
|
||||||
|
|
||||||
// __END__
|
// __END__
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ if (isset($login->loginGetAcl()['unit'])) {
|
|||||||
if ($login->loginCheckEditAccessCuid($edit_access_cuid)) {
|
if ($login->loginCheckEditAccessCuid($edit_access_cuid)) {
|
||||||
print "Set new:" . $edit_access_cuid . "<br>";
|
print "Set new:" . $edit_access_cuid . "<br>";
|
||||||
} else {
|
} else {
|
||||||
print "Load default unit id: " . $login->loginGetAcl()['unit_id'] . "<br>";
|
print "Load default unit id: " . $login->loginGetAcl()['unit_cuid'] . "<br>";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
print "Something went wrong with the login<br>";
|
print "Something went wrong with the login<br>";
|
||||||
@@ -140,4 +140,17 @@ $login->writeLog(
|
|||||||
write_type:'JSON'
|
write_type:'JSON'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
echo "<hr>";
|
||||||
|
print "<h3>Legacy Lookups</h3>";
|
||||||
|
|
||||||
|
$edit_access_id = 1;
|
||||||
|
$edit_access_cuid = $login->loginGetEditAccessCuidFromId($edit_access_id);
|
||||||
|
$edit_access_id_rev = null;
|
||||||
|
if (is_string($edit_access_cuid)) {
|
||||||
|
$edit_access_id_rev = $login->loginGetEditAccessIdFromCuid($edit_access_cuid);
|
||||||
|
}
|
||||||
|
print "EA ID: " . $edit_access_id . "<br>";
|
||||||
|
print "EA CUID: " . $log->prAr($edit_access_cuid) . "<br>";
|
||||||
|
print "REV EA CUID: " . $log->prAr($edit_access_id_rev) . "<br>";
|
||||||
|
|
||||||
print "</body></html>";
|
print "</body></html>";
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
/* general edit javascript */
|
/* general edit javascript */
|
||||||
/* jquery version */
|
/* jquery version */
|
||||||
|
|
||||||
/* jshint esversion: 11 */
|
|
||||||
|
|
||||||
/* global i18n */
|
/* global i18n */
|
||||||
|
|
||||||
// debug set
|
// debug set
|
||||||
@@ -533,22 +531,20 @@ function errorCatch(err)
|
|||||||
if (err.stack) {
|
if (err.stack) {
|
||||||
// only FF
|
// only FF
|
||||||
if (err.lineNumber) {
|
if (err.lineNumber) {
|
||||||
console.log('ERROR[%s:%s] %s', err.name, err.lineNumber, err.message);
|
console.error('ERROR[%s:%s] ', err.name, err.lineNumber, err);
|
||||||
} else if (err.line) {
|
} else if (err.line) {
|
||||||
// only Safari
|
// only Safari
|
||||||
console.log('ERROR[%s:%s] %s', err.name, err.line, err.message);
|
console.error('ERROR[%s:%s] ', err.name, err.line, err);
|
||||||
} else {
|
} else {
|
||||||
console.log('ERROR[%s] %s', err.name, err.message);
|
console.error('ERROR[%s] ', err.name, err);
|
||||||
}
|
}
|
||||||
// stack trace
|
|
||||||
console.log('ERROR[stack] %s', err.stack);
|
|
||||||
} else if (err.number) {
|
} else if (err.number) {
|
||||||
// IE
|
// IE
|
||||||
console.log('ERROR[%s:%s] %s', err.name, err.number, err.message);
|
console.error('ERROR[%s:%s] %s', err.name, err.number, err.message);
|
||||||
console.log('ERROR[description] %s', err.description);
|
console.error('ERROR[description] %s', err.description);
|
||||||
} else {
|
} else {
|
||||||
// the rest
|
// the rest
|
||||||
console.log('ERROR[%s] %s', err.name, err.message);
|
console.error('ERROR[%s] %s', err.name, err.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -183,8 +183,9 @@ if (file_exists(BASE . CONFIGS . 'config.path.php')) {
|
|||||||
define('HOST_NAME', $HOST_NAME);
|
define('HOST_NAME', $HOST_NAME);
|
||||||
// BAIL ON MISSING MASTER SITE CONFIG
|
// BAIL ON MISSING MASTER SITE CONFIG
|
||||||
if (!isset($SITE_CONFIG[HOST_NAME]['location'])) {
|
if (!isset($SITE_CONFIG[HOST_NAME]['location'])) {
|
||||||
echo 'Missing SITE_CONFIG entry for: "' . HOST_NAME . '". Contact Administrator';
|
throw new \InvalidArgumentException(
|
||||||
exit;
|
'Missing SITE_CONFIG entry for: "' . HOST_NAME . '". Contact Administrator'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
// BAIL ON MISSING DB CONFIG:
|
// BAIL ON MISSING DB CONFIG:
|
||||||
// we have either no db selction for this host but have db config entries
|
// we have either no db selction for this host but have db config entries
|
||||||
@@ -200,8 +201,9 @@ if (
|
|||||||
empty($DB_CONFIG[$SITE_CONFIG[HOST_NAME]['db_host']]))
|
empty($DB_CONFIG[$SITE_CONFIG[HOST_NAME]['db_host']]))
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
echo 'No matching DB config found for: "' . HOST_NAME . '". Contact Administrator';
|
throw new \InvalidArgumentException(
|
||||||
exit;
|
'No matching DB config found for: "' . HOST_NAME . '". Contact Administrator'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
// set SSL on
|
// set SSL on
|
||||||
$is_secure = false;
|
$is_secure = false;
|
||||||
|
|||||||
@@ -1560,6 +1560,7 @@ class Login
|
|||||||
'uid' => $unit['uid'],
|
'uid' => $unit['uid'],
|
||||||
'cuuid' => $unit['cuuid'],
|
'cuuid' => $unit['cuuid'],
|
||||||
'level' => $this->default_acl_list[$this->acl['unit'][$ea_cuid]]['name'] ?? -1,
|
'level' => $this->default_acl_list[$this->acl['unit'][$ea_cuid]]['name'] ?? -1,
|
||||||
|
'level_number' => $this->acl['unit'][$ea_cuid],
|
||||||
'default' => $unit['default'],
|
'default' => $unit['default'],
|
||||||
'data' => $unit['data'],
|
'data' => $unit['data'],
|
||||||
'additional_acl' => $unit['additional_acl']
|
'additional_acl' => $unit['additional_acl']
|
||||||
@@ -3217,7 +3218,7 @@ HTML;
|
|||||||
* @return int|null same edit access id if ok
|
* @return int|null same edit access id if ok
|
||||||
* or the default edit access id
|
* or the default edit access id
|
||||||
* if given one is not valid
|
* if given one is not valid
|
||||||
* @deprecated Please switch to using edit access cuid check with ->loginCheckEditAccessValidCuid()
|
* @#deprecated Please switch to using edit access cuid check with ->loginCheckEditAccessValidCuid()
|
||||||
*/
|
*/
|
||||||
public function loginCheckEditAccessId(?int $edit_access_id): ?int
|
public function loginCheckEditAccessId(?int $edit_access_id): ?int
|
||||||
{
|
{
|
||||||
@@ -3290,10 +3291,10 @@ HTML;
|
|||||||
*/
|
*/
|
||||||
public function loginGetEditAccessCuidFromId(int $id): string|false
|
public function loginGetEditAccessCuidFromId(int $id): string|false
|
||||||
{
|
{
|
||||||
if (!isset($_SESSION['LOGIN_UNIT_ACL_LEVEL'][$id])) {
|
if (!isset($_SESSION['LOGIN_UNIT_LEGACY'][$id])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return (string)$_SESSION['LOGIN_UNIT_ACL_LEVEL'][$id]['cuid'];
|
return (string)$_SESSION['LOGIN_UNIT_LEGACY'][$id]['cuid'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -3304,10 +3305,10 @@ HTML;
|
|||||||
*/
|
*/
|
||||||
public function loginGetEditAccessIdFromCuid(string $cuid): int|false
|
public function loginGetEditAccessIdFromCuid(string $cuid): int|false
|
||||||
{
|
{
|
||||||
if (!isset($_SESSION['LOGIN_UNIT_LEGACY'][$cuid])) {
|
if (!isset($_SESSION['LOGIN_UNIT'][$cuid])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return $_SESSION['LOGIN_UNIT_LEGACY'][$cuid];
|
return $_SESSION['LOGIN_UNIT'][$cuid]['id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ class EditBase
|
|||||||
);
|
);
|
||||||
if ($this->form->mobile_phone) {
|
if ($this->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(1);
|
||||||
}
|
}
|
||||||
// $this->log->debug('POST', $this->log->prAr($_POST));
|
// $this->log->debug('POST', $this->log->prAr($_POST));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -500,7 +500,7 @@ class IO
|
|||||||
die('<!-- Cannot load db functions class for: ' . $this->db_type . ' -->');
|
die('<!-- Cannot load db functions class for: ' . $this->db_type . ' -->');
|
||||||
}
|
}
|
||||||
// write to internal one, once OK
|
// write to internal one, once OK
|
||||||
$this->db_functions = $db_functions;
|
$this->db_functions = $db_functions; /** @phan-suppress-current-line PhanPossiblyNullTypeMismatchProperty */
|
||||||
|
|
||||||
// connect to DB
|
// connect to DB
|
||||||
if (!$this->__connectToDB()) {
|
if (!$this->__connectToDB()) {
|
||||||
@@ -2946,7 +2946,7 @@ class IO
|
|||||||
$query_hash = $this->dbGetQueryHash($query, $params);
|
$query_hash = $this->dbGetQueryHash($query, $params);
|
||||||
// clears cache for this query
|
// clears cache for this query
|
||||||
if (empty($this->cursor_ext[$query_hash]['query'])) {
|
if (empty($this->cursor_ext[$query_hash]['query'])) {
|
||||||
$this->__dbError(18, context: [
|
$this->__dbWarning(18, context: [
|
||||||
'query' => $query,
|
'query' => $query,
|
||||||
'params' => $params,
|
'params' => $params,
|
||||||
'hash' => $query_hash,
|
'hash' => $query_hash,
|
||||||
@@ -3141,6 +3141,7 @@ class IO
|
|||||||
'pk_name' => '',
|
'pk_name' => '',
|
||||||
'count' => 0,
|
'count' => 0,
|
||||||
'query' => '',
|
'query' => '',
|
||||||
|
'query_raw' => $query,
|
||||||
'result' => null,
|
'result' => null,
|
||||||
'returning_id' => false,
|
'returning_id' => false,
|
||||||
'placeholder_converted' => [],
|
'placeholder_converted' => [],
|
||||||
@@ -3237,11 +3238,12 @@ class IO
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// if we try to use the same statement name for a differnt query, error abort
|
// if we try to use the same statement name for a differnt query, error abort
|
||||||
if ($this->prepare_cursor[$stm_name]['query'] != $query) {
|
if ($this->prepare_cursor[$stm_name]['query_raw'] != $query) {
|
||||||
// thrown error
|
// thrown error
|
||||||
$this->__dbError(26, false, context: [
|
$this->__dbError(26, false, context: [
|
||||||
'statement_name' => $stm_name,
|
'statement_name' => $stm_name,
|
||||||
'prepared_query' => $this->prepare_cursor[$stm_name]['query'],
|
'prepared_query' => $this->prepare_cursor[$stm_name]['query'],
|
||||||
|
'prepared_query_raw' => $this->prepare_cursor[$stm_name]['query_raw'],
|
||||||
'query' => $query,
|
'query' => $query,
|
||||||
'pk_name' => $pk_name,
|
'pk_name' => $pk_name,
|
||||||
]);
|
]);
|
||||||
@@ -4364,6 +4366,37 @@ class IO
|
|||||||
return $this->prepare_cursor[$stm_name][$key];
|
return $this->prepare_cursor[$stm_name][$key];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if a prepared query eixsts
|
||||||
|
*
|
||||||
|
* @param string $stm_name Statement to check
|
||||||
|
* @param string $query [default=''] If set then query must also match
|
||||||
|
* @return false|int<0,2> False on missing stm_name
|
||||||
|
* 0: ok, 1: stm_name matchin, 2: stm_name and query matching
|
||||||
|
*/
|
||||||
|
public function dbPreparedCursorStatus(string $stm_name, string $query = ''): false|int
|
||||||
|
{
|
||||||
|
if (empty($stm_name)) {
|
||||||
|
$this->__dbError(
|
||||||
|
101,
|
||||||
|
false,
|
||||||
|
'No statement name given'
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// does not exist
|
||||||
|
$return_value = 0;
|
||||||
|
if (!empty($this->prepare_cursor[$stm_name]['query_raw'])) {
|
||||||
|
// statement name eixts
|
||||||
|
$return_value = 1;
|
||||||
|
if ($this->prepare_cursor[$stm_name]['query_raw'] == $query) {
|
||||||
|
// query also matches
|
||||||
|
$return_value = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $return_value;
|
||||||
|
}
|
||||||
|
|
||||||
// ***************************
|
// ***************************
|
||||||
// ERROR AND WARNING DATA
|
// ERROR AND WARNING DATA
|
||||||
// ***************************
|
// ***************************
|
||||||
|
|||||||
Reference in New Issue
Block a user