]> git.mxchange.org Git - ctracker.git/blobdiff - libs/lib_general.php
Added 'safe_mode' (php.ini setting).
[ctracker.git] / libs / lib_general.php
index 5799d08ac4ecde22a736eb36137b03790bd0f9e4..62062d7b2586bf4d094520b762cd11d0ac40ef6a 100644 (file)
@@ -87,20 +87,23 @@ function determineCrackerTrackerRealRemoteAddress () {
        // Is a proxy in use?
        if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
                // Proxy was used
-               $address = $_SERVER['HTTP_X_FORWARDED_FOR'];
+               $address = trim($_SERVER['HTTP_X_FORWARDED_FOR']);
        } elseif (isset($_SERVER['HTTP_CLIENT_IP'])) {
                // Yet, another proxy
-               $address = $_SERVER['HTTP_CLIENT_IP'];
+               $address = trim($_SERVER['HTTP_CLIENT_IP']);
        } elseif (isset($_SERVER['REMOTE_ADDR'])) {
                // The regular address when no proxy was used
-               $address = getenv('REMOTE_ADDR');
+               $address = trim(getenv('REMOTE_ADDR'));
        }
 
-       // This strips out the real address from proxy output
-       if (strstr($address, ',')) {
+       if ($address == 'unknown') {
+               // Invalid IP somehow given
+               $address = '0.0.0.0';
+       elseif (strstr($address, ',')) {
+               // This strips out the real address from proxy output
                $addressArray = explode(',', $address);
                $address = $addressArray[0];
-       } // END - if
+       }
 
        // Return the result
        return $address;
@@ -174,7 +177,7 @@ function crackerTrackerReferer () {
        // Is it there?
        if (isset($_SERVER['HTTP_REFERER'])) {
                // Then use it securely
-               $referer = crackerTrackerSecureString($_SERVER['HTTP_REFERER']);
+               $referer = crackerTrackerSecureString(urldecode($_SERVER['HTTP_REFERER']));
        } // END - if
 
        // Return it
@@ -220,7 +223,7 @@ function isCrackerTrackerFileFound ($FQFN) {
 // Loads a given "template" (this is more an include file)
 function crackerTrackerLoadTemplate ($template) {
        // Create the full-qualified filename (FQFN)
-       $FQFN = sprintf("%s/templates/%s.tpl.php",
+       $FQFN = sprintf('%s/templates/%s.tpl.php',
                dirname(__FILE__),
                $template
        );
@@ -241,7 +244,7 @@ function crackerTrackerLoadTemplate ($template) {
 // Loads a given "template" (this is more an include file)
 function crackerTrackerLoadLocalizedTemplate ($template) {
        // Create the full-qualified filename (FQFN)
-       $FQFN = sprintf("%s/templates/%s/%s.tpl.php",
+       $FQFN = sprintf('%s/templates/%s/%s.tpl.php',
                dirname(__FILE__),
                getCrackerTrackerLanguage(),
                $template