From: Matteo Nastasi (mop) Date: Wed, 18 Jul 2012 05:24:33 +0000 (+0200) Subject: manage remote address with socket_getpeername() X-Git-Tag: v4.0.0~96 X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=commitdiff_plain;h=90c7420f07b9198d094ae0d297c391ede9adc1d9;p=brisk.git manage remote address with socket_getpeername() --- diff --git a/web/index.php b/web/index.php index 587acd8..c8a1599 100644 --- a/web/index.php +++ b/web/index.php @@ -220,7 +220,7 @@ function carousel_top() return (sprintf('', $rn)); } -function index_main(&$room, &$header_out, $get, $post, $cookie) +function index_main(&$room, &$header_out, $addr, $get, $post, $cookie) { GLOBAL $G_with_donors, $G_donors_cur, $G_donors_all; GLOBAL $G_with_topbanner, $G_topbanner, $G_is_local; @@ -287,7 +287,7 @@ function index_main(&$room, &$header_out, $get, $post, $cookie) $room->garbage_manager(TRUE); /* try login */ - if (($user = $room->add_user(&$sess, &$idx, $name, $pass_private, $_SERVER['REMOTE_ADDR'])) != FALSE) { + if (($user = $room->add_user(&$sess, &$idx, $name, $pass_private, $addr)) != FALSE) { $ACTION = "room"; if ($idx < 0) { $idx = -$idx - 1; diff --git a/web/spush/brisk-spush.php b/web/spush/brisk-spush.php index 1f3d7e4..40eb54e 100755 --- a/web/spush/brisk-spush.php +++ b/web/spush/brisk-spush.php @@ -262,12 +262,14 @@ function main() printf("COOKIE:\n"); print_r($cookie); + $addr = stream_socket_get_name($new_socket, TRUE); + switch ($path) { case SITE_PREFIX: case SITE_PREFIX."index.php": $header_out = array(); ob_start(); - index_main($room, $header_out, $get, $post, $cookie); + index_main($room, $header_out, $addr, $get, $post, $cookie); $content = ob_get_contents(); ob_end_clean(); // printf("OUT: [%s]\n", $G_content); @@ -275,10 +277,10 @@ function main() fclose($new_socket); break; case SITE_PREFIX."index_wr.php": - $G_headers = ""; + $header_out = array(); $addr = ""; - $ret = socket_getpeername($new_socket, $addr); - // printf("RET: %d\n", $ret); + // $ret = socket_getpeername($new_socket, $addr); + printf("RET: %s\n", $addr); // exit(123); ob_start(); index_wr_main($room, $addr, $get, $post, $cookie);