php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #55463
Patch bug55463.diff revision 2011-08-22 11:28 UTC by laruence@php.net

Patch bug55463.diff for Built-in web server Bug #55463

Patch version 2011-08-22 11:28 UTC

Return to Bug #55463 | Download this patch
Patch Revisions:

Developer: laruence@php.net

Index: trunk/sapi/cli/php_cli_server.c
===================================================================
--- trunk/sapi/cli/php_cli_server.c	(revision 315272)
+++ trunk/sapi/cli/php_cli_server.c	(working copy)
@@ -496,6 +496,21 @@
 			sapi_cli_server_register_variable(track_vars_array, "HTTP_REFERER", *val TSRMLS_CC);
 		}
 	}
+	{
+		char *tmp;
+		if ((tmp = strrchr(client->addr_str, ':'))) {
+			char addr[64], port[8];
+			strncpy(port, tmp + 1, 8);
+			port[7] = '\0';
+			strncpy(addr, client->addr_str, tmp - client->addr_str);
+			addr[tmp - client->addr_str] = '\0';
+			sapi_cli_server_register_variable(track_vars_array, "REMOTE_ADDR", addr TSRMLS_CC);
+			sapi_cli_server_register_variable(track_vars_array, "REMOTE_PORT", port TSRMLS_CC);
+		} else {
+			sapi_cli_server_register_variable(track_vars_array, "REMOTE_ADDR", client->addr_str TSRMLS_CC);
+		}
+	}
+
 	sapi_cli_server_register_variable(track_vars_array, "REQUEST_URI", client->request.request_uri TSRMLS_CC);
 	sapi_cli_server_register_variable(track_vars_array, "REQUEST_METHOD", SG(request_info).request_method TSRMLS_CC);
 	sapi_cli_server_register_variable(track_vars_array, "PHP_SELF", client->request.vpath TSRMLS_CC);
Index: branches/PHP_5_4/sapi/cli/php_cli_server.c
===================================================================
--- branches/PHP_5_4/sapi/cli/php_cli_server.c	(revision 315272)
+++ branches/PHP_5_4/sapi/cli/php_cli_server.c	(working copy)
@@ -496,6 +496,21 @@
 			sapi_cli_server_register_variable(track_vars_array, "HTTP_REFERER", *val TSRMLS_CC);
 		}
 	}
+	{
+		char *tmp;
+		if ((tmp = strrchr(client->addr_str, ':'))) {
+			char addr[64], port[8];
+			strncpy(port, tmp + 1, 8);
+			port[7] = '\0';
+			strncpy(addr, client->addr_str, tmp - client->addr_str);
+			addr[tmp - client->addr_str] = '\0';
+			sapi_cli_server_register_variable(track_vars_array, "REMOTE_ADDR", addr TSRMLS_CC);
+			sapi_cli_server_register_variable(track_vars_array, "REMOTE_PORT", port TSRMLS_CC);
+		} else {
+			sapi_cli_server_register_variable(track_vars_array, "REMOTE_ADDR", client->addr_str TSRMLS_CC);
+		}
+	}
+
 	sapi_cli_server_register_variable(track_vars_array, "REQUEST_URI", client->request.request_uri TSRMLS_CC);
 	sapi_cli_server_register_variable(track_vars_array, "REQUEST_METHOD", SG(request_info).request_method TSRMLS_CC);
 	sapi_cli_server_register_variable(track_vars_array, "PHP_SELF", client->request.vpath TSRMLS_CC);
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Wed Apr 23 09:02:23 2014 UTC