From 12e335c69c8e33b44bd7718218b9c52a848066c8 Mon Sep 17 00:00:00 2001 From: Clemens Schwaighofer Date: Fri, 15 Nov 2019 17:53:21 +0900 Subject: [PATCH] Move fileUploadErrorMessage from Admin\Backend to Basic Also removed the auto translate, return just string. Is also a static method so can be called by Basic::fileUploadErrorMessage too Removed left over LANG settings in admin header --- www/includes/admin_header.php | 5 ----- www/lib/CoreLibs/Admin/Backend.php | 36 ------------------------------ www/lib/CoreLibs/Basic.php | 36 ++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 41 deletions(-) diff --git a/www/includes/admin_header.php b/www/includes/admin_header.php index 7bf28c0c..8e7980ba 100644 --- a/www/includes/admin_header.php +++ b/www/includes/admin_header.php @@ -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 diff --git a/www/lib/CoreLibs/Admin/Backend.php b/www/lib/CoreLibs/Admin/Backend.php index 38bffc36..fcb5e179 100644 --- a/www/lib/CoreLibs/Admin/Backend.php +++ b/www/lib/CoreLibs/Admin/Backend.php @@ -208,42 +208,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 diff --git a/www/lib/CoreLibs/Basic.php b/www/lib/CoreLibs/Basic.php index 3b0d9b80..115859b8 100644 --- a/www/lib/CoreLibs/Basic.php +++ b/www/lib/CoreLibs/Basic.php @@ -891,6 +891,42 @@ class Basic return "
".print_r($array, true)."
"; } + /** + * 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 ******