Viewing file: sockets.inc.php (2.37 KB) -rwxr-xr-x Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
/*
############################################################################
# DWmail
# - version 4.0
# - Copyright (c) 2003-2006 Dominion Web Design
# - http://www.dominion-web.com/products/dwmail/
############################################################################
#
# The contents of this file are subject to the DWmail License version
# 2.2 ('License'). You may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.dominion-web.com/products/dwmail/license.php
# Software distributed under the License is distributed on an "AS IS" basis,
# without warranty of any kind, either express or implied.
#
# This code is Copyright (c) 2003-2006 Dominion Web Design.
# All rights reserved.
#
# This software may not be redistributed outside the terms of the
# license agreement.
#
############################################################################
*/
class remoteFile {
var $_file;
var $_headers;
function remoteFile() {
}
function fileRead($whichfile) {
$this->_file = $whichfile;
if (strstr($this->_file, "http://") == TRUE || strstr($this->_file, "https://") == TRUE) {
$timeout = 20;
$domain_url = str_replace("http://", "", $this->_file);
$domainarry = explode("/", $domain_url);
$domain = $domainarry[0];
// Bug fix here to make sure that _ / , : are converted back to their proper terms.
$encodedurl = $this->_file;
$finalfile = str_replace("http://" . $domain, "", $encodedurl);
if (strstr($this->_file, "http://") == TRUE) {
$fp = @fsockopen($domain, 80, $errno, $errstr, $timeout);
}
else {
$fp = @fsockopen('ssl://' . $domain, 443, $errno, $errstr, $timeout);
}
if(!$fp) {
$errorreturn = "Unable to connect: Timeout of $timeout reached on port 80 to domain $domain";
}
else {
fwrite($fp, "GET $finalfile HTTP/1.0\r\n");
fwrite($fp, "Host: $domain\r\n");
fwrite($fp, "Content-Type: application/x-www-form-urlencoded\r\n");
fwrite($fp, "User-Agent: Mozilla/2.0 (compatible; DWmail webmail)\r\n\r\n");
while(!feof($fp)) {
$result .= fread($fp, 512);
}
fclose($fp);
$pieces = explode("\r\n\r\n", $result);
$this->_headers = $pieces[0];
$response = $pieces[1];
$filecontents = $response;
}
}
return $filecontents;
}
}
?>
|