jaffaman
12-29-2009, 08:57 AM
I have aske over at vbulletin.com but i thought i would ask here as well.
I have got a cms php widget working on a test site with the code below but when i try and make a side forums block the code does not work even tho i have got a html block working ok.
I do not know how 2 code so i thought i would ask if anyone cold help please as i am looking at putting our site live soon and want to get tings sorted before i do the upgrade.
Here's the working widget code for our BHD server status.
ob_start();
$dbhost = "localhost"; // Database host
$dbname = "******"; // Database name
$dbusername = "******"; // Database user name
$dbuserpw = "******"; // Database password
$link_id = mysql_connect($dbhost,$dbusername,$dbuserpw)
or die("Could not connect to MySQL.");
$selected = mysql_select_db($dbname,$link_id) or die("Could not select database");
$result = mysql_query("SELECT name, server_name, map_name, game_type, dedicated, time, max_players, num_players, player_names, player_teams
FROM chronos_servers ORDER BY max_players DESC");
$onlinex = 0;
while ($row = mysql_fetch_row($result)) {
$name = $row[0];
$sname = htmlspecialchars(base64_decode($row[1]));
$max = $row[6];
$map = htmlspecialchars(base64_decode($row[2]));
$mapname = $row[2];
$dedi = $row[4];
$type = $row[3];
$num = $row[7];
$sertime = $row[5];
$players = $row[8];
$teams = $row[9];
$status = $row[12];
$curtime = time();
$tdiff = $curtime - $sertime;
if ($tdiff < 120) {
$onlinex = 1;
$result1 = mysql_query("SELECT name, thumbnail, game_type, id FROM chronos_maps WHERE name = '$mapname' AND game_type = '$type' ");
while ($row2 = mysql_fetch_array($result1)) {
$mtn = $row2[1];
$mpid = $row2[3];
}
switch($result["age"]) {
case -1: $status = "<font color='red'>Loading Map"; break;
case -2: $status = "<font color='yellow'>Waiting for Players"; break;
case -4: $status = "<font color='blue'>Scoring Map"; break;
default: $status = "<font color='green'>Hosting Map";
}
$url = "<a href='http://www.csa-squad.co.uk/index.php?page=bhdserverstatus'BORDER=0 >";
$url2 = "<a href='http://lobby.sigurd-project.com/server-383.xml'BORDER=0 target=\"_blank\">";
echo "<CENTER>$name</CENTER>";
echo "<CENTER><img src='http://www.csa-squad.co.uk/Neos_Chronos/serverstatus/img/online.gif'></CENTER>";
echo "<CENTER>$type</CENTER>";
echo "<CENTER>$map</CENTER><P>";
echo "$url<CENTER><img src='http://www.csa-squad.co.uk/Neos_Chronos/$mtn'></a></CENTER><br>";
echo "<CENTER>I.P = 85.236.103.11</CENTER>";
echo "<CENTER>PORT 17479</CENTER>";
echo "<CENTER>Players : $num/$max</CENTER>";
if(strlen($players) > 0) {
$PlayStr = explode("\n", $players);
$TeamStr = explode("\n", $teams);
echo "<CENTER><marquee scrollamount='2' width='150'>";
for($i = 0; $i < count($PlayStr); $i++) {
if($TeamStr[$i] == "None") echo "[<font color=\"Green\">";
if($TeamStr[$i] == "Red") echo "[<font color=\"Red\">";
if($TeamStr[$i] == "Blue") echo "[<font color=\"Blue\">";
echo base64_decode($PlayStr[$i])."</font>] ";
}
echo "</marquee></center>";
}
echo "$url2<CENTER><img src='http://www.csa-squad.co.uk/Neos_Chronos/serverstatus/sigurdstatus.gif'></a></CENTER><br>";
echo "<center><a href=\"http://www.babstats.com\" target=\"_blank\">Babstats</a></center>";
//echo "Status:$status<br />";
echo "<CENTER>_____________</CENTER>";
}
}
if ($onlinex == 0) {
echo "<CENTER>! CsA Tryouts</CENTER>";
echo "<CENTER><img src='http://www.csa-squad.co.uk/Neos_Chronos/serverstatus/img/offline.gif'></CENTER>";
echo "<center><a href=\"http://www.babstats.com\" target=\"_blank\">Babstats</a></center>";
//echo "Status:$status<br />";
echo "<CENTER>_____________</CENTER>";
}
$output .= ob_get_contents();
ob_end_clean();
Thanks in advance for any help :)
I have got a cms php widget working on a test site with the code below but when i try and make a side forums block the code does not work even tho i have got a html block working ok.
I do not know how 2 code so i thought i would ask if anyone cold help please as i am looking at putting our site live soon and want to get tings sorted before i do the upgrade.
Here's the working widget code for our BHD server status.
ob_start();
$dbhost = "localhost"; // Database host
$dbname = "******"; // Database name
$dbusername = "******"; // Database user name
$dbuserpw = "******"; // Database password
$link_id = mysql_connect($dbhost,$dbusername,$dbuserpw)
or die("Could not connect to MySQL.");
$selected = mysql_select_db($dbname,$link_id) or die("Could not select database");
$result = mysql_query("SELECT name, server_name, map_name, game_type, dedicated, time, max_players, num_players, player_names, player_teams
FROM chronos_servers ORDER BY max_players DESC");
$onlinex = 0;
while ($row = mysql_fetch_row($result)) {
$name = $row[0];
$sname = htmlspecialchars(base64_decode($row[1]));
$max = $row[6];
$map = htmlspecialchars(base64_decode($row[2]));
$mapname = $row[2];
$dedi = $row[4];
$type = $row[3];
$num = $row[7];
$sertime = $row[5];
$players = $row[8];
$teams = $row[9];
$status = $row[12];
$curtime = time();
$tdiff = $curtime - $sertime;
if ($tdiff < 120) {
$onlinex = 1;
$result1 = mysql_query("SELECT name, thumbnail, game_type, id FROM chronos_maps WHERE name = '$mapname' AND game_type = '$type' ");
while ($row2 = mysql_fetch_array($result1)) {
$mtn = $row2[1];
$mpid = $row2[3];
}
switch($result["age"]) {
case -1: $status = "<font color='red'>Loading Map"; break;
case -2: $status = "<font color='yellow'>Waiting for Players"; break;
case -4: $status = "<font color='blue'>Scoring Map"; break;
default: $status = "<font color='green'>Hosting Map";
}
$url = "<a href='http://www.csa-squad.co.uk/index.php?page=bhdserverstatus'BORDER=0 >";
$url2 = "<a href='http://lobby.sigurd-project.com/server-383.xml'BORDER=0 target=\"_blank\">";
echo "<CENTER>$name</CENTER>";
echo "<CENTER><img src='http://www.csa-squad.co.uk/Neos_Chronos/serverstatus/img/online.gif'></CENTER>";
echo "<CENTER>$type</CENTER>";
echo "<CENTER>$map</CENTER><P>";
echo "$url<CENTER><img src='http://www.csa-squad.co.uk/Neos_Chronos/$mtn'></a></CENTER><br>";
echo "<CENTER>I.P = 85.236.103.11</CENTER>";
echo "<CENTER>PORT 17479</CENTER>";
echo "<CENTER>Players : $num/$max</CENTER>";
if(strlen($players) > 0) {
$PlayStr = explode("\n", $players);
$TeamStr = explode("\n", $teams);
echo "<CENTER><marquee scrollamount='2' width='150'>";
for($i = 0; $i < count($PlayStr); $i++) {
if($TeamStr[$i] == "None") echo "[<font color=\"Green\">";
if($TeamStr[$i] == "Red") echo "[<font color=\"Red\">";
if($TeamStr[$i] == "Blue") echo "[<font color=\"Blue\">";
echo base64_decode($PlayStr[$i])."</font>] ";
}
echo "</marquee></center>";
}
echo "$url2<CENTER><img src='http://www.csa-squad.co.uk/Neos_Chronos/serverstatus/sigurdstatus.gif'></a></CENTER><br>";
echo "<center><a href=\"http://www.babstats.com\" target=\"_blank\">Babstats</a></center>";
//echo "Status:$status<br />";
echo "<CENTER>_____________</CENTER>";
}
}
if ($onlinex == 0) {
echo "<CENTER>! CsA Tryouts</CENTER>";
echo "<CENTER><img src='http://www.csa-squad.co.uk/Neos_Chronos/serverstatus/img/offline.gif'></CENTER>";
echo "<center><a href=\"http://www.babstats.com\" target=\"_blank\">Babstats</a></center>";
//echo "Status:$status<br />";
echo "<CENTER>_____________</CENTER>";
}
$output .= ob_get_contents();
ob_end_clean();
Thanks in advance for any help :)