All pastes #586137 Raw Edit

Mediator

public php v1 · immutable
#586137 ·published 2007-06-23 17:45 UTC
rendered paste body
<?php/***********************************************************************  Copyright (C) 2007  Caleb Champlin [ Mediator ] (cmediator@gmail.com    This is free software; you can redistribute it and/or modify it  under the terms of the GNU General Public License as published  by the Free Software Foundation; either version 2 of the License,  or (at your option) any later version.  This is distributed in the hope that it will be useful, but  WITHOUT ANY WARRANTY; without even the implied warranty of  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License for more details.  You should have received a copy of the GNU General Public License  along with this program; if not, write to the Free Software  Foundation, Inc., 59 Temple Place, Suite 330, Boston,  MA  02111-1307  USA************************************************************************/function obtainContentRaw($url){	if (strpos(str_replace("://","",$url),"/") === false)		$url .= "/";	$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);	if ($socket === false) {		echo socket_strerror(socket_last_error()) . "\n";	}	preg_match('@^(?:http://)?([^/]+)([^\s]+)@i',$url, $matches);	$host = $matches[1];	$request = $matches[2];	$ip = gethostbyname($host);	$result = socket_connect($socket, $ip, 80);	if ($result === false) {		echo socket_strerror(socket_last_error($socket)) . "\n";	}	$req = "GET " . $request . " HTTP/1.1\r\n";	$req .= "Host: " . $host . "\r\n";	$req .= "Connection: Close\r\n\r\n";	socket_write($socket, $req, strlen($req));	while ($response = socket_read($socket, 4096)) {		$content .= $response;	}	socket_close($socket);	$matches = preg_split('/\r\n\r\n/', $content, 2);	$content = $matches[1];	return $content;}?>