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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.