question about php code for server blueburst help

If you have any questions on programming, this is the place to ask them, whether you're a newbie or an experienced programmer. Discussion on programming in general is also welcome. We will help you with programming homework, but we will not do your work for you! Any porting requests must be made in Developmental Ideas.
Post Reply
User avatar
legit nyck
Psychotic DCEmu
Psychotic DCEmu
Posts: 670
https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
Joined: Wed Jan 04, 2012 2:14 pm
Location: Suzano SP BR
Has thanked: 64 times
Been thanked: 49 times
Contact:

question about php code for server blueburst help

Post by legit nyck »

'm asking helps to achieve this code and by my mysql System the long
already tried in various places and various forums help and nowhere
I got them success it (Sad) 'll lay here some of codes that received
only that you guys see that no their works the server PSOBB(teath)
at least not mine
Codes
Spoiler!
<?php
echo "Patch server: ";
$fp = stream_socket_client("tcp://yui.psobbserv.net:11000", $errno, $errstr, 30);
if (!$fp) {
echo "OFFLINE<br />n";
fclose($fp);
} else {
echo "ONLINE<br />n";
fclose($fp);
}
echo "Login server: ";
$fp = stream_socket_client("tcp://yui.psobbserv.net:12000", $errno, $errstr, 30);
if (!$fp) {
echo "OFFLINE<br />n";
fclose($fp);
} else {
echo "ONLINE<br />n";
fclose($fp);
}
echo "Ship server: ";
$fp = stream_socket_client("tcp://yui.psobbserv.net:12001", $errno, $errstr, 30);
if (!$fp) {
echo "OFFLINE<br />n";
fclose($fp);
} else {
echo "ONLINE<br />n";
fclose($fp);
}
?>
this code provides no the status how many players are online server only show
that ship and the server are online
and this other code
Spoiler!
<style>
.style {
font-size: 10px;
font: Verdana;
font-weight: bold;
color: #009900;
}
.style2 {
font-size: 10px;
font: Verdana;
font-weight: bold;
color: #FF0000;
}
.style3 {
font-size: 10px;
font: Verdana;
color: #FF0000;
}
</style>
<?php

/**
* @Fetish
* @copyright 2008
*/

$nome = "Phantasy Star Online Blue Burst"; // Nome do seu servidor

$ip = "127.0.0.1"; // Ip do seu servidor

$shipport = "6121"; // Porta Char
$loginport = "6900"; // Porta Login
$patchport = "5121"; // Porta Patch

$mostrar = 0; # [Mostra Login,Map,Char 1: Mostra Nome do server e status]

$status = array (
"<span class=\"style\">Online</span>",
"<span class=\"style2\">Offline</span>",
"<Font Face='Verdana' Style='Font-Size: 10'><B>", "</B></Font>"
);
$portaserver = array ($charport,$loginport,$mapport);
for ($i = 0; isset ($portaserver[$i]); $i ++) {
$algo[$i] = $status[1];
if($abrir = @fsockopen(gethostbyname($ip),$portaserver[$i],$error,$erro2, (float)0.5)) {
$algo[$i] = $status[0];
fclose($abrir);
}
}
$show[0] = $nome;
if(!$mostrar)
$show = array ("Char-Server","Login-Server","Map-Server");
else {
if($algo[0] == $status[1] || $algo[1] == $status[1] || $algo[2] == $status[1])
$algo[0] = $status[1];
else
$algo[0] = $status[0];
}
$host = "localhost"; //Local padr�o
$user = "root"; // usuario padr�o
$pass = ""; // senha padr�o
$db = ""; // Sua database
$conectar = mysql_connect($host,$user,$pass) or die (mysql_error());
$select = mysql_select_db($db) or die (mysql_error());
$query = mysql_query ("SELECT * FROM `char` WHERE `online` = '1'");
$num = mysql_num_rows ($query);
for ($i = 0; isset ($show[$i]); $i ++)
echo "<br>$status[2] $show[$i] $status[3] $algo[$i]";
echo "<br><Font Face='Verdana' Style='Font-Size: 10'><b>Usuarios Online: <span class=\"style3\">$num</span></b></font>";
?>
is not even accepted by the system php the error at the same time
is this I would greatly appreciate it if someone here can
help me with this issue which has fried my neurons
and left me crazy (literally)
PsO Brazilian Hunter RAmar
User avatar
RyoDC
Mental DCEmu
Mental DCEmu
Posts: 366
Joined: Wed Mar 30, 2011 12:13 pm
Has thanked: 2 times
Been thanked: 0

Re: question about php code for server blueburst help

Post by RyoDC »

What a flow of symbols.
is not even accepted by the system php the error at the same time
Be detailed please.
What error, where, at which line.
Provide screenshots, copy-paste error messages. Provide a full code you're trying to run.
Then we (and I) can help you.

Added.
I've just tested your code, your api is fine, you just use the wrong address - function directly says to you (in error message), that such a host can't be found, means, there's no such host in the Web at all.
Well, and I do agree, it's a very strange behavior for a function - instead of throwing an exception or returning some meaningful result, such as error-code, etc, it's just terminates your program execution with an error, well, yep, it's weird.
Possible solution, to prevent crashing of your program, may be like this:

Code: Select all

 $host =  "yui.psobbserv.net";
    if(gethostbyname("yui.psobbserv.net")==$host) {
        echo 'No such host in the Web';
    }
    else {
        //checkOnlineStatus(); //your function that checks if server is up
    }
Hope this helps.

Also, if you want to test a specific port of the host you're trying to connect to, you can use following code (or like-derivatives):

Code: Select all

function pingDomain($domain){
    $starttime = microtime(true);
    $file      = fsockopen ($domain, 80, $errno, $errstr, 10);
    $stoptime  = microtime(true);
    $status    = 0;

    if (!$file) $status = -1;  // Site is down
    else {
        fclose($file);
        $status = ($stoptime - $starttime) * 1000;
        $status = floor($status);
    }
    return $status;
}
How do I try to build a Dreamcast toolchain:
Image
User avatar
legit nyck
Psychotic DCEmu
Psychotic DCEmu
Posts: 670
Joined: Wed Jan 04, 2012 2:14 pm
Location: Suzano SP BR
Has thanked: 64 times
Been thanked: 49 times
Contact:

Re: question about php code for server blueburst help

Post by legit nyck »

firstly thanks By being willing to help
this first image you see the main server status in my forum
but he has a problem there is showing 0 users online
and patch server online and login server online
correct,,but when I took print this had 3 users logged
the server information there is not correct and I do not
know what to do to fix it ( other things even I shut down the server
such information there in main server status no change are always
thus :?
Image
This second image is the pitcher that I am using in my forum in windgest
Image
and it is the code in my php system
Spoiler!
<?php
echo "Patch server: ";
$fp = stream_socket_client
("Ip my server:11000",
$errno, $errstr, 30);
if (!$fp) {
echo "OFFLINE<br />";
fclose($fp);
} else {
echo "ONLINE<br />";
fclose($fp);
}
echo "Login server: ";
$fp = stream_socket_client
("ip my server:12000",
$errno, $errstr, 30);
if (!$fp) {
echo "OFFLINE<br />";
fclose($fp);
} else {
echo "ONLINE<br />";
fclose($fp);
}
echo "Legits World: ";
$fp = stream_socket_client
("ip my server:12001",
$errno, $errstr, 30);
if (!$fp) {
echo "OFFLINE<br />";
fclose($fp);
} else {
$y = + 0;
$x = $y + 0;
echo "<b><span class=\"style3\">$x</span></b></font>";
fclose($fp);
}
?>
this is good if possible send me a code for I test in my I server
would greatly appreciate it. another question What intrigues me Where should I
adding data ship.ini? I imagine to show quantity players online
must have a integration between ship.ini and php code is not it?
PsO Brazilian Hunter RAmar
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5658
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: question about php code for server blueburst help

Post by BlueCrab »

First of all mysql_num_rows() is not a good way to get what you're looking for. According to the PHP documentation it will be removed from PHP 5.5.0 and later. So, you don't want to do that for future use.

If you're just looking for the count of the users, you can select that quite easily by using a SQL statement like this (you'll have to adjust it for what you're looking for since this is how I could do it on Sylverant, but it should give you the idea):

Code: Select all

SELECT COUNT(*) FROM online_clients;
Then, you can get the data the same way you would any other database value in php. You should end up with one row in the result set and there should only be one column as well (which will be the number of results that the statement would have given you.
User avatar
legit nyck
Psychotic DCEmu
Psychotic DCEmu
Posts: 670
Joined: Wed Jan 04, 2012 2:14 pm
Location: Suzano SP BR
Has thanked: 64 times
Been thanked: 49 times
Contact:

Re: question about php code for server blueburst help

Post by legit nyck »

BlueCrab wrote:

Code: Select all

SELECT COUNT(*) FROM online_clients;
I'll try thanks
PsO Brazilian Hunter RAmar
User avatar
Katherine Kennedy
DCEmu Newbie
DCEmu Newbie
Posts: 3
Joined: Fri Jan 18, 2013 10:08 am
Location: US / California / North Woodbridge
Has thanked: 0
Been thanked: 0

Re: question about php code for server blueburst help

Post by Katherine Kennedy »

BlueCrab wrote:First of all mysql_num_rows() is not a good way to get what you're looking for. According to the PHP documentation it will be removed from PHP 5.5.0 and later. So, you don't want to do that for future use.

If you're just looking for the count of the users, you can select that quite easily by using a SQL statement like this (you'll have to adjust it for what you're looking for since this is how I could do it on Sylverant, but it should give you the idea):

Code: Select all

SELECT COUNT(*) FROM online_clients;
Then, you can get the data the same way you would any other database value in php. You should end up with one row in the result set and there should only be one column as well (which will be the number of results that the statement would have given you.
what do this mean? to me you only this playing further doubts and complicating
further could be direct? one was not made question such as would be done in a specific server
but as if yes make the code :?
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5658
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: question about php code for server blueburst help

Post by BlueCrab »

Katherine Kennedy wrote:
BlueCrab wrote:First of all mysql_num_rows() is not a good way to get what you're looking for. According to the PHP documentation it will be removed from PHP 5.5.0 and later. So, you don't want to do that for future use.

If you're just looking for the count of the users, you can select that quite easily by using a SQL statement like this (you'll have to adjust it for what you're looking for since this is how I could do it on Sylverant, but it should give you the idea):

Code: Select all

SELECT COUNT(*) FROM online_clients;
Then, you can get the data the same way you would any other database value in php. You should end up with one row in the result set and there should only be one column as well (which will be the number of results that the statement would have given you.
what do this mean? to me you only this playing further doubts and complicating
further could be direct? one was not made question such as would be done in a specific server
but as if yes make the code :?
Well, excuse me for trying to help the best I could. I don't have the time to figure out exactly how he'd go about doing what he wants with the server software he's using. I don't maintain that server software, nor do I have the time or patience to mess with it.

I simply gave a hint of how to do it in a much cleaner fashion, and without having to worry about functions that will eventually disappear from PHP. I told him simply how I could do it on my PSO server, Sylverant. Excuse me for not knowing how every other PSO server out there works internally off the top of my head. :roll:
User avatar
legit nyck
Psychotic DCEmu
Psychotic DCEmu
Posts: 670
Joined: Wed Jan 04, 2012 2:14 pm
Location: Suzano SP BR
Has thanked: 64 times
Been thanked: 49 times
Contact:

Re: question about php code for server blueburst help

Post by legit nyck »

BlueCrab wrote:
Katherine Kennedy wrote:
BlueCrab wrote:First of all mysql_num_rows() is not a good way to get what you're looking for. According to the PHP documentation it will be removed from PHP 5.5.0 and later. So, you don't want to do that for future use.

If you're just looking for the count of the users, you can select that quite easily by using a SQL statement like this (you'll have to adjust it for what you're looking for since this is how I could do it on Sylverant, but it should give you the idea):

Code: Select all

SELECT COUNT(*) FROM online_clients;
Then, you can get the data the same way you would any other database value in php. You should end up with one row in the result set and there should only be one column as well (which will be the number of results that the statement would have given you.
what do this mean? to me you only this playing further doubts and complicating
further could be direct? one was not made question such as would be done in a specific server
but as if yes make the code :?
Well, excuse me for trying to help the best I could. I don't have the time to figure out exactly how he'd go about doing what he wants with the server software he's using. I don't maintain that server software, nor do I have the time or patience to mess with it.

I simply gave a hint of how to do it in a much cleaner fashion, and without having to worry about functions that will eventually disappear from PHP. I told him simply how I could do it on my PSO server, Sylverant. Excuse me for not knowing how every other PSO server out there works internally off the top of my head. :roll:
lol I who should apologize for it katherine is a friend of mine and is somewhat stressed
I appreciate your help blue thx ^^ :wink:
PsO Brazilian Hunter RAmar
Post Reply