TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

March 29, 2024, 05:07:06 AM

Login with username, password and session length
Members
Stats
  • Total Posts: 195,105
  • Total Topics: 21,213
  • Online today: 310
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 1
  • Guests: 292
  • Total: 293
  • lurkalot

Block Code for BHD Server Status

Started by BCB, March 15, 2006, 03:21:05 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

BCB

I have a block that was used in PHP Nuke I believe, and I am wanting to get this to work on my portal that I am in the midst of getting complete. not sure if anyone here plays BHD or is familiar with it, It is a shooter game made by Novalogic. BabStats does the coding for the aftermarket (if you will) stats, they call it chronos.

I have the chronos installed on my site at http://www.trdsquad.com/chronos

I have a block added to my blocks with the following inserted. include ("Stats/block-Server-Status.php");

in my portal Directory on my server I have a folder called Stats inside this folder I have a file called block-Server-Status.php .
This file contains the following <?

####################################################################################
# Block module for PHP-Nuke 7.0    #
# Chronos Babstats online status with scrolling members names and map images       #
#        #
# Versione: 1.0                                                                    #
# Sniperwolf~UA~ www.united-assassins.co.uk please edit if you need but mention me #
#                                                                                  #
####################################################################################

$dbhost     = "localhost"; // Database host
$dbname     = "xxxxxxxxx"; // Database name
$dbusername = "xxxxxxxxxxx"; // Database user name
$dbuserpw   = "xxxxxxx"; // Database password

$dbtable = "chronos_players"; // Change to the DB That holds the players

$content1 = "";
$time = time();
$offline = $time - 120;
$db = mysql_connect($dbhost, $dbusername, $dbuserpw) or die(mysql_error());
$dbi =mysql_select_db($dbname,$db) or die(mysql_error());
$sql = mysql_query("SELECT * FROM `chronos_servers` WHERE `time` > '$offline' ORDER BY name",$db);
$servernum = mysql_num_rows($sql);
if ($servernum >= 1) {

while($result = mysql_fetch_array($sql, $dbi)) {



$players = "";
$player_color = "";
$codemap = $result["map_name"];
$result["server_name"] = htmlspecialchars(base64_decode($result["server_name"]));
$result["map_name"] = htmlspecialchars(base64_decode($result["map_name"]));
$result[server_name] = ereg_replace('~[0-9]', '', $result[server_name]);
$result[map_name] = ereg_replace('~[0-9]', '', $result[map_name]);

if ($result["game_type"] == "Deathmatch") $game_type = "Deathmatch";
if ($result["game_type"] == "Team Deathmatch") $game_type = "Team Deathmatch";
if ($result["game_type"] == "Team King of the Hill") $game_type = "Team King of the Hill";
if ($result["game_type"] == "Search and Destroy") $game_type = "Search and Destroy";
if ($result["game_type"] == "Attack and Defend") $game_type = "Attack and Defend";
if ($result["game_type"] == "Capture the Flag") $game_type = "Capture the Flag";
if ($result["game_type"] == "Flagball") $game_type = "Flagball";



$player_names = explode("\n", $result["player_names"]);
$player_teams = explode("\n", $result["player_teams"]);
$playercount = 16;
for($i=0; $i < count($player_names); $i++) {
$player_name = htmlspecialchars(base64_decode($player_names[$i]));

$player_team = $player_teams[$i];
if ($player_team == "Blue") $player_color = "#1796CB";
if ($player_team == "Red") $player_color = "#E3553C";
if ($player_team == "Yellow") $player_color = "yellow";
if ($player_team == "Violet") $player_color = "violet";
if ($player_team == "Green") $player_color = "#44DD44";
if ($player_team == "None") $player_color = "#44DD44";
if ($player_name == "SYSOP =422=") {

$result[num_players]--;

} else {

$players .= "[<font color='".$player_color."'><b>".$player_name."</b></font>] ";

$playercount++;

}

}

if(!$bg) {

$bg = $bgcolor2;

} elseif ($bg == $bgcolor2) {

$bg = $bgcolor2;

} elseif ($bg == $bgcolor2) {

$bg = $bgcolor2;

}

$serverid = $result["id"];



$content1 .= "<center><a href='http://trdsquad.com/chronos/index.php?action=servers&id=$serverid'

class='special1'></a>" ;

$content1 .= "<img src='http://trdsquad.com/chronos/templates/online.gif' alt='Online.gif' title='Online'

border='0'><br>";

$content1 .= "<b>".$result["server_name"]."</b><br>";



$sql2 = mysql_query("select * from `chronos_maps` where name='$codemap'", $db); // Change 'Stats_maps' to Your DB Table

$result2 = mysql_fetch_array($sql2, $dbi);

if ($result2["image"] && $servernum < 3) {



$content1 .= "<a href='http://www.trdsquad.com/chronos/index.php?action=servers&id=$serverid' target='_blank'

class='special1'><img src='http://trdsquad.com/chronos/$result2[image]' alt='$result[map_name]'

title='$result[map_name]' width='125' height='94' border='0'></a><br>";
$content1 .= $result[map_name]."<br>";
}

else {

$content1 .= $result[map_name]."<br>";

}

$content1 .= "$game_type<br>";

$content1 .= $result[num_players]." of ".$result[max_players]."</a><br>";

if ($result["player_names"] && $playercount > 1) { // { && $servernum == 1

$content1 .= "<MARQUEE behavior='scroll' align='center' direction='left' width='180' height='12' scrollamount='2'

scrolldelay='1' onmouseover='this.stop()' onmouseout='this.start()'>"

."<b>Players Online:</b> $players"

."</MARQUEE>";

}

$content1 .= "</td></tr>";

}

}



if (!$content1) {
$content = "<br><center><a href='http://trdsquad.com/chronos'><img src='http://trdsquad.com/chronos/templates/offline.gif' alt='offline.gif' title='Offline' border='0'></a></center><br>";

} else {
$content = "<br>$content1<br>";
}
?>



of course where the  section that has

$dbhost     = "localhost"; // Database host
$dbname     = "xxxxxxxxx"; // Database name
$dbusername = "xxxxxxxxxxx"; // Database user name
$dbuserpw   = "xxxxxxx"; // Database password

in it I removed the x's and put in the proper information for my database.

when i send this through I get a box for the block as I should, however there is nothing in the box.

Attached is a Screenshot of what it looks like now, I know there are PHP Nuke sites that get this to work and I have adjusted it to get it to work all that I can see that would need it. The above coding is how it has been altered by me. I will attach the original PHP file for some genius here to look and see what else I might be able to do to get this to work. Or if someone else out there has a working block that works for this I would love to see how they did theirs.

Thanks in advance for any and all help...

[attachment deleted by admin]

gerrymo

I think its the path in your include that may be at fault. Try using the full URL in it, see if that helps.

BCB

#2
hhhhhhhmmmmmmmm,, well that would not make sense to me but I will try it. The reason it does not make sense is due to the fact that I have the teamspeak block in there and the code i have in my php box is  include ("teamspeak/ts_viewer.php");  and in that I did not have to put the full path.

But stranger things have happened. I will give it a shot.



EDITED PORTION

Still did not work even though i made it go to:  include ("http://trdsquad.com/Site/Stats/block-Server-Status.php");

IchBin

It's not the block itself, it is the script that is not working. First, make sure the script is working before you try it in a block. :) I click on the link to the status script and was given a blank page. I will see if I can see anything that may help.  Kind of hard for me to do when I get check to see if things work.

BCB

Yes I see what you mean about clicking on the page and it bringing up a dead page moreless. As you can see in the original coding it was made for a Module or block for PHP Nuke $content1 .= "<img src='modules/Chronos/templates/online.gif' alt='Online.gif' title='Online'


and I changed that to reflect the fact that I do not have mine in a module by setting it to $content1 .= "<img src='http://trdsquad.com/chronos/templates/online.gif' alt='Online.gif' title='Online'

and if i go to http://trdsquad.com/chronos/templates/online.gif i can see the image.


HHHMMM the plot thickens...

IchBin

Yes, but what about this.
http://trdsquad.com/chronos/templates/offline.gif :)
All you're doing is pointing to the image. It doesn't mean that the server is online or offline.

I'm not sure why the script isn't working. I'm assuming that it's not connecting to the Database. I looked at the code, and I don't see anything that jumps out at me that would not make it work. I'll keep looking though. Maybe someone else will see it before me.

BCB

#6
I see what your saying but when I go to http://trdsquad.com/chronos/index.php?action=servers it lists all the servers that I can usually go and if I click on the Green one it takes me to http://trdsquad.com/chronos/index.php?action=servers&id=1 and it shows me who is in the server but what I am wanting to do is make is so that we do not have to go through all that to see who is on the server.


Edited portion

The above contains the same Database info that I have put into the file for the block so it should be connecting.

IchBin

I think I see it!
$content1 .= "<center><a href='http://trdsquad.com/chronos/index.php?action=servers&id=$serverid'

class='special1'></a>" ;


Make that line look like this:
$content1 .= "<center><a href='http://trdsquad.com/chronos/index.php?action=servers&id='.$serverid.' class='special1'></a>" ;

BCB

well I tried that and still did not work. would I also need to change all of the  "  $serverid'  "  to   "  .$serverid.  " ?

Also is "  $serverid = $result["id"];"  is that where the $serverid' is being declared?  would that need to be changed also?

IchBin

I think the php is OK.

If you're code works fine by going to this link: http://trdsquad.com/chronos/index.php?action=servers&id=1

Cant you just include that with a php include (); ?