$version = str_replace(array("\t", "\n"), "", checkversion()); if ($version != $config['bot']['version']) { echo "[0;33mWarning![0m\nLatest version: [0;32m" . $version . "[0m\nYour version: [0;31m" . $config['bot']['version'] . "[0m\nWe recommend update\n\n"; } else { echo "[0;32mOK![0m - Version up to date\n\n"; } #Budowanie nowego obiektu $tsAdmin = new ts3admin($config['server']['ip'], $config['server']['queryport']); #Sprawdzanie połączenia z serwerem if ($tsAdmin->getElement('success', $tsAdmin->connect())) { #Logowanie się na użytkownika Query $tsAdmin->login($config['query']['login'], $config['query']['password']); #Wybieranie serwera $tsAdmin->selectServer($config['server']['port']); #Ustawianie nazwy bota $tsAdmin->setName($config['bot']['nickname']); #Przenoszenie bota do wybranego kanału $whoami = $tsAdmin->getElement('data', $tsAdmin->whoAmI()); $tsAdmin->clientMove($whoami['client_id'], $config['bot']['channel']); echo "Connection established!\n"; $clients['aktualnie'] = listaclientow(); $clients['record'] = str_replace(array("\t", "\n"), "", file_get_contents('tmp/userecord.txt')); #Pętla z funkcjami bota $i['petla'] = 0; $i['animacja'] = 0; $i['pingpong'] = 0; while ($i['petla'] != 1) { #Pętla wykonuje się co sekundę sleep(1); #Data wykonania pętli $datapetli = date('Y-m-d G:i:s');
<?php /** * * Ts-Islam * **/ require "lib/ts3admin.class.php"; include 'config.php'; $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($bot_nickname); $whoami = $tsAdmin->getElement('data', $tsAdmin->whoAmI()); $tsAdmin->clientMove($whoami['client_id'], $bot_move); while (1) { $serverInfo = $tsAdmin->getElement('data', $tsAdmin->serverInfo()); $clientsOnline = $serverInfo['virtualserver_clientsonline'] - $serverInfo['virtualserver_queryclientsonline']; if ($Channel == 1) { $tsAdmin->channelEdit($channel_id, array('channel_name' => $channel_name . ' ' . $clientsOnline)); } if ($Server == 1) { $tsAdmin->serverEdit(array('virtualserver_name' => $server_name . ' ' . $clientsOnline)); } sleep($sleep); } } else { echo "Connetcion Problem"; }
function tslink_update_groups($mybb_uid) { if (!isset($messages)) { $messages = []; } $messages[] = 'In the following part we gonna update the user his groups on the TS server.'; require __DIR__ . '/config.php'; // Connect to the database. $ConnectDB = new mysqli($hostname, $username, $password, $database); // check connection if ($ConnectDB->connect_errno) { die($ConnectDB->connect_error); } // Get the member from the mybb database. $getit = "SELECT * FROM {$table} WHERE uid = '{$mybb_uid}' LIMIT 1"; $messages['getit_query'] = $getit; $rows = $ConnectDB->query($getit); $row = $rows->fetch_array(MYSQLI_ASSOC); $messages['found_member'] = 'User ID: ' . $row['uid'] . ' Username: '******'username']; // Get the memberstatus from the user. $memberstatus = $row['memberstatus']; $messages['memberstatus'] = $memberstatus; // Let's determine which servergroup to use according to the status of the user. if ($memberstatus == '2') { $ServerGroupID_ToAdd = $ts3_sgid_vip_member; } elseif ($memberstatus == '1') { $ServerGroupID_ToAdd = $ts3_sgid_don_member; } else { $ServerGroupID_ToAdd = $ts3_sgid_member; } $messages['ServerGroupID_ToAdd'] = $ServerGroupID_ToAdd; // Get the user's unique id's from the mybb database $get_ts_uids = 'SELECT * FROM ' . TABLE_PREFIX . "tslink_uids WHERE uid = '{$mybb_uid}' "; $messages['get_ts_uids_query'] = $get_ts_uids; $ts_unique_ids = $ConnectDB->query($get_ts_uids); foreach ($ts_unique_ids as $ts_unique_id) { $messages['registered_ts_db_entries'][] = 'TS UID: ' . $ts_unique_id['ts_uid'] . ' TS CLDBID: ' . $ts_unique_id['ts_cldbid']; } $messages['groups_wont_be_removed'] = implode(',', $ts3_sgid_dont_remove); // Build a new ts3admin object. $ts3 = new ts3admin($ts3_server, $ts3_query_port); // Connect to the TS server. if ($ts3->getElement('success', $ts3->connect())) { $messages['ts_connection'] = 'Successful'; // Login to the TS server. if ($ts3->getElement('success', $ts3->login($ts3_username, $ts3_password))) { $messages['ts3_login'] = '******'; // Select virtual server. if ($ts3->getElement('success', $ts3->selectServer($ts3_server_port))) { $messages['ts3_virtual_server_select'] = 'Successful'; // Set displayed name in TS to given $ts3->setName($ts3_nickname); foreach ($ts_unique_ids as $ts_unique_id) { // First lets remove all groups the user is member of. // First get all servergroups the user is member of. $ClientServerGroups = $ts3->servergroupsbyclientid($ts_unique_id['ts_cldbid']); $csg = []; $c = 0; if (is_array($ClientServerGroups['data'])) { foreach ($ClientServerGroups['data'] as $ClientServerGroup) { $messages['found_groups']['CLDBID_' . $ts_unique_id['ts_cldbid']][] = 'sgid: ' . $ClientServerGroup['sgid'] . ' Name: ' . $ClientServerGroup['name']; } } // For every servergroup found, remove it. if (is_array($ClientServerGroups['data'])) { foreach ($ClientServerGroups['data'] as $Client_ServerGroup) { $csg[] = $Client_ServerGroup['sgid']; } } foreach ($csg as $ClientServerGroupID) { // Except for the servergroups we don't want to have removed. if (!in_array($ClientServerGroupID, $ts3_sgid_dont_remove)) { try { $messages['SGID_' . $ClientServerGroupID]['removing_from'][] = 'CLDBID: ' . $ts_unique_id['ts_cldbid']; $removeResults = $ts3->serverGroupDeleteClient($ClientServerGroupID, $ts_unique_id['ts_cldbid']); if ($removeResults['success']) { $messages['SGID_' . $ClientServerGroupID]['removing_from_result']['CLDBID_' . $ts_unique_id['ts_cldbid']] = 'Succes.'; } else { $messages['SGID_' . $ClientServerGroupID]['removing_from_result']['CLDBID_' . $ts_unique_id['ts_cldbid']] = $removeResults['errors']; } } catch (Exception $e) { // Catches the error(s) if any. But don't do anything with it. } } } $c++; try { // Add the user to the servergroup. $messages['SGID_' . $ServerGroupID_ToAdd]['adding_to'][] = 'CLDBID: ' . $ts_unique_id['ts_cldbid']; $serverGroupAddClientResults = $ts3->serverGroupAddClient($ServerGroupID_ToAdd, $ts_unique_id['ts_cldbid']); if ($serverGroupAddClientResults['success']) { $messages['SGID_' . $ServerGroupID_ToAdd]['adding_to_result']['CLDBID_' . $ts_unique_id['ts_cldbid']] = 'Succes.'; } else { $messages['SGID_' . $ServerGroupID_ToAdd]['adding_to_result']['CLDBID_' . $ts_unique_id['ts_cldbid']] = $serverGroupAddClientResults['errors']; } //$messages[$ServerGroupID_ToAdd]['adding_to_result'][] = $serverGroupAddClientResults; } catch (Exception $e) { // Catches the error(s) if any. But don't do anything with it. } } } else { echo '<p>Could not select the virtual server.</p> <p>Please check the TS server port in the config!</p> <p>Also make sure this (UDP) port is open in the outgoing firewall!</p>'; $messages['ts3_virtual_server_select'] = 'Could not select the virtual server.'; } } else { echo '<p>Could not login to the TS server.</p> <p>Please check the username and password in the config!</p>'; $messages['ts3_login'] = '******'; } } else { echo '<p>Connection to the TS server could not be established.</p> <p>Please check the TS server and TS server query port in the config!</p> <p>Also make sure this (TCP) port is open in the outgoing firewall!</p>'; $messages['ts3_connect'] = 'Connection to the TS server could not be established.'; } if (count($ts3->getDebugLog()) > 0) { $messages['ts3_add_remove_debuglog'] = $ts3->getDebugLog(); } // Close connection $ConnectDB->close(); return $messages; }
<?php require 'ts3admin.class.php'; require 'config.php'; $tsAdmin = new ts3admin($config['ip'], $config['query_port']); if ($tsAdmin->getElement('success', $tsAdmin->connect())) { $tsAdmin->login($config['login'], $config['password']); $tsAdmin->selectServer($config['port']); $tsAdmin->setName($config['name']); $poketimer = date('r'); #Pke function function poke() { global $config; global $tsAdmin; global $poketimer; #Zamiana listy grup na tablice $groups = explode(',', $config['group']); #Sprawdzenie czy można już wysłać poke if (date('r') > $poketimer) { #Sprawdzanie każdej grupy foreach ($groups as $temp_groups) { #Pobranie danych członków grupy $ids = $tsAdmin->serverGroupClientList($temp_groups, true); #Sprawdzenie każdego członka grupy foreach ($ids['data'] as $ids_temp) { #Pobranie nicku oraz spradzenie dostępności użytkownika $find = $tsAdmin->clientFind($ids_temp['client_nickname']); #Jeżeli znaleziono użytkownika if ($find['success'] == true) { foreach ($find['data'] as $find_temp) { #Wysyłanie poke
$botName = $configs['botName']; $channel_deafults = array("channel_flag_permanent" => 1, "channel_codec" => 4, "channel_codec_quality" => 6); $permissions_deafult = array("i_channel_needed_delete_power" => '75', "i_channel_needed_permission_modify_power" => '70'); $channel_info = array('0' => array('channel_name' => "[cspacer000] Channel Name", 'channel_topic' => "Throws on the Go"), '1' => array('channel_name' => "Channel 01", 'channel_topic' => "This is a sub-level channel"), '2' => array('channel_name' => "Channel 02", 'channel_topic' => "This is a sub-level channel"), '3' => array('channel_name' => "Channel 03", 'channel_topic' => "This is a sub-level channel")); /*-------TS3 Object-------*/ #Include ts3admin.class.php require "../vendor/autoload.php"; #build a new ts3admin object $tsAdmin = new ts3admin($ts3_ip, $ts3_queryport); if ($tsAdmin->getElement('success', $tsAdmin->connect())) { #login as serveradmin $tsAdmin->login($ts3_user, $ts3_pass); #select teamspeakserver $tsAdmin->selectServer($ts3_port); #set bot name $tsAdmin->setName($botName); #Create channel //Check that there is channel information to be used if (!empty($channel_info)) { //Loop through array to create each channel foreach ($channel_info as $key => $value) { //Merge custom channel information with default settings $merged_array = $value + $channel_deafults; // preserves keys //If first channel create Master-Parent channel if ($key == 0) { //Create Channel Function: Create channel + record channels CID for parenting $parent_id = createChannel($tsAdmin, $merged_array, $permissions_deafult); moveClients($tsAdmin, $parent_id); //Create sub-channels of Master-Parent channel } else {