aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/path_helper.php
diff options
context:
space:
mode:
authorlucifer4o <lucifer@anavaro.com>2014-02-13 16:23:42 +0200
committerlucifer4o <lucifer@anavaro.com>2014-02-13 16:23:42 +0200
commitc20a313ab09dffc1b169188280e23e56cedc3370 (patch)
treea1456874647ef5f8cacbc600a6da55a389c3c47b /phpBB/phpbb/path_helper.php
parent89007db5050799927c54ab7bd5407c4e172d2760 (diff)
downloadforums-c20a313ab09dffc1b169188280e23e56cedc3370.tar
forums-c20a313ab09dffc1b169188280e23e56cedc3370.tar.gz
forums-c20a313ab09dffc1b169188280e23e56cedc3370.tar.bz2
forums-c20a313ab09dffc1b169188280e23e56cedc3370.tar.xz
forums-c20a313ab09dffc1b169188280e23e56cedc3370.zip
[ticket/12177] Add ucp_friend_list_before/after
Add events before and after list of friends in UCP template Change Since part from a3 to a4 PHPBB3-12177
Diffstat (limited to 'phpBB/phpbb/path_helper.php')
0 files changed, 0 insertions, 0 deletions
21' href='#n21'>21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
package http; # $Id$

use IO::Socket;
use network;


my $sock;

sub getFile {
    local ($^W) = 0;

    my ($url) = @_;
    $sock->close if $sock;
    $url =~ m|/XXX$| and return; #- force closing connection.

    my ($host, $port, $path) = $url =~ m,^http://([^/:]+)(?::(\d+))?(/\S*)?$,;
    $host = network::resolv($host);

    $sock = IO::Socket::INET->new(PeerAddr => $host,
				  PeerPort => $port || 80,
				  Proto    => 'tcp',
				  Timeout  => 60) or die "can't connect $@";
    $sock->autoflush;
    print $sock join("\015\012" =>
		     "GET $path HTTP/1.0",
		     "Host: $host" . ($port && ":$port"),
		     "User-Agent: DrakX/vivelinuxabaszindozs",
		     "", "");

    #- skip until empty line
    my ($now, $last, $buf, $tmp) = 0;
    my $read = sub { sysread($sock, $buf, 1) || die; $tmp .= $buf };
    do {
	$last = $now;
	&$read; &$read if $buf =~ /\015/;
	$now = $buf =~ /\012/;
    } until $now && $last;

    $tmp =~ /^.*\b200\b/ ? $sock : undef;
}

1;