Warning: chmod(): Operation not permitted in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8 [0] in function chmod in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8 [1] in function include_once in /var/www/hopeinstoughton_www/wp-settings.php on line 560 [2] in function require_once in /var/www/hopeinstoughton_www/wp-config.php on line 85 [3] in function require_once in /var/www/hopeinstoughton_www/wp-load.php on line 50 [4] in function require_once in /var/www/hopeinstoughton_www/wp-blog-header.php on line 13 [5] in function require in /var/www/hopeinstoughton_www/index.php on line 17
| Server IP : 94.177.8.99 / Your IP : 216.73.217.165 Web Server : Apache/2.4.58 (Ubuntu) System : Linux aries 6.8.0-134-generic #134-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 26 18:43:11 UTC 2026 x86_64 User : www-data ( 33) PHP Version : 8.1.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/hopeinstoughton_books/core/plugins/ |
Upload File : |
<?php
// Written by hostz.org. Used with permission,
global $HTTP_COOKIES;
$HTTP_COOKIES = array();
class wget {
var $url;
var $request;
var $headers;
var $body;
var $rawheaders;
var $postdata;
var $TIMEOUT;
var $redirect_limit;
var $error;
var $receive_limit;
var $out;
var $ipaddress;
function wget($timeout = 15) {
$this->url = '';
$this->ipaddress = '';
$this->request = array(
'User-Agent' => 'Mozilla/5.0 (Windows NT 6.1; rv:14.0) Gecko/20120405 Firefox/14.0a1',
'Accept' => 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5',
'Accept-Language' => 'en-us,en;q=0.5',
'Accept-Encoding' => 'gzip,deflate',
'Accept-Charset' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
);
// if ($lastmod != '') $out .= "If-Modified-Since: $lastmod\r\n";
$this->postdata = '';
$this->rawheaders = array();
$this->body = '';
$this->headers = array();
$this->TIMEOUT = $timeout;
$this->redirect_limit = 5;
$this->error = '';
$this->receive_limit = 0;
}
public function SetURL($url, $query_array = NULL) {
if ($query_array !== NULL) {
$query = $this->_serialize_data($query_array);
if ($query != '') {
$url .= (strpos($url, '?') === FALSE) ? '?' : '&';
$url .= $query;
}
}
$this->url = $url;
}
public function GET($method = 'GET') {
$this->postdata = '';
$redirect_count = $this->redirect_limit;
$location = '';
do {
if ($location != '') $this->url = $location;
$this->_http_request($method);
$location = isset($this->headers['location']) ? $this->headers['location'] : '';
if ($location != '') {
$location = chp_RelativeToAbsoluteURL($this->headers['URI'], $location);
$redirect_count--;
}
} while ($location != '' && $redirect_count > 0);
if ($location != '') $this->error = 'redirection limit exceeded';
}
public function HEAD() {
$this->GET('HEAD');
}
public function POST($postdata = NULL) {
if ($postdata == NULL) {
$this->postdata = '';
} else {
$this->postdata = $this->_serialize_data($postdata);
}
$this->_http_request('POST');
}
private function _http_request($method = 'GET') {
$this->error = '';
$url = $this->url;
if (($p = strpos($url, '://')) === FALSE) $url = 'http://' . $url;
$defaultport = 80;
$components = parse_url($url);
$protocol = isset($components['scheme']) ? $components['scheme'] : 'http';
if ($protocol == 'https') {
$protocol = 'ssl';
$defaultport = 443;
} elseif ($protocol == 'ftp') {
return;
}
$host = isset($components['host']) ? $components['host'] : '';
if (($p = strpos($host, ':')) !== FALSE) list($host, $defaultport) = explode(':', $host);
$this->original_host = strtolower($host);
if (isset($components['port'])) $defaultport = intval($components['port']);
$protocol = ($protocol == 'http') ? '' : "$protocol://";
$uri = isset($components['path']) ? $components['path'] : '/';
if (isset($components['query'])) $uri .= '?' . $components['query'];
$ipaddress = ($this->ipaddress != '') ? $protocol . $this->ipaddress : $protocol . $host;
$fp = fsockopen($ipaddress, $defaultport, $errno, $errstr, 20);
// echo " $ipaddress, $defaultport, $errno, $errstr, $fp, 20\n";
if (!$fp) {
$this->error = "unable to open socket to $protocol$host";
return;
}
$out = "$method $uri HTTP/1.0\r\n";
if ($defaultport != 80) $host .= ':' . $defaultport;
$out .= "Host: $host\r\n";
$out .= $this->_include_cookies($this->original_host, $uri);
foreach($this->request as $key => $value) {
$out .= "$key: $value\r\n";
}
if ($this->postdata != '') {
if (substr($this->postdata, 0, 1) == '{') { // 20100604
$out .= "Content-Type: application/json; charset=utf-8\r\n".
'Content-Length: ' . strlen($this->postdata) . "\r\n";
} else {
$out .= "Content-Type: application/x-www-form-urlencoded\r\n".
'Content-Length: ' . strlen($this->postdata) . "\r\n";
}
}
$out .= "Connection: close\r\n\r\n"; // intel.com server requires "close" to be lowercase
$this->out = $out;
$this->headers = array('URI' => $url, 'HOST' => $host);
fwrite($fp, $out. $this->postdata);
$this->_process_response($fp);
fclose($fp);
}
private function _process_response($fp) {
$header = '';
$size = 0;
stream_set_blocking($fp, TRUE);
stream_set_timeout($fp, $this->TIMEOUT); // Timeout in seconds
$limit = $this->receive_limit;
$delta = 0; $p = FALSE;
$info = stream_get_meta_data($fp);
while ((!feof($fp)) && (!$info['timed_out'])) {
$header .= fgets($fp, 8192);
if (!$delta) {
$p = strpos($header, "\r\n\r\n");
if ($p !== FALSE) {
$delta = 4;
} else {
$p = strpos($header, "\n\n");
if ($p !== FALSE) $delta = 2;
}
}
if (($limit > 1) && $delta && ($p !== FALSE)) { // do we only need the first x bytes of data?
if (strlen($header) > $p + $limit + $delta) break;
}
$info = stream_get_meta_data($fp);
if (strlen($header) > 2048000) break;
}
$this->body = substr($header, $p + $delta);
$header = substr($header, 0, $p);
$responses = explode("\n", $header);
$this->rawheaders = array();
foreach($responses as $response) {
$response = trim($response);
$p = strpos($response, ':');
$isHTTP = substr($response, 0, 4) == 'HTTP' ? 1 : 0;
$item = strtolower(substr($response, 0, $p));
if (($item != 'content-length') && (!$isHTTP) && $response != '') {
$this->rawheaders[] = $response;
}
if ($p !== FALSE) {
$this->headers[$item] = trim(substr($response, $p + 1));
if ($item == 'set-cookie') {
$this->_include_setcookie($this->original_host, $this->headers[$item]);
}
} elseif ($isHTTP) {
$list = explode(' ', $response);
$this->headers['STATUS'] = $list[1];
}
}
$encoding = isset($this->headers['content-encoding']) ? $this->headers['content-encoding'] : '';
if ($encoding == 'gzip') $this->body = $this->gzdecode($this->body);
}
private function _serialize_data($postdata) {
$result = '';
foreach($postdata as $key => $value) {
$key = urlencode($key);
$value = urlencode($value);
if ($result != '') $result .= '&';
$result .= $key . '=' . $value;
}
return $result;
}
private function gzdecode($data) {
$len = strlen($data);
if ($len < 18 || strcmp(substr($data,0,2),"\x1f\x8b")) {
$this->error = "Not in GZIP format.";
return NULL; // Not GZIP format (See RFC 1952)
}
$method = ord(substr($data,2,1)); // Compression method
$flags = ord(substr($data,3,1)); // Flags
if ($flags & 31 != $flags) {
$this->error = "Reserved bits not allowed.";
return NULL;
}
// NOTE: $mtime may be negative (PHP integer limitations)
$mtime = unpack("V", substr($data,4,4));
$mtime = $mtime[1];
$xfl = substr($data,8,1);
$os = substr($data,8,1);
$headerlen = 10;
$extralen = 0;
$extra = '';
if ($flags & 4) {
// 2-byte length prefixed EXTRA data in header
if ($len - $headerlen - 2 < 8) {
$this->error = 'invalid LENGTH in header';
return NULL; // invalid
}
$extralen = unpack("v",substr($data,8,2));
$extralen = $extralen[1];
if ($len - $headerlen - 2 - $extralen < 8) {
$this->error = 'invalid EXTRA LENGTH in header';
return NULL; // invalid
}
$extra = substr($data,10,$extralen);
$headerlen += 2 + $extralen;
}
$filenamelen = 0;
$filename = '';
if ($flags & 8) {
// C-style string
if ($len - $headerlen - 1 < 8) {
$this->error = 'invalid FILENAME LENGTH in header';
return NULL; // invalid
}
$filenamelen = strpos(substr($data,$headerlen),chr(0));
if ($filenamelen === false || $len - $headerlen - $filenamelen - 1 < 8) {
$this->error = 'invalid FILENAME LENGTH in header (2)';
return NULL; // invalid
}
$filename = substr($data,$headerlen,$filenamelen);
$headerlen += $filenamelen + 1;
}
$commentlen = 0;
$comment = '';
if ($flags & 16) {
// C-style string COMMENT data in header
if ($len - $headerlen - 1 < 8) {
return false; // invalid
}
$commentlen = strpos(substr($data,$headerlen),chr(0));
if ($commentlen === false || $len - $headerlen - $commentlen - 1 < 8) {
return false; // Invalid header format
}
$comment = substr($data,$headerlen,$commentlen);
$headerlen += $commentlen + 1;
}
$headercrc = '';
if ($flags & 2) {
// 2-bytes (lowest order) of CRC32 on header present
if ($len - $headerlen - 2 < 8) {
return false; // invalid
}
$calccrc = crc32(substr($data,0,$headerlen)) & 0xffff;
$headercrc = unpack("v", substr($data,$headerlen,2));
$headercrc = $headercrc[1];
if ($headercrc != $calccrc) {
$this->error = "Header checksum failed.";
return NULL; // Bad header CRC
}
$headerlen += 2;
}
// GZIP FOOTER
$datacrc = unpack("V",substr($data,-8,4));
$datacrc = sprintf('%u',$datacrc[1] & 0xFFFFFFFF);
$isize = unpack("V",substr($data,-4));
$isize = $isize[1];
// decompression:
$bodylen = $len-$headerlen-8;
if ($bodylen < 1) {
// IMPLEMENTATION BUG!
return null;
}
$body = substr($data,$headerlen,$bodylen);
$data = '';
if ($bodylen > 0) {
switch ($method) {
case 8:
// Currently the only supported compression method:
$data = gzinflate($body);
break;
default:
$this->error = "Unknown compression method.";
return NULL;
}
} // zero-byte body content is allowed
// Verifiy CRC32
$crc = sprintf("%u",crc32($data));
$crcOK = $crc == $datacrc;
$lenOK = $isize == strlen($data);
if (!$lenOK || !$crcOK) {
$error = ( $lenOK ? '' : 'Length check FAILED. ') . ( $crcOK ? '' : 'Checksum FAILED.');
return false;
}
return $data;
}
private function _include_cookies($host, $path) {
global $HTTP_COOKIES;
if (($p = strpos($path, '?')) !== FALSE) $path = substr($path, 0, $p);
if (($p = strpos($path, '#')) !== FALSE) $path = substr($path, 0, $p);
$cookietext = '';
foreach($HTTP_COOKIES as $domainname => $cookielist) {
if (substr($domainname, - strlen($host)) == $host) { // cookie is suitable for this domain/subdomain
foreach($cookielist as $cookiename => $cookiedata) {
list($cookievalue, $cookiepath) = $cookiedata;
if (substr($path, 0, strlen($cookiepath)) == $cookiepath) {
if ($cookietext != '') $cookietext .= ';';
$cookietext .= ' ' . $cookiename . '=' . $cookievalue;
}
}
}
}
if ($cookietext != '') $cookietext = "Cookie:$cookietext\r\n";
return $cookietext;
}
private function _include_setcookie($host, $cookietext) {
global $HTTP_COOKIES;
$elements = $this->_parse_cookietext($cookietext);
if (!isset($elements['domain'])) $elements['domain'] = $host;
// remove a cookie ?
if ($elements['__expires'] > 0 && $elements['__expires'] < time()) {
unset($HTTP_COOKIES[$elements['domain']][$elements['name']]);
return;
}
// set cookie
if (!isset($elements['path'])) {
$elements['path'] = '/'; // this is incorrect - it should be the path of the current webpage
}
$HTTP_COOKIES[$elements['domain']][$elements['name']] = array($elements['value'], $elements['path']);
}
private function _parse_cookietext($cookietext) {
$result = array('__expires' => 0);
$text = explode('; ', $cookietext);
$count = 0;
foreach($text as $textitem) {
$p = strpos($textitem, '=');
$key = substr($textitem, 0, $p);
$value = substr($textitem, $p + 1);
if (!$count) {
$result['name'] = $key;
$result['value'] = $value;
} else {
$key = strtolower($key);
$result[$key] = $value;
if ($key == 'expires') $result['__expires'] = strtotime($value);
}
$count++;
}
return $result;
}
}
function chp_RelativeToAbsoluteURL($parent, $link) {
$source = parse_url($parent);
if (strpos($link, '://') !== FALSE) return $link; // already absolute
if (($p = strpos($link, '?')) !== FALSE) {
$source['query'] = substr($link, $p + 1);
$link = substr($link, 0, $p);
} else {
unset($source['query']);
}
$elements = explode('/', $source['path']);
if ($link != '') {
$first = substr($link, 0, 1);
if ($first == '/') {
$elements = array('');
} else {
array_pop($elements); // drop filename
}
$new = explode('/', $link);
foreach($new as $newelement) {
if ($newelement == '.' || $newelement == '') {
} elseif ($newelement == '..') {
array_pop($elements);
} else {
$elements[] = $newelement;
}
}
}
$newlink = $source['scheme'] . '://';
if (isset($source['user'])) {
$newlink .= $source['user'];
if (isset($source['pass'])) $newlink .= ':' . $source['pass'];
$newlink .= '@';
}
$newlink .= $source['host'];
if (isset($source['port'])) {
if ($source['port'] == 80 && $source['scheme'] == 'http') {
unset($source['port']);
} else if ($source['port'] == 443 && $source['scheme'] == 'https') {
unset($source['port']);
} else if ($source['port'] == 21 && $source['scheme'] == 'ftp') {
unset($source['port']);
}
}
if (isset($source['port'])) {
$newlink .= ':' . $source['port'];
}
$newlink .= implode('/', $elements);
if (isset($source['query'])) {
$newlink .= '?' . $source['query'];
}
return $newlink;
}
function chp_parse_response(&$body) {
$RES = array();
$paragraph = '';
$lines = explode("\n", $body);
foreach($lines as $line) {
$line = trim($line);
if ($line == '') continue;
if (preg_match('~\[(.*)\]~', $line, $matches)) {
$paragraph = strtolower($matches[1]);
} else {
$p = strpos($line, '=');
$key = substr($line, 0, $p);
$value = substr($line, $p + 1);
if ($paragraph != '') {
$RES[$paragraph][$key] = $value;
} else {
$RES[$key] = $value;
}
}
}
return $RES;
}