fsocket

jcgo16

New Member
Messages
10
Reaction score
0
Points
0
we made a php code
and im in php v2

but it seems the fsocket is not working

index.php
PHP:
<?php echo '<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">';?>
<head>
<title>O2Jam R3 - The Recollection of Music</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="content-style-type" content="text/css" />
<style type="text/css">
html{ font-size:11px; font-family: Tahoma; }
body{ background: #000; color: #ddd; }
a{ color: #a7a; }
a:hover{ text-decoration: none; }
p{ line-height: 10pt; margin:0px 5px 0px 10px; }

#page-wrapper {
    border: 1px solid #E4E8EF;
    margin: 0px;
    text-align: center;
    vertical-align: top;
    width: 420px;
}

b.green { color: green; text-align: center; }
b.red { color: red; text-align: center; }

#header, #footer{
    border: 1px solid #E4E8EF;
    padding: 5px;
    margin: 10px;
    text-align: center;
    vertical-align: bottom;
    width: 420px
}

.header{
    border-bottom: 2px dotted #494;
    color: #FC0;
    font-family: Arial;
    font-size: 1.25em;
    font-weight: bold;
    margin: 8px;
    padding: 8px;
    text-align: center;
    text-transform: uppercase;
}

.headerdesc{
    line-height: 10pt;
    margin: 8px;
    padding: 8px;
    text-align: center;
    white-space: normal;
}
</style>
</head>

<body>
<div id="page-wrapper">
    <table><tbody>
        <tr><td id="header">
        O2Jam R3 - The Recollection of Music<br/>
            <?php
                include 'serverstatus.php';    
                    
                echo 'Game Server:&nbsp;';
                if($serverstatus == 1) { echo '<b class="green">Online</b>'; }
                else { echo '<b class="red">Offline</b>';}
                
                echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
                
                echo 'Music Server:&nbsp;';
                if($ftptatus == 1) { echo '<b class="green">Online</b>'; }
                else { echo '<b class="red">Offline</b>'; }
            ?>
        </td></tr>
        
        <tr><td>
            <div class="header">:: 31 October 2008 ::</div>
            <div class="headerdesc">
                <p>Let's all get spooked on All Hollow's Eve. New notice page coming in a few days...</p>
            </div>
            
            <div class="header">:: 14 October 2008 ::</div>
            <div class="headerdesc">
                <p>New minor but important patch.
                <br/>- Server IP Address Changed.
                </p>
            </div>
        </td></tr>
        
        <tr><td id="footer">
            <p>&copy; 2008 Chu Chin Kuan. All rights reserved.</p>
            <a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0 Strict" height="31" width="88" /></a>
            <a href="http://jigsaw.w3.org/css-validator/"><img style="border:0;width:88px;height:31px" src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!" /></a>
        </td></tr>
    </tbody></table>
</div>
</body>
</html>
and this is the serverstatus.php

PHP:
<?php
$gameip = "o2jamr3.myftp.org";
$ftpip = "o2r3.servegame.com";

// Game Status Check
$timeout = 1;

if($myipc = @fsockopen($gameip, 15010, $errno, $errstr, $timeout)) {
$serverstatus = 1;
fclose($myipc); }

else{ $serverstatus = 0; }

// FTP Status Check
$timeout = 1;

if($myipc = @fsockopen($ftpip1, 21, $errno, $errstr, $timeout)) {
$ftpstatus = 1;
fclose($myipc); }

else{ $ftpstatus = 0; }
?>
pls... help
all pages are correct
why it is not working well
its always says offline
but in *name of hosting company removed*
http://o2jam-r3.cjb.net/
its says online
pls.. help?
 
Last edited by a moderator:

Submariner

New Member
Messages
44
Reaction score
1
Points
0
Since you have passed the optional parameters $errno and $errstr modify the files as follows:

index.php in 'page-wrapper' div:
PHP:
<?php
	include 'serverstatus.php';

	echo '<!-- Game Error: "$gameErr" GameErrNo: "$gameErrNo" Ftp Error: "$ftpErr" FtpErrNo: "$ftpErrNo" -->';
		
	echo 'Game Server:&nbsp;';
	if($serverstatus == 1) { echo '<b class="green">Online</b>'; }
	else { echo '<b class="red">Offline</b>';}
	
	echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
	
	echo 'Music Server:&nbsp;';
	if($ftptatus == 1) { echo '<b class="green">Online</b>'; }
	else { echo '<b class="red">Offline</b>'; }
?>

serverstatus.php:
PHP:
<?php
$gameip = "o2jamr3.myftp.org";
$ftpip = "o2r3.servegame.com";

// Game Status Check
$timeout = 1;

// error holders
$gameErr = "";
$gameErrNo = 0;
$ftpErr = "";
$ftpErrNo = 0;

$myipc = @fsockopen($gameip, 15010, $errno, $errstr, $timeout)
if($myipx) {
$serverstatus = 1;
fclose($myipc); 
} else { 
$serverstatus = 0; 
$gameErr = $errstr;
$gameErrNo = $errno;
}

// FTP Status Check
$timeout = 1;

if($myipc = @fsockopen($ftpip1, 21, $errno, $errstr, $timeout)) {
$ftpstatus = 1;
fclose($myipc); 
} else { 
$ftpstatus = 0; 
$ftpErr = $errstr;
$ftpErrNo = $errno;
}
?>

Then view the page source and look at the comment to see what the error messages and error number are. It would help troubleshooting a whole bunch.

James
 

jcgo16

New Member
Messages
10
Reaction score
0
Points
0
PHP:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head>
<title>O2Jam R3 - The Recollection of Music</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="content-style-type" content="text/css" />
<style type="text/css">
html{ font-size:11px; font-family: Tahoma; }
body{ background: #000; color: #ddd; }
a{ color: #a7a; }
a:hover{ text-decoration: none; }
p{ line-height: 10pt; margin:0px 5px 0px 10px; }

#page-wrapper {
	border: 1px solid #E4E8EF;
	margin: 0px;
	text-align: center;
	vertical-align: top;
	width: 420px;
}

b.green { color: green; text-align: center; }
b.red { color: red; text-align: center; }

#header, #footer{
	border: 1px solid #E4E8EF;
	padding: 5px;
	margin: 10px;
	text-align: center;
	vertical-align: bottom;
	width: 420px
}

.header{
	border-bottom: 2px dotted #494;
	color: #FC0;
	font-family: Arial;
	font-size: 1.25em;
	font-weight: bold;
	margin: 8px;
	padding: 8px;
	text-align: center;
	text-transform: uppercase;
}

.headerdesc{
	line-height: 10pt;
	margin: 8px;
	padding: 8px;
	text-align: center;
	white-space: normal;
}
</style>
</head>

<body>
<div id="page-wrapper">
	<table><tbody>
		<tr><td id="header">
		O2Jam R3 - The Recollection of Music<br/>
			<br />
<b>Parse error</b>:  syntax error, unexpected T_IF in <b>/home/jcgo16/public_html/serverstatus.php</b> on line <b>15</b><br />


its says
O2Jam R3 - The Recollection of Music

Parse error: syntax error, unexpected T_IF in /home/jcgo16/public_html/serverstatus.php on line 15
 

xPlozion

New Member
Messages
868
Reaction score
1
Points
0
forgot the semicolon ;)
PHP:
$myipc = @fsockopen($gameip, 15010, $errno, $errstr, $timeout)
also, where the ftp part is, change
PHP:
if($myipc = @fsockopen($ftpip1, 21, $errno, $errstr, $timeout)) {
to
PHP:
$myipc = @fsockopen($ftpip1, 21, $errno, $errstr, $timeout);
if($myipc) {
also, where you have
PHP:
$myipc = @fsockopen($gameip, 15010, $errno, $errstr, $timeout) 
if($myipx) {
change they're not the same variable, so it will always return false. change the top to $myipx or the bottom to $myipc

so... serverstatus.php should be:
PHP:
<?php 
$gameip = "o2jamr3.myftp.org"; 
$ftpip = "o2r3.servegame.com"; 

// Game Status Check 
$timeout = 1; 

// error holders 
$gameErr = ""; 
$gameErrNo = 0; 
$ftpErr = ""; 
$ftpErrNo = 0; 

$myipc = @fsockopen($gameip, 15010, $errno, $errstr, $timeout);
if($myipc) { 
$serverstatus = 1; 
fclose($myipc);  
} else {  
$serverstatus = 0;  
$gameErr = $errstr; 
$gameErrNo = $errno; 
} 

// FTP Status Check 
$timeout = 1; 

$myipc = @fsockopen($ftpip1, 21, $errno, $errstr, $timeout);
if($myipc) { 
$ftpstatus = 1; 
fclose($myipc);  
} else {  
$ftpstatus = 0;  
$ftpErr = $errstr; 
$ftpErrNo = $errno; 
} 
?>
 
Last edited:

jcgo16

New Member
Messages
10
Reaction score
0
Points
0
its says offline again
nothing works
i think the php blocks it

dunno
im version 2 intermediate
im gonna change my hosting site
thanks for help
 
Top