fsockopen() won't work :(

Status
Not open for further replies.

ragnar

New Member
Messages
1
Reaction score
0
Points
0
Hi!
First of all, congrats for your excelent service!

Now, my problem is the following:

I have this script:
PHP:
<?php
$info = chr(6).chr(0).chr(255).chr(255).'info';
//making socket connection to an ip and port 7171
$sock = fsockopen('83.149.85.11', 7171, $errno, $errstr, 1);
if ($sock)
{
//writes the info gotten by sending the server packet.
fwrite($sock, $info);
$data='';
while (!feof($sock))
{
$data .= fgets($sock, 1024);
}
fclose($sock);
//players online and max (ex. Players online: 24 / 100)
preg_match('/players online="(\d+)" max="(\d+)"/', $data, $matches);
//print 'Estado:<b><font face="verdana" size="2" color="#00FF00"> Online</font></b>';
$players = 'Online: '.$matches[1].' / '.$matches[2];
//Owner Name and e-mail (ex. Owner Name: jasper E-mail: jaja@jaja.com)
preg_match('/owner name="(\D*)" email="([\w\._]+@[\w\._]*)"/', $data, $matches);
$owner = 'sd: '.$matches[1];
//Uptime (Uptime: 23h 12m)
preg_match('/uptime="(\d+)"/', $data, $matches);
$h = floor($matches[1] / 3600);
$m = floor(($matches[1] - $h*3600) / 60);
$uptime = 'Uptime: '.$h.'h '.$m.'m';
//uncomment for debug
//print "$owner <br /> $uptime <br /> $players";
$image = imagecreatefrompng('fondo.png');
header("Content-type: image/png");
$black = imagecolorallocate($image, 0, 0, 0);
Imagestring($image,2,(imagesy+5),(imagesy+23),$uptime,$black);
Imagestring($image,2,(imagesy+5),(imagesy+37),$players,$black);
imagepng($image);
imagedestroy($image);
}else {
$offline = "Servidor offilne";
$image = imagecreatefrompng('fondo.png');
header("Content-type: image/png");
$black = imagecolorallocate($image, 0, 0, 0);
Imagestring($image,2,(imagesy+5),(imagesy+23),$offline,$black);
imagepng($image);
imagedestroy($image);
}
?>
And when I render the page, it appears this error:

Warning: fsockopen() [function.fsockopen]: unable to connect to 83.149.85.11:7171 (Connection timed out) in /home/utibia/public_html/uptime.php on line 4

Help please :D
 

Corey

I Break Things
Staff member
Messages
34,551
Reaction score
204
Points
63
I don't see a hosting account linked with your forum name so I am unable to look up what server you are on.

Most likely the IP you are trying to connect to will need to be added to our firewall. Could you please link your accounts so I can do this?

-Corey
 

Corey

I Break Things
Staff member
Messages
34,551
Reaction score
204
Points
63
Closing thread due to no response.
 
Status
Not open for further replies.
Top