@@ -519,9 +519,9 @@ public function ip_address()
519519 if ($ separator === ': ' )
520520 {
521521 $ netaddr = explode (': ' , str_replace (':: ' , str_repeat (': ' , 9 - substr_count ($ netaddr , ': ' )), $ netaddr ));
522- for ($ i = 0 ; $ i < 8 ; $ i ++)
522+ for ($ j = 0 ; $ j < 8 ; $ j ++)
523523 {
524- $ netaddr [$ i ] = intval ($ netaddr [$ i ], 16 );
524+ $ netaddr [$ i ] = intval ($ netaddr [$ j ], 16 );
525525 }
526526 }
527527 else
@@ -760,30 +760,32 @@ public function request_headers($xss_clean = FALSE)
760760 // If header is already defined, return it immediately
761761 if ( ! empty ($ this ->headers ))
762762 {
763- return $ this ->headers ;
763+ return $ this ->_fetch_from_array ( $ this -> headers , NULL , $ xss_clean ) ;
764764 }
765765
766766 // In Apache, you can simply call apache_request_headers()
767767 if (function_exists ('apache_request_headers ' ))
768768 {
769- return $ this ->headers = apache_request_headers ();
769+ $ this ->headers = apache_request_headers ();
770770 }
771-
772- $ this ->headers ['Content-Type ' ] = isset ($ _SERVER ['CONTENT_TYPE ' ]) ? $ _SERVER ['CONTENT_TYPE ' ] : @getenv ('CONTENT_TYPE ' );
773-
774- foreach ($ _SERVER as $ key => $ val )
771+ else
775772 {
776- if (sscanf ($ key , 'HTTP_%s ' , $ header ) === 1 )
773+ isset ($ _SERVER ['CONTENT_TYPE ' ]) && $ this ->headers ['Content-Type ' ] = $ _SERVER ['CONTENT_TYPE ' ];
774+
775+ foreach ($ _SERVER as $ key => $ val )
777776 {
778- // take SOME_HEADER and turn it into Some-Header
779- $ header = str_replace ('_ ' , ' ' , strtolower ($ header ));
780- $ header = str_replace (' ' , '- ' , ucwords ($ header ));
777+ if (sscanf ($ key , 'HTTP_%s ' , $ header ) === 1 )
778+ {
779+ // take SOME_HEADER and turn it into Some-Header
780+ $ header = str_replace ('_ ' , ' ' , strtolower ($ header ));
781+ $ header = str_replace (' ' , '- ' , ucwords ($ header ));
781782
782- $ this ->headers [$ header ] = $ this ->_fetch_from_array ($ _SERVER , $ key , $ xss_clean );
783+ $ this ->headers [$ header ] = $ _SERVER [$ key ];
784+ }
783785 }
784786 }
785787
786- return $ this ->headers ;
788+ return $ this ->_fetch_from_array ( $ this -> headers , NULL , $ xss_clean ) ;
787789 }
788790
789791 // --------------------------------------------------------------------
0 commit comments