Class namespace change testing
- move auto loader to lib/ folder (so it doesn't exist in document root) - Fix a lot of old method names in DB\IO and Form\General, etc - Fix login with non existing DB set (abort -> exit) - add getDbEncoding call to DB\IO
This commit is contained in:
@@ -8,35 +8,36 @@ if ($DEBUG_ALL) {
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
}
|
||||
|
||||
ob_start();
|
||||
|
||||
define('USE_DATABASE', true);
|
||||
// sample config
|
||||
require("config.inc");
|
||||
// set session name
|
||||
DEFINE('SET_SESSION_NAME', EDIT_SESSION_NAME);
|
||||
// session_name(EDIT_SESSION_NAME);
|
||||
// session_start();
|
||||
// basic class test file
|
||||
foreach (array ('Login', 'Admin.Backend') as $class) {
|
||||
_spl_autoload('Class.'.$class.'.inc');
|
||||
}
|
||||
|
||||
// set language for l10n
|
||||
$lang = 'en_utf8';
|
||||
|
||||
// define log file id
|
||||
DEFINE('LOG_FILE_ID', 'classTest');
|
||||
$login = new login($DB_CONFIG[LOGIN_DB], $lang);
|
||||
// init with standard
|
||||
// $basic = new db_io($DB_CONFIG[MAIN_DB]);
|
||||
$basic = new AdminBackend($DB_CONFIG[MAIN_DB], $lang);
|
||||
$basic->db_info(1);
|
||||
// init login & backend class
|
||||
$login = new CoreLibs\ACL\Login($DB_CONFIG[LOGIN_DB], $lang);
|
||||
$basic = new CoreLibs\Admin\Backend($DB_CONFIG[MAIN_DB], $lang);
|
||||
$basic->dbInfo(1);
|
||||
ob_end_flush();
|
||||
|
||||
// set + check edit access id
|
||||
$edit_access_id = 3;
|
||||
print "ACL UNIT: ".print_r(array_keys($login->acl['unit']), 1)."<br>";
|
||||
print "ACCESS CHECK: ".$login->login_check_edit_access($edit_access_id)."<br>";
|
||||
if ($login->login_check_edit_access($edit_access_id)) {
|
||||
$basic->edit_access_id = $edit_access_id;
|
||||
if (array_key_exists('unit', $login->acl)) {
|
||||
print "ACL UNIT: ".print_r(array_keys($login->acl['unit']), 1)."<br>";
|
||||
print "ACCESS CHECK: ".$login->loginCheckEditAccess($edit_access_id)."<br>";
|
||||
if ($login->loginCheckEditAccess($edit_access_id)) {
|
||||
$basic->edit_access_id = $edit_access_id;
|
||||
} else {
|
||||
$basic->edit_access_id = $login->acl['unit_id'];
|
||||
}
|
||||
} else {
|
||||
$basic->edit_access_id = $login->acl['unit_id'];
|
||||
print "Something went wrong with the login<br>";
|
||||
}
|
||||
|
||||
// $basic->debug('SESSION', $basic->print_ar($_SESSION));
|
||||
@@ -59,12 +60,12 @@ print "DEBUG OUT ALL: ".$basic->debug_output_all."<br>";
|
||||
print "ECHO OUT ALL: ".$basic->echo_output_all."<br>";
|
||||
print "PRINT OUT ALL: ".$basic->print_output_all."<br>";
|
||||
|
||||
print "CALLER BACKTRACE: ".$basic->get_caller_method()."<br>";
|
||||
print "CALLER BACKTRACE: ".$basic->getCallerMethod()."<br>";
|
||||
$basic->debug('SOME MARK', 'Some error output');
|
||||
|
||||
print "EDIT ACCESS ID: ".$basic->edit_access_id."<br>";
|
||||
// print "ACL: <br>".$basic->print_ar($login->acl)."<br>";
|
||||
$basic->debug('ACL', "ACL: ".$basic->print_ar($login->acl));
|
||||
$basic->debug('ACL', "ACL: ".$basic->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>";
|
||||
// $result = array_flip(array_filter(array_flip($login->default_acl_list), function ($key) { if (is_numeric($key)) return $key; }));
|
||||
@@ -72,51 +73,54 @@ $basic->debug('ACL', "ACL: ".$basic->print_ar($login->acl));
|
||||
// DEPRICATED CALL
|
||||
// $basic->adbSetACL($login->acl);
|
||||
|
||||
while ($res = $basic->db_return("SELECT * FROM max_test")) {
|
||||
// DB client encoding
|
||||
print "DB Client encoding: ".$basic->dbGetEncoding()."<br>";
|
||||
|
||||
while ($res = $basic->dbReturn("SELECT * FROM max_test")) {
|
||||
print "TIME: ".$res['time']."<br>";
|
||||
}
|
||||
|
||||
$status = $basic->db_exec("INSERT INTO foo (test) VALUES ('FOO TEST ".time()."') RETURNING test");
|
||||
$status = $basic->dbExec("INSERT INTO foo (test) VALUES ('FOO TEST ".time()."') RETURNING test");
|
||||
print "DIRECT INSERT STATUS: $status | PRIMARY KEY: ".$basic->insert_id." | PRIMARY KEY EXT: ".print_r($basic->insert_id_ext, 1)."<br>";
|
||||
print "DIRECT INSERT PREVIOUS INSERTED: ".print_r($basic->db_return_row("SELECT foo_id, test FROM foo WHERE foo_id = ".$basic->insert_id), 1)."<br>";
|
||||
$basic->db_prepare("ins_foo", "INSERT INTO foo (test) VALUES ($1)");
|
||||
$status = $basic->db_execute("ins_foo", array('BAR TEST '.time()));
|
||||
print "DIRECT INSERT PREVIOUS INSERTED: ".print_r($basic->dbReturnRow("SELECT foo_id, test FROM foo WHERE foo_id = ".$basic->insert_id), 1)."<br>";
|
||||
$basic->dbPrepare("ins_foo", "INSERT INTO foo (test) VALUES ($1)");
|
||||
$status = $basic->dbExecute("ins_foo", array('BAR TEST '.time()));
|
||||
print "PREPARE INSERT STATUS: $status | PRIMARY KEY: ".$basic->insert_id." | PRIMARY KEY EXT: ".print_r($basic->insert_id_ext, 1)."<br>";
|
||||
print "PREPARE INSERT PREVIOUS INSERTED: ".print_r($basic->db_return_row("SELECT foo_id, test FROM foo WHERE foo_id = ".$basic->insert_id), 1)."<br>";
|
||||
print "PREPARE INSERT PREVIOUS INSERTED: ".print_r($basic->dbReturnRow("SELECT foo_id, test FROM foo WHERE foo_id = ".$basic->insert_id), 1)."<br>";
|
||||
// returning test with multiple entries
|
||||
// $status = $basic->db_exec("INSERT INTO foo (test) values ('BAR 1 ".time()."'), ('BAR 2 ".time()."'), ('BAR 3 ".time()."') RETURNING foo_id");
|
||||
$status = $basic->db_exec("INSERT INTO foo (test) values ('BAR 1 ".time()."'), ('BAR 2 ".time()."'), ('BAR 3 ".time()."') RETURNING foo_id, test");
|
||||
$status = $basic->dbExec("INSERT INTO foo (test) values ('BAR 1 ".time()."'), ('BAR 2 ".time()."'), ('BAR 3 ".time()."') RETURNING foo_id, test");
|
||||
print "DIRECT MULTIPLE INSERT STATUS: $status | PRIMARY KEYS: ".print_r($basic->insert_id, 1)." | PRIMARY KEY EXT: ".print_r($basic->insert_id_ext, 1)."<br>";
|
||||
// no returning, but not needed ;
|
||||
$status = $basic->db_exec("INSERT INTO foo (test) VALUES ('FOO; TEST ".time()."');");
|
||||
$status = $basic->dbExec("INSERT INTO foo (test) VALUES ('FOO; TEST ".time()."');");
|
||||
print "DIRECT INSERT STATUS: $status | PRIMARY KEY: ".$basic->insert_id." | PRIMARY KEY EXT: ".print_r($basic->insert_id_ext, 1)."<br>";
|
||||
|
||||
# db write class test
|
||||
$table = 'foo';
|
||||
print "TABLE META DATA: ".$basic->print_ar($basic->db_show_table_meta_data($table))."<br>";
|
||||
print "TABLE META DATA: ".$basic->printAr($basic->dbShowTableMetaData($table))."<br>";
|
||||
$primary_key = ''; # unset
|
||||
$db_write_table = array ('test', 'string_a', 'number_a', 'some_bool');
|
||||
// $db_write_table = array ('test');
|
||||
$object_fields_not_touch = array ();
|
||||
$object_fields_not_update = array ();
|
||||
$data = array ('test' => 'BOOL TEST SOMETHING '.time(), 'string_a' => 'SOME TEXT', 'number_a' => 5);
|
||||
$primary_key = $basic->db_write_data_ext($db_write_table, $primary_key, $table, $object_fields_not_touch, $object_fields_not_update, $data);
|
||||
$primary_key = $basic->dbWriteDataExt($db_write_table, $primary_key, $table, $object_fields_not_touch, $object_fields_not_update, $data);
|
||||
print "Wrote to DB tabel $table and got primary key $primary_key<br>";
|
||||
$data = array ('test' => 'BOOL TEST ON '.time(), 'string_a' => '', 'number_a' => 0, 'some_bool' => 1);
|
||||
$primary_key = $basic->db_write_data_ext($db_write_table, $primary_key, $table, $object_fields_not_touch, $object_fields_not_update, $data);
|
||||
$primary_key = $basic->dbWriteDataExt($db_write_table, $primary_key, $table, $object_fields_not_touch, $object_fields_not_update, $data);
|
||||
print "Wrote to DB tabel $table and got primary key $primary_key<br>";
|
||||
$data = array ('test' => 'BOOL TEST OFF '.time(), 'string_a' => null, 'number_a' => null, 'some_bool' => 0);
|
||||
$primary_key = $basic->db_write_data_ext($db_write_table, $primary_key, $table, $object_fields_not_touch, $object_fields_not_update, $data);
|
||||
$primary_key = $basic->dbWriteDataExt($db_write_table, $primary_key, $table, $object_fields_not_touch, $object_fields_not_update, $data);
|
||||
print "Wrote to DB tabel $table and got primary key $primary_key<br>";
|
||||
$data = array ('test' => 'BOOL TEST UNSET '.time());
|
||||
$primary_key = $basic->db_write_data_ext($db_write_table, $primary_key, $table, $object_fields_not_touch, $object_fields_not_update, $data);
|
||||
$primary_key = $basic->dbWriteDataExt($db_write_table, $primary_key, $table, $object_fields_not_touch, $object_fields_not_update, $data);
|
||||
print "Wrote to DB tabel $table and got primary key $primary_key<br>";
|
||||
|
||||
# async test queries
|
||||
/* $basic->db_exec_async("SELECT test FROM foo, (SELECT pg_sleep(10)) as sub WHERE foo_id IN (27, 50, 67, 44, 10)");
|
||||
/* $basic->dbExecAsync("SELECT test FROM foo, (SELECT pg_sleep(10)) as sub WHERE foo_id IN (27, 50, 67, 44, 10)");
|
||||
echo "WAITING FOR ASYNC: ";
|
||||
$chars = array('|', '/', '-', '\\');
|
||||
while (($ret = $basic->db_check_async()) === true)
|
||||
while (($ret = $basic->dbCheckAsync()) === true)
|
||||
{
|
||||
if ((list($_, $char) = each($chars)) === FALSE)
|
||||
{
|
||||
@@ -128,37 +132,37 @@ while (($ret = $basic->db_check_async()) === true)
|
||||
flush();
|
||||
}
|
||||
print "<br>END STATUS: ".$ret."<br>";
|
||||
// while ($res = $basic->db_fetch_array($ret))
|
||||
while ($res = $basic->db_fetch_array())
|
||||
// while ($res = $basic->dbFetchArray($ret))
|
||||
while ($res = $basic->dbFetchArray())
|
||||
{
|
||||
echo "RES: ".$res['test']."<br>";
|
||||
}
|
||||
# test async insert
|
||||
$basic->db_exec_async("INSERT INTO foo (Test) VALUES ('ASYNC TEST ".time()."')");
|
||||
$basic->dbExecAsync("INSERT INTO foo (Test) VALUES ('ASYNC TEST ".time()."')");
|
||||
echo "WAITING FOR ASYNC INSERT: ";
|
||||
while (($ret = $basic->db_check_async()) === true)
|
||||
while (($ret = $basic->dbCheckAsync()) === true)
|
||||
{
|
||||
print ".";
|
||||
sleep(1);
|
||||
flush();
|
||||
}
|
||||
print "<br>END STATUS: ".$ret." | PK: ".$basic->insert_id."<br>";
|
||||
print "ASYNC PREVIOUS INSERTED: ".print_r($basic->db_return_row("SELECT foo_id, test FROM foo WHERE foo_id = ".$basic->insert_id), 1)."<br>"; */
|
||||
print "ASYNC PREVIOUS INSERTED: ".print_r($basic->dbReturnRow("SELECT foo_id, test FROM foo WHERE foo_id = ".$basic->insert_id), 1)."<br>"; */
|
||||
|
||||
$to_db_version = '9.1.9';
|
||||
print "VERSION DB: ".$basic->db_version()."<br>";
|
||||
print "DB Version smaller $to_db_version: ".$basic->db_compare_version('<'.$to_db_version)."<br>";
|
||||
print "DB Version smaller than $to_db_version: ".$basic->db_compare_version('<='.$to_db_version)."<br>";
|
||||
print "DB Version equal $to_db_version: ".$basic->db_compare_version('='.$to_db_version)."<br>";
|
||||
print "DB Version bigger than $to_db_version: ".$basic->db_compare_version('>='.$to_db_version)."<br>";
|
||||
print "DB Version bigger $to_db_version: ".$basic->db_compare_version('>'.$to_db_version)."<br>";
|
||||
print "VERSION DB: ".$basic->dbVersion()."<br>";
|
||||
print "DB Version smaller $to_db_version: ".$basic->dbCompareVersion('<'.$to_db_version)."<br>";
|
||||
print "DB Version smaller than $to_db_version: ".$basic->dbCompareVersion('<='.$to_db_version)."<br>";
|
||||
print "DB Version equal $to_db_version: ".$basic->dbCompareVersion('='.$to_db_version)."<br>";
|
||||
print "DB Version bigger than $to_db_version: ".$basic->dbCompareVersion('>='.$to_db_version)."<br>";
|
||||
print "DB Version bigger $to_db_version: ".$basic->dbCompareVersion('>'.$to_db_version)."<br>";
|
||||
|
||||
/* $q = "SELECT FOO FRO BAR";
|
||||
// $q = "Select * from foo";
|
||||
$foo = $basic->db_exec_async($q);
|
||||
$foo = $basic->dbExecAsync($q);
|
||||
print "[ERR] Query: ".$q."<br>";
|
||||
print "[ERR] RESOURCE: $foo<br>";
|
||||
while (($ret = $basic->db_check_async()) === true)
|
||||
while (($ret = $basic->dbCheckAsync()) === true)
|
||||
{
|
||||
print "[ERR]: $ret<br>";
|
||||
// sleep(5);
|
||||
@@ -166,30 +170,33 @@ while (($ret = $basic->db_check_async()) === true)
|
||||
|
||||
// search path check
|
||||
$q = "SHOW search_path";
|
||||
$cursor = $basic->db_exec($q);
|
||||
$data = $basic->db_fetch_array($cursor)['search_path'];
|
||||
$cursor = $basic->dbExec($q);
|
||||
$data = $basic->dbFetchArray($cursor)['search_path'];
|
||||
print "RETURN DATA FOR search_path: ".$data."<br>";
|
||||
// print "RETURN DATA FOR search_path: ".$basic->print_ar($data)."<br>";
|
||||
// print "RETURN DATA FOR search_path: ".$basic->printAr($data)."<br>";
|
||||
// insert something into test.schema_test and see if we get the PK back
|
||||
$status = $basic->db_exec("INSERT INTO test.schema_test (contents, id) VALUES ('TIME: ".time()."', ".rand(1, 10).")");
|
||||
$status = $basic->dbExec("INSERT INTO test.schema_test (contents, id) VALUES ('TIME: ".time()."', ".rand(1, 10).")");
|
||||
print "OTHER SCHEMA INSERT STATUS: ".$status." | PK NAME: ".$basic->pk_name.", PRIMARY KEY: ".$basic->insert_id."<br>";
|
||||
|
||||
// time string thest
|
||||
$timestamp = 5887998.33445;
|
||||
$time_string = $basic->TimeStringFormat($timestamp);
|
||||
$time_string = $basic->timeStringFormat($timestamp);
|
||||
print "TIME STRING TEST: ".$time_string."<br>";
|
||||
print "REVERSE TIME STRING: ".$basic->StringToTime($time_string);
|
||||
print "REVERSE TIME STRING: ".$basic->stringToTime($time_string);
|
||||
|
||||
// magic links test
|
||||
print $basic->magic_links('user@bubu.at').'<br>';
|
||||
print $basic->magic_links('http://test.com/foo/bar.php?foo=1').'<br>';
|
||||
print $basic->magicLinks('user@bubu.at').'<br>';
|
||||
print $basic->magicLinks('http://test.com/foo/bar.php?foo=1').'<br>';
|
||||
|
||||
// compare date
|
||||
$date_1 = '2017/1/5';
|
||||
$date_2 = '2017-01-05';
|
||||
print "COMPARE DATE: ".$basic->CompareDate($date_1, $date_2)."<br>";
|
||||
print "COMPARE DATE: ".$basic->compareDate($date_1, $date_2)."<br>";
|
||||
|
||||
// print error messages
|
||||
print $basic->print_error_msg();
|
||||
print $login->printErrorMsg();
|
||||
print $basic->printErrorMsg();
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
# __END__
|
||||
|
||||
@@ -49,7 +49,7 @@ $login = new CoreLibs\ACL\Login($DB_CONFIG[LOGIN_DB], $lang);
|
||||
|
||||
// create form class
|
||||
$form = new CoreLibs\Output\Form\Generate($DB_CONFIG[MAIN_DB], $lang);
|
||||
$form->db_exec("SET search_path TO ".LOGIN_DB_SCHEMA);
|
||||
$form->dbExec("SET search_path TO ".LOGIN_DB_SCHEMA);
|
||||
if ($form->mobile_phone) {
|
||||
echo "I am sorry, but this page cannot be viewed by a mobile phone";
|
||||
exit;
|
||||
@@ -121,7 +121,7 @@ $HEADER['JAVASCRIPT'] = $EDIT_JAVASCRIPT;
|
||||
$DATA['table_width'] = $table_width;
|
||||
|
||||
// write out error / status messages
|
||||
$messages[] = $form->formErrorMsg();
|
||||
$messages[] = $form->formPrintMsg();
|
||||
$DATA['form_error_msg'] = $messages;
|
||||
|
||||
// MENU START
|
||||
@@ -219,7 +219,7 @@ if ($form->yes) {
|
||||
$elements[] = $form->formCreateElement("db_debug");
|
||||
$elements[] = $form->formCreateElement("edit_language_id");
|
||||
$elements[] = $form->formCreateElement("edit_scheme_id");
|
||||
$elements[] = $form->formShowListTable("edit_access_user");
|
||||
$elements[] = $form->formCreateElementListTable("edit_access_user");
|
||||
break;
|
||||
case "edit_schemes":
|
||||
$elements[] = $form->formCreateElement("enabled");
|
||||
@@ -230,7 +230,7 @@ if ($form->yes) {
|
||||
case "edit_pages":
|
||||
if (!$form->table_array["edit_page_id"]["value"]) {
|
||||
$q = "DELETE FROM temp_files";
|
||||
$form->db_exec($q);
|
||||
$form->dbExec($q);
|
||||
// gets all files in the current dir ending with .php
|
||||
$crap = exec("ls *.php", $output, $status);
|
||||
// now get all that are NOT in de DB
|
||||
@@ -252,12 +252,12 @@ if ($form->yes) {
|
||||
$elements[] = $form->formCreateElement("order_number");
|
||||
$elements[] = $form->formCreateElement("online");
|
||||
$elements[] = $form->formCreateElement("menu");
|
||||
$elements[] = $form->formShowListTable("edit_query_string");
|
||||
$elements[] = $form->formCreateElementListTable("edit_query_string");
|
||||
$elements[] = $form->formCreateElement("popup");
|
||||
$elements[] = $form->formCreateElement("popup_x");
|
||||
$elements[] = $form->formCreateElement("popup_y");
|
||||
$elements[] = $form->formShowReferenceTable("edit_visible_group");
|
||||
$elements[] = $form->formShowReferenceTable("edit_menu_group");
|
||||
$elements[] = $form->formCreateElementReferenceTable("edit_visible_group");
|
||||
$elements[] = $form->formCreateElementReferenceTable("edit_menu_group");
|
||||
break;
|
||||
case "edit_languages":
|
||||
$elements[] = $form->formCreateElement("enabled");
|
||||
@@ -270,7 +270,7 @@ if ($form->yes) {
|
||||
$elements[] = $form->formCreateElement("name");
|
||||
$elements[] = $form->formCreateElement("edit_access_right_id");
|
||||
$elements[] = $form->formCreateElement("edit_scheme_id");
|
||||
$elements[] = $form->formShowListTable("edit_page_access");
|
||||
$elements[] = $form->formCreateElementListTable("edit_page_access");
|
||||
break;
|
||||
case "edit_visible_group":
|
||||
$elements[] = $form->formCreateElement("name");
|
||||
@@ -286,7 +286,7 @@ if ($form->yes) {
|
||||
$elements[] = $form->formCreateElement("color");
|
||||
$elements[] = $form->formCreateElement("description");
|
||||
// add name/value list here
|
||||
$elements[] = $form->formShowListTable("edit_access_data");
|
||||
$elements[] = $form->formCreateElementListTable("edit_access_data");
|
||||
break;
|
||||
default:
|
||||
print "[No valid page definition given]";
|
||||
|
||||
@@ -12,7 +12,7 @@ ob_start();
|
||||
require 'config.inc' ;
|
||||
DEFINE('SET_SESSION_NAME', EDIT_SESSION_NAME);
|
||||
|
||||
echo "CONFIG: ".CONFIG."<br>ROOT: ".ROOT."<br>BASE: ".BASE."<br>";
|
||||
echo "DIR: ".DIR."<br>ROOT: ".ROOT."<br>BASE: ".BASE."<br>";
|
||||
|
||||
$lang = 'en_utf8';
|
||||
$base = new CoreLibs\Admin\Backend($DB_CONFIG[MAIN_DB], $lang);
|
||||
|
||||
23
www/admin/other_test.php
Executable file
23
www/admin/other_test.php
Executable file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Foo;
|
||||
|
||||
class FooBar
|
||||
{
|
||||
public $foo = '';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->foo = 'BAR';
|
||||
}
|
||||
|
||||
public function otherBarBar($wrong)
|
||||
{
|
||||
echo "B: $wrong<br>";
|
||||
}
|
||||
|
||||
public function barBar($wrong)
|
||||
{
|
||||
echo "B: $wrong<br>";
|
||||
}
|
||||
}
|
||||
@@ -91,7 +91,11 @@ class Login extends \CoreLibs\DB\IO
|
||||
$this->log_per_class = 1;
|
||||
|
||||
// create db connection and init base class
|
||||
parent::__construct($db_config, $debug, $db_debug, $echo, $print);
|
||||
if (!parent::__construct($db_config, $debug, $db_debug, $echo, $print)) {
|
||||
echo "Could not connect to DB<br>";
|
||||
// if I can't connect to the DB to auth exit hard. No access allowed
|
||||
exit;
|
||||
}
|
||||
|
||||
// no session could be found at all
|
||||
if (!session_id()) {
|
||||
@@ -104,7 +108,10 @@ class Login extends \CoreLibs\DB\IO
|
||||
// if we have a search path we need to set it, to use the correct DB to login
|
||||
// check what schema to use. if there is a login schema use this, else check if there is a schema set in the config, or fall back to DB_SCHEMA if this exists, if this also does not exists use public schema
|
||||
$SCHEMA = defined('LOGIN_DB_SCHEMA') ? LOGIN_DB_SCHEMA : ($db_config['db_schema'] ? $db_config['db_schema'] : (defined('DB_SCHEMA') ? DB_SCHEMA : 'public'));
|
||||
$this->dbExec("SET search_path TO ".$SCHEMA);
|
||||
// set schema if schema differs to schema set in db conneciton
|
||||
if ($this->dbGetSchema() && $this->dbGetSchema() != $SCHEMA) {
|
||||
$this->dbExec("SET search_path TO ".$SCHEMA);
|
||||
}
|
||||
$this->euid = array_key_exists('EUID', $_SESSION) ? $_SESSION['EUID'] : 0; // if there is none, there is none, saves me POST/GET check
|
||||
// get login vars, are so, can't be changed
|
||||
// prepare
|
||||
|
||||
@@ -308,15 +308,19 @@ class IO extends \CoreLibs\Basic
|
||||
{
|
||||
// start basic class
|
||||
parent::__construct($debug, $echo, $print);
|
||||
// dummy init array for db config if not array
|
||||
if (!is_array($db_config)) {
|
||||
$db_config = array ();
|
||||
}
|
||||
// sets the names (for connect/reconnect)
|
||||
$this->db_name = $db_config['db_name'];
|
||||
$this->db_user = $db_config['db_user'];
|
||||
$this->db_pwd = $db_config['db_pass'];
|
||||
$this->db_host = $db_config['db_host'];
|
||||
$this->db_name = $db_config['db_name'] ?? '';
|
||||
$this->db_user = $db_config['db_user'] ?? '';
|
||||
$this->db_pwd = $db_config['db_pass'] ?? '';
|
||||
$this->db_host = $db_config['db_host'] ?? '';
|
||||
$this->db_port = array_key_exists('db_port', $db_config) ? $db_config['db_port'] : '5432';
|
||||
$this->db_schema = array_key_exists('db_schema', $db_config) ? $db_config['db_schema'] : ''; // do not set to 'public' if not set, because the default is already public
|
||||
$this->db_encoding = array_key_exists('db_encoding', $db_config) ? $db_config['db_encoding'] : '';
|
||||
$this->db_type = 'db_'.$db_config['db_type'];
|
||||
$this->db_type = $db_config['db_type'] ?? '';
|
||||
$this->db_ssl = array_key_exists('db_ssl', $db_config) ? $db_config['db_ssl'] : 'allow';
|
||||
|
||||
// set the target encoding to the DEFAULT_ENCODING if it is one of them: EUC, Shift_JIS, UTF-8
|
||||
@@ -326,13 +330,14 @@ class IO extends \CoreLibs\Basic
|
||||
$this->MAX_QUERY_CALL = 20;
|
||||
|
||||
// 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['11'] = 'No Querystring given';
|
||||
$this->error_string['12'] = 'No Cursor given, no correct query perhaps?';
|
||||
$this->error_string['13'] = 'Query could not be executed without errors';
|
||||
$this->error_string['14'] = 'Can\'t connect to DB server';
|
||||
$this->error_string['15'] = 'Can\'t select DB';
|
||||
$this->error_string['16'] = 'No DB Handler found / connect or reconnect failed';
|
||||
$this->error_string['17'] = 'All db_return* methods work only with SELECT statements, please use db_exec for everything else';
|
||||
$this->error_string['17'] = 'All dbReturn* methods work only with SELECT statements, please use dbExec for everything else';
|
||||
$this->error_string['18'] = 'Query not found in cache. Nothing has been reset';
|
||||
$this->error_string['19'] = 'Wrong PK name given or no PK name given at all, can\'t get Insert ID';
|
||||
$this->error_string['20'] = 'Found given Prepare Statement Name in array, Query not prepared, will use existing one';
|
||||
@@ -361,11 +366,13 @@ class IO extends \CoreLibs\Basic
|
||||
// How can we do this dynamic? eg for non PgSQL
|
||||
// OTOH this whole class is so PgSQL specific
|
||||
// that non PgSQL doesn't make much sense anymore
|
||||
if ($this->db_type == 'pg_sql') {
|
||||
if ($this->db_type == 'pgsql') {
|
||||
$this->db_functions = new \CoreLibs\DB\SQL\PgSQL();
|
||||
} else {
|
||||
// abort error
|
||||
return "Failed to load DB functions for: ".$this->db_type;
|
||||
$this->error_id = 10;
|
||||
$this->__dbError();
|
||||
return false;
|
||||
}
|
||||
|
||||
// connect to DB
|
||||
@@ -381,6 +388,9 @@ class IO extends \CoreLibs\Basic
|
||||
'class_created' => '2000-11-23',
|
||||
'class_author' => 'Clemens Schwaighofer'
|
||||
);
|
||||
|
||||
// all ok return true
|
||||
return true;
|
||||
}
|
||||
|
||||
// METHOD: __destruct
|
||||
@@ -451,12 +461,12 @@ class IO extends \CoreLibs\Basic
|
||||
// WAS : _check_query_for_select
|
||||
// PARAMS: query
|
||||
// RETURN: true if matching, false if not
|
||||
// DESC : checks if query is a SELECT, if not error, 0 return
|
||||
// NOTE : Query needs to start with SELECT. if starts with "with" it is ignored
|
||||
// DESC : checks if query is a SELECT or SHOW, if not error, 0 return
|
||||
// NOTE : Query needs to start with SELECT or SHOW. if starts with "with" it is ignored
|
||||
private function __checkQueryForSelect($query)
|
||||
{
|
||||
// perhaps allow spaces before select ?!?
|
||||
if (!preg_match("/^select /i", $query)) {
|
||||
if (!preg_match("/^(select|show) /i", $query)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -538,11 +548,12 @@ class IO extends \CoreLibs\Basic
|
||||
// NOTE : needed to make public so it can be called from DB.Array.IO too
|
||||
public function __dbError($cursor = '', $msg = '')
|
||||
{
|
||||
$pg_error_string = '';
|
||||
$where_called = $this->get_caller_method();
|
||||
if ($cursor) {
|
||||
$pg_error_string = $this->db_functions->__dbPrintError($cursor);
|
||||
}
|
||||
if (!$cursor) {
|
||||
if (!$cursor && method_exists($this->db_functions, '__dbPrintError')) {
|
||||
$pg_error_string = $this->db_functions->__dbPrintError();
|
||||
}
|
||||
if ($pg_error_string) {
|
||||
@@ -620,7 +631,7 @@ class IO extends \CoreLibs\Basic
|
||||
// WAS : _db_prepare_exec
|
||||
// PARAMS: query, primary key [if set to NULL no returning will be added]
|
||||
// RETURN: md5 OR boolean false on error
|
||||
// DESC : sub function for db_exec and db_exec_async
|
||||
// DESC : sub function for dbExec and dbExecAsync
|
||||
// * checks query is set
|
||||
// * checks there is a database handler
|
||||
// * checks that here is no other query executing
|
||||
@@ -650,7 +661,7 @@ class IO extends \CoreLibs\Basic
|
||||
}
|
||||
}
|
||||
// check that no other query is running right now
|
||||
if ($this->db_functions->__dbConnection_busy()) {
|
||||
if ($this->db_functions->__dbConnectionBusy()) {
|
||||
$this->error_id = 41;
|
||||
$this->__dbError();
|
||||
return false;
|
||||
@@ -774,7 +785,7 @@ class IO extends \CoreLibs\Basic
|
||||
// failed to get insert id
|
||||
$this->insert_id = '';
|
||||
$this->warning_id = 33;
|
||||
$this->__dbError($this->cursor, '[db_exec]');
|
||||
$this->__dbError($this->cursor, '[dbExec]');
|
||||
}
|
||||
// if we have multiple, do not set the insert_id different, keep as array
|
||||
}
|
||||
@@ -782,7 +793,7 @@ class IO extends \CoreLibs\Basic
|
||||
// we returned an array of PKs instread of a single one
|
||||
if (is_array($this->insert_id)) {
|
||||
$this->warning_id = 32;
|
||||
$this->__dbError($this->cursor, '[db_exec]');
|
||||
$this->__dbError($this->cursor, '[dbExec]');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -870,7 +881,7 @@ class IO extends \CoreLibs\Basic
|
||||
return false;
|
||||
}
|
||||
$q = "SET search_path TO '".$this->dbEscapeString($db_schema)."'";
|
||||
return $this->db_exec($q);
|
||||
return $this->dbExec($q);
|
||||
}
|
||||
|
||||
// METHOD: dbGetSchema
|
||||
@@ -897,7 +908,16 @@ class IO extends \CoreLibs\Basic
|
||||
return false;
|
||||
}
|
||||
$q = "SET client_encoding TO '".$this->dbEscapeString($db_encoding)."'";
|
||||
return $this->db_exec($q);
|
||||
return $this->dbExec($q);
|
||||
}
|
||||
|
||||
// METHOD: dbGetEncoding
|
||||
// PARAMS: none
|
||||
// RETURN: current client encoding
|
||||
// DESC : returns the current set client encoding from the connected DB
|
||||
public function dbGetEncoding()
|
||||
{
|
||||
return $this->db_return_row('SHOW client_encoding')['client_encoding'];
|
||||
}
|
||||
|
||||
// METHOD: dbInfo
|
||||
@@ -1009,7 +1029,7 @@ class IO extends \CoreLibs\Basic
|
||||
}
|
||||
}
|
||||
// check that no other query is running right now
|
||||
if ($this->db_functions->__dbConnection_busy()) {
|
||||
if ($this->db_functions->__dbConnectionBusy()) {
|
||||
$this->error_id = 41;
|
||||
$this->__dbError();
|
||||
return false;
|
||||
@@ -1191,7 +1211,7 @@ class IO extends \CoreLibs\Basic
|
||||
{
|
||||
// if there is actually a async query there
|
||||
if ($this->async_running) {
|
||||
if ($this->db_functions->__dbConnection_busy()) {
|
||||
if ($this->db_functions->__dbConnectionBusy()) {
|
||||
return true;
|
||||
} else {
|
||||
// get the result/or error
|
||||
@@ -1250,7 +1270,7 @@ class IO extends \CoreLibs\Basic
|
||||
$this->__dbError('', $query);
|
||||
return false;
|
||||
}
|
||||
$cursor = $this->db_exec($query);
|
||||
$cursor = $this->dbExec($query);
|
||||
$result = $this->dbFetchArray($cursor);
|
||||
return $result;
|
||||
}
|
||||
@@ -1273,7 +1293,7 @@ class IO extends \CoreLibs\Basic
|
||||
$this->__dbError('', $query);
|
||||
return false;
|
||||
}
|
||||
$cursor = $this->db_exec($query);
|
||||
$cursor = $this->dbExec($query);
|
||||
while ($res = $this->dbFetchArray($cursor)) {
|
||||
for ($i = 0; $i < $this->num_fields; $i ++) {
|
||||
// cereated mixed, first name
|
||||
@@ -1361,7 +1381,7 @@ class IO extends \CoreLibs\Basic
|
||||
}
|
||||
}
|
||||
// check that no other query is running right now
|
||||
if ($this->db_functions->__dbConnection_busy()) {
|
||||
if ($this->db_functions->__dbConnectionBusy()) {
|
||||
$this->error_id = 41;
|
||||
$this->__dbError();
|
||||
return false;
|
||||
@@ -1444,7 +1464,7 @@ class IO extends \CoreLibs\Basic
|
||||
return false;
|
||||
} else {
|
||||
if ($this->db_debug) {
|
||||
$this->__dbDebug('db', $this->__dbDebug_prepare($stm_name, $data), 'dbExecPrep', 'Q');
|
||||
$this->__dbDebug('db', $this->__dbDebugPrepare($stm_name, $data), 'dbExecPrep', 'Q');
|
||||
}
|
||||
$code = $this->db_functions->__dbExecute($stm_name, $data);
|
||||
if (!$code) {
|
||||
@@ -1729,7 +1749,7 @@ class IO extends \CoreLibs\Basic
|
||||
$q .= ')';
|
||||
$this->temp_sql = $q;
|
||||
}
|
||||
if (!$this->db_exec($q)) {
|
||||
if (!$this->dbExec($q)) {
|
||||
return false;
|
||||
}
|
||||
if (!$primary_key['value']) {
|
||||
|
||||
@@ -403,7 +403,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
public function formProcedureLoad($archive_id)
|
||||
{
|
||||
if ($this->archive && $archive_id && $this->group_level_user <= $this->security_level["load"]) {
|
||||
$this->form_load_table_array($archive_id);
|
||||
$this->formLoadTableArray($archive_id);
|
||||
$this->yes = 1;
|
||||
}
|
||||
}
|
||||
@@ -417,7 +417,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
{
|
||||
if ($this->new && $this->group_level_user <= $this->security_level["new"]) {
|
||||
if ($this->really_new == "yes") {
|
||||
$this->form_unset_table_array();
|
||||
$this->formUnsetTablearray();
|
||||
} else {
|
||||
$this->msg .= $this->l->__("You have to select the <b>Checkbox for New</b>!<br>");
|
||||
$this->error = 2;
|
||||
@@ -434,9 +434,9 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
public function formProcedureSave()
|
||||
{
|
||||
if ($this->save && $this->group_level_user <= $this->security_level["save"]) {
|
||||
$this->form_error_check();
|
||||
$this->formErrorCheck();
|
||||
if (!$this->error) {
|
||||
$this->form_save_table_array();
|
||||
$this->formSaveTableArray();
|
||||
}
|
||||
$this->yes = 1;
|
||||
}
|
||||
@@ -456,7 +456,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
$this->error = 2;
|
||||
}
|
||||
if ($this->really_delete == "yes") {
|
||||
$this->form_delete_table_array();
|
||||
$this->formDeleteTableArray();
|
||||
} else {
|
||||
$this->msg .= $this->l->__("You have to select the <b>Checkbox for Delete</b>!<br>");
|
||||
$this->error = 2;
|
||||
@@ -492,7 +492,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
|
||||
if ($_POST[$flag] == "true") {
|
||||
$q = "DELETE FROM ".$element_list[$i]." WHERE ".$pk_name." = ".$_POST[$id];
|
||||
$this->db_exec($q);
|
||||
$this->dbExec($q);
|
||||
$this->msg .= $this->l->__("Removed entry from list<br>");
|
||||
$this->warning = 1;
|
||||
} // post okay true -> delete
|
||||
@@ -502,7 +502,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
if (!$_POST[$remove_name[$i]][$j]) {
|
||||
$q = "UPDATE ".$element_list[$i]." WHERE ".$pk_name." = ".$_POST[$prfx.$pk_name][$j];
|
||||
// $this->debug('edit_db', "UP: $q");
|
||||
// $this->db_exec($q);
|
||||
// $this->dbExec($q);
|
||||
$this->msg .= $this->l->__("Disabled deselected entries from list<br>");
|
||||
$this->warning = 1;
|
||||
}
|
||||
@@ -515,7 +515,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
if (!$_POST[$remove_name[$i]][$j] && $_POST[$prfx.$pk_name][$j]) {
|
||||
$q = "DELETE FROM ".$element_list[$i]." WHERE ".$pk_name." = ".$_POST[$prfx.$pk_name][$j];
|
||||
// $this->debug('edit_db', "DEL: $q");
|
||||
$this->db_exec($q);
|
||||
$this->dbExec($q);
|
||||
$this->msg .= $this->l->__("Deleted deselected entries from list<br>");
|
||||
$this->warning = 1;
|
||||
}
|
||||
@@ -539,7 +539,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
$t_pk_name = $this->archive_pk_name;
|
||||
|
||||
// lade liste
|
||||
$this->db_exec($this->load_query);
|
||||
$this->dbExec($this->load_query);
|
||||
while ($res = $this->db_fetch_array()) {
|
||||
$pk_ids[] = $res[$this->int_pk_name];
|
||||
if ($res[$this->int_pk_name] == $this->table_array[$this->int_pk_name]["value"]) {
|
||||
@@ -848,7 +848,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
if ($this->table_array[$this->int_pk_name]["value"]) {
|
||||
$q .= " AND ".$this->int_pk_name." <> ".$this->table_array[$this->int_pk_name]["value"];
|
||||
}
|
||||
list($$key) = $this->db_return_row($q);
|
||||
list($$key) = $this->dbReturnRow($q);
|
||||
if ($$key) {
|
||||
$this->msg .= sprintf($this->l->__("The field <b>%s</b> can be used only once!<br>"), $this->table_array[$key]["output_name"]);
|
||||
}
|
||||
@@ -1003,7 +1003,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
if ($this->table_array[$this->int_pk_name]["value"]) {
|
||||
$q .= " AND ".$this->int_pk_name." <> ".$this->table_array[$this->int_pk_name]["value"];
|
||||
}
|
||||
list($$key) = $this->db_return_row($q);
|
||||
list($$key) = $this->dbReturnRow($q);
|
||||
if ($$key) {
|
||||
$this->msg .= sprintf($this->l->__("The field <b>%s</b> in row <b>%s</b> can be used only once!<br>"), $reference_array["output_name"], $i);
|
||||
}
|
||||
@@ -1046,21 +1046,21 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
public function formSetOrder()
|
||||
{
|
||||
// get order name
|
||||
$order_name = $this->form_get_col_name_from_key("order");
|
||||
$order_name = $this->formGetColNameFromKey("order");
|
||||
if ($order_name) {
|
||||
// first check out of order ...
|
||||
|
||||
if (!$this->table_array[$order_name]["value"]) {
|
||||
// set order (read max)
|
||||
$q = "SELECT MAX(".$order_name.") + 1 AS max_page_order FROM ".$this->table_name;
|
||||
list($this->table_array[$order_name]["value"]) = $this->db_return_row($q);
|
||||
list($this->table_array[$order_name]["value"]) = $this->dbReturnRow($q);
|
||||
// frist element is 0 because NULL gets returned, set to 1
|
||||
if (!$this->table_array[$order_name]["value"]) {
|
||||
$this->table_array[$order_name]["value"] = 1;
|
||||
}
|
||||
} elseif ($this->table_array[$this->int_pk_name]["value"]) {
|
||||
$q = "SELECT $order_name FROM ".$this->table_name." WHERE ".$this->int_pk_name." = ".$this->table_array[$this->int_pk_name]["value"];
|
||||
list($this->table_array[$order_name]["value"]) = $this->db_return_row($q);
|
||||
list($this->table_array[$order_name]["value"]) = $this->dbReturnRow($q);
|
||||
}
|
||||
}
|
||||
return $this->table_array;
|
||||
@@ -1163,20 +1163,20 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
if ($this->table_array[$key]["where"]) {
|
||||
$q .= " AND ".$this->table_array[$key]["where"];
|
||||
}
|
||||
list($pk_name_temp) = $this->db_return_row($q);
|
||||
list($pk_name_temp) = $this->dbReturnRow($q);
|
||||
if ($this->num_rows >= 1) {
|
||||
$this->table_array[$key]["value"] = $pk_name_temp;
|
||||
} else {
|
||||
// if a where was given, set this key also [dangerous!]
|
||||
// postgreSQL compatible insert
|
||||
$q = "INSERT INTO ".$this->table_array[$key]["table_name"]." (".$this->table_array[$key]["input_name"].") VALUES ('".$this->db_escape_string($this->table_array[$key]["input_value"])."')";
|
||||
$this->db_exec($q);
|
||||
$this->dbExec($q);
|
||||
if ($this->table_array[$key]["where"]) {
|
||||
// make an update on the just inseted data with the where data als update values
|
||||
$q = "UPDATE ".$this->table_array[$key]["table_name"]." SET ";
|
||||
$q .= $this->table_array[$key]["where"]." ";
|
||||
$q .= "WHERE ".$this->table_array[$key]["pk_name"]." = ".$this->insert_id;
|
||||
$this->db_exec($q);
|
||||
$this->dbExec($q);
|
||||
}
|
||||
$this->table_array[$key]["value"] = $this->insert_id;
|
||||
} // set value from DB through select or insert
|
||||
@@ -1192,7 +1192,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
if ($this->table_array[$key]["where"]) {
|
||||
$q .= " AND ".$this->table_array[$key]["where"];
|
||||
}
|
||||
list($temp) = $this->db_return_row($q);
|
||||
list($temp) = $this->dbReturnRow($q);
|
||||
// nothing found in table, use new inserted key
|
||||
if (!$temp) {
|
||||
$this->table_array[$key]["value"] = $this->table_array[$key]["input_value"];
|
||||
@@ -1250,9 +1250,9 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
} // go through each field
|
||||
|
||||
// set object order (if necessary)
|
||||
$this->form_set_order();
|
||||
$this->formSetOrder();
|
||||
// write the object
|
||||
$this->db_write($addslashes);
|
||||
$this->dbWrite($addslashes);
|
||||
// write reference array(s) if necessary
|
||||
if (is_array($this->reference_array)) {
|
||||
if (!is_array($this->reference_array)) {
|
||||
@@ -1261,11 +1261,11 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
reset($this->reference_array);
|
||||
foreach ($this->reference_array as $reference_array) {
|
||||
$q = "DELETE FROM ".$reference_array["table_name"]." WHERE ".$this->int_pk_name."=".$this->table_array[$this->int_pk_name]["value"];
|
||||
$this->db_exec($q);
|
||||
$this->dbExec($q);
|
||||
$q = "INSERT INTO ".$reference_array["table_name"]." (".$reference_array["other_table_pk"].", ".$this->int_pk_name.") VALUES ";
|
||||
for ($i = 0; $i < count($reference_array["selected"]); $i ++) {
|
||||
$t_q = "(".$reference_array["selected"][$i].", ".$this->table_array[$this->int_pk_name]["value"].")";
|
||||
$this->db_exec($q.$t_q);
|
||||
$this->dbExec($q.$t_q);
|
||||
}
|
||||
} // foreach reference arrays
|
||||
} // if reference arrays
|
||||
@@ -1383,7 +1383,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
$this->debug('edit', "Pos[$i] => ".$type[$i]." Q: ".$q."<br>");
|
||||
// write the dataset
|
||||
if ($q) {
|
||||
$this->db_exec($q);
|
||||
$this->dbExec($q);
|
||||
}
|
||||
}
|
||||
} // for each created query
|
||||
@@ -1408,7 +1408,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
reset($this->reference_array);
|
||||
foreach ($this->reference_array as $reference_array) {
|
||||
$q = "DELETE FROM ".$reference_array["table_name"]." WHERE ".$this->int_pk_name." = ".$this->table_array[$this->int_pk_name]["value"];
|
||||
$this->db_exec($q);
|
||||
$this->dbExec($q);
|
||||
}
|
||||
}
|
||||
// remove any element list references
|
||||
@@ -1419,7 +1419,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
reset($this->element_list);
|
||||
while (list($table_name, $data_array) = each($this->element_list)) {
|
||||
$q = "DELETE FROM ".$table_name." WHERE ".$this->int_pk_name." = ".$this->table_array[$this->int_pk_name]["value"];
|
||||
$this->db_exec($q);
|
||||
$this->dbExec($q);
|
||||
}
|
||||
}
|
||||
// unlink ALL files
|
||||
@@ -1486,7 +1486,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
}
|
||||
|
||||
// METHOD: formCreateElementListTable
|
||||
// WAS : form_create_element_list
|
||||
// WAS : form_create_element_list_table
|
||||
// PARAMS: show which element list
|
||||
// RETURN: array for output
|
||||
// DESC : create list of elements next to each other for a group of data in an input field
|
||||
@@ -1684,4 +1684,4 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
}
|
||||
} // end of class
|
||||
|
||||
# __END__
|
||||
# __END__
|
||||
|
||||
@@ -13,11 +13,17 @@ if (class_exists('Autoload', false) === false) {
|
||||
// to load that class
|
||||
public static function load($class)
|
||||
{
|
||||
print "(1) Class: $class / DIR: ".__DIR__."<br>";
|
||||
// print "(1) Class: $class / DIR: ".__DIR__."<br>";
|
||||
// set directory seperator (we need to replace from namespace)
|
||||
$ds = DS ?? DIRECTORY_SEPARATOR;
|
||||
// base lib
|
||||
$LIB = LIB ?? 'lib'.DS;
|
||||
$LIB = LIB ?? 'lib';
|
||||
// if lib is in path, do not add lib again
|
||||
if (strpos(__DIR__, $LIB) !== false) {
|
||||
$LIB .= DS;
|
||||
} else {
|
||||
$LIB = '';
|
||||
}
|
||||
// default path is unset
|
||||
$path = false;
|
||||
// set path on full dir
|
||||
@@ -32,10 +38,10 @@ if (class_exists('Autoload', false) === false) {
|
||||
$path = __DIR__.$ds.$LIB.substr($class, $len);
|
||||
// replace namespace \ with dir sepeator
|
||||
$path = str_replace('\\', $ds, $path).$extension;
|
||||
print "(2) Class clean: $path<br>";
|
||||
// print "(2) Class clean: $path<br>";
|
||||
// if path is set and a valid file
|
||||
if ($path !== false && is_file($path)) {
|
||||
echo "<b>(3)</b> Load Path: $path<br>";
|
||||
// echo "<b>(3)</b> Load Path: $path<br>";
|
||||
// we should sub that
|
||||
// self::loadFile($path);
|
||||
include $path;
|
||||
@@ -45,7 +51,6 @@ if (class_exists('Autoload', false) === false) {
|
||||
}
|
||||
} // end class define
|
||||
|
||||
// auto loader
|
||||
spl_autoload_register('Autoloader\Autoload::load', true, true);
|
||||
} // end check for already defined
|
||||
|
||||
Reference in New Issue
Block a user