After doing hours of searching and attempting to recode several scripts, I have finally got a working ventrilo status block working! I did not code this myself, I merely edited it so that it would work.
<?
####################################################################
# This file is Copyright (c) 2005 Scott Benson #
# #
# Please submit changes, suggestions to #
# scott@sbhostingsolutions.com #
# #
# Modified by Vlorn vlornmail@vlornsworld.com #
# December 2006 #
# Modified by C.Arnott cameron@ecn.net.au #
# March 2007 #
####################################################################
define ("NAME", "NAME");
define ("CHANNEL", "CHANNEL");
define ("CLIENT", "CLIENT");
define ("SERVER", "SERVER");
define ("PID", "PID");
define ("CID", "CID");
$chanvar[1]=" ";
$value[1]=" ";
$content=" ";
$ventip = "lead.typefrag.com";
$ventport = "43982";
$ventpass = "reedgud";
$enable_graphics = "0";
$enable_link = "1";
$username_color = "#869927"; // set color of username, use color name or Hex value, use "" for default style.css value
$show_comments = "0"; // show user comments "1" enables, "0" disables
$comment_color = "#808080"; // user comment color, use color name or Hex value, use "" for default style.css value
$graphics['1']['SERVER']= "<img src=images/ventserver.png align=middle>";
$graphics['1']['CLIENT']= "<img src=images/ventclient.png align=middle>";
$graphics['1']['CHANNEL']= "<img src=images/ventchannel.png align=middle>";
###################################################################
#
# No changes should be needed below here
#
##################################################################
$vent_info = "http://ns2.sbhost.net/ventstatus.php?detail=2&ip=".$ventip."&port=".$ventport."&pass=".$ventpass;
$lines = file($vent_info);
$channels[] = 0;
$settings['CHANNEL'][0]['CID'] = "0";
$settings['CHANNEL'][0]['NAME'] = " Lobby";
$settings['CHANNEL'][0]['PID'] = "0";
foreach ($lines as $line) {
if ( $line == " " ) {
next($line); # Ignore blankline
} else {
$line = rtrim($line); # Get rid of newline characters
$line = ltrim($line); # Get rid of any leading spaces
$value = preg_split("/\s*:\s*/", $line, 2); # split by ":" and removing blank space either side of it.
if (($value[0] == "CHANNEL") or ($value[0] == "CLIENT")) {
$vars = preg_split("/\s*,\s*/", $value[1]);
foreach ($vars as $var) {
$chanvar = preg_split("/\s*=\s*/", $var);
if ($value[0] == "CHANNEL") {
if ($chanvar[0] == "CID") {
$channels[] = $chanvar[1];
$id = $chanvar[1];
}
if ($chanvar[0] == "PID") {
$subchans[$id][] = $chanvar[1];
}
} elseif ($value[0] == "CLIENT") {
if ($chanvar[0] == "CID") {
$clients[] = $chanvar[1];
$id = $chanvar[1];
}
}
$settings[$value[0]][$id][$chanvar[0]] = $chanvar[1];
$key="";
}
} else {
$settings[$value[0]] = $value[1]; # Create a new array with all the values.
}
}
}
$serverpic = $graphics[$enable_graphics][SERVER];
$clientpic = $graphics[$enable_graphics][CLIENT];
$channelpic = $graphics[$enable_graphics][CHANNEL];
$content .= "<b><center>".$serverpic.$settings[NAME]."</center></b><br>\n";
foreach ($channels as $channel) {
$pid = $settings['CHANNEL'][$channel]['PID'];
$cid = $settings['CHANNEL'][$channel]['CID'];
if ($pid == "0"){
$chaname = $settings['CHANNEL'][$channel]['NAME'];
$content .= "<b>".$channelpic.$chaname."</b><br />\n";
foreach ($clients as $client) {
$current = $settings['CLIENT'][$client]['CID'];
if ($current == $channel) {
$name = $settings['CLIENT'][$client]['NAME'];
$comment = $settings['CLIENT'][$client]['COMM'];
if (ltrim($name) !== "")
{
$content .= "<font color=".$username_color.">>".$clientpic."$name</font><br />";
}
}
}
foreach ($channels as $channel) {
$pid2 = $settings['CHANNEL'][$channel]['PID'];
$cid2 = $settings['CHANNEL'][$channel]['CID'];
if ($cid == "0"){}
elseif ($pid2 == $cid) {
$chaname = $settings['CHANNEL'][$channel]['NAME'];
$content .= "<b>-".$channelpic.$chaname."</b><br />\n";
if ($clients) {
foreach ($clients as $client) {
$current = $settings['CLIENT'][$client]['CID'];
if ($current == $channel) {
$name = $settings['CLIENT'][$client]['NAME'];
$comment = $settings['CLIENT'][$client]['COMM'];
if (ltrim($name) !== "")
{
$content .= "<font color=".$username_color."> >".$clientpic."$name</font><br />";
}
}
}
}
}
}
}
}
if ($enable_link == "1") {
$content .= "<center><a href=\"ventrilo://".$ventip.":".$ventport."/servername=".$settings[NAME]."\">Connect</a></center><br>\n";
}
if ($use_as_page != "no"){
print "$content\n";
}
?>
Enjoy!
Edit: working example: http://www.lexdysia.com (http://www.lexdysia.com)
Edit2: When I posted this, I was really tired and my code was sloppy. I cleaned up the code, and tweaked it a bit. few real changes were made, just mostly cosmetic stuff.
Well done Vouksh and thanks for sharing :)
Hi Vouksh,
Welcome to TinyPortal.
Not that your block code isn't nice but I wish you had asked here before going to all the trouble. ;)
Personally speaking, I don't like the idea of having a "connect link" to launch an external application like that. I personally use another application called nanospy (link is at http://www.nanospy.de/) to show the server status without having to launch another external application. It allows you to select from either a light backgroud or a dark background and shows the server status immediately.
I have it setup on 2 of my test sites, 1 for SMF 1.1.x (dark background) and the other on SMF 2.0 RC2 (light background). You can see what it looks like, at least for now, on those test sites by clicking the appropriate link below. The blocks are in the top left panel on both.
SMF 1.1.x/TP 1.0 beta 4 ~ http://talesofthehavenexpanse.com/smf1test/index.php
SMF 2.0 RC2/TP 1.0 beta 5 (not yet released) ~ http://talesofthehavenexpanse.com/smf2test/index.php
ZarPrime
Edit: Actually the information on how to use nanospy is located in another one of our block Code snippet topics --> http://www.tinyportal.net/index.php?topic=24407.0
quick bump. I edited the code to be more clear. my script primarily just grabs information from a website. my webhost doesn't support running applications inside the root of the webspace, so I had to use a different method.
And, as for your suggestion, the nanospy doesn't support typefrag (my vent host), and the status applet that typefrag supports is flash-based and looks horrible. My aim was to have a block that meshes with the rest of the site and doesn't stick out like a sore thumb. This is merely a viable alternative to those who are like me and have aesthetics in mind when building a website =)
site: http://forgotten-soldiers.com/index.php
SMF 2.0 RC3
Tiny Portal 1.0 beta 5.2
I just set this up on my site and I notice that when there are 3 users in one channel it is displaying one name for all three users...
So it would look like I am in vent 3 times over and no one else is!
All I have changed was to add my vent ip/port/password
anyone else using this and have it working? (the working example link listed is dead or non existent site now)