Code clean up for Basic Class clean up
Fix all other class code for calling former Basic class methods. Also try to replace all remaining array() calls to [] type Some docblock updates when missing or wrong set
This commit is contained in:
@@ -121,7 +121,7 @@ class Login extends \CoreLibs\DB\IO
|
||||
public function __construct(array $db_config)
|
||||
{
|
||||
// log login data for this class only
|
||||
$this->log_per_class = 1;
|
||||
$this->log->setLogPer('class', true);
|
||||
|
||||
// create db connection and init base class
|
||||
parent::__construct($db_config);
|
||||
@@ -629,24 +629,6 @@ class Login extends \CoreLibs\DB\IO
|
||||
}
|
||||
}
|
||||
|
||||
// METHOD: loginSetAcl
|
||||
// WAS : login_set_acl
|
||||
// PARAMS: none
|
||||
// RETURN: none
|
||||
// DESC : sets all the basic ACLs
|
||||
// init set the basic acl the user has, based on the following rules
|
||||
// * init set from config DEFAULT ACL
|
||||
// * if page ACL is set, it overrides the default ACL
|
||||
// * if group ACL is set, it overrides the page ACL
|
||||
// * if user ACL is set, it overrides the group ACL
|
||||
// set the page ACL
|
||||
// * default ACL set
|
||||
// * set group ACL if not default overrides default ACL
|
||||
// * set page ACL if not default overrides group ACL
|
||||
// set edit access ACL and set default edit access group
|
||||
// * if an account ACL is set, set this parallel, account ACL overrides user ACL if it applies
|
||||
// * if edit access ACL level is set, use this, else use page
|
||||
// set all base ACL levels as a list keyword -> ACL number
|
||||
/**
|
||||
* sets all the basic ACLs
|
||||
* init set the basic acl the user has, based on the following rules
|
||||
|
||||
@@ -65,8 +65,6 @@ class Basic
|
||||
private $session_name = '';
|
||||
private $session_id = '';
|
||||
|
||||
// form token (used for form validation)
|
||||
// private $form_token = '';
|
||||
// ajax flag
|
||||
protected $ajax_page_flag = false;
|
||||
|
||||
@@ -75,11 +73,6 @@ class Basic
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// set per run UID for logging
|
||||
$this->running_uid = \CoreLibs\Create\Uids::uniqId();
|
||||
// running time start for script
|
||||
$this->script_starttime = microtime(true);
|
||||
|
||||
// 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
|
||||
$abort = false;
|
||||
@@ -150,17 +143,13 @@ class Basic
|
||||
}
|
||||
}
|
||||
|
||||
// METHOD: __destruct
|
||||
// PARAMS: none
|
||||
// RETURN: if debug is on, return error data
|
||||
// DESC : basic deconstructor (should be called from all deconstructors in higher classes)
|
||||
// writes out $error_msg to global var
|
||||
/**
|
||||
* deconstructor
|
||||
* basic deconstructor (should be called from all deconstructors in higher classes)
|
||||
* writes out $error_msg to global var
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
// this has to be changed, not returned here, this is the last class to close
|
||||
// return $this->error_msg;
|
||||
// close open file handles
|
||||
// $this->fdebugFP('c');
|
||||
}
|
||||
|
||||
// *************************************************************
|
||||
@@ -243,7 +232,7 @@ class Basic
|
||||
* writes a string to a file immediatly, for fast debug output
|
||||
* @param string $string string to write to the file
|
||||
* @param boolean $enter default true, if set adds a linebreak \n at the end
|
||||
* @return void has no return
|
||||
* @return bool True of False for success of writing
|
||||
* @deprecated Use \CoreLibs\Debug\FileWriter::fdebug() instead
|
||||
*/
|
||||
public function fdebug(string $string, bool $enter = true): bool
|
||||
@@ -267,6 +256,7 @@ class Basic
|
||||
public function debugFor(string $type, string $flag): void
|
||||
{
|
||||
trigger_error('Method '.__METHOD__.' is deprecated, use $basic->log->debugFor() or use \CoreLibs\Debug\Logging() class', E_USER_DEPRECATED);
|
||||
/** @phan-suppress-next-line PhanTypeMismatchArgumentReal */
|
||||
$this->log->debugFor(...[func_get_args()]);
|
||||
}
|
||||
|
||||
@@ -456,8 +446,8 @@ class Basic
|
||||
* prints a html formatted (pre) array
|
||||
* @param array $array any array
|
||||
* @return string formatted array for output with <pre> tag added
|
||||
* DEPRCATE LATER
|
||||
* @_deprecated Use \CoreLibs\Debug\Support::printAr() instead
|
||||
* DEPRCATE HARD LATER
|
||||
* @deprecated Use \CoreLibs\Debug\Support::printAr() instead
|
||||
*/
|
||||
public static function printAr(array $array): string
|
||||
{
|
||||
@@ -1336,10 +1326,10 @@ class Basic
|
||||
* converts RGB to HSB/V values
|
||||
* returns:
|
||||
* array with hue (0-360), sat (0-100%), brightness/value (0-100%)
|
||||
* @param int $r red 0-255
|
||||
* @param int $g green 0-255
|
||||
* @param int $b blue 0-255
|
||||
* @return array Hue, Sat, Brightness/Value
|
||||
* @param int $red red 0-255
|
||||
* @param int $green green 0-255
|
||||
* @param int $blue blue 0-255
|
||||
* @return array Hue, Sat, Brightness/Value
|
||||
* @deprecated use \CoreLibs\Convert\Colors::rgb2hsb() instead
|
||||
*/
|
||||
public static function rgb2hsb(int $red, int $green, int $blue): array
|
||||
@@ -1571,7 +1561,7 @@ class Basic
|
||||
public function mimeSetAppName(string $mime, string $app): void
|
||||
{
|
||||
trigger_error('Method '.__METHOD__.' is deprecated, use \CoreLibs\Convert\MimeAppName()->mimeSetAppName()', E_USER_DEPRECATED);
|
||||
$this->mime->mimeSetAppName($mime, $app);
|
||||
\CoreLibs\Convert\MimeAppName::mimeSetAppName($mime, $app);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1584,7 +1574,7 @@ class Basic
|
||||
public function mimeGetAppName(string $mime): string
|
||||
{
|
||||
trigger_error('Method '.__METHOD__.' is deprecated, use \CoreLibs\Convert\MimeAppName()->mimeGetAppName()', E_USER_DEPRECATED);
|
||||
return $this->mime->mimeGetAppName($mime);
|
||||
return \CoreLibs\Convert\MimeAppName::mimeGetAppName($mime);
|
||||
}
|
||||
|
||||
// *** MIME PARTS END ***
|
||||
|
||||
@@ -19,9 +19,9 @@ class ArrayHandler
|
||||
*/
|
||||
public static function arraySearchRecursive($needle, array $haystack, ?string $key_lookin = null): array
|
||||
{
|
||||
$path = array();
|
||||
$path = [];
|
||||
if (!is_array($haystack)) {
|
||||
$haystack = array();
|
||||
$haystack = [];
|
||||
}
|
||||
if ($key_lookin != null &&
|
||||
!empty($key_lookin) &&
|
||||
@@ -72,21 +72,21 @@ class ArrayHandler
|
||||
{
|
||||
// init if not set on null
|
||||
if ($path === null) {
|
||||
$path = array(
|
||||
$path = [
|
||||
'level' => 0,
|
||||
'work' => array()
|
||||
);
|
||||
'work' => []
|
||||
];
|
||||
}
|
||||
// init sub sets if not set
|
||||
if (!isset($path['level'])) {
|
||||
$path['level'] = 0;
|
||||
}
|
||||
if (!isset($path['work'])) {
|
||||
$path['work'] = array();
|
||||
$path['work'] = [];
|
||||
}
|
||||
// should not be needed because it would trigger a php mehtod error
|
||||
if (!is_array($haystack)) {
|
||||
$haystack = array();
|
||||
$haystack = [];
|
||||
}
|
||||
|
||||
// @phan HACK
|
||||
@@ -112,7 +112,7 @@ class ArrayHandler
|
||||
}
|
||||
// @phan HACK
|
||||
$path['level'] = $path['level'] ?? 0;
|
||||
$path['work'] = $path['work'] ?? array();
|
||||
$path['work'] = $path['work'] ?? [];
|
||||
// cut all that is >= level
|
||||
array_splice($path['work'], $path['level']);
|
||||
// step back a level
|
||||
@@ -130,7 +130,7 @@ class ArrayHandler
|
||||
public static function arraySearchSimple(array $array, $key, $value): bool
|
||||
{
|
||||
if (!is_array($array)) {
|
||||
$array = array();
|
||||
$array = [];
|
||||
}
|
||||
foreach ($array as $_key => $_value) {
|
||||
// if value is an array, we search
|
||||
@@ -177,7 +177,7 @@ class ArrayHandler
|
||||
trigger_error(__FUNCTION__.' needs two or more array arguments', E_USER_WARNING);
|
||||
return false;
|
||||
}
|
||||
$merged = array();
|
||||
$merged = [];
|
||||
while ($arrays) {
|
||||
$array = array_shift($arrays);
|
||||
if (!is_array($array)) {
|
||||
@@ -234,7 +234,7 @@ class ArrayHandler
|
||||
if (!is_array($haystack)) {
|
||||
return false;
|
||||
}
|
||||
$found = array();
|
||||
$found = [];
|
||||
foreach ($needle as $element) {
|
||||
if (in_array($element, $haystack)) {
|
||||
$found[] = $element;
|
||||
@@ -257,7 +257,7 @@ class ArrayHandler
|
||||
*/
|
||||
public static function genAssocArray(array $db_array, $key, $value, bool $set_only = false): array
|
||||
{
|
||||
$ret_array = array();
|
||||
$ret_array = [];
|
||||
// do this to only run count once
|
||||
for ($i = 0, $iMax = count($db_array); $i < $iMax; $i ++) {
|
||||
// if no key then we make an order reference
|
||||
@@ -283,7 +283,7 @@ class ArrayHandler
|
||||
*/
|
||||
public static function flattenArray(array $array): array
|
||||
{
|
||||
$return = array();
|
||||
$return = [];
|
||||
array_walk_recursive(
|
||||
$array,
|
||||
function ($value) use (&$return) {
|
||||
@@ -298,13 +298,13 @@ class ArrayHandler
|
||||
* @param array $array multidemnsional array to flatten
|
||||
* @return array flattened keys array
|
||||
*/
|
||||
public static function flattenArrayKey(array $array/*, array $return = array()*/): array
|
||||
public static function flattenArrayKey(array $array): array
|
||||
{
|
||||
$return = array();
|
||||
$return = [];
|
||||
array_walk_recursive(
|
||||
$array,
|
||||
function ($value, $key) use (&$return) {
|
||||
$return [] = $key;
|
||||
$return[] = $key;
|
||||
}
|
||||
);
|
||||
return $return;
|
||||
@@ -320,7 +320,7 @@ class ArrayHandler
|
||||
public static function arrayFlatForKey(array $array, $search): array
|
||||
{
|
||||
if (!is_array($array)) {
|
||||
$array = array();
|
||||
$array = [];
|
||||
}
|
||||
foreach ($array as $key => $value) {
|
||||
// if it is not an array do just nothing
|
||||
|
||||
@@ -42,7 +42,7 @@ class DateTime
|
||||
if ((int)$timestamp < 0) {
|
||||
$negative = true;
|
||||
}
|
||||
$timestamp = abs($timestamp);
|
||||
$timestamp = abs((float)$timestamp);
|
||||
$timegroups = [86400, 3600, 60, 1];
|
||||
$labels = ['d', 'h', 'm', 's'];
|
||||
$time_string = '';
|
||||
|
||||
@@ -227,7 +227,7 @@ class Colors
|
||||
} else {
|
||||
$sat = $chroma / (1 - abs(2 * $lum - 1));
|
||||
if ($max == $red) {
|
||||
$hue = fmod((($green - $blue) / $chrome), 6);
|
||||
$hue = fmod((($green - $blue) / $chroma), 6);
|
||||
if ($hue < 0) {
|
||||
$hue = (6 - fmod(abs($hue), 6));
|
||||
}
|
||||
@@ -248,10 +248,10 @@ class Colors
|
||||
|
||||
/**
|
||||
* converts an HSL to RGB
|
||||
* @param int $h hue: 0-360 (degrees)
|
||||
* @param float $s saturation: 0-100
|
||||
* @param float $l luminance: 0-100
|
||||
* @return array red/blue/green 0-255 each
|
||||
* @param int $hue hue: 0-360 (degrees)
|
||||
* @param float $sat saturation: 0-100
|
||||
* @param float $lum luminance: 0-100
|
||||
* @return array red/blue/green 0-255 each
|
||||
*/
|
||||
public static function hsl2rgb(int $hue, float $sat, float $lum): array
|
||||
{
|
||||
|
||||
@@ -9,25 +9,14 @@ namespace CoreLibs\Convert;
|
||||
|
||||
class MimeAppName
|
||||
{
|
||||
private $mime_apps= [];
|
||||
private static $mime_apps = [];
|
||||
|
||||
/**
|
||||
* constructor: init mime list
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->mimeInitApps();
|
||||
}
|
||||
|
||||
/**
|
||||
* init array for mime type to application name lookup
|
||||
* @return void
|
||||
*/
|
||||
private function mimeInitApps(): void
|
||||
{
|
||||
// match mime type to some application description
|
||||
// this is NOT translated
|
||||
$this->mime_apps = [
|
||||
self::$mime_apps = [
|
||||
// zip
|
||||
'application/zip' => 'Zip File',
|
||||
// Powerpoint
|
||||
@@ -67,9 +56,9 @@ class MimeAppName
|
||||
* @param string $app Applicaiton name
|
||||
* @return void
|
||||
*/
|
||||
public function mimeSetAppName(string $mime, string $app): void
|
||||
public static function mimeSetAppName(string $mime, string $app): void
|
||||
{
|
||||
$this->mime_apps[$mime] = $app;
|
||||
self::$mime_apps[$mime] = $app;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,9 +67,9 @@ class MimeAppName
|
||||
* @param string $mime MIME Name
|
||||
* @return string Application name matching
|
||||
*/
|
||||
public function mimeGetAppName(string $mime): string
|
||||
public static function mimeGetAppName(string $mime): string
|
||||
{
|
||||
return $this->mime_apps[$mime] ?? 'Other file';
|
||||
return self::$mime_apps[$mime] ?? 'Other file';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,14 +10,6 @@
|
||||
* table from the connected DB.
|
||||
* you don't have to write any SQL queries, worry over update/insert
|
||||
*
|
||||
* PUBLIC VARIABLES
|
||||
*
|
||||
* PRIVATE VARIABLES
|
||||
*
|
||||
* PUBLIC METHOD:S
|
||||
*
|
||||
* PRIVATE METHOD:S
|
||||
*
|
||||
* HISTORY:
|
||||
* 2019/9/11 (cs) error string 21->91, 22->92 for not overlapping with IO
|
||||
* 2005/07/07 (cs) updated array class for postgres: set 0 & NULL if int field given, insert uses () values () syntax
|
||||
@@ -105,11 +97,6 @@ class ArrayIO extends \CoreLibs\DB\IO
|
||||
return $text;
|
||||
}
|
||||
|
||||
// METHOD: convertEntities
|
||||
// WAS : convert_entities
|
||||
// PARAMS: string -> string to be changed
|
||||
// RETURN: string -> altered string
|
||||
// DESC : changeds all HTML entities into non HTML ones
|
||||
/**
|
||||
* changeds all HTML entities into non HTML ones
|
||||
* @param string $text encoded html string
|
||||
@@ -139,7 +126,7 @@ class ArrayIO extends \CoreLibs\DB\IO
|
||||
}
|
||||
// add output to internal error_msg
|
||||
if ($write === true) {
|
||||
$this->error_msg['db'] .= $string;
|
||||
$this->__dbDebug('dbArray', $string);
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
@@ -188,7 +175,7 @@ class ArrayIO extends \CoreLibs\DB\IO
|
||||
* set this as new table array too
|
||||
* @return array returns the table array that was deleted
|
||||
*/
|
||||
public function dbDelete($table_array = array())
|
||||
public function dbDelete($table_array = [])
|
||||
{
|
||||
// is array and has values, override set and set new
|
||||
if (is_array($table_array) && count($table_array)) {
|
||||
@@ -247,7 +234,7 @@ class ArrayIO extends \CoreLibs\DB\IO
|
||||
* @param array $table_array optional table array, overwrites internal set array
|
||||
* @return array set table array with values
|
||||
*/
|
||||
public function dbRead($edit = false, $table_array = array())
|
||||
public function dbRead($edit = false, $table_array = [])
|
||||
{
|
||||
// if array give, overrules internal array
|
||||
if (is_array($table_array) && count($table_array)) {
|
||||
@@ -320,7 +307,7 @@ class ArrayIO extends \CoreLibs\DB\IO
|
||||
* @param array $table_array optional table array, overwrites internal one
|
||||
* @return array table array or null
|
||||
*/
|
||||
public function dbWrite($addslashes = false, $table_array = array())
|
||||
public function dbWrite($addslashes = false, $table_array = [])
|
||||
{
|
||||
if (is_array($table_array) && count($table_array)) {
|
||||
$this->table_array = $table_array;
|
||||
|
||||
@@ -278,7 +278,7 @@ class IO extends \CoreLibs\Basic
|
||||
// other vars
|
||||
private $nbsp = ''; // used by print_array recursion function
|
||||
// error & warning id
|
||||
// not error_id is defined in \CoreLibs\Basic
|
||||
protected $error_id;
|
||||
private $had_error;
|
||||
private $warning_id;
|
||||
private $had_warning;
|
||||
@@ -535,7 +535,7 @@ class IO extends \CoreLibs\Basic
|
||||
* @param string $type query identifier (Q, I, etc)
|
||||
* @return void has no return
|
||||
*/
|
||||
private function __dbDebug(string $debug_id, string $error_string, string $id = '', string $type = ''): void
|
||||
protected function __dbDebug(string $debug_id, string $error_string, string $id = '', string $type = ''): void
|
||||
{
|
||||
$prefix = '';
|
||||
if ($id) {
|
||||
@@ -562,7 +562,7 @@ class IO extends \CoreLibs\Basic
|
||||
public function __dbError($cursor = false, string $msg = ''): void
|
||||
{
|
||||
$pg_error_string = '';
|
||||
$where_called = (string)$this->getCallerMethod();
|
||||
$where_called = (string)\CoreLibs\Debug\Support::getCallerMethod();
|
||||
if ($cursor) {
|
||||
$pg_error_string = $this->db_functions->__dbPrintError($cursor);
|
||||
}
|
||||
@@ -1115,7 +1115,7 @@ class IO extends \CoreLibs\Basic
|
||||
$md5 = md5($query);
|
||||
// pre declare array
|
||||
if (!isset($this->cursor_ext[$md5])) {
|
||||
$this->cursor_ext[$md5] = array(
|
||||
$this->cursor_ext[$md5] = [
|
||||
'query' => '',
|
||||
'pos' => 0,
|
||||
'cursor' => 0,
|
||||
@@ -1123,7 +1123,7 @@ class IO extends \CoreLibs\Basic
|
||||
'num_rows' => 0,
|
||||
'num_fields' => 0,
|
||||
'read_rows' => 0
|
||||
);
|
||||
];
|
||||
}
|
||||
// set the query
|
||||
$this->cursor_ext[$md5]['query'] = $query;
|
||||
@@ -1624,7 +1624,7 @@ class IO extends \CoreLibs\Basic
|
||||
}
|
||||
$result = $this->db_functions->__dbExecute($stm_name, $data);
|
||||
if (!$result) {
|
||||
$this->debug('ExecuteData', 'ERROR in STM['.$stm_name.'|'.$this->prepare_cursor[$stm_name]['result'].']: '.$this->printAr($data));
|
||||
$this->debug('ExecuteData', 'ERROR in STM['.$stm_name.'|'.$this->prepare_cursor[$stm_name]['result'].']: '.\CoreLibs\Debug\Support::printAr($data));
|
||||
$this->error_id = 22;
|
||||
$this->__dbError($this->prepare_cursor[$stm_name]['result']);
|
||||
$this->__dbDebug('db', '<span style="color: red;"><b>DB-Error</b> '.$stm_name.': Execution failed</span>', 'DB_ERROR');
|
||||
@@ -1868,10 +1868,10 @@ class IO extends \CoreLibs\Basic
|
||||
array $data = []
|
||||
) {
|
||||
if (!is_array($primary_key)) {
|
||||
$primary_key = array(
|
||||
$primary_key = [
|
||||
'row' => $table.'_id',
|
||||
'value' => $primary_key
|
||||
);
|
||||
];
|
||||
} else {
|
||||
if (!isset($primary_key['row'])) {
|
||||
$primary_key['row'] = '';
|
||||
|
||||
@@ -266,7 +266,7 @@ class PgSQL
|
||||
if ($q = $this->__dbQuery($q)) {
|
||||
list($id) = $this->__dbFetchArray($q);
|
||||
} else {
|
||||
$id = array(-1, $q);
|
||||
$id = [-1, $q];
|
||||
}
|
||||
return $id;
|
||||
}
|
||||
@@ -444,7 +444,7 @@ class PgSQL
|
||||
{
|
||||
if (false === $limit) {
|
||||
$limit = strlen($text) - 1;
|
||||
$output = array();
|
||||
$output = [];
|
||||
}
|
||||
if ('{}' != $text) {
|
||||
do {
|
||||
|
||||
@@ -308,12 +308,14 @@ class Logging
|
||||
*/
|
||||
public function debugFor(string $type, string $flag): void
|
||||
{
|
||||
/** @phan-suppress-next-line PhanTypeMismatchArgumentReal */
|
||||
$this->setLogLevel(...[func_get_args()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* passes list of level names, to turn on debug
|
||||
* eg $foo->debugFor('print', 'on', ['LOG', 'DEBUG', 'INFO']);
|
||||
* TODO: currently we can only turn ON
|
||||
* @param string $type debug, echo, print
|
||||
* @param string $flag on/off
|
||||
* array $array of levels to turn on/off debug
|
||||
@@ -342,13 +344,13 @@ class Logging
|
||||
|
||||
/**
|
||||
* return the log level for the array type normal and not (disable)
|
||||
* @param string $type debug, echo, print
|
||||
* @param string $flag on/off
|
||||
* @param string $level if not null then check if this array entry is set
|
||||
* else return false
|
||||
* @return bool|array if $level is null, return array, else boolean true/false
|
||||
* @param string $type debug, echo, print
|
||||
* @param string $flag on/off
|
||||
* @param string|null $level if not null then check if this array entry is set
|
||||
* else return false
|
||||
* @return bool|array if $level is null, return array, else boolean true/false
|
||||
*/
|
||||
public function getLogLevel(string $type, string $flag, string $level = null)
|
||||
public function getLogLevel(string $type, string $flag, ?string $level = null)
|
||||
{
|
||||
// abort if not valid type
|
||||
if (!in_array($type, ['debug', 'echo', 'print'])) {
|
||||
@@ -367,6 +369,37 @@ class Logging
|
||||
return $this->{$switch};
|
||||
}
|
||||
|
||||
/**
|
||||
* set flags for per log level type
|
||||
* - level: set per sub group level
|
||||
* - class: split by class
|
||||
* - page: split per page called
|
||||
* - run: for each run
|
||||
* @param string $type Type to get: level, class, page, run
|
||||
* @param bool $set True or False
|
||||
* @return void
|
||||
*/
|
||||
public function setLogPer(string $type, bool $set): void
|
||||
{
|
||||
if (!in_array($type, ['level', 'class', 'page', 'run'])) {
|
||||
return;
|
||||
}
|
||||
$this->{'log_per'.$type} = $set;
|
||||
}
|
||||
|
||||
/**
|
||||
* return current set log per flag in bool
|
||||
* @param string $type Type to get: level, class, page, run
|
||||
* @return bool True of false for turned on or off
|
||||
*/
|
||||
public function getLogPer(string $type): bool
|
||||
{
|
||||
if (!in_array($type, ['level', 'class', 'page', 'run'])) {
|
||||
return false;
|
||||
}
|
||||
return $this->{'log_per'.$type};
|
||||
}
|
||||
|
||||
/**
|
||||
* write debug data to error_msg array
|
||||
* @param string $level id for error message, groups messages together
|
||||
|
||||
@@ -1035,12 +1035,12 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
}
|
||||
break;
|
||||
case 'date': // YYYY-MM-DD
|
||||
if (!$this->checkDate($this->table_array[$key]['value'])) {
|
||||
if (!\CoreLibs\Combined\DateTime::checkDate($this->table_array[$key]['value'])) {
|
||||
$this->msg .= sprintf($this->l->__('Please enter a vailid date (YYYY-MM-DD) for the <b>%s</b> Field!<br>'), $this->table_array[$key]['output_name']);
|
||||
}
|
||||
break;
|
||||
case 'time': // HH:MM[:SS]
|
||||
if (!$this->checkDateTime($this->table_array[$key]['value'])) {
|
||||
if (!\CoreLibs\Combined\DateTime::checkDateTime($this->table_array[$key]['value'])) {
|
||||
$this->msg .= sprintf($this->l->__('Please enter a vailid time (HH:MM[:SS]) for the <b>%s</b> Field!<br>'), $this->table_array[$key]['output_name']);
|
||||
}
|
||||
break;
|
||||
@@ -1198,7 +1198,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
// $this->log->debug('edit_error_chk', 'KEY: $prfx$key | count: '.count($_POST[$prfx.$key]).' | M: $max');
|
||||
// $this->log->debug('edit_error_chk', 'K: '.$_POST[$prfx.$key].' | '.$_POST[$prfx.$key][0]);
|
||||
}
|
||||
$this->log->debug('POST ARRAY', $this->printAr($_POST));
|
||||
$this->log->debug('POST ARRAY', \CoreLibs\Debug\Support::printAr($_POST));
|
||||
// init variables before inner loop run
|
||||
$mand_okay = 0;
|
||||
$mand_name = '';
|
||||
@@ -1503,7 +1503,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
if (isset($this->table_array[$key]['type']) && $this->table_array[$key]['type'] == 'password') {
|
||||
if ($this->table_array[$key]['value']) {
|
||||
// use the better new passwordSet instead of crypt based
|
||||
$this->table_array[$key]['value'] = $this->passwordSet($this->table_array[$key]['value']);
|
||||
$this->table_array[$key]['value'] = \CoreLibs\Check\Password::passwordSet($this->table_array[$key]['value']);
|
||||
$this->table_array[$key]['HIDDEN_value'] = $this->table_array[$key]['value'];
|
||||
} else {
|
||||
// $this->table_array[$key]['HIDDEN_value'] =
|
||||
@@ -1715,11 +1715,10 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
$this->msg = $this->l->__('Dataset has been saved!<Br>');
|
||||
}
|
||||
|
||||
// METHOD: formDeleteTableArray
|
||||
// WAS : form_delete_table_array
|
||||
// PARAMS: none
|
||||
// RETURN: none
|
||||
// DESC : delete a table and reference fields
|
||||
/**
|
||||
* delete a table and reference fields
|
||||
* @return void
|
||||
*/
|
||||
public function formDeleteTableArray()
|
||||
{
|
||||
// remove any reference arrays
|
||||
@@ -1759,12 +1758,12 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
$this->msg = $this->l->__('Dataset has been deleted!');
|
||||
}
|
||||
|
||||
// METHOD: formCreateHiddenFields
|
||||
// WAS : form_create_hidden_fields
|
||||
// PARAMS: $hidden_array
|
||||
// RETURN: the input fields (html)
|
||||
// DESC : creates HTML hidden input fields out of an hash array
|
||||
public function formCreateHiddenFields($hidden_array = [])
|
||||
/**
|
||||
* creates HTML hidden input fields out of an hash array
|
||||
* @param array $hidden_array The list of fields to be added as hidden
|
||||
* @return array key -> value list of hidden fileds data
|
||||
*/
|
||||
public function formCreateHiddenFields(array $hidden_array = []): array
|
||||
{
|
||||
$hidden = [];
|
||||
if (!is_array($this->table_array)) {
|
||||
@@ -1791,12 +1790,12 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
|
||||
return $hidden;
|
||||
}
|
||||
|
||||
// METHOD: formCreateElementReferenceTable
|
||||
// WAS : form_create_element_reference_table
|
||||
// PARAMS: show which reference table
|
||||
// RETURN: array for output
|
||||
// DESC : creates the multiple select part for a reference_table
|
||||
public function formCreateElementReferenceTable($table_name)
|
||||
/**
|
||||
* creates the multiple select part for a reference_table
|
||||
* @param string $table_name Table name for reference array lookup
|
||||
* @return array Reference table output array
|
||||
*/
|
||||
public function formCreateElementReferenceTable(string $table_name): array
|
||||
{
|
||||
$data = [];
|
||||
$output_name = $this->reference_array[$table_name]['output_name'];
|
||||
|
||||
@@ -25,11 +25,22 @@ if (defined('BASE')) {
|
||||
// RETURN: true, so cought errors do not get processed by the PHP error engine
|
||||
// DESC: will catch any error except E_ERROR and try to write them to the log file in log/php_error-<DAY>.llog
|
||||
// if this fails, it will print the data to the window via echo
|
||||
function MyErrorHandler($type, $message, $file, $line, $context)
|
||||
/**
|
||||
* will catch any error except E_ERROR and try to write them to the log file
|
||||
* in log/php_error-<DAY>.log
|
||||
* if this fails, it will print the data to the window via echo
|
||||
* @param int $type the error code from PHP
|
||||
* @param string $message the error message from php
|
||||
* @param string $file in which file the error happend. this is the source file (eg include)
|
||||
* @param int $line in which line the error happened
|
||||
* @param array $context array with all the variable
|
||||
* @return bool true, so cought errors do not get processed by the PHP error engine
|
||||
*/
|
||||
function MyErrorHandler(int $type, string $message, string $file, int $line, array $context): bool
|
||||
{
|
||||
if (!(error_reporting() & $type) && !SHOW_ALL_ERRORS) {
|
||||
// This error code is not included in error_reporting
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
// ERROR LEVEL
|
||||
$error_level = array(
|
||||
@@ -52,7 +63,7 @@ function MyErrorHandler($type, $message, $file, $line, $context)
|
||||
);
|
||||
|
||||
// get the current page name (strip path)
|
||||
$page_temp = explode("/", $_SERVER["PHP_SELF"]);
|
||||
$page_temp = explode(DIRECTORY_SEPARATOR, $_SERVER["PHP_SELF"]);
|
||||
// the output string:
|
||||
// [] current timestamp
|
||||
// {} the current page name in which the error occured (running script)
|
||||
@@ -63,7 +74,7 @@ function MyErrorHandler($type, $message, $file, $line, $context)
|
||||
$output = '{'.array_pop($page_temp).'} ['.$file.'] <'.$line.'> ['.$error_level[$type].'|'.$type.']: '.$message;
|
||||
# try to open file
|
||||
$ROOT = CURRENT_WORKING_DIR;
|
||||
$LOG = 'log/';
|
||||
$LOG = 'log'.DIRECTORY_SEPARATOR;
|
||||
// if the log folder is not found, try to create it
|
||||
if (!is_dir($ROOT.$LOG) && !is_file($ROOT.LOG)) {
|
||||
$ok = mkdir($ROOT.$LOG);
|
||||
|
||||
Reference in New Issue
Block a user