public static function cache_variable_unarchive($y_cache_arch_var) { //-- if ((string) $y_cache_arch_var == '') { return null; // no data to unarchive, return empty string } //end if //-- $raw_str = @base64_decode((string) $y_cache_arch_var); $y_cache_arch_var = ''; // free mem if ($raw_str === false or trim((string) $raw_str) == '') { // use trim, the deflated string can't contain only spaces return null; // something went wrong after b64 decoding ... } //end if //-- $raw_str = @gzuncompress((string) $raw_str); if ($raw_str === false or trim((string) $raw_str) == '') { // use trim, the string before unseryalize can't contain only spaces return null; } //end if //-- return Smart::unseryalize((string) $raw_str); // mixed //-- }
public static function print_debug_info($y_area, $y_debug_token) { global $configs; //-- {{{SYNC-DEBUG-DATA}}} if ((string) SMART_FRAMEWORK_DEBUG_MODE != 'yes') { return ''; } //end if //-- if ((string) $y_area != 'idx' and (string) $y_area != 'adm') { return ''; } //end if //-- $y_debug_token = trim((string) $y_debug_token); if ((string) $y_debug_token == '') { return ''; } //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 //-- $storage = (new SmartGetFileSystem(true))->get_storage($the_dir, true, false); $arr = array(); if (is_array($storage['list-files'])) { $storage['list-files'] = Smart::array_sort($storage['list-files'], 'natsort'); for ($i = 0; $i < Smart::array_size($storage['list-files']); $i++) { $arr[] = Smart::unseryalize(SmartFileSystem::read($storage['list-files'][$i])); } //end if } //end if $storage = array(); //-- //-- $debug_response = ''; $debug_resources = ''; $debug_environment = ''; $debug_session = ''; $debug_auth = ''; $debug_mail = ''; $debug_dbqueries = ''; $debug_optimizations = ''; $debug_extra = ''; $debug_modules = ''; $tmp_decode_arr = array(); //-- $start_marker = '<div class="smartframework_debugbar_status smartframework_debugbar_status_title"><font size="5"><b># DEBUG Data :: ALL REQUESTS #</b></font></div>'; $end_marker = '<div class="smartframework_debugbar_status smartframework_debugbar_status_title"><font size="3"><b># DEBUG # END #</b></font></div>'; //-- for ($i = 0; $i < Smart::array_size($arr); $i++) { //-- if ($arr[$i]['is-request-main'] === true) { $txt_main = '<div class="smartframework_debugbar_status smartframework_debugbar_status_title"><font size="5"><b># DEBUG Data :: MAIN REQUEST #</b></font></div>'; } else { $txt_main = '<div class="smartframework_debugbar_status smartframework_debugbar_status_title"><font size="3"><b># DEBUG Data :: SUB-REQUEST #</b></font></div>'; } //end if else $txt_token = '<div class="smartframework_debugbar_status smartframework_debugbar_status_token" style="width: 400px; text-align: center;"><font size="2"><b>Debug Token: ' . Smart::escape_html($arr[$i]['debug-token']) . '</b></font></div>'; $txt_url = '<div class="smartframework_debugbar_status smartframework_debugbar_status_url"><font size="2">URL: ' . Smart::escape_html($arr[$i]['request-uri']) . '</font></div>'; //-- $debug_response .= $txt_main . $txt_url . $txt_token . self::print_log_headers($arr[$i]['response-code'], Smart::unseryalize(base64_decode($arr[$i]['response-headers'])), Smart::unseryalize(base64_decode($arr[$i]['request-headers']))) . '<hr>'; //-- $debug_resources .= $txt_main . $txt_url . $txt_token . self::print_log_resources($arr[$i]['resources-time'], $arr[$i]['resources-memory']); //-- $debug_environment .= $txt_main . $txt_url . $txt_token . self::print_log_environment(Smart::unseryalize(base64_decode($arr[$i]['env-req-filtered'])), Smart::unseryalize(base64_decode($arr[$i]['env-cookies'])), Smart::unseryalize(base64_decode($arr[$i]['env-get'])), Smart::unseryalize(base64_decode($arr[$i]['env-post'])), Smart::unseryalize(base64_decode($arr[$i]['env-server']))) . '<hr>'; //-- $debug_session .= $txt_main . $txt_url . $txt_token . self::print_log_session(Smart::unseryalize(base64_decode($arr[$i]['php-session']))) . '<hr>'; //-- $debug_auth .= $txt_main . $txt_url . $txt_token . self::print_log_auth($arr[$i]['auth-data']) . '<hr>'; //-- if (is_array($arr[$i]['log-optimizations'])) { $debug_optimizations .= $txt_main . $txt_url . $txt_token; foreach ($arr[$i]['log-optimizations'] as $key => $val) { $debug_optimizations .= self::print_log_optimizations(strtoupper((string) $key), Smart::unseryalize(base64_decode($val))) . '<hr>'; } //end foreach } //end if //-- if (is_array($arr[$i]['log-mail'])) { $debug_mail .= $txt_main . $txt_url . $txt_token . self::print_log_mail(Smart::unseryalize(base64_decode($arr[$i]['log-mail']))) . '<hr>'; } //end if //-- if (is_array($arr[$i]['log-db'])) { $debug_dbqueries .= $txt_main . $txt_url . $txt_token; foreach ($arr[$i]['log-db'] as $key => $val) { $debug_dbqueries .= self::print_log_database(strtoupper((string) $key), Smart::unseryalize(base64_decode($val))) . '<hr>'; } //end foreach } //end if //-- if (is_array($arr[$i]['log-extra'])) { $debug_extra .= $txt_main . $txt_url . $txt_token; foreach ($arr[$i]['log-extra'] as $key => $val) { $debug_extra .= self::print_log_extra(strtoupper((string) $key), Smart::unseryalize(base64_decode($val))) . '<hr>'; } //end foreach } //end if //-- if (is_array($arr[$i]['log-modules'])) { $debug_modules .= $txt_main . $txt_url . $txt_token; foreach ($arr[$i]['log-modules'] as $key => $val) { $debug_modules .= self::print_log_modules(strtoupper((string) $key), Smart::unseryalize(base64_decode($val))) . '<hr>'; } //end foreach } //end if //-- } //end for //-- if ((string) $debug_optimizations == '') { $debug_optimizations = '<div class="smartframework_debugbar_status smartframework_debugbar_status_nodata"><font size="5"><b>Optimization Hints: N/A</b></font></div>'; } else { $debug_optimizations .= $end_marker; } //end if else //-- if ((string) $debug_mail == '') { $debug_mail = '<div class="smartframework_debugbar_status smartframework_debugbar_status_nodata"><font size="5"><b>Mail Debug: No data</b></font></div>'; } else { $debug_mail .= $end_marker; } //end if else //-- if ((string) $debug_dbqueries == '') { $debug_dbqueries = '<div class="smartframework_debugbar_status smartframework_debugbar_status_nodata"><font size="5"><b>Database Debug: No Queries found</b></font></div>'; } else { $debug_dbqueries .= $end_marker; } //end if else //-- if ((string) $debug_extra == '') { $debug_extra = '<div class="smartframework_debugbar_status smartframework_debugbar_status_nodata"><font size="5"><b>Extra Debug: No data</b></font></div>'; } else { $debug_extra .= $end_marker; } //end if else //-- if ((string) $debug_modules == '') { $debug_modules = '<div class="smartframework_debugbar_status smartframework_debugbar_status_nodata"><font size="5"><b>Modules Debug: No data</b></font></div>'; } else { $debug_modules .= $end_marker; } //end if else //-- //-- return SmartMarkersTemplating::render_file_template('lib/core/templates/debug-profiler-footer.inc.htm', array('DEBUG-TIME' => date('Y-m-d H:i:s O'), 'DEBUG-RUNTIME' => $start_marker . self::print_log_runtime() . $end_marker, 'DEBUG-CONFIGS' => $start_marker . self::print_log_configs() . $end_marker, 'DEBUG-RESOURCES' => $debug_resources . $end_marker, 'DEBUG-HEADERS' => $debug_response . $end_marker, 'DEBUG-ENVIRONMENT' => $debug_environment . $end_marker, 'DEBUG-SESSION' => $debug_session . $end_marker, 'DEBUG-AUTH' => $debug_auth . $end_marker, 'DEBUG-OPTIMIZATIONS' => $debug_optimizations, 'DEBUG-MAIL' => $debug_mail, 'DEBUG-DATABASE' => $debug_dbqueries, 'DEBUG-EXTRA' => $debug_extra, 'DEBUG-MODULES' => $debug_modules), 'no'); //-- }
private static function getFromPersistentCache($the_cache_key, $version_translations) { //-- $arr = array(); //-- if (SmartPersistentCache::isActive() and SmartPersistentCache::isMemoryBased()) { //-- if not set translations versions, set them to internal cache :: this will be executed just once per session and is necessary to keep sync between Persistent Cache Translations and Real Translation Sources if ((string) $version_translations == '') { Smart::log_warning('Empty Version for Text Translations ... It is needed for store them in the Persistent Cache !'); } //end if //-- check if persistent cache texts are outdated $check_version = true; if ((string) self::$cache['#VERSION#'] != '') { $check_version = false; } elseif ((string) $version_translations === (string) SmartPersistentCache::getKey('smart-regional-texts', 'version')) { $check_version = false; } //end if else if ($check_version !== false) { //-- cleanup the outdated text keys from persistent cache SmartPersistentCache::unsetKey('smart-regional-texts', '*'); //-- re-register in persistent cache the Date and Version (after cleanup) if (!SmartPersistentCache::keyExists('smart-regional-texts', 'version')) { if (!SmartPersistentCache::keyExists('smart-regional-texts', 'date')) { if (SmartPersistentCache::setKey('smart-regional-texts', 'date', 'Cached on: ' . date('Y-m-d H:i:s O'))) { SmartPersistentCache::setKey('smart-regional-texts', 'version', (string) $version_translations); } //end if } //end if } //end if //-- } else { // text keys in persistent cache appear to be latest version, try to get it //-- self::$cache['#VERSION#'] = (string) $version_translations; //-- $rdata = SmartPersistentCache::getKey('smart-regional-texts', (string) $the_cache_key); if ($rdata) { // here evaluates if non-false $rdata = Smart::unseryalize((string) $rdata); } //end if if (Smart::array_size($rdata) > 0) { $arr = (array) $rdata; } //end if $rdata = ''; // clear //-- } //end if //-- } //end if //-- return (array) $arr; //-- }