manage remote address with socket_getpeername()
authorMatteo Nastasi (mop) <nastasi@alternativeoutput.com>
Wed, 18 Jul 2012 05:24:33 +0000 (07:24 +0200)
committerMatteo Nastasi (mop) <nastasi@alternativeoutput.com>
Wed, 18 Jul 2012 05:24:33 +0000 (07:24 +0200)
web/index.php
web/spush/brisk-spush.php

index 587acd8..c8a1599 100644 (file)
@@ -220,7 +220,7 @@ function carousel_top()
     return (sprintf('<a target="_blank" href="http://shop.alternativeoutput.it"><img class="nobo" style="display: inline; border: 1px solid #808080;" src="img/briskshop%d.gif"></a>', $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;
index 1f3d7e4..40eb54e 100755 (executable)
@@ -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);