Important alert: (current site time 7/15/2013 10:57:41 AM EDT)
 

VB icon

A "Just The Names" script.

Email
Submitted on: 5/3/2010 8:32:07 AM
By: Vince Hahn  
Level: Intermediate
User Rating: Unrated
Compatibility: PHP 5.0
Views: 4727
author picture
(About the author)
 
     InstantVentrilo.com has a service in conjunction with their server hosting: embedded javascript server status. Well for those whom use godaddy and/or cannot use fsockopen() in Php, I've found a way to get raw data (names) from the output code using the copy(), explode(), and array_search().
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
//**************************************
// Name: A "Just The Names" script.
// Description:InstantVentrilo.com has a service in conjunction with their server hosting: embedded javascript server status. Well for those whom use godaddy and/or cannot use fsockopen() in Php, I've found a way to get raw data (names) from the output code using the copy(), explode(), and array_search().
// By: Vince Hahn
//
// Inputs:There are no inputs.
//
// Returns:Does not return anything, but it does send a formatted list to the output buffer (as I use it). More on that in the explanations.
//
// Assumes:For one: this code assumes that you are using output buffering. If not or you don't know how, it's as simple as putting ob_start() in the beginning of your script and ob_flush() at the very end. This script is used as an include as is, but can be altered to work inline. This code is nearly exactly what I use on my site, with the addition of variables on server details (ip/port) and removal of a few site-specific extras.
//
// Side Effects:If the instantventrilo.com status script is broken or if your server is down this may have some unexpected results, possibly fatal errors crashing the entire script, more likely ugly output.
//
//This code is copyrighted and has// limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=2771&lngWId=8//for details.//**************************************

<?php
	ob_start();
	// source URL
	$ip = "127.0.0.1"; // your server's ip or address (ventrilo.something.com or ourventrilo.info or whatever)
	$port = "1234"; // your server's port number
	$vsc = "http://view.light-speed.com/ventrilo.php?IP=$ip&PORT=$port&CHANNEL_WNOUSER=YES&FONTSIZE=10&CONLINK=YES&HELP=YES&WIDTH=700&BGCOLOR=000000&STYLE=2&SHOW_IP_PORT=YES&SN_BGCOLOR=000000&SN_COLOR=FFFFFF&INFO_BGCOLOR=000000&INFO_COLOR=FFFFFF&HELP_BGCOLOR=000000&HELP_COLOR=FFFFFF&CHANNEL_BGCOLOR=000000&CHANNEL_COLOR=FFFFFF&UN=FFFFFF&UN_BG=000000&METHOD=js";
	// copy source url output into a text file (*.sgt ["Serkerim Guild Temporary-File"] format)
	copy($vsc,"vent_temporary_v2.sgt");
	// copy and decode temp file data, erase temp file, one-line double command.
	$tfData = urldecode(file_get_contents("vent_temporary_v2.sgt"));
	unlink("vent_temporary_v2.sgt");
	// replace </div> with </div><!-- splitter --> to form explosion point (array delimiter)
	$tfData = str_replace("</div>","</div><!-- splitter -->",$tfData);
	// explode into array
	$tfArray = explode("<!-- splitter -->",$tfData);
	// we're working with the array now, $tfData should be unset to limit overhead
	unset($tfData);
	// pop last element off array, it's got nothing useful in it
	array_pop($tfArray);
	// remove the javascript from element 1 [0]
	$tfArray[0] = str_replace("document.write(unescape(\"","",$tfArray[0]);
	// strip tags from each array element and trim the remainder
	// set unwanted words/elements (usually room names and/or ip address info
	// ***THESE ARE THE ACTUAL THINGS I LIST FOR REMOVAL IN MY SCRIPT*** ---replace with your own room names, the second to last array element should be your server's name/title. You can add as many elements as you want, however.
	$remove = array(
		"Medium Officers",
		"High Officers",
		"Officers",
		"High Council",
		"Debate",
		"Provided by InstantVentrilo.com",
		"Serkerim Guild Server",
		"IP: $ip    PORT: $port"
	);
	while (list($key,$val) = each($tfArray)) {
		$val = trim(strip_tags($val));
		foreach ($remove as $r) {
			$val = str_replace("$r","",$val);
		}
		reset($remove);
		$tfArray[$key] = $val;
	}
	reset($tfArray);
	while (list($key,$val) = each($tfArray)) {
		if ($val == "") {
			unset($tfArray[$key]);
		}
	}
	$usercount = count($tfArray);
	$tablayer = "\t\t\t\t\t\t\t\t";
	$lineend = "\r\n";
	echo "$tablayer<div style=\"text-align: center; font-weight: bold; font-size: 1.25em; text-decoration: underline;\">Ventrilo Status</div>$lineend";
	foreach ($tfArray as $user) {
		echo "$tablayer<div>$user</div>$lineend";
	}
	echo "$tablayer<div style=\"text-align: center; font-size: 8pt; font-style: italic;\">$usercount Online</span></div>$lineend";
	echo "$tablayer<div style=\"font-size: 8pt;\">$ip<br />Port $port</div>$lineend";
	unset($tfArray);
	ob_flush();
?>


Other 2 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.