access bot

Norvik

Retired Staff
Contributor
Jul 18, 2015
635
588
157
Simply remove the require part and add in the missing variables... that shouldn't be that har.
 

xator

Member
May 3, 2016
58
30
53
here is the config file
Code:
<?php 

//Teamspeak Config
$ts3['ip'] = '127.0.0.1';
$ts3['queryport'] = '10011';
$ts3['port'] = '9987';
$ts3['user'] = 'serveradmin';
$ts3['pass'] = 'password';
$ts3['displayname'] = "[BOT]AutBadge";
?>
 

Umar

Member
Jun 18, 2016
65
8
40
i dont know whats wrong with this one, anyone can explain ? this script always say "you are not vip"
PHP:
<?php defined('BASEPATH') OR exit('No direct script access allowed');
require('../ts3/inc/config.php');
require('../ts3/inc/ts3admin.class.php');
ini_set("register_globals","On");
function getIP()
{
    foreach (array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR') as $key)
    {
        if (array_key_exists($key, $_SERVER) === true)
        {
            foreach (array_map('trim', explode(',', $_SERVER[$key])) as $ip)
            {
                if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false)
                {
                    return $ip;
                }
            }
        }
    }
}

        $tsAdmin = new ts3admin($ts3['ip'], $ts3['queryport']);
    if($tsAdmin->getElement('success', $tsAdmin->connect())) {
        $tsAdmin->login($ts3['user'], $ts3['pass']);
        $tsAdmin->selectServer($ts3['port']);
        $tsAdmin->setName($ts3['displayname']);
        $clients = $tsAdmin->clientList("-ip -uid -groups");
                  
        foreach($clients['data'] as $client) {
                if($client['connection_client_ip'] == getIP()) {
                $userid = $client['client_database_id'];
                $username = $client['client_nickname'];
                $servergroups = $client['client_servergroups'];          
            }
        }
      
        if(!empty($userid)) {
            echo "Please join our Teamspeak";
        } else {
            global $servergroups;
            if(strpos($servergroups, 24607) ) {    //The 10 is the servergroup
                $isMember = true;
            }
        }
    
            global $isMember;
        if ($isMember) {
           echo " you are vip";//do whatever you wanna do if the user is in the group
        } else {
            echo "you are not vip";//do whatever you wanna do if the user is not in the group
    }
    }else {
        echo "Cant connect ts";
    }
    ?>
can u give me the config.php ?
 

Umar

Member
Jun 18, 2016
65
8
40
Man its always say i am not vip

PHP:
require('ts3admin/src/ts3admin.class.php');
function getIP()
{
    foreach (array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR') as $key)
    {
        if (array_key_exists($key, $_SERVER) === true)
        {
            foreach (array_map('trim', explode(',', $_SERVER[$key])) as $ip)
            {
                if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false)
                {
                    return $ip;
                }
            }
        }
    }
}

    $tsAdmin = new ts3admin($ts3['ip'], $ts3['queryport']);
    $tsAdmin->login($ts3['user'], $ts3['pass']);
    $tsAdmin->selectServer($ts3['port']);
 
    $clients = $tsAdmin->clientList("-ip -groups");
                 
        foreach($clients['data'] as $client) {
            if($client['connection_client_ip'] == getIP()) {
                $username = $client['client_nickname'];
                $servergroups = $client['client_servergroups'];
            }
        }
     
        if(!empty($username)) {
            echo "Please join our Teamspeak";
        } else {
            if(strpos($servergroups, 9)) { //The 10 is the servergroup
                $isMember = true;
            }
        }
     
        if ($isMember) {
           echo " you are vip"; //do whatever you wanna do if the user is in the group
        } else {
           echo "you are not vip"; //do whatever you wanna do if the user is not in the group
        }
what is the problem ??
 

xator

Member
May 3, 2016
58
30
53
i dont know whats wrong with this one, anyone can explain ? this script always say "you are not vip"
PHP:
<?php defined('BASEPATH') OR exit('No direct script access allowed');
require('../ts3/inc/config.php');
require('../ts3/inc/ts3admin.class.php');
ini_set("register_globals","On");
function getIP()
{
    foreach (array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR') as $key)
    {
        if (array_key_exists($key, $_SERVER) === true)
        {
            foreach (array_map('trim', explode(',', $_SERVER[$key])) as $ip)
            {
                if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false)
                {
                    return $ip;
                }
            }
        }
    }
}

        $tsAdmin = new ts3admin($ts3['ip'], $ts3['queryport']);
    if($tsAdmin->getElement('success', $tsAdmin->connect())) {
        $tsAdmin->login($ts3['user'], $ts3['pass']);
        $tsAdmin->selectServer($ts3['port']);
        $tsAdmin->setName($ts3['displayname']);
        $clients = $tsAdmin->clientList("-ip -uid -groups");
                  
        foreach($clients['data'] as $client) {
                if($client['connection_client_ip'] == getIP()) {
                $userid = $client['client_database_id'];
                $username = $client['client_nickname'];
                $servergroups = $client['client_servergroups'];          
            }
        }
      
        if(!empty($userid)) {
            echo "Please join our Teamspeak";
        } else {
            global $servergroups;
            if(strpos($servergroups, 24607) ) {    //The 10 is the servergroup
                $isMember = true;
            }
        }
    
            global $isMember;
        if ($isMember) {
           echo " you are vip";//do whatever you wanna do if the user is in the group
        } else {
            echo "you are not vip";//do whatever you wanna do if the user is not in the group
    }
    }else {
        echo "Cant connect ts";
    }
    ?>
yes i told you "i dont know whats wrong with this one, anyone can explain ? this script always say "you are not vip"" thats why i posted my code here so we can find the problem :)
 

Norvik

Retired Staff
Contributor
Jul 18, 2015
635
588
157
So I found my issue and I decided to create a working version. Place the ts3admin.class.php file into the same folder than this script and it should work. At least is did work on my test server.

PHP:
<?php
require('ts3admin.class.php');

//###################  Config  #####################

$cfg['tsIP'] = "127.0.0.1";
$cfg['tsQueryport'] = "10011";
$cfg['tsPort'] = "9000";
$cfg['tsLogin'] = "serveradmin";
$cfg['tsPassword'] = "Xvu7qqDY";
$cfg['tsName'] = "R4P3 Bot";

//##################################################

function getIP()
{
    foreach (array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR') as $key)
    {
        if (array_key_exists($key, $_SERVER) === true)
        {
            foreach (array_map('trim', explode(',', $_SERVER[$key])) as $ip)
            {
                if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false)
                {
                    return $ip;
                }
            }
        }
    }
}

$tsAdmin = new ts3admin($cfg['tsIP'], $cfg['tsQueryport']);
if($tsAdmin->getElement('success', $tsAdmin->connect())) {
    $tsAdmin->login($cfg['tsLogin'], $cfg['tsPassword']);
    $tsAdmin->selectServer($cfg['tsPort']);
    $tsAdmin->setName($cfg['tsName']);
   
    $clients = $tsAdmin->clientList("-ip -groups");

        foreach($clients['data'] as $client) {
            if($client['connection_client_ip'] == getIP()) {
                $username = $client['client_nickname'];
                $servergroups = explode(",", $client['client_servergroups']);
            }
        }
        $isMember = false;
        if(empty($username)) {
            echo "Please join our Teamspeak<br />";
        } else {
            foreach($servergroups as $servergroup){
                if($servergroup == 19){ //The 10 is the servergroup
                    $isMember = true;
                }
            }
        }
     
        if(!empty($username)){
            if ($isMember) {
                echo "He is a member";//do whatever you wanna do if the user is in the group
            } else {
                echo "You are no member";//do whatever you wanna do if the user is not in the group
            }
        }
}
?>
 

Ibo

Member
Oct 20, 2015
94
39
53
So I found my issue and I decided to create a working version. Place the ts3admin.class.php file into the same folder than this script and it should work. At least is did work on my test server.

PHP:
<?php
require('ts3admin.class.php');

//###################  Config  #####################

$cfg['tsIP'] = "127.0.0.1";
$cfg['tsQueryport'] = "10011";
$cfg['tsPort'] = "9000";
$cfg['tsLogin'] = "serveradmin";
$cfg['tsPassword'] = "Xvu7qqDY";
$cfg['tsName'] = "R4P3 Bot";

//##################################################

function getIP()
{
    foreach (array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR') as $key)
    {
        if (array_key_exists($key, $_SERVER) === true)
        {
            foreach (array_map('trim', explode(',', $_SERVER[$key])) as $ip)
            {
                if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false)
                {
                    return $ip;
                }
            }
        }
    }
}

$tsAdmin = new ts3admin($cfg['tsIP'], $cfg['tsQueryport']);
if($tsAdmin->getElement('success', $tsAdmin->connect())) {
    $tsAdmin->login($cfg['tsLogin'], $cfg['tsPassword']);
    $tsAdmin->selectServer($cfg['tsPort']);
    $tsAdmin->setName($cfg['tsName']);
 
    $clients = $tsAdmin->clientList("-ip -groups");

        foreach($clients['data'] as $client) {
            if($client['connection_client_ip'] == getIP()) {
                $username = $client['client_nickname'];
                $servergroups = explode(",", $client['client_servergroups']);
            }
        }
        $isMember = false;
        if(empty($username)) {
            echo "Please join our Teamspeak<br />";
        } else {
            foreach($servergroups as $servergroup){
                if($servergroup == 19){ //The 10 is the servergroup
                    $isMember = true;
                }
            }
        }
   
        if(!empty($username)){
            if ($isMember) {
                echo "He is a member";//do whatever you wanna do if the user is in the group
            } else {
                echo "You are no member";//do whatever you wanna do if the user is not in the group
            }
        }
}
?>
works perfectly <3
 

Umar

Member
Jun 18, 2016
65
8
40
there is the problem in the script
if i join the page and i have two users in the server one vip and one are not vip
then i cant join the page and its say you are no member
can anyone make it if i join with 2 users i will go to another page says
you join with 2 users

sorry for my bad english :)
 
Last edited:
Top