Warning This code is very poor in some ways. I'm not a professional coder at all just hack and play till i get it working.
firstly you need to use this in conjunction with
http://www.ventrilo.com/dlprod.php?id=201
PHP Code:
<?php
include "ventrilostatus.php";
include "ventriloinfo_ex1.php";
include "ventrilodisplay_ex1.php";
include "ventrilodisplay_ex2.php";
$filename = '/home/vowgamin/public_html/vent/ventrilo_status';
$current_timestamp=mktime(date("H"), date("i"), 0, date("m"), date("d"), date("Y"));
function toArray($data) {
if (is_object($data)) $data = get_object_vars($data);
return is_array($data) ? array_map(__FUNCTION__, $data) : $data;
}
function myTruncate($string, $limit, $break=".", $pad="...")
{
// return with no change if string is shorter than $limit
if(strlen($string) <= $limit) return $string;
// is $break present between $limit and the end of the string?
if(false !== ($breakpoint = strpos($string, $break, $limit))) {
if($breakpoint < strlen($string) - 1) {
$string = substr($string, 0, $breakpoint);
}
}
return $string;
}
$stat = new CVentriloStatus;
$stat->m_cmdprog = "/home/vowgamin/public_html/vent/ventrilo_status"; // Adjust accordingly.
$stat->m_cmdcode = "2"; // Detail mode.
$stat->m_cmdhost = "Vent server address"; // Assume ventrilo server on same machine.
$stat->m_cmdport = "port"; // Port to be statused.
$stat->m_cmdpass = ""; // Status password if necessary.
$rc = $stat->Request();
$data = toArray($stat);
// This code truncates the user names removing anything after the _ key
$i=0;
while (list($key, $val) = each($data[m_clientlist]))
{
$users[$i][name]=myTruncate($val[m_name],1, "_");
$users[$i][chan]=myTruncate($val[m_cid],1, "_");
$i=$i+1;
}
$i=0;
foreach ($users as $value) {
// the following checks ventrilo channel name if it is not the parent channel get the parent channel name
foreach ($data[m_channellist] as $k => $v)
{
if ($users[$i][chan] == $v[m_cid])
{
if ($v[m_pid] == 0)
{
$users[$i][chananme]=$v[m_name];
}
else
{
$chan2=$v[m_pid];
foreach ($data[m_channellist] as $j => $b)
{
if ($chan2 == $b[m_cid]) $users[$i][chananme]=$b[m_name];
}
}
}
}
$i=$i+1;
}
// connect to the database and pull out all the data assigning it to the forum array for searching latter
$link = mysql_connect('localhost', '********', '**********');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("vowgamin_Vbulletin", $link);
$query = "SELECT * FROM user";
$result = mysql_query($query) or die(mysql_error());
$i=0;
while($row = mysql_fetch_array($result)){
$forum[$i]['username']=$row['username'];
$forum[$i]['xperience']=$row['xperience'];
$forum[$i]['userid']=$row['userid'];
$forum[$i]['usergroupid']=$row['usergroupid'];
$i=$i+1;
}
$size= 0;
$size2= 0;
$size = sizeof($users); // set the size of the upcoming for loops
$size2 = sizeof($forum);
// go through all users on the vent server looking for a case insensitive match
for ($h = 0; $h <= $size; $h++)
{
for ($i = 0; $i <= $size2; $i++)
{
if (strcasecmp($users[$h]['name'], $forum[$i]['username']) == 0)
{
$m[$h]['username'] =$forum[$i]['username'];
$m[$h]['xperience'] =$forum[$i]['xperience'];
$m[$h]['channame'] =$users[$h]['chananme'];
$m[$h]['userid'] =$forum[$i]['userid'];
$m[$h]['usergroupid'] =$forum[$i]['usergroupid'];
}
if ($users[$h]['name']=="Match")
{
$match=4; // the multiplier for clan matches
$chan=$users[$h][chananme]; // record the channel name down where match bot is located
}
}
}
$array=array_filter($m);
$size3= sizeof($array);
for ($j = 0; $j <= $size3; $j++)
{
$points=3; // default points per cron job
$message= "Ventrilo Participation";
$experience = $array[$j]['xperience'];
$userid = $array[$j]['userid'];
// Check to see if the match bot is in the chanel and change message plus points
if ($array[$j][channame] == $chan)
{
$message="Ventrilo Clan Match Participation";
$points=5*$match;
}
// adjust points to 1 for users sitting in afk channel
if ($array[$j][channame] == "AFK")
{
$points=1;
$message="AFK user";
}
if ($array[$j][channame] == "Members Lounge")
{
$points=2;
$message="Members Lounge Ventrilo";
}
if ($array[$j][channame] == "Sulk Room")
{
$points=-20;
$message="Members Lounge Ventrilo";
}
// adjust points for boot camp users to stop them ranking up to quick
if ($array[$j]['usergroupid'] == "55")
{
$points=1;
$message="Boot Camp User";
}
// check to make sure a user exists then enter data into the database
if ($userid)
{
$query2 = "INSERT INTO xperience_custompoints (userid, points_misc_custom, adminid, comment, dateline) VALUES ( $userid, $points , 1, '$message', $current_timestamp)";
//echo $query2."<br />";
mysql_query($query2);
}
}
mysql_close($link);
You will need to add your own server and port for ventrilo setup and change the ***** to your details for the database.
I have also hard coded this for the names of our vent channels and have included a check to see if a user match bot is part of the channel if it is increase the points
This script is run by a cron job every 15 mins and it adds points to the custom point table. (This is becoming an issue as the table is getting quite large)