miless Posted July 28, 2008 Share Posted July 28, 2008 Is there a way to search inside the header name, rather than the header output ? For example: I want to know if the client has sent any headers with the word "forwarded" in them. Link to comment https://forums.phpfreaks.com/topic/116975-solved-search-in-header-name/ Share on other sites More sharing options...
trq Posted July 28, 2008 Share Posted July 28, 2008 Providing your using apache apache_request_headers() will return an array of all request headers sent by the client. Link to comment https://forums.phpfreaks.com/topic/116975-solved-search-in-header-name/#findComment-601618 Share on other sites More sharing options...
miless Posted July 28, 2008 Author Share Posted July 28, 2008 Unfortunately, my host has it installed as CGI. I am most concerned by HTTP call response times. I do not know how headers work exactly but does this script call the browser (or user-agent) every time it checks for each header ? If so that is quite slow, can it be done quicker ? if ( !empty($_SERVER["HTTP_CLIENT_IP"]) ){ $ip = $_SERVER["HTTP_CLIENT_IP"]; }elseif ( !empty($_SERVER["HTTP_X_FORWARDED_FOR"]) ){ $ip = $_SERVER["HTTP_X_FORWARDED_FOR"]; }elseif ( !empty($_SERVER["HTTP_FORWARDED"]) ){ $ip = $_SERVER["HTTP_FORWARDED"]; }elseif ( !empty($_SERVER["HTTP_FORWARDED_FOR"]) ){ $ip = $_SERVER["HTTP_FORWARDED_FOR"]; }elseif ( !empty($_SERVER["HTTP_X_FORWARDED"]) ){ $ip = $_SERVER["HTTP_X_FORWARDED"]; }elseif ( !empty($_SERVER["X_FORWARDED_FOR"]) ){ $ip = $_SERVER["X_FORWARDED_FOR"]; }elseif ( !empty($_SERVER["X_FORWARDED_FOR"]) ){ $ip = $_SERVER["X_Forwarded_For"]; }elseif ( !empty($_SERVER["HTTP_VIA"]) ){ $ip = $_SERVER["HTTP_VIA"]; }elseif ( !empty($_SERVER["HTTP_X_COMING_FROM"]) ){ $ip = $_SERVER["HTTP_X_COMING_FROM"]; }elseif ( !empty($_SERVER["HTTP_COMING_FROM"]) ){ $ip = $_SERVER["HTTP_COMING_FROM"]; }else{ $ip = $_SERVER["REMOTE_ADDR"]; } Link to comment https://forums.phpfreaks.com/topic/116975-solved-search-in-header-name/#findComment-601727 Share on other sites More sharing options...
trq Posted July 28, 2008 Share Posted July 28, 2008 but does this script call the browser (or user-agent) every time it checks for each header ? No, headers are sent from the client to the server once upon each request. Link to comment https://forums.phpfreaks.com/topic/116975-solved-search-in-header-name/#findComment-601789 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.