', file_get_contents('style/' . $tplname)); ob_start(); eval('?> ' . $tpl . ''; $written = false; if (is_writable($_path)) { $fh = @fopen($_path . 'config.php', 'wb'); if ($fh) { fwrite($fh, $data); fclose($fh); $written = true; } } if(!$written) { header('Content-Type: text/x-delimtext; name="config.php"'); header('Content-disposition: attachment; filename=config.php'); echo $data; exit; } return true; } /** * Usefull to caluculte time of execution */ function get_microtime() { list($usec, $sec) = explode(' ', microtime()); return ((float) $usec + (float) $sec); } /** * Get config value from database directly, if not return false. */ function inst_get_config($name) { global $SQL, $dbprefix; if(!$SQL) { global $dbserver, $dbuser, $dbpass, $dbname; if(!isset($dbserver)) { return false; } $SQL = new KleejaDatabase($dbserver, $dbuser, $dbpass, $dbname); } if(!$SQL) { return false; } $sql = "SELECT value FROM `{$dbprefix}config` WHERE `name` = '" . $name . "'"; $result = $SQL->query($sql); if($SQL->num_rows($result) == 0) { return false; } else { $current_ver = $SQL->fetch_array($result); return $current_ver['value']; } } /** * trying to detect cookies settings */ function get_cookies_settings() { $server_port = !empty($_SERVER['SERVER_PORT']) ? (int) $_SERVER['SERVER_PORT'] : (int) @getenv('SERVER_PORT'); $server_name = $server_name = (!empty($_SERVER['HTTP_HOST'])) ? strtolower($_SERVER['HTTP_HOST']) : ((!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : @getenv('SERVER_NAME')); // HTTP HOST can carry a port number... if (strpos($server_name, ':') !== false) $server_name = substr($server_name, 0, strpos($server_name, ':')); $cookie_secure = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? true : false; $cookie_name = 'klj_' . strtolower(substr(str_replace('0', 'z', base_convert(md5(mt_rand()), 16, 35)), 0, 5)); $name = (!empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : getenv('PHP_SELF'); if (!$name) $name = (!empty($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : @getenv('REQUEST_URI'); $script_path = trim(dirname(str_replace(array('\\', '//'), '/', $name))); if ($script_path !== '/') { if (substr($script_path, -1) == '/') $script_path = substr($script_path, 0, -1); $script_path = str_replace(array('../', './'), '', $script_path); if ($script_path[0] != '/') $script_path = '/' . $script_path; } $cookie_domain = $server_name; if (strpos($cookie_domain, 'www.') === 0) { $cookie_domain = str_replace('www.', '.', $cookie_domain); } return array( 'server_name' => $server_name, 'cookie_secure' => $cookie_secure, 'cookie_name' => $cookie_name, 'cookie_domain' => $cookie_domain, 'cookie_path' => str_replace('/install', '', $script_path), ); }