public static function cache_variable_archive($y_var) { //-- $raw_data = (string) Smart::seryalize($y_var); $y_var = ''; // free mem if ((string) $raw_data == '') { return ''; } //end if //-- compress $arch_data = @gzcompress((string) $raw_data, 6, ZLIB_ENCODING_DEFLATE); // zlib compress (default compression of zlib is 6) //-- check for possible compress errors if ($arch_data === false or (string) $arch_data == '') { Smart::log_warning('SmartFramework Utils / Cache Variable Archive :: ZLib Compress ERROR ! ...'); return ''; } //end if $len_data = strlen((string) $raw_data); $len_arch = strlen((string) $arch_data); if ($len_data > 0 and $len_arch > 0) { $ratio = $len_data / $len_arch; } else { $ratio = 0; } //end if if ($ratio <= 0) { // check for empty input / output ! Smart::log_warning('SmartFramework Utils / Cache Variable Archive :: ZLib Data Ratio is zero ! ...'); return ''; } //end if if ($ratio > 32768) { // check for this bug in ZLib {{{SYNC-GZDEFLATE-ERR-CHECK}}} Smart::log_warning('SmartFramework Utils / Cache Variable Archive :: ZLib Data Ratio is higher than 32768 ! ...'); return ''; } //end if //-- $raw_data = ''; // free mem //-- return (string) base64_encode((string) $arch_data); //-- }
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; //-- }
private static function setInPersistentCache($the_cache_key, $y_data_arr) { //-- if (SmartPersistentCache::isActive() and SmartPersistentCache::isMemoryBased()) { if (Smart::array_size($y_data_arr) > 0) { SmartPersistentCache::setKey('smart-regional-texts', (string) $the_cache_key, (string) Smart::seryalize((array) $y_data_arr)); } //end if } //end if //-- }