View Single Post
  #1  
Old 12-29-2009, 08:57 AM
jaffaman jaffaman is offline
 
Join Date: Nov 2004
Posts: 153
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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();
Thanks in advance for any help
Attached Images
File Type: png block.png (23.3 KB, 0 views)
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01160 seconds
  • Memory Usage 1,818KB
  • Queries Executed 12 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_attachment
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete