Novahq.net Forum

Novahq.net Forum (https://novahq.net/forum/index.php)
-   phphq.Net Forums (https://novahq.net/forum/forumdisplay.php?f=277)
-   -   babstats server online (https://novahq.net/forum/showthread.php?t=38774)

varg 01-16-2005 12:44 PM

babstats server online
 
I'm trying to put a status note in my forums saying if our main server is running. Using babstats.
Here's what I've got so far, it's working, but it echoes all the servers. I'd like it to echo just the server with a certain ID - I guess that has to be specified in the $query, but I'm not sure how to do just that.

[code:1:26d24b6abe]
<?
$dbh=mysql_connect ('localhost', 'username', 'password') or die(mysql_error());
mysql_select_db(dbname,$dbh) or die(mysql_error());


$query = mysql_query("SELECT * FROM `bab_servers` ORDER BY name") or die(mysql_error());
$thetime = time();
while($row = mysql_fetch_array($query)) {
if($thetime > ($row[last_update] + 120)) {
echo "Server is offline";
} else {
echo "Server is online";
} }
?>

[/code:1:26d24b6abe]
this is how it looks now. as you can see, it shows the offline servers aswell. While I only want it to show the last, online server, which is ID=5 in the database.
I'm no php expert, so help is most appreciated

//EDIT:
problem fixed, you can now delete this post if you want to.
in case someone wants to know
[code:1:26d24b6abe]
$dbh=mysql_connect ('localhost', 'username', 'password') or die(mysql_error());
mysql_select_db(dbname,$dbh) or die(mysql_error());
$id = "5";
$query = mysql_query("SELECT * FROM `bab_servers` WHERE id=$id") or die(mysql_error());
$thetime = time();
while($row = mysql_fetch_array($query)) {
if($thetime > ($row[last_update] + 120)) {
echo "<a href=\"http://www.mapmakersheaven.com/server.php\">server is<font size=\"2\" color=\"#871C01\"><strong> offline </strong></font></a>";
} else {
echo "<a href=\"http://www.mapmakersheaven.com/server.php\">server is<font size=\"2\" color=\"#006600\"><strong> online </strong></font></a>";
} }[/code:1:26d24b6abe]

varg 01-19-2005 07:14 AM

I've been working some more on extracting info from the babstats database, learned a lot on my way, and I have to say that I'm quite proud lol.
http://mapmakersheaven.com/server/
Still working on it, but it is fully functional :)

Ennough bragging, here's my question:
I want to get the names of the people in the server...
The only way I can think of would be to get it from df-favs (I have a df favs bug running on my main page, which will display the players when you hover your mouse over the gamename) Would anyone happen to know how i should go about to do just that??

Scott 01-19-2005 11:20 PM

The player names are listed in the database in bab.stats. They are just encoded (if i remember correct) look in the files where it lists players in the server.. look for something similar to base64_encode() base64_decode().. if memory serves right you have to do something on the lines of:

run your query for the encoded names in the mysql coloum, explode them by whatever they are seperated with, and do something like:

$names=explode(" ",$result[names]); //if they are seperated by a space..

Then do a for():

for($i=0; $i=>count($names); $i++) {
$name=base64_decode($name[$i]);
Echo($name);
}

That would be similar to what your looking for or at least get you on the right track. I don't have bab.stats installed and haven't for awhile so I can't be sure, but I know there encoded with a base64_encode() in the db.

varg 01-20-2005 07:49 AM

Thanks its great news if the info is allready in the bab db. And why shouldn't it, it displays the name of the best players, so it has to know when they played...

I took a quick look for "base64" in some of the files now, couldn't find it. But I'll take a closer look at some more files when I get home tonight.
I guess I should have mentioned that I am using babstats v3 .
(http://www.mapmakersheaven.com/bab/)

//Edit just as I closed my editor I checked status.php where it lists
[code:1:f57ae5f8f2] $game = base64_decode($game);
$servername = base64_decode($servername);
$mapname = base64_decode($mapname);
$idcode = base64_decode($idcode);[/code:1:f57ae5f8f2]
I'm gonna mess with this later as I said, but I'm definitly going to need some help at one point or another :)


All times are GMT -5. The time now is 05:16 PM.

Powered by vBulletin®