<?php
/**
* Project: RV SiteBuilder Installer: the PHP Installer RV Site Builder.
* File: Controller.php
*
* @author Pairote Manunphol <pairote@rvskin.com>
* @version $Revision$
* @since PHP 4.1
*/
class URL extends Controller
{
function urlConnect ($site = null, $port = 80, $authorization = null, $useSSL = false, $request = null)
{
$site = preg_replace('/https\:\/\//i', '', $site);
$site = preg_replace('/http\:\/\//i', '', $site);
if (function_exists("curl_init")) {
$ch = curl_init();
if ($useSSL) {
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,0);
curl_setopt($ch, CURLOPT_URL, 'https://' . $site . ':' . $port . $request);
} else {
curl_setopt($ch, CURLOPT_URL, $site . ':' . $port . $request);
}
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
if ($authorization) {
$curlheaders[0] = 'Authorization: WHM ' . $authorization;
curl_setopt($ch, CURLOPT_HTTPHEADER, $curlheaders);
}
$pages = curl_exec($ch);
curl_close($ch);
} elseif (function_exists("fsockopen")) {
if ($authorization) {
$ReqHeader = "GET " . $request . " HTTP/1.0\n";
$ReqHeader .= "Connection: close\n";
$ReqHeader .= "Authorization: WHM " . $authorization . "\n\n";
} else {
$ReqHeader = "GET " . $request . " HTTP/1.1\r\n";
$ReqHeader .= "Host: $site\r\n";
$ReqHeader .= "Connection: close\r\n";
$ReqHeader .= "\r\n";
}
$socket = fsockopen($site, 80, $errno, $errstr);
if (!$socket) {
print $errstr;
exit;
}
fputs($socket, $ReqHeader);
$pages = '';
$header = 1;
$skip = 0;
while (false !== ($next = fgetss($socket, 1024))) {
if (!$header) {
if ($skip == 1) {
$skip = 0;
} else {
if (!preg_match("/^0[\n|\r\n]/i", $next, $match)) {
$pages .= $next;
}
}
}
if ($header && preg_match("/^[\n|\r\n]/i", $next, $match)) {
$header = 0;
$skip = 1;
}
}
fclose($socket);
} else {
print 'ERROR : php not compiled with --enable-fsockopen or curl';
exit;
}
return $pages;
}
}
?>
Copyright 2K16 - 2K18 Indonesian Hacker Rulez