Jump to content

[SOLVED] fsocketopen error


chris_2001

Recommended Posts

Im trying to connect to a program with fsocketopen, it works perfectly but when its offline (the program) its supposed to echo "Not online, try again later.\r\n";

 

instead i get this error:

 

Warning:  fsockopen(): unable to connect to 24.87.88.136:31221 in c:\program files\easyphp1-7\www\login.php on line 14

Fatal error:  Maximum execution time of 30 seconds exceeded in c:\program files\easyphp1-7\www\login.php on line 14

 

Code below

 

Thx in advance

 

<?php




$login = $_POST['user'];
$pass = $_POST['pw'];



include 'accounts.php';

echo "<pre>";
$fp = fsockopen($host, $port);
if(!$fp) {
	echo "Not online, try again later.\r\n";
	exit;
}else{


if ($login == '****' && $pass == '****' or $login == '****' && $pass == '****')
{







fputs($fp, $gliderpass . "\r\n");
echo "Current Leveling Status: \r\n";
fputs($fp, "/status\r\n");
$status = "";
while(1){
$packet = fread($fp, 8192);
$status .= $packet;
if(substr($packet, -5) == "---\r\n") break;
}
$status = explode("\r\n", $status);
//if you want to remove undesired stuff
//$status = array_slice($status, 0, 6);
//print_r($status);


//$hp = str_replace('Health: ', '', $status['6']);
//$hp = $hp*100;
//$mana = str_replace('Mana: ', '', $status['7']);

if ($accstatus == '1'){
$xp = str_replace('Experience: ', '', $status['11']);
$nextxp = str_replace ('Next-Experience: ', '', $status['12']);
$xphr = str_replace ('XP/Hour: ', '', $status['13']);
$timelevel1 = $nextxp-$xp;
$timelevel2 = $timelevel1/$xphr;

	if($host==$chrisip){		
			if (isset($money)){
			echo "{$status['9']}<br></br>{$status['10']}<br></br>Experience: $xp<br></br>Next Experience: $nextxp<br></br>XP Needed: $timelevel1<br></br>XP/HR: $xphr<br></br><B>Hours till next level: $timelevel2</b><br></br>{$status['16']} (Kill/Looted/Deaths)<br></br><br></br><br></br>You owe: $money<br></br>Leveler: Chris"; 
			}else{
			echo "{$status['9']}<br></br>{$status['10']}<br></br>Experience: $xp<br></br>Next Experience: $nextxp<br></br>XP Needed: $timelevel1<br></br>XP/HR: $xphr<br></br><B>Hours till next level: $timelevel2</b><br></br>{$status['16']} (Kill/Looted/Deaths)<br></br><br></br><br></br><br></br>Leveler: Chris"; 
	}}
	elseif($host==$nimaip){
			if (isset($money)){
			echo "{$status['9']}<br></br>{$status['10']}<br></br>Experience: $xp<br></br>Next Experience: $nextxp<br></br>XP Needed: $timelevel1<br></br>XP/HR: $xphr<br></br><B>Hours till next level: $timelevel2</b><br></br>{$status['16']} (Kill/Looted/Deaths)<br></br><br></br><br></br>You owe: $money<br></br>Leveler: Nima"; 
			}else{
			echo "{$status['9']}<br></br>{$status['10']}<br></br>Experience: $xp<br></br>Next Experience: $nextxp<br></br>XP Needed: $timelevel1<br></br>XP/HR: $xphr<br></br><B>Hours till next level: $timelevel2</b><br></br>{$status['16']} (Kill/Looted/Deaths)<br></br><br></br><br></br><br></br>Leveler: Nima"; 
	}}
	else{
			if (isset($money)){
			echo "{$status['9']}<br></br>{$status['10']}<br></br>Experience: $xp<br></br>Next Experience: $nextxp<br></br>XP Needed: $timelevel1<br></br>XP/HR: $xphr<br></br><B>Hours till next level: $timelevel2</b><br></br>{$status['16']} (Kill/Looted/Deaths)<br></br><br></br><br></br>You owe: $money<br></br>Leveler: Chris"; 
			}else{
			echo "{$status['9']}<br></br>{$status['10']}<br></br>Experience: $xp<br></br>Next Experience: $nextxp<br></br>XP Needed: $timelevel1<br></br>XP/HR: $xphr<br></br><B>Hours till next level: $timelevel2</b><br></br>{$status['16']} (Kill/Looted/Deaths)<br></br><br></br><br></br><br></br>Leveler: Nima"; 
	}}




}
else if ($accstatus == '0'){

echo "Your character has not started being leveled at this time.";

}

else if ($accstatus == '2'){

echo "Leveling is complete. No status to show!";

}else {

echo 'Unknown Account status';

}

fclose($fp);
}
else
{
header("Location: index.php");
}}
?>

Link to comment
https://forums.phpfreaks.com/topic/75140-solved-fsocketopen-error/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.