rs4.php only works localhost!

Results 1 to 2 of 2
  1. #1
    Apprentice sahdsak is offline
    MemberRank
    Jun 2014 Join Date
    9Posts

    rs4.php only works localhost!

    Hi I'm having issues getting rs4.php to work outside of localhost. I'm able to load up the hotel on my vps but when doing it on my personal computer I keep getting redirected to /game folder which I assume is cause of rs4.php

    I've tried adding my ip in rs4.php as follows:
    Code:
    <?php
    
    /*
     *****************
     * @author capos *
     *****************
    */
    
    
    $width = 100;
    $height = 114;
    
    
    function buildimg($bytes, $width, $height)
    {
        $img=imagecreatetruecolor($width, $height);imagealphablending($img, false);imagesavealpha($img, true);$x=0;$y=0;
        $colors=unpack("N*", $bytes);
        foreach($colors as $color)
        {
            imagesetpixel($img, $x, $y, (0x7f-($color>>25)<<24)|($color&0xffffff));
            if(++$x==$width)
            {$x=0;$y++;}
        }
        header('Content-Type: image/png');
        imagepng($img);
    }
    
    
    $pixels = file_get_contents('./banner.txt'); // the banner pixels
    
    
    if($_GET)
    {
        $token = trim($_GET["token"]);
        if(strlen($token) >= 10)
        {    
            // Stuff to connect to mus and get banner data.. (prime and generator)
            $fp = fsockopen("my ip", 30000, $errno, $errstr, 1);
            if (!is_resource($fp))
            {
                exit("LE FAIL...");
            }
            
            $packet = '0'.chr(1).$token;
    
    
            fwrite($fp, $packet); 
            fflush($fp);
            
            stream_set_timeout($fp, 1);
            $data = fgets($fp, 512);
            list($prime, $generator) = explode(':', $data);
            fclose($fp);
            
            $prime = '114670925920269957593299136150366957983142588366300079186349531';
            $generator = '1589935137502239924254699078669119674538324391752663931735947';
    
    
            $insert = chr(strlen($prime)).$prime.chr(strlen($generator)).$generator;
            $Length = strlen($token);$Length2 = strlen($insert);
            $p = 0;$bitsnum = "";
            for($i=0;$i<$Length2;$i++)
            {
                $bits = base_convert(ord($insert[$i]) ^ ord($token[$p]),10,2);
                $need = 8 - strlen($bits);
                for($o=0;$o<$need;$o++)$bits = "0".$bits;
                $bitsnum .= $bits;
                if (++$p == $Length) $p = 0;
            }
            $insertpos = 0;$Length = strlen($bitsnum);
            for ($y = 39; $y < 69; $y++)
            {
                $a = 0;
                for ($r = 4; $r < 84; $r++)
                {
                    $pos = (($y + $a) * $width + $r) * 4;
                    $b = 1;
                    while ($b < 4)
                    {
                        if($insertpos < $Length)
                        {
                            $binaryData = base_convert(ord($pixels[$pos + $b]),10,2);
                            $need = 8 - strlen($binaryData);
                            for($o=0;$o<$need;$o++) $binaryData = "0".$binaryData;
                            $binaryData[7] = $bitsnum[$insertpos];
                            $pixels[$pos + $b] = chr(base_convert($binaryData,2,10));
                            $insertpos++;$b++;
                            continue;
                        }
                        break 3;
                    }
                    if ($r % 2 == 0) $a++;
                }
            }
            
        }
    }
    buildimg($pixels, $width, $height);
    ?>
    If you didn't notice where I edited:
    Code:
    // Stuff to connect to mus and get banner data.. (prime and generator)        $fp = fsockopen("my ip", 30000, $errno, $errstr, 1);
            if (!is_resource($fp))
            {
                exit("LE FAIL...");
            }
            
            $packet = '0'.chr(1).$token;
    
    
            fwrite($fp, $packet); 
            fflush($fp);
            
            stream_set_timeout($fp, 1);
            $data = fgets($fp, 512);
            list($prime, $generator) = explode(':', $data);
            fclose($fp);
    I've tried both my emu port and mus port (30000 and 30001) but none worked. Any help? Thanks.


  2. #2
    Member Dj-DevilBlack is offline
    MemberRank
    Oct 2009 Join Date
    GermanyLocation
    72Posts

    Re: rs4.php only works localhost!

    Edit your rs4.php:
    Find and Replace:
    Code:
    $fp = fsockopen("my ip", 30000, $errno, $errstr, 1);
    to:
    Code:
    $fp = fsockopen("127.0.0.1", 30001, $errno, $errstr, 1);
    Change your Emulator Configuration and Set musport to 30001.

    This code is only if Emulator and Webserver running on Same PC/Server.
    If not you need to edit 127.0.0.1 to emulator ip and Open the mus port.



Advertisement