Thread: Major Additions - vBExperience 4
View Single Post
  #2285  
Old 02-14-2012, 11:52 AM
Vowgaming Vowgaming is offline
 
Join Date: Jan 2011
Posts: 18
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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"), 0date("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($string0$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;
    }

$size0;
$size20;
$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);

$size3sizeof($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)
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01214 seconds
  • Memory Usage 1,888KB
  • Queries Executed 11 (?)
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_php
  • (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_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_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete