Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 12-02-2008, 03:36 PM
StilleVande StilleVande is offline
 
Join Date: Nov 2006
Posts: 3
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Trying to add another section Below "Who's Online"

I run a gameserver, and I have some php code that checks the server status. Here is the code if youd like to see it:

Code:
<?php

# function: nwserver_status
# Returns the server status in an array
# If the server does not respond with the expected hex string, 
# it returns an error message (which is not an array).


function nwserver_status($serveraddr, $port="5121", $timeout=5) {
	$connect = fsockopen( "udp://" . $serveraddr, $port, $errno, $errstr, $timeout );
	$error = NULL;
	if ( ! $connect )    {
	    $error = "server down";
	    return $error;
	} else {
	    socket_set_timeout( $connect, $timeout );
	    $send = "\xFE\xFD\x00\xE0\xEB\x2D\x0E\x14\x01\x0B\x01\x05\x08\x0A\x33\x34\x35\x13\x04\x36\x37\x38\x39\x14\x3A\x3B\x3C\x3D\x00\x00";
	    fwrite( $connect, $send );
	    $output = fread( $connect, 5000 );
	    if ( ! $output ) {
            $error = "no reply";
	    } else {
            $statusarray = explode( "\x00", $output );
            if (count($statusarray) < 6) { // if the array has < 6 elements, we're referencing a non-existing element
                $error = "bad reply";
            }
	    }
	}
	fclose( $connect );
	if ($error == NULL) {
		return $statusarray;
	} else {
		return $error;
	}
}

# php script to get the server status and player list

// gets server status directly from the gameserver

$serveraddr = "xxx.xxx.xxx.xxx";
// $server_down is displayed if the script can't connect 
// or if it receives no data from the server
$server_down = "<p class=\"highlight\">The server is down - now what are you gonna do?</p>\n";


$status = nwserver_status($serveraddr);
if (!is_array($status)) { // if an error message was returned
	print ($status);
} else {
    // format serverstatus array
	// $status[11] is the port used, $status[5] the number of players online
	// $status[6] the maximum number of players allowed
    print( "Server Address: <strong>$serveraddr:$status[11]</strong><br />\n" );
    print( "Server Status: <strong>Online</strong><br />\n" );
    print( "Players: <strong>$status[5]</strong> / <strong>$status[6]</strong><br />\n" );
}

?>
Id like to add it between "Who's Online" and the "Statistics" section on the bottom of the forums, but I cant figure it out.

I know it deals with making a plugin, but I dont know what to hook it off of for it to be there.

In the end, Id like to have it fire off and give the feedback, essentially looking like this:
Quote:
Server Address: xxx.xxx.xxx.xxx:5121
Server Status: Online
Players: 0 / 12
Any help would be highly appreciated.
Reply With Quote
  #2  
Old 12-02-2008, 04:16 PM
SEOvB's Avatar
SEOvB SEOvB is offline
 
Join Date: May 2007
Location: Indianapolis
Posts: 2,451
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

<a href="http://www.vbulletin.com/docs/html/main/templates_externalfiles" target="_blank">http://www.vbulletin.com/docs/html/m..._externalfiles</a>
Reply With Quote
  #3  
Old 12-02-2008, 08:15 PM
StilleVande StilleVande is offline
 
Join Date: Nov 2006
Posts: 3
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks tons my friend.

Worked like a charm.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:58 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03615 seconds
  • Memory Usage 2,182KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (3)post_thanks_box
  • (3)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (3)post_thanks_postbit_info
  • (3)postbit
  • (3)postbit_onlinestatus
  • (3)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • 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_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete