The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Widget and side block.
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. Code:
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(); |
#2
|
||||
|
||||
Try replacing $output .= with return in the last line but one.
|
#3
|
|||
|
|||
That sort of works thanks i can now see it in the side bar but it also shows above the header as well this seems to be intermitment so might just be me but i had the sam problem with Firefox & IE.
So the end of the code now looks like. Code:
return ob_get_contents(); ob_end_clean(); Thanks again for helping me |
#4
|
||||
|
||||
Try this (all echo replaced with $output .= and removed then unnecessary output buffering):
PHP Code:
|
#5
|
|||
|
|||
Thats stoped the side bar and above the header issue but for some reason it will not update the players on the server.
When i done the edit and save it and went to the sideblock for the 1st time it showed 2 players on but it is still showing 2 players on even tho the server is empty ? the widget on the cms is updateing ok as that shows 0 players. |
#6
|
||||
|
||||
The forum blocks are cached. Try changing Cache Time (in minutes) setting to 0 for your block. But beware, that will run the query every single time a page is loaded.
|
#7
|
|||
|
|||
Thanks alot for your help that done the trick
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|