+/**
+ * Returns the browser/OS data from the request header
+ * Note: headers are spoofable
+ * @return string
+ */
+function wfGetAgent() {
+ if( function_exists( 'apache_request_headers' ) ) {
+ // More reliable than $_SERVER due to case and -/_ folding
+ $set = array ();
+ foreach ( apache_request_headers() as $tempName => $tempValue ) {
+ $set[ strtoupper( $tempName ) ] = $tempValue;
+ }
+ $index = strtoupper ( 'User-Agent' );
+ } else {
+ // Subject to spoofing with headers like X_Forwarded_For
+ $set = $_SERVER;
+ $index = 'HTTP_USER_AGENT';
+ }
+ if( isset( $set[$index] ) ) {
+ return $set[$index];
+ } else {
+ return '';
+ }
+}
+
+/**
+ * Work out the IP address based on various globals
+ * For trusted proxies, use the XFF client IP (first of the chain)
+ * @return string
+ */