Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
04b47574eb | ||
|
|
ecc52e2dbd | ||
|
|
12e335c69c |
@@ -13,7 +13,6 @@ if ($DEBUG_ALL && $ENABLE_ERROR_HANDLING) {
|
||||
include BASE.LIBS."Error.Handling.php";
|
||||
}
|
||||
// predefine vars
|
||||
$LANG = '';
|
||||
$messages = array();
|
||||
// import all POST vars
|
||||
// extract($_POST, EXTR_SKIP);
|
||||
@@ -50,10 +49,6 @@ if ($AJAX_PAGE && !$ZIP_STREAM) {
|
||||
//------------------------------ class init start
|
||||
// login & page access check
|
||||
$login = new CoreLibs\ACL\Login(DB_CONFIG);
|
||||
// post login lang check
|
||||
if (isset($_SESSION['DEFAULT_LANG'])) {
|
||||
$LANG = $_SESSION['DEFAULT_LANG'];
|
||||
}
|
||||
// create smarty object
|
||||
$smarty = new CoreLibs\Template\SmartyExtend();
|
||||
// create new DB class
|
||||
|
||||
@@ -105,6 +105,7 @@ class Backend extends \CoreLibs\DB\IO
|
||||
|
||||
/**
|
||||
* set the language encoding and language settings
|
||||
* use $OVERRIDE_LANG to override all language settings
|
||||
* the default charset from _SESSION login or from
|
||||
* config DEFAULT ENCODING
|
||||
* the lang full name for mo loading from _SESSION login
|
||||
@@ -208,42 +209,6 @@ class Backend extends \CoreLibs\DB\IO
|
||||
$this->dbExec($q, 'NULL');
|
||||
}
|
||||
|
||||
/**
|
||||
* helper function for PHP file upload error messgaes to messge string
|
||||
* @param int $error_code integer _FILE upload error code
|
||||
* @return string message string, translated
|
||||
*/
|
||||
public function fileUploadErrorMessage(int $error_code): string
|
||||
{
|
||||
switch ($error_code) {
|
||||
case UPLOAD_ERR_INI_SIZE:
|
||||
$message = 'The uploaded file exceeds the upload_max_filesize directive in php.ini';
|
||||
break;
|
||||
case UPLOAD_ERR_FORM_SIZE:
|
||||
$message = 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form';
|
||||
break;
|
||||
case UPLOAD_ERR_PARTIAL:
|
||||
$message = 'The uploaded file was only partially uploaded';
|
||||
break;
|
||||
case UPLOAD_ERR_NO_FILE:
|
||||
$message = 'No file was uploaded';
|
||||
break;
|
||||
case UPLOAD_ERR_NO_TMP_DIR:
|
||||
$message = 'Missing a temporary folder';
|
||||
break;
|
||||
case UPLOAD_ERR_CANT_WRITE:
|
||||
$message = 'Failed to write file to disk';
|
||||
break;
|
||||
case UPLOAD_ERR_EXTENSION:
|
||||
$message = 'File upload stopped by extension';
|
||||
break;
|
||||
default:
|
||||
$message = 'Unknown upload error';
|
||||
break;
|
||||
}
|
||||
return $this->l->__($message);
|
||||
}
|
||||
|
||||
/**
|
||||
* menu creater (from login menu session pages)
|
||||
* @param int $flag visible flag trigger
|
||||
|
||||
@@ -891,6 +891,42 @@ class Basic
|
||||
return "<pre>".print_r($array, true)."</pre>";
|
||||
}
|
||||
|
||||
/**
|
||||
* helper function for PHP file upload error messgaes to messge string
|
||||
* @param int $error_code integer _FILE upload error code
|
||||
* @return string message string, translated
|
||||
*/
|
||||
public function fileUploadErrorMessage(int $error_code): string
|
||||
{
|
||||
switch ($error_code) {
|
||||
case UPLOAD_ERR_INI_SIZE:
|
||||
$message = 'The uploaded file exceeds the upload_max_filesize directive in php.ini';
|
||||
break;
|
||||
case UPLOAD_ERR_FORM_SIZE:
|
||||
$message = 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form';
|
||||
break;
|
||||
case UPLOAD_ERR_PARTIAL:
|
||||
$message = 'The uploaded file was only partially uploaded';
|
||||
break;
|
||||
case UPLOAD_ERR_NO_FILE:
|
||||
$message = 'No file was uploaded';
|
||||
break;
|
||||
case UPLOAD_ERR_NO_TMP_DIR:
|
||||
$message = 'Missing a temporary folder';
|
||||
break;
|
||||
case UPLOAD_ERR_CANT_WRITE:
|
||||
$message = 'Failed to write file to disk';
|
||||
break;
|
||||
case UPLOAD_ERR_EXTENSION:
|
||||
$message = 'File upload stopped by extension';
|
||||
break;
|
||||
default:
|
||||
$message = 'Unknown upload error';
|
||||
break;
|
||||
}
|
||||
return $message;
|
||||
}
|
||||
|
||||
// ****** DEBUG/ERROR FUNCTIONS ******
|
||||
|
||||
// ****** RANDOM KEY GEN ******
|
||||
@@ -1200,12 +1236,22 @@ class Basic
|
||||
$path[] = $key_lookin;
|
||||
} else {
|
||||
foreach ($haystack as $key => $val) {
|
||||
if (is_scalar($val) && $val === $needle && empty($key_lookin)) {
|
||||
break;
|
||||
} elseif (is_scalar($val) && !empty($key_lookin) && $key === $key_lookin && $val == $needle) {
|
||||
if (is_scalar($val) &&
|
||||
$val === $needle &&
|
||||
empty($key_lookin)
|
||||
) {
|
||||
$path[] = $key;
|
||||
break;
|
||||
} elseif (is_array($val) && $path = Basic::arraySearchRecursive($needle, $val, $key_lookin)) {
|
||||
} elseif (is_scalar($val) &&
|
||||
!empty($key_lookin) &&
|
||||
$key === $key_lookin &&
|
||||
$val == $needle
|
||||
) {
|
||||
$path[] = $key;
|
||||
break;
|
||||
} elseif (is_array($val) &&
|
||||
$path = Basic::arraySearchRecursive($needle, $val, $key_lookin)
|
||||
) {
|
||||
array_unshift($path, $key);
|
||||
break;
|
||||
}
|
||||
@@ -1344,6 +1390,21 @@ class Basic
|
||||
return $merged;
|
||||
}
|
||||
|
||||
/**
|
||||
* correct array_diff that does an actualy difference between two arrays.
|
||||
* array_diff only checks elements from A that are not in B, but not the
|
||||
* other way around.
|
||||
* Note that like array_diff this only checks first level values not keys
|
||||
* @param array $a array to compare a
|
||||
* @param array $b array to compare b
|
||||
* @return array array with missing elements from a & b
|
||||
*/
|
||||
public static function arrayDiff(array $a, array $b): array
|
||||
{
|
||||
$intersect = array_intersect($a, $b);
|
||||
return array_merge(array_diff($a, $intersect), array_diff($b, $intersect));
|
||||
}
|
||||
|
||||
/**
|
||||
* search for the needle array elements in haystack and return the ones found as an array,
|
||||
* is there nothing found, it returns FALSE (boolean)
|
||||
|
||||
Reference in New Issue
Block a user