Login  |  Register
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome, Guest. Please login or register.
Did you miss your activation email?

August 19, 2022, 09:13:14 PM

Login with username, password and session length
Members
  • Total Members: 3843
  • Latest: Tricky
Stats
  • Total Posts: 193479
  • Total Topics: 21088
  • Online today: 60
  • Online ever: 1035
  • (November 26, 2020, 04:45:12 AM)
Users Online
Users: 0
Guests: 51
Total: 51

Author Topic: Block Code for BHD Server Status  (Read 17568 times)

0 Members and 1 Guest are viewing this topic.

BCB

  • Guest
Block Code for BHD Server Status
« on: March 15, 2006, 08:21:05 AM »
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.
Code: [Select]
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
Code: [Select]
<?

####################################################################################
# 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
 
Code: [Select]
$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

  • Guest
Re: Block Code for BHD Server Status
« Reply #1 on: March 15, 2006, 08:43:44 AM »
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

  • Guest
Re: Block Code for BHD Server Status
« Reply #2 on: March 15, 2006, 09:49:42 AM »
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");
« Last Edit: March 15, 2006, 09:52:24 AM by BCB »

Offline IchBin

  • Friends
  • *
  • Posts: 16231
Re: Block Code for BHD Server Status
« Reply #3 on: March 15, 2006, 10:13:45 AM »
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

  • Guest
Re: Block Code for BHD Server Status
« Reply #4 on: March 15, 2006, 10:36:29 AM »
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
Code: [Select]
$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
Code: [Select]
$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...

Offline IchBin

  • Friends
  • *
  • Posts: 16231
Re: Block Code for BHD Server Status
« Reply #5 on: March 15, 2006, 11:07:15 AM »
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

  • Guest
Re: Block Code for BHD Server Status
« Reply #6 on: March 15, 2006, 11:16:58 AM »
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.
« Last Edit: March 15, 2006, 11:19:15 AM by BCB »

Offline IchBin

  • Friends
  • *
  • Posts: 16231
Re: Block Code for BHD Server Status
« Reply #7 on: March 15, 2006, 02:28:32 PM »
I think I see it!
Code: [Select]
$content1 .= "<center><a href='http://trdsquad.com/chronos/index.php?action=servers&id=$serverid'

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

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

BCB

  • Guest
Re: Block Code for BHD Server Status
« Reply #8 on: March 16, 2006, 06:59:25 AM »
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?

Offline IchBin

  • Friends
  • *
  • Posts: 16231
Re: Block Code for BHD Server Status
« Reply #9 on: March 16, 2006, 07:12:37 AM »
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 (); ?