HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/PvdBoogaard/indoorski.nl/backup/oude-site/cms/lib/class.remoteopener.php
<?php

	/*
		Class to determine which remote file opening method to use -
		either fopen or CURL, depending on what is available.
	*/

	class connect_remote
	{
		var $_method = 'OPENER_NONE';
		var $timeout = 5;

		// Constructor PHP 4
		public function connect_remote()
		{
			$this->__construct();
		}

		// Constructor PHP 5
		public function __construct(){
			if(@function_exists("curl_init")){
				$this->_method = 'OPENER_CURL';
			}elseif((int)@ini_get("allow_url_fopen") != 0){
				$this->_method = 'OPENER_FOPEN';
			}else{
				$this->_method = 'OPENER_NONE';
			}
		}

		public  function CanOpen()
		{
			return ($this->_method == 'OPENER_NONE' ? false : true);
		}

		public  function Open($URL, &$RetVal)
		{
			// Open the remote file using fopen or CURL
			$data = "";

			if($this->_method == 'OPENER_FOPEN')
			{
				// Try with FOPEN
				if($fp = @fopen($URL, "rb"))
				{
					while(!@feof($fp)){
						$RetVal .= @fgets($fp, 4096);
					}

					@fclose($fp);
					return true;
				}
				else
				{
					return false;
				}
			}
			else if($this->_method == 'OPENER_CURL')
			{
				// Try with CURL
				if($ch = @curl_init())
				{
					curl_setopt($ch, CURLOPT_URL, $URL);
					//curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
					curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
					curl_setopt($ch, CURLOPT_FAILONERROR, true);
					curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout);
					curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
					curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

					$RetVal = curl_exec($ch);
					curl_close($ch);
					return true;
				}
				else
				{
					return false;
				}
			}
			else
			{
				return false;
			}
		}
	}