}
// Detects the user-agent string
-function crackerTrackerUserAgent () {
+function crackerTrackerUserAgent ($sanitize = FALSE) {
// Default is 'unknown'
$ua = 'unknown';
$ua = crackerTrackerSecureString(urldecode($_SERVER['HTTP_USER_AGENT']));
} // END - if
+ // Sanitize it?
+ if ($sanitize === TRUE) {
+ // Sanitize ...
+ $ua = crackerTrackerSanitize($ua);
+ } // END - if
+
// Return it
return $ua;
}
// Detects the script name
-function crackerTrackerScriptName () {
+function crackerTrackerScriptName ($sanitize = FALSE) {
+ // Default is NULL
+ $scriptName = NULL;
+
// Is it there?
- if (!isset($_SERVER['SCRIPT_NAME'])) {
+ if (!empty($_SERVER['SCRIPT_NAME'])) {
// Return NULL
- return NULL;
+ $scriptName = crackerTrackerSecureString($_SERVER['SCRIPT_NAME']);
} // END - if
- // Should always be there!
- return crackerTrackerSecureString($_SERVER['SCRIPT_NAME']);
+ // Sanitize it?
+ if ($sanitize === TRUE) {
+ // Sanitize ...
+ $scriptName = crackerTrackerSanitize($scriptName);
+ } // END - if
+
+ // Return
+ return $scriptName;
}
// Detects the query string
-function crackerTrackerQueryString () {
+function crackerTrackerQueryString ($sanitize = FALSE) {
+ // Default is NULL
+ $query = NULL;
+
// Is it there?
- if (!isset($_SERVER['QUERY_STRING'])) {
+ if (!empty($_SERVER['QUERY_STRING'])) {
// Return NULL
- return NULL;
+ $query = crackerTrackerEscapeString(urldecode($_SERVER['QUERY_STRING']));
} // END - if
- // Should always be there!
- return crackerTrackerEscapeString(urldecode($_SERVER['QUERY_STRING']));
+ // Sanitize it?
+ if ($sanitize === TRUE) {
+ // Sanitize ...
+ $query = crackerTrackerSanitize($query);
+ } // END - if
+
+ // Return it
+ return $query;
}
// Detects the server's name
-function crackerTrackerServerName () {
+function crackerTrackerServerName ($sanitize = FALSE) {
+ // Default is NULL
+ $serverName = NULL;
+
// Is it there?
- if (!isset($_SERVER['SERVER_NAME'])) {
+ if (!empty($_SERVER['SERVER_NAME'])) {
// Return NULL
- return NULL;
+ $serverName = crackerTrackerSecureString($_SERVER['SERVER_NAME']);
} // END - if
- // Should always be there!
- return crackerTrackerSecureString($_SERVER['SERVER_NAME']);
+ // Sanitize it?
+ if ($sanitize === TRUE) {
+ // Sanitize ...
+ $serverName = crackerTrackerSanitize($serverName);
+ } // END - if
+
+ // Return it
+ return $serverName;
}
// Detects the referer
-function crackerTrackerReferer () {
+function crackerTrackerReferer ($sanitize = FALSE) {
// Default is a dash
$referer = '-';
$referer = crackerTrackerSecureString(urldecode($_SERVER['HTTP_REFERER']));
} // END - if
+ // Sanitize it?
+ if ($sanitize === TRUE) {
+ // Sanitize ...
+ $referer = crackerTrackerSanitize($referer);
+ } // END - if
+
// Return it
return $referer;
}
} // END - foreach
}
-// [EOF]
-?>
+// Sanitizes string
+function crackerTrackerSanitize ($str) {
+ return str_replace(array('//', '/./'), array('/', '/'), $str);
+}