public static function Extract_Filtered_Request_Get_Post_Vars($filter_____arr, $filter_____info)
 {
     // FILTER INPUT VARIABLES v.160122 (with collision fix and private space check)
     // This no more limits the input variables as it is handled via prior checks to PHP.INI: max_input_vars and max_input_nesting_level
     // If any of: GET / POST / COOKIE overflow the max_input_vars and max_input_nesting_level a PHP warning is issued !!
     // The max_input_vars applies separately to each of the input variables, includding array(s) keys
     // The max_input_nesting_level also must be at least 5
     //-- check if can run
     if (self::$RequestProcessed !== false) {
         return;
         // avoid run after it was already processed
     }
     //end if
     //--
     //--
     if ((string) SMART_FRAMEWORK_DEBUG_MODE == 'yes') {
         self::DebugRequestLog('######################### FILTER NEW REQUEST:' . "\n" . date('Y-m-d H:i:s O') . "\n" . $_SERVER['REQUEST_URI'] . "\n\n" . '##### RAW REQUEST VARS:' . "\n" . '[' . $filter_____info . ']' . "\n" . print_r($filter_____arr, 1) . "\n");
     }
     //end if
     //--
     //-- process
     if (is_array($filter_____arr)) {
         //--
         foreach ($filter_____arr as $filter_____key => $filter_____val) {
             //--
             $filter_____key = (string) $filter_____key;
             // force string
             //--
             if (substr($filter_____key, 0, 11) != 'filter_____') {
                 // avoid collisions with the variables in this function
                 //--
                 if (SmartFrameworkSecurity::ValidateVariableName($filter_____key)) {
                     //--
                     if (is_array($filter_____val)) {
                         // array
                         //--
                         if ((string) SMART_FRAMEWORK_DEBUG_MODE == 'yes') {
                             self::DebugRequestLog('#EXTRACT-FILTER-VAR-ARRAY:' . "\n" . $filter_____key . '=' . print_r($filter_____val, 1) . "\n");
                         }
                         //end if
                         SmartFrameworkRegistry::setRequestVar((string) $filter_____key, (array) SmartFrameworkSecurity::FilterGetPostCookieVars($filter_____val)) or @trigger_error(__CLASS__ . '::' . __FUNCTION__ . '() :: ' . 'Failed to register an array request variable: ' . $filter_____key . ' @ ' . $filter_____info, E_USER_WARNING);
                         //--
                     } else {
                         // string
                         //--
                         if ((string) SMART_FRAMEWORK_DEBUG_MODE == 'yes') {
                             self::DebugRequestLog('#EXTRACT-FILTER-VAR-STRING:' . "\n" . $filter_____key . '=' . $filter_____val . "\n");
                         }
                         //end if
                         SmartFrameworkRegistry::setRequestVar((string) $filter_____key, (string) SmartFrameworkSecurity::FilterGetPostCookieVars($filter_____val)) or @trigger_error(__CLASS__ . '::' . __FUNCTION__ . '() :: ' . 'Failed to register a string request variable: ' . $filter_____key . ' @ ' . $filter_____info, E_USER_WARNING);
                         //--
                     }
                     //end if else
                     //--
                 }
                 //end if
                 //--
             }
             //end if
             //--
         }
         //end foreach
         //--
     }
     //end if
     //--
     //--
     if ((string) SMART_FRAMEWORK_DEBUG_MODE == 'yes') {
         self::DebugRequestLog('########## END REQUEST FILTER ##########' . "\n\n");
     }
     //end if
     //--
 }
 /**
  *
  * @access 		private
  * @internal
  *
  */
 public static function registerInternalCacheToDebugLog()
 {
     //--
     if (defined('SMART_FRAMEWORK_INTERNAL_DEBUG')) {
         if ((string) SMART_FRAMEWORK_DEBUG_MODE == 'yes') {
             SmartFrameworkRegistry::setDebugMsg('extra', '***SMART-CLASSES:INTERNAL-CACHE***', ['title' => 'Smart (Base) // Internal Cache', 'data' => 'Dump of Cfgs:' . "\n" . print_r(self::$Cfgs, 1)]);
         }
         //end if
     }
     //end if
     //--
 }
 public static function save_debug_info($y_area, $y_debug_token, $is_main)
 {
     //-- {{{SYNC-DEBUG-DATA}}}
     if ((string) SMART_FRAMEWORK_DEBUG_MODE != 'yes') {
         return false;
     }
     //end if
     //--
     if ((string) $y_area != 'idx' and (string) $y_area != 'adm') {
         return false;
     }
     //end if
     //--
     $y_debug_token = trim((string) $y_debug_token);
     if ((string) $y_debug_token == '') {
         return false;
     }
     //end if
     //--
     $the_dir = 'tmp/logs/' . Smart::safe_filename($y_area) . '/' . date('Y-m-d@H') . '-debug-data/' . Smart::safe_filename($y_debug_token) . '/';
     //-- #END# SYNC
     //--
     if ($is_main) {
         $the_file = $the_dir . 'debug-main.log';
     } else {
         $the_file = $the_dir . 'debug-sub-req-' . time() . '-' . SmartHashCrypto::sha1($_SERVER['REQUEST_URI']) . '.log';
     }
     //end if else
     //--
     //--
     if (!is_dir($the_dir)) {
         SmartFileSystem::dir_recursive_create($the_dir);
     }
     //end if
     //--
     if (is_dir($the_dir)) {
         if (is_writable($the_dir)) {
             //--
             $arr = array();
             //-- generate debug info if set to show optimizations
             SmartMarkersTemplating::registerOptimizationHintsToDebugLog();
             //-- generate debug info if set to show internals
             if (defined('SMART_FRAMEWORK_INTERNAL_DEBUG')) {
                 Smart::registerInternalCacheToDebugLog();
                 SmartFrameworkRegistry::registerInternalCacheToDebugLog();
                 SmartAuth::registerInternalCacheToDebugLog();
                 SmartHashCrypto::registerInternalCacheToDebugLog();
                 SmartUtils::registerInternalCacheToDebugLog();
                 SmartMarkersTemplating::registerInternalCacheToDebugLog();
             }
             //end if
             //--
             $dbg_stats = (array) SmartFrameworkRegistry::getDebugMsgs('stats');
             //--
             $arr['date-time'] = date('Y-m-d H:i:s O');
             $arr['debug-token'] = (string) $y_debug_token;
             $arr['is-request-main'] = $is_main;
             $arr['request-hash'] = SmartHashCrypto::sha1($_SERVER['REQUEST_URI']);
             $arr['request-uri'] = (string) $_SERVER['REQUEST_URI'];
             $arr['resources-time'] = $dbg_stats['time'];
             $arr['resources-memory'] = $dbg_stats['memory'];
             $arr['response-code'] = (int) http_response_code();
             $arr['response-headers'] = base64_encode(Smart::seryalize((array) headers_list()));
             if (function_exists('getallheaders')) {
                 $arr['request-headers'] = base64_encode(Smart::seryalize((array) getallheaders()));
             } else {
                 $arr['request-headers'] = base64_encode(Smart::seryalize(''));
             }
             //end if else
             $arr['env-req-filtered'] = base64_encode(Smart::seryalize((array) SmartFrameworkRegistry::getRequestVars()));
             $arr['env-get'] = base64_encode(Smart::seryalize((array) $_GET));
             $arr['env-post'] = base64_encode(Smart::seryalize((array) $_POST));
             $arr['env-cookies'] = base64_encode(Smart::seryalize((array) $_COOKIE));
             $arr['env-server'] = base64_encode(Smart::seryalize((array) $_SERVER));
             if (@session_status() === PHP_SESSION_ACTIVE) {
                 $arr['php-session'] = base64_encode(Smart::seryalize((array) $_SESSION));
             } else {
                 $arr['php-session'] = base64_encode(Smart::seryalize(''));
             }
             //end if else
             if (SmartAuth::check_login() === true) {
                 $arr['auth-data'] = array('is_auth' => true, 'login_data' => (array) SmartAuth::get_login_data(), '#login-pass#', SmartAuth::get_login_password());
             } else {
                 $arr['auth-data'] = array('is_auth' => false, 'login_data' => array());
             }
             //end if else
             foreach ((array) SmartFrameworkRegistry::getDebugMsgs('optimizations') as $key => $val) {
                 $arr['log-optimizations'][(string) $key] = base64_encode(Smart::seryalize((array) $val));
             }
             //end foreach
             foreach ((array) SmartFrameworkRegistry::getDebugMsgs('extra') as $key => $val) {
                 $arr['log-extra'][(string) $key] = base64_encode(Smart::seryalize((array) $val));
             }
             //end foreach
             foreach ((array) SmartFrameworkRegistry::getDebugMsgs('db') as $key => $val) {
                 $arr['log-db'][(string) $key] = base64_encode(Smart::seryalize((array) $val));
             }
             //end foreach
             $arr['log-mail'] = base64_encode(Smart::seryalize((array) SmartFrameworkRegistry::getDebugMsgs('mail')));
             foreach ((array) SmartFrameworkRegistry::getDebugMsgs('modules') as $key => $val) {
                 $arr['log-modules'][(string) $key] = base64_encode(Smart::seryalize((array) $val));
             }
             //end foreach
             //--
             SmartFileSystem::write($the_file, Smart::seryalize($arr));
             //--
         }
         //end if
     }
     //end if
     //--
     //--
     return true;
     //--
 }
 public static function Run()
 {
     //--
     global $configs;
     //--
     //==
     //--
     if (self::$MiddlewareCompleted !== false) {
         // avoid to execute more than 1 this middleware !
         self::Raise500Error('Middleware App Execution already completed ...');
         return;
     }
     //end if
     self::$MiddlewareCompleted = true;
     //--
     $the_midmark = '[A]';
     //--
     if (SMART_FRAMEWORK_ADMIN_AREA !== true) {
         Smart::raise_error('Admin Middleware ERROR: SMART_FRAMEWORK_ADMIN_AREA is not set to TRUE', 'Invalid Area / This middleware is designed for Admin area and requires to turn ON the Administration flag ...');
         return;
     }
     //end if
     //--
     if (!defined('SMART_APP_TEMPLATES_DIR')) {
         self::Raise500Error('The SMART_APP_TEMPLATES_DIR not defined ...');
         return;
     }
     //end if
     //--
     if (defined('SMART_APP_MODULE_AREA')) {
         self::Raise500Error('Smart App Area must NOT be Defined outside controllers ...');
         return;
     }
     //end if
     if (defined('SMART_APP_MODULE_AUTH')) {
         self::Raise500Error('Smart App Module Auth must NOT be Defined outside controllers ...');
         return;
     }
     //end if
     if (defined('SMART_APP_MODULE_REALM_AUTH')) {
         self::Raise500Error('Smart App Module Realm Auth must NOT be Defined outside controllers ...');
         return;
     }
     //end if
     if (defined('SMART_APP_MODULE_DIRECT_OUTPUT')) {
         self::Raise500Error('Smart App Module Direct Output must NOT be Defined outside controllers ...');
         return;
     }
     //end if
     //--
     //==
     //--
     $smartframeworkservice = '';
     // special operation
     if (SmartFrameworkRegistry::issetRequestVar('smartframeworkservice') === true) {
         $smartframeworkservice = (string) strtolower((string) SmartUnicode::utf8_to_iso((string) SmartFrameworkRegistry::getRequestVar('smartframeworkservice')));
         switch ((string) $smartframeworkservice) {
             case 'status':
             case 'debug':
                 break;
             default:
                 // invalid value
                 $smartframeworkservice = '';
         }
         //end switch
     }
     //end if
     //--
     //==
     //-- switch language by cookie (this needs to be before loading the app core)
     if (strlen(trim((string) $_COOKIE['SmartApp_ADM_LANGUAGE_SET'])) > 0) {
         SmartTextTranslations::setLanguage(trim((string) $_COOKIE['SmartApp_ADM_LANGUAGE_SET']));
     }
     //end if
     //-- switch language by print cookie (this needs to be before loading the app core and after language by cookie)
     if (SmartFrameworkRegistry::issetRequestVar((string) SMART_FRAMEWORK_URL_PARAM_PRINTABLE) === true) {
         if (strtolower((string) SmartFrameworkRegistry::getRequestVar((string) SMART_FRAMEWORK_URL_PARAM_PRINTABLE)) == strtolower((string) SMART_FRAMEWORK_URL_VALUE_ENABLED)) {
             if (strlen(trim((string) $_COOKIE['SmartApp_ADM_PRINT_LANGUAGE_SET'])) > 0) {
                 SmartTextTranslations::setLanguage(trim((string) $_COOKIE['SmartApp_ADM_PRINT_LANGUAGE_SET']));
             }
             //end if
         }
         //end if
     }
     //end if
     //--
     //== RAW OUTPUT FOR STATUS
     //--
     if ((string) $smartframeworkservice == 'status') {
         //--
         if (SMART_SOFTWARE_DISABLE_STATUS_POWERED === true) {
             $status_powered_info = '';
         } else {
             $status_powered_info = (string) SmartComponents::draw_powered_info('no');
         }
         //end if else
         //--
         self::HeadersNoCache();
         // headers: cache control, force no-cache
         echo SmartComponents::http_status_message('Smart.Framework :: Status :: [OK]', '<script type="text/javascript">setTimeout(function(){ self.location = self.location; }, 60000);</script><img src="lib/core/img/busy_bar.gif"><div><h1>' . date('Y-m-d H:i:s O') . ' // Service Ready :: ' . $the_midmark . '</h1></div>' . $status_powered_info . '<br>');
         //--
         return;
         // break stop
         //--
     }
     //end if
     //--
     //== OVERALL AUTHENTICATION BREAKPOINT
     //--
     SmartAppBootstrap::Authenticate('admin');
     // if the auth uses session it may start now
     //--
     //== RAW OUTPUT FOR DEBUG
     //--
     if ((string) $smartframeworkservice == 'debug') {
         //--
         if ((string) SMART_FRAMEWORK_DEBUG_MODE == 'yes') {
             self::HeadersNoCache();
             // headers: cache control, force no-cache
             $the_debug_cookie = trim((string) $_COOKIE['SmartFramework__DebugAdmID']);
             echo SmartDebugProfiler::print_debug_info('adm', $the_debug_cookie);
         } else {
             http_response_code(404);
             echo SmartComponents::http_message_404_notfound('No Debug service has been activated on this server ...');
         }
         //end if
         //--
         return;
         // break stop
         //--
     }
     //end if else
     //--
     //== LOAD THE MODULE (OR DEFAULT MODULE)
     //--
     $reserved_controller_names = ['php', 'html', 'stml', 'css', 'js', 'json', 'xml', 'rss', 'txt', 'csv', 'sql', 'png', 'gif', 'jpg', 'pdf', 'svg', 'zip', '7z', 'netarch'];
     // these are reserved extensions and cannot be used as controller names because they need to be used also with friendly URLs as the 2nd param if module is missing from URL page param
     //--
     $err404 = '';
     $arr = array();
     //--
     $page = (string) SmartUnicode::utf8_to_iso((string) SmartFrameworkRegistry::getRequestVar('page'));
     $page = trim(str_replace(array('/', '\\', ':', '?', '&', '=', '%'), array('', '', '', '', '', '', ''), $page));
     // fix for get as it automatically replaces . with _ (so, reverse), but also fix some invalid characters ...
     if ((string) $page == '') {
         $page = (string) $configs['app']['admin-home'];
     }
     //end if
     //--
     if (strpos($page, '.') !== false) {
         // page can be as module.controller / module.controller(.php|html|stml|css|js|json|xml|rss|txt|csv|sql|png|gif|jpg|pdf|svg|zip|7z|netarch)
         //--
         $arr = (array) explode('.', (string) $page, 3);
         // separe 1st and 2nd from the rest
         //--
         //#
         //#
         $arr[0] = trim(strtolower((string) $arr[0]));
         // module
         $arr[1] = trim(strtolower((string) $arr[1]));
         // controller
         //#
         //# Admin will NOT integrate with friendly URLs SMART_FRAMEWORK_SEMANTIC_URL_SKIP_MODULE
         //# that feature is just for Index
         //#
         //--
     } elseif ((string) $configs['app']['admin-default-module'] != '') {
         //--
         $arr[0] = trim(strtolower((string) $configs['app']['admin-default-module']));
         // get default module
         $arr[1] = trim(strtolower((string) $page));
         // controller
         //--
     } else {
         //--
         if ((string) $err404 == '') {
             $err404 = 'Invalid Page (Invalid URL Page Segments Syntax): ' . $page;
         }
         //end if
         //--
     }
     //end if else
     //--
     if ((string) $arr[0] == '' or (string) $arr[1] == '') {
         if ((string) $err404 == '') {
             $err404 = 'Invalid Page (Empty or Missing URL Page Segments): ' . $page;
         }
         //end if
     }
     //end if
     if (!preg_match('/^[a-z0-9_\\-]+$/', (string) $arr[0]) or !preg_match('/^[a-z0-9_\\-]+$/', (string) $arr[1])) {
         if ((string) $err404 == '') {
             $err404 = 'Invalid Page (Invalid Characters in the URL Page Segments): ' . $page;
         }
         //end if
     }
     //end if
     if (in_array((string) $arr[1], (array) $reserved_controller_names)) {
         if ((string) $err404 == '') {
             $err404 = 'Invalid Page (Reserved Page Controller Name): [' . $arr[1] . '] in: ' . $page;
         }
         //end if
     }
     //end if
     //--
     $the_controller_name = (string) $arr[0] . '.' . $arr[1];
     $the_path_to_module = Smart::safe_pathname(SmartFileSysUtils::add_dir_last_slash('modules/mod-' . Smart::safe_filename($arr[0])));
     $the_module = Smart::safe_pathname($the_path_to_module . Smart::safe_filename($arr[1]) . '.php');
     if (!is_file($the_module)) {
         if ((string) $err404 == '') {
             $err404 = 'Page does not exist: ' . $page;
         }
         //end if
     }
     //end if
     //--
     if ((string) $err404 != '') {
         self::Raise404Error((string) $err404);
         return;
     }
     //end if
     //--
     if (!SmartFileSysUtils::check_file_or_dir_name($the_path_to_module) or !SmartFileSysUtils::check_file_or_dir_name($the_module)) {
         self::Raise400Error('Insecure Module Access for Page: ' . $page);
         return;
     }
     //end if
     //--
     if (class_exists('SmartAppIndexController') or class_exists('SmartAppAdminController')) {
         self::Raise500Error('Module Class Runtimes must be defined only in modules ...');
         return;
     }
     //end if
     //--
     require (string) $the_module;
     //--
     if ((string) SMART_APP_MODULE_AREA !== 'ADMIN' and (string) SMART_APP_MODULE_AREA !== 'SHARED') {
         self::Raise403Error('Page Access Denied for Admin Area: ' . $page);
         return;
     }
     //end if
     if (defined('SMART_APP_MODULE_AUTH')) {
         if (SmartAuth::check_login() !== true) {
             self::Raise403Error('Page Access Denied ! No Authentication: ' . $page);
             return;
         }
         //end if
         if (defined('SMART_APP_MODULE_REALM_AUTH')) {
             if ((string) SmartAuth::get_login_realm() !== (string) SMART_APP_MODULE_REALM_AUTH) {
                 self::Raise403Error('Page Access Denied ! Invalid Login Realm: ' . $page);
                 return;
             }
             //end if
         }
         //end if
     }
     //end if
     //--
     if (!class_exists('SmartAppAdminController')) {
         self::Raise500Error('Invalid Module Class Runtime for Page: ' . $page);
         return;
     }
     //end if
     if (!is_subclass_of('SmartAppAdminController', 'SmartAbstractAppController')) {
         self::Raise500Error('Invalid Module Class Inheritance for Controller Page: ' . $page);
         return;
     }
     //end if
     //--
     //== PATHS
     //--
     $base_script = SmartUtils::get_server_current_script();
     $base_full_path = SmartUtils::get_server_current_path();
     $base_full_url = SmartUtils::get_server_current_url();
     //--
     //== RUN THE MODULE
     //--
     $appModule = new SmartAppAdminController($the_path_to_module, $base_script, $base_full_path, $base_full_url, $page, $the_controller_name);
     //--
     if (SMART_APP_MODULE_DIRECT_OUTPUT !== true) {
         ob_start();
     }
     //end if
     $appStatusCode = (int) $appModule->Run();
     $appModule->ShutDown();
     if (SMART_APP_MODULE_DIRECT_OUTPUT !== true) {
         $ctrl_output = ob_get_contents();
         ob_end_clean();
         if ((string) $ctrl_output != '') {
             Smart::log_warning('The middleware service ' . $the_midmark . ' detected an illegal output in the controller: ' . $page . "\n" . 'The result of this output is: ' . $ctrl_output);
         }
         //end if
         $ctrl_output = '';
     } else {
         return;
         // break stop after the controller has terminated the direct output
     }
     //end if else
     //--
     $appSettings = (array) $appModule->PageViewGetCfgs();
     //--
     //== CACHE CONTROL
     //--
     if ((int) $appSettings['expires'] > 0 and (string) SMART_FRAMEWORK_DEBUG_MODE != 'yes') {
         self::HeadersCacheExpire((int) $appSettings['expires'], (int) $appSettings['modified']);
         // headers: cache expiration control
     } else {
         self::HeadersNoCache();
         // headers: cache control, force no-cache
     }
     //end if else
     //--
     //== STATUS CODE
     //--
     switch ((int) $appStatusCode) {
         //-- client errors
         case 400:
             self::Raise400Error((string) $appSettings['error']);
             return;
             break;
         case 401:
             self::Raise401Error((string) $appSettings['error']);
             return;
             break;
         case 403:
             self::Raise403Error((string) $appSettings['error']);
             return;
             break;
         case 404:
             self::Raise404Error((string) $appSettings['error']);
             return;
             break;
         case 429:
             self::Raise429Error((string) $appSettings['error']);
             return;
             break;
             //-- server errors
         //-- server errors
         case 500:
             self::Raise500Error((string) $appSettings['error']);
             return;
             break;
         case 502:
             self::Raise502Error((string) $appSettings['error']);
             return;
             break;
         case 503:
             self::Raise503Error((string) $appSettings['error']);
             return;
             break;
         case 504:
             self::Raise504Error((string) $appSettings['error']);
             return;
             break;
             //-- extended 2xx statuses: NOTICE / WARNING / ERROR that can be used for REST / API
         //-- extended 2xx statuses: NOTICE / WARNING / ERROR that can be used for REST / API
         case 202:
             // NOTICE
             if (!headers_sent()) {
                 http_response_code(202);
                 // Accepted (this should be used only as an alternate SUCCESS code instead of 200 for NOTICES)
             } else {
                 Smart::log_warning('Headers Already Sent before 202 ...');
             }
             //end if else
             break;
         case 203:
             // WARNING
             if (!headers_sent()) {
                 http_response_code(203);
                 // Non-Authoritative Information (this should be used only as an alternate SUCCESS code instead of 200 for WARNINGS)
             } else {
                 Smart::log_warning('Headers Already Sent before 203 ...');
             }
             //end if else
             break;
         case 208:
             // ERROR
             if (!headers_sent()) {
                 http_response_code(208);
                 // Already Reported (this should be used only as an alternate SUCCESS code instead of 200 for ERRORS)
             } else {
                 Smart::log_warning('Headers Already Sent before 208 ...');
             }
             //end if else
             break;
             //-- DEFAULT: OK
         //-- DEFAULT: OK
         case 200:
         default:
             // any other codes not listed above are not supported and will be interpreted as 200
             // nothing to do here ...
     }
     //end switch
     //--
     //== PREPARE THE OUTPUT
     //--
     if (stripos((string) $configs['js']['popup-override-mobiles'], '<' . SmartUtils::get_os_browser_ip('os') . '>') !== false) {
         $configs['js']['popup-mode'] = 'popup';
         // particular os settings for mobiles
     }
     //end if
     //--
     $rawpage = '';
     if (isset($appSettings['rawpage'])) {
         $rawpage = strtolower((string) $appSettings['rawpage']);
         if ((string) $rawpage == 'yes') {
             $rawpage = 'yes';
             // standardize the value
         }
         //end if
     }
     //end if
     if ((string) $rawpage != 'yes') {
         $rawpage = '';
     }
     //end if
     //--
     $rawmime = '';
     if (isset($appSettings['rawmime'])) {
         $rawmime = (string) $appSettings['rawmime'];
         if ((string) $rawmime != '') {
             $rawmime = SmartValidator::validate_mime_type($rawmime);
         }
         //end if
     }
     //end if else
     //--
     $rawdisp = '';
     if (isset($appSettings['rawdisp'])) {
         $rawdisp = (string) $appSettings['rawdisp'];
         if ((string) $rawdisp != '') {
             $rawdisp = SmartValidator::validate_mime_disposition($rawdisp);
         }
         //end if
     }
     //end if else
     //--
     $appData = (array) $appModule->PageViewGetVars();
     //--
     $appData['base-path'] = (string) $base_full_path;
     $appData['base-url'] = (string) $base_full_url;
     //--
     //== REDIRECTION HANDLER (this can be set only explicit from Controllers)
     //--
     if ((string) $appSettings['redirect-url'] != '') {
         // expects a valid URL
         //--
         $the_redirect_link = '<a href="' . Smart::escape_html((string) $appSettings['redirect-url']) . '">' . Smart::escape_html((string) $appSettings['redirect-url']) . '</a>';
         //--
         if (headers_sent()) {
             Smart::log_warning('Headers Already Sent before Redirection: [' . $appStatusCode . '] ; URL: ' . $appSettings['redirect-url']);
             self::Raise500Error('The app failed to Redirect to: ' . $the_redirect_link);
             return;
         }
         //end if
         switch ((int) $appStatusCode) {
             case 301:
                 http_response_code(301);
                 $the_redirect_text = 'Moved Permanently';
                 // permanent redirect for HTTP 1.0 / HTTP 1.1
                 break;
             case 302:
             default:
                 // any other code will be interpreted as 302 (the default redirection in PHP)
                 http_response_code(302);
                 $the_redirect_text = 'Found';
                 // temporary redirect for HTTP 1.0 / HTTP 1.1
                 break;
         }
         //end switch
         header('Location: ' . SmartFrameworkSecurity::FilterUnsafeString((string) $appSettings['redirect-url']));
         echo '<h1>' . Smart::escape_html($the_redirect_text) . '</h1>' . '<br>' . 'If the page redirection fails, click on the below link:' . '<br>' . $the_redirect_link;
         return;
         // break stop
     }
     //end if
     //--
     //== DOWNLOADS HANDLER (downloads can be set only explicit from Controllers)
     //--
     if ((string) $appSettings['download-packet'] != '' and (string) $appSettings['download-key'] != '') {
         // expects an encrypted data packet and a key
         $dwl_result = self::DownloadsHandler((string) $appSettings['download-packet'], (string) $appSettings['download-key']);
         if ((string) $dwl_result != '') {
             Smart::log_info('File Download - Client: ' . SmartUtils::get_visitor_signature(), (string) $dwl_result);
             // log result and mark it as finalized
         }
         //end if
         return;
         // break stop
     }
     //end if
     //--
     //== RAW OUTPUT FOR PAGES
     //--
     if ((string) $rawpage == 'yes') {
         //-- {{{SYNC-RESOURCES}}}
         if (function_exists('memory_get_peak_usage')) {
             $res_memory = @memory_get_peak_usage(false);
         } else {
             $res_memory = 'unknown';
         }
         //end if else
         $res_time = (double) (microtime(true) - (double) SMART_FRAMEWORK_RUNTIME_READY);
         //-- #END-SYNC
         if ((string) SMART_FRAMEWORK_DEBUG_MODE == 'yes') {
             //-- {{{SYNC-DEBUG-META-INFO}}}
             SmartFrameworkRegistry::setDebugMsg('stats', 'memory', $res_memory);
             // bytes
             SmartFrameworkRegistry::setDebugMsg('stats', 'time', $res_time);
             // seconds
             //-- #END-SYNC
             $the_debug_cookie = trim((string) $_COOKIE['SmartFramework__DebugAdmID']);
             SmartDebugProfiler::save_debug_info('adm', $the_debug_cookie, false);
         } else {
             $the_debug_cookie = '';
         }
         //end if
         //--
         if (headers_sent()) {
             Smart::raise_error('Middleware ERROR: Headers already sent', 'ERROR: Headers already sent !');
             return;
             // avoid serve raw pages with errors injections before headers
         }
         //end if
         //--
         if ((string) $rawmime != '') {
             header('Content-Type: ' . $rawmime);
         }
         //end if
         if ((string) $rawdisp != '') {
             header('Content-Disposition: ' . $rawdisp);
         }
         //end if
         header('Content-Length: ' . (0 + strlen((string) $appData['main'])));
         // must be strlen NOT SmartUnicode::str_len as it must get number of bytes not characters
         echo (string) $appData['main'];
         return;
         // break stop
         //--
     }
     //end if else
     //--
     //== DEFAULT OUTPUT
     //--
     if (isset($appSettings['template-path'])) {
         if ((string) $appSettings['template-path'] == '@') {
             // if template path is set to self (module)
             $the_template_path = '@';
             // this is a special setting
         } else {
             $the_template_path = Smart::safe_pathname(SmartFileSysUtils::add_dir_last_slash(trim((string) $appSettings['template-path'])));
         }
         //end if else
     } else {
         $the_template_path = Smart::safe_pathname(SmartFileSysUtils::add_dir_last_slash(trim((string) $configs['app']['admin-template-path'])));
         // use default template path
     }
     //end if else
     //--
     if (isset($appSettings['template-file'])) {
         $the_template_file = Smart::safe_filename(trim((string) $appSettings['template-file']));
     } else {
         $the_template_file = Smart::safe_filename(trim((string) $configs['app']['admin-template-file']));
         // use default template
     }
     //end if else
     //--
     if ((string) $the_template_path == '@') {
         $the_template_path = (string) $the_path_to_module . 'templates/';
         // must have the dir last slash as above
     } else {
         $the_template_path = (string) SMART_APP_TEMPLATES_DIR . $the_template_path;
         // finally normalize and set the complete template path
     }
     //end if else
     $the_template_file = (string) $the_template_file;
     // finally normalize
     //--
     if (!SmartFileSysUtils::check_file_or_dir_name($the_template_path)) {
         Smart::log_warning('Invalid Page Template Path: ' . $the_template_path);
         self::Raise500Error('Invalid Page Template Path. See the error log !');
         return;
     }
     //end if
     if (!is_dir($the_template_path)) {
         Smart::log_warning('Page Template Path does not Exists: ' . $the_template_path);
         self::Raise500Error('Page Template Path does not Exists. See the error log !');
         return;
     }
     //end if
     if (!SmartFileSysUtils::check_file_or_dir_name($the_template_path . $the_template_file)) {
         Smart::log_warning('Invalid Page Template File: ' . $the_template_path . $the_template_file);
         self::Raise500Error('Invalid Page Template File. See the error log !');
         return;
     }
     //end if
     if (!is_file($the_template_path . $the_template_file)) {
         Smart::log_warning('Page Template File does not Exists: ' . $the_template_path . $the_template_file);
         self::Raise500Error('Page Template File does not Exists. See the error log !');
         return;
     }
     //end if
     //--
     $the_template_content = trim(SmartMarkersTemplating::read_template_file($the_template_path . $the_template_file));
     if ((string) $the_template_content == '') {
         Smart::log_warning('Page Template File is Empty or cannot be read: ' . $the_template_path . $the_template_file);
         self::Raise500Error('Page Template File is Empty or cannot be read. See the error log !');
         return;
     }
     //end if
     //--
     if ((string) SMART_FRAMEWORK_DEBUG_MODE == 'yes') {
         $the_template_content = str_ireplace('</head>', "\n" . SmartDebugProfiler::js_headers_debug('admin.php?smartframeworkservice=debug') . "\n" . '</head>', $the_template_content);
         $the_template_content = str_ireplace('</body>', "\n" . SmartDebugProfiler::div_main_debug() . "\n" . '</body>', $the_template_content);
     }
     //end if
     //--
     $appData['app-domain'] = (string) $configs['app']['admin-domain'];
     $appData['template-file'] = $the_template_path . $the_template_file;
     $appData['template-path'] = $the_template_path;
     $appData['js.settings'] = SmartComponents::js_inc_settings((string) $configs['js']['popup-mode'], true, (bool) SMART_APP_VISITOR_COOKIE);
     $appData['head-meta'] = (string) $appData['head-meta'];
     if ((string) $appData['head-meta'] == '') {
         $appData['head-meta'] = '<!-- Head Meta -->';
     }
     //end if
     $appData['title'] = (string) $appData['title'];
     $appData['main'] = (string) $appData['main'];
     $appData['lang'] = SmartTextTranslations::getLanguage();
     //--
     if ((string) SMART_FRAMEWORK_DEBUG_MODE == 'yes') {
         //--
         $the_debug_cookie = 'adm-' . Smart::uuid_10_seq() . '-' . Smart::uuid_10_num() . '-' . Smart::uuid_10_str();
         @setcookie('SmartFramework__DebugAdmID', (string) $the_debug_cookie, 0, '/');
         // debug token cookie is set just on main request
         //--
     }
     //end if
     //--
     echo SmartMarkersTemplating::render_mixed_template((string) $the_template_content, (array) $appData, (string) $appData['template-path'], 'no', 'no');
     //-- {{{SYNC-RESOURCES}}}
     if (function_exists('memory_get_peak_usage')) {
         $res_memory = @memory_get_peak_usage(false);
     } else {
         $res_memory = 'unknown';
     }
     //end if else
     $res_time = (double) (microtime(true) - (double) SMART_FRAMEWORK_RUNTIME_READY);
     //-- #END-SYNC
     if ((string) SMART_FRAMEWORK_DEBUG_MODE == 'yes') {
         //-- {{{SYNC-DEBUG-META-INFO}}}
         SmartFrameworkRegistry::setDebugMsg('stats', 'memory', $res_memory);
         // bytes
         SmartFrameworkRegistry::setDebugMsg('stats', 'time', $res_time);
         // seconds
         //-- #END-SYNC
         SmartDebugProfiler::save_debug_info('adm', $the_debug_cookie, true);
         //--
     }
     //end if else
     //--
     if (SMART_SOFTWARE_DISABLE_STATUS_POWERED !== true) {
         echo "\n" . '<!-- Smart.Framework スマート.フレームワーク :: ' . SMART_FRAMEWORK_RELEASE_TAGVERSION . ' / ' . SMART_FRAMEWORK_RELEASE_VERSION . ' @ ' . $the_midmark . ' :: ' . SMART_FRAMEWORK_RELEASE_URL . ' -->';
     }
     //end if
     echo "\n" . '<!-- Resources: [' . Smart::format_number_dec($res_time, 13, '.', '') . ' sec.] / [' . Smart::format_number_dec($res_memory, 0, '.', ' ') . ' by.]' . ' -->' . "\n";
     //--
 }
 /**
  * Unset a Key into the non-persistent Cache
  *
  * @param STRING 	$y_realm	The Cache Realm
  * @param STRING 	$y_key		The Cache Key
  *
  * @return BOOLEAN	Always returns true
  */
 public static function unsetKey($y_realm, $y_key)
 {
     //--
     self::$CachedData[(string) $y_realm] = (array) self::$CachedData[(string) $y_realm];
     unset(self::$CachedData[(string) $y_realm][(string) $y_key]);
     //--
     if ((string) SMART_FRAMEWORK_DEBUG_MODE == 'yes') {
         SmartFrameworkRegistry::setDebugMsg('extra', 'SMART-CACHE', ['title' => '[INFO] :: UnsetKey: ' . $y_realm . ' / ' . $y_key, 'data' => '']);
     }
     //end if
     //--
     return true;
     //--
 }
 /**
  *
  * @access 		private
  * @internal
  *
  */
 public static function registerInternalCacheToDebugLog()
 {
     //--
     if (defined('SMART_FRAMEWORK_INTERNAL_DEBUG')) {
         if ((string) SMART_FRAMEWORK_DEBUG_MODE == 'yes') {
             $tmpAuthData = (array) self::$AuthData;
             $tmpAuthData['KEY'] = '*****';
             // protect the key !
             SmartFrameworkRegistry::setDebugMsg('extra', '***SMART-CLASSES:INTERNAL-CACHE***', ['title' => 'SmartAuth // Internal Cached Vars', 'data' => 'Dump of AuthCompleted: [' . print_r(self::$AuthCompleted, 1) . ']' . "\n" . 'Dump of AuthData:' . "\n" . print_r($tmpAuthData, 1)]);
         }
         //end if
     }
     //end if
     //--
 }
 public static function mov_pw_process($y_mov_file, $y_mov_img_preview, $y_quality, $y_width, $y_height, $y_watermark = '', $y_waterlocate = 'center', $y_mov_blank_img_preview = '')
 {
     //--
     $y_mov_file = (string) trim((string) $y_mov_file);
     $y_mov_img_preview = (string) trim((string) $y_mov_img_preview);
     $y_mov_blank_img_preview = (string) trim((string) $y_mov_blank_img_preview);
     $y_watermark = (string) trim((string) $y_watermark);
     //--
     //--
     $blank_mov_pw = 'lib/core/plugins/img/mediagallery/video.jpg';
     // this must be jpeg like the preview generated by ffmpeg
     //--
     $watermark_mov_pw = 'lib/core/plugins/img/mediagallery/play.png';
     //--
     //--
     if ((string) $y_mov_blank_img_preview == '') {
         $y_mov_blank_img_preview = $blank_mov_pw;
     }
     //end if
     //--
     if (!SmartFileSysUtils::check_file_or_dir_name($y_mov_blank_img_preview)) {
         $y_mov_blank_img_preview = $blank_mov_pw;
     }
     //end if
     //--
     if (!is_file($y_mov_blank_img_preview)) {
         Smart::log_warning('SmartMediaGalleryConverter :: mov_pw_process // Invalid Blank Preview Path: BLANK-PREVIEW=' . $y_mov_blank_img_preview);
         return '';
     }
     //end if
     //--
     if ((string) $y_watermark == '') {
         $y_watermark = $watermark_mov_pw;
     }
     //end if
     //--
     //--
     if (!SmartFileSysUtils::check_file_or_dir_name($y_mov_file)) {
         Smart::log_warning('SmartMediaGalleryConverter :: mov_pw_process // Unsafe Path: SRC=' . $y_mov_file);
         return '';
     }
     //end if
     //--
     if (!SmartFileSysUtils::check_file_or_dir_name($y_mov_img_preview)) {
         Smart::log_warning('SmartMediaGalleryConverter :: mov_pw_process // Unsafe Path: DEST=' . $y_mov_img_preview);
         return '';
     }
     //end if
     //--
     if ((string) $y_mov_file == (string) $y_mov_img_preview) {
         Smart::log_warning('SmartMediaGalleryConverter :: mov_pw_process // The Origin movie and Destination image are the same: SRC=' . $y_mov_file . ' ; DEST=' . $y_mov_img_preview);
         return '';
     }
     //end if
     //--
     if ((string) $y_watermark != '') {
         if (!SmartFileSysUtils::check_file_or_dir_name($y_watermark)) {
             $y_watermark = '';
             Smart::log_warning('SmartMediaGalleryConverter :: mov_pw_process // Unsafe Path: WATERMARK=' . $y_watermark);
         }
         //end if
     }
     //end if
     //--
     //--
     $y_quality = Smart::format_number_int($y_quality, '+');
     if ($y_quality < 1) {
         $y_quality = 1;
     }
     //end if
     if ($y_quality > 100) {
         $y_quality = 100;
     }
     //end if
     //--
     //--
     $y_width = Smart::format_number_int($y_width, '+');
     $y_height = Smart::format_number_int($y_height, '+');
     //--
     if ($y_width < 10) {
         $y_width = 10;
     }
     //end if
     if ($y_width > 240) {
         $y_width = 240;
     }
     //end if
     //--
     if ($y_height < 10) {
         $y_height = 10;
     }
     //end if
     if ($y_height > 240) {
         $y_height = 240;
     }
     //end if
     //--
     //-- {{{SYNC-GRAVITY}}}
     switch ((string) $y_waterlocate) {
         case 'northwest':
             $y_waterlocate = 'northwest';
             break;
         case 'northeast':
             $y_waterlocate = 'northeast';
             break;
         case 'southwest':
             $y_waterlocate = 'southwest';
             break;
         case 'southeast':
             $y_waterlocate = 'southeast';
             break;
         case 'center':
         default:
             $y_waterlocate = 'center';
     }
     //end switch
     //--
     //--
     if ((string) SMART_FRAMEWORK_DEBUG_MODE == 'yes') {
         SmartFrameworkRegistry::setDebugMsg('extra', 'MEDIA-GALLERY', ['title' => '[INFO] :: MediaUTIL/Mov/Process-Preview', 'data' => "'" . SMART_FRAMEWORK_MEDIAGALLERY_MOV_THUMBNAILER . "'" . ' :: ' . "'" . SMART_FRAMEWORK_MEDIAGALLERY_IMG_COMPOSITE . "'"]);
     }
     //end if
     //--
     //--
     $out = '';
     //--
     if (defined('SMART_FRAMEWORK_MEDIAGALLERY_MOV_THUMBNAILER') and (string) SMART_FRAMEWORK_MEDIAGALLERY_MOV_THUMBNAILER != '') {
         //--
         $lock_file = $y_mov_img_preview . '.LOCK-MOV-MEDIAGALLERY';
         $temporary_pw = $y_mov_img_preview . '.#tmp-preview#.jpg';
         // {{{SYNC-MOV-TMP-PREVIEW}}}
         //--
         $lock_time = Smart::format_number_int(SmartFileSystem::read($lock_file), '+');
         //--
         if ($lock_time > 0) {
             if ($lock_time + 45 < time()) {
                 // allow max locktime of 45 seconds
                 SmartFileSystem::delete($temporary_pw);
                 // delete the old temporary if any
                 SmartFileSystem::delete($lock_file);
                 // release the lock file
             }
             //end if
         }
         //end if
         //--
         if (is_file($y_mov_file) and !SmartFileSystem::file_or_link_exists($y_mov_img_preview) and !SmartFileSystem::file_or_link_exists($lock_file)) {
             //--
             @chmod($y_mov_file, SMART_FRAMEWORK_CHMOD_FILES);
             //mark chmod
             //--
             $out .= '<table width="550" bgcolor="#74B83F">';
             $out .= '<tr><td>Processing Movie Preview:' . ' ' . "'" . Smart::escape_html(basename($y_mov_file)) . "'" . ' -&gt; ' . "'" . Smart::escape_html(basename($y_mov_img_preview)) . "'" . '</td></tr>';
             //-- create a lock file
             SmartFileSystem::write($lock_file, time());
             //-- generate preview (jpeg)
             if (is_executable(SMART_FRAMEWORK_MEDIAGALLERY_MOV_THUMBNAILER)) {
                 // generate a max preview of 240x240 which will be later converted below
                 $exec = SMART_FRAMEWORK_MEDIAGALLERY_MOV_THUMBNAILER . ' -y -i ' . '"' . $y_mov_file . '"' . ' -s 240x240 -vframes 60 -f image2 -vcodec mjpeg -deinterlace ' . '"' . $temporary_pw . '"';
                 @exec($exec, $arr_result, $exitcode);
             } else {
                 $arr_result = array('error' => 'IS NOT EXECUTABLE ...', 'movie-thumbnailer' => SMART_FRAMEWORK_MEDIAGALLERY_MOV_THUMBNAILER);
                 $exitcode = -1;
             }
             //end if
             //--
             $is_ok_pw = 1;
             if (!is_file($temporary_pw)) {
                 $is_ok_pw = 0;
             } elseif (@filesize($temporary_pw) <= 1444) {
                 // detect if blank jpeg of 240x240
                 $is_ok_pw = 0;
             }
             //end if
             //--
             if ($is_ok_pw != 1) {
                 SmartFileSystem::delete($temporary_pw);
                 SmartFileSystem::copy($y_mov_blank_img_preview, $temporary_pw);
                 // in the case ffmpeg fails we avoid enter into a loop, or if ffmpeg is not found we use a blank preview
             }
             //end if
             //--
             $out .= '<tr><td>[DONE]</td></tr>';
             if ((string) SMART_FRAMEWORK_DEBUG_MODE == 'yes') {
                 SmartFrameworkRegistry::setDebugMsg('extra', 'MEDIA-GALLERY', ['title' => '[INFO] :: MediaUTIL/Mov/Process-Preview/FFMpeg', 'data' => 'Runtime Result: ' . "'" . $y_mov_file . "'" . ' -> ' . "'" . $y_mov_img_preview . "'" . ' = [' . $exitcode . '] @ ' . @print_r($arr_result, 1)]);
             }
             //end if
             //-- process and apply watermark if any
             if (is_file($temporary_pw)) {
                 //--
                 @chmod($temporary_pw, SMART_FRAMEWORK_CHMOD_FILES);
                 //mark chmod
                 //--
                 self::img_process('preview', 'no', $temporary_pw, $y_mov_img_preview, $y_quality, $y_width, $y_height, $y_watermark, $y_waterlocate);
                 //--
                 SmartFileSystem::delete($temporary_pw);
                 //--
             }
             //end if
             //-- release the lock file
             SmartFileSystem::delete($lock_file);
             //--
             $out .= '</table>';
             //--
         }
         //end if
         //--
     }
     //end if
     //--
     //--
     return $out;
     //--
 }
 public static function write_data($db, $query, $params_or_title = '')
 {
     //--
     self::check_connection($db);
     //--
     if ((string) SMART_FRAMEWORK_DEBUG_MODE == 'yes') {
         //--
         $time_start = microtime(true);
         //--
     }
     //end if
     //--
     if (is_array($params_or_title)) {
         $query = self::prepare_param_query($db, $query, $params_or_title);
     }
     //end if
     //--
     $result = @$db->exec($query);
     //--
     if ($result) {
         $affected_rows = @$db->changes();
         // free result is not available for exec, but just for query
         $sqlite_error = '';
     } else {
         $affected_rows = 0;
         $sqlite_error = 'SQLite3-ERR:: ' . @$db->lastErrorMsg();
     }
     //end if
     //--
     if ((string) SMART_FRAMEWORK_DEBUG_MODE == 'yes') {
         //--
         SmartFrameworkRegistry::setDebugMsg('db', 'sqlite|total-queries', 1, '+');
         //--
         $time_end = (double) (microtime(true) - (double) $time_start);
         SmartFrameworkRegistry::setDebugMsg('db', 'sqlite|total-time', $time_end, '+');
         //--
         if (is_array($params_or_title)) {
             $the_query_title = '';
         } else {
             $the_query_title = (string) $params_or_title;
         }
         //end if else
         //--
         if (strtoupper(substr(trim($query), 0, 5)) == 'BEGIN' or strtoupper(substr(trim($query), 0, 6)) == 'COMMIT' or strtoupper(substr(trim($query), 0, 8)) == 'ROLLBACK') {
             SmartFrameworkRegistry::setDebugMsg('db', 'sqlite|log', ['type' => 'transaction', 'data' => 'TRANSACTION :: ' . $the_query_title, 'query' => $query, 'time' => Smart::format_number_dec($time_end, 9, '.', ''), 'connection' => (string) self::get_connection_id($db)]);
         } else {
             SmartFrameworkRegistry::setDebugMsg('db', 'sqlite|log', ['type' => 'write', 'data' => 'WRITE :: ' . $the_query_title, 'query' => $query, 'rows' => $affected_rows, 'time' => Smart::format_number_dec($time_end, 9, '.', ''), 'connection' => (string) self::get_connection_id($db)]);
         }
         //end if else
         //--
     }
     //end if
     //--
     if (strlen($sqlite_error) > 0) {
         $message = 'errorsqlwriteoperation: ' . $sqlite_error;
         self::error($db, 'WRITE-DATA', $sqlite_error, $query, $params_or_title);
         return array($message, 0);
     } else {
         $message = 'oksqlwriteoperation';
     }
     //end if
     //--
     return array($message, Smart::format_number_int($affected_rows, '+'));
     //--
 }
 /**
  * Class Constructor - will initiate also the custom connection for a MySQL Server specified as parameters of this function.
  *
  * @param ARRAY $y_configs_arr 					:: The Array of Configuration parameters - the ARRAY STRUCTURE should be identical with the default config.php: $configs['mysqli'].
  *
  */
 public function __construct($y_configs_arr)
 {
     //--
     $y_configs_arr = (array) $y_configs_arr;
     //-- {{{SYNC-CONNECTIONS-IDS}}}
     $the_conn_key = (string) $y_configs_arr['server-host'] . ':' . $y_configs_arr['server-port'] . '@' . $y_configs_arr['dbname'] . '#' . $y_configs_arr['username'] . '>' . trim(strtoupper(str_replace(' ', '', (string) $y_configs_arr['transact']))) . '.';
     if (array_key_exists((string) $the_conn_key, (array) SmartFrameworkRegistry::$Connections['mysqli'])) {
         //-- try to reuse the connection :: only check if array key exists, not if it is a valid resource ; this should be as so to avoid mismatching connection mixings (if by example will re-use the connection of another server, and connection is broken in the middle of a transaction, it will fail ugly ;) and out of any control !
         $this->connection =& SmartFrameworkRegistry::$Connections['mysqli'][(string) $the_conn_key];
         //--
         if ((string) SMART_FRAMEWORK_DEBUG_MODE == 'yes') {
             SmartFrameworkRegistry::setDebugMsg('db', 'mysqli|log', ['type' => 'open-close', 'data' => 'Re-Using Connection to MySQLi Server: ' . $the_conn_key, 'connection' => (string) SmartMysqliDb::get_connection_id($this->connection)]);
         }
         //end if
         //--
     } else {
         //-- connect
         $this->connection = SmartMysqliDb::server_connect((string) $y_configs_arr['server-host'], (int) $y_configs_arr['server-port'], (string) $y_configs_arr['dbname'], (string) $y_configs_arr['username'], (string) $y_configs_arr['password'], (int) $y_configs_arr['timeout'], (string) $y_configs_arr['transact'], (double) $y_configs_arr['slowtime'], (string) $y_configs_arr['type']);
         //--
         $this->check_server_version();
         //--
     }
     //end if else
     //--
 }
 private function solr_connect()
 {
     //--
     if (!is_object($this->instance)) {
         //--
         $options = array('hostname' => $this->host, 'port' => $this->port);
         //--
         $this->protocol = 'http://';
         if ((string) $this->ssl === true) {
             $options['secure'] = true;
             $this->protocol = 'https://';
         }
         //end if
         //--
         if ((string) $this->user != '') {
             $options['login'] = $this->user;
             $options['login'] = $this->password;
         }
         //end if
         //--
         $options['timeout'] = $this->timeout;
         //--
         $options['path'] = $this->db;
         //--
         $options['wt'] = $this->mode;
         //--
         if ((string) SMART_FRAMEWORK_DEBUG_MODE == 'yes') {
             //--
             SmartFrameworkRegistry::setDebugMsg('db', 'solr|log', ['type' => 'open-close', 'data' => 'Solr DB :: Open Connection [' . $this->mode . '] to DB: ' . $this->db . ' :: ' . $this->description . ' @ HOST: ' . $this->protocol . $this->host . ':' . $this->port . ' # User: '******'Solr ERROR # Connect # ' . $e->getMessage());
             //--
         }
         //end try catch
         //--
         return false;
         //--
     } else {
         //--
         return true;
         //--
     }
     //end if else
     //--
 }
 /**
  * this is for disconnect from MongoDB
  *
  * @access 		private
  * @internal
  *
  */
 public function disconnect()
 {
     //--
     if (!is_object($this->mongoclient)) {
         return null;
     }
     //end if
     //--
     $the_conn_key = (string) $this->server . '@' . $this->db . ':' . $this->collection;
     //--
     if (array_key_exists((string) $the_conn_key, (array) SmartFrameworkRegistry::$Connections['mongodb'])) {
         if (Smart::array_size(SmartFrameworkRegistry::$Connections['mongodb'][(string) $the_conn_key]) > 0) {
             //--
             foreach (SmartFrameworkRegistry::$Connections['mongodb'][(string) $the_conn_key] as $c) {
                 //--
                 $this->mongoclient->close($c['hash']);
                 //--
                 if ((string) SMART_FRAMEWORK_DEBUG_MODE == 'yes') {
                     //--
                     SmartFrameworkRegistry::setDebugMsg('db', 'mongodb|log', ['type' => 'open-close', 'data' => 'MongoDB Connection Closed :: Resource-Hash: ' . $c['hash']]);
                     //--
                 }
                 //end if
                 //--
             }
             //end foreach
             //--
         }
         //end if
     }
     //end if
     //--
 }
 /**
  * Displays the Redis Errors and HALT EXECUTION (This have to be a FATAL ERROR as it occur when a FATAL Redis ERROR happens or when Data Exchange fails)
  * PRIVATE
  *
  * @param BOOL $is_fatal :: TRUE / FALSE if the Error is Fatal or Not
  * @param STRING $y_area :: The Area
  * @param STRING $y_error_message :: The Error Message to Display
  * @param STRING $y_query :: The query
  * @param STRING $y_warning :: The Warning Title
  *
  * @return :: HALT EXECUTION WITH ERROR MESSAGE
  *
  */
 private function error($is_fatal, $y_area, $y_error_message, $y_query = '', $y_warning = '')
 {
     //--
     $this->err = true;
     // required, to halt driver
     //--
     $is_fatal = (bool) $is_fatal;
     //--
     if ($is_fatal !== false) {
         // FATAL ERROR
         //--
         $def_warn = 'Execution Halted !';
         $y_warning = (string) trim((string) $y_warning);
         if ((string) SMART_FRAMEWORK_DEBUG_MODE == 'yes') {
             $width = 750;
             $the_area = (string) $y_area;
             if ((string) $y_warning == '') {
                 $y_warning = (string) $def_warn;
             }
             //end if
             $the_error_message = 'Operation FAILED: ' . $def_warn . "\n" . $y_error_message;
             $the_params = '- ' . $this->description . ' -';
             $the_query_info = (string) $y_query;
             if ((string) $the_query_info == '') {
                 $the_query_info = '-';
                 // query cannot e empty in this case (templating enforcement)
             }
             //end if
         } else {
             $width = 550;
             $the_area = '';
             $the_error_message = 'Operation FAILED: ' . $def_warn;
             $the_params = '';
             $the_query_info = '';
             // do not display query if not in debug mode ... this a security issue if displayed to public ;)
         }
         //end if else
         //--
         $out = SmartComponents::db_error_message('Redis Client', 'Redis', 'Caching', 'Server', 'lib/core/img/db/redis_logo_trans.png', $width, $the_area, $the_error_message, $the_params, $the_query_info);
         //--
         Smart::raise_error('#REDIS@' . $this->socket . '# :: Q# // Redis Client :: ERROR :: ' . $y_area . "\n" . '*** Error-Message: ' . $y_error_message . "\n" . '*** Command:' . "\n" . $y_query, $out);
         die('');
         // just in case
         //--
     } else {
         // SILENT WARNING
         //--
         if ((string) SMART_FRAMEWORK_DEBUG_MODE == 'yes') {
             //--
             SmartFrameworkRegistry::setDebugMsg('db', 'redis|log', ['type' => 'metainfo', 'data' => 'Redis SILENT WARNING: ' . $y_area . "\n" . $y_query . "\n" . 'Error-Message: ' . $y_error_message . "\n" . 'The settings for this Redis instance allow just silent warnings on connection fail.' . "\n" . 'All next method calls to this Redis instance will be discarded silently ...']);
             //--
         }
         //end if
         //--
         Smart::log_warning('#REDIS@' . $this->socket . '# :: Q# // Redis :: WARNING :: ' . $y_area . "\n" . '*** Error-Message: ' . $y_error_message . "\n" . '*** Command:' . "\n" . $y_query);
         //--
     }
     //end if else
     //--
 }
 /**
  * Get a Request Variable (GET/POST) in a controller
  *
  * @param 	STRING 		$key			:: The name (key) of the GET or POST variable (if the variable is set in both GET and POST, the GPC as set in PHP.INI sequence will overwrite the GET with POST, thus the POST value will be get).
  * @param	MIXED		$defval			:: The default value (if a type is set must be the same type) of that variable in the case was not set in the Request (GET/POST). By default it is set to null.
  * @param	ENUM		$type			:: The type of the variable ; Default is '' (no enforcing). This can be used to enforce a type for the variable as: ['enum', 'list', 'of', 'allowed', 'values'], 'array', 'string', 'boolean', 'integer', 'integer+', 'integer-', 'decimal1', 'decimal2', 'decimal3', 'decimal4', 'numeric'.
  *
  * @return 	MIXED						:: The value of the choosen Request (GET/POST) variable
  */
 public final function RequestVarGet($key, $defval = null, $type = '')
 {
     // {{{SYNC-REQUEST-DEF-PARAMS}}}
     //--
     return SmartFrameworkRegistry::getRequestVar($key, $defval, $type);
     // mixed
     //--
 }
 /**
  * Send Email Mime Message from custom MailBox to a destination
  *
  * @param ARRAY			$y_server_settings	arr = [ server_name, server_port, server_sslmode, server_auth_user, server_auth_pass, send_from_addr, send_from_name, smtp_mxdomain ]
  * @param ENUM			$y_mode				'send' = do send | 'send-return' = do send + return | 'return' = return mime formated mail
  * @param STRING 		$to					To:
  * @param STRING 		$cc					Cc: | empty
  * @param STRING 		$subj				Subject:
  * @param STRING 		$message			Body/Message:
  * @param TRUE/FALSE 	$is_html			* Format: Html or Text/Plain
  * @param ARRAY 		$attachments		* $attachments = array('file1.txt'=>'This is the file 1 content', ...);
  * @param ENUM			$charset			* charset
  * @param ENUM			$priority			* 1=High ; 3=Normal ; 5=Low
  * @param STRING 		$inreplyto			'' | the ID of message that is replying to
  * @return ARRAY							OPERATION RESULT, ERROR, MIME MESSAGE
  */
 public static function send_extended_email($y_server_settings, $y_mode, $to, $cc, $subj, $message, $is_html, $attachments, $charset, $priority, $inreplyto, $bcc = '', $replytoaddr = '')
 {
     //-- SMTP Hello
     $server_helo = trim($y_server_settings['smtp_mxdomain']);
     //-- SMTP connection vars
     $server_name = trim($y_server_settings['server_name']);
     $server_port = trim($y_server_settings['server_port']);
     $server_sslmode = trim($y_server_settings['server_sslmode']);
     $server_user = trim($y_server_settings['server_auth_user']);
     $server_pass = trim($y_server_settings['server_auth_pass']);
     //-- SEND FROM
     $send_from_addr = trim($y_server_settings['send_from_addr']);
     $send_from_name = trim($y_server_settings['send_from_name']);
     //--
     //-- mail send class init
     $mail = new SmartMailerSend();
     $mail->usealways_b64 = true;
     //--
     if ((string) $server_name == '@mail') {
         //--
         if ((string) SMART_FRAMEWORK_DEBUG_MODE == 'yes') {
             SmartFrameworkRegistry::setDebugMsg('mail', 'SEND', 'Send eMail Method Selected: [MAIL]');
         }
         //end if
         //-- mail method
         $mail->method = 'mail';
         //--
     } elseif (strlen($server_name) > 0) {
         //--
         if ((string) SMART_FRAMEWORK_DEBUG_MODE == 'yes') {
             SmartFrameworkRegistry::setDebugMsg('mail', 'SEND', 'Send eMail Method Selected: [SMTP]');
         }
         //end if
         //-- smtp server method
         $mail->method = 'smtp';
         $mail->smtp_timeout = '30';
         //--
         $mail->smtp_helo = $server_helo;
         $mail->smtp_server = $server_name;
         $mail->smtp_port = $server_port;
         $mail->smtp_ssl = $server_sslmode;
         //--
         if ((string) SMART_FRAMEWORK_DEBUG_MODE == 'yes') {
             $mail->debuglevel = 1;
             // default is 1
         } else {
             $mail->debuglevel = 0;
             // no debug
         }
         //end if else
         //--
         if ((string) $server_user == '' or (string) $server_pass == '') {
             $mail->smtp_login = false;
         } else {
             $mail->smtp_login = true;
             $mail->smtp_user = $server_user;
             $mail->smtp_password = $server_pass;
         }
         //end if
         //--
     } else {
         //--
         if ((string) SMART_FRAMEWORK_DEBUG_MODE == 'yes') {
             SmartFrameworkRegistry::setDebugMsg('mail', 'SEND', 'Send eMail Method Selected: [NONE] !!!');
         }
         //end if
         //--
         $mail->method = 'skip';
         //--
     }
     //end if else
     //--
     //-- charset
     if ((string) $charset == '') {
         $charset = 'UTF-8';
         // default
     }
     //end if
     //--
     $mail->charset = (string) $charset;
     //--
     //--
     if ((string) $mail->charset != 'UTF-8') {
         // in this case (ISO-88591 / ISO-8859-2) we deaccent the things for maximum compatibility
         $send_from_name = SmartUnicode::deaccent_str($send_from_name);
         $subj = SmartUnicode::deaccent_str($subj);
         $message = SmartUnicode::deaccent_str($message);
     }
     //end if
     //--
     //--
     $tmp_explode_arr = (array) explode('@', (string) $send_from_addr);
     $tmp_name = trim($tmp_explode_arr[0]);
     // not used
     $tmp_domain = trim($tmp_explode_arr[1]);
     // used for message ID
     //--
     $tmp_my_uid = getmyuid();
     $tmp_my_gid = getmygid();
     //--
     //-- Extra Mail Headers
     $mail->headers = '';
     //-- Errors Reporting Header
     $mail->headers .= 'Errors-To: ' . $send_from_addr . "\r\n";
     //-- In-Reply-To Header
     if ((string) $inreplyto != '') {
         $mail->headers .= 'In-Reply-To: ' . $inreplyto . "\r\n";
     }
     //end if else
     //-- Reply-To Header
     if ((string) $replytoaddr != '') {
         $mail->headers .= 'Reply-To: ' . $replytoaddr . "\r\n";
     }
     //end if
     //-- antiSPAM Header
     $mail->headers .= 'X-AntiAbuse: This header was added to track abuse, please include it with any abuse report' . "\r\n";
     $mail->headers .= 'X-AntiAbuse: Primary Hostname - ' . $server_helo . "\r\n";
     $mail->headers .= 'X-AntiAbuse: Original Domain - ' . $server_helo . "\r\n";
     $mail->headers .= 'X-AntiAbuse: Originator/Caller UID/GID - [48880 48885] / [' . $tmp_my_uid . ' ' . $tmp_my_gid . ']' . "\r\n";
     $mail->headers .= 'X-AntiAbuse: Sender Address Domain - ' . $tmp_domain . "\r\n";
     //--
     //--
     $mail->priority = $priority;
     // high=1 | low=5 | normal=3
     //--
     //-- from
     $mail->from_return = $send_from_addr;
     $mail->from = $send_from_addr;
     $mail->namefrom = $send_from_name;
     //--
     //-- subject
     $mail->subject = $subj;
     //--
     //-- if message is html, include CID imgs as attachments
     if ((string) $y_mode != 'return' and $is_html) {
         //-- init
         $arr_links = array();
         //-- embedd all images
         $htmlparser = new SmartHtmlParser($message);
         $htmlparser->get_clean_html();
         // to be tested ...
         $arr_links = $htmlparser->get_tags('img');
         $htmlparser = '';
         unset($htmlparser);
         //--
         $chk_duplicates_arr = array();
         $uniq_id = 0;
         //--
         for ($i = 0; $i < Smart::array_size($arr_links); $i++) {
             //--
             $tmp_original_img_link = trim($arr_links[$i][src]);
             // trim any possible spaces
             //-- reverse the &amp; back to & (generated from JavaScript) ...
             $tmp_imglink = str_replace('&amp;', '&', (string) $tmp_original_img_link);
             //--
             $tmp_cid = 'img_' . sha1('SmartFramework eMail-Utils // CID Embedd // ' . '@' . $tmp_imglink . '#');
             // this should not vary by $i or others because if duplicate images are detected only the first is attached
             //--
             if (strlen($chk_duplicates_arr[$tmp_cid]) <= 0) {
                 // avoid browse twice the same image
                 //--
                 $tmp_original_lnk = (string) $tmp_imglink;
                 $tmp_eval_link = (string) $tmp_imglink;
                 $tmp_allow_credentials = 'no';
                 if (substr($tmp_original_lnk, 0, 10) == 'admin.php?') {
                     $tmp_original_lnk = (string) SmartUtils::get_server_current_url() . $tmp_imglink;
                     $tmp_allow_credentials = 'yes';
                     // in the case we have embedded pictures generated by admin.php who always need authentication to work, we have to send credentials too
                     $tmp_eval_link = '';
                     // we clear to re-eval
                 } elseif (SmartUnicode::sub_str($tmp_original_lnk, 0, SmartUnicode::str_len(SmartUtils::get_server_current_url() . 'admin.php?')) == SmartUtils::get_server_current_url() . 'admin.php?' and (substr($tmp_original_lnk, 0, 7) == 'http://' or substr($tmp_original_lnk, 0, 8) == 'https://')) {
                     $tmp_allow_credentials = 'yes';
                     // in the case we have embedded pictures generated by admin.php who always need authentication to work, we have to send credentials too
                     $tmp_eval_link = '';
                     // we clear to re-eval
                 } elseif (substr($tmp_original_lnk, 0, 10) == 'index.php?' or substr($tmp_original_lnk, 0, 1) == '?') {
                     $tmp_original_lnk = (string) SmartUtils::get_server_current_url() . $tmp_imglink;
                     $tmp_eval_link = '';
                     // we clear to re-eval
                 } elseif (SmartUnicode::sub_str($tmp_original_lnk, 0, SmartUnicode::str_len(SmartUtils::get_server_current_url() . 'index.php?')) == SmartUtils::get_server_current_url() . 'index.php?' and (substr($tmp_original_lnk, 0, 7) == 'http://' or substr($tmp_original_lnk, 0, 8) == 'https://')) {
                     $tmp_eval_link = '';
                     // we clear to re-eval
                 } elseif (SmartUnicode::sub_str($tmp_original_lnk, 0, SmartUnicode::str_len(SmartUtils::get_server_current_url() . '?')) == SmartUtils::get_server_current_url() . '?' and (substr($tmp_original_lnk, 0, 7) == 'http://' or substr($tmp_original_lnk, 0, 8) == 'https://')) {
                     $tmp_eval_link = '';
                     // we clear to re-eval
                 }
                 //end if
                 //--
                 $tmp_browse_arr = array();
                 $tmp_browse_arr = SmartUtils::load_url_or_file($tmp_original_lnk, SMART_FRAMEWORK_NETSOCKET_TIMEOUT, 'GET', '', '', '', $tmp_allow_credentials);
                 // [OK]
                 //Smart::log_notice(print_r($tmp_browse_arr,1));
                 //--
                 $guess_arr = array();
                 $guess_arr = SmartUtils::guess_image_extension_by_url_head($tmp_browse_arr['headers']);
                 $tmp_img_ext = (string) $guess_arr['extension'];
                 $tmp_where_we_guess = (string) $guess_arr['where-was-detected'];
                 //Smart::log_notice('Guess Ext by URL Head: '.$tmp_browse_arr['headers']."\n".'### '.print_r($guess_arr,1)."\n".'#');
                 if ((string) $tmp_img_ext == '') {
                     $tmp_img_ext = SmartUtils::guess_image_extension_by_first_bytes(substr($tmp_browse_arr['content'], 0, 256));
                     if ((string) $tmp_img_ext != '') {
                         $tmp_where_we_guess = ' First Bytes ...';
                     }
                     //end if
                 }
                 //end if
                 //Smart::log_notice('Guess Ext by First Bytes: '.$tmp_img_ext."\n".'#');
                 if ((string) $tmp_eval_link == '') {
                     $tmp_eval_link = 'file' . $tmp_img_ext;
                 }
                 //end if
                 //--
                 $tmp_fcontent = '';
                 if ((string) $tmp_browse_arr['result'] == '1' and (string) $tmp_browse_arr['code'] == '200') {
                     if ((string) $tmp_img_ext == '' or (string) $tmp_img_ext == '.png' or (string) $tmp_img_ext == '.gif' or (string) $tmp_img_ext == '.jpg') {
                         $tmp_fcontent = (string) $tmp_browse_arr['content'];
                     }
                     //end if
                 }
                 //end if else
                 //--
                 if (strlen($tmp_fcontent) > 0) {
                     //--
                     $tmp_arr_fmime = array();
                     $tmp_arr_fmime = SmartFileSysUtils::mime_eval($tmp_eval_link);
                     //--
                     $tmp_fmime = (string) $tmp_arr_fmime[0];
                     if ((string) $tmp_fmime == '' or (string) $tmp_fmime == 'application/octet-stream') {
                         $tmp_fmime = 'image';
                         // in the case of CIDS we already pre-validated the images
                     }
                     //end if
                     $tmp_fname = 'cid_' . $uniq_id . '__' . $tmp_cid . $tmp_img_ext;
                     //--
                     $mail->add_attachment($tmp_fcontent, $tmp_fname, $tmp_fmime, 'inline', $tmp_cid . $tmp_img_ext);
                     // attachment
                     $message = str_replace('src="' . $tmp_original_img_link . '"', 'src="cid:' . $tmp_cid . $tmp_img_ext . '"', $message);
                     //--
                     $uniq_id += 1;
                     //--
                 }
                 //end if
                 //--
                 $chk_duplicates_arr[$tmp_cid] = 'embedd';
                 //--
             }
             //end if
             //--
         }
         //end for
         //-- clean
         $chk_duplicates_arr = array();
         $uniq_id = 0;
         $tmp_original_img_link = '';
         $tmp_imglink = '';
         $tmp_cid = '';
         $tmp_browse_arr = array();
         $tmp_fcontent = '';
         $tmp_arr_fmime = array();
         $tmp_fmime = '';
         $tmp_fname = '';
         //--
     }
     //end if
     //--
     //-- message body
     $mail->is_html = $is_html;
     // false | true
     $mail->body = $message;
     //--
     $message = '';
     unset($message);
     //--
     //-- attachments
     if (is_array($attachments)) {
         if (Smart::array_size($attachments) > 0) {
             while (list($key, $val) = each($attachments)) {
                 //--
                 $tmp_arr_fmime = array();
                 $tmp_arr_fmime = SmartFileSysUtils::mime_eval($key);
                 //--
                 $mail->add_attachment($val, $key, (string) $tmp_arr_fmime[0], 'attachment', '', 'yes');
                 // force as real attachments
                 //--
             }
             //end while
         }
         //end if
     }
     //end if
     //--
     //--
     switch ((string) $y_mode) {
         case 'return':
             //--
             $mail->to = '[::!::]';
             $mail->cc = '';
             //-- only return mime formated message
             $mail->send('no');
             return array('result' => 1, 'error' => '', 'message' => $mail->mime_message);
             //--
             break;
         case 'send-return':
         case 'send':
         default:
             //--
             $out = 0;
             //--
             $arr_to = array();
             if (!is_array($to)) {
                 $arr_to[] = (string) $to;
                 $tmp_send_to = (string) $to;
             } else {
                 $arr_to = (array) $to;
                 if (Smart::array_size($arr_to) > 1) {
                     $tmp_send_to = '[::@::]';
                     // multi message
                 } else {
                     $tmp_send_to = (string) $arr_to[0];
                 }
                 //end if else
             }
             //end if else
             //--
             $tmp_send_log = '';
             $tmp_send_log .= '-----------------------------------------------------------------------' . "\n";
             $tmp_send_log .= 'Smart / eMail Send Log :: ' . $send_from_addr . ' [' . $send_from_name . ']' . "\n";
             $tmp_send_log .= $server_sslmode . '://' . $server_name . ':' . $server_port . ' # ' . $server_user . ' :: ' . $server_helo . "\n";
             $tmp_send_log .= '-----------------------------------------------------------------------' . "\n";
             //--
             $counter_sent = 0;
             for ($i = 0; $i < Smart::array_size($arr_to); $i++) {
                 //--
                 $arr_to[$i] = trim($arr_to[$i]);
                 //--
                 if (strlen($arr_to[$i]) > 0) {
                     //--
                     $mail->to = (string) $arr_to[$i];
                     //--
                     $mail->cc = $cc;
                     // can be string or array
                     //--
                     $mail->bcc = (string) $bcc;
                     //--
                     $tmp_send_log .= '#' . ($i + 1) . '. To: \'' . $arr_to[$i] . '\' :: ' . date('Y-m-d H:i:s O');
                     //-- real send
                     if ((string) $mail->method == 'mail' or (string) $mail->method == 'smtp') {
                         $err = $mail->send('yes');
                         if ((string) SMART_FRAMEWORK_DEBUG_MODE == 'yes') {
                             SmartFrameworkRegistry::setDebugMsg('mail', 'SEND', 'Send eMail Log #' . ($i + 1) . ': ' . $mail->log);
                         }
                         //end if
                     } else {
                         $err = 'WARNING: SMTP Server or Mail Method IS NOT SET in CONFIG. Send eMail - Operation ABORTED !';
                     }
                     //end if else
                     //--
                     if ((string) SMART_FRAMEWORK_DEBUG_MODE == 'yes') {
                         SmartFrameworkRegistry::setDebugMsg('mail', 'SEND', '========== SEND TO: ' . $arr_to[$i] . ' ==========' . "\n" . 'ERRORS: ' . $err . "\n" . '==========' . "\n" . $mail->log . "\n" . '========== # ==========');
                     }
                     //end if
                     //--
                     if (strlen($err) > 0) {
                         $tmp_send_log .= ' :: ERROR:' . "\n" . $arr_to[$i] . "\n" . $err . "\n";
                     } else {
                         $counter_sent += 1;
                         $tmp_send_log .= ' :: OK' . "\n";
                     }
                     //end if else
                     //--
                     if ($i > 10000) {
                         break;
                         // hard limit
                     }
                     //end if
                     //--
                 }
                 //end if
                 //--
             }
             //end for
             //--
             if ($counter_sent > 0) {
                 $out = 1;
             }
             //end if
             //--
             $tmp_send_log .= '-----------------------------------------------------------------------' . "\n\n";
             if ((string) SMART_FRAMEWORK_DEBUG_MODE == 'yes') {
                 SmartFrameworkRegistry::setDebugMsg('mail', 'SEND', 'Send eMail Operations Log: ' . $tmp_send_log);
             }
             //end if
             //--
             if ((string) $y_mode == 'send-return') {
                 $mail->to = $tmp_send_to;
                 if (is_array($cc)) {
                     $mail->cc = (string) implode(', ', $cc);
                 } elseif ((string) $cc != '') {
                     $mail->cc = (string) $cc;
                 }
                 //end if else
                 $mail->add_attachment($tmp_send_log, 'smart-email-send.log', 'text/plain', 'inline');
                 $mail->send('no');
                 return array('result' => $out, 'error' => $err, 'log' => $tmp_send_log, 'message' => $mail->mime_message);
             } else {
                 return array('result' => $out, 'error' => $err, 'log' => $tmp_send_log, 'message' => '');
                 // skip returning the message
             }
             //end if else
             //--
     }
     //end switch
     //--
 }
 private static function getFromOptimalPlace($y_area, $y_subarea)
 {
     //-- normalize params
     $y_area = (string) $y_area;
     $y_subarea = (string) $y_subarea;
     //-- get the current language
     $the_lang = self::getLanguage();
     //-- built the cache key
     $the_cache_key = (string) $the_lang . '.' . $y_area . '.' . $y_subarea;
     // must use . as separator as it is the only character that is not allowed in lang / area / sub-area but is allowed in persistent cache
     //-- try to get from internal (in-memory) cache
     $translations = (array) self::$cache['translations@' . $the_cache_key];
     if (Smart::array_size($translations) > 0) {
         if (defined('SMART_FRAMEWORK_INTERNAL_DEBUG')) {
             if ((string) SMART_FRAMEWORK_DEBUG_MODE == 'yes') {
                 SmartFrameworkRegistry::setDebugMsg('extra', '***REGIONAL-TEXTS***', ['title' => 'Get Text from Internal Cache for Key: ' . $the_cache_key, 'data' => 'Content:' . "\n" . print_r($translations, 1)]);
             }
             //end if
         }
         //end if
         return (array) $translations;
     }
     //end if
     //-- try to get from persistent cache
     $version_translations = (string) self::getLatestVersion();
     // get translations version
     $translations = (array) self::getFromPersistentCache((string) $the_cache_key, (string) $version_translations);
     if (Smart::array_size($translations) > 0) {
         if (defined('SMART_FRAMEWORK_INTERNAL_DEBUG')) {
             if ((string) SMART_FRAMEWORK_DEBUG_MODE == 'yes') {
                 SmartFrameworkRegistry::setDebugMsg('extra', '***REGIONAL-TEXTS***', ['title' => 'Get Text from Persistent Cache for Key: ' . $the_cache_key, 'data' => 'Version:' . "\n" . $version_translations . "\n" . 'Content:' . "\n" . print_r($translations, 1)]);
             }
             //end if
         }
         //end if
         self::$cache['translations@' . $the_cache_key] = (array) $translations;
         return (array) $translations;
     }
     //end if
     //-- try to get from source
     $translations = (array) self::getFromSource($the_lang, $y_area, $y_subarea);
     if (Smart::array_size($translations) > 0) {
         if (defined('SMART_FRAMEWORK_INTERNAL_DEBUG')) {
             if ((string) SMART_FRAMEWORK_DEBUG_MODE == 'yes') {
                 SmartFrameworkRegistry::setDebugMsg('extra', '***REGIONAL-TEXTS***', ['title' => 'Get Text from Sources for Key: ' . $the_cache_key, 'data' => 'Content:' . "\n" . print_r($translations, 1)]);
             }
             //end if
         }
         //end if
         self::$cache['translations@' . $the_cache_key] = (array) $translations;
         self::setInPersistentCache((string) $the_cache_key, (array) $translations);
         return (array) $translations;
     }
     //end if
     //--
     if (defined('SMART_FRAMEWORK_INTERNAL_DEBUG')) {
         if ((string) SMART_FRAMEWORK_DEBUG_MODE == 'yes') {
             SmartFrameworkRegistry::setDebugMsg('extra', '***REGIONAL-TEXTS***', ['title' => '!!! FAILED !!! to Get Text from Sources for Key: ' . $the_cache_key, 'data' => 'Content:' . "\n" . print_r($translations, 1)]);
         }
         //end if
     }
     //end if
     Smart::log_warning('Cannot get from source Text Translations for Key: ' . $the_cache_key);
     return array();
     // this is invalid, means not found in any places
     //--
 }