X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=libs%2Flib_general.php;h=fe382dc249938179c20c9db3921ea562de560dc5;hb=405e14dad137dced353b1ac5b0389291e3f1a984;hp=f67d41cf6d99877df6899d15b7622eaa57d17da8;hpb=4922a297cb2fe1801306722f1b1a72553706f135;p=ctracker.git diff --git a/libs/lib_general.php b/libs/lib_general.php index f67d41c..fe382dc 100644 --- a/libs/lib_general.php +++ b/libs/lib_general.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 3.0.0 - * @copyright Copyright (c) 2009, 2010 Cracker Tracker Team + * @copyright Copyright (c) 2009 - 2011 Cracker Tracker Team * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -73,14 +73,17 @@ if (!function_exists('implode_secure')) { } // END - function } // END - if -// Getter for ctracker_debug +// Getter for ctracker_debug_enabled function isCrackerTrackerDebug () { // Is it set? - return ((isset($GLOBALS['ctracker_debug'])) && ($GLOBALS['ctracker_debug'] === true)); + return ((isset($GLOBALS['ctracker_debug_enabled'])) && ($GLOBALS['ctracker_debug_enabled'] === true)); } // Determines the real remote address function determineCrackerTrackerRealRemoteAddress () { + // Initial value + $address = '0.0.0.0'; + // Is a proxy in use? if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { // Proxy was used @@ -88,9 +91,9 @@ function determineCrackerTrackerRealRemoteAddress () { } elseif (isset($_SERVER['HTTP_CLIENT_IP'])) { // Yet, another proxy $address = $_SERVER['HTTP_CLIENT_IP']; - } else { + } elseif (isset($_SERVER['REMOTE_ADDR'])) { // The regular address when no proxy was used - $address = $_SERVER['REMOTE_ADDR']; + $address = getenv('REMOTE_ADDR'); } // This strips out the real address from proxy output @@ -119,8 +122,8 @@ function crackerTrackerUserAgent () { // Is the entry there? if (isset($_SERVER['HTTP_USER_AGENT'])) { - // Then use it - $ua = $_SERVER['HTTP_USER_AGENT']; + // Then use it securely + $ua = crackerTrackerSecureString($_SERVER['HTTP_USER_AGENT']); } // END - if // Return it @@ -129,18 +132,36 @@ function crackerTrackerUserAgent () { // Detects the script name function crackerTrackerScriptName () { + // Is it there? + if (!isset($_SERVER['SCRIPT_NAME'])) { + // Return NULL + return NULL; + } // END - if + // Should always be there! return crackerTrackerSecureString($_SERVER['SCRIPT_NAME']); } // Detects the query string function crackerTrackerQueryString () { + // Is it there? + if (!isset($_SERVER['QUERY_STRING'])) { + // Return NULL + return NULL; + } // END - if + // Should always be there! return crackerTrackerEscapeString($_SERVER['QUERY_STRING']); } // Detects the server's name function crackerTrackerServerName () { + // Is it there? + if (!isset($_SERVER['SERVER_NAME'])) { + // Return NULL + return NULL; + } // END - if + // Should always be there! return crackerTrackerSecureString($_SERVER['SERVER_NAME']); } @@ -411,24 +432,23 @@ function crackerTrackerRedirectSameUrl () { } // And redirect - sendRawRedirect($url); + crackerTrackerSendRawRedirect($url); } /** - * Send a HTTP redirect to the browser. This function wass taken from DokuWiki + * Send a HTTP redirect to the browser. This function was taken from DokuWiki * (GNU GPL 2; http://www.dokuwiki.org) and modified to fit into this script. * - * ---------------------------------------------------------------------------- - * If you want to redirect, please use redirectToUrl(); instead - * ---------------------------------------------------------------------------- - * * Works arround Microsoft IIS cookie sending bug. Does exit the script. * * @link http://support.microsoft.com/kb/q176113/ * @author Andreas Gohr * @access private */ -function sendRawRedirect ($url) { +function crackerTrackerSendRawRedirect ($url) { + // Better remove any data by ctracker + unsetCtrackerData(); + // always close the session session_write_close(); @@ -449,5 +469,35 @@ function sendRawRedirect ($url) { exit(); } +// Removes all ctracker-related data from global space +function unsetCtrackerData () { + // Unset all ctracker data + foreach (array( + 'ctracker_host', + 'ctracker_dbname', + 'ctracker_user', + 'ctracker_password', + 'ctracker_debug_enabled', + 'ctracker_email', + 'ctracker_whitelist', + 'ctracker_get_blacklist', + 'ctracker_post_blacklist', + 'ctracker_header', + 'ctracker_post_track', + 'ctracker_checkworm', + 'ctracker_check_post', + 'ctracker_last_sql', + 'ctracker_last_result', + 'ctracker_config', + 'ctracker_updates', + 'ctracker_language', + 'ctracker_localized', + 'ctracker_link', + ) as $key) { + // Unset it + unset($GLOBALS[$key]); + } // END - foreach +} + // [EOF] ?>