Warning: fsockopen() [function.fsockopen]: unable to connect to – Apache Web Server

  apache

Q(Question):

I am working on a script and i get this error

Warning: fsockopen() [function.fsockopen]: unable to connect to https://www.alertpay.com:443 (Unable to find the socket transport "https" – did you forget to enable it when you configured PHP?) in XXXXXXXXXXXXXX on line 84

I have contacted my host to make sure that ssl and all that is enabled he says it has been enabled and it still dont work

here is my server info
http://www.performancebux.com/info.php

If any one see what that problem is please let me know how to maybe fix it and maybe how to get it to work here is a copy of the php code that i am using to witch is causeing the problem


class CYsHttpClass
{
protected $cookies, $postdata,$r_header,$r_content,$s_request;
final protected function addCookie($k, $v)
{
if(is_array($k))
for($i=0;$i<sizeof($k);$i++)
$this->cookies[$k[$i]] = $v[$i];
else
$this->cookies[$k] = $v;
}
final protected function addPostData($k, $v)
{
if(is_array($k))
for($i=0;$i<sizeof($k);$i++)
$this->postdata[$k[$i]] = $v[$i];
else
$this->postdata[$k] = $v;
}
final protected function httpConnect($url,$method='GET',$referer='',$useragent='PayChain')
{
$port = 80; //Set Default Port to 80
$method = strtoupper($method);
list($protocol,$server,$script) = preg_split("/(http|https)?:\/\/([^\/]+)([^ ]*)/",$url,-1,PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
if($protocol=="https")
$port = 443;
if(strpos($server,":") != false)
list($server,$port) = preg_split("/([^:]+):(.+)/",$server,-1,PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
$cookiestring = "";
if(is_array($this->cookies))
if(sizeof($this->cookies) > 0)
foreach($this->cookies as $key=>$value)
{
if(strlen($cookiestring) != 0)
$cookiestring .= '; ';
$cookiestring .= urlencode($key) . '=' . urlencode($value);
}
$postdatastring = "";
if(is_array($this->postdata))
{
$postdatastring = "";
if(sizeof($this->postdata) > 0)
foreach($this->postdata as $key=>$value)
{
if(strlen($postdatastring) != 0) $postdatastring .= '&';
$postdatastring .= urlencode($key) . '=' . urlencode($value);
}
}
$this->postdata = array(); // reset postdata field after use
$this->s_request="$method $script HTTP/1.1\r\n";
$this->s_request.="Host: $server\r\n";
$this->s_request.="Accept: */*\r\n";
if($cookiestring)
$this->s_request.="Cookie: $cookiestring\r\n";
if($referer)
$this->s_request.="Referer: $referer\r\n";
if($useragent)
$this->s_request.="User-Agent: $useragent\r\n";
$this->s_request.="Connection: close\r\n";
if($method == "POST")
{
$this->s_request.="Content-Type: application/x-www-form-urlencoded\r\n";
$this->s_request.="Content-Length: ".strlen($postdatastring)."\r\n";
$this->s_request.="\r\n$postdatastring\r\n";
}
else
$this->s_request.="\r\n";
$sock = fsockopen(($protocol=="https"? "ssl://".$server : $server), $port, $errno, $errstr);
if($sock)
fwrite($sock, $this->s_request);
else
{
$this->r_header = "$errstr ($errno)";
return -1;
}
$this->r_header = "";
while($str = trim(fgets($sock, 4096)))
$this->r_header .= "$str\n";
if(preg_match_all("/Set-Cookie: (.*); path/", $this->r_header, $newcookie))
foreach($newcookie[1] as $c)
{
list($k,$v) = explode("=", $c);
$this->cookies[$k] = $v;
}
$this->r_content = "";
while(1)
{
$buf = fread($sock,8192);
if(strlen($buf) == 0) break;
$this->r_content .= $buf;
}
// echo("DEBUG:".$this->r_content);
}
}

please if any can give some advice please let me know

A(Answer):

LEAVE A COMMENT