簡體   English   中英

PHP代理服務器

[英]PHP Proxy Servers


我想知道是否有任何方法可以將我的網站變成代理服務器..我發現大量的腳本使用PHP但他們都需要導航到網站才能使用
代理,但我真正想要的是一個腳本,當我在選項對話框中輸入IP和端口號時,我可以通過瀏覽器配置訪問網站,就像在Firefox中一樣,是否有任何類型的腳本可以做到這一點?
任何鏈接可以幫助我快速了解這個主題,歡迎..
謝謝,
AB

將您的適配器重定向到此計算機的IP和端口,它是同步的,但它會很慢。

    $addr   = gethostbyname('0.0.0.0'); //ip sensitive :((
    $server = stream_socket_server("tcp://" . $addr . ":8000", $errno, $errorMessage);

    echo "connected to: $addr:8000";

    if ($server === false) {
            throw new UnexpectedValueException("Could not bind to socket: $errorMessage");
    }

    $conns      = array( $server ); // connections
    $connection = 0;

    // loop forever
    for (;;) {
            $reads = $conns;

            // get number of connections with new data
            $mod = stream_select($reads, $write, $except, 5);
            if ($mod===false) break;

            // I have no idea what this does but what im doing here is separating the client ip and port from server 1:1 only!
            foreach ($reads as $read) {
                    if ($read===$server) {

                            // if a client is connected
                            if ($client = @stream_socket_accept( $server )) {

                                    echo "\nconnection from " . stream_socket_get_name( $client, true ) . "\n";

                                    $recv = fread($client, 1024);
                                    $rec_arr = explode( ' ', $recv );

                                    echo hex_dump($recv);

                                    if(strpos($recv, "CONNECT ")!==0) {

                                            if( $src = @fopen( $rec_arr[ 1 ], 'rb') ) {
                                                    while ($chunk = fread($src, 1024000)) {
                                                            @fwrite( $client, $chunk );
                                                    }

                                                    $chunk = "";

                                                    fclose( $src );
                                            }
                                    }

                                    stream_socket_shutdown($client, STREAM_SHUT_RDWR);
                            }
                    }
            }
    }

    function hex_dump($data, $newline="\n")
    {
            $from = '';
            $to = '';

            $width = 16; # number of bytes per line

            $pad = '.'; # padding for non-visible characters

            if ($from==='')
            {
                            for ($i=0; $i<=0xFF; $i++)
                            {
                                            $from .= chr($i);
                                            $to .= ($i >= 0x20 && $i <= 0x7E) ? chr($i) : $pad;
                            }
            }

            $hex = str_split(bin2hex($data), $width*2);
            $chars = str_split(strtr($data, $from, $to), $width);

            $offset = 0;
            foreach ($hex as $i => $line)
            {
                            $line = strtoupper( $line );

                            echo sprintf('%6X',$offset).' : '.implode(' ', str_split($line,2)) . ' [' . $chars[$i] . ']' . $newline;

                            $offset += $width;
            }
    }

(以及更多,請谷歌)

這是您正在尋找的代理軟件嗎? 在PHP中只是簡單的HTTP代理。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM