<?php
/*-------------------------------------------------------+
| PHP-Fusion Content Management System
| Copyright © 2002 - 2008 Nick Jones
| http://www.php-fusion.co.uk/
+--------------------------------------------------------+
| Ventrilo Viewer Infusion
| Filename: ventrilo_panel.php
| Author: Michal "An_Old_Man" Thomsen
| Author: Peter "Van_Dragen" Nielsen
| web: http://www.99.dk
| web: http://www.vandragen.dk
| email: admin@99.dk
| email: admin@vandragen.dk
|--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at www.gnu.org/licenses/agpl.html. Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
if (!defined("IN_FUSION"

) { die("Access Denied"

; }
require_once INFUSIONS."ventrilo_panel/infusion_db.php";
// Check if locale file is available matching the current locale setting.
if (file_exists(INFUSIONS."ventrilo_panel/locale/".$settings['locale'].".php"

) {
// Load the locale file matching the current site locale setting.
include INFUSIONS."ventrilo_panel/locale/".$settings['locale'].".php";
} else {
// Load the infusion's default locale file.
include INFUSIONS."ventrilo_panel/locale/English.php";
}
//-- Open Sidepanel
openside($locale['VNT300']);
// var $serverdata();
$data = dbarray(dbquery("SELECT * FROM ".DB_VENTRILO_TABLE." WHERE ventrilo_id='1'"

);
$server_ip = $data['server_ip'];
$query_port = $data['query_port'];
$info_lev = "#key#";
$feedok = $data['feed_on']; // If = 1, then feed is active
$feed_url = $data['feed_ip']; // feed url or ip and path
$kompat = $data['compatible']; // default 0, hvis 1 er ventrilo bagud kompatibel skal i admin og infusion
//til test for fejlmelding hvis intet er defineret
if (( $data['server_ip'] ) and ($data['query_port']) > NULL ) {
require_once("vent.inc.php"

;
If ($feedok=="1"

{
// ******* Start Feed section **************
ob_start(); // get content of page
readfile("http://".$feed_url."/ventrilo_feed.php"

;
$imdata = ob_get_contents();
ob_end_clean();
$vdata = explode($info_lev, $imdata);
// ******* End Feed section ***********
} else
{
// ******** Start Normal Info section ********
$vent = new Vent;
$vent->setTimeout( 300000 ); // 300 ms timeout
if ( $vent->makeRequest( 2, $server_ip,$query_port )) {
$vdata = explode("\x0a", $vent->getResponse());
}
// ******** End Normal Info section ********
}
$baseDir = INFUSIONS."ventrilo_panel/";
//////////////////////////////////////////////////////////////////////////////
$patt = array ( '/%E5/', '/%F8/', '/%E6/', '/%C6/', '/%D8/', '/%C5/', '/%2C/', '/%A4/', '/%25/', '/%3D/', '/%FC/', '/%DC/', '/%A3/', '/%BD/', '/%A7/', '/%80/'

; // ********** tabel skal i sql
$replpatt = array ( 'å','ø','æ', 'Æ', 'Ø', 'Å', ' ~', '¤', '%', '', 'ü', 'Ü', '£', '½', '§', '€'

; // ******************************** tabel skal i sql
$i = 0;
while ($i < count($vdata)) {
$vdata[$i] = preg_replace($patt, $replpatt, $vdata[$i]);
// echo $vdata[$i].'<br>';
$i++;
}
/////////////////////////////////////////////////////////////////////////////
function GetUsers($cid,$clientdata,$clientnum,$level,$data)
{
$oo = 0;
$baseDir = INFUSIONS."ventrilo_panel/";
while ($oo <= $clientnum) {
if ($cid == $clientdata[$oo]['CID']) {
echo "<img src=\"".$baseDir."images/b.gif\"width=\"".(12*$level)."\" height=\"1\" align=\"left\" border=\"0\" alt=\"\">";
echo "<img src=\"".$baseDir."images/user.gif\"width=\"12\" height=\"12\" align=\"left\" border=\"0\" alt=\"".$clientdata[$oo]['PING']."\">".$clientdata[$oo]['NAME'].' ';
if ( $data['info_admin'] ) {
if ($clientdata[$oo]['ADMIN']=="1"

{
$clientdata[$oo]['ADMIN']="\"A\""; // Ændrer ADMIN=1 til A
// }
echo $clientdata[$oo]['ADMIN'].' ';
// echo "Admin:".$clientdata[$oo]['ADMIN'].' ';
}
}
// echo "Ping:".$clientdata[$oo]['PING'].' ';
// echo "Admin:".$clientdata[$oo]['ADMIN'].' ';
// echo "Phan:".$clientdata[$oo]['PHAN'].' ';
// echo "Comm:".$clientdata[$oo]['COMM'].' ';
echo '<br>';
} //End if
$oo++;
} // End while
} // End function
function getSubChannel($channeldata,$pid,$channelcount,$level,$clientdata,$clientnum,$data)
{
$baseDir = INFUSIONS."ventrilo_panel/";
$c =0;
$level++;
while ($c <= $channelcount) { // løb alle kanaler igennem
//echo $pid." ".$channelcount.'<br>';
if ( $channeldata[$c]['PID'] == $pid ) { // check om kanal er en sub kanal
echo "<img src=\"".$baseDir."images/b.gif\"width=\"".(12*$level)."\" height=\"1\" align=\"left\" border=\"0\" alt=\"\">";
if ($channeldata[$c]['PROT']=="1"

{
echo "<img src=\"".$baseDir."images/channel_pw.png\"width=\"12\" height=\"12\" align=\"left\" border=\"0\" alt=\"\">";
} else {
echo "<img src=\"".$baseDir."images/channel.png\"width=\"12\" height=\"12\" align=\"left\" border=\"0\" alt=\"\">";
}
echo " ";
echo $channeldata[$c]['NAME'].'<br>';
echo GetUsers($channeldata[$c]['CID'],$clientdata,$clientnum,$level,$data);
echo getSubChannel($channeldata,$channeldata[$c]['CID'],$channelcount,$level,$clientdata,$clientnum,$data);
} // End if
$c++;
} // End while
return ($result);
} // End function
$o = 0;
while ($o <= count($vdata)) {
$oo = 0;
$ddata = explode(":", $vdata[$o]);
while ($oo <= count($ddata)) {
if ($ddata[$oo] == "CHANNELCOUNT"

{
$vdata['CHANNELCOUNT'] = $ddata[$oo+1];
$channelcount = $ddata[$oo+1];
$channum = $o+2;
}
if ($ddata[$oo] == "CLIENTCOUNT"

{
$vdata['CLIENTCOUNT'] = $ddata[$oo+1];
$clientnum = $o+2;
}
$oo++;
}
$o++;
}
// $serverdata = array();
$o = 0;
while ($o <= $channum-1) {
$ddata = explode(":", $vdata[$o]);
$serverdata[$ddata[0]]=$ddata[1];
$o++;
}
// end $serverdata
$o = $channum;
$tael = 0;
while ($o <= $clientnum-3) {
$oo = 0;
while ($oo <= 0) {
$tdata = explode(":", $vdata[$o]);
if (count($tdata) > 2 ) {
$ooo=2;
while ( count($tdata)> $ooo ) {
$tdata[1]=$tdata[1]."\x3a".$tdata[$ooo]; // add missing :
$ooo++;
}
}
$ooo = 0;
while ($ooo <= count($channelprop)) {
$channelprop = explode(",", $tdata[1]);
$channelraw[$tael]=$channelprop[$ooo];
$ooo++;
if ($channelraw[$tael] <> ''

$tael++;
}
$oo++;
}
$o++;
}
/////////////////////////////////////////////////////////////////
$o = 0;
$oo = 1;
while ($o <= count($channelraw)) {
$channeltmp = explode("=", $channelraw[$o]);
$channeltmp[0] = trim($channeltmp[0]);
$channeldata[$oo][$channeltmp[0]] = $channeltmp[1];
if ( $kompat == "1" ) { if ($channeltmp[0] == 'NAME'

$oo++;
} else {
if ($channeltmp[0] == 'COMM'

$oo++;
}
$o++;
}
////////////////////////////////////////////////////////////////////
// definition of default-channel
$channeldata[0]['CID'] = "0";
$channeldata[0]['PID'] = "0";
$channeldata[0]['PROT'] = "0";
$channeldata[0]['NAME'] = $serverdata['NAME'];
$channeldata[0]['COMM'] = "";
$o = $clientnum; // <- starter ved
$tael = 0;
while ($o <= $clientnum+$vdata['CLIENTCOUNT']) {
$oo = 0;
while ($oo <= 0) {
$tdata = explode(":", $vdata[$o]);
if (count($tdata) > 2 ) {
$oooo=2;
while ( count($tdata)> $oooo ) {
$tdata[1]=$tdata[1]."\x3a".$tdata[$oooo]; // adding missing :
$oooo++;
}
}
$ooo = 0;
while ($ooo <= count($clientprop)) {
$clientprop = explode(",", $tdata[1]);
$clientraw[$tael]=$clientprop[$ooo];
$ooo++;
if ($clientraw[$tael] <> ''

$tael++;
}
$oo++;
}
$o++;
}
/////////////////////////////////////////////////////////////
$o = 0;
$oo = 1;
while ($o <= count($clientraw)) {
$clienttmp = explode("=", $clientraw[$o]);
$clienttmp[0] = trim($clienttmp[0]);
$clientdata[$oo][$clienttmp[0]] = $clienttmp[1];
if ( $kompat == "1" ) { if ($clienttmp[0] == 'NAME'

$oo++;
} else {
if ($clienttmp[0] == 'COMM'

$oo++;
}
$o++;
}
//////////////////////////////////////////////////////////////
if ( count($serverdata) > 3 ){
$o = 0;
$oo = 1;
while ($o <= $serverdata['CHANNELCOUNT']) { // løb alle kanaler igennem
if ( $channeldata[$o]['PID'] == "0" ) { // check om kanal er en sub kanal
if ( $channeldata[$o]['CID'] == "0" ) { // check om kanal er en sub kanal
// Debug echo $subchannel[$oo]." ".$oo." ServerNavn: $channeldata[$o]['NAME']." (PID: ".$channeldata[$o]['PID'].", CID: ".$channeldata[$o]['CID']." )".'<br>';
echo "<img src=\"".$baseDir."images/main.gif\"width=\"12\" height=\"12\" align=\"left\" border=\"0\" alt=\"\">".$channeldata[$o]['NAME'].'<br>';
echo GetUsers($channeldata[$o]['CID'],$clientdata,$clientnum,0,$data);
} else {
if ($channeldata[$o]['PROT']=="1"

{
echo "<img src=\"".$baseDir."images/channel_pw.png\"width=\"12\" height=\"12\" align=\"left\" border=\"0\" alt=\"\">";
} else {
echo "<img src=\"".$baseDir."images/channel.png\"width=\"12\" height=\"12\" align=\"left\" border=\"0\" alt=\"\">";
}
// Debug: echo "KanalNavn: ".$channeldata[$o]['NAME']." (PID: ".$channeldata[$o]['PID'].", CID: ".$channeldata[$o]['CID']." )".'<br>';
echo $channeldata[$o]['NAME'].'<br>';
echo GetUsers($channeldata[$o]['CID'],$clientdata,$clientnum,0,$data);
// Kald af funktion getSubChannel($channeldata,KanalID,Kanalantal,Level);
echo getSubChannel($channeldata,$channeldata[$o]['CID'],$serverdata['CHANNELCOUNT'],0,$clientdata,$clientnum,$data);
// debug echo '<br>';
}
}
$o++;
}
echo "<img src=\"".$baseDir."images/userson.gif\"width=\"13\" height=\"13\" align=\"left\" border=\"0\" alt=\"\">";
echo ($vdata['CLIENTCOUNT']);
echo " /";
echo ($serverdata['MAXCLIENTS']);
// Do NOT change our copyright
echo "<br>2007 © <a href=\"mailto:admin@99.dk\">[>>99<<]</a>";
}
if ( count($serverdata) < 3 ) {
echo "<b>".$locale['VNT401'] . $query_port."</b>";
echo "<br>2007 © <a href=\"mailto:admin@99.dk\">[>>99<<]</a>";
}
//til test for fejlmelding hvis intet er defineret
} else {
echo $locale['VNT400'];
echo "<br>2007 © <a href=\"mailto:admin@99.dk\">[>>99<<]</a>";
}
//--- Close Sidepanel
closeside();
?>