dbInfo(true);
ob_end_flush();
echo "DB_CONFIG_SET constant:
".print_r(DB_CONFIG, true)."
";
$basic->hrRunningTime();
$basic->runningTime();
echo "RANDOM KEY [50]: ".$basic->randomKeyGen(50)."
";
echo "TIMED [hr]: ".$basic->hrRunningTime()."
";
echo "TIMED [def]: ".$basic->runningTime()."
";
echo "TIMED [string]: ".$basic->runningtime_string."
";
$basic->hrRunningTime();
echo "RANDOM KEY [default]: ".$basic->randomKeyGen()."
";
echo "TIMED [hr]: ".$basic->hrRunningTime()."
";
// color
print "COLOR: -1, -1, -1: ".$basic->rgb2hex(-1, -1, -1)."
";
print "COLOR: 10, 20, 30: ".$basic->rgb2hex(10, 20, 30)."
";
// set + check edit access id
$edit_access_id = 3;
if (is_object($login) && isset($login->acl['unit'])) {
print "ACL UNIT: ".print_r(array_keys($login->acl['unit']), true)."
";
print "ACCESS CHECK: ".(string)$login->loginCheckEditAccess($edit_access_id)."
";
if ($login->loginCheckEditAccess($edit_access_id)) {
$basic->edit_access_id = $edit_access_id;
} else {
$basic->edit_access_id = $login->acl['unit_id'];
}
} else {
print "Something went wrong with the login
";
}
// $basic->debug('SESSION', $basic->print_ar($_SESSION));
print "TEST CLASS";
print "";
print '';
// print the debug core vars
print "DEBUG OUT: ".$basic->debug_output."
";
print "ECHO OUT: ".$basic->echo_output."
";
print "PRINT OUT: ".$basic->print_output."
";
print "NOT DEBUG OUT: ".$basic->debug_output_not."
";
print "NOT ECHO OUT: ".$basic->echo_output_not."
";
print "NOT PRINT OUT: ".$basic->print_output_not."
";
print "DEBUG OUT ALL: ".$basic->debug_output_all."
";
print "ECHO OUT ALL: ".$basic->echo_output_all."
";
print "PRINT OUT ALL: ".$basic->print_output_all."
";
print "CALLER BACKTRACE: ".$basic->getCallerMethod()."
";
$basic->debug('SOME MARK', 'Some error output');
print "EDIT ACCESS ID: ".$basic->edit_access_id."
";
if (is_object($login)) {
// print "ACL:
".$basic->print_ar($login->acl)."
";
$basic->debug('ACL', "ACL: ".$basic->printAr($login->acl));
// print "DEFAULT ACL:
".$basic->print_ar($login->default_acl_list)."
";
// print "DEFAULT ACL:
".$basic->print_ar($login->default_acl_list)."
";
// $result = array_flip(array_filter(array_flip($login->default_acl_list), function ($key) { if (is_numeric($key)) return $key; }));
// print "DEFAULT ACL:
".$basic->print_ar($result)."
";
// DEPRICATED CALL
// $basic->adbSetACL($login->acl);
}
// DB client encoding
print "DB Client encoding: ".$basic->dbGetEncoding()."
";
while ($res = $basic->dbReturn("SELECT * FROM max_test", 0, true)) {
print "TIME: ".$res['time']."
";
}
print "CACHED DATA: ".print_r($basic->cursor_ext, true)."
";
while ($res = $basic->dbReturn("SELECT * FROM max_test")) {
print "[CACHED] TIME: ".$res['time']."
";
}
$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, true)."
";
print "DIRECT INSERT PREVIOUS INSERTED: ".print_r($basic->dbReturnRow("SELECT foo_id, test FROM foo WHERE foo_id = ".$basic->insert_id), true)."
";
$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, true)."
";
print "PREPARE INSERT PREVIOUS INSERTED: ".print_r($basic->dbReturnRow("SELECT foo_id, test FROM foo WHERE foo_id = ".$basic->insert_id), true)."
";
// 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->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, true)." | PRIMARY KEY EXT: ".print_r($basic->insert_id_ext, true)."
";
// no returning, but not needed ;
$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, true)."
";
// UPDATE WITH RETURNING
$status = $basic->dbExec("UPDATE foo SET test = 'SOMETHING DIFFERENT' WHERE foo_id = 3688452 RETURNING test");
print "UPDATE STATUS: $status | RETURNING EXT: ".print_r($basic->insert_id_ext, true)."
";
# db write class test
$table = 'foo';
print "TABLE META DATA: ".$basic->printAr($basic->dbShowTableMetaData($table))."
";
$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->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
";
$data = array('test' => 'BOOL TEST ON '.time(), 'string_a' => '', 'number_a' => 0, 'some_bool' => 1);
$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
";
$data = array('test' => 'BOOL TEST OFF '.time(), 'string_a' => null, 'number_a' => null, 'some_bool' => 0);
$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
";
$data = array('test' => 'BOOL TEST UNSET '.time());
$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
";
// return Array Test
$query = "SELECT type, sdate, integer FROM foobar";
$data = $basic->dbReturnArray($query, true);
print "Full foobar list:
".print_r($data, true)."
";
# async test queries
/* $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->dbCheckAsync()) === true)
{
if ((list($_, $char) = each($chars)) === FALSE)
{
reset($chars);
list($_, $char) = each($chars);
}
print $char;
sleep(1);
flush();
}
print "
END STATUS: ".$ret."
";
// while ($res = $basic->dbFetchArray($ret))
while ($res = $basic->dbFetchArray())
{
echo "RES: ".$res['test']."
";
}
# test async insert
$basic->dbExecAsync("INSERT INTO foo (Test) VALUES ('ASYNC TEST ".time()."')");
echo "WAITING FOR ASYNC INSERT: ";
while (($ret = $basic->dbCheckAsync()) === true)
{
print ".";
sleep(1);
flush();
}
print "
END STATUS: ".$ret." | PK: ".$basic->insert_id."
";
print "ASYNC PREVIOUS INSERTED: ".print_r($basic->dbReturnRow("SELECT foo_id, test FROM foo WHERE foo_id = ".$basic->insert_id), true)."
"; */
$to_db_version = '9.1.9';
print "VERSION DB: ".$basic->dbVersion()."
";
print "DB Version smaller $to_db_version: ".$basic->dbCompareVersion('<'.$to_db_version)."
";
print "DB Version smaller than $to_db_version: ".$basic->dbCompareVersion('<='.$to_db_version)."
";
print "DB Version equal $to_db_version: ".$basic->dbCompareVersion('='.$to_db_version)."
";
print "DB Version bigger than $to_db_version: ".$basic->dbCompareVersion('>='.$to_db_version)."
";
print "DB Version bigger $to_db_version: ".$basic->dbCompareVersion('>'.$to_db_version)."
";
/* $q = "SELECT FOO FRO BAR";
// $q = "Select * from foo";
$foo = $basic->dbExecAsync($q);
print "[ERR] Query: ".$q."
";
print "[ERR] RESOURCE: $foo
";
while (($ret = $basic->dbCheckAsync()) === true)
{
print "[ERR]: $ret
";
sleep(5);
} */
// search path check
$q = "SHOW search_path";
$cursor = $basic->dbExec($q);
$data = $basic->dbFetchArray($cursor)['search_path'];
print "RETURN DATA FOR search_path: ".$data."
";
// print "RETURN DATA FOR search_path: ".$basic->printAr($data)."
";
// insert something into test.schema_test and see if we get the PK back
$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."
";
print "NULL TEST DB READ
";
$q = "SELECT uid, null_varchar, null_int FROM test_null_data WHERE uid = 'A'";
$res = $basic->dbReturnRow($q);
var_dump($res);
print "RES: ".$basic->printAr($res)."
";
print "ISSET: ".isset($res['null_varchar'])."
";
print "EMPTY: ".empty($res['null_varchar'])."
";
// data read test
// time string thest
$timestamp = 5887998.33445;
$time_string = $basic->timeStringFormat($timestamp);
print "PLANE TIME STRING: ".$timestamp."
";
print "TIME STRING TEST: ".$time_string."
";
print "REVERSE TIME STRING: ".$basic->stringToTime($time_string)."
";
if (round($timestamp, 4) == $basic->stringToTime($time_string)) {
print "REVERSE TIME STRING MATCH
";
} else {
print "REVERSE TRIME STRING DO NOT MATCH
";
}
print "ZERO TIME STRING: ".$basic->timeStringFormat(0, true)."
";
print "ZERO TIME STRING: ".$basic->timeStringFormat(0.0, true)."
";
print "ZERO TIME STRING: ".$basic->timeStringFormat(1.005, true)."
";
echo "HTML ENT INT: ".$basic->htmlent(5)."
";
echo "HTML ENT STRING: ".$basic->htmlent('5<<>')."
";
echo "HTML ENT NULL: ".$basic->htmlent(null)."
";
// magic links test
print $basic->magicLinks('user@bubu.at').'
';
print $basic->magicLinks('http://test.com/foo/bar.php?foo=1').'
';
// compare date
$date_1 = '2017/1/5';
$date_2 = '2017-01-05';
print "COMPARE DATE: ".$basic->compareDate($date_1, $date_2)."
";
// recursive array search
$test_array = array(
'foo' => 'bar',
'input' => array(
'element_a' => array(
'type' => 'text'
),
'element_b' => array(
'type' => 'email'
),
'element_c' => array(
'type' => 'email'
)
)
);
echo "SOURCE ARRAY: ".$basic->printAr($test_array)."
";
echo "FOUND ELEMENTS [base]: ".$basic->printAr($basic->arraySearchRecursive('email', $test_array, 'type'))."
";
echo "FOUND ELEMENTS [input]: ".$basic->printAr($basic->arraySearchRecursive('email', $test_array['input'], 'type'))."
";
// *** BYTES TEST ***
$bytes = array(
-123123123,
999999, // KB-1
999999999, // MB-1
254779258, // MB-n
999999999999999, // TB-1
588795544887632, // TB-n
999999999999999999, // PB-1
9223372036854775807, // MAX INT
999999999999999999999, // EB-1
);
print "BYTE FORMAT TESTS
";
foreach ($bytes as $byte) {
print '';
//
print '
';
print "(".number_format($byte)."/".$byte.") bytes :";
print '
';
print $basic->humanReadableByteFormat($byte);
print "
";
//
print "
";
//
print '';
//
print '
';
print "bytes [si]:";
print '
';
// print $basic->byteStringFormat($byte, true, false, true);
print $basic->humanReadableByteFormat($byte, $basic::BYTE_FORMAT_SI);
print "
";
//
print "
";
}
// *** IMAGE TESTS ***
echo "
";
// image thumbnail
$images = array(
// height bigger
// 'no_picture.jpg',
// 'no_picture.png',
// width bigger
// 'no_picture_width_bigger.jpg',
// 'no_picture_width_bigger.png',
// square
// 'no_picture_square.jpg',
// 'no_picture_square.png',
// other sample images
// '5c501af48da6c.jpg',
// Apple HEIC files
// 'img_2145.heic',
// Photoshop
'photoshop_test.psd',
);
$thumb_width = 250;
$thumb_height = 300;
// return mime type ala mimetype
$finfo = new finfo(FILEINFO_MIME_TYPE);
foreach ($images as $image) {
$image = BASE.LAYOUT.CONTENT_PATH.IMAGES.$image;
list ($height, $width, $img_type) = getimagesize($image);
echo "IMAGE INFO: ".$height."x".$width.", TYPE: ".$img_type." [".$finfo->file($image)."]
";
// rotate image first
$basic->correctImageOrientation($image);
// thumbnail tests
echo "".basename($image).": WIDTH: $thumb_width
.)
";
echo "".basename($image).": HEIGHT: $thumb_height
.)
";
echo "".basename($image).": WIDTH/HEIGHT: $thumb_width x $thumb_height
.)
";
// test with dummy
echo "".basename($image).": WIDTH/HEIGHT: $thumb_width x $thumb_height (+DUMMY)
.)
";
echo "
";
}
// print error messages
// print $login->printErrorMsg();
print $basic->printErrorMsg();
print "";
# __END__