release 1.2.10
This commit is contained in:
43
install.php
43
install.php
@@ -111,8 +111,7 @@ $db[\'pass\']=\''.$pass.'\';
|
||||
$db[\'dbname\']=\''.$dbname.'\';
|
||||
?>';
|
||||
|
||||
$handle=fopen('./other/dbconfig.php','w');
|
||||
if(!fwrite($handle,$newconfig)) {
|
||||
if(!is_writable('./other/dbconfig.php')) {
|
||||
$err_msg = $lang['isntwicfg'];
|
||||
$err_lvl = 2;
|
||||
} else {
|
||||
@@ -147,7 +146,7 @@ $db[\'dbname\']=\''.$dbname.'\';
|
||||
$count++;
|
||||
}
|
||||
|
||||
if($mysqlcon->exec("CREATE TABLE `$dbname`.`config` (`webuser` varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci,`webpass` varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci,`tshost` varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci,`tsquery` smallint(5) UNSIGNED NOT NULL default '0',`tsvoice` smallint(5) UNSIGNED NOT NULL default '0',`tsuser` varchar(30) CHARACTER SET utf8 COLLATE utf8_unicode_ci,`tspass` varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci,`language` char(2) CHARACTER SET utf8 COLLATE utf8_unicode_ci,`queryname` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,`queryname2` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,`grouptime` varchar(5000) CHARACTER SET utf8 COLLATE utf8_unicode_ci,`resetbydbchange` tinyint(1) NOT NULL default '0',`msgtouser` tinyint(1) NOT NULL default '0',`currvers` varchar(32) CHARACTER SET utf8 COLLATE utf8_unicode_ci,`substridle` tinyint(1) NOT NULL default '0',`exceptuuid` varchar(999) CHARACTER SET utf8 COLLATE utf8_unicode_ci,`exceptgroup` varchar(999) CHARACTER SET utf8 COLLATE utf8_unicode_ci,`dateformat` varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci,`showexcld` tinyint(1) NOT NULL default '0',`showcolcld` tinyint(1) NOT NULL default '0',`showcoluuid` tinyint(1) NOT NULL default '0',`showcoldbid` tinyint(1) NOT NULL default '0',`showcolot` tinyint(1) NOT NULL default '0',`showcolit` tinyint(1) NOT NULL default '0',`showcolat` tinyint(1) NOT NULL default '0',`showcolnx` tinyint(1) NOT NULL default '0',`showcolsg` tinyint(1) NOT NULL default '0',`showcolrg` tinyint(1) NOT NULL default '0',`showcolls` tinyint(1) NOT NULL default '0',`slowmode` mediumint(9) NOT NULL default '0',`cleanclients` tinyint(1) NOT NULL default '0',`cleanperiod` mediumint(9) NOT NULL default '0',`showhighest` tinyint(1) NOT NULL default '0',`boost` varchar(999) CHARACTER SET utf8 COLLATE utf8_unicode_ci,`showcolas` tinyint(1) NOT NULL default '0',`defchid` int(10) NOT NULL default '0',`timezone` varchar(35) CHARACTER SET utf8 COLLATE utf8_unicode_ci,`logpath` varchar(200) CHARACTER SET utf8 COLLATE utf8_unicode_ci,`advancemode` tinyint(1) NOT NULL default '0',`count_access` tinyint(2) NOT NULL default '0',`last_access` bigint(11) NOT NULL default '0',`ignoreidle` smallint(5) NOT NULL default '0',`exceptcid` varchar(999) CHARACTER SET utf8 COLLATE utf8_unicode_ci,`rankupmsg` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,`boost_mode` tinyint(1) NOT NULL default '0',`newversion` varchar(25) CHARACTER SET utf8 COLLATE utf8_unicode_ci,`servernews` varchar(5000) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,`adminuuid` varchar(500) CHARACTER SET utf8 COLLATE utf8_unicode_ci,`nextupinfo` tinyint(1) NOT NULL default '0',`nextupinfomsg1` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,`nextupinfomsg2` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,`nextupinfomsg3` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,`shownav` tinyint(1) NOT NULL default '0',`showgrpsince` tinyint(1) NOT NULL default '0',`resetexcept` tinyint(1) NOT NULL default '0',`upchannel` varchar(20) NOT NULL default '0',`avatar_delay` smallint(5) UNSIGNED NOT NULL default '0',`registercid` mediumint(8) UNSIGNED NOT NULL default '0',`iphash` tinyint(1) NOT NULL default '0')") === false) {
|
||||
if($mysqlcon->exec("CREATE TABLE `$dbname`.`config` (`webuser` varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci,`webpass` varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci,`tshost` varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci,`tsquery` smallint(5) UNSIGNED NOT NULL default '0',`tsvoice` smallint(5) UNSIGNED NOT NULL default '0',`tsuser` varchar(30) CHARACTER SET utf8 COLLATE utf8_unicode_ci,`tspass` varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci,`language` char(2) CHARACTER SET utf8 COLLATE utf8_unicode_ci,`queryname` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,`queryname2` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,`grouptime` varchar(5000) CHARACTER SET utf8 COLLATE utf8_unicode_ci,`resetbydbchange` tinyint(1) NOT NULL default '0',`msgtouser` tinyint(1) NOT NULL default '0',`currvers` varchar(32) CHARACTER SET utf8 COLLATE utf8_unicode_ci,`substridle` tinyint(1) NOT NULL default '0',`exceptuuid` varchar(999) CHARACTER SET utf8 COLLATE utf8_unicode_ci,`exceptgroup` varchar(999) CHARACTER SET utf8 COLLATE utf8_unicode_ci,`dateformat` varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci,`showexcld` tinyint(1) NOT NULL default '0',`showcolcld` tinyint(1) NOT NULL default '0',`showcoluuid` tinyint(1) NOT NULL default '0',`showcoldbid` tinyint(1) NOT NULL default '0',`showcolot` tinyint(1) NOT NULL default '0',`showcolit` tinyint(1) NOT NULL default '0',`showcolat` tinyint(1) NOT NULL default '0',`showcolnx` tinyint(1) NOT NULL default '0',`showcolsg` tinyint(1) NOT NULL default '0',`showcolrg` tinyint(1) NOT NULL default '0',`showcolls` tinyint(1) NOT NULL default '0',`slowmode` mediumint(9) NOT NULL default '0',`cleanclients` tinyint(1) NOT NULL default '0',`cleanperiod` mediumint(9) NOT NULL default '0',`showhighest` tinyint(1) NOT NULL default '0',`boost` varchar(999) CHARACTER SET utf8 COLLATE utf8_unicode_ci,`showcolas` tinyint(1) NOT NULL default '0',`defchid` int(10) NOT NULL default '0',`timezone` varchar(35) CHARACTER SET utf8 COLLATE utf8_unicode_ci,`logpath` varchar(200) CHARACTER SET utf8 COLLATE utf8_unicode_ci,`advancemode` tinyint(1) NOT NULL default '0',`count_access` tinyint(2) NOT NULL default '0',`last_access` bigint(11) NOT NULL default '0',`ignoreidle` smallint(5) NOT NULL default '0',`exceptcid` varchar(999) CHARACTER SET utf8 COLLATE utf8_unicode_ci,`rankupmsg` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,`boost_mode` tinyint(1) NOT NULL default '0',`newversion` varchar(25) CHARACTER SET utf8 COLLATE utf8_unicode_ci,`servernews` varchar(5000) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,`adminuuid` varchar(500) CHARACTER SET utf8 COLLATE utf8_unicode_ci,`nextupinfo` tinyint(1) NOT NULL default '0',`nextupinfomsg1` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,`nextupinfomsg2` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,`nextupinfomsg3` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,`shownav` tinyint(1) NOT NULL default '0',`showgrpsince` tinyint(1) NOT NULL default '0',`resetexcept` tinyint(1) NOT NULL default '0',`upchannel` varchar(20) NOT NULL default '0',`avatar_delay` smallint(5) UNSIGNED NOT NULL default '0',`registercid` mediumint(8) UNSIGNED NOT NULL default '0',`iphash` tinyint(1) NOT NULL default '0',`tsencrypt` tinyint(1) NOT NULL default '0')") === false) {
|
||||
$err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode()." ".print_r($mysqlcon->errorInfo(), true).'<br>'; $err_lvl = 2;
|
||||
$count++;
|
||||
}
|
||||
@@ -236,13 +235,19 @@ $db[\'dbname\']=\''.$dbname.'\';
|
||||
$err_msg .= $lang['isntwidbmsg'].$mysqlcon->errorCode()." ".print_r($mysqlcon->errorInfo(), true).'<br>'; $err_lvl = 2;
|
||||
$count++;
|
||||
}
|
||||
|
||||
|
||||
if($count == 1) {
|
||||
$err_msg = sprintf($lang['instdbsuc'], $dbname); $err_lvl = NULL;
|
||||
$install_webuser = 1;
|
||||
|
||||
$dbconfig = fopen('./other/dbconfig.php','w');
|
||||
if(!fwrite($dbconfig, $newconfig)) {
|
||||
$err_msg = $lang['isntwicfg'];
|
||||
$err_lvl = 2;
|
||||
}
|
||||
fclose($dbconfig);
|
||||
}
|
||||
}
|
||||
fclose($handle);
|
||||
}
|
||||
|
||||
if (isset($_POST['install'])) {
|
||||
@@ -297,7 +302,7 @@ if(isset($_POST['confweb'])) {
|
||||
$pass=password_hash($_POST['pass'], PASSWORD_DEFAULT);
|
||||
$logpath = addslashes(__DIR__."/logs/");
|
||||
$dbname = $db['dbname'];
|
||||
$dbserver = $db['dbtype'].':host='.$db['dbhost'].'; dbname=`'.$db['dbname'].'`;charset=utf8mb4';
|
||||
$dbserver = $db['type'].':host='.$db['host'].'; dbname=`'.$db['dbname'].'`;charset=utf8mb4';
|
||||
$dbserver2 = $db['type'].':host='.$db['host'];
|
||||
try {
|
||||
$mysqlcon = new PDO($dbserver, $db['user'], $db['pass']);
|
||||
@@ -314,7 +319,7 @@ if(isset($_POST['confweb'])) {
|
||||
$nextupinfomsg3 = $mysqlcon->quote("You are excepted from the Ranksystem. If you wish to rank contact an admin on the TS3 server.");
|
||||
$servernews = $mysqlcon->quote("<strong>Message</strong><br>This is an example Message.<br>Change this Message inside the webinterface.");
|
||||
$rankupmsg = $mysqlcon->quote('Hey, you reached a higher rank, since you already connected for %1$s days, %2$s hours and %3$s minutes to our TS3 server.[B]Keep it up![/B] ;-) ');
|
||||
if($mysqlcon->exec("INSERT INTO `$dbname`.`config` (`webuser`,`webpass`,`tshost`,`tsquery`,`tsvoice`,`tsuser`,`language`,`queryname`,`queryname2`,`grouptime`,`resetbydbchange`,`msgtouser`,`currvers`,`exceptuuid`,`exceptgroup`,`dateformat`,`showexcld`,`showcolcld`,`showcoluuid`,`showcoldbid`,`showcolot`,`showcolit`,`showcolat`,`showcolnx`,`showcolsg`,`showcolrg`,`showcolls`,`slowmode`,`cleanclients`,`cleanperiod`,`showhighest`,`showcolas`,`defchid`,`timezone`,`logpath`,`ignoreidle`,`rankupmsg`,`newversion`,`servernews`,`nextupinfo`,`nextupinfomsg1`,`nextupinfomsg2`,`nextupinfomsg3`,`shownav`,`showgrpsince`,`resetexcept`,`upchannel`,`avatar_delay`,`iphash`) VALUES ('$user','$pass','localhost','10011','9987','serveradmin','en','Ranksystem','RankSystem','31536000=>47,31536060=>50','1','1','1.2.9','xrTKhT/HDl4ea0WoFDQH2zOpmKg=','2,6','%a days, %h hours, %i mins, %s secs','1','1','1','1','1','1','1','1','1','1','1','0','1','86400','1','1','0','Europe/Berlin','$logpath','600',$rankupmsg,'1.2.9',$servernews,'1',$nextupinfomsg1,$nextupinfomsg2,$nextupinfomsg3,'1','1','0','version','0','0')") === false) {
|
||||
if($mysqlcon->exec("INSERT INTO `$dbname`.`config` (`webuser`,`webpass`,`tshost`,`tsquery`,`tsvoice`,`tsuser`,`language`,`queryname`,`queryname2`,`grouptime`,`resetbydbchange`,`msgtouser`,`currvers`,`exceptuuid`,`exceptgroup`,`dateformat`,`showexcld`,`showcolcld`,`showcoluuid`,`showcoldbid`,`showcolot`,`showcolit`,`showcolat`,`showcolnx`,`showcolsg`,`showcolrg`,`showcolls`,`slowmode`,`cleanclients`,`cleanperiod`,`showhighest`,`showcolas`,`defchid`,`timezone`,`logpath`,`ignoreidle`,`rankupmsg`,`newversion`,`servernews`,`nextupinfo`,`nextupinfomsg1`,`nextupinfomsg2`,`nextupinfomsg3`,`shownav`,`showgrpsince`,`resetexcept`,`upchannel`,`avatar_delay`,`iphash`) VALUES ('$user','$pass','localhost','10011','9987','serveradmin','en','Ranksystem','RankSystem','31536000=>47,31536060=>50','1','1','1.2.10','xrTKhT/HDl4ea0WoFDQH2zOpmKg=','2,6','%a days, %h hours, %i mins, %s secs','1','1','1','1','1','1','1','1','1','1','1','0','1','86400','1','1','0','Europe/Berlin','$logpath','600',$rankupmsg,'1.2.10',$servernews,'1',$nextupinfomsg1,$nextupinfomsg2,$nextupinfomsg3,'1','1','0','version','0','0','0')") === false) {
|
||||
$err_msg = $lang['isntwidbmsg'].$mysqlcon->errorCode()." ".print_r($mysqlcon->errorInfo(), true); $err_lvl = 2;
|
||||
} else {
|
||||
$err_msg = $lang['isntwiusr'].'<br><br>';
|
||||
@@ -336,41 +341,41 @@ if (!isset($_POST['install']) && !isset($_POST['confweb'])) {
|
||||
$err_msg = sprintf($lang['winav10'], $host,'</a>!<br>', '<br>'); $err_lvl = 2;
|
||||
}
|
||||
if(!is_writeable('./other/dbconfig.php')) {
|
||||
unset($err_msg); $err_msg .= "<br>".$lang['isntwicfg']; $err_lvl = 3;
|
||||
unset($err_msg); $err_msg = $lang['isntwicfg']; $err_lvl = 3;
|
||||
}
|
||||
if(substr(sprintf('%o', fileperms('./avatars/')), -4)!='0777') {
|
||||
unset($err_msg); $err_msg .= "<br>".sprintf($lang['isntwichm'],"avatars"); $err_lvl = 3;
|
||||
unset($err_msg); $err_msg = sprintf($lang['isntwichm'],"avatars"); $err_lvl = 3;
|
||||
}
|
||||
if(substr(sprintf('%o', fileperms('./tsicons/')), -4)!='0777') {
|
||||
unset($err_msg); $err_msg .= "<br>".sprintf($lang['isntwichm'],"tsicons"); $err_lvl = 3;
|
||||
unset($err_msg); $err_msg = sprintf($lang['isntwichm'],"tsicons"); $err_lvl = 3;
|
||||
}
|
||||
if(substr(sprintf('%o', fileperms('./logs/')), -4)!='0777') {
|
||||
unset($err_msg); $err_msg .= "<br>".sprintf($lang['isntwichm'],"logs"); $err_lvl = 3;
|
||||
unset($err_msg); $err_msg = sprintf($lang['isntwichm'],"logs"); $err_lvl = 3;
|
||||
}
|
||||
if(substr(sprintf('%o', fileperms('./update/')), -4)!='0777') {
|
||||
unset($err_msg); $err_msg .= "<br>".sprintf($lang['isntwichm'],"update"); $err_lvl = 3;
|
||||
unset($err_msg); $err_msg = sprintf($lang['isntwichm'],"update"); $err_lvl = 3;
|
||||
}
|
||||
if(!class_exists('PDO')) {
|
||||
unset($err_msg); $err_msg .= "<br>".$lang['insterr2']; $err_lvl = 3;
|
||||
unset($err_msg); $err_msg = $lang['insterr2']; $err_lvl = 3;
|
||||
}
|
||||
if(!function_exists('exec')) {
|
||||
unset($err_msg); $err_msg .= "<br>".$lang['insterr3']; $err_lvl = 3;
|
||||
unset($err_msg); $err_msg = $lang['insterr3']; $err_lvl = 3;
|
||||
}
|
||||
if(version_compare(phpversion(), '5.5.0', '<')) {
|
||||
unset($err_msg); $err_msg .= "<br>".sprintf($lang['insterr4'],phpversion()); $err_lvl = 3;
|
||||
unset($err_msg); $err_msg = sprintf($lang['insterr4'],phpversion()); $err_lvl = 3;
|
||||
}
|
||||
if(!function_exists('simplexml_load_file')) {
|
||||
unset($err_msg); $err_msg .= "<br>".$lang['insterr5']; $err_lvl = 3;
|
||||
unset($err_msg); $err_msg = $lang['insterr5']; $err_lvl = 3;
|
||||
}
|
||||
if(!in_array('curl', get_loaded_extensions())) {
|
||||
unset($err_msg); $err_msg .= "<br>".$lang['insterr6']; $err_lvl = 3;
|
||||
unset($err_msg); $err_msg = $lang['insterr6']; $err_lvl = 3;
|
||||
}
|
||||
if(!in_array('zip', get_loaded_extensions())) {
|
||||
unset($err_msg); $err_msg .= "<br>".$lang['insterr7']; $err_lvl = 3;
|
||||
unset($err_msg); $err_msg = $lang['insterr7']; $err_lvl = 3;
|
||||
}
|
||||
if(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
|
||||
if(!in_array('com_dotnet', get_loaded_extensions())) {
|
||||
unset($err_msg); $err_msg .= "<br>".$lang['insterr8']; $err_lvl = 3;
|
||||
unset($err_msg); $err_msg = $lang['insterr8']; $err_lvl = 3;
|
||||
}
|
||||
}
|
||||
if(!isset($err_lvl)) {
|
||||
|
||||
52
jobs/bot.php
52
jobs/bot.php
@@ -5,12 +5,10 @@ ini_set('default_charset', 'UTF-8');
|
||||
setlocale(LC_ALL, 'UTF-8');
|
||||
error_reporting(0);
|
||||
|
||||
function shutdown($mysqlcon = NULL, $logpath, $timezone, $loglevel, $reason, $nodestroypid = NULL) {
|
||||
if($nodestroypid == NULL) {
|
||||
if (substr(php_uname(), 0, 7) == "Windows") {
|
||||
exec("del /F ".substr(__DIR__,0,-4).'logs/pid');
|
||||
} else {
|
||||
exec("rm -f ".substr(__DIR__,0,-4).'logs/pid');
|
||||
function shutdown($mysqlcon = NULL, $logpath, $timezone, $loglevel, $reason, $nodestroypid = TRUE) {
|
||||
if($nodestroypid === TRUE) {
|
||||
if (file_exists(substr(__DIR__,0,-4).'logs/pid')) {
|
||||
unlink(substr(__DIR__,0,-4).'logs/pid');
|
||||
}
|
||||
}
|
||||
enter_logfile($logpath,$timezone,$loglevel,$reason." Shutting down!");
|
||||
@@ -44,7 +42,9 @@ function enter_logfile($logpath,$timezone,$loglevel,$logtext,$norotate = false)
|
||||
fwrite($loghandle, DateTime::createFromFormat('U.u', number_format(microtime(true), 6, '.', ''))->setTimeZone(new DateTimeZone($timezone))->format("Y-m-d H:i:s.u ")." NOTICE Logfile filesie of 5 MiB reached.. Rotate logfile.\n");
|
||||
fclose($loghandle);
|
||||
$file2 = "$file.old";
|
||||
if (file_exists($file2)) unlink($file2);
|
||||
if (file_exists($file2)) {
|
||||
unlink($file2);
|
||||
}
|
||||
rename($file, $file2);
|
||||
$loghandle = fopen($file, 'a');
|
||||
fwrite($loghandle, DateTime::createFromFormat('U.u', number_format(microtime(true), 6, '.', ''))->setTimeZone(new DateTimeZone($timezone))->format("Y-m-d H:i:s.u ")." NOTICE Rotated logfile...\n");
|
||||
@@ -56,7 +56,7 @@ require_once(substr(__DIR__,0,-4).'other/config.php');
|
||||
require_once(substr(__DIR__,0,-4).'other/phpcommand.php');
|
||||
|
||||
if(isset($_SERVER['HTTP_HOST']) || isset($_SERVER['REMOTE_ADDR'])) {
|
||||
shutdown($mysqlcon, $logpath, $timezone, 1, "Request to start the Ranksystem from ".$_SERVER['REMOTE_ADDR'].". It seems the request came not from the command line!", 1);
|
||||
shutdown($mysqlcon, $logpath, $timezone, 1, "Request to start the Ranksystem from ".$_SERVER['REMOTE_ADDR'].". It seems the request came not from the command line!");
|
||||
}
|
||||
if(version_compare(phpversion(), '5.5.0', '<')) {
|
||||
shutdown($mysqlcon, $logpath, $timezone, 1, "Your PHP version (".phpversion().") is below 5.5.0. Update of PHP is required!");
|
||||
@@ -70,6 +70,9 @@ if(!in_array('curl', get_loaded_extensions())) {
|
||||
if(!in_array('zip', get_loaded_extensions())) {
|
||||
shutdown($mysqlcon, $logpath, $timezone, 1, "PHP Zip is missed. Installation of PHP Zip is required!");
|
||||
}
|
||||
if(!in_array('ssh2', get_loaded_extensions()) && $ts['tsencrypt'] == 1) {
|
||||
shutdown($mysqlcon, $logpath, $timezone, 1, "PHP SSH2 is missed. Installation of PHP SSH2 is required, when using secured (SSH) connection to TeamSpeak! If you are not able to install PHP SSH2 (i.e. hosted webspace), you need to deactivate the TS3 Query encryption inside the Webinterface.");
|
||||
}
|
||||
|
||||
enter_logfile($logpath,$timezone,5,"###################################################################");
|
||||
enter_logfile($logpath,$timezone,5,"");
|
||||
@@ -100,7 +103,7 @@ enter_logfile($logpath,$timezone,5,"Check Ranksystem files for updates [done]");
|
||||
|
||||
function check_shutdown($timezone,$logpath) {
|
||||
if(!is_file(substr(__DIR__,0,-4).'logs/pid')) {
|
||||
shutdown($mysqlcon, $logpath, $timezone, 5, "Received signal to stop!");
|
||||
shutdown(NULL, $logpath, $timezone, 5, "Received signal to stop!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,10 +120,21 @@ if($addons_config['assign_groups_active']['value'] == '1') {
|
||||
}
|
||||
enter_logfile($logpath,$timezone,5,"Loading addons [done]");
|
||||
|
||||
enter_logfile($logpath,$timezone,5,"Connect to TS3 Server (Address: \"".$ts['host']."\" Voice-Port: \"".$ts['voice']."\" Query-Port: \"".$ts['query']."\").");
|
||||
enter_logfile($logpath,$timezone,5,"Connect to TS3 Server (Address: \"".$ts['host']."\" Voice-Port: \"".$ts['voice']."\" Query-Port: \"".$ts['query']."\" SSH: \"".$ts['tsencrypt']."\").");
|
||||
try {
|
||||
$ts3 = TeamSpeak3::factory("serverquery://".rawurlencode($ts['user']).":".rawurlencode($ts['pass'])."@".$ts['host'].":".$ts['query']."/?server_port=".$ts['voice']."&blocking=0");
|
||||
enter_logfile($logpath,$timezone,5," Connection to TS3 Server established.");
|
||||
if($ts['tsencrypt'] == 1) {
|
||||
$ts3 = TeamSpeak3::factory("serverquery://".rawurlencode($ts['user']).":".rawurlencode($ts['pass'])."@".$ts['host'].":".$ts['query']."/?server_port=".$ts['voice']."&ssh=1");
|
||||
} else {
|
||||
$ts3 = TeamSpeak3::factory("serverquery://".rawurlencode($ts['user']).":".rawurlencode($ts['pass'])."@".$ts['host'].":".$ts['query']."/?server_port=".$ts['voice']."&blocking=0");
|
||||
}
|
||||
enter_logfile($logpath,$timezone,5,"Connection to TS3 Server established.");
|
||||
try{
|
||||
$ts3version = $ts3->version();
|
||||
enter_logfile($logpath,$timezone,5," TS3 Server version: ".$ts3version['version']." on ".$ts3version['platform']." [Build: ".$ts3version['build']." from ".date("Y-m-d H:i:s",$ts3version['build'])."]");
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($logpath,$timezone,2," Error due getting TS3 server version - ".$e->getCode().': '.$e->getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
usleep($slowmode);
|
||||
$ts3->notifyRegister("server");
|
||||
@@ -130,7 +144,7 @@ try {
|
||||
TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyTextmessage", "handle_messages");
|
||||
TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyCliententerview", "event_userenter");
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($logpath,$timezone,2," Error due register notifyTextmessage ".$e->getCode().': '.$e->getMessage());
|
||||
enter_logfile($logpath,$timezone,2," Error due notifyRegister on TS3 server - ".$e->getCode().': '.$e->getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -143,7 +157,7 @@ try {
|
||||
$ts3->selfUpdate(array('client_nickname' => $queryname2));
|
||||
}
|
||||
catch (Exception $e) {
|
||||
enter_logfile($logpath,$timezone,2,$lang['error'].$e->getCode().': '.$e->getMessage());
|
||||
enter_logfile($logpath,$timezone,2,$lang['errorts3'].$e->getCode().': '.$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,9 +170,9 @@ try {
|
||||
enter_logfile($logpath,$timezone,5," Joined to specified Channel.");
|
||||
} catch (Exception $e) {
|
||||
if($e->getCode() != 770) {
|
||||
enter_logfile($logpath,$timezone,5," Could not join specified channel.");
|
||||
enter_logfile($logpath,$timezone,2," Could not join specified channel (Channel ID: ".$defchid.") - ".$e->getCode().': '.$e->getMessage());
|
||||
} else {
|
||||
enter_logfile($logpath,$timezone,5," Joined to specified channel.");
|
||||
enter_logfile($logpath,$timezone,5," Joined to specified channel (already member of it).");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -390,14 +404,14 @@ try {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception $e) {
|
||||
enter_logfile($logpath,$timezone,2,$lang['error'].$e->getCode().': '.$e->getMessage());
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($logpath,$timezone,2,$lang['errorts3'].$e->getCode().': '.$e->getMessage());
|
||||
$offline_status = array(110,257,258,1024,1026,1031,1032,1033,1034,1280,1793);
|
||||
if(in_array($e->getCode(), $offline_status)) {
|
||||
if($mysqlcon->exec("UPDATE $dbname.stats_server SET server_status='0'") === false) {
|
||||
enter_logfile($logpath,$timezone,2,$lang['error'].print_r($mysqlcon->errorInfo(), true));
|
||||
}
|
||||
}
|
||||
shutdown($mysqlcon, $logpath, $timezone, 1, "Critical TS3 error on core function!");
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?PHP
|
||||
function check_db($mysqlcon,$lang,$dbname,$timezone,$currvers,$logpath) {
|
||||
$newversion = '1.2.9';
|
||||
$newversion = '1.2.10';
|
||||
enter_logfile($logpath,$timezone,5,"Check Ranksystem database for updates...");
|
||||
|
||||
function set_new_version($mysqlcon,$dbname,$timezone,$newversion,$logpath) {
|
||||
@@ -64,8 +64,53 @@ function check_db($mysqlcon,$lang,$dbname,$timezone,$currvers,$logpath) {
|
||||
enter_logfile($logpath,$timezone,4,"Unnecessary file, please delete it from your webserver: webinterface/admin.php");
|
||||
}
|
||||
}
|
||||
if(is_file(substr(__DIR__,0,-4).'libs/ts3_lib/Adapter/Blacklist/Exception.php')) {
|
||||
if(!unlink(substr(__DIR__,0,-4).'libs/ts3_lib/Adapter/Blacklist/Exception.php')) {
|
||||
enter_logfile($logpath,$timezone,4,"Unnecessary file, please delete it from your webserver: libs/ts3_lib/Adapter/Blacklist/Exception.php");
|
||||
}
|
||||
}
|
||||
if(is_dir(substr(__DIR__,0,-4).'libs/ts3_lib/Adapter/Blacklist/')) {
|
||||
if(!rmdir(substr(__DIR__,0,-4).'libs/ts3_lib/Adapter/Blacklist/')) {
|
||||
enter_logfile($logpath,$timezone,4,"Unnecessary folder, please delete it from your webserver: libs/ts3_lib/Adapter/Blacklist/");
|
||||
}
|
||||
}
|
||||
if(is_file(substr(__DIR__,0,-4).'libs/ts3_lib/Adapter/TSDNS/Exception.php')) {
|
||||
if(!unlink(substr(__DIR__,0,-4).'libs/ts3_lib/Adapter/TSDNS/Exception.php')) {
|
||||
enter_logfile($logpath,$timezone,4,"Unnecessary file, please delete it from your webserver: libs/ts3_lib/Adapter/TSDNS/Exception.php");
|
||||
}
|
||||
}
|
||||
if(is_dir(substr(__DIR__,0,-4).'libs/ts3_lib/Adapter/TSDNS/')) {
|
||||
if(!rmdir(substr(__DIR__,0,-4).'libs/ts3_lib/Adapter/TSDNS/')) {
|
||||
enter_logfile($logpath,$timezone,4,"Unnecessary folder, please delete it from your webserver: libs/ts3_lib/Adapter/TSDNS/");
|
||||
}
|
||||
}
|
||||
if(is_file(substr(__DIR__,0,-4).'libs/ts3_lib/Adapter/Update/Exception.php')) {
|
||||
if(!unlink(substr(__DIR__,0,-4).'libs/ts3_lib/Adapter/Update/Exception.php')) {
|
||||
enter_logfile($logpath,$timezone,4,"Unnecessary file, please delete it from your webserver: libs/ts3_lib/Adapter/Update/Exception.php");
|
||||
}
|
||||
}
|
||||
if(is_dir(substr(__DIR__,0,-4).'libs/ts3_lib/Adapter/Update/')) {
|
||||
if(!rmdir(substr(__DIR__,0,-4).'libs/ts3_lib/Adapter/Update/')) {
|
||||
enter_logfile($logpath,$timezone,4,"Unnecessary folder, please delete it from your webserver: libs/ts3_lib/Adapter/Update/");
|
||||
}
|
||||
}
|
||||
if(is_file(substr(__DIR__,0,-4).'libs/ts3_lib/Adapter/Blacklist.php')) {
|
||||
if(!unlink(substr(__DIR__,0,-4).'libs/ts3_lib/Adapter/Blacklist.php')) {
|
||||
enter_logfile($logpath,$timezone,4,"Unnecessary file, please delete it from your webserver: libs/ts3_lib/Adapter/Blacklist.php");
|
||||
}
|
||||
}
|
||||
if(is_file(substr(__DIR__,0,-4).'libs/ts3_lib/Adapter/TSDNS.php')) {
|
||||
if(!unlink(substr(__DIR__,0,-4).'libs/ts3_lib/Adapter/TSDNS.php')) {
|
||||
enter_logfile($logpath,$timezone,4,"Unnecessary file, please delete it from your webserver: libs/ts3_lib/Adapter/TSDNS.php");
|
||||
}
|
||||
}
|
||||
if(is_file(substr(__DIR__,0,-4).'libs/ts3_lib/Adapter/Update.php')) {
|
||||
if(!unlink(substr(__DIR__,0,-4).'libs/ts3_lib/Adapter/Update.php')) {
|
||||
enter_logfile($logpath,$timezone,4,"Unnecessary file, please delete it from your webserver: libs/ts3_lib/Adapter/Update.php");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function check_writable($timezone,$logpath) {
|
||||
enter_logfile($logpath,$timezone,5," Check files permissions...");
|
||||
$counterr=0;
|
||||
@@ -76,7 +121,6 @@ function check_db($mysqlcon,$lang,$dbname,$timezone,$currvers,$logpath) {
|
||||
if (!$object->isDir()) {
|
||||
if(!is_writable($object->getPathname())) {
|
||||
enter_logfile($logpath,$timezone,3," File is not writeable ".$object);
|
||||
echo "\nhier: ".$object."\n";
|
||||
$counterr++;
|
||||
}
|
||||
} else {
|
||||
@@ -94,7 +138,7 @@ function check_db($mysqlcon,$lang,$dbname,$timezone,$currvers,$logpath) {
|
||||
enter_logfile($logpath,$timezone,5," Check files permissions [done]");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($currvers==$newversion) {
|
||||
enter_logfile($logpath,$timezone,5," No newer version detected; Database check finished.");
|
||||
old_files($timezone,$logpath);
|
||||
@@ -253,10 +297,13 @@ function check_db($mysqlcon,$lang,$dbname,$timezone,$currvers,$logpath) {
|
||||
enter_logfile($logpath,$timezone,4," [1.2.7] Created table user_iphash successfully.");
|
||||
}
|
||||
}
|
||||
if(version_compare($currvers, '1.2.8', '<=')) {
|
||||
if(version_compare($currvers, '1.2.9', '<=')) {
|
||||
if($mysqlcon->exec("ALTER TABLE `$dbname`.`config` ADD (`tsencrypt` tinyint(1) NOT NULL default '0')") === false) { } else {
|
||||
enter_logfile($logpath,$timezone,4," [1.2.10] Adjusted table config successfully.");
|
||||
}
|
||||
if($mysqlcon->exec("UPDATE `$dbname`.`job_check` SET `timestamp`='".time()."' WHERE `job_name`='last_update'") === false) { } else {
|
||||
enter_logfile($logpath,$timezone,4," [1.2.9] Stored timestamp of last update successfully.");
|
||||
}
|
||||
enter_logfile($logpath,$timezone,4," [1.2.10] Stored timestamp of last update successfully.");
|
||||
}
|
||||
}
|
||||
$currvers = set_new_version($mysqlcon,$dbname,$timezone,$newversion,$logpath);
|
||||
old_files($timezone,$logpath);
|
||||
|
||||
@@ -11,19 +11,20 @@ function clean($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$cleanclients,$c
|
||||
$break=200;
|
||||
$count_tsuser['count'] = 0;
|
||||
$clientdblist=array();
|
||||
enter_logfile($logpath,$timezone,6,"Get TS3 Clientlist...".$start);
|
||||
enter_logfile($logpath,$timezone,5," Get TS3 Clientlist...");
|
||||
while($getclientdblist=$ts3->clientListDb($start, $break)) {
|
||||
$ts3->serverInfoReset(); //TeamSpeak gets very slow on sending dblist.. needs to hold the connection
|
||||
#enter_logfile($logpath,$timezone,6,"Round TS3 Clientlist ".$start);
|
||||
check_shutdown($timezone,$logpath);
|
||||
$dummy = $mysqlcon->query("SELECT * FROM `$dbname`.`job_check`"); //TeamSpeak became very slow on sending dblist with 3.3.0.. needs to hold the connection
|
||||
$clientdblist=array_merge($clientdblist, $getclientdblist);
|
||||
$start=$start+$break;
|
||||
$count_tsuser=array_shift($getclientdblist);
|
||||
enter_logfile($logpath,$timezone,6," Got TS3 Clientlist ".count($clientdblist)." of ".$count_tsuser['count']." Clients.");
|
||||
if($count_tsuser['count'] <= $start) {
|
||||
break;
|
||||
}
|
||||
usleep($slowmode);
|
||||
}
|
||||
enter_logfile($logpath,$timezone,6,"Get TS3 Clientlist [DONE]");
|
||||
enter_logfile($logpath,$timezone,5," Get TS3 Clientlist [DONE]");
|
||||
foreach($clientdblist as $uuidts) {
|
||||
$single_uuid = $uuidts['client_unique_identifier']->toString();
|
||||
$uidarrts[$single_uuid]= 1;
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
$lang= array();
|
||||
$lang['adduser'] = "User %s (unique Client-ID: %s; Client-database-ID %s) is unknown -> added to the Ranksystem now.";
|
||||
$lang['brute'] = "Much incorrect logins detected on the webinterface. Blocked login for 300 seconds! Last access from IP %s.";
|
||||
$lang['brute1'] = "Incorrect login attempt on the webinterface detected. Failed access attempt from IP %s with username %s.";
|
||||
$lang['brute2'] = "Successful login attempt to the webinterface from IP %s.";
|
||||
$lang['changedbid'] = "User %s (unique Client-ID: %s) got a new TeamSpeak Client-database-ID (%s). Update the old Client-database-ID (%s) and reset collected times!";
|
||||
$lang['crawl'] = "البحث عن المستخدمين المتواجدين وحساب التفاعل";
|
||||
$lang['clean'] = "البحث عن المستخدمين الذين من المفروض حذفهم";
|
||||
@@ -86,7 +88,7 @@ $lang['listsumi'] = "وقت عدم النشاط الكلي";
|
||||
$lang['listsumo'] = "وقت التواجد الكلي";
|
||||
$lang['listuid'] = "unique Client-ID";
|
||||
$lang['login'] = "Login";
|
||||
$lang['msg0001'] = "running version: %s";
|
||||
$lang['msg0001'] = "The Ranksystem is running on version: %s";
|
||||
$lang['msg0002'] = "Valid commands are:\n[B]!help[/B], [B]!info[/B], [B]!commands[/B]\t\t get a command list\n[B]!version[/B]\t\t\t\t\t\t\t\t get the Ranksystem version\n[B]!update[/B], [B]!checkupdate[/B]\t\t check for new version and run update\n[B]!clean[/B]\t\t\t\t\t\t\t\t\t start cleaning of the user database\n[B]!next[/B], [B]!nextup[/B]\t\t\t\t\t\tget the time to the next rank up\n[B]!restart[/B], [B]!reboot[/B]\t\t\t\t\trestart the Ranksystem bot\n[B]!shutdown[/B], [B]!quit[/B], [B]!stop[/B]\t\t stop the Ranksystem bot";
|
||||
$lang['msg0003'] = "You are not eligible for this command!";
|
||||
$lang['msg0004'] = "Client %s (%s) requests shutdown.";
|
||||
@@ -532,7 +534,9 @@ $lang['wits3querpwdesc'] = "TeamSpeak 3 query password<br>Password for the query
|
||||
$lang['wits3querusr'] = "TS3 Query-User";
|
||||
$lang['wits3querusrdesc'] = "TeamSpeak 3 query username<br>Default is serveradmin<br>Of course, you can also create an additional serverquery account only for the Ranksystem.<br>The needed permissions you find on:<br>http://ts-n.net/ranksystem.php";
|
||||
$lang['wits3query'] = "TS3 Query-Port";
|
||||
$lang['wits3querydesc'] = "TeamSpeak 3 query port<br>Default is 10011 (TCP)<br>If its not default, you should find it in your 'ts3server.ini'.";
|
||||
$lang['wits3querydesc'] = "TeamSpeak 3 query port<br>Default RAW (plain text) is 10011 (TCP)<br>Default SSH (encrypted) is 10022 (TCP)<br><br>If its not default, you should find it in your 'ts3server.ini'.";
|
||||
$lang['wits3encrypt'] = "TS3 Query encryption";
|
||||
$lang['wits3encryptdesc'] = "Activate this option to encrypt the communication between the Ranksystem and the TeamSpeak 3 server (SSH).<br>When this function is disabled, the communication will be done in plain text (RAW). This could be a security risk, especially when the TS3 server and the Ranksystem are running on different machines.<br><br>Be also sure, you have checked the TS3 Query Port, which needs (perhaps) to be changed in the Ranksystem!<br><br><b>Attention:</b> The SSH encryption needs more CPU time and with this truly more system resources. That's why we recommend to use a RAW connection (disabled encryption) if the TS3 server and the Ranksystem are running on the same machine / server (localhost / 127.0.0.1). If they are running on separate machines, you should activate the encrypted connection!<br><br><b>Requirements:</b><br><br>1) TS3 Server version 3.3.0 or above.<br><br>2) The PHP extension PHP-SSH2 is necessary.<br>On Linux you can it install with the following command:<br><pre>sudo apt-get install php-ssh2</pre><br>3) The encryption needs to be enabled on your TS3 server!<br>Activate the following parameters inside your 'ts3server.ini' and customize it for your needs:<br><pre>query_ssh_ip=0.0.0.0,::<br>query_ssh_port=10022<br>query_protocols=ssh,raw<br>query_ssh_rsa_host_key=ssh_host_rsa_key</pre>After changing your TS3 server configurations a restart of your TS3 server is necessary.";
|
||||
$lang['wits3voice'] = "TS3 Voice-Port";
|
||||
$lang['wits3voicedesc'] = "TeamSpeak 3 voice port<br>Default is 9987 (UDP)<br>This is the port, you uses also to connect with the TS3 Client.";
|
||||
$lang['wiverify'] = "Verification-Channel";
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
$lang = array();
|
||||
$lang['adduser'] = "Uživatel %s (unique Client-ID: %s; Client-database-ID %s) ještě není v databázi -> přidán do Ranksystem.";
|
||||
$lang['brute'] = "Much incorrect logins detected on the webinterface. Blocked login for 300 seconds! Last access from IP %s.";
|
||||
$lang['brute1'] = "Incorrect login attempt on the webinterface detected. Failed access attempt from IP %s with username %s.";
|
||||
$lang['brute2'] = "Successful login attempt to the webinterface from IP %s.";
|
||||
$lang['changedbid'] = "Uživatel %s (unique Client-ID: %s) má novou TeamSpeak Client-database-ID (%s). aktulizujte starou Client-database-ID (%s) a resetujte všechny časy!";
|
||||
$lang['crawl'] = "Skenuji nové i stávající uživatele.";
|
||||
$lang['clean'] = "Skunuji uživatele ke smazání";
|
||||
@@ -86,7 +88,7 @@ $lang['listsumi'] = "Dohromady online (neaktivně)";
|
||||
$lang['listsumo'] = "Dohromady online";
|
||||
$lang['listuid'] = "unique Client-ID";
|
||||
$lang['login'] = "Přihlášení";
|
||||
$lang['msg0001'] = "Aktuální verze: %s";
|
||||
$lang['msg0001'] = "The Ranksystem is running on version: %s";
|
||||
$lang['msg0002'] = "Příkazy pro ovládání bota:\n[B]!help[/B], [B]!info[/B], [B]!commands[/B]\t\t vypíše seznam příkazů\n[B]!version[/B]\t\t\t\t\t\t\t\t vypíše verzi Ranksystemu\n[B]!update[/B], [B]!checkupdate[/B]\t\t Zkontroje dostupné aktualizace, popř. aktulizuje Ranksystem\n[B]!nextup[/B]\t\t\t\t\t\t\tčas do dalšího ranku (úrovně)\n[B]!restart[/B], [B]!reboot[/B]\t\t\t\t\trestartuje Ranksystem bota\n[B]!shutdown[/B], [B]!quit[/B], [B]!stop[/B]\t\t vypne Ranksystem bota";
|
||||
$lang['msg0003'] = "Nemáto dostatečné oprávnění pro tento příkaz!";
|
||||
$lang['msg0004'] = "Uživatel %s (%s) požádal o vypnutí Ranksystemu!";
|
||||
@@ -531,7 +533,9 @@ $lang['wits3querpwdesc'] = "TeamSpeak 3 query password<br>Heslo pro uživatele q
|
||||
$lang['wits3querusr'] = "TS3 Query-uživatel";
|
||||
$lang['wits3querusrdesc'] = "TeamSpeak 3 query (přihlašovací jméno)<br>Ve výchozím nastavení nastaveno-> serveradmin<br>Samozřejmě můžete vytvořit nový query účet přímo pro Ranksystem.<br>Potřebné oprávnění najdete zde:<br>http://ts-n.net/ranksystem.php";
|
||||
$lang['wits3query'] = "TS3 Query-Port";
|
||||
$lang['wits3querydesc'] = "TeamSpeak 3 query port<br>Ve výchozím nastavení > 10011 (TCP)<br>Pokud nepoužíváte výchozí port (10011) koukněte do configu--> 'ts3server.ini'.";
|
||||
$lang['wits3querydesc'] = "TeamSpeak 3 query port<br>Default RAW (plain text) is 10011 (TCP)<br>Default SSH (encrypted) is 10022 (TCP)<br><br>Pokud nepoužíváte výchozí port (10011) koukněte do configu--> 'ts3server.ini'.";
|
||||
$lang['wits3encrypt'] = "TS3 Query encryption";
|
||||
$lang['wits3encryptdesc'] = "Activate this option to encrypt the communication between the Ranksystem and the TeamSpeak 3 server (SSH).<br>When this function is disabled, the communication will be done in plain text (RAW). This could be a security risk, especially when the TS3 server and the Ranksystem are running on different machines.<br><br>Be also sure, you have checked the TS3 Query Port, which needs (perhaps) to be changed in the Ranksystem!<br><br><b>Attention:</b> The SSH encryption needs more CPU time and with this truly more system resources. That's why we recommend to use a RAW connection (disabled encryption) if the TS3 server and the Ranksystem are running on the same machine / server (localhost / 127.0.0.1). If they are running on separate machines, you should activate the encrypted connection!<br><br><b>Requirements:</b><br><br>1) TS3 Server version 3.3.0 or above.<br><br>2) The PHP extension PHP-SSH2 is necessary.<br>On Linux you can it install with the following command:<br><pre>sudo apt-get install php-ssh2</pre><br>3) The encryption needs to be enabled on your TS3 server!<br>Activate the following parameters inside your 'ts3server.ini' and customize it for your needs:<br><pre>query_ssh_ip=0.0.0.0,::<br>query_ssh_port=10022<br>query_protocols=ssh,raw<br>query_ssh_rsa_host_key=ssh_host_rsa_key</pre>After changing your TS3 server configurations a restart of your TS3 server is necessary.";
|
||||
$lang['wits3voice'] = "TS3 Voice-Port";
|
||||
$lang['wits3voicedesc'] = "TeamSpeak 3 voice port<br>Default is 9987 (UDP)<br>Toto je port, který používáš při připojení na TS3 server v TS3 Clientu.";
|
||||
$lang['wiverify'] = "Verification-Channel";
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
$lang= array();
|
||||
$lang['adduser'] = "User %s (eindeutige Client-ID: %s; Client-Datenbank-ID: %s) ist bisher unbekannt -> wurde nun zum Ranksystem hinzugefügt.";
|
||||
$lang['brute'] = "Es wurden einige fehlgeschlagene Login-Versuche festgestellt. Blocke login für 300 Sekunden! Letzter Versuch von IP %s.";
|
||||
$lang['brute1'] = "Fehlgeschlagener Login-Versuch zum Webinterface festgestellt. Login Anfrage kam von IP %s mit dem Usernamen %s.";
|
||||
$lang['brute2'] = "Erfolgreicher Login zum Webinterface von IP %s festgestellt.";
|
||||
$lang['changedbid'] = "User %s (eindeutige Client-ID: %s) hat eine neue TeamSpeak Client-Datenbank-ID (%s). Ersetze die alte Client-Datenbank-ID (%s) und setze die gesammelte Zeiten zurück";
|
||||
$lang['crawl'] = "Scanne nach verbundenen Usern und sammle die online Zeit...";
|
||||
$lang['clean'] = "Scanne nach Usern, welche zu löschen sind...";
|
||||
@@ -86,7 +88,7 @@ $lang['listsumi'] = "ges. idle Zeit";
|
||||
$lang['listsumo'] = "ges. online Zeit";
|
||||
$lang['listuid'] = "eindeutige Client-ID";
|
||||
$lang['login'] = "Login";
|
||||
$lang['msg0001'] = "eingesetzte Version: %s";
|
||||
$lang['msg0001'] = "Das Ranksystem läuft auf Version: %s";
|
||||
$lang['msg0002'] = "Verfügbare Befehle sind:\n[B]!help[/B], [B]!info[/B], [B]!commands[/B]\t\t erhalte Liste der Befehle\n[B]!version[/B]\t\t\t\t\t\t\t\t erhalte die aktuelle Version\n[B]!update[/B], [B]!checkupdate[/B]\t\t\tprüfe auf neue Version und update\n[B]!clean[/B]\t\t\t\t\t\t\t\t\t bereinge User-Datenbank\n[B]!next[/B], [B]!nextup[/B]\t\t\t\t\t\t erhalte die Zeit zur nächsten Rangsteigerung\n[B]!restart[/B], [B]!reboot[/B]\t\t\t\t\tden Ranksystem bot neu starten\n[B]!shutdown[/B], [B]!quit[/B], [B]!stop[/B]\t\t den Ranksystem Bot stoppen";
|
||||
$lang['msg0003'] = "Du bist nicht berechtigt diesen Befehl abzusetzen!";
|
||||
$lang['msg0004'] = "Client %s (%s) fordert Abschaltung.";
|
||||
@@ -531,7 +533,9 @@ $lang['wits3querpwdesc'] = "TeamSpeak 3 Query Passwort<br>Passwort des Query Ben
|
||||
$lang['wits3querusr'] = "TS3 Query-Benutzer";
|
||||
$lang['wits3querusrdesc'] = "TeamSpeak 3 Query Benutzername<br>Standard ist serveradmin<br>Natürlich kann auch ein gesonderter Query-Benutzer erstellt und genutzt werden.<br>Die benötigten Rechte sind hier aufgelistet:<br>http://ts-n.net/ranksystem.php";
|
||||
$lang['wits3query'] = "TS3 Query-Port";
|
||||
$lang['wits3querydesc'] = "TeamSpeak 3 Query Port<br>Standard ist 10011 (TCP)<br>andere Werte sollten in der 'ts3server.ini' zu finden sein.";
|
||||
$lang['wits3querydesc'] = "TeamSpeak 3 Query Port<br>Standard RAW (Klartext) ist 10011 (TCP)<br>Standard SSH (verschlüsselt) ist 10022 (TCP)<br><br>Abweichende Werte sollten sich aus der 'ts3server.ini' entnehmen lassen.";
|
||||
$lang['wits3encrypt'] = "TS3 Query Verschlüsselung";
|
||||
$lang['wits3encryptdesc'] = "Aktiviere diese Option, um die Kommunikation zwischen dem Ranksystem und dem TeamSpeak 3 Server zu verschlüsseln (SSH).<br>Ist diese Funktion deaktiviert, so erfolgt die Kommunikation unverschlüsselt (RAW). Das könnte ein Sicherheitsrisiko darstellen, insbesondere, wenn der TS3 Server und das Ranksystem auf unterschiedlichen Machinen betrieben wird.<br><br>Es ist auch sicherzustellen, dass der richtige TS3 Query Port passend zu dieser Funktion hinterlegt wird!<br><br><b>Achtung:</b> Die SSH Verschlüsselung benötigt mehr CPU und damit mehr System Ressourcen. Das ist der Grund, warum wir empfehlen die RAW Verbindung zu verwenden, wenn der TS3 Server und das Ranksystem auf der gleichen Machine laufen (localhost / 127.0.0.1). Laufen sie jedoch auf getrennten Machinen, sollte die SSH Verschlüsselung für die Verbindung aktiviert werden<br><br><b>Voraussetzungen:</b><br><br>1) TS3 Server Version 3.3.0 oder höher.<br><br>2) Die PHP Erweiterung (Extension) PHP-SSH2 wird benötigt.<br>Unter Linux kann sie wie folgt installiert werden:<br><pre>sudo apt-get install php-ssh2</pre><br>3) Die Verschlüsselung (SSH) muss innerhalb des TS3 Servers zuvor aktiviert werden!<br>Aktiviere die folgenden Parameter in der 'ts3server.ini' und passe diese nach Bedarf an:<br><pre>query_ssh_ip=0.0.0.0,::<br>query_ssh_port=10022<br>query_protocols=ssh,raw<br>query_ssh_rsa_host_key=ssh_host_rsa_key</pre>Nach Änderung der TS3 Server Konfiguration ist ein Neustart dessen erforderlich.";
|
||||
$lang['wits3voice'] = "TS3 Voice-Port";
|
||||
$lang['wits3voicedesc'] = "TeamSpeak 3 Voice Port<br>Standard ist 9987 (UDP)<br>Dieser Port wird zum Verbinden mit dem TS3 Client genutzt.";
|
||||
$lang['wiverify'] = "Verifizierung-Channel";
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
$lang = array();
|
||||
$lang['adduser'] = "User %s (unique Client-ID: %s; Client-database-ID %s) is unknown -> added to the Ranksystem now.";
|
||||
$lang['brute'] = "Much incorrect logins detected on the webinterface. Blocked login for 300 seconds! Last access from IP %s.";
|
||||
$lang['brute1'] = "Incorrect login attempt on the webinterface detected. Failed access attempt from IP %s with username %s.";
|
||||
$lang['brute2'] = "Successful login attempt to the webinterface from IP %s.";
|
||||
$lang['changedbid'] = "User %s (unique Client-ID: %s) got a new TeamSpeak Client-database-ID (%s). Update the old Client-database-ID (%s) and reset collected times!";
|
||||
$lang['crawl'] = "Scanning for connected users and count the activity...";
|
||||
$lang['clean'] = "Scanning for clients to delete...";
|
||||
@@ -86,7 +88,7 @@ $lang['listsumi'] = "sum. idle time";
|
||||
$lang['listsumo'] = "sum. online time";
|
||||
$lang['listuid'] = "unique Client-ID";
|
||||
$lang['login'] = "Login";
|
||||
$lang['msg0001'] = "running version: %s";
|
||||
$lang['msg0001'] = "The Ranksystem is running on version: %s";
|
||||
$lang['msg0002'] = "Valid commands are:\n[B]!help[/B], [B]!info[/B], [B]!commands[/B]\t\t get a command list\n[B]!version[/B]\t\t\t\t\t\t\t\t get the Ranksystem version\n[B]!update[/B], [B]!checkupdate[/B]\t\t check for new version and run update\n[B]!clean[/B]\t\t\t\t\t\t\t\t\t start cleaning of the user database\n[B]!next[/B], [B]!nextup[/B]\t\t\t\t\t\tget the time to the next rank up\n[B]!restart[/B], [B]!reboot[/B]\t\t\t\t\trestart the Ranksystem bot\n[B]!shutdown[/B], [B]!quit[/B], [B]!stop[/B]\t\t stop the Ranksystem bot";
|
||||
$lang['msg0003'] = "You are not eligible for this command!";
|
||||
$lang['msg0004'] = "Client %s (%s) requests shutdown.";
|
||||
@@ -531,7 +533,9 @@ $lang['wits3querpwdesc'] = "TeamSpeak 3 query password<br>Password for the query
|
||||
$lang['wits3querusr'] = "TS3 Query-User";
|
||||
$lang['wits3querusrdesc'] = "TeamSpeak 3 query username<br>Default is serveradmin<br>Of course, you can also create an additional serverquery account only for the Ranksystem.<br>The needed permissions you find on:<br>http://ts-n.net/ranksystem.php";
|
||||
$lang['wits3query'] = "TS3 Query-Port";
|
||||
$lang['wits3querydesc'] = "TeamSpeak 3 query port<br>Default is 10011 (TCP)<br>If its not default, you should find it in your 'ts3server.ini'.";
|
||||
$lang['wits3querydesc'] = "TeamSpeak 3 query port<br>Default RAW (plain text) is 10011 (TCP)<br>Default SSH (encrypted) is 10022 (TCP)<br><br>If its not default, you should find it in your 'ts3server.ini'.";
|
||||
$lang['wits3encrypt'] = "TS3 Query encryption";
|
||||
$lang['wits3encryptdesc'] = "Activate this option to encrypt the communication between the Ranksystem and the TeamSpeak 3 server (SSH).<br>When this function is disabled, the communication will be done in plain text (RAW). This could be a security risk, especially when the TS3 server and the Ranksystem are running on different machines.<br><br>Be also sure, you have checked the TS3 Query Port, which needs (perhaps) to be changed in the Ranksystem!<br><br><b>Attention:</b> The SSH encryption needs more CPU time and with this truly more system resources. That's why we recommend to use a RAW connection (disabled encryption) if the TS3 server and the Ranksystem are running on the same machine / server (localhost / 127.0.0.1). If they are running on separate machines, you should activate the encrypted connection!<br><br><b>Requirements:</b><br><br>1) TS3 Server version 3.3.0 or above.<br><br>2) The PHP extension PHP-SSH2 is necessary.<br>On Linux you can it install with the following command:<br><pre>sudo apt-get install php-ssh2</pre><br>3) The encryption needs to be enabled on your TS3 server!<br>Activate the following parameters inside your 'ts3server.ini' and customize it for your needs:<br><pre>query_ssh_ip=0.0.0.0,::<br>query_ssh_port=10022<br>query_protocols=ssh,raw<br>query_ssh_rsa_host_key=ssh_host_rsa_key</pre>After changing your TS3 server configurations a restart of your TS3 server is necessary.";
|
||||
$lang['wits3voice'] = "TS3 Voice-Port";
|
||||
$lang['wits3voicedesc'] = "TeamSpeak 3 voice port<br>Default is 9987 (UDP)<br>This is the port, you uses also to connect with the TS3 Client.";
|
||||
$lang['wiverify'] = "Verification-Channel";
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
$lang = array();
|
||||
$lang['adduser'] = "L'utilisateur %s (Identifiant unique: %s; ID dans la base de donnée: %s) est inconnu -> Il vient d'être ajouté dans le Ranksystem.";
|
||||
$lang['brute'] = "Much incorrect logins detected on the webinterface. Blocked login for 300 seconds! Last access from IP %s.";
|
||||
$lang['brute1'] = "Incorrect login attempt on the webinterface detected. Failed access attempt from IP %s with username %s.";
|
||||
$lang['brute2'] = "Successful login attempt to the webinterface from IP %s.";
|
||||
$lang['changedbid'] = "L'utilisateur %s (Identifiant unique: %s) a obtenu un nouveau TeamSpeak ID dans la base de donnée (%s). Mettez à jour l'ancien ID dans la base de donnée (%s) et réinitialisez les heures collectées !";
|
||||
$lang['crawl'] = "Scan des utilisateurs connectés et comptage de leur activité...";
|
||||
$lang['clean'] = "Scan des clients, certains doivent être supprimer...";
|
||||
@@ -86,7 +88,7 @@ $lang['listsumi'] = "Temps d'inactivité";
|
||||
$lang['listsumo'] = "Temps en ligne";
|
||||
$lang['listuid'] = "Identifiant unique de l'utilisateur";
|
||||
$lang['login'] = "S'identifier";
|
||||
$lang['msg0001'] = "version actuelle: %s";
|
||||
$lang['msg0001'] = "The Ranksystem is running on version: %s";
|
||||
$lang['msg0002'] = "Les commandes valides sont:\n[B]!help[/B], [B]!info[/B], [B]!commands[/B]\t\t obtenir une liste de commandes\n[B]!version[/B]\t\t\t\t\t\t\t\t obtenir la version du Ranksystem\n[B]!update[/B], [B]!checkupdate[/B]\t\t check for new version and run update\n[B]!clean[/B]\t\t\t\t\t\t\t\t\t start cleaning of the user database\n[B]!next[/B], [B]!nextup[/B]\t\t\t\t\t\t obtenir le temps pour le prochain rang \n[B]!restart[/B], [B]!reboot[/B]\t\t\t\t\tRedémarrer le bot du ranksystem\n[B]!shutdown[/B], [B]!quit[/B], [B]!stop[/B]\t\t Arrêter le bot du ranksystem";
|
||||
$lang['msg0003'] = "Vous n'êtes pas admissible à cette commande !";
|
||||
$lang['msg0004'] = "Client %s (%s) demmande l'arrêt.";
|
||||
@@ -531,7 +533,9 @@ $lang['wits3querpwdesc'] = "Mot de passe query du serveur TeamSpeak 3<br>Mot de
|
||||
$lang['wits3querusr'] = "Utilisateur query du TS3";
|
||||
$lang['wits3querusrdesc'] = "Nom d'utilisateur query du serveur TeamSpeak3<br>La valeur par défaut est serveradmin<br>Bien sûr, vous pouvez également créer un compte serverquery supplémentaire uniquement pour le Ranksystem.<br>Les autorisations nécessaires sont trouvable sur:<br>http://ts-n.net/ranksystem.php";
|
||||
$lang['wits3query'] = "TS3 Query-Port";
|
||||
$lang['wits3querydesc'] = "Port query TeamSpeak 3<br>La valeur par défaut est 10011 (TCP)<br>Si ce n'est pas par défaut, vous devriez le trouver dans votre 'ts3server.ini'.";
|
||||
$lang['wits3querydesc'] = "Port query TeamSpeak 3<br>Default RAW (plain text) is 10011 (TCP)<br>Default SSH (encrypted) is 10022 (TCP)<br><br>Si ce n'est pas par défaut, vous devriez le trouver dans votre 'ts3server.ini'.";
|
||||
$lang['wits3encrypt'] = "TS3 Query encryption";
|
||||
$lang['wits3encryptdesc'] = "Activate this option to encrypt the communication between the Ranksystem and the TeamSpeak 3 server (SSH).<br>When this function is disabled, the communication will be done in plain text (RAW). This could be a security risk, especially when the TS3 server and the Ranksystem are running on different machines.<br><br>Be also sure, you have checked the TS3 Query Port, which needs (perhaps) to be changed in the Ranksystem!<br><br><b>Attention:</b> The SSH encryption needs more CPU time and with this truly more system resources. That's why we recommend to use a RAW connection (disabled encryption) if the TS3 server and the Ranksystem are running on the same machine / server (localhost / 127.0.0.1). If they are running on separate machines, you should activate the encrypted connection!<br><br><b>Requirements:</b><br><br>1) TS3 Server version 3.3.0 or above.<br><br>2) The PHP extension PHP-SSH2 is necessary.<br>On Linux you can it install with the following command:<br><pre>sudo apt-get install php-ssh2</pre><br>3) The encryption needs to be enabled on your TS3 server!<br>Activate the following parameters inside your 'ts3server.ini' and customize it for your needs:<br><pre>query_ssh_ip=0.0.0.0,::<br>query_ssh_port=10022<br>query_protocols=ssh,raw<br>query_ssh_rsa_host_key=ssh_host_rsa_key</pre>After changing your TS3 server configurations a restart of your TS3 server is necessary.";
|
||||
$lang['wits3voice'] = "TS3 Voix-Port";
|
||||
$lang['wits3voicedesc'] = "Port vocal TeamSpeak 3<br>La valeur par défaut est 9987 (UDP)<br>Il s'agit du port, que vous utilisez également pour vous connecter avec le logiciel client TS3.";
|
||||
$lang['wiverify'] = "Verification-Channel";
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
$lang = array();
|
||||
$lang['adduser'] = "L'utente %s ( Client-ID: %s; Client-database-ID %s) non è presente nel database -> L'utente è stato aggiunto al sistema.";
|
||||
$lang['brute'] = "Rilevati molti accessi non corretti nell'interfaccia web. Login bloccato per 300 secondi! Ultimo accesso dall'IP %s.";
|
||||
$lang['brute1'] = "Incorrect login attempt on the webinterface detected. Failed access attempt from IP %s with username %s.";
|
||||
$lang['brute2'] = "Successful login attempt to the webinterface from IP %s.";
|
||||
$lang['changedbid'] = "L'utente %s (unique Client-ID: %s) ha ottenuto un nuovo database-ID (%s). Aggiorna il vecchio Client-database-ID (%s) e resetta il tempo raggiunto!";
|
||||
$lang['crawl'] = "Scansione degli utenti connessi e conteggio delle attività...";
|
||||
$lang['clean'] = "Scansione degli utenti che vanno eliminati...";
|
||||
@@ -86,7 +88,7 @@ $lang['listsumi'] = "Somma del tempo in IDLE";
|
||||
$lang['listsumo'] = "Somma del tempo Online";
|
||||
$lang['listuid'] = "Client-ID Univoco";
|
||||
$lang['login'] = "Login";
|
||||
$lang['msg0001'] = "Versione in uso: %s";
|
||||
$lang['msg0001'] = "The Ranksystem is running on version: %s";
|
||||
$lang['msg0002'] = "I comandi validi sono:\n[B]help[/B], [B]info[/B], [B]commands[/B]\t\tvedi la lista dei comandi\n[B]version[/B]\t\t\t\t\t\t\t\t vedi la versione di Ranksystem\n[B]!clean[/B]\t\t\t\t\t\t\t\t\t start cleaning of the user database\n[B]!next[/B], [B]!nextup[/B]\t\t\t\t\t\t\t\t vedi il tempo rimasto per aumentare di rank\n[B]restart[/B], [B]reboot[/B]\t\t\t\t\tRiavvia il bot di Ranksystem\n[B]shutdown[/B], [B]quit[/B], [B]stop[/B]\t\t Arresta il bot del Ranksystem";
|
||||
$lang['msg0003'] = "Non sei idoneo per eseguire questo comando!";
|
||||
$lang['msg0004'] = "Il client %s (%s) ha richiesto uno shotdown.";
|
||||
@@ -531,7 +533,9 @@ $lang['wits3querpwdesc'] = "Password della query di Teamspeak (di norma viene cr
|
||||
$lang['wits3querusr'] = "TS3 - Utente della Query";
|
||||
$lang['wits3querusrdesc'] = "Il nome utente della Query scelta<br>Di default è serveradmin<br>Ma se preferisci potrai creare un ulteriore query solo per il Ranksystem.<br>Per vedere i permessi necessari alla Query guarda:<br>http://ts-n.net/ranksystem.php";
|
||||
$lang['wits3query'] = "TS3 - Porta della Query";
|
||||
$lang['wits3querydesc'] = "La porta per l'accesso delle query a Teamspeak<br>La porta di default è 10011 (TCP)<br>Se non è la porta di default e non sai che porta possa essere guarda all'interno del file 'ts3server.ini' nella directory principale del server Teamspeak dove troverai tutte le informazioni sul server.";
|
||||
$lang['wits3querydesc'] = "La porta per l'accesso delle query a Teamspeak<br>Default RAW (plain text) is 10011 (TCP)<br>Default SSH (encrypted) is 10022 (TCP)<br><br>Se non è la porta di default e non sai che porta possa essere guarda all'interno del file 'ts3server.ini' nella directory principale del server Teamspeak dove troverai tutte le informazioni sul server.";
|
||||
$lang['wits3encrypt'] = "TS3 Query encryption";
|
||||
$lang['wits3encryptdesc'] = "Activate this option to encrypt the communication between the Ranksystem and the TeamSpeak 3 server (SSH).<br>When this function is disabled, the communication will be done in plain text (RAW). This could be a security risk, especially when the TS3 server and the Ranksystem are running on different machines.<br><br>Be also sure, you have checked the TS3 Query Port, which needs (perhaps) to be changed in the Ranksystem!<br><br><b>Attention:</b> The SSH encryption needs more CPU time and with this truly more system resources. That's why we recommend to use a RAW connection (disabled encryption) if the TS3 server and the Ranksystem are running on the same machine / server (localhost / 127.0.0.1). If they are running on separate machines, you should activate the encrypted connection!<br><br><b>Requirements:</b><br><br>1) TS3 Server version 3.3.0 or above.<br><br>2) The PHP extension PHP-SSH2 is necessary.<br>On Linux you can it install with the following command:<br><pre>sudo apt-get install php-ssh2</pre><br>3) The encryption needs to be enabled on your TS3 server!<br>Activate the following parameters inside your 'ts3server.ini' and customize it for your needs:<br><pre>query_ssh_ip=0.0.0.0,::<br>query_ssh_port=10022<br>query_protocols=ssh,raw<br>query_ssh_rsa_host_key=ssh_host_rsa_key</pre>After changing your TS3 server configurations a restart of your TS3 server is necessary.";
|
||||
$lang['wits3voice'] = "TS3 - Voice-Port";
|
||||
$lang['wits3voicedesc'] = "La voice port del vostro Teamspeak<br>Di default è 9987 (UDP)<br>Questa è inoltre la porta con cui vi connettete al TS3.";
|
||||
$lang['wiverify'] = "Verification-Channel";
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
$lang = array();
|
||||
$lang['adduser'] = "Gebruiker %s (unieke Client-ID: %s; Client-database-ID %s) is onbekend -> zojuist toegevoegd aan ranksysteem.";
|
||||
$lang['brute'] = "Much incorrect logins detected on the webinterface. Blocked login for 300 seconds! Last access from IP %s.";
|
||||
$lang['brute1'] = "Incorrect login attempt on the webinterface detected. Failed access attempt from IP %s with username %s.";
|
||||
$lang['brute2'] = "Successful login attempt to the webinterface from IP %s.";
|
||||
$lang['changedbid'] = "Gebruiker %s (unieke Client-ID: %s) heeft een nieuwe TeamSpeak Client-database-ID (%s). Update de oude Client-database-ID (%s) en reset gecollecteerde tijden!";
|
||||
$lang['crawl'] = "Scannen naar geconnecte gebruikers en de activiteiten aan het optellen...";
|
||||
$lang['clean'] = "Scannen naar clients, die moeten worden verwijderd...";
|
||||
@@ -86,7 +88,7 @@ $lang['listsumi'] = "overzicht inactieve tijd";
|
||||
$lang['listsumo'] = "overzicht online tijd";
|
||||
$lang['listuid'] = "unieke Client-ID";
|
||||
$lang['login'] = "Inloggen";
|
||||
$lang['msg0001'] = "versie: %s";
|
||||
$lang['msg0001'] = "The Ranksystem is running on version: %s";
|
||||
$lang['msg0002'] = "Valid commands are:\n[B]!help[/B], [B]!info[/B], [B]!commands[/B]\t\t get a command list\n[B]!version[/B]\t\t\t\t\t\t\t\t get the Ranksystem version\n[B]!update[/B], [B]!checkupdate[/B]\t\t check for new version and run update\n[B]!clean[/B]\t\t\t\t\t\t\t\t\t start cleaning of the user database\n[B]!next[/B], [B]!nextup[/B]\t\t\t\t\t\t\t\t\tget the time to the next rank up\n[B]!restart[/B], [B]!reboot[/B]\t\t\t\t\trestart the Ranksystem bot\n[B]!shutdown[/B], [B]!quit[/B], [B]!stop[/B]\t\t stop the Ranksystem bot";
|
||||
$lang['msg0003'] = "Je bent niet in beschikking van deze commando!";
|
||||
$lang['msg0004'] = "Client %s (%s) verzoekt afsluiten.";
|
||||
@@ -531,7 +533,9 @@ $lang['wits3querpwdesc'] = "TeamSpeak 3 query password<br>Password for the query
|
||||
$lang['wits3querusr'] = "TS3 Query-User";
|
||||
$lang['wits3querusrdesc'] = "TeamSpeak 3 query username<br>Default is serveradmin<br>Of course, you can also create an additional serverquery account only for the Ranksystem.<br>The needed permissions you find on:<br>http://ts-n.net/ranksystem.php";
|
||||
$lang['wits3query'] = "TS3 Query-Port";
|
||||
$lang['wits3querydesc'] = "TeamSpeak 3 query port<br>Default is 10011 (TCP)<br>If its not default, you should find it in your 'ts3server.ini'.";
|
||||
$lang['wits3querydesc'] = "TeamSpeak 3 query port<br>Default RAW (plain text) is 10011 (TCP)<br>Default SSH (encrypted) is 10022 (TCP)<br><br>If its not default, you should find it in your 'ts3server.ini'.";
|
||||
$lang['wits3encrypt'] = "TS3 Query encryption";
|
||||
$lang['wits3encryptdesc'] = "Activate this option to encrypt the communication between the Ranksystem and the TeamSpeak 3 server (SSH).<br>When this function is disabled, the communication will be done in plain text (RAW). This could be a security risk, especially when the TS3 server and the Ranksystem are running on different machines.<br><br>Be also sure, you have checked the TS3 Query Port, which needs (perhaps) to be changed in the Ranksystem!<br><br><b>Attention:</b> The SSH encryption needs more CPU time and with this truly more system resources. That's why we recommend to use a RAW connection (disabled encryption) if the TS3 server and the Ranksystem are running on the same machine / server (localhost / 127.0.0.1). If they are running on separate machines, you should activate the encrypted connection!<br><br><b>Requirements:</b><br><br>1) TS3 Server version 3.3.0 or above.<br><br>2) The PHP extension PHP-SSH2 is necessary.<br>On Linux you can it install with the following command:<br><pre>sudo apt-get install php-ssh2</pre><br>3) The encryption needs to be enabled on your TS3 server!<br>Activate the following parameters inside your 'ts3server.ini' and customize it for your needs:<br><pre>query_ssh_ip=0.0.0.0,::<br>query_ssh_port=10022<br>query_protocols=ssh,raw<br>query_ssh_rsa_host_key=ssh_host_rsa_key</pre>After changing your TS3 server configurations a restart of your TS3 server is necessary.";
|
||||
$lang['wits3voice'] = "TS3 Voice-Port";
|
||||
$lang['wits3voicedesc'] = "TeamSpeak 3 voice port<br>Default is 9987 (UDP)<br>This is the port, you uses also to connect with the TS3 Client.";
|
||||
$lang['wiverify'] = "Verification-Channel";
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
$lang = array();
|
||||
$lang['adduser'] = "User %s (unique Client-ID: %s; Client-database-ID %s) is unknown -> added to the Ranksystem now.";
|
||||
$lang['brute'] = "Wykryto wiele niepoprawnych logowan na WWW Zablokowane logowanie przez 300 sekund! Ostatni dostep z IP% s.";
|
||||
$lang['brute1'] = "Incorrect login attempt on the webinterface detected. Failed access attempt from IP %s with username %s.";
|
||||
$lang['brute2'] = "Successful login attempt to the webinterface from IP %s.";
|
||||
$lang['changedbid'] = "Uzytkownik %s (unique Client-ID: %s) ma nowy identyfikator klienta TeamSpeak (%s). Zaktualizuj stary identyfikator bazy danych klienta (%s). i zresetuj zebrany czasy!";
|
||||
$lang['crawl'] = "Skanowanie dla podłączonych uzytkownikow i zliczanie aktywnosci...";
|
||||
$lang['clean'] = "Skanowanie w celu usuniecia klientow...";
|
||||
@@ -86,7 +88,7 @@ $lang['listsumi'] = "suma. czas bezczynnosci";
|
||||
$lang['listsumo'] = "suma. czas online";
|
||||
$lang['listuid'] = "unikalny identyfikator klienta";
|
||||
$lang['login'] = "Zaloguj Sie";
|
||||
$lang['msg0001'] = "Uruchomiona wersja: %s";
|
||||
$lang['msg0001'] = "The Ranksystem is running on version: %s";
|
||||
$lang['msg0002'] = "Prawidłowe polecenia to:\n[B]!help[/B], [B]!info[/B], [B]!commands[/B]\t\t otrzymują liste polecen\n[B]!version[/B]\t\t\t\t\t\t\t\t pobierz wersje systemu Ranksystem\n[B]!update[/B], [B]!checkupdate[/B]\t\t sprawdz dla nowej wersji i uruchamiania aktualizacji\n[B]!clean[/B]\t\t\t\t\t\t\t\t\t rozpoczyna czyszczenie bazy uzytkownikow\n[B]!next[/B], [B]!nextup[/B]\t\t\t\t\t\t\t\t\tget czas na kolejną range\n[B]!restart[/B], [B]!reboot[/B]\t\t\t\t\trestart bota Ranksystem\n[B]!shutdown[/B], [B]!quit[/B], [B]!stop[/B]\t\t zatrzymaj bota Ranksystem";
|
||||
$lang['msg0003'] = "Nie kwalifikujesz sie do tego polecenia!";
|
||||
$lang['msg0004'] = "Klient %s (%s) ząda zamkniecia systemu.";
|
||||
@@ -531,7 +533,9 @@ $lang['wits3querpwdesc'] = "Hasło do zapytania TeamSpeak 3<br>Hasło dla uzytko
|
||||
$lang['wits3querusr'] = "Uzytkownik zapytan TS3";
|
||||
$lang['wits3querusrdesc'] = "Nazwa uzytkownika zapytania TeamSpeak 3<br>Domyslna wartosc to serveradmin<br>Oczywiscie, mozesz takze utworzyc dodatkowe konto serwerowe tylko dla systemu Ranksystem.<br>Potrzebne uprawnienia, ktore mozna znalezc:<br>http://ts-n.net/ranksystem.php";
|
||||
$lang['wits3query'] = "TS-Query-Port";
|
||||
$lang['wits3querydesc'] = "Port zapytania TeamSpeak 3<br>Domyslna wartosc to 10011 (TCP)<br>Jesli nie jest domyslny, powinienes go znalezc w swoim 'ts3server.ini'.";
|
||||
$lang['wits3querydesc'] = "Port zapytania TeamSpeak 3<br>Default RAW (plain text) is 10011 (TCP)<br>Default SSH (encrypted) is 10022 (TCP)<br><br>Jesli nie jest domyslny, powinienes go znalezc w swoim 'ts3server.ini'.";
|
||||
$lang['wits3encrypt'] = "TS3 Query encryption";
|
||||
$lang['wits3encryptdesc'] = "Activate this option to encrypt the communication between the Ranksystem and the TeamSpeak 3 server (SSH).<br>When this function is disabled, the communication will be done in plain text (RAW). This could be a security risk, especially when the TS3 server and the Ranksystem are running on different machines.<br><br>Be also sure, you have checked the TS3 Query Port, which needs (perhaps) to be changed in the Ranksystem!<br><br><b>Attention:</b> The SSH encryption needs more CPU time and with this truly more system resources. That's why we recommend to use a RAW connection (disabled encryption) if the TS3 server and the Ranksystem are running on the same machine / server (localhost / 127.0.0.1). If they are running on separate machines, you should activate the encrypted connection!<br><br><b>Requirements:</b><br><br>1) TS3 Server version 3.3.0 or above.<br><br>2) The PHP extension PHP-SSH2 is necessary.<br>On Linux you can it install with the following command:<br><pre>sudo apt-get install php-ssh2</pre><br>3) The encryption needs to be enabled on your TS3 server!<br>Activate the following parameters inside your 'ts3server.ini' and customize it for your needs:<br><pre>query_ssh_ip=0.0.0.0,::<br>query_ssh_port=10022<br>query_protocols=ssh,raw<br>query_ssh_rsa_host_key=ssh_host_rsa_key</pre>After changing your TS3 server configurations a restart of your TS3 server is necessary.";
|
||||
$lang['wits3voice'] = "Port głosowy TS3";
|
||||
$lang['wits3voicedesc'] = "Port głosowy TeamSpeak 3<br>Domyslna wartosc to 9987 (UDP)<br>To jest port, ktorego uzywasz rowniez do łączenia sie z klientem TS3.";
|
||||
$lang['wiverify'] = "Weryfikacja - kanał";
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
$lang = array();
|
||||
$lang['adduser'] = "O usuário %s (ID-Ùnica: %s; Cliente-banco de dados-ID %s) é desconhecido -> adicionado ao sistema de ranking agora.";
|
||||
$lang['brute'] = "Muitos logins incorretos detectados na interface da web. Acesso bloqueado por 300 segundos! Último acesso pelo IP %s.";
|
||||
$lang['brute1'] = "Incorrect login attempt on the webinterface detected. Failed access attempt from IP %s with username %s.";
|
||||
$lang['brute2'] = "Successful login attempt to the webinterface from IP %s.";
|
||||
$lang['changedbid'] = "O usuário %s (ID-Ùnica:: %s) obteve um novo ID no banco de dados do teamspeak (%s). Atualize o antigo Client-banco de dados-ID (%s) e reinicie os tempos coletados!";
|
||||
$lang['crawl'] = "Procure o usuário conectado e conte a atividade...";
|
||||
$lang['clean'] = "Procurando por clientes, que devem ser excluidos...";
|
||||
@@ -86,7 +88,7 @@ $lang['listsumi'] = "Tempo total afk";
|
||||
$lang['listsumo'] = "Tempo total Online";
|
||||
$lang['listuid'] = "ID ùnica";
|
||||
$lang['login'] = "Entrar";
|
||||
$lang['msg0001'] = "versão em execução: %s";
|
||||
$lang['msg0001'] = "The Ranksystem is running on version: %s";
|
||||
$lang['msg0002'] = "Os comandos válidos são:\n[B]help[/B], [B]info[/B], [B]commands[/B]\t\tget a command list\n[B]version[/B]\t\t\t\t\t\t\t\t get the Ranksystem version\n[B]!clean[/B]\t\t\t\t\t\t\t\t\t start cleaning of the user database\n[B]!next[/B], [B]!nextup[/B]\t\t\t\t\t\t\t\t get the time to the next rank up\n[B]restart[/B], [B]reboot[/B]\t\t\t\t\trestart the Ranksystem bot\n[B]shutdown[/B], [B]quit[/B], [B]stop[/B]\t\t stop the Ranksystem bot";
|
||||
$lang['msg0003'] = "Você não é elegível para usar este comando!";
|
||||
$lang['msg0004'] = "Cliente %s (%s) fez o pedido de desligamento.";
|
||||
@@ -531,7 +533,9 @@ $lang['wits3querpwdesc'] = "TeamSpeak 3 senha query<br>Senha para o usuário da
|
||||
$lang['wits3querusr'] = "TS3 Usuário-query";
|
||||
$lang['wits3querusrdesc'] = "Nome de usuário da consulta TeamSpeak 3<br>O padrão é serveradmin<br>Claro, você também pode criar uma conta de serverquery adicional somente para o Sistema de ranking.<br>As permissões necessárias que você encontra em:<br>http://ts-n.net/ranksystem.php";
|
||||
$lang['wits3query'] = "TS3 Porta-query";
|
||||
$lang['wits3querydesc'] = "TeamSpeak 3 porta query<br>O padrão é 10011 (TCP)<br>Se não for padrão, você deve encontrar a sua em 'ts3server.ini'.";
|
||||
$lang['wits3querydesc'] = "TeamSpeak 3 porta query<br>Default RAW (plain text) is 10011 (TCP)<br>Default SSH (encrypted) is 10022 (TCP)<br><br>Se não for padrão, você deve encontrar a sua em 'ts3server.ini'.";
|
||||
$lang['wits3encrypt'] = "TS3 Query encryption";
|
||||
$lang['wits3encryptdesc'] = "Activate this option to encrypt the communication between the Ranksystem and the TeamSpeak 3 server (SSH).<br>When this function is disabled, the communication will be done in plain text (RAW). This could be a security risk, especially when the TS3 server and the Ranksystem are running on different machines.<br><br>Be also sure, you have checked the TS3 Query Port, which needs (perhaps) to be changed in the Ranksystem!<br><br><b>Attention:</b> The SSH encryption needs more CPU time and with this truly more system resources. That's why we recommend to use a RAW connection (disabled encryption) if the TS3 server and the Ranksystem are running on the same machine / server (localhost / 127.0.0.1). If they are running on separate machines, you should activate the encrypted connection!<br><br><b>Requirements:</b><br><br>1) TS3 Server version 3.3.0 or above.<br><br>2) The PHP extension PHP-SSH2 is necessary.<br>On Linux you can it install with the following command:<br><pre>sudo apt-get install php-ssh2</pre><br>3) The encryption needs to be enabled on your TS3 server!<br>Activate the following parameters inside your 'ts3server.ini' and customize it for your needs:<br><pre>query_ssh_ip=0.0.0.0,::<br>query_ssh_port=10022<br>query_protocols=ssh,raw<br>query_ssh_rsa_host_key=ssh_host_rsa_key</pre>After changing your TS3 server configurations a restart of your TS3 server is necessary.";
|
||||
$lang['wits3voice'] = "TS3 Porta de voz";
|
||||
$lang['wits3voicedesc'] = "TeamSpeak 3 porta de voz<br>O padrão é 9987 (UDP)<br>Esta é a porta, que você também usa para se conectar ao TS3 Client.";
|
||||
$lang['wiverify'] = "Verificação-Canal";
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
$lang = array();
|
||||
$lang['adduser'] = "Userul %s (unique Client-ID: %s; Client-database-ID %s) este necunoscut -> adaugat la Sistem Rank acum.";
|
||||
$lang['brute'] = "Au fost detectate prea multe conectari incorecte pe interfata web. Au fost blocate datele de conectare timp de 300 de secunde! Ultimul acces de pe IP: %s.";
|
||||
$lang['brute1'] = "Incorrect login attempt on the webinterface detected. Failed access attempt from IP %s with username %s.";
|
||||
$lang['brute2'] = "Successful login attempt to the webinterface from IP %s.";
|
||||
$lang['changedbid'] = "Userul %s (unique Client-ID: %s) a primit un noua identitate (%s). Actualizam vechea identitate (%s) ?i resetam timpul colectat!";
|
||||
$lang['crawl'] = "Scanam clientul conectat ?i contorizam activitatea...";
|
||||
$lang['clean'] = "Scanam clien?ii care trebuie ?ter?i...";
|
||||
@@ -86,7 +88,7 @@ $lang['listsumi'] = "sum. timpul de inactivitate";
|
||||
$lang['listsumo'] = "sum. timp online";
|
||||
$lang['listuid'] = "unique-ID";
|
||||
$lang['login'] = "Logare";
|
||||
$lang['msg0001'] = "versiune: %s";
|
||||
$lang['msg0001'] = "The Ranksystem is running on version: %s";
|
||||
$lang['msg0002'] = "Comenzi valide:\n[B]!help[/B], [B]!info[/B], [B]!commands[/B] - primeste lista de comenzi\n[B]!version[/B] - vezi versiunea sistemlui\n[B]!update[/B], [B]!checkupdate[/B] - incearca versiune noua\n[B]!clean[/B] - sterge userii din baza de date\n[B]!next[/B], [B]nextup[/B] - primeste timpul pentru urmatorul rank\n[B]!restart[/B], [B]!reboot[/B] - restart\n[B]!shutdown[/B], [B]!quit[/B], [B]!stop[/B] - stop";
|
||||
$lang['msg0003'] = "Nu ai acces pentru aceste comenzi!";
|
||||
$lang['msg0004'] = "Userul %s (%s) a oprit botul.";
|
||||
@@ -531,7 +533,9 @@ $lang['wits3querpwdesc'] = "TeamSpeak3 parola query<br>Parola pentru query.";
|
||||
$lang['wits3querusr'] = "TS3 nume query";
|
||||
$lang['wits3querusrdesc'] = "TeamSpeak3 nume query<br>Implicit este serveradmin<br>Desigur, pute?i crea, de asemenea, un cont suplimentar serverquery doar pentru sistemul Ranks.<br> Permisiile necesare pe care le gasi?i pe: http://ts-n.net/ranksystem.php";
|
||||
$lang['wits3query'] = "TS3 Query-Port";
|
||||
$lang['wits3querydesc'] = "TeamSpeak3 query port<br>Implicit este 10011 (TCP)<br>Daca acesta nu este implicit, il gasesti in \"ts3server.ini\".";
|
||||
$lang['wits3querydesc'] = "TeamSpeak3 query port<br>Default RAW (plain text) is 10011 (TCP)<br>Default SSH (encrypted) is 10022 (TCP)<br><br>Daca acesta nu este implicit, il gasesti in \"ts3server.ini\".";
|
||||
$lang['wits3encrypt'] = "TS3 Query encryption";
|
||||
$lang['wits3encryptdesc'] = "Activate this option to encrypt the communication between the Ranksystem and the TeamSpeak 3 server (SSH).<br>When this function is disabled, the communication will be done in plain text (RAW). This could be a security risk, especially when the TS3 server and the Ranksystem are running on different machines.<br><br>Be also sure, you have checked the TS3 Query Port, which needs (perhaps) to be changed in the Ranksystem!<br><br><b>Attention:</b> The SSH encryption needs more CPU time and with this truly more system resources. That's why we recommend to use a RAW connection (disabled encryption) if the TS3 server and the Ranksystem are running on the same machine / server (localhost / 127.0.0.1). If they are running on separate machines, you should activate the encrypted connection!<br><br><b>Requirements:</b><br><br>1) TS3 Server version 3.3.0 or above.<br><br>2) The PHP extension PHP-SSH2 is necessary.<br>On Linux you can it install with the following command:<br><pre>sudo apt-get install php-ssh2</pre><br>3) The encryption needs to be enabled on your TS3 server!<br>Activate the following parameters inside your 'ts3server.ini' and customize it for your needs:<br><pre>query_ssh_ip=0.0.0.0,::<br>query_ssh_port=10022<br>query_protocols=ssh,raw<br>query_ssh_rsa_host_key=ssh_host_rsa_key</pre>After changing your TS3 server configurations a restart of your TS3 server is necessary.";
|
||||
$lang['wits3voice'] = "TS3 Port";
|
||||
$lang['wits3voicedesc'] = "TeamSpeak3 port<br>Implicit este 9987 (UDP)<br>Acest port ajuta la conectarea userilor pe TS3.";
|
||||
$lang['wiverify'] = "Canal de verificare";
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
$lang = array();
|
||||
$lang['adduser'] = "Пользователь %s (UID: %s; DBID: %s) неизвестен и был успешно добавлен в базу данных системы рангов.";
|
||||
$lang['brute'] = "Слишком много некорректных попыток входа в веб-интерфейс. Вы были заблокированы на 300 секунд! Последний успешный вход был выполен с IP %s.";
|
||||
$lang['brute1'] = "Incorrect login attempt on the webinterface detected. Failed access attempt from IP %s with username %s.";
|
||||
$lang['brute2'] = "Successful login attempt to the webinterface from IP %s.";
|
||||
$lang['changedbid'] = "У пользователя %s (UID: %s) изменился TeamSpeak DBID (%s). Обновляем старый Client-DBID (%s) и сбрасываем ему старое время!";
|
||||
$lang['crawl'] = "Сканирование активности подключенных пользователей...";
|
||||
$lang['clean'] = "Сканирование пользователей, подлежащих удалению из базы системы рангов...";
|
||||
@@ -86,7 +88,7 @@ $lang['listsumi'] = "Сумм. время простоя";
|
||||
$lang['listsumo'] = "Сумм. время подключения";
|
||||
$lang['listuid'] = "Уникальный ID клиента(UID)";
|
||||
$lang['login'] = "Авторизоваться";
|
||||
$lang['msg0001'] = "используемая версия: %s";
|
||||
$lang['msg0001'] = "The Ranksystem is running on version: %s";
|
||||
$lang['msg0002'] = "Список доступных команд:\n[B]help[/B], [B]info[/B], [B]commands[/B]\t\t выводят список доступных команд\n[B]version[/B]\t\t\t\t\t\t\t\t выводит информацию о версии системы рангов\n[B]!update[/B], [B]!checkupdate[/B]\t\t check for new version and run update\n[B]!clean[/B]\t\t\t\t\t\t\t\t\t start cleaning of the user database\n[B]!next[/B], [B]!nextup[/B]\t\t\t\t\t\t выводит время, через которое произойдет повышение ранга\n[B]restart[/B], [B]reboot[/B]\t\t\t\t\tперезапускают систему рангов\n[B]shutdown[/B], [B]quit[/B], [B]stop[/B]\t\t выключают систему рангов";
|
||||
$lang['msg0003'] = "У вас нет доступа для выполнения данной команды!";
|
||||
$lang['msg0004'] = "Клиент %s (%s) выключил систему рангов.";
|
||||
@@ -531,7 +533,9 @@ $lang['wits3querpwdesc'] = "TeamSpeak 3 query-Пароль<br>Ваш парол
|
||||
$lang['wits3querusr'] = "TS3 Query-Логин";
|
||||
$lang['wits3querusrdesc'] = "TeamSpeak 3 query-Логин<br>По умолчанию: serveradmin<br>Конечно вы можете указать другой логин для системы рангов.<br>Необходимые разрешения привилегий вы можете найти на:<br>//ts-n.net/ranksystem.php";
|
||||
$lang['wits3query'] = "TS3 Query-Порт";
|
||||
$lang['wits3querydesc'] = "TeamSpeak 3 query-Порт<br>По умолчанию: 10011 (TCP)<br>Если порт изменен, то укажите его согласно настройкам из 'ts3server.ini'.";
|
||||
$lang['wits3querydesc'] = "TeamSpeak 3 query-Порт<br>Default RAW (plain text) is 10011 (TCP)<br>Default SSH (encrypted) is 10022 (TCP)<br><br>Если порт изменен, то укажите его согласно настройкам из 'ts3server.ini'.";
|
||||
$lang['wits3encrypt'] = "TS3 Query encryption";
|
||||
$lang['wits3encryptdesc'] = "Activate this option to encrypt the communication between the Ranksystem and the TeamSpeak 3 server (SSH).<br>When this function is disabled, the communication will be done in plain text (RAW). This could be a security risk, especially when the TS3 server and the Ranksystem are running on different machines.<br><br>Be also sure, you have checked the TS3 Query Port, which needs (perhaps) to be changed in the Ranksystem!<br><br><b>Attention:</b> The SSH encryption needs more CPU time and with this truly more system resources. That's why we recommend to use a RAW connection (disabled encryption) if the TS3 server and the Ranksystem are running on the same machine / server (localhost / 127.0.0.1). If they are running on separate machines, you should activate the encrypted connection!<br><br><b>Requirements:</b><br><br>1) TS3 Server version 3.3.0 or above.<br><br>2) The PHP extension PHP-SSH2 is necessary.<br>On Linux you can it install with the following command:<br><pre>sudo apt-get install php-ssh2</pre><br>3) The encryption needs to be enabled on your TS3 server!<br>Activate the following parameters inside your 'ts3server.ini' and customize it for your needs:<br><pre>query_ssh_ip=0.0.0.0,::<br>query_ssh_port=10022<br>query_protocols=ssh,raw<br>query_ssh_rsa_host_key=ssh_host_rsa_key</pre>After changing your TS3 server configurations a restart of your TS3 server is necessary.";
|
||||
$lang['wits3voice'] = "TS3 Voice-Порт";
|
||||
$lang['wits3voicedesc'] = "TeamSpeak 3 voice-Порт<br>По умолчанию: 9987 (UDP)<br>Этот порт используется Teamspeak 3 клиентом для подключения к серверу.";
|
||||
$lang['wiverify'] = "Канал для верификации";
|
||||
|
||||
@@ -1,157 +1,157 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Adapter_Abstract
|
||||
* @brief Provides low-level methods for concrete adapters to communicate with a TeamSpeak 3 Server.
|
||||
*/
|
||||
abstract class TeamSpeak3_Adapter_Abstract
|
||||
{
|
||||
/**
|
||||
* Stores user-provided options.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $options = null;
|
||||
|
||||
/**
|
||||
* Stores an TeamSpeak3_Transport_Abstract object.
|
||||
*
|
||||
* @var TeamSpeak3_Transport_Abstract
|
||||
*/
|
||||
protected $transport = null;
|
||||
|
||||
/**
|
||||
* The TeamSpeak3_Adapter_Abstract constructor.
|
||||
*
|
||||
* @param array $options
|
||||
* @return TeamSpeak3_Adapter_Abstract
|
||||
*/
|
||||
public function __construct(array $options)
|
||||
{
|
||||
$this->options = $options;
|
||||
|
||||
if($this->transport === null)
|
||||
{
|
||||
$this->syn();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The TeamSpeak3_Adapter_Abstract destructor.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
abstract public function __destruct();
|
||||
|
||||
/**
|
||||
* Connects the TeamSpeak3_Transport_Abstract object and performs initial actions on the remote
|
||||
* server.
|
||||
*
|
||||
* @throws TeamSpeak3_Adapter_Exception
|
||||
* @return void
|
||||
*/
|
||||
abstract protected function syn();
|
||||
|
||||
/**
|
||||
* Commit pending data.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function __sleep()
|
||||
{
|
||||
return array("options");
|
||||
}
|
||||
|
||||
/**
|
||||
* Reconnects to the remote server.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __wakeup()
|
||||
{
|
||||
$this->syn();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the profiler timer used for this connection adapter.
|
||||
*
|
||||
* @return TeamSpeak3_Helper_Profiler_Timer
|
||||
*/
|
||||
public function getProfiler()
|
||||
{
|
||||
return TeamSpeak3_Helper_Profiler::get(spl_object_hash($this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the transport object used for this connection adapter.
|
||||
*
|
||||
* @return TeamSpeak3_Transport_Abstract
|
||||
*/
|
||||
public function getTransport()
|
||||
{
|
||||
return $this->transport;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the transport object object used for the connection adapter and passes a given set
|
||||
* of options.
|
||||
*
|
||||
* @param array $options
|
||||
* @param string $transport
|
||||
* @throws TeamSpeak3_Adapter_Exception
|
||||
* @return void
|
||||
*/
|
||||
protected function initTransport($options, $transport = "TeamSpeak3_Transport_TCP")
|
||||
{
|
||||
if(!is_array($options))
|
||||
{
|
||||
throw new TeamSpeak3_Adapter_Exception("transport parameters must provided in an array");
|
||||
}
|
||||
|
||||
$this->transport = new $transport($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hostname or IPv4 address the underlying TeamSpeak3_Transport_Abstract object
|
||||
* is connected to.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTransportHost()
|
||||
{
|
||||
return $this->getTransport()->getConfig("host", "0.0.0.0");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the port number of the server the underlying TeamSpeak3_Transport_Abstract object
|
||||
* is connected to.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTransportPort()
|
||||
{
|
||||
return $this->getTransport()->getConfig("port", "0");
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Adapter_Abstract
|
||||
* @brief Provides low-level methods for concrete adapters to communicate with a TeamSpeak 3 Server.
|
||||
*/
|
||||
abstract class TeamSpeak3_Adapter_Abstract
|
||||
{
|
||||
/**
|
||||
* Stores user-provided options.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $options = null;
|
||||
|
||||
/**
|
||||
* Stores an TeamSpeak3_Transport_Abstract object.
|
||||
*
|
||||
* @var TeamSpeak3_Transport_Abstract
|
||||
*/
|
||||
protected $transport = null;
|
||||
|
||||
/**
|
||||
* The TeamSpeak3_Adapter_Abstract constructor.
|
||||
*
|
||||
* @param array $options
|
||||
* @return TeamSpeak3_Adapter_Abstract
|
||||
*/
|
||||
public function __construct(array $options)
|
||||
{
|
||||
$this->options = $options;
|
||||
|
||||
if($this->transport === null)
|
||||
{
|
||||
$this->syn();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The TeamSpeak3_Adapter_Abstract destructor.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
abstract public function __destruct();
|
||||
|
||||
/**
|
||||
* Connects the TeamSpeak3_Transport_Abstract object and performs initial actions on the remote
|
||||
* server.
|
||||
*
|
||||
* @throws TeamSpeak3_Adapter_Exception
|
||||
* @return void
|
||||
*/
|
||||
abstract protected function syn();
|
||||
|
||||
/**
|
||||
* Commit pending data.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function __sleep()
|
||||
{
|
||||
return array("options");
|
||||
}
|
||||
|
||||
/**
|
||||
* Reconnects to the remote server.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __wakeup()
|
||||
{
|
||||
$this->syn();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the profiler timer used for this connection adapter.
|
||||
*
|
||||
* @return TeamSpeak3_Helper_Profiler_Timer
|
||||
*/
|
||||
public function getProfiler()
|
||||
{
|
||||
return TeamSpeak3_Helper_Profiler::get(spl_object_hash($this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the transport object used for this connection adapter.
|
||||
*
|
||||
* @return TeamSpeak3_Transport_Abstract
|
||||
*/
|
||||
public function getTransport()
|
||||
{
|
||||
return $this->transport;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the transport object object used for the connection adapter and passes a given set
|
||||
* of options.
|
||||
*
|
||||
* @param array $options
|
||||
* @param string $transport
|
||||
* @throws TeamSpeak3_Adapter_Exception
|
||||
* @return void
|
||||
*/
|
||||
protected function initTransport($options, $transport = "TeamSpeak3_Transport_TCP")
|
||||
{
|
||||
if(!is_array($options))
|
||||
{
|
||||
throw new TeamSpeak3_Adapter_Exception("transport parameters must provided in an array");
|
||||
}
|
||||
|
||||
$this->transport = new $transport($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hostname or IPv4 address the underlying TeamSpeak3_Transport_Abstract object
|
||||
* is connected to.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTransportHost()
|
||||
{
|
||||
return $this->getTransport()->getConfig("host", "0.0.0.0");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the port number of the server the underlying TeamSpeak3_Transport_Abstract object
|
||||
* is connected to.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTransportPort()
|
||||
{
|
||||
return $this->getTransport()->getConfig("port", "0");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,119 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* $Id: Blacklist.php 06/06/2016 22:27:13 scp@Svens-iMac $
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @version 1.1.24
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) 2010 by Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Adapter_Blacklist
|
||||
* @brief Provides methods to check if an IP address is currently blacklisted.
|
||||
*/
|
||||
class TeamSpeak3_Adapter_Blacklist extends TeamSpeak3_Adapter_Abstract
|
||||
{
|
||||
/**
|
||||
* The IPv4 address or FQDN of the TeamSpeak Systems update server.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $default_host = "blacklist.teamspeak.com";
|
||||
|
||||
/**
|
||||
* The UDP port number of the TeamSpeak Systems update server.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $default_port = 17385;
|
||||
|
||||
/**
|
||||
* Stores an array containing the latest build numbers.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $build_numbers = null;
|
||||
|
||||
/**
|
||||
* Connects the TeamSpeak3_Transport_Abstract object and performs initial actions on the remote
|
||||
* server.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function syn()
|
||||
{
|
||||
if(!isset($this->options["host"]) || empty($this->options["host"])) $this->options["host"] = $this->default_host;
|
||||
if(!isset($this->options["port"]) || empty($this->options["port"])) $this->options["port"] = $this->default_port;
|
||||
|
||||
$this->initTransport($this->options, "TeamSpeak3_Transport_UDP");
|
||||
$this->transport->setAdapter($this);
|
||||
|
||||
TeamSpeak3_Helper_Profiler::init(spl_object_hash($this));
|
||||
|
||||
TeamSpeak3_Helper_Signal::getInstance()->emit("blacklistConnected", $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* The TeamSpeak3_Adapter_Blacklist destructor.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
if($this->getTransport() instanceof TeamSpeak3_Transport_Abstract && $this->getTransport()->isConnected())
|
||||
{
|
||||
$this->getTransport()->disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns TRUE if a specified $host IP address is currently blacklisted.
|
||||
*
|
||||
* @param string $host
|
||||
* @throws TeamSpeak3_Adapter_Blacklist_Exception
|
||||
* @return boolean
|
||||
*/
|
||||
public function isBlacklisted($host)
|
||||
{
|
||||
if(ip2long($host) === FALSE)
|
||||
{
|
||||
$addr = gethostbyname($host);
|
||||
|
||||
if($addr == $host)
|
||||
{
|
||||
throw new TeamSpeak3_Adapter_Blacklist_Exception("unable to resolve IPv4 address (" . $host . ")");
|
||||
}
|
||||
|
||||
$host = $addr;
|
||||
}
|
||||
|
||||
$this->getTransport()->send("ip4:" . $host);
|
||||
$repl = $this->getTransport()->read(1);
|
||||
$this->getTransport()->disconnect();
|
||||
|
||||
if(!count($repl))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return ($repl->toInt()) ? FALSE : TRUE;
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* $Id: Exception.php 06/06/2016 22:27:13 scp@Svens-iMac $
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @version 1.1.24
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) 2010 by Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Adapter_Blacklist_Exception
|
||||
* @brief Enhanced exception class for TeamSpeak3_Adapter_Blacklist objects.
|
||||
*/
|
||||
class TeamSpeak3_Adapter_Blacklist_Exception extends TeamSpeak3_Adapter_Exception {}
|
||||
@@ -1,29 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Adapter_Exception
|
||||
* @brief Enhanced exception class for TeamSpeak3_Adapter_Abstract objects.
|
||||
*/
|
||||
class TeamSpeak3_Adapter_Exception extends TeamSpeak3_Exception {}
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Adapter_Exception
|
||||
* @brief Enhanced exception class for TeamSpeak3_Adapter_Abstract objects.
|
||||
*/
|
||||
class TeamSpeak3_Adapter_Exception extends TeamSpeak3_Exception {}
|
||||
|
||||
@@ -1,187 +1,187 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Adapter_FileTransfer
|
||||
* @brief Provides low-level methods for file transfer communication with a TeamSpeak 3 Server.
|
||||
*/
|
||||
class TeamSpeak3_Adapter_FileTransfer extends TeamSpeak3_Adapter_Abstract
|
||||
{
|
||||
/**
|
||||
* Connects the TeamSpeak3_Transport_Abstract object and performs initial actions on the remote
|
||||
* server.
|
||||
*
|
||||
* @throws TeamSpeak3_Adapter_Exception
|
||||
* @return void
|
||||
*/
|
||||
public function syn()
|
||||
{
|
||||
$this->initTransport($this->options);
|
||||
$this->transport->setAdapter($this);
|
||||
|
||||
TeamSpeak3_Helper_Profiler::init(spl_object_hash($this));
|
||||
|
||||
TeamSpeak3_Helper_Signal::getInstance()->emit("filetransferConnected", $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* The TeamSpeak3_Adapter_FileTransfer destructor.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
if($this->getTransport() instanceof TeamSpeak3_Transport_Abstract && $this->getTransport()->isConnected())
|
||||
{
|
||||
$this->getTransport()->disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a valid file transfer key to the server to initialize the file transfer.
|
||||
*
|
||||
* @param string $ftkey
|
||||
* @throws TeamSpeak3_Adapter_FileTransfer_Exception
|
||||
* @return void
|
||||
*/
|
||||
protected function init($ftkey)
|
||||
{
|
||||
if(strlen($ftkey) != 32 && strlen($ftkey) != 16)
|
||||
{
|
||||
throw new TeamSpeak3_Adapter_FileTransfer_Exception("invalid file transfer key format");
|
||||
}
|
||||
|
||||
$this->getProfiler()->start();
|
||||
$this->getTransport()->send($ftkey);
|
||||
|
||||
TeamSpeak3_Helper_Signal::getInstance()->emit("filetransferHandshake", $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the content of a file to the server.
|
||||
*
|
||||
* @param string $ftkey
|
||||
* @param integer $seek
|
||||
* @param string $data
|
||||
* @throws TeamSpeak3_Adapter_FileTransfer_Exception
|
||||
* @return void
|
||||
*/
|
||||
public function upload($ftkey, $seek, $data)
|
||||
{
|
||||
$this->init($ftkey);
|
||||
|
||||
$size = strlen($data);
|
||||
$seek = intval($seek);
|
||||
$pack = 4096;
|
||||
|
||||
TeamSpeak3_Helper_Signal::getInstance()->emit("filetransferUploadStarted", $ftkey, $seek, $size);
|
||||
|
||||
for(;$seek < $size;)
|
||||
{
|
||||
$rest = $size-$seek;
|
||||
$pack = $rest < $pack ? $rest : $pack;
|
||||
$buff = substr($data, $seek, $pack);
|
||||
$seek = $seek+$pack;
|
||||
|
||||
$this->getTransport()->send($buff);
|
||||
|
||||
TeamSpeak3_Helper_Signal::getInstance()->emit("filetransferUploadProgress", $ftkey, $seek, $size);
|
||||
}
|
||||
|
||||
$this->getProfiler()->stop();
|
||||
|
||||
TeamSpeak3_Helper_Signal::getInstance()->emit("filetransferUploadFinished", $ftkey, $seek, $size);
|
||||
|
||||
if($seek < $size)
|
||||
{
|
||||
throw new TeamSpeak3_Adapter_FileTransfer_Exception("incomplete file upload (" . $seek . " of " . $size . " bytes)");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the content of a downloaded file as a TeamSpeak3_Helper_String object.
|
||||
*
|
||||
* @param string $ftkey
|
||||
* @param integer $size
|
||||
* @param boolean $passthru
|
||||
* @throws TeamSpeak3_Adapter_FileTransfer_Exception
|
||||
* @return TeamSpeak3_Helper_String
|
||||
*/
|
||||
public function download($ftkey, $size, $passthru = FALSE)
|
||||
{
|
||||
$this->init($ftkey);
|
||||
|
||||
if($passthru)
|
||||
{
|
||||
return $this->passthru($size);
|
||||
}
|
||||
|
||||
$buff = new TeamSpeak3_Helper_String("");
|
||||
$size = intval($size);
|
||||
$pack = 4096;
|
||||
|
||||
TeamSpeak3_Helper_Signal::getInstance()->emit("filetransferDownloadStarted", $ftkey, count($buff), $size);
|
||||
|
||||
for($seek = 0;$seek < $size;)
|
||||
{
|
||||
$rest = $size-$seek;
|
||||
$pack = $rest < $pack ? $rest : $pack;
|
||||
$data = $this->getTransport()->read($rest < $pack ? $rest : $pack);
|
||||
$seek = $seek+$pack;
|
||||
|
||||
$buff->append($data);
|
||||
|
||||
TeamSpeak3_Helper_Signal::getInstance()->emit("filetransferDownloadProgress", $ftkey, count($buff), $size);
|
||||
}
|
||||
|
||||
$this->getProfiler()->stop();
|
||||
|
||||
TeamSpeak3_Helper_Signal::getInstance()->emit("filetransferDownloadFinished", $ftkey, count($buff), $size);
|
||||
|
||||
if(strlen($buff) != $size)
|
||||
{
|
||||
throw new TeamSpeak3_Adapter_FileTransfer_Exception("incomplete file download (" . count($buff) . " of " . $size . " bytes)");
|
||||
}
|
||||
|
||||
return $buff;
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs all remaining data on a TeamSpeak 3 file transfer stream using PHP's fpassthru()
|
||||
* function.
|
||||
*
|
||||
* @param integer $size
|
||||
* @throws TeamSpeak3_Adapter_FileTransfer_Exception
|
||||
* @return void
|
||||
*/
|
||||
protected function passthru($size)
|
||||
{
|
||||
$buff_size = fpassthru($this->getTransport()->getStream());
|
||||
|
||||
if($buff_size != $size)
|
||||
{
|
||||
throw new TeamSpeak3_Adapter_FileTransfer_Exception("incomplete file download (" . intval($buff_size) . " of " . $size . " bytes)");
|
||||
}
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Adapter_FileTransfer
|
||||
* @brief Provides low-level methods for file transfer communication with a TeamSpeak 3 Server.
|
||||
*/
|
||||
class TeamSpeak3_Adapter_FileTransfer extends TeamSpeak3_Adapter_Abstract
|
||||
{
|
||||
/**
|
||||
* Connects the TeamSpeak3_Transport_Abstract object and performs initial actions on the remote
|
||||
* server.
|
||||
*
|
||||
* @throws TeamSpeak3_Adapter_Exception
|
||||
* @return void
|
||||
*/
|
||||
public function syn()
|
||||
{
|
||||
$this->initTransport($this->options);
|
||||
$this->transport->setAdapter($this);
|
||||
|
||||
TeamSpeak3_Helper_Profiler::init(spl_object_hash($this));
|
||||
|
||||
TeamSpeak3_Helper_Signal::getInstance()->emit("filetransferConnected", $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* The TeamSpeak3_Adapter_FileTransfer destructor.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
if($this->getTransport() instanceof TeamSpeak3_Transport_Abstract && $this->getTransport()->isConnected())
|
||||
{
|
||||
$this->getTransport()->disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a valid file transfer key to the server to initialize the file transfer.
|
||||
*
|
||||
* @param string $ftkey
|
||||
* @throws TeamSpeak3_Adapter_FileTransfer_Exception
|
||||
* @return void
|
||||
*/
|
||||
protected function init($ftkey)
|
||||
{
|
||||
if(strlen($ftkey) != 32 && strlen($ftkey) != 16)
|
||||
{
|
||||
throw new TeamSpeak3_Adapter_FileTransfer_Exception("invalid file transfer key format");
|
||||
}
|
||||
|
||||
$this->getProfiler()->start();
|
||||
$this->getTransport()->send($ftkey);
|
||||
|
||||
TeamSpeak3_Helper_Signal::getInstance()->emit("filetransferHandshake", $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the content of a file to the server.
|
||||
*
|
||||
* @param string $ftkey
|
||||
* @param integer $seek
|
||||
* @param string $data
|
||||
* @throws TeamSpeak3_Adapter_FileTransfer_Exception
|
||||
* @return void
|
||||
*/
|
||||
public function upload($ftkey, $seek, $data)
|
||||
{
|
||||
$this->init($ftkey);
|
||||
|
||||
$size = strlen($data);
|
||||
$seek = intval($seek);
|
||||
$pack = 4096;
|
||||
|
||||
TeamSpeak3_Helper_Signal::getInstance()->emit("filetransferUploadStarted", $ftkey, $seek, $size);
|
||||
|
||||
for(;$seek < $size;)
|
||||
{
|
||||
$rest = $size-$seek;
|
||||
$pack = $rest < $pack ? $rest : $pack;
|
||||
$buff = substr($data, $seek, $pack);
|
||||
$seek = $seek+$pack;
|
||||
|
||||
$this->getTransport()->send($buff);
|
||||
|
||||
TeamSpeak3_Helper_Signal::getInstance()->emit("filetransferUploadProgress", $ftkey, $seek, $size);
|
||||
}
|
||||
|
||||
$this->getProfiler()->stop();
|
||||
|
||||
TeamSpeak3_Helper_Signal::getInstance()->emit("filetransferUploadFinished", $ftkey, $seek, $size);
|
||||
|
||||
if($seek < $size)
|
||||
{
|
||||
throw new TeamSpeak3_Adapter_FileTransfer_Exception("incomplete file upload (" . $seek . " of " . $size . " bytes)");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the content of a downloaded file as a TeamSpeak3_Helper_String object.
|
||||
*
|
||||
* @param string $ftkey
|
||||
* @param integer $size
|
||||
* @param boolean $passthru
|
||||
* @throws TeamSpeak3_Adapter_FileTransfer_Exception
|
||||
* @return TeamSpeak3_Helper_String
|
||||
*/
|
||||
public function download($ftkey, $size, $passthru = FALSE)
|
||||
{
|
||||
$this->init($ftkey);
|
||||
|
||||
if($passthru)
|
||||
{
|
||||
return $this->passthru($size);
|
||||
}
|
||||
|
||||
$buff = new TeamSpeak3_Helper_String("");
|
||||
$size = intval($size);
|
||||
$pack = 4096;
|
||||
|
||||
TeamSpeak3_Helper_Signal::getInstance()->emit("filetransferDownloadStarted", $ftkey, count($buff), $size);
|
||||
|
||||
for($seek = 0;$seek < $size;)
|
||||
{
|
||||
$rest = $size-$seek;
|
||||
$pack = $rest < $pack ? $rest : $pack;
|
||||
$data = $this->getTransport()->read($rest < $pack ? $rest : $pack);
|
||||
$seek = $seek+$pack;
|
||||
|
||||
$buff->append($data);
|
||||
|
||||
TeamSpeak3_Helper_Signal::getInstance()->emit("filetransferDownloadProgress", $ftkey, count($buff), $size);
|
||||
}
|
||||
|
||||
$this->getProfiler()->stop();
|
||||
|
||||
TeamSpeak3_Helper_Signal::getInstance()->emit("filetransferDownloadFinished", $ftkey, count($buff), $size);
|
||||
|
||||
if(strlen($buff) != $size)
|
||||
{
|
||||
throw new TeamSpeak3_Adapter_FileTransfer_Exception("incomplete file download (" . count($buff) . " of " . $size . " bytes)");
|
||||
}
|
||||
|
||||
return $buff;
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs all remaining data on a TeamSpeak 3 file transfer stream using PHP's fpassthru()
|
||||
* function.
|
||||
*
|
||||
* @param integer $size
|
||||
* @throws TeamSpeak3_Adapter_FileTransfer_Exception
|
||||
* @return void
|
||||
*/
|
||||
protected function passthru($size)
|
||||
{
|
||||
$buff_size = fpassthru($this->getTransport()->getStream());
|
||||
|
||||
if($buff_size != $size)
|
||||
{
|
||||
throw new TeamSpeak3_Adapter_FileTransfer_Exception("incomplete file download (" . intval($buff_size) . " of " . $size . " bytes)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Adapter_FileTransfer_Exception
|
||||
* @brief Enhanced exception class for TeamSpeak3_Adapter_FileTransfer objects.
|
||||
*/
|
||||
class TeamSpeak3_Adapter_FileTransfer_Exception extends TeamSpeak3_Adapter_Exception {}
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Adapter_FileTransfer_Exception
|
||||
* @brief Enhanced exception class for TeamSpeak3_Adapter_FileTransfer objects.
|
||||
*/
|
||||
class TeamSpeak3_Adapter_FileTransfer_Exception extends TeamSpeak3_Adapter_Exception {}
|
||||
|
||||
@@ -1,260 +1,260 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Adapter_ServerQuery
|
||||
* @brief Provides low-level methods for ServerQuery communication with a TeamSpeak 3 Server.
|
||||
*/
|
||||
class TeamSpeak3_Adapter_ServerQuery extends TeamSpeak3_Adapter_Abstract
|
||||
{
|
||||
/**
|
||||
* Stores a singleton instance of the active TeamSpeak3_Node_Host object.
|
||||
*
|
||||
* @var TeamSpeak3_Node_Host
|
||||
*/
|
||||
protected $host = null;
|
||||
|
||||
/**
|
||||
* Stores the timestamp of the last command.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $timer = null;
|
||||
|
||||
/**
|
||||
* Number of queries executed on the server.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $count = 0;
|
||||
|
||||
/**
|
||||
* Stores an array with unsupported commands.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $block = array("help");
|
||||
|
||||
/**
|
||||
* Connects the TeamSpeak3_Transport_Abstract object and performs initial actions on the remote
|
||||
* server.
|
||||
*
|
||||
* @throws TeamSpeak3_Adapter_Exception
|
||||
* @return void
|
||||
*/
|
||||
protected function syn()
|
||||
{
|
||||
$this->initTransport($this->options);
|
||||
$this->transport->setAdapter($this);
|
||||
|
||||
TeamSpeak3_Helper_Profiler::init(spl_object_hash($this));
|
||||
|
||||
$rdy = $this->getTransport()->readLine();
|
||||
|
||||
if(!$rdy->startsWith(TeamSpeak3::TS3_PROTO_IDENT) && !$rdy->startsWith(TeamSpeak3::TEA_PROTO_IDENT) && !(defined("CUSTOM_PROTO_IDENT") && $rdy->startsWith(CUSTOM_PROTO_IDENT)))
|
||||
{
|
||||
throw new TeamSpeak3_Adapter_Exception("invalid reply from the server (" . $rdy . ")");
|
||||
}
|
||||
|
||||
TeamSpeak3_Helper_Signal::getInstance()->emit("serverqueryConnected", $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* The TeamSpeak3_Adapter_ServerQuery destructor.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
if($this->getTransport() instanceof TeamSpeak3_Transport_Abstract && $this->transport->isConnected())
|
||||
{
|
||||
try
|
||||
{
|
||||
$this->request("quit");
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a prepared command to the server and returns the result.
|
||||
*
|
||||
* @param string $cmd
|
||||
* @param boolean $throw
|
||||
* @throws TeamSpeak3_Adapter_Exception
|
||||
* @return TeamSpeak3_Adapter_ServerQuery_Reply
|
||||
*/
|
||||
public function request($cmd, $throw = TRUE)
|
||||
{
|
||||
$query = TeamSpeak3_Helper_String::factory($cmd)->section(TeamSpeak3::SEPARATOR_CELL);
|
||||
|
||||
if(strstr($cmd, "\r") || strstr($cmd, "\n"))
|
||||
{
|
||||
throw new TeamSpeak3_Adapter_Exception("illegal characters in command '" . $query . "'");
|
||||
}
|
||||
elseif(in_array($query, $this->block))
|
||||
{
|
||||
throw new TeamSpeak3_Adapter_ServerQuery_Exception("command not found", 0x100);
|
||||
}
|
||||
|
||||
TeamSpeak3_Helper_Signal::getInstance()->emit("serverqueryCommandStarted", $cmd);
|
||||
|
||||
$this->getProfiler()->start();
|
||||
$this->getTransport()->sendLine($cmd);
|
||||
$this->timer = time();
|
||||
$this->count++;
|
||||
|
||||
$rpl = array();
|
||||
|
||||
do {
|
||||
$str = $this->getTransport()->readLine();
|
||||
$rpl[] = $str;
|
||||
} while($str instanceof TeamSpeak3_Helper_String && $str->section(TeamSpeak3::SEPARATOR_CELL) != TeamSpeak3::ERROR);
|
||||
|
||||
$this->getProfiler()->stop();
|
||||
|
||||
$reply = new TeamSpeak3_Adapter_ServerQuery_Reply($rpl, $cmd, $this->getHost(), $throw);
|
||||
|
||||
TeamSpeak3_Helper_Signal::getInstance()->emit("serverqueryCommandFinished", $cmd, $reply);
|
||||
|
||||
return $reply;
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits for the server to send a notification message and returns the result.
|
||||
*
|
||||
* @throws TeamSpeak3_Adapter_Exception
|
||||
* @return TeamSpeak3_Adapter_ServerQuery_Event
|
||||
*/
|
||||
public function wait()
|
||||
{
|
||||
if($this->getTransport()->getConfig("blocking"))
|
||||
{
|
||||
throw new TeamSpeak3_Adapter_Exception("only available in non-blocking mode");
|
||||
}
|
||||
|
||||
do {
|
||||
$evt = $this->getTransport()->readLine();
|
||||
} while($evt instanceof TeamSpeak3_Helper_String && !$evt->section(TeamSpeak3::SEPARATOR_CELL)->startsWith(TeamSpeak3::EVENT));
|
||||
|
||||
return new TeamSpeak3_Adapter_ServerQuery_Event($evt, $this->getHost());
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses given parameters and returns a prepared ServerQuery command.
|
||||
*
|
||||
* @param string $cmd
|
||||
* @param array $params
|
||||
* @return string
|
||||
*/
|
||||
public function prepare($cmd, array $params = array())
|
||||
{
|
||||
$args = array();
|
||||
$cells = array();
|
||||
|
||||
foreach($params as $ident => $value)
|
||||
{
|
||||
$ident = is_numeric($ident) ? "" : strtolower($ident) . TeamSpeak3::SEPARATOR_PAIR;
|
||||
|
||||
if(is_array($value))
|
||||
{
|
||||
$value = array_values($value);
|
||||
|
||||
for($i = 0; $i < count($value); $i++)
|
||||
{
|
||||
if($value[$i] === null) continue;
|
||||
elseif($value[$i] === FALSE) $value[$i] = 0x00;
|
||||
elseif($value[$i] === TRUE) $value[$i] = 0x01;
|
||||
elseif($value[$i] instanceof TeamSpeak3_Node_Abstract) $value[$i] = $value[$i]->getId();
|
||||
|
||||
$cells[$i][] = $ident . TeamSpeak3_Helper_String::factory($value[$i])->escape()->toUtf8();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if($value === null) continue;
|
||||
elseif($value === FALSE) $value = 0x00;
|
||||
elseif($value === TRUE) $value = 0x01;
|
||||
elseif($value instanceof TeamSpeak3_Node_Abstract) $value = $value->getId();
|
||||
|
||||
$args[] = $ident . TeamSpeak3_Helper_String::factory($value)->escape()->toUtf8();
|
||||
}
|
||||
}
|
||||
|
||||
foreach(array_keys($cells) as $ident) $cells[$ident] = implode(TeamSpeak3::SEPARATOR_CELL, $cells[$ident]);
|
||||
|
||||
if(count($args)) $cmd .= " " . implode(TeamSpeak3::SEPARATOR_CELL, $args);
|
||||
if(count($cells)) $cmd .= " " . implode(TeamSpeak3::SEPARATOR_LIST, $cells);
|
||||
|
||||
return trim($cmd);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the timestamp of the last command.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getQueryLastTimestamp()
|
||||
{
|
||||
return $this->timer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of queries executed on the server.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getQueryCount()
|
||||
{
|
||||
return $this->count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the total runtime of all queries.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getQueryRuntime()
|
||||
{
|
||||
return $this->getProfiler()->getRuntime();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the TeamSpeak3_Node_Host object of the current connection.
|
||||
*
|
||||
* @return TeamSpeak3_Node_Host
|
||||
*/
|
||||
public function getHost()
|
||||
{
|
||||
if($this->host === null)
|
||||
{
|
||||
$this->host = new TeamSpeak3_Node_Host($this);
|
||||
}
|
||||
|
||||
return $this->host;
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Adapter_ServerQuery
|
||||
* @brief Provides low-level methods for ServerQuery communication with a TeamSpeak 3 Server.
|
||||
*/
|
||||
class TeamSpeak3_Adapter_ServerQuery extends TeamSpeak3_Adapter_Abstract
|
||||
{
|
||||
/**
|
||||
* Stores a singleton instance of the active TeamSpeak3_Node_Host object.
|
||||
*
|
||||
* @var TeamSpeak3_Node_Host
|
||||
*/
|
||||
protected $host = null;
|
||||
|
||||
/**
|
||||
* Stores the timestamp of the last command.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $timer = null;
|
||||
|
||||
/**
|
||||
* Number of queries executed on the server.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $count = 0;
|
||||
|
||||
/**
|
||||
* Stores an array with unsupported commands.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $block = array("help");
|
||||
|
||||
/**
|
||||
* Connects the TeamSpeak3_Transport_Abstract object and performs initial actions on the remote
|
||||
* server.
|
||||
*
|
||||
* @throws TeamSpeak3_Adapter_Exception
|
||||
* @return void
|
||||
*/
|
||||
protected function syn()
|
||||
{
|
||||
$this->initTransport($this->options);
|
||||
$this->transport->setAdapter($this);
|
||||
|
||||
TeamSpeak3_Helper_Profiler::init(spl_object_hash($this));
|
||||
|
||||
$rdy = $this->getTransport()->readLine();
|
||||
|
||||
if(!$rdy->startsWith(TeamSpeak3::TS3_PROTO_IDENT) && !$rdy->startsWith(TeamSpeak3::TEA_PROTO_IDENT) && !(defined("CUSTOM_PROTO_IDENT") && $rdy->startsWith(CUSTOM_PROTO_IDENT)))
|
||||
{
|
||||
throw new TeamSpeak3_Adapter_Exception("invalid reply from the server (" . $rdy . ")");
|
||||
}
|
||||
|
||||
TeamSpeak3_Helper_Signal::getInstance()->emit("serverqueryConnected", $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* The TeamSpeak3_Adapter_ServerQuery destructor.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
if($this->getTransport() instanceof TeamSpeak3_Transport_Abstract && $this->transport->isConnected())
|
||||
{
|
||||
try
|
||||
{
|
||||
$this->request("quit");
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a prepared command to the server and returns the result.
|
||||
*
|
||||
* @param string $cmd
|
||||
* @param boolean $throw
|
||||
* @throws TeamSpeak3_Adapter_Exception
|
||||
* @return TeamSpeak3_Adapter_ServerQuery_Reply
|
||||
*/
|
||||
public function request($cmd, $throw = TRUE)
|
||||
{
|
||||
$query = TeamSpeak3_Helper_String::factory($cmd)->section(TeamSpeak3::SEPARATOR_CELL);
|
||||
|
||||
if(strstr($cmd, "\r") || strstr($cmd, "\n"))
|
||||
{
|
||||
throw new TeamSpeak3_Adapter_Exception("illegal characters in command '" . $query . "'");
|
||||
}
|
||||
elseif(in_array($query, $this->block))
|
||||
{
|
||||
throw new TeamSpeak3_Adapter_ServerQuery_Exception("command not found", 0x100);
|
||||
}
|
||||
|
||||
TeamSpeak3_Helper_Signal::getInstance()->emit("serverqueryCommandStarted", $cmd);
|
||||
|
||||
$this->getProfiler()->start();
|
||||
$this->getTransport()->sendLine($cmd);
|
||||
$this->timer = time();
|
||||
$this->count++;
|
||||
|
||||
$rpl = array();
|
||||
|
||||
do {
|
||||
$str = $this->getTransport()->readLine();
|
||||
$rpl[] = $str;
|
||||
} while($str instanceof TeamSpeak3_Helper_String && $str->section(TeamSpeak3::SEPARATOR_CELL) != TeamSpeak3::ERROR);
|
||||
|
||||
$this->getProfiler()->stop();
|
||||
|
||||
$reply = new TeamSpeak3_Adapter_ServerQuery_Reply($rpl, $cmd, $this->getHost(), $throw);
|
||||
|
||||
TeamSpeak3_Helper_Signal::getInstance()->emit("serverqueryCommandFinished", $cmd, $reply);
|
||||
|
||||
return $reply;
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits for the server to send a notification message and returns the result.
|
||||
*
|
||||
* @throws TeamSpeak3_Adapter_Exception
|
||||
* @return TeamSpeak3_Adapter_ServerQuery_Event
|
||||
*/
|
||||
public function wait()
|
||||
{
|
||||
if($this->getTransport()->getConfig("blocking"))
|
||||
{
|
||||
throw new TeamSpeak3_Adapter_Exception("only available in non-blocking mode");
|
||||
}
|
||||
|
||||
do {
|
||||
$evt = $this->getTransport()->readLine();
|
||||
} while($evt instanceof TeamSpeak3_Helper_String && !$evt->section(TeamSpeak3::SEPARATOR_CELL)->startsWith(TeamSpeak3::EVENT));
|
||||
|
||||
return new TeamSpeak3_Adapter_ServerQuery_Event($evt, $this->getHost());
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses given parameters and returns a prepared ServerQuery command.
|
||||
*
|
||||
* @param string $cmd
|
||||
* @param array $params
|
||||
* @return string
|
||||
*/
|
||||
public function prepare($cmd, array $params = array())
|
||||
{
|
||||
$args = array();
|
||||
$cells = array();
|
||||
|
||||
foreach($params as $ident => $value)
|
||||
{
|
||||
$ident = is_numeric($ident) ? "" : strtolower($ident) . TeamSpeak3::SEPARATOR_PAIR;
|
||||
|
||||
if(is_array($value))
|
||||
{
|
||||
$value = array_values($value);
|
||||
|
||||
for($i = 0; $i < count($value); $i++)
|
||||
{
|
||||
if($value[$i] === null) continue;
|
||||
elseif($value[$i] === FALSE) $value[$i] = 0x00;
|
||||
elseif($value[$i] === TRUE) $value[$i] = 0x01;
|
||||
elseif($value[$i] instanceof TeamSpeak3_Node_Abstract) $value[$i] = $value[$i]->getId();
|
||||
|
||||
$cells[$i][] = $ident . TeamSpeak3_Helper_String::factory($value[$i])->escape()->toUtf8();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if($value === null) continue;
|
||||
elseif($value === FALSE) $value = 0x00;
|
||||
elseif($value === TRUE) $value = 0x01;
|
||||
elseif($value instanceof TeamSpeak3_Node_Abstract) $value = $value->getId();
|
||||
|
||||
$args[] = $ident . TeamSpeak3_Helper_String::factory($value)->escape()->toUtf8();
|
||||
}
|
||||
}
|
||||
|
||||
foreach(array_keys($cells) as $ident) $cells[$ident] = implode(TeamSpeak3::SEPARATOR_CELL, $cells[$ident]);
|
||||
|
||||
if(count($args)) $cmd .= " " . implode(TeamSpeak3::SEPARATOR_CELL, $args);
|
||||
if(count($cells)) $cmd .= " " . implode(TeamSpeak3::SEPARATOR_LIST, $cells);
|
||||
|
||||
return trim($cmd);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the timestamp of the last command.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getQueryLastTimestamp()
|
||||
{
|
||||
return $this->timer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of queries executed on the server.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getQueryCount()
|
||||
{
|
||||
return $this->count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the total runtime of all queries.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getQueryRuntime()
|
||||
{
|
||||
return $this->getProfiler()->getRuntime();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the TeamSpeak3_Node_Host object of the current connection.
|
||||
*
|
||||
* @return TeamSpeak3_Node_Host
|
||||
*/
|
||||
public function getHost()
|
||||
{
|
||||
if($this->host === null)
|
||||
{
|
||||
$this->host = new TeamSpeak3_Node_Host($this);
|
||||
}
|
||||
|
||||
return $this->host;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,167 +1,167 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Adapter_ServerQuery_Event
|
||||
* @brief Provides methods to analyze and format a ServerQuery event.
|
||||
*/
|
||||
class TeamSpeak3_Adapter_ServerQuery_Event implements ArrayAccess
|
||||
{
|
||||
/**
|
||||
* Stores the event type.
|
||||
*
|
||||
* @var TeamSpeak3_Helper_String
|
||||
*/
|
||||
protected $type = null;
|
||||
|
||||
/**
|
||||
* Stores the event data.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $data = null;
|
||||
|
||||
/**
|
||||
* Stores the event data as an unparsed string.
|
||||
*
|
||||
* @var TeamSpeak3_Helper_String
|
||||
*/
|
||||
protected $mesg = null;
|
||||
|
||||
/**
|
||||
* Creates a new TeamSpeak3_Adapter_ServerQuery_Event object.
|
||||
*
|
||||
* @param TeamSpeak3_Helper_String $evt
|
||||
* @param TeamSpeak3_Node_Host $con
|
||||
* @throws TeamSpeak3_Adapter_Exception
|
||||
* @return TeamSpeak3_Adapter_ServerQuery_Event
|
||||
*/
|
||||
public function __construct(TeamSpeak3_Helper_String $evt, TeamSpeak3_Node_Host $con = null)
|
||||
{
|
||||
if(!$evt->startsWith(TeamSpeak3::EVENT))
|
||||
{
|
||||
throw new TeamSpeak3_Adapter_Exception("invalid notification event format");
|
||||
}
|
||||
|
||||
list($type, $data) = $evt->split(TeamSpeak3::SEPARATOR_CELL, 2);
|
||||
|
||||
if(empty($data))
|
||||
{
|
||||
throw new TeamSpeak3_Adapter_Exception("invalid notification event data");
|
||||
}
|
||||
|
||||
$fake = new TeamSpeak3_Helper_String(TeamSpeak3::ERROR . TeamSpeak3::SEPARATOR_CELL . "id" . TeamSpeak3::SEPARATOR_PAIR . 0 . TeamSpeak3::SEPARATOR_CELL . "msg" . TeamSpeak3::SEPARATOR_PAIR . "ok");
|
||||
$repl = new TeamSpeak3_Adapter_ServerQuery_Reply(array($data, $fake), $type);
|
||||
|
||||
$this->type = $type->substr(strlen(TeamSpeak3::EVENT));
|
||||
$this->data = $repl->toList();
|
||||
$this->mesg = $data;
|
||||
|
||||
TeamSpeak3_Helper_Signal::getInstance()->emit("notifyEvent", $this, $con);
|
||||
TeamSpeak3_Helper_Signal::getInstance()->emit("notify" . ucfirst($this->type), $this, $con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the event type string.
|
||||
*
|
||||
* @return TeamSpeak3_Helper_String
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the event data array.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the event data as an unparsed string.
|
||||
*
|
||||
* @return TeamSpeak3_Helper_String
|
||||
*/
|
||||
public function getMessage()
|
||||
{
|
||||
return $this->mesg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
public function offsetExists($offset)
|
||||
{
|
||||
return array_key_exists($offset, $this->data) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
if(!$this->offsetExists($offset))
|
||||
{
|
||||
throw new TeamSpeak3_Adapter_ServerQuery_Exception("invalid parameter", 0x602);
|
||||
}
|
||||
|
||||
return $this->data[$offset];
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
throw new TeamSpeak3_Node_Exception("event '" . $this->getType() . "' is read only");
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
public function offsetUnset($offset)
|
||||
{
|
||||
unset($this->data[$offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
public function __get($offset)
|
||||
{
|
||||
return $this->offsetGet($offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
public function __set($offset, $value)
|
||||
{
|
||||
$this->offsetSet($offset, $value);
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Adapter_ServerQuery_Event
|
||||
* @brief Provides methods to analyze and format a ServerQuery event.
|
||||
*/
|
||||
class TeamSpeak3_Adapter_ServerQuery_Event implements ArrayAccess
|
||||
{
|
||||
/**
|
||||
* Stores the event type.
|
||||
*
|
||||
* @var TeamSpeak3_Helper_String
|
||||
*/
|
||||
protected $type = null;
|
||||
|
||||
/**
|
||||
* Stores the event data.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $data = null;
|
||||
|
||||
/**
|
||||
* Stores the event data as an unparsed string.
|
||||
*
|
||||
* @var TeamSpeak3_Helper_String
|
||||
*/
|
||||
protected $mesg = null;
|
||||
|
||||
/**
|
||||
* Creates a new TeamSpeak3_Adapter_ServerQuery_Event object.
|
||||
*
|
||||
* @param TeamSpeak3_Helper_String $evt
|
||||
* @param TeamSpeak3_Node_Host $con
|
||||
* @throws TeamSpeak3_Adapter_Exception
|
||||
* @return TeamSpeak3_Adapter_ServerQuery_Event
|
||||
*/
|
||||
public function __construct(TeamSpeak3_Helper_String $evt, TeamSpeak3_Node_Host $con = null)
|
||||
{
|
||||
if(!$evt->startsWith(TeamSpeak3::EVENT))
|
||||
{
|
||||
throw new TeamSpeak3_Adapter_Exception("invalid notification event format");
|
||||
}
|
||||
|
||||
list($type, $data) = $evt->split(TeamSpeak3::SEPARATOR_CELL, 2);
|
||||
|
||||
if(empty($data))
|
||||
{
|
||||
throw new TeamSpeak3_Adapter_Exception("invalid notification event data");
|
||||
}
|
||||
|
||||
$fake = new TeamSpeak3_Helper_String(TeamSpeak3::ERROR . TeamSpeak3::SEPARATOR_CELL . "id" . TeamSpeak3::SEPARATOR_PAIR . 0 . TeamSpeak3::SEPARATOR_CELL . "msg" . TeamSpeak3::SEPARATOR_PAIR . "ok");
|
||||
$repl = new TeamSpeak3_Adapter_ServerQuery_Reply(array($data, $fake), $type);
|
||||
|
||||
$this->type = $type->substr(strlen(TeamSpeak3::EVENT));
|
||||
$this->data = $repl->toList();
|
||||
$this->mesg = $data;
|
||||
|
||||
TeamSpeak3_Helper_Signal::getInstance()->emit("notifyEvent", $this, $con);
|
||||
TeamSpeak3_Helper_Signal::getInstance()->emit("notify" . ucfirst($this->type), $this, $con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the event type string.
|
||||
*
|
||||
* @return TeamSpeak3_Helper_String
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the event data array.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the event data as an unparsed string.
|
||||
*
|
||||
* @return TeamSpeak3_Helper_String
|
||||
*/
|
||||
public function getMessage()
|
||||
{
|
||||
return $this->mesg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
public function offsetExists($offset)
|
||||
{
|
||||
return array_key_exists($offset, $this->data) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
if(!$this->offsetExists($offset))
|
||||
{
|
||||
throw new TeamSpeak3_Adapter_ServerQuery_Exception("invalid parameter", 0x602);
|
||||
}
|
||||
|
||||
return $this->data[$offset];
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
throw new TeamSpeak3_Node_Exception("event '" . $this->getType() . "' is read only");
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
public function offsetUnset($offset)
|
||||
{
|
||||
unset($this->data[$offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
public function __get($offset)
|
||||
{
|
||||
return $this->offsetGet($offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
public function __set($offset, $value)
|
||||
{
|
||||
$this->offsetSet($offset, $value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +1,72 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Adapter_ServerQuery_Exception
|
||||
* @brief Enhanced exception class for TeamSpeak3_Adapter_ServerQuery objects.
|
||||
*/
|
||||
class TeamSpeak3_Adapter_ServerQuery_Exception extends TeamSpeak3_Adapter_Exception {}
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Adapter_ServerQuery_Exception
|
||||
* @brief Enhanced exception class for TeamSpeak3_Adapter_ServerQuery objects.
|
||||
*/
|
||||
class TeamSpeak3_Adapter_ServerQuery_Exception extends TeamSpeak3_Adapter_Exception
|
||||
{
|
||||
/**
|
||||
* Stores the optional return code for ServerQuery errors.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $return_code = null;
|
||||
|
||||
/**
|
||||
* The TeamSpeak3_Adapter_ServerQuery_Exception constructor.
|
||||
*
|
||||
* @param string $mesg
|
||||
* @param integer $code
|
||||
* @param string $return_code
|
||||
* @return TeamSpeak3_Adapter_ServerQuery_Exception
|
||||
*/
|
||||
public function __construct($mesg, $code = 0x00, $return_code = null)
|
||||
{
|
||||
parent::__construct($mesg, $code);
|
||||
|
||||
$this->return_code = $return_code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns TRUE if the exception provides a return code for ServerQuery errors.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasReturnCode()
|
||||
{
|
||||
return $this->return_code !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the optional return code for ServerQuery errors.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getReturnCode()
|
||||
{
|
||||
return $this->return_code;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,343 +1,343 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Adapter_ServerQuery_Reply
|
||||
* @brief Provides methods to analyze and format a ServerQuery reply.
|
||||
*/
|
||||
class TeamSpeak3_Adapter_ServerQuery_Reply
|
||||
{
|
||||
/**
|
||||
* Stores the command used to get this reply.
|
||||
*
|
||||
* @var TeamSpeak3_Helper_String
|
||||
*/
|
||||
protected $cmd = null;
|
||||
|
||||
/**
|
||||
* Stores the servers reply (if available).
|
||||
*
|
||||
* @var TeamSpeak3_Helper_String
|
||||
*/
|
||||
protected $rpl = null;
|
||||
|
||||
/**
|
||||
* Stores connected TeamSpeak3_Node_Host object.
|
||||
*
|
||||
* @var TeamSpeak3_Node_Host
|
||||
*/
|
||||
protected $con = null;
|
||||
|
||||
/**
|
||||
* Stores an assoc array containing the error info for this reply.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $err = array();
|
||||
|
||||
/**
|
||||
* Sotres an array of events that occured before or during this reply.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $evt = array();
|
||||
|
||||
/**
|
||||
* Indicates whether exceptions should be thrown or not.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $exp = TRUE;
|
||||
|
||||
/**
|
||||
* Creates a new TeamSpeak3_Adapter_ServerQuery_Reply object.
|
||||
*
|
||||
* @param array $rpl
|
||||
* @param string $cmd
|
||||
* @param boolean $exp
|
||||
* @param TeamSpeak3_Node_Host $con
|
||||
* @return TeamSpeak3_Adapter_ServerQuery_Reply
|
||||
*/
|
||||
public function __construct(array $rpl, $cmd = null, TeamSpeak3_Node_Host $con = null, $exp = TRUE)
|
||||
{
|
||||
$this->cmd = new TeamSpeak3_Helper_String($cmd);
|
||||
$this->con = $con;
|
||||
$this->exp = (bool) $exp;
|
||||
|
||||
$this->fetchError(array_pop($rpl));
|
||||
$this->fetchReply($rpl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the reply as an TeamSpeak3_Helper_String object.
|
||||
*
|
||||
* @return TeamSpeak3_Helper_String
|
||||
*/
|
||||
public function toString()
|
||||
{
|
||||
return (!func_num_args()) ? $this->rpl->unescape() : $this->rpl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the reply as a standard PHP array where each element represents one item.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toLines()
|
||||
{
|
||||
if(!count($this->rpl)) return array();
|
||||
|
||||
$list = $this->toString(0)->split(TeamSpeak3::SEPARATOR_LIST);
|
||||
|
||||
if(!func_num_args())
|
||||
{
|
||||
for($i = 0; $i < count($list); $i++) $list[$i]->unescape();
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the reply as a standard PHP array where each element represents one item in table format.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toTable()
|
||||
{
|
||||
$table = array();
|
||||
|
||||
foreach($this->toLines(0) as $cells)
|
||||
{
|
||||
$pairs = $cells->split(TeamSpeak3::SEPARATOR_CELL);
|
||||
|
||||
if(!func_num_args())
|
||||
{
|
||||
for($i = 0; $i < count($pairs); $i++) $pairs[$i]->unescape();
|
||||
}
|
||||
|
||||
$table[] = $pairs;
|
||||
}
|
||||
|
||||
return $table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a multi-dimensional array containing the reply splitted in multiple rows and columns.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
$array = array();
|
||||
$table = $this->toTable(1);
|
||||
|
||||
for($i = 0; $i < count($table); $i++)
|
||||
{
|
||||
foreach($table[$i] as $pair)
|
||||
{
|
||||
if(!count($pair))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!$pair->contains(TeamSpeak3::SEPARATOR_PAIR))
|
||||
{
|
||||
$array[$i][$pair->toString()] = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
list($ident, $value) = $pair->split(TeamSpeak3::SEPARATOR_PAIR, 2);
|
||||
|
||||
$array[$i][$ident->toString()] = $value->isInt() ? $value->toInt() : (!func_num_args() ? $value->unescape() : $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a multi-dimensional assoc array containing the reply splitted in multiple rows and columns.
|
||||
* The identifier specified by key will be used while indexing the array.
|
||||
*
|
||||
* @param $key
|
||||
* @return array
|
||||
*/
|
||||
public function toAssocArray($ident)
|
||||
{
|
||||
$nodes = (func_num_args() > 1) ? $this->toArray(1) : $this->toArray();
|
||||
$array = array();
|
||||
|
||||
foreach($nodes as $node)
|
||||
{
|
||||
if(isset($node[$ident]))
|
||||
{
|
||||
$array[(is_object($node[$ident])) ? $node[$ident]->toString() : $node[$ident]] = $node;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new TeamSpeak3_Adapter_ServerQuery_Exception("invalid parameter", 0x602);
|
||||
}
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing the reply splitted in multiple rows and columns.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toList()
|
||||
{
|
||||
$array = func_num_args() ? $this->toArray(1) : $this->toArray();
|
||||
|
||||
if(count($array) == 1)
|
||||
{
|
||||
return array_shift($array);
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing stdClass objects.
|
||||
*
|
||||
* @return ArrayObject
|
||||
*/
|
||||
public function toObjectArray()
|
||||
{
|
||||
$array = (func_num_args() > 1) ? $this->toArray(1) : $this->toArray();
|
||||
|
||||
for($i = 0; $i < count($array); $i++)
|
||||
{
|
||||
$array[$i] = (object) $array[$i];
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the command used to get this reply.
|
||||
*
|
||||
* @return TeamSpeak3_Helper_String
|
||||
*/
|
||||
public function getCommandString()
|
||||
{
|
||||
return new TeamSpeak3_Helper_String($this->cmd);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of events that occured before or during this reply.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getNotifyEvents()
|
||||
{
|
||||
return $this->evt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value for a specified error property.
|
||||
*
|
||||
* @param string $ident
|
||||
* @param mixed $default
|
||||
* @return mixed
|
||||
*/
|
||||
public function getErrorProperty($ident, $default = null)
|
||||
{
|
||||
return (array_key_exists($ident, $this->err)) ? $this->err[$ident] : $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a ServerQuery error and throws a TeamSpeak3_Adapter_ServerQuery_Exception object if
|
||||
* there's an error.
|
||||
*
|
||||
* @param string $err
|
||||
* @throws TeamSpeak3_Adapter_ServerQuery_Exception
|
||||
* @return void
|
||||
*/
|
||||
protected function fetchError($err)
|
||||
{
|
||||
$cells = $err->section(TeamSpeak3::SEPARATOR_CELL, 1, 3);
|
||||
|
||||
foreach($cells->split(TeamSpeak3::SEPARATOR_CELL) as $pair)
|
||||
{
|
||||
list($ident, $value) = $pair->split(TeamSpeak3::SEPARATOR_PAIR);
|
||||
|
||||
$this->err[$ident->toString()] = $value->isInt() ? $value->toInt() : $value->unescape();
|
||||
}
|
||||
|
||||
TeamSpeak3_Helper_Signal::getInstance()->emit("notifyError", $this);
|
||||
|
||||
if($this->getErrorProperty("id", 0x00) != 0x00 && $this->exp)
|
||||
{
|
||||
if($permid = $this->getErrorProperty("failed_permid"))
|
||||
{
|
||||
if($permsid = key($this->con->request("permget permid=" . $permid, FALSE)->toAssocArray("permsid")))
|
||||
{
|
||||
$suffix = " (failed on " . $permsid . ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
$suffix = " (failed on " . $this->cmd->section(TeamSpeak3::SEPARATOR_CELL) . " " . $permid . "/0x" . strtoupper(dechex($permid)) . ")";
|
||||
}
|
||||
}
|
||||
elseif($details = $this->getErrorProperty("extra_msg"))
|
||||
{
|
||||
$suffix = " (" . trim($details) . ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
$suffix = "";
|
||||
}
|
||||
|
||||
throw new TeamSpeak3_Adapter_ServerQuery_Exception($this->getErrorProperty("msg") . $suffix, $this->getErrorProperty("id"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a ServerQuery reply and creates a TeamSpeak3_Helper_String object.
|
||||
*
|
||||
* @param string $rpl
|
||||
* @return void
|
||||
*/
|
||||
protected function fetchReply($rpl)
|
||||
{
|
||||
foreach($rpl as $key => $val)
|
||||
{
|
||||
if($val->startsWith(TeamSpeak3::TS3_MOTD_PREFIX) || $val->startsWith(TeamSpeak3::TEA_MOTD_PREFIX) || (defined("CUSTOM_MOTD_PREFIX") && $val->startsWith(CUSTOM_MOTD_PREFIX)))
|
||||
{
|
||||
unset($rpl[$key]);
|
||||
}
|
||||
elseif($val->startsWith(TeamSpeak3::EVENT))
|
||||
{
|
||||
$this->evt[] = new TeamSpeak3_Adapter_ServerQuery_Event($rpl[$key], $this->con);
|
||||
unset($rpl[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
$this->rpl = new TeamSpeak3_Helper_String(implode(TeamSpeak3::SEPARATOR_LIST, $rpl));
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Adapter_ServerQuery_Reply
|
||||
* @brief Provides methods to analyze and format a ServerQuery reply.
|
||||
*/
|
||||
class TeamSpeak3_Adapter_ServerQuery_Reply
|
||||
{
|
||||
/**
|
||||
* Stores the command used to get this reply.
|
||||
*
|
||||
* @var TeamSpeak3_Helper_String
|
||||
*/
|
||||
protected $cmd = null;
|
||||
|
||||
/**
|
||||
* Stores the servers reply (if available).
|
||||
*
|
||||
* @var TeamSpeak3_Helper_String
|
||||
*/
|
||||
protected $rpl = null;
|
||||
|
||||
/**
|
||||
* Stores connected TeamSpeak3_Node_Host object.
|
||||
*
|
||||
* @var TeamSpeak3_Node_Host
|
||||
*/
|
||||
protected $con = null;
|
||||
|
||||
/**
|
||||
* Stores an assoc array containing the error info for this reply.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $err = array();
|
||||
|
||||
/**
|
||||
* Sotres an array of events that occured before or during this reply.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $evt = array();
|
||||
|
||||
/**
|
||||
* Indicates whether exceptions should be thrown or not.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $exp = TRUE;
|
||||
|
||||
/**
|
||||
* Creates a new TeamSpeak3_Adapter_ServerQuery_Reply object.
|
||||
*
|
||||
* @param array $rpl
|
||||
* @param string $cmd
|
||||
* @param boolean $exp
|
||||
* @param TeamSpeak3_Node_Host $con
|
||||
* @return TeamSpeak3_Adapter_ServerQuery_Reply
|
||||
*/
|
||||
public function __construct(array $rpl, $cmd = null, TeamSpeak3_Node_Host $con = null, $exp = TRUE)
|
||||
{
|
||||
$this->cmd = new TeamSpeak3_Helper_String($cmd);
|
||||
$this->con = $con;
|
||||
$this->exp = (bool) $exp;
|
||||
|
||||
$this->fetchError(array_pop($rpl));
|
||||
$this->fetchReply($rpl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the reply as an TeamSpeak3_Helper_String object.
|
||||
*
|
||||
* @return TeamSpeak3_Helper_String
|
||||
*/
|
||||
public function toString()
|
||||
{
|
||||
return (!func_num_args()) ? $this->rpl->unescape() : $this->rpl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the reply as a standard PHP array where each element represents one item.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toLines()
|
||||
{
|
||||
if(!count($this->rpl)) return array();
|
||||
|
||||
$list = $this->toString(0)->split(TeamSpeak3::SEPARATOR_LIST);
|
||||
|
||||
if(!func_num_args())
|
||||
{
|
||||
for($i = 0; $i < count($list); $i++) $list[$i]->unescape();
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the reply as a standard PHP array where each element represents one item in table format.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toTable()
|
||||
{
|
||||
$table = array();
|
||||
|
||||
foreach($this->toLines(0) as $cells)
|
||||
{
|
||||
$pairs = $cells->split(TeamSpeak3::SEPARATOR_CELL);
|
||||
|
||||
if(!func_num_args())
|
||||
{
|
||||
for($i = 0; $i < count($pairs); $i++) $pairs[$i]->unescape();
|
||||
}
|
||||
|
||||
$table[] = $pairs;
|
||||
}
|
||||
|
||||
return $table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a multi-dimensional array containing the reply splitted in multiple rows and columns.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
$array = array();
|
||||
$table = $this->toTable(1);
|
||||
|
||||
for($i = 0; $i < count($table); $i++)
|
||||
{
|
||||
foreach($table[$i] as $pair)
|
||||
{
|
||||
if(!count($pair))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!$pair->contains(TeamSpeak3::SEPARATOR_PAIR))
|
||||
{
|
||||
$array[$i][$pair->toString()] = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
list($ident, $value) = $pair->split(TeamSpeak3::SEPARATOR_PAIR, 2);
|
||||
|
||||
$array[$i][$ident->toString()] = $value->isInt() ? $value->toInt() : (!func_num_args() ? $value->unescape() : $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a multi-dimensional assoc array containing the reply splitted in multiple rows and columns.
|
||||
* The identifier specified by key will be used while indexing the array.
|
||||
*
|
||||
* @param $key
|
||||
* @return array
|
||||
*/
|
||||
public function toAssocArray($ident)
|
||||
{
|
||||
$nodes = (func_num_args() > 1) ? $this->toArray(1) : $this->toArray();
|
||||
$array = array();
|
||||
|
||||
foreach($nodes as $node)
|
||||
{
|
||||
if(isset($node[$ident]))
|
||||
{
|
||||
$array[(is_object($node[$ident])) ? $node[$ident]->toString() : $node[$ident]] = $node;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new TeamSpeak3_Adapter_ServerQuery_Exception("invalid parameter", 0x602);
|
||||
}
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing the reply splitted in multiple rows and columns.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toList()
|
||||
{
|
||||
$array = func_num_args() ? $this->toArray(1) : $this->toArray();
|
||||
|
||||
if(count($array) == 1)
|
||||
{
|
||||
return array_shift($array);
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing stdClass objects.
|
||||
*
|
||||
* @return ArrayObject
|
||||
*/
|
||||
public function toObjectArray()
|
||||
{
|
||||
$array = (func_num_args() > 1) ? $this->toArray(1) : $this->toArray();
|
||||
|
||||
for($i = 0; $i < count($array); $i++)
|
||||
{
|
||||
$array[$i] = (object) $array[$i];
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the command used to get this reply.
|
||||
*
|
||||
* @return TeamSpeak3_Helper_String
|
||||
*/
|
||||
public function getCommandString()
|
||||
{
|
||||
return new TeamSpeak3_Helper_String($this->cmd);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of events that occured before or during this reply.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getNotifyEvents()
|
||||
{
|
||||
return $this->evt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value for a specified error property.
|
||||
*
|
||||
* @param string $ident
|
||||
* @param mixed $default
|
||||
* @return mixed
|
||||
*/
|
||||
public function getErrorProperty($ident, $default = null)
|
||||
{
|
||||
return (array_key_exists($ident, $this->err)) ? $this->err[$ident] : $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a ServerQuery error and throws a TeamSpeak3_Adapter_ServerQuery_Exception object if
|
||||
* there's an error.
|
||||
*
|
||||
* @param string $err
|
||||
* @throws TeamSpeak3_Adapter_ServerQuery_Exception
|
||||
* @return void
|
||||
*/
|
||||
protected function fetchError($err)
|
||||
{
|
||||
$cells = $err->section(TeamSpeak3::SEPARATOR_CELL, 1, 3);
|
||||
|
||||
foreach($cells->split(TeamSpeak3::SEPARATOR_CELL) as $pair)
|
||||
{
|
||||
list($ident, $value) = $pair->split(TeamSpeak3::SEPARATOR_PAIR);
|
||||
|
||||
$this->err[$ident->toString()] = $value->isInt() ? $value->toInt() : $value->unescape();
|
||||
}
|
||||
|
||||
TeamSpeak3_Helper_Signal::getInstance()->emit("notifyError", $this);
|
||||
|
||||
if($this->getErrorProperty("id", 0x00) != 0x00 && $this->exp)
|
||||
{
|
||||
if($permid = $this->getErrorProperty("failed_permid"))
|
||||
{
|
||||
if($permsid = key($this->con->request("permget permid=" . $permid, FALSE)->toAssocArray("permsid")))
|
||||
{
|
||||
$suffix = " (failed on " . $permsid . ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
$suffix = " (failed on " . $this->cmd->section(TeamSpeak3::SEPARATOR_CELL) . " " . $permid . "/0x" . strtoupper(dechex($permid)) . ")";
|
||||
}
|
||||
}
|
||||
elseif($details = $this->getErrorProperty("extra_msg"))
|
||||
{
|
||||
$suffix = " (" . trim($details) . ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
$suffix = "";
|
||||
}
|
||||
|
||||
throw new TeamSpeak3_Adapter_ServerQuery_Exception($this->getErrorProperty("msg") . $suffix, $this->getErrorProperty("id"), $this->getErrorProperty("return_code"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a ServerQuery reply and creates a TeamSpeak3_Helper_String object.
|
||||
*
|
||||
* @param string $rpl
|
||||
* @return void
|
||||
*/
|
||||
protected function fetchReply($rpl)
|
||||
{
|
||||
foreach($rpl as $key => $val)
|
||||
{
|
||||
if($val->startsWith(TeamSpeak3::TS3_MOTD_PREFIX) || $val->startsWith(TeamSpeak3::TEA_MOTD_PREFIX) || (defined("CUSTOM_MOTD_PREFIX") && $val->startsWith(CUSTOM_MOTD_PREFIX)))
|
||||
{
|
||||
unset($rpl[$key]);
|
||||
}
|
||||
elseif($val->startsWith(TeamSpeak3::EVENT))
|
||||
{
|
||||
$this->evt[] = new TeamSpeak3_Adapter_ServerQuery_Event($rpl[$key], $this->con);
|
||||
unset($rpl[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
$this->rpl = new TeamSpeak3_Helper_String(implode(TeamSpeak3::SEPARATOR_LIST, $rpl));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,95 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* $Id: TSDNS.php 06/06/2016 22:27:13 scp@Svens-iMac $
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @version 1.1.24
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) 2010 by Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Adapter_TSDNS
|
||||
* @brief Provides methods to query a TSDNS server.
|
||||
*/
|
||||
class TeamSpeak3_Adapter_TSDNS extends TeamSpeak3_Adapter_Abstract
|
||||
{
|
||||
/**
|
||||
* The TCP port number used by any TSDNS server.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $default_port = 41144;
|
||||
|
||||
/**
|
||||
* Connects the TeamSpeak3_Transport_Abstract object and performs initial actions on the remote
|
||||
* server.
|
||||
*
|
||||
* @throws TeamSpeak3_Adapter_Exception
|
||||
* @return void
|
||||
*/
|
||||
public function syn()
|
||||
{
|
||||
if(!isset($this->options["port"]) || empty($this->options["port"])) $this->options["port"] = $this->default_port;
|
||||
|
||||
$this->initTransport($this->options);
|
||||
$this->transport->setAdapter($this);
|
||||
|
||||
TeamSpeak3_Helper_Profiler::init(spl_object_hash($this));
|
||||
|
||||
TeamSpeak3_Helper_Signal::getInstance()->emit("tsdnsConnected", $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* The TeamSpeak3_Adapter_FileTransfer destructor.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
if($this->getTransport() instanceof TeamSpeak3_Transport_Abstract && $this->getTransport()->isConnected())
|
||||
{
|
||||
$this->getTransport()->disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Queries the TSDNS server for a specified virtual hostname and returns the result.
|
||||
*
|
||||
* @param string $tsdns
|
||||
* @throws TeamSpeak3_Adapter_TSDNS_Exception
|
||||
* @return TeamSpeak3_Helper_String
|
||||
*/
|
||||
public function resolve($tsdns)
|
||||
{
|
||||
$this->getTransport()->sendLine($tsdns);
|
||||
$repl = $this->getTransport()->readLine();
|
||||
$this->getTransport()->disconnect();
|
||||
|
||||
if($repl->section(":", 0)->toInt() == 404)
|
||||
{
|
||||
throw new TeamSpeak3_Adapter_TSDNS_Exception("unable to resolve TSDNS hostname (" . $tsdns . ")");
|
||||
}
|
||||
|
||||
TeamSpeak3_Helper_Signal::getInstance()->emit("tsdnsResolved", $tsdns, $repl);
|
||||
|
||||
return $repl;
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* $Id: Exception.php 06/06/2016 22:27:13 scp@Svens-iMac $
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @version 1.1.24
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) 2010 by Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Adapter_TSDNS_Exception
|
||||
* @brief Enhanced exception class for TeamSpeak3_Adapter_TSDNS objects.
|
||||
*/
|
||||
class TeamSpeak3_Adapter_TSDNS_Exception extends TeamSpeak3_Adapter_Exception {}
|
||||
@@ -1,217 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* $Id: Update.php 06/06/2016 22:27:13 scp@Svens-iMac $
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @version 1.1.24
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) 2010 by Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Adapter_Update
|
||||
* @brief Provides methods to query the latest TeamSpeak 3 build numbers from the master server.
|
||||
*/
|
||||
class TeamSpeak3_Adapter_Update extends TeamSpeak3_Adapter_Abstract
|
||||
{
|
||||
/**
|
||||
* The IPv4 address or FQDN of the TeamSpeak Systems update server.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $default_host = "update.teamspeak.com";
|
||||
|
||||
/**
|
||||
* The UDP port number of the TeamSpeak Systems update server.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $default_port = 17384;
|
||||
|
||||
/**
|
||||
* Stores an array containing the latest build numbers (integer timestamps).
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $build_datetimes = null;
|
||||
|
||||
/**
|
||||
* Stores an array containing the latest version strings.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $version_strings = null;
|
||||
|
||||
/**
|
||||
* Connects the TeamSpeak3_Transport_Abstract object and performs initial actions on the remote
|
||||
* server.
|
||||
*
|
||||
* @throws TeamSpeak3_Adapter_Update_Exception
|
||||
* @return void
|
||||
*/
|
||||
public function syn()
|
||||
{
|
||||
if(!isset($this->options["host"]) || empty($this->options["host"])) $this->options["host"] = $this->default_host;
|
||||
if(!isset($this->options["port"]) || empty($this->options["port"])) $this->options["port"] = $this->default_port;
|
||||
|
||||
$this->initTransport($this->options, "TeamSpeak3_Transport_UDP");
|
||||
$this->transport->setAdapter($this);
|
||||
|
||||
TeamSpeak3_Helper_Profiler::init(spl_object_hash($this));
|
||||
|
||||
$this->getTransport()->send(TeamSpeak3_Helper_String::fromHex(33));
|
||||
|
||||
if(!preg_match_all("/,?(\d+)#([0-9a-zA-Z\._-]+),?/", $this->getTransport()->read(96), $matches) || !isset($matches[1]) || !isset($matches[2]))
|
||||
{
|
||||
throw new TeamSpeak3_Adapter_Update_Exception("invalid reply from the server");
|
||||
}
|
||||
|
||||
$this->build_datetimes = $matches[1];
|
||||
$this->version_strings = $matches[2];
|
||||
|
||||
TeamSpeak3_Helper_Signal::getInstance()->emit("updateConnected", $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* The TeamSpeak3_Adapter_Update destructor.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
if($this->getTransport() instanceof TeamSpeak3_Transport_Abstract && $this->getTransport()->isConnected())
|
||||
{
|
||||
$this->getTransport()->disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current build number for a specified update channel. Note that since version
|
||||
* 3.0.0, the build number represents an integer timestamp. $channel must be set to one of
|
||||
* the following values:
|
||||
*
|
||||
* - stable
|
||||
* - beta
|
||||
* - alpha
|
||||
* - server
|
||||
*
|
||||
* @param string $channel
|
||||
* @throws TeamSpeak3_Adapter_Update_Exception
|
||||
* @return integer
|
||||
*/
|
||||
public function getRev($channel = "stable")
|
||||
{
|
||||
switch($channel)
|
||||
{
|
||||
case "stable":
|
||||
return isset($this->build_datetimes[0]) ? $this->build_datetimes[0] : null;
|
||||
|
||||
case "beta":
|
||||
return isset($this->build_datetimes[1]) ? $this->build_datetimes[1] : null;
|
||||
|
||||
case "alpha":
|
||||
return isset($this->build_datetimes[2]) ? $this->build_datetimes[2] : null;
|
||||
|
||||
case "server":
|
||||
return isset($this->build_datetimes[3]) ? $this->build_datetimes[3] : null;
|
||||
|
||||
default:
|
||||
throw new TeamSpeak3_Adapter_Update_Exception("invalid update channel identifier (" . $channel . ")");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current version string for a specified update channel. $channel must be set to
|
||||
* one of the following values:
|
||||
*
|
||||
* - stable
|
||||
* - beta
|
||||
* - alpha
|
||||
* - server
|
||||
*
|
||||
* @param string $channel
|
||||
* @throws TeamSpeak3_Adapter_Update_Exception
|
||||
* @return integer
|
||||
*/
|
||||
public function getVersion($channel = "stable")
|
||||
{
|
||||
switch($channel)
|
||||
{
|
||||
case "stable":
|
||||
return isset($this->version_strings[0]) ? $this->version_strings[0] : null;
|
||||
|
||||
case "beta":
|
||||
return isset($this->version_strings[1]) ? $this->version_strings[1] : null;
|
||||
|
||||
case "alpha":
|
||||
return isset($this->version_strings[2]) ? $this->version_strings[2] : null;
|
||||
|
||||
case "server":
|
||||
return isset($this->version_strings[3]) ? $this->version_strings[3] : null;
|
||||
|
||||
default:
|
||||
throw new TeamSpeak3_Adapter_Update_Exception("invalid update channel identifier (" . $channel . ")");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for getRev() using the 'stable' update channel.
|
||||
*
|
||||
* @param string $channel
|
||||
* @return integer
|
||||
*/
|
||||
public function getClientRev()
|
||||
{
|
||||
return $this->getRev("stable");
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for getRev() using the 'server' update channel.
|
||||
*
|
||||
* @param string $channel
|
||||
* @return integer
|
||||
*/
|
||||
public function getServerRev()
|
||||
{
|
||||
return $this->getRev("server");
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for getVersion() using the 'stable' update channel.
|
||||
*
|
||||
* @param string $channel
|
||||
* @return integer
|
||||
*/
|
||||
public function getClientVersion()
|
||||
{
|
||||
return $this->getVersion("stable");
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for getVersion() using the 'server' update channel.
|
||||
*
|
||||
* @param string $channel
|
||||
* @return integer
|
||||
*/
|
||||
public function getServerVersion()
|
||||
{
|
||||
return $this->getVersion("server");
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* $Id: Exception.php 06/06/2016 22:27:13 scp@Svens-iMac $
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @version 1.1.24
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) 2010 by Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Adapter_Update_Exception
|
||||
* @brief Enhanced exception class for TeamSpeak3_Adapter_Update objects.
|
||||
*/
|
||||
class TeamSpeak3_Adapter_Update_Exception extends TeamSpeak3_Adapter_Exception {}
|
||||
@@ -1,126 +1,163 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Exception
|
||||
* @brief Enhanced exception class for TeamSpeak3 objects.
|
||||
*/
|
||||
class TeamSpeak3_Exception extends Exception
|
||||
{
|
||||
/**
|
||||
* Stores custom error messages.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $messages = array();
|
||||
|
||||
/**
|
||||
* The TeamSpeak3_Exception constructor.
|
||||
*
|
||||
* @param string $mesg
|
||||
* @param integer $code
|
||||
* @return TeamSpeak3_Exception
|
||||
*/
|
||||
public function __construct($mesg, $code = 0x00)
|
||||
{
|
||||
parent::__construct($mesg, $code);
|
||||
|
||||
if(array_key_exists((int) $code, self::$messages))
|
||||
{
|
||||
$this->message = $this->prepareCustomMessage(self::$messages[intval($code)]);
|
||||
}
|
||||
|
||||
TeamSpeak3_Helper_Signal::getInstance()->emit("errorException", $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares a custom error message by replacing pre-defined signs with given values.
|
||||
*
|
||||
* @param TeamSpeak3_Helper_String $mesg
|
||||
* @return TeamSpeak3_Helper_String
|
||||
*/
|
||||
protected function prepareCustomMessage(TeamSpeak3_Helper_String $mesg)
|
||||
{
|
||||
$args = array(
|
||||
"code" => $this->getCode(),
|
||||
"mesg" => $this->getMessage(),
|
||||
"line" => $this->getLine(),
|
||||
"file" => $this->getFile(),
|
||||
);
|
||||
|
||||
return $mesg->arg($args)->toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a custom error message to $code.
|
||||
*
|
||||
* @param integer $code
|
||||
* @param string $mesg
|
||||
* @throws TeamSpeak3_Exception
|
||||
* @return void
|
||||
*/
|
||||
public static function registerCustomMessage($code, $mesg)
|
||||
{
|
||||
if(array_key_exists((int) $code, self::$messages))
|
||||
{
|
||||
throw new self("custom message for code 0x" . strtoupper(dechex($code)) . " is already registered");
|
||||
}
|
||||
|
||||
if(!is_string($mesg))
|
||||
{
|
||||
throw new self("custom message for code 0x" . strtoupper(dechex($code)) . " must be a string");
|
||||
}
|
||||
|
||||
self::$messages[(int) $code] = new TeamSpeak3_Helper_String($mesg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters a custom error message from $code.
|
||||
*
|
||||
* @param integer $code
|
||||
* @throws TeamSpeak3_Exception
|
||||
* @return void
|
||||
*/
|
||||
public static function unregisterCustomMessage($code)
|
||||
{
|
||||
if(!array_key_exists((int) $code, self::$messages))
|
||||
{
|
||||
throw new self("custom message for code 0x" . strtoupper(dechex($code)) . " is not registered");
|
||||
}
|
||||
|
||||
unset(self::$messages[(int) $code]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the class from which the exception was thrown.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSender()
|
||||
{
|
||||
$trace = $this->getTrace();
|
||||
|
||||
return (isset($trace[0]["class"])) ? $trace[0]["class"] : "{main}";
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Exception
|
||||
* @brief Enhanced exception class for TeamSpeak3 objects.
|
||||
*/
|
||||
class TeamSpeak3_Exception extends Exception
|
||||
{
|
||||
/**
|
||||
* Stores the original error code.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $raw_code = 0x00;
|
||||
|
||||
/**
|
||||
* Stores the original error message.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $raw_mesg = null;
|
||||
|
||||
/**
|
||||
* Stores custom error messages.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $messages = array();
|
||||
|
||||
/**
|
||||
* The TeamSpeak3_Exception constructor.
|
||||
*
|
||||
* @param string $mesg
|
||||
* @param integer $code
|
||||
* @return TeamSpeak3_Exception
|
||||
*/
|
||||
public function __construct($mesg, $code = 0x00)
|
||||
{
|
||||
parent::__construct($mesg, $code);
|
||||
|
||||
$this->raw_code = $code;
|
||||
$this->raw_mesg = $mesg;
|
||||
|
||||
if(array_key_exists((int) $code, self::$messages))
|
||||
{
|
||||
$this->message = $this->prepareCustomMessage(self::$messages[intval($code)]);
|
||||
}
|
||||
|
||||
TeamSpeak3_Helper_Signal::getInstance()->emit("errorException", $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares a custom error message by replacing pre-defined signs with given values.
|
||||
*
|
||||
* @param TeamSpeak3_Helper_String $mesg
|
||||
* @return TeamSpeak3_Helper_String
|
||||
*/
|
||||
protected function prepareCustomMessage(TeamSpeak3_Helper_String $mesg)
|
||||
{
|
||||
$args = array(
|
||||
"code" => $this->getCode(),
|
||||
"mesg" => $this->getMessage(),
|
||||
"line" => $this->getLine(),
|
||||
"file" => $this->getFile(),
|
||||
);
|
||||
|
||||
return $mesg->arg($args)->toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a custom error message to $code.
|
||||
*
|
||||
* @param integer $code
|
||||
* @param string $mesg
|
||||
* @throws TeamSpeak3_Exception
|
||||
* @return void
|
||||
*/
|
||||
public static function registerCustomMessage($code, $mesg)
|
||||
{
|
||||
if(array_key_exists((int) $code, self::$messages))
|
||||
{
|
||||
throw new self("custom message for code 0x" . strtoupper(dechex($code)) . " is already registered");
|
||||
}
|
||||
|
||||
if(!is_string($mesg))
|
||||
{
|
||||
throw new self("custom message for code 0x" . strtoupper(dechex($code)) . " must be a string");
|
||||
}
|
||||
|
||||
self::$messages[(int) $code] = new TeamSpeak3_Helper_String($mesg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters a custom error message from $code.
|
||||
*
|
||||
* @param integer $code
|
||||
* @throws TeamSpeak3_Exception
|
||||
* @return void
|
||||
*/
|
||||
public static function unregisterCustomMessage($code)
|
||||
{
|
||||
if(!array_key_exists((int) $code, self::$messages))
|
||||
{
|
||||
throw new self("custom message for code 0x" . strtoupper(dechex($code)) . " is not registered");
|
||||
}
|
||||
|
||||
unset(self::$messages[(int) $code]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the original error code.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getRawCode()
|
||||
{
|
||||
return $this->raw_code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the original error message.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getRawMessage()
|
||||
{
|
||||
return $this->raw_mesg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the class from which the exception was thrown.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSender()
|
||||
{
|
||||
$trace = $this->getTrace();
|
||||
|
||||
return (isset($trace[0]["class"])) ? $trace[0]["class"] : "{main}";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,266 +1,266 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Helper_Char
|
||||
* @brief Helper class for char handling.
|
||||
*/
|
||||
class TeamSpeak3_Helper_Char
|
||||
{
|
||||
/**
|
||||
* Stores the original character.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $char = null;
|
||||
|
||||
/**
|
||||
* The TeamSpeak3_Helper_Char constructor.
|
||||
*
|
||||
* @param string $var
|
||||
* @throws TeamSpeak3_Helper_Exception
|
||||
* @return TeamSpeak3_Helper_Char
|
||||
*/
|
||||
public function __construct($char)
|
||||
{
|
||||
if(strlen($char) != 1)
|
||||
{
|
||||
throw new TeamSpeak3_Helper_Exception("char parameter may not contain more or less than one character");
|
||||
}
|
||||
|
||||
$this->char = strval($char);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the character is a letter.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isLetter()
|
||||
{
|
||||
return ctype_alpha($this->char);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the character is a decimal digit.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isDigit()
|
||||
{
|
||||
return ctype_digit($this->char);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the character is a space.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isSpace()
|
||||
{
|
||||
return ctype_space($this->char);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the character is a mark.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isMark()
|
||||
{
|
||||
return ctype_punct($this->char);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the character is a control character (i.e. "\t").
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isControl()
|
||||
{
|
||||
return ctype_cntrl($this->char);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the character is a printable character.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isPrintable()
|
||||
{
|
||||
return ctype_print($this->char);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the character is the Unicode character 0x0000 ("\0").
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isNull()
|
||||
{
|
||||
return ($this->char === "\0") ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the character is an uppercase letter.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isUpper()
|
||||
{
|
||||
return ($this->char === strtoupper($this->char)) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the character is a lowercase letter.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isLower()
|
||||
{
|
||||
return ($this->char === strtolower($this->char)) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the uppercase equivalent if the character is lowercase.
|
||||
*
|
||||
* @return TeamSpeak3_Helper_Char
|
||||
*/
|
||||
public function toUpper()
|
||||
{
|
||||
return ($this->isUpper()) ? $this : new self(strtoupper($this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the lowercase equivalent if the character is uppercase.
|
||||
*
|
||||
* @return TeamSpeak3_Helper_Char
|
||||
*/
|
||||
public function toLower()
|
||||
{
|
||||
return ($this->isLower()) ? $this : new self(strtolower($this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ascii value of the character.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function toAscii()
|
||||
{
|
||||
return ord($this->char);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Unicode value of the character.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function toUnicode()
|
||||
{
|
||||
$h = ord($this->char{0});
|
||||
|
||||
if($h <= 0x7F)
|
||||
{
|
||||
return $h;
|
||||
}
|
||||
else if($h < 0xC2)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
else if($h <= 0xDF)
|
||||
{
|
||||
return ($h & 0x1F) << 6 | (ord($this->char{1}) & 0x3F);
|
||||
}
|
||||
else if($h <= 0xEF)
|
||||
{
|
||||
return ($h & 0x0F) << 12 | (ord($this->char{1}) & 0x3F) << 6 | (ord($this->char{2}) & 0x3F);
|
||||
}
|
||||
else if($h <= 0xF4)
|
||||
{
|
||||
return ($h & 0x0F) << 18 | (ord($this->char{1}) & 0x3F) << 12 | (ord($this->char{2}) & 0x3F) << 6 | (ord($this->char{3}) & 0x3F);
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hexadecimal value of the char.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toHex()
|
||||
{
|
||||
return strtoupper(dechex($this->toAscii()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the TeamSpeak3_Helper_Char based on a given hex value.
|
||||
*
|
||||
* @param string $hex
|
||||
* @throws TeamSpeak3_Helper_Exception
|
||||
* @return TeamSpeak3_Helper_Char
|
||||
*/
|
||||
public static function fromHex($hex)
|
||||
{
|
||||
if(strlen($hex) != 2)
|
||||
{
|
||||
throw new TeamSpeak3_Helper_Exception("given parameter '" . $hex . "' is not a valid hexadecimal number");
|
||||
}
|
||||
|
||||
return new self(chr(hexdec($hex)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the character as a standard string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toString()
|
||||
{
|
||||
return $this->char;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the integer value of the character.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function toInt()
|
||||
{
|
||||
return intval($this->char);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the character as a standard string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->char;
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Helper_Char
|
||||
* @brief Helper class for char handling.
|
||||
*/
|
||||
class TeamSpeak3_Helper_Char
|
||||
{
|
||||
/**
|
||||
* Stores the original character.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $char = null;
|
||||
|
||||
/**
|
||||
* The TeamSpeak3_Helper_Char constructor.
|
||||
*
|
||||
* @param string $var
|
||||
* @throws TeamSpeak3_Helper_Exception
|
||||
* @return TeamSpeak3_Helper_Char
|
||||
*/
|
||||
public function __construct($char)
|
||||
{
|
||||
if(strlen($char) != 1)
|
||||
{
|
||||
throw new TeamSpeak3_Helper_Exception("char parameter may not contain more or less than one character");
|
||||
}
|
||||
|
||||
$this->char = strval($char);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the character is a letter.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isLetter()
|
||||
{
|
||||
return ctype_alpha($this->char);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the character is a decimal digit.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isDigit()
|
||||
{
|
||||
return ctype_digit($this->char);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the character is a space.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isSpace()
|
||||
{
|
||||
return ctype_space($this->char);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the character is a mark.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isMark()
|
||||
{
|
||||
return ctype_punct($this->char);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the character is a control character (i.e. "\t").
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isControl()
|
||||
{
|
||||
return ctype_cntrl($this->char);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the character is a printable character.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isPrintable()
|
||||
{
|
||||
return ctype_print($this->char);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the character is the Unicode character 0x0000 ("\0").
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isNull()
|
||||
{
|
||||
return ($this->char === "\0") ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the character is an uppercase letter.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isUpper()
|
||||
{
|
||||
return ($this->char === strtoupper($this->char)) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the character is a lowercase letter.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isLower()
|
||||
{
|
||||
return ($this->char === strtolower($this->char)) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the uppercase equivalent if the character is lowercase.
|
||||
*
|
||||
* @return TeamSpeak3_Helper_Char
|
||||
*/
|
||||
public function toUpper()
|
||||
{
|
||||
return ($this->isUpper()) ? $this : new self(strtoupper($this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the lowercase equivalent if the character is uppercase.
|
||||
*
|
||||
* @return TeamSpeak3_Helper_Char
|
||||
*/
|
||||
public function toLower()
|
||||
{
|
||||
return ($this->isLower()) ? $this : new self(strtolower($this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ascii value of the character.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function toAscii()
|
||||
{
|
||||
return ord($this->char);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Unicode value of the character.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function toUnicode()
|
||||
{
|
||||
$h = ord($this->char{0});
|
||||
|
||||
if($h <= 0x7F)
|
||||
{
|
||||
return $h;
|
||||
}
|
||||
else if($h < 0xC2)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
else if($h <= 0xDF)
|
||||
{
|
||||
return ($h & 0x1F) << 6 | (ord($this->char{1}) & 0x3F);
|
||||
}
|
||||
else if($h <= 0xEF)
|
||||
{
|
||||
return ($h & 0x0F) << 12 | (ord($this->char{1}) & 0x3F) << 6 | (ord($this->char{2}) & 0x3F);
|
||||
}
|
||||
else if($h <= 0xF4)
|
||||
{
|
||||
return ($h & 0x0F) << 18 | (ord($this->char{1}) & 0x3F) << 12 | (ord($this->char{2}) & 0x3F) << 6 | (ord($this->char{3}) & 0x3F);
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hexadecimal value of the char.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toHex()
|
||||
{
|
||||
return strtoupper(dechex($this->toAscii()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the TeamSpeak3_Helper_Char based on a given hex value.
|
||||
*
|
||||
* @param string $hex
|
||||
* @throws TeamSpeak3_Helper_Exception
|
||||
* @return TeamSpeak3_Helper_Char
|
||||
*/
|
||||
public static function fromHex($hex)
|
||||
{
|
||||
if(strlen($hex) != 2)
|
||||
{
|
||||
throw new TeamSpeak3_Helper_Exception("given parameter '" . $hex . "' is not a valid hexadecimal number");
|
||||
}
|
||||
|
||||
return new self(chr(hexdec($hex)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the character as a standard string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toString()
|
||||
{
|
||||
return $this->char;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the integer value of the character.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function toInt()
|
||||
{
|
||||
return intval($this->char);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the character as a standard string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->char;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,370 +1,370 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Helper_Convert
|
||||
* @brief Helper class for data conversion.
|
||||
*/
|
||||
class TeamSpeak3_Helper_Convert
|
||||
{
|
||||
/**
|
||||
* Converts bytes to a human readable value.
|
||||
*
|
||||
* @param integer $bytes
|
||||
* @return string
|
||||
*/
|
||||
public static function bytes($bytes)
|
||||
{
|
||||
// @todo: Fix precision lost from multiple rounding
|
||||
$kbytes = sprintf("%.02f", $bytes/1024);
|
||||
$mbytes = sprintf("%.02f", $kbytes/1024);
|
||||
$gbytes = sprintf("%.02f", $mbytes/1024);
|
||||
$tbytes = sprintf("%.02f", $gbytes/1024);
|
||||
|
||||
// @todo: Fix assuming non-negative $bytes value, without validation
|
||||
// Recommend something like: if( (float)$xbytes != 0 )
|
||||
if($tbytes >= 1)
|
||||
return $tbytes . " TB";
|
||||
if($gbytes >= 1)
|
||||
return $gbytes . " GB";
|
||||
if($mbytes >= 1)
|
||||
return $mbytes . " MB";
|
||||
if($kbytes >= 1)
|
||||
return $kbytes . " KB";
|
||||
|
||||
return $bytes . " B";
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts seconds/milliseconds to a human readable value.
|
||||
*
|
||||
* Note: Assumes non-negative integer, but no validation
|
||||
* @todo: Handle negative integer $seconds, or invalidate
|
||||
*
|
||||
* @param integer $seconds
|
||||
* @param boolean $is_ms
|
||||
* @param string $format
|
||||
* @return string
|
||||
*/
|
||||
public static function seconds($seconds, $is_ms = FALSE, $format = "%dD %02d:%02d:%02d")
|
||||
{
|
||||
if($is_ms) $seconds = $seconds/1000;
|
||||
|
||||
return sprintf($format, $seconds/60/60/24, ($seconds/60/60)%24, ($seconds/60)%60, $seconds%60);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a given codec ID to a human readable name.
|
||||
*
|
||||
* @param integer $codec
|
||||
* @return string
|
||||
*/
|
||||
public static function codec($codec)
|
||||
{
|
||||
if($codec == TeamSpeak3::CODEC_SPEEX_NARROWBAND)
|
||||
return "Speex Narrowband";
|
||||
if($codec == TeamSpeak3::CODEC_SPEEX_WIDEBAND)
|
||||
return "Speex Wideband";
|
||||
if($codec == TeamSpeak3::CODEC_SPEEX_ULTRAWIDEBAND)
|
||||
return "Speex Ultra-Wideband";
|
||||
if($codec == TeamSpeak3::CODEC_CELT_MONO)
|
||||
return "CELT Mono";
|
||||
if($codec == TeamSpeak3::CODEC_OPUS_VOICE)
|
||||
return "Opus Voice";
|
||||
if($codec == TeamSpeak3::CODEC_OPUS_MUSIC)
|
||||
return "Opus Music";
|
||||
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a given group type ID to a human readable name.
|
||||
*
|
||||
* @param integer $type
|
||||
* @return string
|
||||
*/
|
||||
public static function groupType($type)
|
||||
{
|
||||
if($type == TeamSpeak3::GROUP_DBTYPE_TEMPLATE)
|
||||
return "Template";
|
||||
if($type == TeamSpeak3::GROUP_DBTYPE_REGULAR)
|
||||
return "Regular";
|
||||
if($type == TeamSpeak3::GROUP_DBTYPE_SERVERQUERY)
|
||||
return "ServerQuery";
|
||||
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a given permission type ID to a human readable name.
|
||||
*
|
||||
* @param integer $type
|
||||
* @return string
|
||||
*/
|
||||
public static function permissionType($type)
|
||||
{
|
||||
if($type == TeamSpeak3::PERM_TYPE_SERVERGROUP)
|
||||
return "Server Group";
|
||||
if($type == TeamSpeak3::PERM_TYPE_CLIENT)
|
||||
return "Client";
|
||||
if($type == TeamSpeak3::PERM_TYPE_CHANNEL)
|
||||
return "Channel";
|
||||
if($type == TeamSpeak3::PERM_TYPE_CHANNELGROUP)
|
||||
return "Channel Group";
|
||||
if($type == TeamSpeak3::PERM_TYPE_CHANNELCLIENT)
|
||||
return "Channel Client";
|
||||
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a given permission category value to a human readable name.
|
||||
*
|
||||
* @param integer $pcat
|
||||
* @return string
|
||||
*/
|
||||
public static function permissionCategory($pcat)
|
||||
{
|
||||
if($pcat == TeamSpeak3::PERM_CAT_GLOBAL)
|
||||
return "Global";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_GLOBAL_INFORMATION)
|
||||
return "Global / Information";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_GLOBAL_SERVER_MGMT)
|
||||
return "Global / Virtual Server Management";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_GLOBAL_ADM_ACTIONS)
|
||||
return "Global / Administration";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_GLOBAL_SETTINGS)
|
||||
return "Global / Settings";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_SERVER)
|
||||
return "Virtual Server";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_SERVER_INFORMATION)
|
||||
return "Virtual Server / Information";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_SERVER_ADM_ACTIONS)
|
||||
return "Virtual Server / Administration";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_SERVER_SETTINGS)
|
||||
return "Virtual Server / Settings";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_CHANNEL)
|
||||
return "Channel";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_CHANNEL_INFORMATION)
|
||||
return "Channel / Information";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_CHANNEL_CREATE)
|
||||
return "Channel / Create";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_CHANNEL_MODIFY)
|
||||
return "Channel / Modify";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_CHANNEL_DELETE)
|
||||
return "Channel / Delete";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_CHANNEL_ACCESS)
|
||||
return "Channel / Access";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_GROUP)
|
||||
return "Group";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_GROUP_INFORMATION)
|
||||
return "Group / Information";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_GROUP_CREATE)
|
||||
return "Group / Create";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_GROUP_MODIFY)
|
||||
return "Group / Modify";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_GROUP_DELETE)
|
||||
return "Group / Delete";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_CLIENT)
|
||||
return "Client";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_CLIENT_INFORMATION)
|
||||
return "Client / Information";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_CLIENT_ADM_ACTIONS)
|
||||
return "Client / Admin";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_CLIENT_BASICS)
|
||||
return "Client / Basics";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_CLIENT_MODIFY)
|
||||
return "Client / Modify";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_FILETRANSFER)
|
||||
return "File Transfer";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_NEEDED_MODIFY_POWER)
|
||||
return "Grant";
|
||||
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a given log level ID to a human readable name and vice versa.
|
||||
*
|
||||
* @param mixed $level
|
||||
* @return string
|
||||
*/
|
||||
public static function logLevel($level)
|
||||
{
|
||||
if(is_numeric($level))
|
||||
{
|
||||
if($level == TeamSpeak3::LOGLEVEL_CRITICAL)
|
||||
return "CRITICAL";
|
||||
if($level == TeamSpeak3::LOGLEVEL_ERROR)
|
||||
return "ERROR";
|
||||
if($level == TeamSpeak3::LOGLEVEL_DEBUG)
|
||||
return "DEBUG";
|
||||
if($level == TeamSpeak3::LOGLEVEL_WARNING)
|
||||
return "WARNING";
|
||||
if($level == TeamSpeak3::LOGLEVEL_INFO)
|
||||
return "INFO";
|
||||
|
||||
return "DEVELOP";
|
||||
}
|
||||
else
|
||||
{
|
||||
if(strtoupper($level) == "CRITICAL")
|
||||
return TeamSpeak3::LOGLEVEL_CRITICAL;
|
||||
if(strtoupper($level) == "ERROR")
|
||||
return TeamSpeak3::LOGLEVEL_ERROR;
|
||||
if(strtoupper($level) == "DEBUG")
|
||||
return TeamSpeak3::LOGLEVEL_DEBUG;
|
||||
if(strtoupper($level) == "WARNING")
|
||||
return TeamSpeak3::LOGLEVEL_WARNING;
|
||||
if(strtoupper($level) == "INFO")
|
||||
return TeamSpeak3::LOGLEVEL_INFO;
|
||||
|
||||
return TeamSpeak3::LOGLEVEL_DEVEL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a specified log entry string into an array containing the data.
|
||||
*
|
||||
* @param string $entry
|
||||
* @return array
|
||||
*/
|
||||
public static function logEntry($entry)
|
||||
{
|
||||
$parts = explode("|", $entry, 5);
|
||||
$array = array();
|
||||
|
||||
if(count($parts) != 5)
|
||||
{
|
||||
$array["timestamp"] = 0;
|
||||
$array["level"] = TeamSpeak3::LOGLEVEL_ERROR;
|
||||
$array["channel"] = "ParamParser";
|
||||
$array["server_id"] = "";
|
||||
$array["msg"] = TeamSpeak3_Helper_String::factory("convert error (" . trim($entry) . ")");
|
||||
$array["msg_plain"] = $entry;
|
||||
$array["malformed"] = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
$array["timestamp"] = strtotime(trim($parts[0]));
|
||||
$array["level"] = self::logLevel(trim($parts[1]));
|
||||
$array["channel"] = trim($parts[2]);
|
||||
$array["server_id"] = trim($parts[3]);
|
||||
$array["msg"] = TeamSpeak3_Helper_String::factory(trim($parts[4]));
|
||||
$array["msg_plain"] = $entry;
|
||||
$array["malformed"] = FALSE;
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a specified 32-bit unsigned integer value to a signed 32-bit integer value.
|
||||
*
|
||||
* @param integer $unsigned
|
||||
* @return integer
|
||||
*/
|
||||
public static function iconId($unsigned)
|
||||
{
|
||||
$signed = (int) $unsigned;
|
||||
|
||||
if(PHP_INT_SIZE > 4) // 64-bit
|
||||
{
|
||||
if($signed & 0x80000000) return $signed - 0x100000000;
|
||||
}
|
||||
|
||||
return $signed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a given string to a ServerQuery password hash.
|
||||
*
|
||||
* @param string $plain
|
||||
* @return string
|
||||
*/
|
||||
public static function password($plain)
|
||||
{
|
||||
return base64_encode(sha1($plain, TRUE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a client-like formatted version of the TeamSpeak 3 version string.
|
||||
*
|
||||
* @param string $version
|
||||
* @param string $format
|
||||
* @return string
|
||||
*/
|
||||
public static function version($version, $format = "Y-m-d h:i:s")
|
||||
{
|
||||
if(!$version instanceof TeamSpeak3_Helper_String)
|
||||
{
|
||||
$version = new TeamSpeak3_Helper_String($version);
|
||||
}
|
||||
|
||||
$buildno = $version->section("[", 1)->filterDigits()->toInt();
|
||||
|
||||
return ($buildno <= 15001) ? $version : $version->section("[")->append("(" . date($format, $buildno) . ")");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a client-like short-formatted version of the TeamSpeak 3 version string.
|
||||
*
|
||||
* @param string $version
|
||||
* @return string
|
||||
*/
|
||||
public static function versionShort($version)
|
||||
{
|
||||
if(!$version instanceof TeamSpeak3_Helper_String)
|
||||
{
|
||||
$version = new TeamSpeak3_Helper_String($version);
|
||||
}
|
||||
|
||||
return $version->section(" ", 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to detect the type of an image by a given string and returns it.
|
||||
*
|
||||
* @param string $binary
|
||||
* @return string
|
||||
*/
|
||||
public static function imageMimeType($binary)
|
||||
{
|
||||
if(!preg_match('/\A(?:(\xff\xd8\xff)|(GIF8[79]a)|(\x89PNG\x0d\x0a)|(BM)|(\x49\x49(\x2a\x00|\x00\x4a))|(FORM.{4}ILBM))/', $binary, $matches))
|
||||
{
|
||||
return "image/svg+xml";
|
||||
}
|
||||
|
||||
$type = array(
|
||||
1 => "image/jpeg",
|
||||
2 => "image/gif",
|
||||
3 => "image/png",
|
||||
4 => "image/x-windows-bmp",
|
||||
5 => "image/tiff",
|
||||
6 => "image/x-ilbm",
|
||||
);
|
||||
|
||||
return $type[count($matches)-1];
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Helper_Convert
|
||||
* @brief Helper class for data conversion.
|
||||
*/
|
||||
class TeamSpeak3_Helper_Convert
|
||||
{
|
||||
/**
|
||||
* Converts bytes to a human readable value.
|
||||
*
|
||||
* @param integer $bytes
|
||||
* @return string
|
||||
*/
|
||||
public static function bytes($bytes)
|
||||
{
|
||||
// @todo: Fix precision lost from multiple rounding
|
||||
$kbytes = sprintf("%.02f", $bytes/1024);
|
||||
$mbytes = sprintf("%.02f", $kbytes/1024);
|
||||
$gbytes = sprintf("%.02f", $mbytes/1024);
|
||||
$tbytes = sprintf("%.02f", $gbytes/1024);
|
||||
|
||||
// @todo: Fix assuming non-negative $bytes value, without validation
|
||||
// Recommend something like: if( (float)$xbytes != 0 )
|
||||
if($tbytes >= 1)
|
||||
return $tbytes . " TB";
|
||||
if($gbytes >= 1)
|
||||
return $gbytes . " GB";
|
||||
if($mbytes >= 1)
|
||||
return $mbytes . " MB";
|
||||
if($kbytes >= 1)
|
||||
return $kbytes . " KB";
|
||||
|
||||
return $bytes . " B";
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts seconds/milliseconds to a human readable value.
|
||||
*
|
||||
* Note: Assumes non-negative integer, but no validation
|
||||
* @todo: Handle negative integer $seconds, or invalidate
|
||||
*
|
||||
* @param integer $seconds
|
||||
* @param boolean $is_ms
|
||||
* @param string $format
|
||||
* @return string
|
||||
*/
|
||||
public static function seconds($seconds, $is_ms = FALSE, $format = "%dD %02d:%02d:%02d")
|
||||
{
|
||||
if($is_ms) $seconds = $seconds/1000;
|
||||
|
||||
return sprintf($format, $seconds/60/60/24, ($seconds/60/60)%24, ($seconds/60)%60, $seconds%60);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a given codec ID to a human readable name.
|
||||
*
|
||||
* @param integer $codec
|
||||
* @return string
|
||||
*/
|
||||
public static function codec($codec)
|
||||
{
|
||||
if($codec == TeamSpeak3::CODEC_SPEEX_NARROWBAND)
|
||||
return "Speex Narrowband";
|
||||
if($codec == TeamSpeak3::CODEC_SPEEX_WIDEBAND)
|
||||
return "Speex Wideband";
|
||||
if($codec == TeamSpeak3::CODEC_SPEEX_ULTRAWIDEBAND)
|
||||
return "Speex Ultra-Wideband";
|
||||
if($codec == TeamSpeak3::CODEC_CELT_MONO)
|
||||
return "CELT Mono";
|
||||
if($codec == TeamSpeak3::CODEC_OPUS_VOICE)
|
||||
return "Opus Voice";
|
||||
if($codec == TeamSpeak3::CODEC_OPUS_MUSIC)
|
||||
return "Opus Music";
|
||||
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a given group type ID to a human readable name.
|
||||
*
|
||||
* @param integer $type
|
||||
* @return string
|
||||
*/
|
||||
public static function groupType($type)
|
||||
{
|
||||
if($type == TeamSpeak3::GROUP_DBTYPE_TEMPLATE)
|
||||
return "Template";
|
||||
if($type == TeamSpeak3::GROUP_DBTYPE_REGULAR)
|
||||
return "Regular";
|
||||
if($type == TeamSpeak3::GROUP_DBTYPE_SERVERQUERY)
|
||||
return "ServerQuery";
|
||||
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a given permission type ID to a human readable name.
|
||||
*
|
||||
* @param integer $type
|
||||
* @return string
|
||||
*/
|
||||
public static function permissionType($type)
|
||||
{
|
||||
if($type == TeamSpeak3::PERM_TYPE_SERVERGROUP)
|
||||
return "Server Group";
|
||||
if($type == TeamSpeak3::PERM_TYPE_CLIENT)
|
||||
return "Client";
|
||||
if($type == TeamSpeak3::PERM_TYPE_CHANNEL)
|
||||
return "Channel";
|
||||
if($type == TeamSpeak3::PERM_TYPE_CHANNELGROUP)
|
||||
return "Channel Group";
|
||||
if($type == TeamSpeak3::PERM_TYPE_CHANNELCLIENT)
|
||||
return "Channel Client";
|
||||
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a given permission category value to a human readable name.
|
||||
*
|
||||
* @param integer $pcat
|
||||
* @return string
|
||||
*/
|
||||
public static function permissionCategory($pcat)
|
||||
{
|
||||
if($pcat == TeamSpeak3::PERM_CAT_GLOBAL)
|
||||
return "Global";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_GLOBAL_INFORMATION)
|
||||
return "Global / Information";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_GLOBAL_SERVER_MGMT)
|
||||
return "Global / Virtual Server Management";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_GLOBAL_ADM_ACTIONS)
|
||||
return "Global / Administration";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_GLOBAL_SETTINGS)
|
||||
return "Global / Settings";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_SERVER)
|
||||
return "Virtual Server";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_SERVER_INFORMATION)
|
||||
return "Virtual Server / Information";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_SERVER_ADM_ACTIONS)
|
||||
return "Virtual Server / Administration";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_SERVER_SETTINGS)
|
||||
return "Virtual Server / Settings";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_CHANNEL)
|
||||
return "Channel";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_CHANNEL_INFORMATION)
|
||||
return "Channel / Information";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_CHANNEL_CREATE)
|
||||
return "Channel / Create";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_CHANNEL_MODIFY)
|
||||
return "Channel / Modify";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_CHANNEL_DELETE)
|
||||
return "Channel / Delete";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_CHANNEL_ACCESS)
|
||||
return "Channel / Access";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_GROUP)
|
||||
return "Group";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_GROUP_INFORMATION)
|
||||
return "Group / Information";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_GROUP_CREATE)
|
||||
return "Group / Create";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_GROUP_MODIFY)
|
||||
return "Group / Modify";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_GROUP_DELETE)
|
||||
return "Group / Delete";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_CLIENT)
|
||||
return "Client";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_CLIENT_INFORMATION)
|
||||
return "Client / Information";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_CLIENT_ADM_ACTIONS)
|
||||
return "Client / Admin";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_CLIENT_BASICS)
|
||||
return "Client / Basics";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_CLIENT_MODIFY)
|
||||
return "Client / Modify";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_FILETRANSFER)
|
||||
return "File Transfer";
|
||||
if($pcat == TeamSpeak3::PERM_CAT_NEEDED_MODIFY_POWER)
|
||||
return "Grant";
|
||||
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a given log level ID to a human readable name and vice versa.
|
||||
*
|
||||
* @param mixed $level
|
||||
* @return string
|
||||
*/
|
||||
public static function logLevel($level)
|
||||
{
|
||||
if(is_numeric($level))
|
||||
{
|
||||
if($level == TeamSpeak3::LOGLEVEL_CRITICAL)
|
||||
return "CRITICAL";
|
||||
if($level == TeamSpeak3::LOGLEVEL_ERROR)
|
||||
return "ERROR";
|
||||
if($level == TeamSpeak3::LOGLEVEL_DEBUG)
|
||||
return "DEBUG";
|
||||
if($level == TeamSpeak3::LOGLEVEL_WARNING)
|
||||
return "WARNING";
|
||||
if($level == TeamSpeak3::LOGLEVEL_INFO)
|
||||
return "INFO";
|
||||
|
||||
return "DEVELOP";
|
||||
}
|
||||
else
|
||||
{
|
||||
if(strtoupper($level) == "CRITICAL")
|
||||
return TeamSpeak3::LOGLEVEL_CRITICAL;
|
||||
if(strtoupper($level) == "ERROR")
|
||||
return TeamSpeak3::LOGLEVEL_ERROR;
|
||||
if(strtoupper($level) == "DEBUG")
|
||||
return TeamSpeak3::LOGLEVEL_DEBUG;
|
||||
if(strtoupper($level) == "WARNING")
|
||||
return TeamSpeak3::LOGLEVEL_WARNING;
|
||||
if(strtoupper($level) == "INFO")
|
||||
return TeamSpeak3::LOGLEVEL_INFO;
|
||||
|
||||
return TeamSpeak3::LOGLEVEL_DEVEL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a specified log entry string into an array containing the data.
|
||||
*
|
||||
* @param string $entry
|
||||
* @return array
|
||||
*/
|
||||
public static function logEntry($entry)
|
||||
{
|
||||
$parts = explode("|", $entry, 5);
|
||||
$array = array();
|
||||
|
||||
if(count($parts) != 5)
|
||||
{
|
||||
$array["timestamp"] = 0;
|
||||
$array["level"] = TeamSpeak3::LOGLEVEL_ERROR;
|
||||
$array["channel"] = "ParamParser";
|
||||
$array["server_id"] = "";
|
||||
$array["msg"] = TeamSpeak3_Helper_String::factory("convert error (" . trim($entry) . ")");
|
||||
$array["msg_plain"] = $entry;
|
||||
$array["malformed"] = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
$array["timestamp"] = strtotime(trim($parts[0]));
|
||||
$array["level"] = self::logLevel(trim($parts[1]));
|
||||
$array["channel"] = trim($parts[2]);
|
||||
$array["server_id"] = trim($parts[3]);
|
||||
$array["msg"] = TeamSpeak3_Helper_String::factory(trim($parts[4]));
|
||||
$array["msg_plain"] = $entry;
|
||||
$array["malformed"] = FALSE;
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a specified 32-bit unsigned integer value to a signed 32-bit integer value.
|
||||
*
|
||||
* @param integer $unsigned
|
||||
* @return integer
|
||||
*/
|
||||
public static function iconId($unsigned)
|
||||
{
|
||||
$signed = (int) $unsigned;
|
||||
|
||||
if(PHP_INT_SIZE > 4) // 64-bit
|
||||
{
|
||||
if($signed & 0x80000000) return $signed - 0x100000000;
|
||||
}
|
||||
|
||||
return $signed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a given string to a ServerQuery password hash.
|
||||
*
|
||||
* @param string $plain
|
||||
* @return string
|
||||
*/
|
||||
public static function password($plain)
|
||||
{
|
||||
return base64_encode(sha1($plain, TRUE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a client-like formatted version of the TeamSpeak 3 version string.
|
||||
*
|
||||
* @param string $version
|
||||
* @param string $format
|
||||
* @return string
|
||||
*/
|
||||
public static function version($version, $format = "Y-m-d h:i:s")
|
||||
{
|
||||
if(!$version instanceof TeamSpeak3_Helper_String)
|
||||
{
|
||||
$version = new TeamSpeak3_Helper_String($version);
|
||||
}
|
||||
|
||||
$buildno = $version->section("[", 1)->filterDigits()->toInt();
|
||||
|
||||
return ($buildno <= 15001) ? $version : $version->section("[")->append("(" . date($format, $buildno) . ")");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a client-like short-formatted version of the TeamSpeak 3 version string.
|
||||
*
|
||||
* @param string $version
|
||||
* @return string
|
||||
*/
|
||||
public static function versionShort($version)
|
||||
{
|
||||
if(!$version instanceof TeamSpeak3_Helper_String)
|
||||
{
|
||||
$version = new TeamSpeak3_Helper_String($version);
|
||||
}
|
||||
|
||||
return $version->section(" ", 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to detect the type of an image by a given string and returns it.
|
||||
*
|
||||
* @param string $binary
|
||||
* @return string
|
||||
*/
|
||||
public static function imageMimeType($binary)
|
||||
{
|
||||
if(!preg_match('/\A(?:(\xff\xd8\xff)|(GIF8[79]a)|(\x89PNG\x0d\x0a)|(BM)|(\x49\x49(\x2a\x00|\x00\x4a))|(FORM.{4}ILBM))/', $binary, $matches))
|
||||
{
|
||||
return "image/svg+xml";
|
||||
}
|
||||
|
||||
$type = array(
|
||||
1 => "image/jpeg",
|
||||
2 => "image/gif",
|
||||
3 => "image/png",
|
||||
4 => "image/x-windows-bmp",
|
||||
5 => "image/tiff",
|
||||
6 => "image/x-ilbm",
|
||||
);
|
||||
|
||||
return $type[count($matches)-1];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,481 +1,481 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @todo: Replace this class with native encryption
|
||||
*
|
||||
* @class TeamSpeak3_Helper_Crypt
|
||||
* @brief Helper class for data encryption.
|
||||
*/
|
||||
class TeamSpeak3_Helper_Crypt
|
||||
{
|
||||
/**
|
||||
* Stores the secret passphrase to encrypt or decrypt a given string.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $passphrase = null;
|
||||
|
||||
/**
|
||||
* Stores an array containing 18 32-bit entries.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $p = array();
|
||||
|
||||
/**
|
||||
* Stores an array containing 4 sub-arrays with 256 32-bit entries.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $s = array();
|
||||
|
||||
/**
|
||||
* The TeamSpeak3_Helper_Crypt constructor.
|
||||
*
|
||||
* @param string $secret
|
||||
* @return TeamSpeak3_Helper_Crypt
|
||||
*/
|
||||
public function __construct($secret)
|
||||
{
|
||||
$this->setDefaultKeys();
|
||||
$this->setSecretKey($secret);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encrypts a given string.
|
||||
*
|
||||
* @param string $string
|
||||
* @return string
|
||||
*/
|
||||
public function encrypt($string)
|
||||
{
|
||||
$string = trim($string);
|
||||
$encryp = "";
|
||||
$length = strlen($string);
|
||||
$string .= str_repeat(chr(0), (8-($length%8))%8);
|
||||
|
||||
for($i = 0; $i < $length; $i += 8)
|
||||
{
|
||||
list(,$xl,$xr) = unpack("N2", substr($string, $i, 8));
|
||||
$this->encipher($xl, $xr);
|
||||
$encryp .= pack("N2", $xl, $xr);
|
||||
}
|
||||
|
||||
return base64_encode($encryp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrypts a given string.
|
||||
*
|
||||
* @param string $string
|
||||
* @return string
|
||||
*/
|
||||
public function decrypt($string)
|
||||
{
|
||||
$string = base64_decode($string);
|
||||
$decryp = "";
|
||||
$length = strlen($string);
|
||||
$string .= str_repeat(chr(0), (8-($length%8))%8);
|
||||
|
||||
for($i = 0; $i < $length; $i += 8)
|
||||
{
|
||||
list(,$xl,$xr) = unpack("N2", substr($string, $i, 8));
|
||||
$this->decipher($xl, $xr);
|
||||
$decryp .= pack("N2", $xl, $xr);
|
||||
}
|
||||
|
||||
return trim($decryp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enciphers a single 64-bit block.
|
||||
*
|
||||
* @param integer $xl
|
||||
* @param integer $xr
|
||||
*/
|
||||
protected function encipher(&$xl, &$xr)
|
||||
{
|
||||
for($i = 0; $i < 16; $i++)
|
||||
{
|
||||
$temp = $xl ^ $this->p[$i];
|
||||
$xl = ((($this->s[0][($temp>>24) & 255] + $this->s[1][($temp>>16) & 255]) ^ $this->s[2][($temp>>8) & 255]) + $this->s[3][$temp & 255]) ^ $xr;
|
||||
$xr = $temp;
|
||||
}
|
||||
|
||||
$xr = $xl ^ $this->p[16];
|
||||
$xl = $temp ^ $this->p[17];
|
||||
}
|
||||
|
||||
/**
|
||||
* Deciphers a single 64-bit block
|
||||
*
|
||||
* @param integer $xl
|
||||
* @param integer $xr
|
||||
* @return void
|
||||
*/
|
||||
protected function decipher(&$xl, &$xr)
|
||||
{
|
||||
for($i = 17; $i > 1; $i--)
|
||||
{
|
||||
$temp = $xl ^ $this->p[$i];
|
||||
$xl = ((($this->s[0][($temp>>24) & 255] + $this->s[1][($temp>>16) & 255]) ^ $this->s[2][($temp>>8) & 255]) + $this->s[3][$temp & 255]) ^ $xr;
|
||||
$xr = $temp;
|
||||
}
|
||||
|
||||
$xr = $xl ^ $this->p[1];
|
||||
$xl = $temp ^ $this->p[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the secret key using the specified pasphrase.
|
||||
*
|
||||
* @param string $passphrase
|
||||
* @throws Habitat_Exception
|
||||
* @return void
|
||||
*/
|
||||
protected function setSecretKey($passphrase)
|
||||
{
|
||||
$length = strlen($passphrase);
|
||||
|
||||
if(strlen($passphrase) < 1 || strlen($passphrase) > 56)
|
||||
{
|
||||
throw new TeamSpeak3_Helper_Exception("secret passphrase must contain at least one but less than 56 characters");
|
||||
}
|
||||
|
||||
$k = 0;
|
||||
$data = 0;
|
||||
$datal = 0;
|
||||
$datar = 0;
|
||||
|
||||
for($i = 0; $i < 18; $i++)
|
||||
{
|
||||
$data = 0;
|
||||
for($j = 4; $j > 0; $j--)
|
||||
{
|
||||
$data = $data << 8 | ord($passphrase{$k});
|
||||
$k = ($k+1) % $length;
|
||||
}
|
||||
$this->p[$i] ^= $data;
|
||||
}
|
||||
|
||||
|
||||
for($i = 0; $i <= 16; $i += 2)
|
||||
{
|
||||
$this->encipher($datal, $datar);
|
||||
$this->p[$i] = $datal;
|
||||
$this->p[$i+1] = $datar;
|
||||
}
|
||||
|
||||
foreach($this->s as $key => $val)
|
||||
{
|
||||
for ($i = 0; $i < 256; $i += 2)
|
||||
{
|
||||
$this->encipher($datal, $datar);
|
||||
$this->s[$key][$i] = $datal;
|
||||
$this->s[$key][$i+1] = $datar;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the defult p and s keys.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setDefaultKeys()
|
||||
{
|
||||
$this->p = array(
|
||||
0x243F6A88, 0x85A308D3, 0x13198A2E, 0x03707344, 0xA4093822, 0x299F31D0,
|
||||
0x082EFA98, 0xEC4E6C89, 0x452821E6, 0x38D01377, 0xBE5466CF, 0x34E90C6C,
|
||||
0xC0AC29B7, 0xC97C50DD, 0x3F84D5B5, 0xB5470917, 0x9216D5D9, 0x8979FB1B,
|
||||
);
|
||||
$this->s = array(
|
||||
array(
|
||||
0xD1310BA6, 0x98DFB5AC, 0x2FFD72DB, 0xD01ADFB7,
|
||||
0xB8E1AFED, 0x6A267E96, 0xBA7C9045, 0xF12C7F99,
|
||||
0x24A19947, 0xB3916CF7, 0x0801F2E2, 0x858EFC16,
|
||||
0x636920D8, 0x71574E69, 0xA458FEA3, 0xF4933D7E,
|
||||
0x0D95748F, 0x728EB658, 0x718BCD58, 0x82154AEE,
|
||||
0x7B54A41D, 0xC25A59B5, 0x9C30D539, 0x2AF26013,
|
||||
0xC5D1B023, 0x286085F0, 0xCA417918, 0xB8DB38EF,
|
||||
0x8E79DCB0, 0x603A180E, 0x6C9E0E8B, 0xB01E8A3E,
|
||||
0xD71577C1, 0xBD314B27, 0x78AF2FDA, 0x55605C60,
|
||||
0xE65525F3, 0xAA55AB94, 0x57489862, 0x63E81440,
|
||||
0x55CA396A, 0x2AAB10B6, 0xB4CC5C34, 0x1141E8CE,
|
||||
0xA15486AF, 0x7C72E993, 0xB3EE1411, 0x636FBC2A,
|
||||
0x2BA9C55D, 0x741831F6, 0xCE5C3E16, 0x9B87931E,
|
||||
0xAFD6BA33, 0x6C24CF5C, 0x7A325381, 0x28958677,
|
||||
0x3B8F4898, 0x6B4BB9AF, 0xC4BFE81B, 0x66282193,
|
||||
0x61D809CC, 0xFB21A991, 0x487CAC60, 0x5DEC8032,
|
||||
0xEF845D5D, 0xE98575B1, 0xDC262302, 0xEB651B88,
|
||||
0x23893E81, 0xD396ACC5, 0x0F6D6FF3, 0x83F44239,
|
||||
0x2E0B4482, 0xA4842004, 0x69C8F04A, 0x9E1F9B5E,
|
||||
0x21C66842, 0xF6E96C9A, 0x670C9C61, 0xABD388F0,
|
||||
0x6A51A0D2, 0xD8542F68, 0x960FA728, 0xAB5133A3,
|
||||
0x6EEF0B6C, 0x137A3BE4, 0xBA3BF050, 0x7EFB2A98,
|
||||
0xA1F1651D, 0x39AF0176, 0x66CA593E, 0x82430E88,
|
||||
0x8CEE8619, 0x456F9FB4, 0x7D84A5C3, 0x3B8B5EBE,
|
||||
0xE06F75D8, 0x85C12073, 0x401A449F, 0x56C16AA6,
|
||||
0x4ED3AA62, 0x363F7706, 0x1BFEDF72, 0x429B023D,
|
||||
0x37D0D724, 0xD00A1248, 0xDB0FEAD3, 0x49F1C09B,
|
||||
0x075372C9, 0x80991B7B, 0x25D479D8, 0xF6E8DEF7,
|
||||
0xE3FE501A, 0xB6794C3B, 0x976CE0BD, 0x04C006BA,
|
||||
0xC1A94FB6, 0x409F60C4, 0x5E5C9EC2, 0x196A2463,
|
||||
0x68FB6FAF, 0x3E6C53B5, 0x1339B2EB, 0x3B52EC6F,
|
||||
0x6DFC511F, 0x9B30952C, 0xCC814544, 0xAF5EBD09,
|
||||
0xBEE3D004, 0xDE334AFD, 0x660F2807, 0x192E4BB3,
|
||||
0xC0CBA857, 0x45C8740F, 0xD20B5F39, 0xB9D3FBDB,
|
||||
0x5579C0BD, 0x1A60320A, 0xD6A100C6, 0x402C7279,
|
||||
0x679F25FE, 0xFB1FA3CC, 0x8EA5E9F8, 0xDB3222F8,
|
||||
0x3C7516DF, 0xFD616B15, 0x2F501EC8, 0xAD0552AB,
|
||||
0x323DB5FA, 0xFD238760, 0x53317B48, 0x3E00DF82,
|
||||
0x9E5C57BB, 0xCA6F8CA0, 0x1A87562E, 0xDF1769DB,
|
||||
0xD542A8F6, 0x287EFFC3, 0xAC6732C6, 0x8C4F5573,
|
||||
0x695B27B0, 0xBBCA58C8, 0xE1FFA35D, 0xB8F011A0,
|
||||
0x10FA3D98, 0xFD2183B8, 0x4AFCB56C, 0x2DD1D35B,
|
||||
0x9A53E479, 0xB6F84565, 0xD28E49BC, 0x4BFB9790,
|
||||
0xE1DDF2DA, 0xA4CB7E33, 0x62FB1341, 0xCEE4C6E8,
|
||||
0xEF20CADA, 0x36774C01, 0xD07E9EFE, 0x2BF11FB4,
|
||||
0x95DBDA4D, 0xAE909198, 0xEAAD8E71, 0x6B93D5A0,
|
||||
0xD08ED1D0, 0xAFC725E0, 0x8E3C5B2F, 0x8E7594B7,
|
||||
0x8FF6E2FB, 0xF2122B64, 0x8888B812, 0x900DF01C,
|
||||
0x4FAD5EA0, 0x688FC31C, 0xD1CFF191, 0xB3A8C1AD,
|
||||
0x2F2F2218, 0xBE0E1777, 0xEA752DFE, 0x8B021FA1,
|
||||
0xE5A0CC0F, 0xB56F74E8, 0x18ACF3D6, 0xCE89E299,
|
||||
0xB4A84FE0, 0xFD13E0B7, 0x7CC43B81, 0xD2ADA8D9,
|
||||
0x165FA266, 0x80957705, 0x93CC7314, 0x211A1477,
|
||||
0xE6AD2065, 0x77B5FA86, 0xC75442F5, 0xFB9D35CF,
|
||||
0xEBCDAF0C, 0x7B3E89A0, 0xD6411BD3, 0xAE1E7E49,
|
||||
0x00250E2D, 0x2071B35E, 0x226800BB, 0x57B8E0AF,
|
||||
0x2464369B, 0xF009B91E, 0x5563911D, 0x59DFA6AA,
|
||||
0x78C14389, 0xD95A537F, 0x207D5BA2, 0x02E5B9C5,
|
||||
0x83260376, 0x6295CFA9, 0x11C81968, 0x4E734A41,
|
||||
0xB3472DCA, 0x7B14A94A, 0x1B510052, 0x9A532915,
|
||||
0xD60F573F, 0xBC9BC6E4, 0x2B60A476, 0x81E67400,
|
||||
0x08BA6FB5, 0x571BE91F, 0xF296EC6B, 0x2A0DD915,
|
||||
0xB6636521, 0xE7B9F9B6, 0xFF34052E, 0xC5855664,
|
||||
0x53B02D5D, 0xA99F8FA1, 0x08BA4799, 0x6E85076A
|
||||
),
|
||||
array(
|
||||
0x4B7A70E9, 0xB5B32944, 0xDB75092E, 0xC4192623,
|
||||
0xAD6EA6B0, 0x49A7DF7D, 0x9CEE60B8, 0x8FEDB266,
|
||||
0xECAA8C71, 0x699A17FF, 0x5664526C, 0xC2B19EE1,
|
||||
0x193602A5, 0x75094C29, 0xA0591340, 0xE4183A3E,
|
||||
0x3F54989A, 0x5B429D65, 0x6B8FE4D6, 0x99F73FD6,
|
||||
0xA1D29C07, 0xEFE830F5, 0x4D2D38E6, 0xF0255DC1,
|
||||
0x4CDD2086, 0x8470EB26, 0x6382E9C6, 0x021ECC5E,
|
||||
0x09686B3F, 0x3EBAEFC9, 0x3C971814, 0x6B6A70A1,
|
||||
0x687F3584, 0x52A0E286, 0xB79C5305, 0xAA500737,
|
||||
0x3E07841C, 0x7FDEAE5C, 0x8E7D44EC, 0x5716F2B8,
|
||||
0xB03ADA37, 0xF0500C0D, 0xF01C1F04, 0x0200B3FF,
|
||||
0xAE0CF51A, 0x3CB574B2, 0x25837A58, 0xDC0921BD,
|
||||
0xD19113F9, 0x7CA92FF6, 0x94324773, 0x22F54701,
|
||||
0x3AE5E581, 0x37C2DADC, 0xC8B57634, 0x9AF3DDA7,
|
||||
0xA9446146, 0x0FD0030E, 0xECC8C73E, 0xA4751E41,
|
||||
0xE238CD99, 0x3BEA0E2F, 0x3280BBA1, 0x183EB331,
|
||||
0x4E548B38, 0x4F6DB908, 0x6F420D03, 0xF60A04BF,
|
||||
0x2CB81290, 0x24977C79, 0x5679B072, 0xBCAF89AF,
|
||||
0xDE9A771F, 0xD9930810, 0xB38BAE12, 0xDCCF3F2E,
|
||||
0x5512721F, 0x2E6B7124, 0x501ADDE6, 0x9F84CD87,
|
||||
0x7A584718, 0x7408DA17, 0xBC9F9ABC, 0xE94B7D8C,
|
||||
0xEC7AEC3A, 0xDB851DFA, 0x63094366, 0xC464C3D2,
|
||||
0xEF1C1847, 0x3215D908, 0xDD433B37, 0x24C2BA16,
|
||||
0x12A14D43, 0x2A65C451, 0x50940002, 0x133AE4DD,
|
||||
0x71DFF89E, 0x10314E55, 0x81AC77D6, 0x5F11199B,
|
||||
0x043556F1, 0xD7A3C76B, 0x3C11183B, 0x5924A509,
|
||||
0xF28FE6ED, 0x97F1FBFA, 0x9EBABF2C, 0x1E153C6E,
|
||||
0x86E34570, 0xEAE96FB1, 0x860E5E0A, 0x5A3E2AB3,
|
||||
0x771FE71C, 0x4E3D06FA, 0x2965DCB9, 0x99E71D0F,
|
||||
0x803E89D6, 0x5266C825, 0x2E4CC978, 0x9C10B36A,
|
||||
0xC6150EBA, 0x94E2EA78, 0xA5FC3C53, 0x1E0A2DF4,
|
||||
0xF2F74EA7, 0x361D2B3D, 0x1939260F, 0x19C27960,
|
||||
0x5223A708, 0xF71312B6, 0xEBADFE6E, 0xEAC31F66,
|
||||
0xE3BC4595, 0xA67BC883, 0xB17F37D1, 0x018CFF28,
|
||||
0xC332DDEF, 0xBE6C5AA5, 0x65582185, 0x68AB9802,
|
||||
0xEECEA50F, 0xDB2F953B, 0x2AEF7DAD, 0x5B6E2F84,
|
||||
0x1521B628, 0x29076170, 0xECDD4775, 0x619F1510,
|
||||
0x13CCA830, 0xEB61BD96, 0x0334FE1E, 0xAA0363CF,
|
||||
0xB5735C90, 0x4C70A239, 0xD59E9E0B, 0xCBAADE14,
|
||||
0xEECC86BC, 0x60622CA7, 0x9CAB5CAB, 0xB2F3846E,
|
||||
0x648B1EAF, 0x19BDF0CA, 0xA02369B9, 0x655ABB50,
|
||||
0x40685A32, 0x3C2AB4B3, 0x319EE9D5, 0xC021B8F7,
|
||||
0x9B540B19, 0x875FA099, 0x95F7997E, 0x623D7DA8,
|
||||
0xF837889A, 0x97E32D77, 0x11ED935F, 0x16681281,
|
||||
0x0E358829, 0xC7E61FD6, 0x96DEDFA1, 0x7858BA99,
|
||||
0x57F584A5, 0x1B227263, 0x9B83C3FF, 0x1AC24696,
|
||||
0xCDB30AEB, 0x532E3054, 0x8FD948E4, 0x6DBC3128,
|
||||
0x58EBF2EF, 0x34C6FFEA, 0xFE28ED61, 0xEE7C3C73,
|
||||
0x5D4A14D9, 0xE864B7E3, 0x42105D14, 0x203E13E0,
|
||||
0x45EEE2B6, 0xA3AAABEA, 0xDB6C4F15, 0xFACB4FD0,
|
||||
0xC742F442, 0xEF6ABBB5, 0x654F3B1D, 0x41CD2105,
|
||||
0xD81E799E, 0x86854DC7, 0xE44B476A, 0x3D816250,
|
||||
0xCF62A1F2, 0x5B8D2646, 0xFC8883A0, 0xC1C7B6A3,
|
||||
0x7F1524C3, 0x69CB7492, 0x47848A0B, 0x5692B285,
|
||||
0x095BBF00, 0xAD19489D, 0x1462B174, 0x23820E00,
|
||||
0x58428D2A, 0x0C55F5EA, 0x1DADF43E, 0x233F7061,
|
||||
0x3372F092, 0x8D937E41, 0xD65FECF1, 0x6C223BDB,
|
||||
0x7CDE3759, 0xCBEE7460, 0x4085F2A7, 0xCE77326E,
|
||||
0xA6078084, 0x19F8509E, 0xE8EFD855, 0x61D99735,
|
||||
0xA969A7AA, 0xC50C06C2, 0x5A04ABFC, 0x800BCADC,
|
||||
0x9E447A2E, 0xC3453484, 0xFDD56705, 0x0E1E9EC9,
|
||||
0xDB73DBD3, 0x105588CD, 0x675FDA79, 0xE3674340,
|
||||
0xC5C43465, 0x713E38D8, 0x3D28F89E, 0xF16DFF20,
|
||||
0x153E21E7, 0x8FB03D4A, 0xE6E39F2B, 0xDB83ADF7
|
||||
),
|
||||
array(
|
||||
0xE93D5A68, 0x948140F7, 0xF64C261C, 0x94692934,
|
||||
0x411520F7, 0x7602D4F7, 0xBCF46B2E, 0xD4A20068,
|
||||
0xD4082471, 0x3320F46A, 0x43B7D4B7, 0x500061AF,
|
||||
0x1E39F62E, 0x97244546, 0x14214F74, 0xBF8B8840,
|
||||
0x4D95FC1D, 0x96B591AF, 0x70F4DDD3, 0x66A02F45,
|
||||
0xBFBC09EC, 0x03BD9785, 0x7FAC6DD0, 0x31CB8504,
|
||||
0x96EB27B3, 0x55FD3941, 0xDA2547E6, 0xABCA0A9A,
|
||||
0x28507825, 0x530429F4, 0x0A2C86DA, 0xE9B66DFB,
|
||||
0x68DC1462, 0xD7486900, 0x680EC0A4, 0x27A18DEE,
|
||||
0x4F3FFEA2, 0xE887AD8C, 0xB58CE006, 0x7AF4D6B6,
|
||||
0xAACE1E7C, 0xD3375FEC, 0xCE78A399, 0x406B2A42,
|
||||
0x20FE9E35, 0xD9F385B9, 0xEE39D7AB, 0x3B124E8B,
|
||||
0x1DC9FAF7, 0x4B6D1856, 0x26A36631, 0xEAE397B2,
|
||||
0x3A6EFA74, 0xDD5B4332, 0x6841E7F7, 0xCA7820FB,
|
||||
0xFB0AF54E, 0xD8FEB397, 0x454056AC, 0xBA489527,
|
||||
0x55533A3A, 0x20838D87, 0xFE6BA9B7, 0xD096954B,
|
||||
0x55A867BC, 0xA1159A58, 0xCCA92963, 0x99E1DB33,
|
||||
0xA62A4A56, 0x3F3125F9, 0x5EF47E1C, 0x9029317C,
|
||||
0xFDF8E802, 0x04272F70, 0x80BB155C, 0x05282CE3,
|
||||
0x95C11548, 0xE4C66D22, 0x48C1133F, 0xC70F86DC,
|
||||
0x07F9C9EE, 0x41041F0F, 0x404779A4, 0x5D886E17,
|
||||
0x325F51EB, 0xD59BC0D1, 0xF2BCC18F, 0x41113564,
|
||||
0x257B7834, 0x602A9C60, 0xDFF8E8A3, 0x1F636C1B,
|
||||
0x0E12B4C2, 0x02E1329E, 0xAF664FD1, 0xCAD18115,
|
||||
0x6B2395E0, 0x333E92E1, 0x3B240B62, 0xEEBEB922,
|
||||
0x85B2A20E, 0xE6BA0D99, 0xDE720C8C, 0x2DA2F728,
|
||||
0xD0127845, 0x95B794FD, 0x647D0862, 0xE7CCF5F0,
|
||||
0x5449A36F, 0x877D48FA, 0xC39DFD27, 0xF33E8D1E,
|
||||
0x0A476341, 0x992EFF74, 0x3A6F6EAB, 0xF4F8FD37,
|
||||
0xA812DC60, 0xA1EBDDF8, 0x991BE14C, 0xDB6E6B0D,
|
||||
0xC67B5510, 0x6D672C37, 0x2765D43B, 0xDCD0E804,
|
||||
0xF1290DC7, 0xCC00FFA3, 0xB5390F92, 0x690FED0B,
|
||||
0x667B9FFB, 0xCEDB7D9C, 0xA091CF0B, 0xD9155EA3,
|
||||
0xBB132F88, 0x515BAD24, 0x7B9479BF, 0x763BD6EB,
|
||||
0x37392EB3, 0xCC115979, 0x8026E297, 0xF42E312D,
|
||||
0x6842ADA7, 0xC66A2B3B, 0x12754CCC, 0x782EF11C,
|
||||
0x6A124237, 0xB79251E7, 0x06A1BBE6, 0x4BFB6350,
|
||||
0x1A6B1018, 0x11CAEDFA, 0x3D25BDD8, 0xE2E1C3C9,
|
||||
0x44421659, 0x0A121386, 0xD90CEC6E, 0xD5ABEA2A,
|
||||
0x64AF674E, 0xDA86A85F, 0xBEBFE988, 0x64E4C3FE,
|
||||
0x9DBC8057, 0xF0F7C086, 0x60787BF8, 0x6003604D,
|
||||
0xD1FD8346, 0xF6381FB0, 0x7745AE04, 0xD736FCCC,
|
||||
0x83426B33, 0xF01EAB71, 0xB0804187, 0x3C005E5F,
|
||||
0x77A057BE, 0xBDE8AE24, 0x55464299, 0xBF582E61,
|
||||
0x4E58F48F, 0xF2DDFDA2, 0xF474EF38, 0x8789BDC2,
|
||||
0x5366F9C3, 0xC8B38E74, 0xB475F255, 0x46FCD9B9,
|
||||
0x7AEB2661, 0x8B1DDF84, 0x846A0E79, 0x915F95E2,
|
||||
0x466E598E, 0x20B45770, 0x8CD55591, 0xC902DE4C,
|
||||
0xB90BACE1, 0xBB8205D0, 0x11A86248, 0x7574A99E,
|
||||
0xB77F19B6, 0xE0A9DC09, 0x662D09A1, 0xC4324633,
|
||||
0xE85A1F02, 0x09F0BE8C, 0x4A99A025, 0x1D6EFE10,
|
||||
0x1AB93D1D, 0x0BA5A4DF, 0xA186F20F, 0x2868F169,
|
||||
0xDCB7DA83, 0x573906FE, 0xA1E2CE9B, 0x4FCD7F52,
|
||||
0x50115E01, 0xA70683FA, 0xA002B5C4, 0x0DE6D027,
|
||||
0x9AF88C27, 0x773F8641, 0xC3604C06, 0x61A806B5,
|
||||
0xF0177A28, 0xC0F586E0, 0x006058AA, 0x30DC7D62,
|
||||
0x11E69ED7, 0x2338EA63, 0x53C2DD94, 0xC2C21634,
|
||||
0xBBCBEE56, 0x90BCB6DE, 0xEBFC7DA1, 0xCE591D76,
|
||||
0x6F05E409, 0x4B7C0188, 0x39720A3D, 0x7C927C24,
|
||||
0x86E3725F, 0x724D9DB9, 0x1AC15BB4, 0xD39EB8FC,
|
||||
0xED545578, 0x08FCA5B5, 0xD83D7CD3, 0x4DAD0FC4,
|
||||
0x1E50EF5E, 0xB161E6F8, 0xA28514D9, 0x6C51133C,
|
||||
0x6FD5C7E7, 0x56E14EC4, 0x362ABFCE, 0xDDC6C837,
|
||||
0xD79A3234, 0x92638212, 0x670EFA8E, 0x406000E0
|
||||
),
|
||||
array(
|
||||
0x3A39CE37, 0xD3FAF5CF, 0xABC27737, 0x5AC52D1B,
|
||||
0x5CB0679E, 0x4FA33742, 0xD3822740, 0x99BC9BBE,
|
||||
0xD5118E9D, 0xBF0F7315, 0xD62D1C7E, 0xC700C47B,
|
||||
0xB78C1B6B, 0x21A19045, 0xB26EB1BE, 0x6A366EB4,
|
||||
0x5748AB2F, 0xBC946E79, 0xC6A376D2, 0x6549C2C8,
|
||||
0x530FF8EE, 0x468DDE7D, 0xD5730A1D, 0x4CD04DC6,
|
||||
0x2939BBDB, 0xA9BA4650, 0xAC9526E8, 0xBE5EE304,
|
||||
0xA1FAD5F0, 0x6A2D519A, 0x63EF8CE2, 0x9A86EE22,
|
||||
0xC089C2B8, 0x43242EF6, 0xA51E03AA, 0x9CF2D0A4,
|
||||
0x83C061BA, 0x9BE96A4D, 0x8FE51550, 0xBA645BD6,
|
||||
0x2826A2F9, 0xA73A3AE1, 0x4BA99586, 0xEF5562E9,
|
||||
0xC72FEFD3, 0xF752F7DA, 0x3F046F69, 0x77FA0A59,
|
||||
0x80E4A915, 0x87B08601, 0x9B09E6AD, 0x3B3EE593,
|
||||
0xE990FD5A, 0x9E34D797, 0x2CF0B7D9, 0x022B8B51,
|
||||
0x96D5AC3A, 0x017DA67D, 0xD1CF3ED6, 0x7C7D2D28,
|
||||
0x1F9F25CF, 0xADF2B89B, 0x5AD6B472, 0x5A88F54C,
|
||||
0xE029AC71, 0xE019A5E6, 0x47B0ACFD, 0xED93FA9B,
|
||||
0xE8D3C48D, 0x283B57CC, 0xF8D56629, 0x79132E28,
|
||||
0x785F0191, 0xED756055, 0xF7960E44, 0xE3D35E8C,
|
||||
0x15056DD4, 0x88F46DBA, 0x03A16125, 0x0564F0BD,
|
||||
0xC3EB9E15, 0x3C9057A2, 0x97271AEC, 0xA93A072A,
|
||||
0x1B3F6D9B, 0x1E6321F5, 0xF59C66FB, 0x26DCF319,
|
||||
0x7533D928, 0xB155FDF5, 0x03563482, 0x8ABA3CBB,
|
||||
0x28517711, 0xC20AD9F8, 0xABCC5167, 0xCCAD925F,
|
||||
0x4DE81751, 0x3830DC8E, 0x379D5862, 0x9320F991,
|
||||
0xEA7A90C2, 0xFB3E7BCE, 0x5121CE64, 0x774FBE32,
|
||||
0xA8B6E37E, 0xC3293D46, 0x48DE5369, 0x6413E680,
|
||||
0xA2AE0810, 0xDD6DB224, 0x69852DFD, 0x09072166,
|
||||
0xB39A460A, 0x6445C0DD, 0x586CDECF, 0x1C20C8AE,
|
||||
0x5BBEF7DD, 0x1B588D40, 0xCCD2017F, 0x6BB4E3BB,
|
||||
0xDDA26A7E, 0x3A59FF45, 0x3E350A44, 0xBCB4CDD5,
|
||||
0x72EACEA8, 0xFA6484BB, 0x8D6612AE, 0xBF3C6F47,
|
||||
0xD29BE463, 0x542F5D9E, 0xAEC2771B, 0xF64E6370,
|
||||
0x740E0D8D, 0xE75B1357, 0xF8721671, 0xAF537D5D,
|
||||
0x4040CB08, 0x4EB4E2CC, 0x34D2466A, 0x0115AF84,
|
||||
0xE1B00428, 0x95983A1D, 0x06B89FB4, 0xCE6EA048,
|
||||
0x6F3F3B82, 0x3520AB82, 0x011A1D4B, 0x277227F8,
|
||||
0x611560B1, 0xE7933FDC, 0xBB3A792B, 0x344525BD,
|
||||
0xA08839E1, 0x51CE794B, 0x2F32C9B7, 0xA01FBAC9,
|
||||
0xE01CC87E, 0xBCC7D1F6, 0xCF0111C3, 0xA1E8AAC7,
|
||||
0x1A908749, 0xD44FBD9A, 0xD0DADECB, 0xD50ADA38,
|
||||
0x0339C32A, 0xC6913667, 0x8DF9317C, 0xE0B12B4F,
|
||||
0xF79E59B7, 0x43F5BB3A, 0xF2D519FF, 0x27D9459C,
|
||||
0xBF97222C, 0x15E6FC2A, 0x0F91FC71, 0x9B941525,
|
||||
0xFAE59361, 0xCEB69CEB, 0xC2A86459, 0x12BAA8D1,
|
||||
0xB6C1075E, 0xE3056A0C, 0x10D25065, 0xCB03A442,
|
||||
0xE0EC6E0E, 0x1698DB3B, 0x4C98A0BE, 0x3278E964,
|
||||
0x9F1F9532, 0xE0D392DF, 0xD3A0342B, 0x8971F21E,
|
||||
0x1B0A7441, 0x4BA3348C, 0xC5BE7120, 0xC37632D8,
|
||||
0xDF359F8D, 0x9B992F2E, 0xE60B6F47, 0x0FE3F11D,
|
||||
0xE54CDA54, 0x1EDAD891, 0xCE6279CF, 0xCD3E7E6F,
|
||||
0x1618B166, 0xFD2C1D05, 0x848FD2C5, 0xF6FB2299,
|
||||
0xF523F357, 0xA6327623, 0x93A83531, 0x56CCCD02,
|
||||
0xACF08162, 0x5A75EBB5, 0x6E163697, 0x88D273CC,
|
||||
0xDE966292, 0x81B949D0, 0x4C50901B, 0x71C65614,
|
||||
0xE6C6C7BD, 0x327A140A, 0x45E1D006, 0xC3F27B9A,
|
||||
0xC9AA53FD, 0x62A80F00, 0xBB25BFE2, 0x35BDD2F6,
|
||||
0x71126905, 0xB2040222, 0xB6CBCF7C, 0xCD769C2B,
|
||||
0x53113EC0, 0x1640E3D3, 0x38ABBD60, 0x2547ADF0,
|
||||
0xBA38209C, 0xF746CE76, 0x77AFA1C5, 0x20756060,
|
||||
0x85CBFE4E, 0x8AE88DD8, 0x7AAAF9B0, 0x4CF9AA7E,
|
||||
0x1948C25C, 0x02FB8A8C, 0x01C36AE4, 0xD6EBE1F9,
|
||||
0x90D4F869, 0xA65CDEA0, 0x3F09252D, 0xC208E69F,
|
||||
0xB74E6132, 0xCE77E25B, 0x578FDFE3, 0x3AC372E6
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @todo: Replace this class with native encryption
|
||||
*
|
||||
* @class TeamSpeak3_Helper_Crypt
|
||||
* @brief Helper class for data encryption.
|
||||
*/
|
||||
class TeamSpeak3_Helper_Crypt
|
||||
{
|
||||
/**
|
||||
* Stores the secret passphrase to encrypt or decrypt a given string.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $passphrase = null;
|
||||
|
||||
/**
|
||||
* Stores an array containing 18 32-bit entries.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $p = array();
|
||||
|
||||
/**
|
||||
* Stores an array containing 4 sub-arrays with 256 32-bit entries.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $s = array();
|
||||
|
||||
/**
|
||||
* The TeamSpeak3_Helper_Crypt constructor.
|
||||
*
|
||||
* @param string $secret
|
||||
* @return TeamSpeak3_Helper_Crypt
|
||||
*/
|
||||
public function __construct($secret)
|
||||
{
|
||||
$this->setDefaultKeys();
|
||||
$this->setSecretKey($secret);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encrypts a given string.
|
||||
*
|
||||
* @param string $string
|
||||
* @return string
|
||||
*/
|
||||
public function encrypt($string)
|
||||
{
|
||||
$string = trim($string);
|
||||
$encryp = "";
|
||||
$length = strlen($string);
|
||||
$string .= str_repeat(chr(0), (8-($length%8))%8);
|
||||
|
||||
for($i = 0; $i < $length; $i += 8)
|
||||
{
|
||||
list(,$xl,$xr) = unpack("N2", substr($string, $i, 8));
|
||||
$this->encipher($xl, $xr);
|
||||
$encryp .= pack("N2", $xl, $xr);
|
||||
}
|
||||
|
||||
return base64_encode($encryp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrypts a given string.
|
||||
*
|
||||
* @param string $string
|
||||
* @return string
|
||||
*/
|
||||
public function decrypt($string)
|
||||
{
|
||||
$string = base64_decode($string);
|
||||
$decryp = "";
|
||||
$length = strlen($string);
|
||||
$string .= str_repeat(chr(0), (8-($length%8))%8);
|
||||
|
||||
for($i = 0; $i < $length; $i += 8)
|
||||
{
|
||||
list(,$xl,$xr) = unpack("N2", substr($string, $i, 8));
|
||||
$this->decipher($xl, $xr);
|
||||
$decryp .= pack("N2", $xl, $xr);
|
||||
}
|
||||
|
||||
return trim($decryp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enciphers a single 64-bit block.
|
||||
*
|
||||
* @param integer $xl
|
||||
* @param integer $xr
|
||||
*/
|
||||
protected function encipher(&$xl, &$xr)
|
||||
{
|
||||
for($i = 0; $i < 16; $i++)
|
||||
{
|
||||
$temp = $xl ^ $this->p[$i];
|
||||
$xl = ((($this->s[0][($temp>>24) & 255] + $this->s[1][($temp>>16) & 255]) ^ $this->s[2][($temp>>8) & 255]) + $this->s[3][$temp & 255]) ^ $xr;
|
||||
$xr = $temp;
|
||||
}
|
||||
|
||||
$xr = $xl ^ $this->p[16];
|
||||
$xl = $temp ^ $this->p[17];
|
||||
}
|
||||
|
||||
/**
|
||||
* Deciphers a single 64-bit block
|
||||
*
|
||||
* @param integer $xl
|
||||
* @param integer $xr
|
||||
* @return void
|
||||
*/
|
||||
protected function decipher(&$xl, &$xr)
|
||||
{
|
||||
for($i = 17; $i > 1; $i--)
|
||||
{
|
||||
$temp = $xl ^ $this->p[$i];
|
||||
$xl = ((($this->s[0][($temp>>24) & 255] + $this->s[1][($temp>>16) & 255]) ^ $this->s[2][($temp>>8) & 255]) + $this->s[3][$temp & 255]) ^ $xr;
|
||||
$xr = $temp;
|
||||
}
|
||||
|
||||
$xr = $xl ^ $this->p[1];
|
||||
$xl = $temp ^ $this->p[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the secret key using the specified pasphrase.
|
||||
*
|
||||
* @param string $passphrase
|
||||
* @throws Habitat_Exception
|
||||
* @return void
|
||||
*/
|
||||
protected function setSecretKey($passphrase)
|
||||
{
|
||||
$length = strlen($passphrase);
|
||||
|
||||
if(strlen($passphrase) < 1 || strlen($passphrase) > 56)
|
||||
{
|
||||
throw new TeamSpeak3_Helper_Exception("secret passphrase must contain at least one but less than 56 characters");
|
||||
}
|
||||
|
||||
$k = 0;
|
||||
$data = 0;
|
||||
$datal = 0;
|
||||
$datar = 0;
|
||||
|
||||
for($i = 0; $i < 18; $i++)
|
||||
{
|
||||
$data = 0;
|
||||
for($j = 4; $j > 0; $j--)
|
||||
{
|
||||
$data = $data << 8 | ord($passphrase{$k});
|
||||
$k = ($k+1) % $length;
|
||||
}
|
||||
$this->p[$i] ^= $data;
|
||||
}
|
||||
|
||||
|
||||
for($i = 0; $i <= 16; $i += 2)
|
||||
{
|
||||
$this->encipher($datal, $datar);
|
||||
$this->p[$i] = $datal;
|
||||
$this->p[$i+1] = $datar;
|
||||
}
|
||||
|
||||
foreach($this->s as $key => $val)
|
||||
{
|
||||
for ($i = 0; $i < 256; $i += 2)
|
||||
{
|
||||
$this->encipher($datal, $datar);
|
||||
$this->s[$key][$i] = $datal;
|
||||
$this->s[$key][$i+1] = $datar;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the defult p and s keys.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setDefaultKeys()
|
||||
{
|
||||
$this->p = array(
|
||||
0x243F6A88, 0x85A308D3, 0x13198A2E, 0x03707344, 0xA4093822, 0x299F31D0,
|
||||
0x082EFA98, 0xEC4E6C89, 0x452821E6, 0x38D01377, 0xBE5466CF, 0x34E90C6C,
|
||||
0xC0AC29B7, 0xC97C50DD, 0x3F84D5B5, 0xB5470917, 0x9216D5D9, 0x8979FB1B,
|
||||
);
|
||||
$this->s = array(
|
||||
array(
|
||||
0xD1310BA6, 0x98DFB5AC, 0x2FFD72DB, 0xD01ADFB7,
|
||||
0xB8E1AFED, 0x6A267E96, 0xBA7C9045, 0xF12C7F99,
|
||||
0x24A19947, 0xB3916CF7, 0x0801F2E2, 0x858EFC16,
|
||||
0x636920D8, 0x71574E69, 0xA458FEA3, 0xF4933D7E,
|
||||
0x0D95748F, 0x728EB658, 0x718BCD58, 0x82154AEE,
|
||||
0x7B54A41D, 0xC25A59B5, 0x9C30D539, 0x2AF26013,
|
||||
0xC5D1B023, 0x286085F0, 0xCA417918, 0xB8DB38EF,
|
||||
0x8E79DCB0, 0x603A180E, 0x6C9E0E8B, 0xB01E8A3E,
|
||||
0xD71577C1, 0xBD314B27, 0x78AF2FDA, 0x55605C60,
|
||||
0xE65525F3, 0xAA55AB94, 0x57489862, 0x63E81440,
|
||||
0x55CA396A, 0x2AAB10B6, 0xB4CC5C34, 0x1141E8CE,
|
||||
0xA15486AF, 0x7C72E993, 0xB3EE1411, 0x636FBC2A,
|
||||
0x2BA9C55D, 0x741831F6, 0xCE5C3E16, 0x9B87931E,
|
||||
0xAFD6BA33, 0x6C24CF5C, 0x7A325381, 0x28958677,
|
||||
0x3B8F4898, 0x6B4BB9AF, 0xC4BFE81B, 0x66282193,
|
||||
0x61D809CC, 0xFB21A991, 0x487CAC60, 0x5DEC8032,
|
||||
0xEF845D5D, 0xE98575B1, 0xDC262302, 0xEB651B88,
|
||||
0x23893E81, 0xD396ACC5, 0x0F6D6FF3, 0x83F44239,
|
||||
0x2E0B4482, 0xA4842004, 0x69C8F04A, 0x9E1F9B5E,
|
||||
0x21C66842, 0xF6E96C9A, 0x670C9C61, 0xABD388F0,
|
||||
0x6A51A0D2, 0xD8542F68, 0x960FA728, 0xAB5133A3,
|
||||
0x6EEF0B6C, 0x137A3BE4, 0xBA3BF050, 0x7EFB2A98,
|
||||
0xA1F1651D, 0x39AF0176, 0x66CA593E, 0x82430E88,
|
||||
0x8CEE8619, 0x456F9FB4, 0x7D84A5C3, 0x3B8B5EBE,
|
||||
0xE06F75D8, 0x85C12073, 0x401A449F, 0x56C16AA6,
|
||||
0x4ED3AA62, 0x363F7706, 0x1BFEDF72, 0x429B023D,
|
||||
0x37D0D724, 0xD00A1248, 0xDB0FEAD3, 0x49F1C09B,
|
||||
0x075372C9, 0x80991B7B, 0x25D479D8, 0xF6E8DEF7,
|
||||
0xE3FE501A, 0xB6794C3B, 0x976CE0BD, 0x04C006BA,
|
||||
0xC1A94FB6, 0x409F60C4, 0x5E5C9EC2, 0x196A2463,
|
||||
0x68FB6FAF, 0x3E6C53B5, 0x1339B2EB, 0x3B52EC6F,
|
||||
0x6DFC511F, 0x9B30952C, 0xCC814544, 0xAF5EBD09,
|
||||
0xBEE3D004, 0xDE334AFD, 0x660F2807, 0x192E4BB3,
|
||||
0xC0CBA857, 0x45C8740F, 0xD20B5F39, 0xB9D3FBDB,
|
||||
0x5579C0BD, 0x1A60320A, 0xD6A100C6, 0x402C7279,
|
||||
0x679F25FE, 0xFB1FA3CC, 0x8EA5E9F8, 0xDB3222F8,
|
||||
0x3C7516DF, 0xFD616B15, 0x2F501EC8, 0xAD0552AB,
|
||||
0x323DB5FA, 0xFD238760, 0x53317B48, 0x3E00DF82,
|
||||
0x9E5C57BB, 0xCA6F8CA0, 0x1A87562E, 0xDF1769DB,
|
||||
0xD542A8F6, 0x287EFFC3, 0xAC6732C6, 0x8C4F5573,
|
||||
0x695B27B0, 0xBBCA58C8, 0xE1FFA35D, 0xB8F011A0,
|
||||
0x10FA3D98, 0xFD2183B8, 0x4AFCB56C, 0x2DD1D35B,
|
||||
0x9A53E479, 0xB6F84565, 0xD28E49BC, 0x4BFB9790,
|
||||
0xE1DDF2DA, 0xA4CB7E33, 0x62FB1341, 0xCEE4C6E8,
|
||||
0xEF20CADA, 0x36774C01, 0xD07E9EFE, 0x2BF11FB4,
|
||||
0x95DBDA4D, 0xAE909198, 0xEAAD8E71, 0x6B93D5A0,
|
||||
0xD08ED1D0, 0xAFC725E0, 0x8E3C5B2F, 0x8E7594B7,
|
||||
0x8FF6E2FB, 0xF2122B64, 0x8888B812, 0x900DF01C,
|
||||
0x4FAD5EA0, 0x688FC31C, 0xD1CFF191, 0xB3A8C1AD,
|
||||
0x2F2F2218, 0xBE0E1777, 0xEA752DFE, 0x8B021FA1,
|
||||
0xE5A0CC0F, 0xB56F74E8, 0x18ACF3D6, 0xCE89E299,
|
||||
0xB4A84FE0, 0xFD13E0B7, 0x7CC43B81, 0xD2ADA8D9,
|
||||
0x165FA266, 0x80957705, 0x93CC7314, 0x211A1477,
|
||||
0xE6AD2065, 0x77B5FA86, 0xC75442F5, 0xFB9D35CF,
|
||||
0xEBCDAF0C, 0x7B3E89A0, 0xD6411BD3, 0xAE1E7E49,
|
||||
0x00250E2D, 0x2071B35E, 0x226800BB, 0x57B8E0AF,
|
||||
0x2464369B, 0xF009B91E, 0x5563911D, 0x59DFA6AA,
|
||||
0x78C14389, 0xD95A537F, 0x207D5BA2, 0x02E5B9C5,
|
||||
0x83260376, 0x6295CFA9, 0x11C81968, 0x4E734A41,
|
||||
0xB3472DCA, 0x7B14A94A, 0x1B510052, 0x9A532915,
|
||||
0xD60F573F, 0xBC9BC6E4, 0x2B60A476, 0x81E67400,
|
||||
0x08BA6FB5, 0x571BE91F, 0xF296EC6B, 0x2A0DD915,
|
||||
0xB6636521, 0xE7B9F9B6, 0xFF34052E, 0xC5855664,
|
||||
0x53B02D5D, 0xA99F8FA1, 0x08BA4799, 0x6E85076A
|
||||
),
|
||||
array(
|
||||
0x4B7A70E9, 0xB5B32944, 0xDB75092E, 0xC4192623,
|
||||
0xAD6EA6B0, 0x49A7DF7D, 0x9CEE60B8, 0x8FEDB266,
|
||||
0xECAA8C71, 0x699A17FF, 0x5664526C, 0xC2B19EE1,
|
||||
0x193602A5, 0x75094C29, 0xA0591340, 0xE4183A3E,
|
||||
0x3F54989A, 0x5B429D65, 0x6B8FE4D6, 0x99F73FD6,
|
||||
0xA1D29C07, 0xEFE830F5, 0x4D2D38E6, 0xF0255DC1,
|
||||
0x4CDD2086, 0x8470EB26, 0x6382E9C6, 0x021ECC5E,
|
||||
0x09686B3F, 0x3EBAEFC9, 0x3C971814, 0x6B6A70A1,
|
||||
0x687F3584, 0x52A0E286, 0xB79C5305, 0xAA500737,
|
||||
0x3E07841C, 0x7FDEAE5C, 0x8E7D44EC, 0x5716F2B8,
|
||||
0xB03ADA37, 0xF0500C0D, 0xF01C1F04, 0x0200B3FF,
|
||||
0xAE0CF51A, 0x3CB574B2, 0x25837A58, 0xDC0921BD,
|
||||
0xD19113F9, 0x7CA92FF6, 0x94324773, 0x22F54701,
|
||||
0x3AE5E581, 0x37C2DADC, 0xC8B57634, 0x9AF3DDA7,
|
||||
0xA9446146, 0x0FD0030E, 0xECC8C73E, 0xA4751E41,
|
||||
0xE238CD99, 0x3BEA0E2F, 0x3280BBA1, 0x183EB331,
|
||||
0x4E548B38, 0x4F6DB908, 0x6F420D03, 0xF60A04BF,
|
||||
0x2CB81290, 0x24977C79, 0x5679B072, 0xBCAF89AF,
|
||||
0xDE9A771F, 0xD9930810, 0xB38BAE12, 0xDCCF3F2E,
|
||||
0x5512721F, 0x2E6B7124, 0x501ADDE6, 0x9F84CD87,
|
||||
0x7A584718, 0x7408DA17, 0xBC9F9ABC, 0xE94B7D8C,
|
||||
0xEC7AEC3A, 0xDB851DFA, 0x63094366, 0xC464C3D2,
|
||||
0xEF1C1847, 0x3215D908, 0xDD433B37, 0x24C2BA16,
|
||||
0x12A14D43, 0x2A65C451, 0x50940002, 0x133AE4DD,
|
||||
0x71DFF89E, 0x10314E55, 0x81AC77D6, 0x5F11199B,
|
||||
0x043556F1, 0xD7A3C76B, 0x3C11183B, 0x5924A509,
|
||||
0xF28FE6ED, 0x97F1FBFA, 0x9EBABF2C, 0x1E153C6E,
|
||||
0x86E34570, 0xEAE96FB1, 0x860E5E0A, 0x5A3E2AB3,
|
||||
0x771FE71C, 0x4E3D06FA, 0x2965DCB9, 0x99E71D0F,
|
||||
0x803E89D6, 0x5266C825, 0x2E4CC978, 0x9C10B36A,
|
||||
0xC6150EBA, 0x94E2EA78, 0xA5FC3C53, 0x1E0A2DF4,
|
||||
0xF2F74EA7, 0x361D2B3D, 0x1939260F, 0x19C27960,
|
||||
0x5223A708, 0xF71312B6, 0xEBADFE6E, 0xEAC31F66,
|
||||
0xE3BC4595, 0xA67BC883, 0xB17F37D1, 0x018CFF28,
|
||||
0xC332DDEF, 0xBE6C5AA5, 0x65582185, 0x68AB9802,
|
||||
0xEECEA50F, 0xDB2F953B, 0x2AEF7DAD, 0x5B6E2F84,
|
||||
0x1521B628, 0x29076170, 0xECDD4775, 0x619F1510,
|
||||
0x13CCA830, 0xEB61BD96, 0x0334FE1E, 0xAA0363CF,
|
||||
0xB5735C90, 0x4C70A239, 0xD59E9E0B, 0xCBAADE14,
|
||||
0xEECC86BC, 0x60622CA7, 0x9CAB5CAB, 0xB2F3846E,
|
||||
0x648B1EAF, 0x19BDF0CA, 0xA02369B9, 0x655ABB50,
|
||||
0x40685A32, 0x3C2AB4B3, 0x319EE9D5, 0xC021B8F7,
|
||||
0x9B540B19, 0x875FA099, 0x95F7997E, 0x623D7DA8,
|
||||
0xF837889A, 0x97E32D77, 0x11ED935F, 0x16681281,
|
||||
0x0E358829, 0xC7E61FD6, 0x96DEDFA1, 0x7858BA99,
|
||||
0x57F584A5, 0x1B227263, 0x9B83C3FF, 0x1AC24696,
|
||||
0xCDB30AEB, 0x532E3054, 0x8FD948E4, 0x6DBC3128,
|
||||
0x58EBF2EF, 0x34C6FFEA, 0xFE28ED61, 0xEE7C3C73,
|
||||
0x5D4A14D9, 0xE864B7E3, 0x42105D14, 0x203E13E0,
|
||||
0x45EEE2B6, 0xA3AAABEA, 0xDB6C4F15, 0xFACB4FD0,
|
||||
0xC742F442, 0xEF6ABBB5, 0x654F3B1D, 0x41CD2105,
|
||||
0xD81E799E, 0x86854DC7, 0xE44B476A, 0x3D816250,
|
||||
0xCF62A1F2, 0x5B8D2646, 0xFC8883A0, 0xC1C7B6A3,
|
||||
0x7F1524C3, 0x69CB7492, 0x47848A0B, 0x5692B285,
|
||||
0x095BBF00, 0xAD19489D, 0x1462B174, 0x23820E00,
|
||||
0x58428D2A, 0x0C55F5EA, 0x1DADF43E, 0x233F7061,
|
||||
0x3372F092, 0x8D937E41, 0xD65FECF1, 0x6C223BDB,
|
||||
0x7CDE3759, 0xCBEE7460, 0x4085F2A7, 0xCE77326E,
|
||||
0xA6078084, 0x19F8509E, 0xE8EFD855, 0x61D99735,
|
||||
0xA969A7AA, 0xC50C06C2, 0x5A04ABFC, 0x800BCADC,
|
||||
0x9E447A2E, 0xC3453484, 0xFDD56705, 0x0E1E9EC9,
|
||||
0xDB73DBD3, 0x105588CD, 0x675FDA79, 0xE3674340,
|
||||
0xC5C43465, 0x713E38D8, 0x3D28F89E, 0xF16DFF20,
|
||||
0x153E21E7, 0x8FB03D4A, 0xE6E39F2B, 0xDB83ADF7
|
||||
),
|
||||
array(
|
||||
0xE93D5A68, 0x948140F7, 0xF64C261C, 0x94692934,
|
||||
0x411520F7, 0x7602D4F7, 0xBCF46B2E, 0xD4A20068,
|
||||
0xD4082471, 0x3320F46A, 0x43B7D4B7, 0x500061AF,
|
||||
0x1E39F62E, 0x97244546, 0x14214F74, 0xBF8B8840,
|
||||
0x4D95FC1D, 0x96B591AF, 0x70F4DDD3, 0x66A02F45,
|
||||
0xBFBC09EC, 0x03BD9785, 0x7FAC6DD0, 0x31CB8504,
|
||||
0x96EB27B3, 0x55FD3941, 0xDA2547E6, 0xABCA0A9A,
|
||||
0x28507825, 0x530429F4, 0x0A2C86DA, 0xE9B66DFB,
|
||||
0x68DC1462, 0xD7486900, 0x680EC0A4, 0x27A18DEE,
|
||||
0x4F3FFEA2, 0xE887AD8C, 0xB58CE006, 0x7AF4D6B6,
|
||||
0xAACE1E7C, 0xD3375FEC, 0xCE78A399, 0x406B2A42,
|
||||
0x20FE9E35, 0xD9F385B9, 0xEE39D7AB, 0x3B124E8B,
|
||||
0x1DC9FAF7, 0x4B6D1856, 0x26A36631, 0xEAE397B2,
|
||||
0x3A6EFA74, 0xDD5B4332, 0x6841E7F7, 0xCA7820FB,
|
||||
0xFB0AF54E, 0xD8FEB397, 0x454056AC, 0xBA489527,
|
||||
0x55533A3A, 0x20838D87, 0xFE6BA9B7, 0xD096954B,
|
||||
0x55A867BC, 0xA1159A58, 0xCCA92963, 0x99E1DB33,
|
||||
0xA62A4A56, 0x3F3125F9, 0x5EF47E1C, 0x9029317C,
|
||||
0xFDF8E802, 0x04272F70, 0x80BB155C, 0x05282CE3,
|
||||
0x95C11548, 0xE4C66D22, 0x48C1133F, 0xC70F86DC,
|
||||
0x07F9C9EE, 0x41041F0F, 0x404779A4, 0x5D886E17,
|
||||
0x325F51EB, 0xD59BC0D1, 0xF2BCC18F, 0x41113564,
|
||||
0x257B7834, 0x602A9C60, 0xDFF8E8A3, 0x1F636C1B,
|
||||
0x0E12B4C2, 0x02E1329E, 0xAF664FD1, 0xCAD18115,
|
||||
0x6B2395E0, 0x333E92E1, 0x3B240B62, 0xEEBEB922,
|
||||
0x85B2A20E, 0xE6BA0D99, 0xDE720C8C, 0x2DA2F728,
|
||||
0xD0127845, 0x95B794FD, 0x647D0862, 0xE7CCF5F0,
|
||||
0x5449A36F, 0x877D48FA, 0xC39DFD27, 0xF33E8D1E,
|
||||
0x0A476341, 0x992EFF74, 0x3A6F6EAB, 0xF4F8FD37,
|
||||
0xA812DC60, 0xA1EBDDF8, 0x991BE14C, 0xDB6E6B0D,
|
||||
0xC67B5510, 0x6D672C37, 0x2765D43B, 0xDCD0E804,
|
||||
0xF1290DC7, 0xCC00FFA3, 0xB5390F92, 0x690FED0B,
|
||||
0x667B9FFB, 0xCEDB7D9C, 0xA091CF0B, 0xD9155EA3,
|
||||
0xBB132F88, 0x515BAD24, 0x7B9479BF, 0x763BD6EB,
|
||||
0x37392EB3, 0xCC115979, 0x8026E297, 0xF42E312D,
|
||||
0x6842ADA7, 0xC66A2B3B, 0x12754CCC, 0x782EF11C,
|
||||
0x6A124237, 0xB79251E7, 0x06A1BBE6, 0x4BFB6350,
|
||||
0x1A6B1018, 0x11CAEDFA, 0x3D25BDD8, 0xE2E1C3C9,
|
||||
0x44421659, 0x0A121386, 0xD90CEC6E, 0xD5ABEA2A,
|
||||
0x64AF674E, 0xDA86A85F, 0xBEBFE988, 0x64E4C3FE,
|
||||
0x9DBC8057, 0xF0F7C086, 0x60787BF8, 0x6003604D,
|
||||
0xD1FD8346, 0xF6381FB0, 0x7745AE04, 0xD736FCCC,
|
||||
0x83426B33, 0xF01EAB71, 0xB0804187, 0x3C005E5F,
|
||||
0x77A057BE, 0xBDE8AE24, 0x55464299, 0xBF582E61,
|
||||
0x4E58F48F, 0xF2DDFDA2, 0xF474EF38, 0x8789BDC2,
|
||||
0x5366F9C3, 0xC8B38E74, 0xB475F255, 0x46FCD9B9,
|
||||
0x7AEB2661, 0x8B1DDF84, 0x846A0E79, 0x915F95E2,
|
||||
0x466E598E, 0x20B45770, 0x8CD55591, 0xC902DE4C,
|
||||
0xB90BACE1, 0xBB8205D0, 0x11A86248, 0x7574A99E,
|
||||
0xB77F19B6, 0xE0A9DC09, 0x662D09A1, 0xC4324633,
|
||||
0xE85A1F02, 0x09F0BE8C, 0x4A99A025, 0x1D6EFE10,
|
||||
0x1AB93D1D, 0x0BA5A4DF, 0xA186F20F, 0x2868F169,
|
||||
0xDCB7DA83, 0x573906FE, 0xA1E2CE9B, 0x4FCD7F52,
|
||||
0x50115E01, 0xA70683FA, 0xA002B5C4, 0x0DE6D027,
|
||||
0x9AF88C27, 0x773F8641, 0xC3604C06, 0x61A806B5,
|
||||
0xF0177A28, 0xC0F586E0, 0x006058AA, 0x30DC7D62,
|
||||
0x11E69ED7, 0x2338EA63, 0x53C2DD94, 0xC2C21634,
|
||||
0xBBCBEE56, 0x90BCB6DE, 0xEBFC7DA1, 0xCE591D76,
|
||||
0x6F05E409, 0x4B7C0188, 0x39720A3D, 0x7C927C24,
|
||||
0x86E3725F, 0x724D9DB9, 0x1AC15BB4, 0xD39EB8FC,
|
||||
0xED545578, 0x08FCA5B5, 0xD83D7CD3, 0x4DAD0FC4,
|
||||
0x1E50EF5E, 0xB161E6F8, 0xA28514D9, 0x6C51133C,
|
||||
0x6FD5C7E7, 0x56E14EC4, 0x362ABFCE, 0xDDC6C837,
|
||||
0xD79A3234, 0x92638212, 0x670EFA8E, 0x406000E0
|
||||
),
|
||||
array(
|
||||
0x3A39CE37, 0xD3FAF5CF, 0xABC27737, 0x5AC52D1B,
|
||||
0x5CB0679E, 0x4FA33742, 0xD3822740, 0x99BC9BBE,
|
||||
0xD5118E9D, 0xBF0F7315, 0xD62D1C7E, 0xC700C47B,
|
||||
0xB78C1B6B, 0x21A19045, 0xB26EB1BE, 0x6A366EB4,
|
||||
0x5748AB2F, 0xBC946E79, 0xC6A376D2, 0x6549C2C8,
|
||||
0x530FF8EE, 0x468DDE7D, 0xD5730A1D, 0x4CD04DC6,
|
||||
0x2939BBDB, 0xA9BA4650, 0xAC9526E8, 0xBE5EE304,
|
||||
0xA1FAD5F0, 0x6A2D519A, 0x63EF8CE2, 0x9A86EE22,
|
||||
0xC089C2B8, 0x43242EF6, 0xA51E03AA, 0x9CF2D0A4,
|
||||
0x83C061BA, 0x9BE96A4D, 0x8FE51550, 0xBA645BD6,
|
||||
0x2826A2F9, 0xA73A3AE1, 0x4BA99586, 0xEF5562E9,
|
||||
0xC72FEFD3, 0xF752F7DA, 0x3F046F69, 0x77FA0A59,
|
||||
0x80E4A915, 0x87B08601, 0x9B09E6AD, 0x3B3EE593,
|
||||
0xE990FD5A, 0x9E34D797, 0x2CF0B7D9, 0x022B8B51,
|
||||
0x96D5AC3A, 0x017DA67D, 0xD1CF3ED6, 0x7C7D2D28,
|
||||
0x1F9F25CF, 0xADF2B89B, 0x5AD6B472, 0x5A88F54C,
|
||||
0xE029AC71, 0xE019A5E6, 0x47B0ACFD, 0xED93FA9B,
|
||||
0xE8D3C48D, 0x283B57CC, 0xF8D56629, 0x79132E28,
|
||||
0x785F0191, 0xED756055, 0xF7960E44, 0xE3D35E8C,
|
||||
0x15056DD4, 0x88F46DBA, 0x03A16125, 0x0564F0BD,
|
||||
0xC3EB9E15, 0x3C9057A2, 0x97271AEC, 0xA93A072A,
|
||||
0x1B3F6D9B, 0x1E6321F5, 0xF59C66FB, 0x26DCF319,
|
||||
0x7533D928, 0xB155FDF5, 0x03563482, 0x8ABA3CBB,
|
||||
0x28517711, 0xC20AD9F8, 0xABCC5167, 0xCCAD925F,
|
||||
0x4DE81751, 0x3830DC8E, 0x379D5862, 0x9320F991,
|
||||
0xEA7A90C2, 0xFB3E7BCE, 0x5121CE64, 0x774FBE32,
|
||||
0xA8B6E37E, 0xC3293D46, 0x48DE5369, 0x6413E680,
|
||||
0xA2AE0810, 0xDD6DB224, 0x69852DFD, 0x09072166,
|
||||
0xB39A460A, 0x6445C0DD, 0x586CDECF, 0x1C20C8AE,
|
||||
0x5BBEF7DD, 0x1B588D40, 0xCCD2017F, 0x6BB4E3BB,
|
||||
0xDDA26A7E, 0x3A59FF45, 0x3E350A44, 0xBCB4CDD5,
|
||||
0x72EACEA8, 0xFA6484BB, 0x8D6612AE, 0xBF3C6F47,
|
||||
0xD29BE463, 0x542F5D9E, 0xAEC2771B, 0xF64E6370,
|
||||
0x740E0D8D, 0xE75B1357, 0xF8721671, 0xAF537D5D,
|
||||
0x4040CB08, 0x4EB4E2CC, 0x34D2466A, 0x0115AF84,
|
||||
0xE1B00428, 0x95983A1D, 0x06B89FB4, 0xCE6EA048,
|
||||
0x6F3F3B82, 0x3520AB82, 0x011A1D4B, 0x277227F8,
|
||||
0x611560B1, 0xE7933FDC, 0xBB3A792B, 0x344525BD,
|
||||
0xA08839E1, 0x51CE794B, 0x2F32C9B7, 0xA01FBAC9,
|
||||
0xE01CC87E, 0xBCC7D1F6, 0xCF0111C3, 0xA1E8AAC7,
|
||||
0x1A908749, 0xD44FBD9A, 0xD0DADECB, 0xD50ADA38,
|
||||
0x0339C32A, 0xC6913667, 0x8DF9317C, 0xE0B12B4F,
|
||||
0xF79E59B7, 0x43F5BB3A, 0xF2D519FF, 0x27D9459C,
|
||||
0xBF97222C, 0x15E6FC2A, 0x0F91FC71, 0x9B941525,
|
||||
0xFAE59361, 0xCEB69CEB, 0xC2A86459, 0x12BAA8D1,
|
||||
0xB6C1075E, 0xE3056A0C, 0x10D25065, 0xCB03A442,
|
||||
0xE0EC6E0E, 0x1698DB3B, 0x4C98A0BE, 0x3278E964,
|
||||
0x9F1F9532, 0xE0D392DF, 0xD3A0342B, 0x8971F21E,
|
||||
0x1B0A7441, 0x4BA3348C, 0xC5BE7120, 0xC37632D8,
|
||||
0xDF359F8D, 0x9B992F2E, 0xE60B6F47, 0x0FE3F11D,
|
||||
0xE54CDA54, 0x1EDAD891, 0xCE6279CF, 0xCD3E7E6F,
|
||||
0x1618B166, 0xFD2C1D05, 0x848FD2C5, 0xF6FB2299,
|
||||
0xF523F357, 0xA6327623, 0x93A83531, 0x56CCCD02,
|
||||
0xACF08162, 0x5A75EBB5, 0x6E163697, 0x88D273CC,
|
||||
0xDE966292, 0x81B949D0, 0x4C50901B, 0x71C65614,
|
||||
0xE6C6C7BD, 0x327A140A, 0x45E1D006, 0xC3F27B9A,
|
||||
0xC9AA53FD, 0x62A80F00, 0xBB25BFE2, 0x35BDD2F6,
|
||||
0x71126905, 0xB2040222, 0xB6CBCF7C, 0xCD769C2B,
|
||||
0x53113EC0, 0x1640E3D3, 0x38ABBD60, 0x2547ADF0,
|
||||
0xBA38209C, 0xF746CE76, 0x77AFA1C5, 0x20756060,
|
||||
0x85CBFE4E, 0x8AE88DD8, 0x7AAAF9B0, 0x4CF9AA7E,
|
||||
0x1948C25C, 0x02FB8A8C, 0x01C36AE4, 0xD6EBE1F9,
|
||||
0x90D4F869, 0xA65CDEA0, 0x3F09252D, 0xC208E69F,
|
||||
0xB74E6132, 0xCE77E25B, 0x578FDFE3, 0x3AC372E6
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Helper_Exception
|
||||
* @brief Enhanced exception class for TeamSpeak3_Helper_* objects.
|
||||
*/
|
||||
class TeamSpeak3_Helper_Exception extends TeamSpeak3_Exception {}
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Helper_Exception
|
||||
* @brief Enhanced exception class for TeamSpeak3_Helper_* objects.
|
||||
*/
|
||||
class TeamSpeak3_Helper_Exception extends TeamSpeak3_Exception {}
|
||||
|
||||
@@ -1,98 +1,98 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Helper_Profiler
|
||||
* @brief Helper class for profiler handling.
|
||||
*/
|
||||
class TeamSpeak3_Helper_Profiler
|
||||
{
|
||||
/**
|
||||
* Stores various timers for code profiling.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $timers = array();
|
||||
|
||||
/**
|
||||
* Inits a timer.
|
||||
*
|
||||
* @param string $name
|
||||
* @return void
|
||||
*/
|
||||
public static function init($name = "default")
|
||||
{
|
||||
self::$timers[$name] = new TeamSpeak3_Helper_Profiler_Timer($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a timer.
|
||||
*
|
||||
* @param string $name
|
||||
* @return void
|
||||
*/
|
||||
public static function start($name = "default")
|
||||
{
|
||||
if(array_key_exists($name, self::$timers))
|
||||
{
|
||||
self::$timers[$name]->start();
|
||||
}
|
||||
else
|
||||
{
|
||||
self::$timers[$name] = new TeamSpeak3_Helper_Profiler_Timer($name);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops a timer.
|
||||
*
|
||||
* @param string $name
|
||||
* @return void
|
||||
*/
|
||||
public static function stop($name = "default")
|
||||
{
|
||||
if(!array_key_exists($name, self::$timers))
|
||||
{
|
||||
self::init($name);
|
||||
}
|
||||
|
||||
self::$timers[$name]->stop();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a timer.
|
||||
*
|
||||
* @param string $name
|
||||
* @return TeamSpeak3_Helper_Profiler_Timer
|
||||
*/
|
||||
public static function get($name = "default")
|
||||
{
|
||||
if(!array_key_exists($name, self::$timers))
|
||||
{
|
||||
self::init($name);
|
||||
}
|
||||
|
||||
return self::$timers[$name];
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Helper_Profiler
|
||||
* @brief Helper class for profiler handling.
|
||||
*/
|
||||
class TeamSpeak3_Helper_Profiler
|
||||
{
|
||||
/**
|
||||
* Stores various timers for code profiling.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $timers = array();
|
||||
|
||||
/**
|
||||
* Inits a timer.
|
||||
*
|
||||
* @param string $name
|
||||
* @return void
|
||||
*/
|
||||
public static function init($name = "default")
|
||||
{
|
||||
self::$timers[$name] = new TeamSpeak3_Helper_Profiler_Timer($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a timer.
|
||||
*
|
||||
* @param string $name
|
||||
* @return void
|
||||
*/
|
||||
public static function start($name = "default")
|
||||
{
|
||||
if(array_key_exists($name, self::$timers))
|
||||
{
|
||||
self::$timers[$name]->start();
|
||||
}
|
||||
else
|
||||
{
|
||||
self::$timers[$name] = new TeamSpeak3_Helper_Profiler_Timer($name);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops a timer.
|
||||
*
|
||||
* @param string $name
|
||||
* @return void
|
||||
*/
|
||||
public static function stop($name = "default")
|
||||
{
|
||||
if(!array_key_exists($name, self::$timers))
|
||||
{
|
||||
self::init($name);
|
||||
}
|
||||
|
||||
self::$timers[$name]->stop();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a timer.
|
||||
*
|
||||
* @param string $name
|
||||
* @return TeamSpeak3_Helper_Profiler_Timer
|
||||
*/
|
||||
public static function get($name = "default")
|
||||
{
|
||||
if(!array_key_exists($name, self::$timers))
|
||||
{
|
||||
self::init($name);
|
||||
}
|
||||
|
||||
return self::$timers[$name];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Helper_Profiler_Exception
|
||||
* @brief Enhanced exception class for TeamSpeak3_Helper_Profiler objects.
|
||||
*/
|
||||
class TeamSpeak3_Helper_Profiler_Exception extends TeamSpeak3_Helper_Exception {}
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Helper_Profiler_Exception
|
||||
* @brief Enhanced exception class for TeamSpeak3_Helper_Profiler objects.
|
||||
*/
|
||||
class TeamSpeak3_Helper_Profiler_Exception extends TeamSpeak3_Helper_Exception {}
|
||||
|
||||
@@ -1,151 +1,151 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Helper_Profiler_Timer
|
||||
* @brief Helper class providing profiler timers.
|
||||
*/
|
||||
class TeamSpeak3_Helper_Profiler_Timer
|
||||
{
|
||||
/**
|
||||
* Indicates wether the timer is running or not.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $running = FALSE;
|
||||
|
||||
/**
|
||||
* Stores the timestamp when the timer was last started.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $started = 0;
|
||||
|
||||
/**
|
||||
* Stores the timer name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = null;
|
||||
|
||||
/**
|
||||
* Stores various information about the server environment.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $data = array();
|
||||
|
||||
/**
|
||||
* The TeamSpeak3_Helper_Profiler_Timer constructor.
|
||||
*
|
||||
* @param string $name
|
||||
* @return TeamSpeak3_Helper_Profiler_Timer
|
||||
*/
|
||||
public function __construct($name)
|
||||
{
|
||||
$this->name = (string) $name;
|
||||
|
||||
$this->data["runtime"] = 0;
|
||||
$this->data["realmem"] = 0;
|
||||
$this->data["emalloc"] = 0;
|
||||
|
||||
$this->start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the timer.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function start()
|
||||
{
|
||||
if($this->isRunning()) return;
|
||||
|
||||
$this->data["realmem_start"] = memory_get_usage(TRUE);
|
||||
$this->data["emalloc_start"] = memory_get_usage();
|
||||
|
||||
$this->started = microtime(TRUE);
|
||||
$this->running = TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops the timer.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function stop()
|
||||
{
|
||||
if(!$this->isRunning()) return;
|
||||
|
||||
$this->data["runtime"] += microtime(TRUE) - $this->started;
|
||||
$this->data["realmem"] += memory_get_usage(TRUE) - $this->data["realmem_start"];
|
||||
$this->data["emalloc"] += memory_get_usage() - $this->data["emalloc_start"];
|
||||
|
||||
$this->started = 0;
|
||||
$this->running = FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the timer runtime.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getRuntime()
|
||||
{
|
||||
if($this->isRunning())
|
||||
{
|
||||
$this->stop();
|
||||
$this->start();
|
||||
}
|
||||
|
||||
return $this->data["runtime"];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the amount of memory allocated to PHP in bytes.
|
||||
*
|
||||
* @param boolean $realmem
|
||||
* @return integer
|
||||
*/
|
||||
public function getMemUsage($realmem = FALSE)
|
||||
{
|
||||
if($this->isRunning())
|
||||
{
|
||||
$this->stop();
|
||||
$this->start();
|
||||
}
|
||||
|
||||
return ($realmem !== FALSE) ? $this->data["realmem"] : $this->data["emalloc"];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns TRUE if the timer is running.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isRunning()
|
||||
{
|
||||
return $this->running;
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Helper_Profiler_Timer
|
||||
* @brief Helper class providing profiler timers.
|
||||
*/
|
||||
class TeamSpeak3_Helper_Profiler_Timer
|
||||
{
|
||||
/**
|
||||
* Indicates wether the timer is running or not.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $running = FALSE;
|
||||
|
||||
/**
|
||||
* Stores the timestamp when the timer was last started.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $started = 0;
|
||||
|
||||
/**
|
||||
* Stores the timer name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = null;
|
||||
|
||||
/**
|
||||
* Stores various information about the server environment.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $data = array();
|
||||
|
||||
/**
|
||||
* The TeamSpeak3_Helper_Profiler_Timer constructor.
|
||||
*
|
||||
* @param string $name
|
||||
* @return TeamSpeak3_Helper_Profiler_Timer
|
||||
*/
|
||||
public function __construct($name)
|
||||
{
|
||||
$this->name = (string) $name;
|
||||
|
||||
$this->data["runtime"] = 0;
|
||||
$this->data["realmem"] = 0;
|
||||
$this->data["emalloc"] = 0;
|
||||
|
||||
$this->start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the timer.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function start()
|
||||
{
|
||||
if($this->isRunning()) return;
|
||||
|
||||
$this->data["realmem_start"] = memory_get_usage(TRUE);
|
||||
$this->data["emalloc_start"] = memory_get_usage();
|
||||
|
||||
$this->started = microtime(TRUE);
|
||||
$this->running = TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops the timer.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function stop()
|
||||
{
|
||||
if(!$this->isRunning()) return;
|
||||
|
||||
$this->data["runtime"] += microtime(TRUE) - $this->started;
|
||||
$this->data["realmem"] += memory_get_usage(TRUE) - $this->data["realmem_start"];
|
||||
$this->data["emalloc"] += memory_get_usage() - $this->data["emalloc_start"];
|
||||
|
||||
$this->started = 0;
|
||||
$this->running = FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the timer runtime.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getRuntime()
|
||||
{
|
||||
if($this->isRunning())
|
||||
{
|
||||
$this->stop();
|
||||
$this->start();
|
||||
}
|
||||
|
||||
return $this->data["runtime"];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the amount of memory allocated to PHP in bytes.
|
||||
*
|
||||
* @param boolean $realmem
|
||||
* @return integer
|
||||
*/
|
||||
public function getMemUsage($realmem = FALSE)
|
||||
{
|
||||
if($this->isRunning())
|
||||
{
|
||||
$this->stop();
|
||||
$this->start();
|
||||
}
|
||||
|
||||
return ($realmem !== FALSE) ? $this->data["realmem"] : $this->data["emalloc"];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns TRUE if the timer is running.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isRunning()
|
||||
{
|
||||
return $this->running;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,213 +1,213 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Helper_Signal
|
||||
* @brief Helper class for signal slots.
|
||||
*/
|
||||
class TeamSpeak3_Helper_Signal
|
||||
{
|
||||
/**
|
||||
* Stores the TeamSpeak3_Helper_Signal object.
|
||||
*
|
||||
* @var TeamSpeak3_Helper_Signal
|
||||
*/
|
||||
protected static $instance = null;
|
||||
|
||||
/**
|
||||
* Stores subscribed signals and their slots.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $sigslots = array();
|
||||
|
||||
/**
|
||||
* Emits a signal with a given set of parameters.
|
||||
*
|
||||
* @todo: Confirm / fix $return is set to last $slot->call() return value.
|
||||
* It appears all previous calls before last are lost / ignored.
|
||||
*
|
||||
* @param string $signal
|
||||
* @param mixed $params
|
||||
* @return mixed
|
||||
*/
|
||||
public function emit($signal, $params = null)
|
||||
{
|
||||
if(!$this->hasHandlers($signal))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(!is_array($params))
|
||||
{
|
||||
$params = func_get_args();
|
||||
$params = array_slice($params, 1);
|
||||
}
|
||||
|
||||
foreach($this->sigslots[$signal] as $slot)
|
||||
{
|
||||
$return = $slot->call($params);
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a MD5 hash based on a given callback.
|
||||
*
|
||||
* @param mixed $callback
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
public function getCallbackHash($callback)
|
||||
{
|
||||
if(!is_callable($callback, TRUE, $callable_name))
|
||||
{
|
||||
throw new TeamSpeak3_Helper_Signal_Exception("invalid callback specified");
|
||||
}
|
||||
|
||||
return md5($callable_name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscribes to a signal and returns the signal handler.
|
||||
*
|
||||
* @param string $signal
|
||||
* @param mixed $callback
|
||||
* @return TeamSpeak3_Helper_Signal_Handler
|
||||
*/
|
||||
public function subscribe($signal, $callback)
|
||||
{
|
||||
if(empty($this->sigslots[$signal]))
|
||||
{
|
||||
$this->sigslots[$signal] = array();
|
||||
}
|
||||
|
||||
$index = $this->getCallbackHash($callback);
|
||||
|
||||
if(!array_key_exists($index, $this->sigslots[$signal]))
|
||||
{
|
||||
$this->sigslots[$signal][$index] = new TeamSpeak3_Helper_Signal_Handler($signal, $callback);
|
||||
}
|
||||
|
||||
return $this->sigslots[$signal][$index];
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsubscribes from a signal.
|
||||
*
|
||||
* @param string $signal
|
||||
* @param mixed $callback
|
||||
* @return void
|
||||
*/
|
||||
public function unsubscribe($signal, $callback = null)
|
||||
{
|
||||
if(!$this->hasHandlers($signal))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if($callback !== null)
|
||||
{
|
||||
$index = $this->getCallbackHash($callback);
|
||||
|
||||
if(!array_key_exists($index, $this->sigslots[$signal]))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
unset($this->sigslots[$signal][$index]);
|
||||
}
|
||||
else
|
||||
{
|
||||
unset($this->sigslots[$signal]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all registered signals.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getSignals()
|
||||
{
|
||||
return array_keys($this->sigslots);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns TRUE there are slots subscribed for a specified signal.
|
||||
*
|
||||
* @param string $signal
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasHandlers($signal)
|
||||
{
|
||||
return empty($this->sigslots[$signal]) ? FALSE : TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all slots for a specified signal.
|
||||
*
|
||||
* @param string $signal
|
||||
* @return array
|
||||
*/
|
||||
public function getHandlers($signal)
|
||||
{
|
||||
if($this->hasHandlers($signal))
|
||||
{
|
||||
return $this->sigslots[$signal];
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears all slots for a specified signal.
|
||||
*
|
||||
* @param string $signal
|
||||
* @return void
|
||||
*/
|
||||
public function clearHandlers($signal)
|
||||
{
|
||||
if($this->hasHandlers($signal))
|
||||
{
|
||||
unset($this->sigslots[$signal]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a singleton instance of TeamSpeak3_Helper_Signal.
|
||||
*
|
||||
* @return TeamSpeak3_Helper_Signal
|
||||
*/
|
||||
public static function getInstance()
|
||||
{
|
||||
if(self::$instance === null)
|
||||
{
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Helper_Signal
|
||||
* @brief Helper class for signal slots.
|
||||
*/
|
||||
class TeamSpeak3_Helper_Signal
|
||||
{
|
||||
/**
|
||||
* Stores the TeamSpeak3_Helper_Signal object.
|
||||
*
|
||||
* @var TeamSpeak3_Helper_Signal
|
||||
*/
|
||||
protected static $instance = null;
|
||||
|
||||
/**
|
||||
* Stores subscribed signals and their slots.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $sigslots = array();
|
||||
|
||||
/**
|
||||
* Emits a signal with a given set of parameters.
|
||||
*
|
||||
* @todo: Confirm / fix $return is set to last $slot->call() return value.
|
||||
* It appears all previous calls before last are lost / ignored.
|
||||
*
|
||||
* @param string $signal
|
||||
* @param mixed $params
|
||||
* @return mixed
|
||||
*/
|
||||
public function emit($signal, $params = null)
|
||||
{
|
||||
if(!$this->hasHandlers($signal))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(!is_array($params))
|
||||
{
|
||||
$params = func_get_args();
|
||||
$params = array_slice($params, 1);
|
||||
}
|
||||
|
||||
foreach($this->sigslots[$signal] as $slot)
|
||||
{
|
||||
$return = $slot->call($params);
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a MD5 hash based on a given callback.
|
||||
*
|
||||
* @param mixed $callback
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
public function getCallbackHash($callback)
|
||||
{
|
||||
if(!is_callable($callback, TRUE, $callable_name))
|
||||
{
|
||||
throw new TeamSpeak3_Helper_Signal_Exception("invalid callback specified");
|
||||
}
|
||||
|
||||
return md5($callable_name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscribes to a signal and returns the signal handler.
|
||||
*
|
||||
* @param string $signal
|
||||
* @param mixed $callback
|
||||
* @return TeamSpeak3_Helper_Signal_Handler
|
||||
*/
|
||||
public function subscribe($signal, $callback)
|
||||
{
|
||||
if(empty($this->sigslots[$signal]))
|
||||
{
|
||||
$this->sigslots[$signal] = array();
|
||||
}
|
||||
|
||||
$index = $this->getCallbackHash($callback);
|
||||
|
||||
if(!array_key_exists($index, $this->sigslots[$signal]))
|
||||
{
|
||||
$this->sigslots[$signal][$index] = new TeamSpeak3_Helper_Signal_Handler($signal, $callback);
|
||||
}
|
||||
|
||||
return $this->sigslots[$signal][$index];
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsubscribes from a signal.
|
||||
*
|
||||
* @param string $signal
|
||||
* @param mixed $callback
|
||||
* @return void
|
||||
*/
|
||||
public function unsubscribe($signal, $callback = null)
|
||||
{
|
||||
if(!$this->hasHandlers($signal))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if($callback !== null)
|
||||
{
|
||||
$index = $this->getCallbackHash($callback);
|
||||
|
||||
if(!array_key_exists($index, $this->sigslots[$signal]))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
unset($this->sigslots[$signal][$index]);
|
||||
}
|
||||
else
|
||||
{
|
||||
unset($this->sigslots[$signal]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all registered signals.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getSignals()
|
||||
{
|
||||
return array_keys($this->sigslots);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns TRUE there are slots subscribed for a specified signal.
|
||||
*
|
||||
* @param string $signal
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasHandlers($signal)
|
||||
{
|
||||
return empty($this->sigslots[$signal]) ? FALSE : TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all slots for a specified signal.
|
||||
*
|
||||
* @param string $signal
|
||||
* @return array
|
||||
*/
|
||||
public function getHandlers($signal)
|
||||
{
|
||||
if($this->hasHandlers($signal))
|
||||
{
|
||||
return $this->sigslots[$signal];
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears all slots for a specified signal.
|
||||
*
|
||||
* @param string $signal
|
||||
* @return void
|
||||
*/
|
||||
public function clearHandlers($signal)
|
||||
{
|
||||
if($this->hasHandlers($signal))
|
||||
{
|
||||
unset($this->sigslots[$signal]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a singleton instance of TeamSpeak3_Helper_Signal.
|
||||
*
|
||||
* @return TeamSpeak3_Helper_Signal
|
||||
*/
|
||||
public static function getInstance()
|
||||
{
|
||||
if(self::$instance === null)
|
||||
{
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Helper_Signal_Exception
|
||||
* @brief Enhanced exception class for TeamSpeak3_Helper_Signal objects.
|
||||
*/
|
||||
class TeamSpeak3_Helper_Signal_Exception extends TeamSpeak3_Helper_Exception {}
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Helper_Signal_Exception
|
||||
* @brief Enhanced exception class for TeamSpeak3_Helper_Signal objects.
|
||||
*/
|
||||
class TeamSpeak3_Helper_Signal_Exception extends TeamSpeak3_Helper_Exception {}
|
||||
|
||||
@@ -1,75 +1,75 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Helper_Signal_Handler
|
||||
* @brief Helper class providing handler functions for signals.
|
||||
*/
|
||||
class TeamSpeak3_Helper_Signal_Handler
|
||||
{
|
||||
/**
|
||||
* Stores the name of the subscribed signal.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signal = null;
|
||||
|
||||
/**
|
||||
* Stores the callback function for the subscribed signal.
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
protected $callback = null;
|
||||
|
||||
/**
|
||||
* The TeamSpeak3_Helper_Signal_Handler constructor.
|
||||
*
|
||||
* @param string $signal
|
||||
* @param mixed $callback
|
||||
* @throws TeamSpeak3_Helper_Signal_Exception
|
||||
* @return TeamSpeak3_Helper_Signal_Handler
|
||||
*/
|
||||
public function __construct($signal, $callback)
|
||||
{
|
||||
$this->signal = (string) $signal;
|
||||
|
||||
if(!is_callable($callback))
|
||||
{
|
||||
throw new TeamSpeak3_Helper_Signal_Exception("invalid callback specified for signal '" . $signal . "'");
|
||||
}
|
||||
|
||||
$this->callback = $callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke the signal handler.
|
||||
*
|
||||
* @param array $args
|
||||
* @return mixed
|
||||
*/
|
||||
public function call(array $args = array())
|
||||
{
|
||||
return call_user_func_array($this->callback, $args);
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Helper_Signal_Handler
|
||||
* @brief Helper class providing handler functions for signals.
|
||||
*/
|
||||
class TeamSpeak3_Helper_Signal_Handler
|
||||
{
|
||||
/**
|
||||
* Stores the name of the subscribed signal.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signal = null;
|
||||
|
||||
/**
|
||||
* Stores the callback function for the subscribed signal.
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
protected $callback = null;
|
||||
|
||||
/**
|
||||
* The TeamSpeak3_Helper_Signal_Handler constructor.
|
||||
*
|
||||
* @param string $signal
|
||||
* @param mixed $callback
|
||||
* @throws TeamSpeak3_Helper_Signal_Exception
|
||||
* @return TeamSpeak3_Helper_Signal_Handler
|
||||
*/
|
||||
public function __construct($signal, $callback)
|
||||
{
|
||||
$this->signal = (string) $signal;
|
||||
|
||||
if(!is_callable($callback))
|
||||
{
|
||||
throw new TeamSpeak3_Helper_Signal_Exception("invalid callback specified for signal '" . $signal . "'");
|
||||
}
|
||||
|
||||
$this->callback = $callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke the signal handler.
|
||||
*
|
||||
* @param array $args
|
||||
* @return mixed
|
||||
*/
|
||||
public function call(array $args = array())
|
||||
{
|
||||
return call_user_func_array($this->callback, $args);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,340 +1,340 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Helper_Signal_Interface
|
||||
* @brief Interface class describing the layout for TeamSpeak3_Helper_Signal callbacks.
|
||||
*/
|
||||
interface TeamSpeak3_Helper_Signal_Interface
|
||||
{
|
||||
/**
|
||||
* Possible callback for '<adapter>Connected' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("serverqueryConnected", array($object, "onConnect"));
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("filetransferConnected", array($object, "onConnect"));
|
||||
*
|
||||
* @param TeamSpeak3_Adapter_Abstract $adapter
|
||||
* @return void
|
||||
*/
|
||||
public function onConnect(TeamSpeak3_Adapter_Abstract $adapter);
|
||||
|
||||
/**
|
||||
* Possible callback for '<adapter>Disconnected' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("serverqueryDisconnected", array($object, "onDisconnect"));
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("filetransferDisconnected", array($object, "onDisconnect"));
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function onDisconnect();
|
||||
|
||||
/**
|
||||
* Possible callback for 'serverqueryCommandStarted' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("serverqueryCommandStarted", array($object, "onCommandStarted"));
|
||||
*
|
||||
* @param string $cmd
|
||||
* @return void
|
||||
*/
|
||||
public function onCommandStarted($cmd);
|
||||
|
||||
/**
|
||||
* Possible callback for 'serverqueryCommandFinished' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("serverqueryCommandFinished", array($object, "onCommandFinished"));
|
||||
*
|
||||
* @param string $cmd
|
||||
* @param TeamSpeak3_Adapter_ServerQuery_Reply $reply
|
||||
* @return void
|
||||
*/
|
||||
public function onCommandFinished($cmd, TeamSpeak3_Adapter_ServerQuery_Reply $reply);
|
||||
|
||||
/**
|
||||
* Possible callback for 'notifyEvent' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyEvent", array($object, "onEvent"));
|
||||
*
|
||||
* @param TeamSpeak3_Adapter_ServerQuery_Event $event
|
||||
* @param TeamSpeak3_Node_Host $host
|
||||
* @return void
|
||||
*/
|
||||
public function onEvent(TeamSpeak3_Adapter_ServerQuery_Event $event, TeamSpeak3_Node_Host $host);
|
||||
|
||||
/**
|
||||
* Possible callback for 'notifyError' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyError", array($object, "onError"));
|
||||
*
|
||||
* @param TeamSpeak3_Adapter_ServerQuery_Reply $reply
|
||||
* @return void
|
||||
*/
|
||||
public function onError(TeamSpeak3_Adapter_ServerQuery_Reply $reply);
|
||||
|
||||
/**
|
||||
* Possible callback for 'notifyServerselected' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyServerselected", array($object, "onServerselected"));
|
||||
*
|
||||
* @param TeamSpeak3_Node_Host $host
|
||||
* @return void
|
||||
*/
|
||||
public function onServerselected(TeamSpeak3_Node_Host $host);
|
||||
|
||||
/**
|
||||
* Possible callback for 'notifyServercreated' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyServercreated", array($object, "onServercreated"));
|
||||
*
|
||||
* @param TeamSpeak3_Node_Host $host
|
||||
* @param integer $sid
|
||||
* @return void
|
||||
*/
|
||||
public function onServercreated(TeamSpeak3_Node_Host $host, $sid);
|
||||
|
||||
/**
|
||||
* Possible callback for 'notifyServerdeleted' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyServerdeleted", array($object, "onServerdeleted"));
|
||||
*
|
||||
* @param TeamSpeak3_Node_Host $host
|
||||
* @param integer $sid
|
||||
* @return void
|
||||
*/
|
||||
public function onServerdeleted(TeamSpeak3_Node_Host $host, $sid);
|
||||
|
||||
/**
|
||||
* Possible callback for 'notifyServerstarted' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyServerstarted", array($object, "onServerstarted"));
|
||||
*
|
||||
* @param TeamSpeak3_Node_Host $host
|
||||
* @param integer $sid
|
||||
* @return void
|
||||
*/
|
||||
public function onServerstarted(TeamSpeak3_Node_Host $host, $sid);
|
||||
|
||||
/**
|
||||
* Possible callback for 'notifyServerstopped' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyServerstopped", array($object, "onServerstopped"));
|
||||
*
|
||||
* @param TeamSpeak3_Node_Host $host
|
||||
* @param integer $sid
|
||||
* @return void
|
||||
*/
|
||||
public function onServerstopped(TeamSpeak3_Node_Host $host, $sid);
|
||||
|
||||
/**
|
||||
* Possible callback for 'notifyServershutdown' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyServershutdown", array($object, "onServershutdown"));
|
||||
*
|
||||
* @param TeamSpeak3_Node_Host $host
|
||||
* @return void
|
||||
*/
|
||||
public function onServershutdown(TeamSpeak3_Node_Host $host);
|
||||
|
||||
/**
|
||||
* Possible callback for 'notifyLogin' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyLogin", array($object, "onLogin"));
|
||||
*
|
||||
* @param TeamSpeak3_Node_Host $host
|
||||
* @return void
|
||||
*/
|
||||
public function onLogin(TeamSpeak3_Node_Host $host);
|
||||
|
||||
/**
|
||||
* Possible callback for 'notifyLogout' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyLogout", array($object, "onLogout"));
|
||||
*
|
||||
* @param TeamSpeak3_Node_Host $host
|
||||
* @return void
|
||||
*/
|
||||
public function onLogout(TeamSpeak3_Node_Host $host);
|
||||
|
||||
/**
|
||||
* Possible callback for 'notifyTokencreated' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyTokencreated", array($object, "onTokencreated"));
|
||||
*
|
||||
* @param TeamSpeak3_Node_Server $server
|
||||
* @param string $token
|
||||
* @return void
|
||||
*/
|
||||
public function onTokencreated(TeamSpeak3_Node_Server $server, $token);
|
||||
|
||||
/**
|
||||
* Possible callback for 'filetransferHandshake' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("filetransferHandshake", array($object, "onFtHandshake"));
|
||||
*
|
||||
* @param TeamSpeak3_Adapter_FileTransfer $adapter
|
||||
* @return void
|
||||
*/
|
||||
public function onFtHandshake(TeamSpeak3_Adapter_FileTransfer $adapter);
|
||||
|
||||
/**
|
||||
* Possible callback for 'filetransferUploadStarted' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("filetransferUploadStarted", array($object, "onFtUploadStarted"));
|
||||
*
|
||||
* @param string $ftkey
|
||||
* @param integer $seek
|
||||
* @param integer $size
|
||||
* @return void
|
||||
*/
|
||||
public function onFtUploadStarted($ftkey, $seek, $size);
|
||||
|
||||
/**
|
||||
* Possible callback for 'filetransferUploadProgress' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("filetransferUploadProgress", array($object, "onFtUploadProgress"));
|
||||
*
|
||||
* @param string $ftkey
|
||||
* @param integer $seek
|
||||
* @param integer $size
|
||||
* @return void
|
||||
*/
|
||||
public function onFtUploadProgress($ftkey, $seek, $size);
|
||||
|
||||
/**
|
||||
* Possible callback for 'filetransferUploadFinished' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("filetransferUploadFinished", array($object, "onFtUploadFinished"));
|
||||
*
|
||||
* @param string $ftkey
|
||||
* @param integer $seek
|
||||
* @param integer $size
|
||||
* @return void
|
||||
*/
|
||||
public function onFtUploadFinished($ftkey, $seek, $size);
|
||||
|
||||
/**
|
||||
* Possible callback for 'filetransferDownloadStarted' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("filetransferDownloadStarted", array($object, "onFtDownloadStarted"));
|
||||
*
|
||||
* @param string $ftkey
|
||||
* @param integer $buff
|
||||
* @param integer $size
|
||||
* @return void
|
||||
*/
|
||||
public function onFtDownloadStarted($ftkey, $buff, $size);
|
||||
|
||||
/**
|
||||
* Possible callback for 'filetransferDownloadProgress' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("filetransferDownloadProgress", array($object, "onFtDownloadProgress"));
|
||||
*
|
||||
* @param string $ftkey
|
||||
* @param integer $buff
|
||||
* @param integer $size
|
||||
* @return void
|
||||
*/
|
||||
public function onFtDownloadProgress($ftkey, $buff, $size);
|
||||
|
||||
/**
|
||||
* Possible callback for 'filetransferDownloadFinished' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("filetransferDownloadFinished", array($object, "onFtDownloadFinished"));
|
||||
*
|
||||
* @param string $ftkey
|
||||
* @param integer $buff
|
||||
* @param integer $size
|
||||
* @return void
|
||||
*/
|
||||
public function onFtDownloadFinished($ftkey, $buff, $size);
|
||||
|
||||
/**
|
||||
* Possible callback for '<adapter>DataRead' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("serverqueryDataRead", array($object, "onDebugDataRead"));
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("filetransferDataRead", array($object, "onDebugDataRead"));
|
||||
*
|
||||
* @param string $data
|
||||
* @return void
|
||||
*/
|
||||
public function onDebugDataRead($data);
|
||||
|
||||
/**
|
||||
* Possible callback for '<adapter>DataSend' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("serverqueryDataSend", array($object, "onDebugDataSend"));
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("filetransferDataSend", array($object, "onDebugDataSend"));
|
||||
*
|
||||
* @param string $data
|
||||
* @return void
|
||||
*/
|
||||
public function onDebugDataSend($data);
|
||||
|
||||
/**
|
||||
* Possible callback for '<adapter>WaitTimeout' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("serverqueryWaitTimeout", array($object, "onWaitTimeout"));
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("filetransferWaitTimeout", array($object, "onWaitTimeout"));
|
||||
*
|
||||
* @param integer $time
|
||||
* @param TeamSpeak3_Adapter_Abstract $adapter
|
||||
* @return void
|
||||
*/
|
||||
public function onWaitTimeout($time, TeamSpeak3_Adapter_Abstract $adapter);
|
||||
|
||||
/**
|
||||
* Possible callback for 'errorException' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("errorException", array($object, "onException"));
|
||||
*
|
||||
* @param TeamSpeak3_Exception $e
|
||||
* @return void
|
||||
*/
|
||||
public function onException(TeamSpeak3_Exception $e);
|
||||
}
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Helper_Signal_Interface
|
||||
* @brief Interface class describing the layout for TeamSpeak3_Helper_Signal callbacks.
|
||||
*/
|
||||
interface TeamSpeak3_Helper_Signal_Interface
|
||||
{
|
||||
/**
|
||||
* Possible callback for '<adapter>Connected' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("serverqueryConnected", array($object, "onConnect"));
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("filetransferConnected", array($object, "onConnect"));
|
||||
*
|
||||
* @param TeamSpeak3_Adapter_Abstract $adapter
|
||||
* @return void
|
||||
*/
|
||||
public function onConnect(TeamSpeak3_Adapter_Abstract $adapter);
|
||||
|
||||
/**
|
||||
* Possible callback for '<adapter>Disconnected' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("serverqueryDisconnected", array($object, "onDisconnect"));
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("filetransferDisconnected", array($object, "onDisconnect"));
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function onDisconnect();
|
||||
|
||||
/**
|
||||
* Possible callback for 'serverqueryCommandStarted' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("serverqueryCommandStarted", array($object, "onCommandStarted"));
|
||||
*
|
||||
* @param string $cmd
|
||||
* @return void
|
||||
*/
|
||||
public function onCommandStarted($cmd);
|
||||
|
||||
/**
|
||||
* Possible callback for 'serverqueryCommandFinished' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("serverqueryCommandFinished", array($object, "onCommandFinished"));
|
||||
*
|
||||
* @param string $cmd
|
||||
* @param TeamSpeak3_Adapter_ServerQuery_Reply $reply
|
||||
* @return void
|
||||
*/
|
||||
public function onCommandFinished($cmd, TeamSpeak3_Adapter_ServerQuery_Reply $reply);
|
||||
|
||||
/**
|
||||
* Possible callback for 'notifyEvent' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyEvent", array($object, "onEvent"));
|
||||
*
|
||||
* @param TeamSpeak3_Adapter_ServerQuery_Event $event
|
||||
* @param TeamSpeak3_Node_Host $host
|
||||
* @return void
|
||||
*/
|
||||
public function onEvent(TeamSpeak3_Adapter_ServerQuery_Event $event, TeamSpeak3_Node_Host $host);
|
||||
|
||||
/**
|
||||
* Possible callback for 'notifyError' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyError", array($object, "onError"));
|
||||
*
|
||||
* @param TeamSpeak3_Adapter_ServerQuery_Reply $reply
|
||||
* @return void
|
||||
*/
|
||||
public function onError(TeamSpeak3_Adapter_ServerQuery_Reply $reply);
|
||||
|
||||
/**
|
||||
* Possible callback for 'notifyServerselected' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyServerselected", array($object, "onServerselected"));
|
||||
*
|
||||
* @param TeamSpeak3_Node_Host $host
|
||||
* @return void
|
||||
*/
|
||||
public function onServerselected(TeamSpeak3_Node_Host $host);
|
||||
|
||||
/**
|
||||
* Possible callback for 'notifyServercreated' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyServercreated", array($object, "onServercreated"));
|
||||
*
|
||||
* @param TeamSpeak3_Node_Host $host
|
||||
* @param integer $sid
|
||||
* @return void
|
||||
*/
|
||||
public function onServercreated(TeamSpeak3_Node_Host $host, $sid);
|
||||
|
||||
/**
|
||||
* Possible callback for 'notifyServerdeleted' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyServerdeleted", array($object, "onServerdeleted"));
|
||||
*
|
||||
* @param TeamSpeak3_Node_Host $host
|
||||
* @param integer $sid
|
||||
* @return void
|
||||
*/
|
||||
public function onServerdeleted(TeamSpeak3_Node_Host $host, $sid);
|
||||
|
||||
/**
|
||||
* Possible callback for 'notifyServerstarted' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyServerstarted", array($object, "onServerstarted"));
|
||||
*
|
||||
* @param TeamSpeak3_Node_Host $host
|
||||
* @param integer $sid
|
||||
* @return void
|
||||
*/
|
||||
public function onServerstarted(TeamSpeak3_Node_Host $host, $sid);
|
||||
|
||||
/**
|
||||
* Possible callback for 'notifyServerstopped' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyServerstopped", array($object, "onServerstopped"));
|
||||
*
|
||||
* @param TeamSpeak3_Node_Host $host
|
||||
* @param integer $sid
|
||||
* @return void
|
||||
*/
|
||||
public function onServerstopped(TeamSpeak3_Node_Host $host, $sid);
|
||||
|
||||
/**
|
||||
* Possible callback for 'notifyServershutdown' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyServershutdown", array($object, "onServershutdown"));
|
||||
*
|
||||
* @param TeamSpeak3_Node_Host $host
|
||||
* @return void
|
||||
*/
|
||||
public function onServershutdown(TeamSpeak3_Node_Host $host);
|
||||
|
||||
/**
|
||||
* Possible callback for 'notifyLogin' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyLogin", array($object, "onLogin"));
|
||||
*
|
||||
* @param TeamSpeak3_Node_Host $host
|
||||
* @return void
|
||||
*/
|
||||
public function onLogin(TeamSpeak3_Node_Host $host);
|
||||
|
||||
/**
|
||||
* Possible callback for 'notifyLogout' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyLogout", array($object, "onLogout"));
|
||||
*
|
||||
* @param TeamSpeak3_Node_Host $host
|
||||
* @return void
|
||||
*/
|
||||
public function onLogout(TeamSpeak3_Node_Host $host);
|
||||
|
||||
/**
|
||||
* Possible callback for 'notifyTokencreated' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyTokencreated", array($object, "onTokencreated"));
|
||||
*
|
||||
* @param TeamSpeak3_Node_Server $server
|
||||
* @param string $token
|
||||
* @return void
|
||||
*/
|
||||
public function onTokencreated(TeamSpeak3_Node_Server $server, $token);
|
||||
|
||||
/**
|
||||
* Possible callback for 'filetransferHandshake' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("filetransferHandshake", array($object, "onFtHandshake"));
|
||||
*
|
||||
* @param TeamSpeak3_Adapter_FileTransfer $adapter
|
||||
* @return void
|
||||
*/
|
||||
public function onFtHandshake(TeamSpeak3_Adapter_FileTransfer $adapter);
|
||||
|
||||
/**
|
||||
* Possible callback for 'filetransferUploadStarted' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("filetransferUploadStarted", array($object, "onFtUploadStarted"));
|
||||
*
|
||||
* @param string $ftkey
|
||||
* @param integer $seek
|
||||
* @param integer $size
|
||||
* @return void
|
||||
*/
|
||||
public function onFtUploadStarted($ftkey, $seek, $size);
|
||||
|
||||
/**
|
||||
* Possible callback for 'filetransferUploadProgress' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("filetransferUploadProgress", array($object, "onFtUploadProgress"));
|
||||
*
|
||||
* @param string $ftkey
|
||||
* @param integer $seek
|
||||
* @param integer $size
|
||||
* @return void
|
||||
*/
|
||||
public function onFtUploadProgress($ftkey, $seek, $size);
|
||||
|
||||
/**
|
||||
* Possible callback for 'filetransferUploadFinished' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("filetransferUploadFinished", array($object, "onFtUploadFinished"));
|
||||
*
|
||||
* @param string $ftkey
|
||||
* @param integer $seek
|
||||
* @param integer $size
|
||||
* @return void
|
||||
*/
|
||||
public function onFtUploadFinished($ftkey, $seek, $size);
|
||||
|
||||
/**
|
||||
* Possible callback for 'filetransferDownloadStarted' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("filetransferDownloadStarted", array($object, "onFtDownloadStarted"));
|
||||
*
|
||||
* @param string $ftkey
|
||||
* @param integer $buff
|
||||
* @param integer $size
|
||||
* @return void
|
||||
*/
|
||||
public function onFtDownloadStarted($ftkey, $buff, $size);
|
||||
|
||||
/**
|
||||
* Possible callback for 'filetransferDownloadProgress' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("filetransferDownloadProgress", array($object, "onFtDownloadProgress"));
|
||||
*
|
||||
* @param string $ftkey
|
||||
* @param integer $buff
|
||||
* @param integer $size
|
||||
* @return void
|
||||
*/
|
||||
public function onFtDownloadProgress($ftkey, $buff, $size);
|
||||
|
||||
/**
|
||||
* Possible callback for 'filetransferDownloadFinished' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("filetransferDownloadFinished", array($object, "onFtDownloadFinished"));
|
||||
*
|
||||
* @param string $ftkey
|
||||
* @param integer $buff
|
||||
* @param integer $size
|
||||
* @return void
|
||||
*/
|
||||
public function onFtDownloadFinished($ftkey, $buff, $size);
|
||||
|
||||
/**
|
||||
* Possible callback for '<adapter>DataRead' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("serverqueryDataRead", array($object, "onDebugDataRead"));
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("filetransferDataRead", array($object, "onDebugDataRead"));
|
||||
*
|
||||
* @param string $data
|
||||
* @return void
|
||||
*/
|
||||
public function onDebugDataRead($data);
|
||||
|
||||
/**
|
||||
* Possible callback for '<adapter>DataSend' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("serverqueryDataSend", array($object, "onDebugDataSend"));
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("filetransferDataSend", array($object, "onDebugDataSend"));
|
||||
*
|
||||
* @param string $data
|
||||
* @return void
|
||||
*/
|
||||
public function onDebugDataSend($data);
|
||||
|
||||
/**
|
||||
* Possible callback for '<adapter>WaitTimeout' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("serverqueryWaitTimeout", array($object, "onWaitTimeout"));
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("filetransferWaitTimeout", array($object, "onWaitTimeout"));
|
||||
*
|
||||
* @param integer $time
|
||||
* @param TeamSpeak3_Adapter_Abstract $adapter
|
||||
* @return void
|
||||
*/
|
||||
public function onWaitTimeout($time, TeamSpeak3_Adapter_Abstract $adapter);
|
||||
|
||||
/**
|
||||
* Possible callback for 'errorException' signals.
|
||||
*
|
||||
* === Examples ===
|
||||
* - TeamSpeak3_Helper_Signal::getInstance()->subscribe("errorException", array($object, "onException"));
|
||||
*
|
||||
* @param TeamSpeak3_Exception $e
|
||||
* @return void
|
||||
*/
|
||||
public function onException(TeamSpeak3_Exception $e);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,274 +1,274 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Node_Channelgroup
|
||||
* @brief Class describing a TeamSpeak 3 channel group and all it's parameters.
|
||||
*/
|
||||
class TeamSpeak3_Node_Channelgroup extends TeamSpeak3_Node_Abstract
|
||||
{
|
||||
/**
|
||||
* The TeamSpeak3_Node_Channelgroup constructor.
|
||||
*
|
||||
* @param TeamSpeak3_Node_Server $server
|
||||
* @param array $info
|
||||
* @param string $index
|
||||
* @throws TeamSpeak3_Adapter_ServerQuery_Exception
|
||||
* @return TeamSpeak3_Node_Channelgroup
|
||||
*/
|
||||
public function __construct(TeamSpeak3_Node_Server $server, array $info, $index = "cgid")
|
||||
{
|
||||
$this->parent = $server;
|
||||
$this->nodeInfo = $info;
|
||||
|
||||
if(!array_key_exists($index, $this->nodeInfo))
|
||||
{
|
||||
throw new TeamSpeak3_Adapter_ServerQuery_Exception("invalid groupID", 0xA00);
|
||||
}
|
||||
|
||||
$this->nodeId = $this->nodeInfo[$index];
|
||||
}
|
||||
|
||||
/**
|
||||
* Renames the channel group specified.
|
||||
*
|
||||
* @param string $name
|
||||
* @return void
|
||||
*/
|
||||
public function rename($name)
|
||||
{
|
||||
$this->getParent()->channelGroupRename($this->getId(), $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the channel group. If $force is set to TRUE, the channel group will be
|
||||
* deleted even if there are clients within.
|
||||
*
|
||||
* @param boolean $force
|
||||
* @return void
|
||||
*/
|
||||
public function delete($force = FALSE)
|
||||
{
|
||||
$this->getParent()->channelGroupDelete($this->getId(), $force);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a copy of the channel group and returns the new groups ID.
|
||||
*
|
||||
* @param string $name
|
||||
* @param integer $tcgid
|
||||
* @param integer $type
|
||||
* @return integer
|
||||
*/
|
||||
public function copy($name = null, $tcgid = 0, $type = TeamSpeak3::GROUP_DBTYPE_REGULAR)
|
||||
{
|
||||
return $this->getParent()->channelGroupCopy($this->getId(), $name, $tcgid, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of permissions assigned to the channel group.
|
||||
*
|
||||
* @param boolean $permsid
|
||||
* @return array
|
||||
*/
|
||||
public function permList($permsid = FALSE)
|
||||
{
|
||||
return $this->getParent()->channelGroupPermList($this->getId(), $permsid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a set of specified permissions to the channel group. Multiple permissions
|
||||
* can be added by providing the two parameters of each permission in separate arrays.
|
||||
*
|
||||
* @param integer $permid
|
||||
* @param integer $permvalue
|
||||
* @return void
|
||||
*/
|
||||
public function permAssign($permid, $permvalue)
|
||||
{
|
||||
$this->getParent()->channelGroupPermAssign($this->getId(), $permid, $permvalue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for permAssign().
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function permAssignByName($permname, $permvalue)
|
||||
{
|
||||
$this->permAssign($permname, $permvalue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a set of specified permissions from the channel group. Multiple
|
||||
* permissions can be removed at once.
|
||||
*
|
||||
* @param integer $permid
|
||||
* @return void
|
||||
*/
|
||||
public function permRemove($permid)
|
||||
{
|
||||
$this->getParent()->channelGroupPermRemove($this->getId(), $permid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for permAssign().
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function permRemoveByName($permname)
|
||||
{
|
||||
$this->permRemove($permname);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of clients assigned to the channel group specified.
|
||||
*
|
||||
* @param integer $cid
|
||||
* @param integer $cldbid
|
||||
* @param boolean $resolve
|
||||
* @return array
|
||||
*/
|
||||
public function clientList($cid = null, $cldbid = null, $resolve = FALSE)
|
||||
{
|
||||
return $this->getParent()->channelGroupClientList($this->getId(), $cid, $cldbid, $resolve);
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for privilegeKeyCreate().
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function tokenCreate($cid, $description = null, $customset = null)
|
||||
{
|
||||
return $this->privilegeKeyCreate($cid, $description, $customset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new privilege key (token) for the channel group and returns the key.
|
||||
*
|
||||
* @param integer $cid
|
||||
* @param string $description
|
||||
* @param string $customset
|
||||
* @return TeamSpeak3_Helper_String
|
||||
*/
|
||||
public function privilegeKeyCreate($cid, $description = null, $customset = null)
|
||||
{
|
||||
return $this->getParent()->privilegeKeyCreate(TeamSpeak3::TOKEN_CHANNELGROUP, $this->getId(), $cid, $description, $customset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a text message to all clients residing in the channel group on the virtual server.
|
||||
*
|
||||
* @param string $msg
|
||||
* @return void
|
||||
*/
|
||||
public function message($msg)
|
||||
{
|
||||
foreach($this as $client)
|
||||
{
|
||||
try
|
||||
{
|
||||
$this->execute("sendtextmessage", array("msg" => $msg, "target" => $client, "targetmode" => TeamSpeak3::TEXTMSG_CLIENT));
|
||||
}
|
||||
catch(TeamSpeak3_Adapter_ServerQuery_Exception $e)
|
||||
{
|
||||
/* ERROR_client_invalid_id */
|
||||
if($e->getCode() != 0x0200) throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Downloads and returns the channel groups icon file content.
|
||||
*
|
||||
* @return TeamSpeak3_Helper_String
|
||||
*/
|
||||
public function iconDownload()
|
||||
{
|
||||
if($this->iconIsLocal("iconid") || $this["iconid"] == 0) return;
|
||||
|
||||
$download = $this->getParent()->transferInitDownload(rand(0x0000, 0xFFFF), 0, $this->iconGetName("iconid"));
|
||||
$transfer = TeamSpeak3::factory("filetransfer://" . (strstr($download["host"], ":") !== FALSE ? "[" . $download["host"] . "]" : $download["host"]) . ":" . $download["port"]);
|
||||
|
||||
return $transfer->download($download["ftkey"], $download["size"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
protected function fetchNodeList()
|
||||
{
|
||||
$this->nodeList = array();
|
||||
|
||||
foreach($this->getParent()->clientList() as $client)
|
||||
{
|
||||
if($client["client_channel_group_id"] == $this->getId())
|
||||
{
|
||||
$this->nodeList[] = $client;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a unique identifier for the node which can be used as a HTML property.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUniqueId()
|
||||
{
|
||||
return $this->getParent()->getUniqueId() . "_cg" . $this->getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of a possible icon to display the node object.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getIcon()
|
||||
{
|
||||
return "group_channel";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a symbol representing the node.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSymbol()
|
||||
{
|
||||
return "%";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this node.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return (string) $this["name"];
|
||||
}
|
||||
}
|
||||
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Node_Channelgroup
|
||||
* @brief Class describing a TeamSpeak 3 channel group and all it's parameters.
|
||||
*/
|
||||
class TeamSpeak3_Node_Channelgroup extends TeamSpeak3_Node_Abstract
|
||||
{
|
||||
/**
|
||||
* The TeamSpeak3_Node_Channelgroup constructor.
|
||||
*
|
||||
* @param TeamSpeak3_Node_Server $server
|
||||
* @param array $info
|
||||
* @param string $index
|
||||
* @throws TeamSpeak3_Adapter_ServerQuery_Exception
|
||||
* @return TeamSpeak3_Node_Channelgroup
|
||||
*/
|
||||
public function __construct(TeamSpeak3_Node_Server $server, array $info, $index = "cgid")
|
||||
{
|
||||
$this->parent = $server;
|
||||
$this->nodeInfo = $info;
|
||||
|
||||
if(!array_key_exists($index, $this->nodeInfo))
|
||||
{
|
||||
throw new TeamSpeak3_Adapter_ServerQuery_Exception("invalid groupID", 0xA00);
|
||||
}
|
||||
|
||||
$this->nodeId = $this->nodeInfo[$index];
|
||||
}
|
||||
|
||||
/**
|
||||
* Renames the channel group specified.
|
||||
*
|
||||
* @param string $name
|
||||
* @return void
|
||||
*/
|
||||
public function rename($name)
|
||||
{
|
||||
$this->getParent()->channelGroupRename($this->getId(), $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the channel group. If $force is set to TRUE, the channel group will be
|
||||
* deleted even if there are clients within.
|
||||
*
|
||||
* @param boolean $force
|
||||
* @return void
|
||||
*/
|
||||
public function delete($force = FALSE)
|
||||
{
|
||||
$this->getParent()->channelGroupDelete($this->getId(), $force);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a copy of the channel group and returns the new groups ID.
|
||||
*
|
||||
* @param string $name
|
||||
* @param integer $tcgid
|
||||
* @param integer $type
|
||||
* @return integer
|
||||
*/
|
||||
public function copy($name = null, $tcgid = 0, $type = TeamSpeak3::GROUP_DBTYPE_REGULAR)
|
||||
{
|
||||
return $this->getParent()->channelGroupCopy($this->getId(), $name, $tcgid, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of permissions assigned to the channel group.
|
||||
*
|
||||
* @param boolean $permsid
|
||||
* @return array
|
||||
*/
|
||||
public function permList($permsid = FALSE)
|
||||
{
|
||||
return $this->getParent()->channelGroupPermList($this->getId(), $permsid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a set of specified permissions to the channel group. Multiple permissions
|
||||
* can be added by providing the two parameters of each permission in separate arrays.
|
||||
*
|
||||
* @param integer $permid
|
||||
* @param integer $permvalue
|
||||
* @return void
|
||||
*/
|
||||
public function permAssign($permid, $permvalue)
|
||||
{
|
||||
$this->getParent()->channelGroupPermAssign($this->getId(), $permid, $permvalue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for permAssign().
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function permAssignByName($permname, $permvalue)
|
||||
{
|
||||
$this->permAssign($permname, $permvalue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a set of specified permissions from the channel group. Multiple
|
||||
* permissions can be removed at once.
|
||||
*
|
||||
* @param integer $permid
|
||||
* @return void
|
||||
*/
|
||||
public function permRemove($permid)
|
||||
{
|
||||
$this->getParent()->channelGroupPermRemove($this->getId(), $permid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for permAssign().
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function permRemoveByName($permname)
|
||||
{
|
||||
$this->permRemove($permname);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of clients assigned to the channel group specified.
|
||||
*
|
||||
* @param integer $cid
|
||||
* @param integer $cldbid
|
||||
* @param boolean $resolve
|
||||
* @return array
|
||||
*/
|
||||
public function clientList($cid = null, $cldbid = null, $resolve = FALSE)
|
||||
{
|
||||
return $this->getParent()->channelGroupClientList($this->getId(), $cid, $cldbid, $resolve);
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for privilegeKeyCreate().
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function tokenCreate($cid, $description = null, $customset = null)
|
||||
{
|
||||
return $this->privilegeKeyCreate($cid, $description, $customset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new privilege key (token) for the channel group and returns the key.
|
||||
*
|
||||
* @param integer $cid
|
||||
* @param string $description
|
||||
* @param string $customset
|
||||
* @return TeamSpeak3_Helper_String
|
||||
*/
|
||||
public function privilegeKeyCreate($cid, $description = null, $customset = null)
|
||||
{
|
||||
return $this->getParent()->privilegeKeyCreate(TeamSpeak3::TOKEN_CHANNELGROUP, $this->getId(), $cid, $description, $customset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a text message to all clients residing in the channel group on the virtual server.
|
||||
*
|
||||
* @param string $msg
|
||||
* @return void
|
||||
*/
|
||||
public function message($msg)
|
||||
{
|
||||
foreach($this as $client)
|
||||
{
|
||||
try
|
||||
{
|
||||
$this->execute("sendtextmessage", array("msg" => $msg, "target" => $client, "targetmode" => TeamSpeak3::TEXTMSG_CLIENT));
|
||||
}
|
||||
catch(TeamSpeak3_Adapter_ServerQuery_Exception $e)
|
||||
{
|
||||
/* ERROR_client_invalid_id */
|
||||
if($e->getCode() != 0x0200) throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Downloads and returns the channel groups icon file content.
|
||||
*
|
||||
* @return TeamSpeak3_Helper_String
|
||||
*/
|
||||
public function iconDownload()
|
||||
{
|
||||
if($this->iconIsLocal("iconid") || $this["iconid"] == 0) return;
|
||||
|
||||
$download = $this->getParent()->transferInitDownload(rand(0x0000, 0xFFFF), 0, $this->iconGetName("iconid"));
|
||||
$transfer = TeamSpeak3::factory("filetransfer://" . (strstr($download["host"], ":") !== FALSE ? "[" . $download["host"] . "]" : $download["host"]) . ":" . $download["port"]);
|
||||
|
||||
return $transfer->download($download["ftkey"], $download["size"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
protected function fetchNodeList()
|
||||
{
|
||||
$this->nodeList = array();
|
||||
|
||||
foreach($this->getParent()->clientList() as $client)
|
||||
{
|
||||
if($client["client_channel_group_id"] == $this->getId())
|
||||
{
|
||||
$this->nodeList[] = $client;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a unique identifier for the node which can be used as a HTML property.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUniqueId()
|
||||
{
|
||||
return $this->getParent()->getUniqueId() . "_cg" . $this->getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of a possible icon to display the node object.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getIcon()
|
||||
{
|
||||
return "group_channel";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a symbol representing the node.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSymbol()
|
||||
{
|
||||
return "%";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this node.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return (string) $this["name"];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,471 +1,493 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Node_Client
|
||||
* @brief Class describing a TeamSpeak 3 client and all it's parameters.
|
||||
*/
|
||||
class TeamSpeak3_Node_Client extends TeamSpeak3_Node_Abstract
|
||||
{
|
||||
/**
|
||||
* The TeamSpeak3_Node_Client constructor.
|
||||
*
|
||||
* @param TeamSpeak3_Node_Server $server
|
||||
* @param array $info
|
||||
* @param string $index
|
||||
* @throws TeamSpeak3_Adapter_ServerQuery_Exception
|
||||
* @return TeamSpeak3_Node_Client
|
||||
*/
|
||||
public function __construct(TeamSpeak3_Node_Server $server, array $info, $index = "clid")
|
||||
{
|
||||
$this->parent = $server;
|
||||
$this->nodeInfo = $info;
|
||||
|
||||
if(!array_key_exists($index, $this->nodeInfo))
|
||||
{
|
||||
throw new TeamSpeak3_Adapter_ServerQuery_Exception("invalid clientID", 0x200);
|
||||
}
|
||||
|
||||
$this->nodeId = $this->nodeInfo[$index];
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the clients properties using given properties.
|
||||
*
|
||||
* @param array $properties
|
||||
* @return void
|
||||
*/
|
||||
public function modify(array $properties)
|
||||
{
|
||||
$properties["clid"] = $this->getId();
|
||||
|
||||
$this->execute("clientedit", $properties);
|
||||
$this->resetNodeInfo();
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the clients properties using given properties.
|
||||
*
|
||||
* @param array $properties
|
||||
* @return void
|
||||
*/
|
||||
public function modifyDb(array $properties)
|
||||
{
|
||||
$this->getParent()->clientModifyDb($this["client_database_id"], $properties);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the clients properties from the database.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function deleteDb()
|
||||
{
|
||||
$this->getParent()->clientDeleteDb($this["client_database_id"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of properties from the database for the client.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function infoDb()
|
||||
{
|
||||
return $this->getParent()->clientInfoDb($this["client_database_id"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a text message to the client.
|
||||
*
|
||||
* @param string $msg
|
||||
* @return void
|
||||
*/
|
||||
public function message($msg)
|
||||
{
|
||||
$this->execute("sendtextmessage", array("msg" => $msg, "target" => $this->getId(), "targetmode" => TeamSpeak3::TEXTMSG_CLIENT));
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the client to another channel.
|
||||
*
|
||||
* @param integer $cid
|
||||
* @param string $cpw
|
||||
* @return void
|
||||
*/
|
||||
public function move($cid, $cpw = null)
|
||||
{
|
||||
$this->getParent()->clientMove($this->getId(), $cid, $cpw);
|
||||
}
|
||||
|
||||
/**
|
||||
* Kicks the client from his currently joined channel or from the server.
|
||||
*
|
||||
* @param integer $reasonid
|
||||
* @param string $reasonmsg
|
||||
* @return void
|
||||
*/
|
||||
public function kick($reasonid = TeamSpeak3::KICK_CHANNEL, $reasonmsg = null)
|
||||
{
|
||||
$this->getParent()->clientKick($this->getId(), $reasonid, $reasonmsg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a poke message to the client.
|
||||
*
|
||||
* @param string $msg
|
||||
* @return void
|
||||
*/
|
||||
public function poke($msg)
|
||||
{
|
||||
$this->getParent()->clientPoke($this->getId(), $msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Bans the client from the server. Please note that this will create two separate
|
||||
* ban rules for the targeted clients IP address and his unique identifier.
|
||||
*
|
||||
* @param integer $timeseconds
|
||||
* @param string $reason
|
||||
* @return array
|
||||
*/
|
||||
public function ban($timeseconds = null, $reason = null)
|
||||
{
|
||||
return $this->getParent()->clientBan($this->getId(), $timeseconds, $reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of custom properties for the client.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function customInfo()
|
||||
{
|
||||
return $this->getParent()->customInfo($this["client_database_id"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing the permission overview of the client.
|
||||
*
|
||||
* @param integer $cid
|
||||
* @return array
|
||||
*/
|
||||
public function permOverview($cid)
|
||||
{
|
||||
return $this->execute("permoverview", array("cldbid" => $this["client_database_id"], "cid" => $cid, "permid" => 0))->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of permissions defined for the client.
|
||||
*
|
||||
* @param boolean $permsid
|
||||
* @return array
|
||||
*/
|
||||
public function permList($permsid = FALSE)
|
||||
{
|
||||
return $this->getParent()->clientPermList($this["client_database_id"], $permsid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a set of specified permissions to the client. Multiple permissions can be added by providing
|
||||
* the three parameters of each permission.
|
||||
*
|
||||
* @param integer $permid
|
||||
* @param integer $permvalue
|
||||
* @param integer $permskip
|
||||
* @return void
|
||||
*/
|
||||
public function permAssign($permid, $permvalue, $permskip = FALSE)
|
||||
{
|
||||
$this->getParent()->clientPermAssign($this["client_database_id"], $permid, $permvalue, $permskip);
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for permAssign().
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function permAssignByName($permname, $permvalue, $permskip = FALSE)
|
||||
{
|
||||
$this->permAssign($permname, $permvalue, $permskip);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a set of specified permissions from a client. Multiple permissions can be removed at once.
|
||||
*
|
||||
* @param integer $permid
|
||||
* @return void
|
||||
*/
|
||||
public function permRemove($permid)
|
||||
{
|
||||
$this->getParent()->clientPermRemove($this["client_database_id"], $permid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for permRemove().
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function permRemoveByName($permname)
|
||||
{
|
||||
$this->permRemove($permname);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the channel group of a client to the ID specified.
|
||||
*
|
||||
* @param integer $cid
|
||||
* @param integer $cgid
|
||||
* @return void
|
||||
*/
|
||||
public function setChannelGroup($cid, $cgid)
|
||||
{
|
||||
$this->getParent()->clientSetChannelGroup($this["client_database_id"], $cid, $cgid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the client to the server group specified with $sgid.
|
||||
*
|
||||
* @param integer $sgid
|
||||
* @return void
|
||||
*/
|
||||
public function addServerGroup($sgid)
|
||||
{
|
||||
$this->getParent()->serverGroupClientAdd($sgid, $this["client_database_id"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the client from the server group specified with $sgid.
|
||||
*
|
||||
* @param integer $sgid
|
||||
* @return void
|
||||
*/
|
||||
public function remServerGroup($sgid)
|
||||
{
|
||||
$this->getParent()->serverGroupClientDel($sgid, $this["client_database_id"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the possible name of the clients avatar.
|
||||
*
|
||||
* @return TeamSpeak3_Helper_String
|
||||
*/
|
||||
public function avatarGetName()
|
||||
{
|
||||
return new TeamSpeak3_Helper_String("/avatar_" . $this["client_base64HashClientUID"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Downloads and returns the clients avatar file content.
|
||||
*
|
||||
* @return TeamSpeak3_Helper_String
|
||||
*/
|
||||
public function avatarDownload()
|
||||
{
|
||||
if($this["client_flag_avatar"]->toString() == NULL) return;
|
||||
|
||||
$download = $this->getParent()->transferInitDownload(rand(0x0000, 0xFFFF), 0, $this->avatarGetName());
|
||||
$transfer = TeamSpeak3::factory("filetransfer://" . (strstr($download["host"], ":") !== FALSE ? "[" . $download["host"] . "]" : $download["host"]) . ":" . $download["port"]);
|
||||
|
||||
return $transfer->download($download["ftkey"], $download["size"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of client connections using the same identity as this client.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getClones()
|
||||
{
|
||||
return $this->execute("clientgetids", array("cluid" => $this["client_unique_identifier"]))->toAssocArray("clid");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns TRUE if the client is using Overwolf.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasOverwolf()
|
||||
{
|
||||
return strstr($this["client_badges"], "overwolf=1") !== FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of equipped badges for this client.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getBadges()
|
||||
{
|
||||
$badges = array();
|
||||
|
||||
foreach(explode(":", $this["client_badges"]) as $set)
|
||||
{
|
||||
if(substr($set, 0, 7) == "badges=")
|
||||
{
|
||||
$badges[] = array_map("trim", explode(",", substr($set, 7)));
|
||||
}
|
||||
}
|
||||
|
||||
return $badges;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the revision/build number from the clients version string.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getRev()
|
||||
{
|
||||
return $this["client_type"] ? null : $this["client_version"]->section("[", 1)->filterDigits();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all server and channel groups the client is currently residing in.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function memberOf()
|
||||
{
|
||||
$cgroups = array($this->getParent()->channelGroupGetById($this["client_channel_group_id"]));
|
||||
$sgroups = array();
|
||||
|
||||
foreach(explode(",", $this["client_servergroups"]) as $sgid)
|
||||
{
|
||||
$sgroups[] = $this->getParent()->serverGroupGetById($sgid);
|
||||
}
|
||||
|
||||
uasort($sgroups, array(__CLASS__, "sortGroupList"));
|
||||
|
||||
return array_merge($cgroups, $sgroups);
|
||||
}
|
||||
|
||||
/**
|
||||
* Downloads and returns the clients icon file content.
|
||||
*
|
||||
* @return TeamSpeak3_Helper_String
|
||||
*/
|
||||
public function iconDownload()
|
||||
{
|
||||
if($this->iconIsLocal("client_icon_id") || $this["client_icon_id"] == 0) return;
|
||||
|
||||
$download = $this->getParent()->transferInitDownload(rand(0x0000, 0xFFFF), 0, $this->iconGetName("client_icon_id"));
|
||||
$transfer = TeamSpeak3::factory("filetransfer://" . (strstr($download["host"], ":") !== FALSE ? "[" . $download["host"] . "]" : $download["host"]) . ":" . $download["port"]);
|
||||
|
||||
return $transfer->download($download["ftkey"], $download["size"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a plugin command to the client.
|
||||
*
|
||||
* @param string $plugin
|
||||
* @param string $data
|
||||
* @return void
|
||||
*/
|
||||
public function sendPluginCmd($plugin, $data)
|
||||
{
|
||||
$this->execute("plugincmd", array("name" => $plugin, "data" => $data, "targetmode" => TeamSpeak3::PLUGINCMD_CLIENT, "target" => $this->getId()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
protected function fetchNodeInfo()
|
||||
{
|
||||
if($this->offsetExists("client_type") && $this["client_type"] == 1) return;
|
||||
|
||||
$this->nodeInfo = array_merge($this->nodeInfo, $this->execute("clientinfo", array("clid" => $this->getId()))->toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a unique identifier for the node which can be used as a HTML property.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUniqueId()
|
||||
{
|
||||
return $this->getParent()->getUniqueId() . "_cl" . $this->getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of a possible icon to display the node object.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getIcon()
|
||||
{
|
||||
if($this["client_type"])
|
||||
{
|
||||
return "client_query";
|
||||
}
|
||||
elseif($this["client_away"])
|
||||
{
|
||||
return "client_away";
|
||||
}
|
||||
elseif(!$this["client_output_hardware"])
|
||||
{
|
||||
return "client_snd_disabled";
|
||||
}
|
||||
elseif($this["client_output_muted"])
|
||||
{
|
||||
return "client_snd_muted";
|
||||
}
|
||||
elseif(!$this["client_input_hardware"])
|
||||
{
|
||||
return "client_mic_disabled";
|
||||
}
|
||||
elseif($this["client_input_muted"])
|
||||
{
|
||||
return "client_mic_muted";
|
||||
}
|
||||
elseif($this["client_is_channel_commander"])
|
||||
{
|
||||
return $this["client_flag_talking"] ? "client_cc_talk" : "client_cc_idle";
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this["client_flag_talking"] ? "client_talk" : "client_idle";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a symbol representing the node.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSymbol()
|
||||
{
|
||||
return "@";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this node.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return (string) $this["client_nickname"];
|
||||
}
|
||||
}
|
||||
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Node_Client
|
||||
* @brief Class describing a TeamSpeak 3 client and all it's parameters.
|
||||
*/
|
||||
class TeamSpeak3_Node_Client extends TeamSpeak3_Node_Abstract
|
||||
{
|
||||
/**
|
||||
* The TeamSpeak3_Node_Client constructor.
|
||||
*
|
||||
* @param TeamSpeak3_Node_Server $server
|
||||
* @param array $info
|
||||
* @param string $index
|
||||
* @throws TeamSpeak3_Adapter_ServerQuery_Exception
|
||||
* @return TeamSpeak3_Node_Client
|
||||
*/
|
||||
public function __construct(TeamSpeak3_Node_Server $server, array $info, $index = "clid")
|
||||
{
|
||||
$this->parent = $server;
|
||||
$this->nodeInfo = $info;
|
||||
|
||||
if(!array_key_exists($index, $this->nodeInfo))
|
||||
{
|
||||
throw new TeamSpeak3_Adapter_ServerQuery_Exception("invalid clientID", 0x200);
|
||||
}
|
||||
|
||||
$this->nodeId = $this->nodeInfo[$index];
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the clients properties using given properties.
|
||||
*
|
||||
* @param array $properties
|
||||
* @return void
|
||||
*/
|
||||
public function modify(array $properties)
|
||||
{
|
||||
$properties["clid"] = $this->getId();
|
||||
|
||||
$this->execute("clientedit", $properties);
|
||||
$this->resetNodeInfo();
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the clients properties using given properties.
|
||||
*
|
||||
* @param array $properties
|
||||
* @return void
|
||||
*/
|
||||
public function modifyDb(array $properties)
|
||||
{
|
||||
$this->getParent()->clientModifyDb($this["client_database_id"], $properties);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the clients properties from the database.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function deleteDb()
|
||||
{
|
||||
$this->getParent()->clientDeleteDb($this["client_database_id"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of properties from the database for the client.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function infoDb()
|
||||
{
|
||||
return $this->getParent()->clientInfoDb($this["client_database_id"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a text message to the client.
|
||||
*
|
||||
* @param string $msg
|
||||
* @return void
|
||||
*/
|
||||
public function message($msg)
|
||||
{
|
||||
$this->execute("sendtextmessage", array("msg" => $msg, "target" => $this->getId(), "targetmode" => TeamSpeak3::TEXTMSG_CLIENT));
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the client to another channel.
|
||||
*
|
||||
* @param integer $cid
|
||||
* @param string $cpw
|
||||
* @return void
|
||||
*/
|
||||
public function move($cid, $cpw = null)
|
||||
{
|
||||
$this->getParent()->clientMove($this->getId(), $cid, $cpw);
|
||||
}
|
||||
|
||||
/**
|
||||
* Kicks the client from his currently joined channel or from the server.
|
||||
*
|
||||
* @param integer $reasonid
|
||||
* @param string $reasonmsg
|
||||
* @return void
|
||||
*/
|
||||
public function kick($reasonid = TeamSpeak3::KICK_CHANNEL, $reasonmsg = null)
|
||||
{
|
||||
$this->getParent()->clientKick($this->getId(), $reasonid, $reasonmsg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a poke message to the client.
|
||||
*
|
||||
* @param string $msg
|
||||
* @return void
|
||||
*/
|
||||
public function poke($msg)
|
||||
{
|
||||
$this->getParent()->clientPoke($this->getId(), $msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Bans the client from the server. Please note that this will create two separate
|
||||
* ban rules for the targeted clients IP address and his unique identifier.
|
||||
*
|
||||
* @param integer $timeseconds
|
||||
* @param string $reason
|
||||
* @return array
|
||||
*/
|
||||
public function ban($timeseconds = null, $reason = null)
|
||||
{
|
||||
return $this->getParent()->clientBan($this->getId(), $timeseconds, $reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of custom properties for the client.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function customInfo()
|
||||
{
|
||||
return $this->getParent()->customInfo($this["client_database_id"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates or updates a custom property for the client.
|
||||
*
|
||||
* @param string $ident
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function customSet($ident, $value)
|
||||
{
|
||||
$this->getParent()->customSet($this["client_database_id"], $ident, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a custom property from the client.
|
||||
*
|
||||
* @param string $ident
|
||||
* @return void
|
||||
*/
|
||||
public function customDelete($ident)
|
||||
{
|
||||
$this->getParent()->customDelete($this["client_database_id"], $ident);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing the permission overview of the client.
|
||||
*
|
||||
* @param integer $cid
|
||||
* @return array
|
||||
*/
|
||||
public function permOverview($cid)
|
||||
{
|
||||
return $this->execute("permoverview", array("cldbid" => $this["client_database_id"], "cid" => $cid, "permid" => 0))->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of permissions defined for the client.
|
||||
*
|
||||
* @param boolean $permsid
|
||||
* @return array
|
||||
*/
|
||||
public function permList($permsid = FALSE)
|
||||
{
|
||||
return $this->getParent()->clientPermList($this["client_database_id"], $permsid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a set of specified permissions to the client. Multiple permissions can be added by providing
|
||||
* the three parameters of each permission.
|
||||
*
|
||||
* @param integer $permid
|
||||
* @param integer $permvalue
|
||||
* @param integer $permskip
|
||||
* @return void
|
||||
*/
|
||||
public function permAssign($permid, $permvalue, $permskip = FALSE)
|
||||
{
|
||||
$this->getParent()->clientPermAssign($this["client_database_id"], $permid, $permvalue, $permskip);
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for permAssign().
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function permAssignByName($permname, $permvalue, $permskip = FALSE)
|
||||
{
|
||||
$this->permAssign($permname, $permvalue, $permskip);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a set of specified permissions from a client. Multiple permissions can be removed at once.
|
||||
*
|
||||
* @param integer $permid
|
||||
* @return void
|
||||
*/
|
||||
public function permRemove($permid)
|
||||
{
|
||||
$this->getParent()->clientPermRemove($this["client_database_id"], $permid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for permRemove().
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function permRemoveByName($permname)
|
||||
{
|
||||
$this->permRemove($permname);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the channel group of a client to the ID specified.
|
||||
*
|
||||
* @param integer $cid
|
||||
* @param integer $cgid
|
||||
* @return void
|
||||
*/
|
||||
public function setChannelGroup($cid, $cgid)
|
||||
{
|
||||
$this->getParent()->clientSetChannelGroup($this["client_database_id"], $cid, $cgid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the client to the server group specified with $sgid.
|
||||
*
|
||||
* @param integer $sgid
|
||||
* @return void
|
||||
*/
|
||||
public function addServerGroup($sgid)
|
||||
{
|
||||
$this->getParent()->serverGroupClientAdd($sgid, $this["client_database_id"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the client from the server group specified with $sgid.
|
||||
*
|
||||
* @param integer $sgid
|
||||
* @return void
|
||||
*/
|
||||
public function remServerGroup($sgid)
|
||||
{
|
||||
$this->getParent()->serverGroupClientDel($sgid, $this["client_database_id"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the possible name of the clients avatar.
|
||||
*
|
||||
* @return TeamSpeak3_Helper_String
|
||||
*/
|
||||
public function avatarGetName()
|
||||
{
|
||||
return new TeamSpeak3_Helper_String("/avatar_" . $this["client_base64HashClientUID"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Downloads and returns the clients avatar file content.
|
||||
*
|
||||
* @return TeamSpeak3_Helper_String
|
||||
*/
|
||||
public function avatarDownload()
|
||||
{
|
||||
if($this["client_flag_avatar"] == NULL) return;
|
||||
|
||||
$download = $this->getParent()->transferInitDownload(rand(0x0000, 0xFFFF), 0, $this->avatarGetName());
|
||||
$transfer = TeamSpeak3::factory("filetransfer://" . (strstr($download["host"], ":") !== FALSE ? "[" . $download["host"] . "]" : $download["host"]) . ":" . $download["port"]);
|
||||
|
||||
return $transfer->download($download["ftkey"], $download["size"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of client connections using the same identity as this client.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getClones()
|
||||
{
|
||||
return $this->execute("clientgetids", array("cluid" => $this["client_unique_identifier"]))->toAssocArray("clid");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns TRUE if the client is using Overwolf.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasOverwolf()
|
||||
{
|
||||
return strstr($this["client_badges"], "overwolf=1") !== FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of equipped badges for this client.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getBadges()
|
||||
{
|
||||
$badges = array();
|
||||
|
||||
foreach(explode(":", $this["client_badges"]) as $set)
|
||||
{
|
||||
if(substr($set, 0, 7) == "badges=")
|
||||
{
|
||||
$badges[] = array_map("trim", explode(",", substr($set, 7)));
|
||||
}
|
||||
}
|
||||
|
||||
return $badges;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the revision/build number from the clients version string.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getRev()
|
||||
{
|
||||
return $this["client_type"] ? null : $this["client_version"]->section("[", 1)->filterDigits();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all server and channel groups the client is currently residing in.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function memberOf()
|
||||
{
|
||||
$cgroups = array($this->getParent()->channelGroupGetById($this["client_channel_group_id"]));
|
||||
$sgroups = array();
|
||||
|
||||
foreach(explode(",", $this["client_servergroups"]) as $sgid)
|
||||
{
|
||||
$sgroups[] = $this->getParent()->serverGroupGetById($sgid);
|
||||
}
|
||||
|
||||
uasort($sgroups, array(__CLASS__, "sortGroupList"));
|
||||
|
||||
return array_merge($cgroups, $sgroups);
|
||||
}
|
||||
|
||||
/**
|
||||
* Downloads and returns the clients icon file content.
|
||||
*
|
||||
* @return TeamSpeak3_Helper_String
|
||||
*/
|
||||
public function iconDownload()
|
||||
{
|
||||
if($this->iconIsLocal("client_icon_id") || $this["client_icon_id"] == 0) return;
|
||||
|
||||
$download = $this->getParent()->transferInitDownload(rand(0x0000, 0xFFFF), 0, $this->iconGetName("client_icon_id"));
|
||||
$transfer = TeamSpeak3::factory("filetransfer://" . (strstr($download["host"], ":") !== FALSE ? "[" . $download["host"] . "]" : $download["host"]) . ":" . $download["port"]);
|
||||
|
||||
return $transfer->download($download["ftkey"], $download["size"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a plugin command to the client.
|
||||
*
|
||||
* @param string $plugin
|
||||
* @param string $data
|
||||
* @return void
|
||||
*/
|
||||
public function sendPluginCmd($plugin, $data)
|
||||
{
|
||||
$this->execute("plugincmd", array("name" => $plugin, "data" => $data, "targetmode" => TeamSpeak3::PLUGINCMD_CLIENT, "target" => $this->getId()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
protected function fetchNodeInfo()
|
||||
{
|
||||
if($this->offsetExists("client_type") && $this["client_type"] == 1) return;
|
||||
|
||||
$this->nodeInfo = array_merge($this->nodeInfo, $this->execute("clientinfo", array("clid" => $this->getId()))->toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a unique identifier for the node which can be used as a HTML property.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUniqueId()
|
||||
{
|
||||
return $this->getParent()->getUniqueId() . "_cl" . $this->getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of a possible icon to display the node object.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getIcon()
|
||||
{
|
||||
if($this["client_type"])
|
||||
{
|
||||
return "client_query";
|
||||
}
|
||||
elseif($this["client_away"])
|
||||
{
|
||||
return "client_away";
|
||||
}
|
||||
elseif(!$this["client_output_hardware"])
|
||||
{
|
||||
return "client_snd_disabled";
|
||||
}
|
||||
elseif($this["client_output_muted"])
|
||||
{
|
||||
return "client_snd_muted";
|
||||
}
|
||||
elseif(!$this["client_input_hardware"])
|
||||
{
|
||||
return "client_mic_disabled";
|
||||
}
|
||||
elseif($this["client_input_muted"])
|
||||
{
|
||||
return "client_mic_muted";
|
||||
}
|
||||
elseif($this["client_is_channel_commander"])
|
||||
{
|
||||
return $this["client_flag_talking"] ? "client_cc_talk" : "client_cc_idle";
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this["client_flag_talking"] ? "client_talk" : "client_idle";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a symbol representing the node.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSymbol()
|
||||
{
|
||||
return "@";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this node.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return (string) $this["client_nickname"];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Node_Exception
|
||||
* @brief Enhanced exception class for TeamSpeak3_Node_Abstract objects.
|
||||
*/
|
||||
class TeamSpeak3_Node_Exception extends TeamSpeak3_Exception {}
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Node_Exception
|
||||
* @brief Enhanced exception class for TeamSpeak3_Node_Abstract objects.
|
||||
*/
|
||||
class TeamSpeak3_Node_Exception extends TeamSpeak3_Exception {}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,295 +1,295 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Node_Servergroup
|
||||
* @brief Class describing a TeamSpeak 3 server group and all it's parameters.
|
||||
*/
|
||||
class TeamSpeak3_Node_Servergroup extends TeamSpeak3_Node_Abstract
|
||||
{
|
||||
/**
|
||||
* The TeamSpeak3_Node_Servergroup constructor.
|
||||
*
|
||||
* @param TeamSpeak3_Node_Server $server
|
||||
* @param array $info
|
||||
* @param string $index
|
||||
* @throws TeamSpeak3_Node_Exception
|
||||
* @return TeamSpeak3_Node_Servergroup
|
||||
*/
|
||||
public function __construct(TeamSpeak3_Node_Server $server, array $info, $index = "sgid")
|
||||
{
|
||||
$this->parent = $server;
|
||||
$this->nodeInfo = $info;
|
||||
|
||||
if(!array_key_exists($index, $this->nodeInfo))
|
||||
{
|
||||
throw new TeamSpeak3_Node_Exception("invalid groupID", 0xA00);
|
||||
}
|
||||
|
||||
$this->nodeId = $this->nodeInfo[$index];
|
||||
}
|
||||
|
||||
/**
|
||||
* Renames the server group specified.
|
||||
*
|
||||
* @param string $name
|
||||
* @return void
|
||||
*/
|
||||
public function rename($name)
|
||||
{
|
||||
$this->getParent()->serverGroupRename($this->getId(), $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the server group. If $force is set to 1, the server group will be
|
||||
* deleted even if there are clients within.
|
||||
*
|
||||
* @param boolean $force
|
||||
* @return void
|
||||
*/
|
||||
public function delete($force = FALSE)
|
||||
{
|
||||
$this->getParent()->serverGroupDelete($this->getId(), $force);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a copy of the server group and returns the new groups ID.
|
||||
*
|
||||
* @param string $name
|
||||
* @param integer $tsgid
|
||||
* @param integer $type
|
||||
* @return integer
|
||||
*/
|
||||
public function copy($name = null, $tsgid = 0, $type = TeamSpeak3::GROUP_DBTYPE_REGULAR)
|
||||
{
|
||||
return $this->getParent()->serverGroupCopy($this->getId(), $name, $tsgid, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of permissions assigned to the server group.
|
||||
*
|
||||
* @param boolean $permsid
|
||||
* @return array
|
||||
*/
|
||||
public function permList($permsid = FALSE)
|
||||
{
|
||||
return $this->getParent()->serverGroupPermList($this->getId(), $permsid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a set of specified permissions to the server group. Multiple permissions
|
||||
* can be added by providing the four parameters of each permission in separate arrays.
|
||||
*
|
||||
* @param integer $permid
|
||||
* @param integer $permvalue
|
||||
* @param integer $permnegated
|
||||
* @param integer $permskip
|
||||
* @return void
|
||||
*/
|
||||
public function permAssign($permid, $permvalue, $permnegated = FALSE, $permskip = FALSE)
|
||||
{
|
||||
$this->getParent()->serverGroupPermAssign($this->getId(), $permid, $permvalue, $permnegated, $permskip);
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for permAssign().
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function permAssignByName($permname, $permvalue, $permnegated = FALSE, $permskip = FALSE)
|
||||
{
|
||||
$this->permAssign($permname, $permvalue, $permnegated, $permskip);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a set of specified permissions from the server group. Multiple
|
||||
* permissions can be removed at once.
|
||||
*
|
||||
* @param integer $permid
|
||||
* @return void
|
||||
*/
|
||||
public function permRemove($permid)
|
||||
{
|
||||
$this->getParent()->serverGroupPermRemove($this->getId(), $permid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for permRemove().
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function permRemoveByName($permname)
|
||||
{
|
||||
$this->permRemove($permname);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of clients assigned to the server group specified.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function clientList()
|
||||
{
|
||||
return $this->getParent()->serverGroupClientList($this->getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a client to the server group specified. Please note that a client cannot be
|
||||
* added to default groups or template groups.
|
||||
*
|
||||
* @param integer $cldbid
|
||||
* @return void
|
||||
*/
|
||||
public function clientAdd($cldbid)
|
||||
{
|
||||
$this->getParent()->serverGroupClientAdd($this->getId(), $cldbid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a client from the server group.
|
||||
*
|
||||
* @param integer $cldbid
|
||||
* @return void
|
||||
*/
|
||||
public function clientDel($cldbid)
|
||||
{
|
||||
$this->getParent()->serverGroupClientDel($this->getId(), $cldbid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for privilegeKeyCreate().
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function tokenCreate($description = null, $customset = null)
|
||||
{
|
||||
return $this->privilegeKeyCreate($description, $customset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new privilege key (token) for the server group and returns the key.
|
||||
*
|
||||
* @param string $description
|
||||
* @param string $customset
|
||||
* @return TeamSpeak3_Helper_String
|
||||
*/
|
||||
public function privilegeKeyCreate($description = null, $customset = null)
|
||||
{
|
||||
return $this->getParent()->privilegeKeyCreate(TeamSpeak3::TOKEN_SERVERGROUP, $this->getId(), 0, $description, $customset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a text message to all clients residing in the server group on the virtual server.
|
||||
*
|
||||
* @param string $msg
|
||||
* @return void
|
||||
*/
|
||||
public function message($msg)
|
||||
{
|
||||
foreach($this as $client)
|
||||
{
|
||||
try
|
||||
{
|
||||
$this->execute("sendtextmessage", array("msg" => $msg, "target" => $client, "targetmode" => TeamSpeak3::TEXTMSG_CLIENT));
|
||||
}
|
||||
catch(TeamSpeak3_Adapter_ServerQuery_Exception $e)
|
||||
{
|
||||
/* ERROR_client_invalid_id */
|
||||
if($e->getCode() != 0x0200) throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Downloads and returns the server groups icon file content.
|
||||
*
|
||||
* @return TeamSpeak3_Helper_String
|
||||
*/
|
||||
public function iconDownload()
|
||||
{
|
||||
if($this->iconIsLocal("iconid") || $this["iconid"] == 0) return;
|
||||
|
||||
$download = $this->getParent()->transferInitDownload(rand(0x0000, 0xFFFF), 0, $this->iconGetName("iconid"));
|
||||
$transfer = TeamSpeak3::factory("filetransfer://" . (strstr($download["host"], ":") !== FALSE ? "[" . $download["host"] . "]" : $download["host"]) . ":" . $download["port"]);
|
||||
|
||||
return $transfer->download($download["ftkey"], $download["size"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
protected function fetchNodeList()
|
||||
{
|
||||
$this->nodeList = array();
|
||||
|
||||
foreach($this->getParent()->clientList() as $client)
|
||||
{
|
||||
if(in_array($this->getId(), explode(",", $client["client_servergroups"])))
|
||||
{
|
||||
$this->nodeList[] = $client;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a unique identifier for the node which can be used as a HTML property.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUniqueId()
|
||||
{
|
||||
return $this->getParent()->getUniqueId() . "_sg" . $this->getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of a possible icon to display the node object.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getIcon()
|
||||
{
|
||||
return "group_server";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a symbol representing the node.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSymbol()
|
||||
{
|
||||
return "%";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this node.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return (string) $this["name"];
|
||||
}
|
||||
}
|
||||
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Node_Servergroup
|
||||
* @brief Class describing a TeamSpeak 3 server group and all it's parameters.
|
||||
*/
|
||||
class TeamSpeak3_Node_Servergroup extends TeamSpeak3_Node_Abstract
|
||||
{
|
||||
/**
|
||||
* The TeamSpeak3_Node_Servergroup constructor.
|
||||
*
|
||||
* @param TeamSpeak3_Node_Server $server
|
||||
* @param array $info
|
||||
* @param string $index
|
||||
* @throws TeamSpeak3_Node_Exception
|
||||
* @return TeamSpeak3_Node_Servergroup
|
||||
*/
|
||||
public function __construct(TeamSpeak3_Node_Server $server, array $info, $index = "sgid")
|
||||
{
|
||||
$this->parent = $server;
|
||||
$this->nodeInfo = $info;
|
||||
|
||||
if(!array_key_exists($index, $this->nodeInfo))
|
||||
{
|
||||
throw new TeamSpeak3_Node_Exception("invalid groupID", 0xA00);
|
||||
}
|
||||
|
||||
$this->nodeId = $this->nodeInfo[$index];
|
||||
}
|
||||
|
||||
/**
|
||||
* Renames the server group specified.
|
||||
*
|
||||
* @param string $name
|
||||
* @return void
|
||||
*/
|
||||
public function rename($name)
|
||||
{
|
||||
$this->getParent()->serverGroupRename($this->getId(), $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the server group. If $force is set to 1, the server group will be
|
||||
* deleted even if there are clients within.
|
||||
*
|
||||
* @param boolean $force
|
||||
* @return void
|
||||
*/
|
||||
public function delete($force = FALSE)
|
||||
{
|
||||
$this->getParent()->serverGroupDelete($this->getId(), $force);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a copy of the server group and returns the new groups ID.
|
||||
*
|
||||
* @param string $name
|
||||
* @param integer $tsgid
|
||||
* @param integer $type
|
||||
* @return integer
|
||||
*/
|
||||
public function copy($name = null, $tsgid = 0, $type = TeamSpeak3::GROUP_DBTYPE_REGULAR)
|
||||
{
|
||||
return $this->getParent()->serverGroupCopy($this->getId(), $name, $tsgid, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of permissions assigned to the server group.
|
||||
*
|
||||
* @param boolean $permsid
|
||||
* @return array
|
||||
*/
|
||||
public function permList($permsid = FALSE)
|
||||
{
|
||||
return $this->getParent()->serverGroupPermList($this->getId(), $permsid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a set of specified permissions to the server group. Multiple permissions
|
||||
* can be added by providing the four parameters of each permission in separate arrays.
|
||||
*
|
||||
* @param integer $permid
|
||||
* @param integer $permvalue
|
||||
* @param integer $permnegated
|
||||
* @param integer $permskip
|
||||
* @return void
|
||||
*/
|
||||
public function permAssign($permid, $permvalue, $permnegated = FALSE, $permskip = FALSE)
|
||||
{
|
||||
$this->getParent()->serverGroupPermAssign($this->getId(), $permid, $permvalue, $permnegated, $permskip);
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for permAssign().
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function permAssignByName($permname, $permvalue, $permnegated = FALSE, $permskip = FALSE)
|
||||
{
|
||||
$this->permAssign($permname, $permvalue, $permnegated, $permskip);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a set of specified permissions from the server group. Multiple
|
||||
* permissions can be removed at once.
|
||||
*
|
||||
* @param integer $permid
|
||||
* @return void
|
||||
*/
|
||||
public function permRemove($permid)
|
||||
{
|
||||
$this->getParent()->serverGroupPermRemove($this->getId(), $permid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for permRemove().
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function permRemoveByName($permname)
|
||||
{
|
||||
$this->permRemove($permname);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of clients assigned to the server group specified.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function clientList()
|
||||
{
|
||||
return $this->getParent()->serverGroupClientList($this->getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a client to the server group specified. Please note that a client cannot be
|
||||
* added to default groups or template groups.
|
||||
*
|
||||
* @param integer $cldbid
|
||||
* @return void
|
||||
*/
|
||||
public function clientAdd($cldbid)
|
||||
{
|
||||
$this->getParent()->serverGroupClientAdd($this->getId(), $cldbid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a client from the server group.
|
||||
*
|
||||
* @param integer $cldbid
|
||||
* @return void
|
||||
*/
|
||||
public function clientDel($cldbid)
|
||||
{
|
||||
$this->getParent()->serverGroupClientDel($this->getId(), $cldbid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for privilegeKeyCreate().
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function tokenCreate($description = null, $customset = null)
|
||||
{
|
||||
return $this->privilegeKeyCreate($description, $customset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new privilege key (token) for the server group and returns the key.
|
||||
*
|
||||
* @param string $description
|
||||
* @param string $customset
|
||||
* @return TeamSpeak3_Helper_String
|
||||
*/
|
||||
public function privilegeKeyCreate($description = null, $customset = null)
|
||||
{
|
||||
return $this->getParent()->privilegeKeyCreate(TeamSpeak3::TOKEN_SERVERGROUP, $this->getId(), 0, $description, $customset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a text message to all clients residing in the server group on the virtual server.
|
||||
*
|
||||
* @param string $msg
|
||||
* @return void
|
||||
*/
|
||||
public function message($msg)
|
||||
{
|
||||
foreach($this as $client)
|
||||
{
|
||||
try
|
||||
{
|
||||
$this->execute("sendtextmessage", array("msg" => $msg, "target" => $client, "targetmode" => TeamSpeak3::TEXTMSG_CLIENT));
|
||||
}
|
||||
catch(TeamSpeak3_Adapter_ServerQuery_Exception $e)
|
||||
{
|
||||
/* ERROR_client_invalid_id */
|
||||
if($e->getCode() != 0x0200) throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Downloads and returns the server groups icon file content.
|
||||
*
|
||||
* @return TeamSpeak3_Helper_String
|
||||
*/
|
||||
public function iconDownload()
|
||||
{
|
||||
if($this->iconIsLocal("iconid") || $this["iconid"] == 0) return;
|
||||
|
||||
$download = $this->getParent()->transferInitDownload(rand(0x0000, 0xFFFF), 0, $this->iconGetName("iconid"));
|
||||
$transfer = TeamSpeak3::factory("filetransfer://" . (strstr($download["host"], ":") !== FALSE ? "[" . $download["host"] . "]" : $download["host"]) . ":" . $download["port"]);
|
||||
|
||||
return $transfer->download($download["ftkey"], $download["size"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
protected function fetchNodeList()
|
||||
{
|
||||
$this->nodeList = array();
|
||||
|
||||
foreach($this->getParent()->clientList() as $client)
|
||||
{
|
||||
if(in_array($this->getId(), explode(",", $client["client_servergroups"])))
|
||||
{
|
||||
$this->nodeList[] = $client;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a unique identifier for the node which can be used as a HTML property.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUniqueId()
|
||||
{
|
||||
return $this->getParent()->getUniqueId() . "_sg" . $this->getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of a possible icon to display the node object.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getIcon()
|
||||
{
|
||||
return "group_server";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a symbol representing the node.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSymbol()
|
||||
{
|
||||
return "%";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this node.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return (string) $this["name"];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,267 +1,274 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Transport_Abstract
|
||||
* @brief Abstract class for connecting to a TeamSpeak 3 Server through different ways of transport.
|
||||
*/
|
||||
abstract class TeamSpeak3_Transport_Abstract
|
||||
{
|
||||
/**
|
||||
* Stores user-provided configuration settings.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $config = null;
|
||||
|
||||
/**
|
||||
* Stores the stream resource of the connection.
|
||||
*
|
||||
* @var resource
|
||||
*/
|
||||
protected $stream = null;
|
||||
|
||||
/**
|
||||
* Stores the TeamSpeak3_Adapter_Abstract object using this transport.
|
||||
*
|
||||
* @var TeamSpeak3_Adapter_Abstract
|
||||
*/
|
||||
protected $adapter = null;
|
||||
|
||||
/**
|
||||
* The TeamSpeak3_Transport_Abstract constructor.
|
||||
*
|
||||
* @param array $config
|
||||
* @throws TeamSpeak3_Transport_Exception
|
||||
* @return TeamSpeak3_Transport_Abstract
|
||||
*/
|
||||
public function __construct(array $config)
|
||||
{
|
||||
if(!array_key_exists("host", $config))
|
||||
{
|
||||
throw new TeamSpeak3_Transport_Exception("config must have a key for 'host' which specifies the server host name");
|
||||
}
|
||||
|
||||
if(!array_key_exists("port", $config))
|
||||
{
|
||||
throw new TeamSpeak3_Transport_Exception("config must have a key for 'port' which specifies the server port number");
|
||||
}
|
||||
|
||||
if(!array_key_exists("timeout", $config))
|
||||
{
|
||||
$config["timeout"] = 10;
|
||||
}
|
||||
|
||||
if(!array_key_exists("blocking", $config))
|
||||
{
|
||||
$config["blocking"] = 1;
|
||||
}
|
||||
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Commit pending data.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function __sleep()
|
||||
{
|
||||
return array("config");
|
||||
}
|
||||
|
||||
/**
|
||||
* Reconnects to the remote server.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __wakeup()
|
||||
{
|
||||
$this->connect();
|
||||
}
|
||||
|
||||
/**
|
||||
* The TeamSpeak3_Transport_Abstract destructor.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
if($this->adapter instanceof TeamSpeak3_Adapter_Abstract)
|
||||
{
|
||||
$this->adapter->__destruct();
|
||||
}
|
||||
|
||||
$this->disconnect();
|
||||
}
|
||||
|
||||
/**
|
||||
* Connects to a remote server.
|
||||
*
|
||||
* @throws TeamSpeak3_Transport_Exception
|
||||
* @return void
|
||||
*/
|
||||
abstract public function connect();
|
||||
|
||||
/**
|
||||
* Disconnects from a remote server.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
abstract public function disconnect();
|
||||
|
||||
/**
|
||||
* Reads data from the stream.
|
||||
*
|
||||
* @param integer $length
|
||||
* @throws TeamSpeak3_Transport_Exception
|
||||
* @return TeamSpeak3_Helper_String
|
||||
*/
|
||||
abstract public function read($length = 4096);
|
||||
|
||||
/**
|
||||
* Writes data to the stream.
|
||||
*
|
||||
* @param string $data
|
||||
* @return void
|
||||
*/
|
||||
abstract public function send($data);
|
||||
|
||||
/**
|
||||
* Returns the underlying stream resource.
|
||||
*
|
||||
* @return resource
|
||||
*/
|
||||
public function getStream()
|
||||
{
|
||||
return $this->stream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the configuration variables in this adapter.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $default
|
||||
* @return array
|
||||
*/
|
||||
public function getConfig($key = null, $default = null)
|
||||
{
|
||||
if($key !== null)
|
||||
{
|
||||
return array_key_exists($key, $this->config) ? $this->config[$key] : $default;
|
||||
}
|
||||
|
||||
return $this->config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the TeamSpeak3_Adapter_Abstract object using this transport.
|
||||
*
|
||||
* @param TeamSpeak3_Adapter_Abstract $adapter
|
||||
* @return void
|
||||
*/
|
||||
public function setAdapter(TeamSpeak3_Adapter_Abstract $adapter)
|
||||
{
|
||||
$this->adapter = $adapter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the TeamSpeak3_Adapter_Abstract object using this transport.
|
||||
*
|
||||
* @return TeamSpeak3_Adapter_Abstract
|
||||
*/
|
||||
public function getAdapter()
|
||||
{
|
||||
return $this->adapter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the adapter type.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAdapterType()
|
||||
{
|
||||
if($this->adapter instanceof TeamSpeak3_Adapter_Abstract)
|
||||
{
|
||||
$string = TeamSpeak3_Helper_String::factory(get_class($this->adapter));
|
||||
|
||||
return $string->substr($string->findLast("_"))->replace(array("_", " "), "")->toString();
|
||||
}
|
||||
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns header/meta data from stream pointer.
|
||||
*
|
||||
* @throws TeamSpeak3_Transport_Exception
|
||||
* @return array
|
||||
*/
|
||||
public function getMetaData()
|
||||
{
|
||||
if($this->stream === null)
|
||||
{
|
||||
throw new TeamSpeak3_Transport_Exception("unable to retrieve header/meta data from stream pointer");
|
||||
}
|
||||
|
||||
return stream_get_meta_data($this->stream);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns TRUE if the transport is connected.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isConnected()
|
||||
{
|
||||
return (is_resource($this->stream)) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Blocks a stream until data is available for reading if the stream is connected
|
||||
* in non-blocking mode.
|
||||
*
|
||||
* @param integer $time
|
||||
* @return void
|
||||
*/
|
||||
protected function waitForReadyRead($time = 0)
|
||||
{
|
||||
if(!$this->isConnected() || $this->config["blocking"]) return;
|
||||
|
||||
do
|
||||
{
|
||||
$read = array($this->stream);
|
||||
$null = null;
|
||||
|
||||
if($time)
|
||||
{
|
||||
TeamSpeak3_Helper_Signal::getInstance()->emit(strtolower($this->getAdapterType()) . "WaitTimeout", $time, $this->getAdapter());
|
||||
}
|
||||
|
||||
$time = $time+$this->config["timeout"];
|
||||
}
|
||||
while(@stream_select($read, $null, $null, $this->config["timeout"]) == 0);
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Transport_Abstract
|
||||
* @brief Abstract class for connecting to a TeamSpeak 3 Server through different ways of transport.
|
||||
*/
|
||||
abstract class TeamSpeak3_Transport_Abstract
|
||||
{
|
||||
/**
|
||||
* Stores user-provided configuration settings.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $config = null;
|
||||
|
||||
/**
|
||||
* Stores the stream resource of the connection.
|
||||
*
|
||||
* @var resource
|
||||
*/
|
||||
protected $stream = null;
|
||||
|
||||
/**
|
||||
* Stores an optional stream session for the connection.
|
||||
*
|
||||
* @var session
|
||||
*/
|
||||
protected $session = null;
|
||||
|
||||
/**
|
||||
* Stores the TeamSpeak3_Adapter_Abstract object using this transport.
|
||||
*
|
||||
* @var TeamSpeak3_Adapter_Abstract
|
||||
*/
|
||||
protected $adapter = null;
|
||||
|
||||
/**
|
||||
* The TeamSpeak3_Transport_Abstract constructor.
|
||||
*
|
||||
* @param array $config
|
||||
* @throws TeamSpeak3_Transport_Exception
|
||||
* @return TeamSpeak3_Transport_Abstract
|
||||
*/
|
||||
public function __construct(array $config)
|
||||
{
|
||||
if(!array_key_exists("host", $config))
|
||||
{
|
||||
throw new TeamSpeak3_Transport_Exception("config must have a key for 'host' which specifies the server host name");
|
||||
}
|
||||
|
||||
if(!array_key_exists("port", $config))
|
||||
{
|
||||
throw new TeamSpeak3_Transport_Exception("config must have a key for 'port' which specifies the server port number");
|
||||
}
|
||||
|
||||
if(!array_key_exists("timeout", $config))
|
||||
{
|
||||
$config["timeout"] = 10;
|
||||
}
|
||||
|
||||
if(!array_key_exists("blocking", $config))
|
||||
{
|
||||
$config["blocking"] = 1;
|
||||
}
|
||||
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Commit pending data.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function __sleep()
|
||||
{
|
||||
return array("config");
|
||||
}
|
||||
|
||||
/**
|
||||
* Reconnects to the remote server.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __wakeup()
|
||||
{
|
||||
$this->connect();
|
||||
}
|
||||
|
||||
/**
|
||||
* The TeamSpeak3_Transport_Abstract destructor.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
if($this->adapter instanceof TeamSpeak3_Adapter_Abstract)
|
||||
{
|
||||
$this->adapter->__destruct();
|
||||
}
|
||||
|
||||
$this->disconnect();
|
||||
}
|
||||
|
||||
/**
|
||||
* Connects to a remote server.
|
||||
*
|
||||
* @throws TeamSpeak3_Transport_Exception
|
||||
* @return void
|
||||
*/
|
||||
abstract public function connect();
|
||||
|
||||
/**
|
||||
* Disconnects from a remote server.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
abstract public function disconnect();
|
||||
|
||||
/**
|
||||
* Reads data from the stream.
|
||||
*
|
||||
* @param integer $length
|
||||
* @throws TeamSpeak3_Transport_Exception
|
||||
* @return TeamSpeak3_Helper_String
|
||||
*/
|
||||
abstract public function read($length = 4096);
|
||||
|
||||
/**
|
||||
* Writes data to the stream.
|
||||
*
|
||||
* @param string $data
|
||||
* @return void
|
||||
*/
|
||||
abstract public function send($data);
|
||||
|
||||
/**
|
||||
* Returns the underlying stream resource.
|
||||
*
|
||||
* @return resource
|
||||
*/
|
||||
public function getStream()
|
||||
{
|
||||
return $this->stream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the configuration variables in this adapter.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $default
|
||||
* @return array
|
||||
*/
|
||||
public function getConfig($key = null, $default = null)
|
||||
{
|
||||
if($key !== null)
|
||||
{
|
||||
return array_key_exists($key, $this->config) ? $this->config[$key] : $default;
|
||||
}
|
||||
|
||||
return $this->config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the TeamSpeak3_Adapter_Abstract object using this transport.
|
||||
*
|
||||
* @param TeamSpeak3_Adapter_Abstract $adapter
|
||||
* @return void
|
||||
*/
|
||||
public function setAdapter(TeamSpeak3_Adapter_Abstract $adapter)
|
||||
{
|
||||
$this->adapter = $adapter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the TeamSpeak3_Adapter_Abstract object using this transport.
|
||||
*
|
||||
* @return TeamSpeak3_Adapter_Abstract
|
||||
*/
|
||||
public function getAdapter()
|
||||
{
|
||||
return $this->adapter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the adapter type.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAdapterType()
|
||||
{
|
||||
if($this->adapter instanceof TeamSpeak3_Adapter_Abstract)
|
||||
{
|
||||
$string = TeamSpeak3_Helper_String::factory(get_class($this->adapter));
|
||||
|
||||
return $string->substr($string->findLast("_"))->replace(array("_", " "), "")->toString();
|
||||
}
|
||||
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns header/meta data from stream pointer.
|
||||
*
|
||||
* @throws TeamSpeak3_Transport_Exception
|
||||
* @return array
|
||||
*/
|
||||
public function getMetaData()
|
||||
{
|
||||
if($this->stream === null)
|
||||
{
|
||||
throw new TeamSpeak3_Transport_Exception("unable to retrieve header/meta data from stream pointer");
|
||||
}
|
||||
|
||||
return stream_get_meta_data($this->stream);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns TRUE if the transport is connected.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isConnected()
|
||||
{
|
||||
return (is_resource($this->stream)) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Blocks a stream until data is available for reading if the stream is connected
|
||||
* in non-blocking mode.
|
||||
*
|
||||
* @param integer $time
|
||||
* @return void
|
||||
*/
|
||||
protected function waitForReadyRead($time = 0)
|
||||
{
|
||||
if(!$this->isConnected() || $this->config["blocking"]) return;
|
||||
|
||||
do
|
||||
{
|
||||
$read = array($this->stream);
|
||||
$null = null;
|
||||
|
||||
if($time)
|
||||
{
|
||||
TeamSpeak3_Helper_Signal::getInstance()->emit(strtolower($this->getAdapterType()) . "WaitTimeout", $time, $this->getAdapter());
|
||||
}
|
||||
|
||||
$time = $time+$this->config["timeout"];
|
||||
}
|
||||
while(@stream_select($read, $null, $null, $this->config["timeout"]) == 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Transport_Exception
|
||||
* @brief Enhanced exception class for TeamSpeak3_Transport_Abstract objects.
|
||||
*/
|
||||
class TeamSpeak3_Transport_Exception extends TeamSpeak3_Exception {}
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Transport_Exception
|
||||
* @brief Enhanced exception class for TeamSpeak3_Transport_Abstract objects.
|
||||
*/
|
||||
class TeamSpeak3_Transport_Exception extends TeamSpeak3_Exception {}
|
||||
|
||||
@@ -1,182 +1,212 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Transport_TCP
|
||||
* @brief Class for connecting to a remote server through TCP.
|
||||
*/
|
||||
class TeamSpeak3_Transport_TCP extends TeamSpeak3_Transport_Abstract
|
||||
{
|
||||
/**
|
||||
* Connects to a remote server.
|
||||
*
|
||||
* @throws TeamSpeak3_Transport_Exception
|
||||
* @return void
|
||||
*/
|
||||
public function connect()
|
||||
{
|
||||
if($this->stream !== null) return;
|
||||
|
||||
$host = strval($this->config["host"]);
|
||||
$port = strval($this->config["port"]);
|
||||
|
||||
$address = "tcp://" . (strstr($host, ":") !== FALSE ? "[" . $host . "]" : $host) . ":" . $port;
|
||||
$options = empty($this->config["tls"]) ? array() : array("ssl" => array("allow_self_signed" => TRUE, "verify_peer" => FALSE, "verify_peer_name" => FALSE));
|
||||
$timeout = (int) $this->config["timeout"];
|
||||
|
||||
$this->stream = @stream_socket_client($address, $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, stream_context_create($options));
|
||||
|
||||
if($this->stream === FALSE)
|
||||
{
|
||||
throw new TeamSpeak3_Transport_Exception(TeamSpeak3_Helper_String::factory($errstr)->toUtf8()->toString(), $errno);
|
||||
}
|
||||
|
||||
if(!empty($this->config["tls"]))
|
||||
{
|
||||
stream_socket_enable_crypto($this->stream, TRUE, STREAM_CRYPTO_METHOD_SSLv23_CLIENT);
|
||||
}
|
||||
|
||||
@stream_set_timeout($this->stream, $timeout);
|
||||
@stream_set_blocking($this->stream, $this->config["blocking"] ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disconnects from a remote server.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function disconnect()
|
||||
{
|
||||
if($this->stream === null) return;
|
||||
|
||||
$this->stream = null;
|
||||
|
||||
TeamSpeak3_Helper_Signal::getInstance()->emit(strtolower($this->getAdapterType()) . "Disconnected");
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads data from the stream.
|
||||
*
|
||||
* @param integer $length
|
||||
* @throws TeamSpeak3_Transport_Exception
|
||||
* @return TeamSpeak3_Helper_String
|
||||
*/
|
||||
public function read($length = 4096)
|
||||
{
|
||||
$this->connect();
|
||||
$this->waitForReadyRead();
|
||||
|
||||
$data = @stream_get_contents($this->stream, $length);
|
||||
|
||||
TeamSpeak3_Helper_Signal::getInstance()->emit(strtolower($this->getAdapterType()) . "DataRead", $data);
|
||||
|
||||
if($data === FALSE)
|
||||
{
|
||||
throw new TeamSpeak3_Transport_Exception("connection to server '" . $this->config["host"] . ":" . $this->config["port"] . "' lost");
|
||||
}
|
||||
|
||||
return new TeamSpeak3_Helper_String($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a single line of data from the stream.
|
||||
*
|
||||
* @param string $token
|
||||
* @throws TeamSpeak3_Transport_Exception
|
||||
* @return TeamSpeak3_Helper_String
|
||||
*/
|
||||
public function readLine($token = "\n")
|
||||
{
|
||||
$this->connect();
|
||||
|
||||
$line = TeamSpeak3_Helper_String::factory("");
|
||||
|
||||
while(!$line->endsWith($token))
|
||||
{
|
||||
$this->waitForReadyRead();
|
||||
|
||||
$data = @fgets($this->stream, 4096);
|
||||
|
||||
TeamSpeak3_Helper_Signal::getInstance()->emit(strtolower($this->getAdapterType()) . "DataRead", $data);
|
||||
|
||||
if($data === FALSE)
|
||||
{
|
||||
if($line->count())
|
||||
{
|
||||
$line->append($token);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new TeamSpeak3_Transport_Exception("connection to server '" . $this->config["host"] . ":" . $this->config["port"] . "' lost");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$line->append($data);
|
||||
}
|
||||
}
|
||||
|
||||
return $line->trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes data to the stream.
|
||||
*
|
||||
* @param string $data
|
||||
* @return void
|
||||
*/
|
||||
public function send($data)
|
||||
{
|
||||
$this->connect();
|
||||
|
||||
@fwrite($this->stream, $data);
|
||||
|
||||
TeamSpeak3_Helper_Signal::getInstance()->emit(strtolower($this->getAdapterType()) . "DataSend", $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a line of data to the stream.
|
||||
*
|
||||
* @param string $data
|
||||
* @param string $separator
|
||||
* @return void
|
||||
*/
|
||||
public function sendLine($data, $separator = "\n")
|
||||
{
|
||||
$size = strlen($data);
|
||||
$pack = 4096;
|
||||
|
||||
for($seek = 0 ;$seek < $size;)
|
||||
{
|
||||
$rest = $size-$seek;
|
||||
$pack = $rest < $pack ? $rest : $pack;
|
||||
$buff = substr($data, $seek, $pack);
|
||||
$seek = $seek+$pack;
|
||||
|
||||
if($seek >= $size) $buff .= $separator;
|
||||
|
||||
$this->send($buff);
|
||||
}
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Transport_TCP
|
||||
* @brief Class for connecting to a remote server through TCP.
|
||||
*/
|
||||
class TeamSpeak3_Transport_TCP extends TeamSpeak3_Transport_Abstract
|
||||
{
|
||||
/**
|
||||
* Connects to a remote server.
|
||||
*
|
||||
* @throws TeamSpeak3_Transport_Exception
|
||||
* @return void
|
||||
*/
|
||||
public function connect()
|
||||
{
|
||||
if($this->stream !== null) return;
|
||||
|
||||
$host = strval($this->config["host"]);
|
||||
$port = strval($this->config["port"]);
|
||||
$timeout = intval($this->config["timeout"]);
|
||||
$blocking = intval($this->config["blocking"]);
|
||||
|
||||
if(empty($this->config["ssh"]))
|
||||
{
|
||||
$address = "tcp://" . (strstr($host, ":") !== FALSE ? "[" . $host . "]" : $host) . ":" . $port;
|
||||
$options = empty($this->config["tls"]) ? array() : array("ssl" => array("allow_self_signed" => TRUE, "verify_peer" => FALSE, "verify_peer_name" => FALSE));
|
||||
|
||||
$this->stream = @stream_socket_client($address, $errno, $errstr, $this->config["timeout"], STREAM_CLIENT_CONNECT, stream_context_create($options));
|
||||
|
||||
if($this->stream === FALSE)
|
||||
{
|
||||
throw new TeamSpeak3_Transport_Exception(TeamSpeak3_Helper_String::factory($errstr)->toUtf8()->toString(), $errno);
|
||||
}
|
||||
|
||||
if(!empty($this->config["tls"]))
|
||||
{
|
||||
stream_socket_enable_crypto($this->stream, TRUE, STREAM_CRYPTO_METHOD_SSLv23_CLIENT);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->session = @ssh2_connect($host, $port);
|
||||
|
||||
if($this->session === FALSE)
|
||||
{
|
||||
throw new TeamSpeak3_Transport_Exception("failed to establish secure shell connection to server '" . $this->config["host"] . ":" . $this->config["port"] . "'");
|
||||
}
|
||||
|
||||
if(!@ssh2_auth_password($this->session, $this->config["username"], $this->config["password"]))
|
||||
{
|
||||
throw new TeamSpeak3_Adapter_ServerQuery_Exception("invalid loginname or password", 0x208);
|
||||
}
|
||||
|
||||
$this->stream = @ssh2_shell($this->session, "raw");
|
||||
|
||||
if($this->stream === FALSE)
|
||||
{
|
||||
throw new TeamSpeak3_Transport_Exception("failed to open a secure shell on server '" . $this->config["host"] . ":" . $this->config["port"] . "'");
|
||||
}
|
||||
}
|
||||
|
||||
@stream_set_timeout($this->stream, $timeout);
|
||||
@stream_set_blocking($this->stream, $blocking ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disconnects from a remote server.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function disconnect()
|
||||
{
|
||||
if($this->stream === null) return;
|
||||
|
||||
$this->stream = null;
|
||||
|
||||
if(is_resource($this->session))
|
||||
{
|
||||
@ssh2_disconnect($this->session);
|
||||
}
|
||||
|
||||
TeamSpeak3_Helper_Signal::getInstance()->emit(strtolower($this->getAdapterType()) . "Disconnected");
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads data from the stream.
|
||||
*
|
||||
* @param integer $length
|
||||
* @throws TeamSpeak3_Transport_Exception
|
||||
* @return TeamSpeak3_Helper_String
|
||||
*/
|
||||
public function read($length = 4096)
|
||||
{
|
||||
$this->connect();
|
||||
$this->waitForReadyRead();
|
||||
|
||||
$data = @stream_get_contents($this->stream, $length);
|
||||
|
||||
TeamSpeak3_Helper_Signal::getInstance()->emit(strtolower($this->getAdapterType()) . "DataRead", $data);
|
||||
|
||||
if($data === FALSE)
|
||||
{
|
||||
throw new TeamSpeak3_Transport_Exception("connection to server '" . $this->config["host"] . ":" . $this->config["port"] . "' lost");
|
||||
}
|
||||
|
||||
return new TeamSpeak3_Helper_String($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a single line of data from the stream.
|
||||
*
|
||||
* @param string $token
|
||||
* @throws TeamSpeak3_Transport_Exception
|
||||
* @return TeamSpeak3_Helper_String
|
||||
*/
|
||||
public function readLine($token = "\n")
|
||||
{
|
||||
$this->connect();
|
||||
|
||||
$line = TeamSpeak3_Helper_String::factory("");
|
||||
|
||||
while(!$line->endsWith($token))
|
||||
{
|
||||
$this->waitForReadyRead();
|
||||
|
||||
$data = @fgets($this->stream, 4096);
|
||||
|
||||
TeamSpeak3_Helper_Signal::getInstance()->emit(strtolower($this->getAdapterType()) . "DataRead", $data);
|
||||
|
||||
if($data === FALSE)
|
||||
{
|
||||
if($line->count())
|
||||
{
|
||||
$line->append($token);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new TeamSpeak3_Transport_Exception("connection to server '" . $this->config["host"] . ":" . $this->config["port"] . "' lost");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$line->append($data);
|
||||
}
|
||||
}
|
||||
|
||||
return $line->trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes data to the stream.
|
||||
*
|
||||
* @param string $data
|
||||
* @return void
|
||||
*/
|
||||
public function send($data)
|
||||
{
|
||||
$this->connect();
|
||||
|
||||
@fwrite($this->stream, $data);
|
||||
|
||||
TeamSpeak3_Helper_Signal::getInstance()->emit(strtolower($this->getAdapterType()) . "DataSend", $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a line of data to the stream.
|
||||
*
|
||||
* @param string $data
|
||||
* @param string $separator
|
||||
* @return void
|
||||
*/
|
||||
public function sendLine($data, $separator = "\n")
|
||||
{
|
||||
$size = strlen($data);
|
||||
$pack = 4096;
|
||||
|
||||
for($seek = 0 ;$seek < $size;)
|
||||
{
|
||||
$rest = $size-$seek;
|
||||
$pack = $rest < $pack ? $rest : $pack;
|
||||
$buff = substr($data, $seek, $pack);
|
||||
$seek = $seek+$pack;
|
||||
|
||||
if($seek >= $size) $buff .= $separator;
|
||||
|
||||
$this->send($buff);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,110 +1,110 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Transport_UDP
|
||||
* @brief Class for connecting to a remote server through UDP.
|
||||
*/
|
||||
class TeamSpeak3_Transport_UDP extends TeamSpeak3_Transport_Abstract
|
||||
{
|
||||
/**
|
||||
* Connects to a remote server.
|
||||
*
|
||||
* @throws TeamSpeak3_Transport_Exception
|
||||
* @return void
|
||||
*/
|
||||
public function connect()
|
||||
{
|
||||
if($this->stream !== null) return;
|
||||
|
||||
$host = strval($this->config["host"]);
|
||||
$port = strval($this->config["port"]);
|
||||
|
||||
$address = "udp://" . (strstr($host, ":") !== FALSE ? "[" . $host . "]" : $host) . ":" . $port;
|
||||
$timeout = (int) $this->config["timeout"];
|
||||
|
||||
$this->stream = @stream_socket_client($address, $errno, $errstr, $timeout);
|
||||
|
||||
if($this->stream === FALSE)
|
||||
{
|
||||
throw new TeamSpeak3_Transport_Exception(TeamSpeak3_Helper_String::factory($errstr)->toUtf8()->toString(), $errno);
|
||||
}
|
||||
|
||||
@stream_set_timeout($this->stream, $timeout);
|
||||
@stream_set_blocking($this->stream, $this->config["blocking"] ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disconnects from a remote server.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function disconnect()
|
||||
{
|
||||
if($this->stream === null) return;
|
||||
|
||||
$this->stream = null;
|
||||
|
||||
TeamSpeak3_Helper_Signal::getInstance()->emit(strtolower($this->getAdapterType()) . "Disconnected");
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads data from the stream.
|
||||
*
|
||||
* @param integer $length
|
||||
* @throws TeamSpeak3_Transport_Exception
|
||||
* @return TeamSpeak3_Helper_String
|
||||
*/
|
||||
public function read($length = 4096)
|
||||
{
|
||||
$this->connect();
|
||||
$this->waitForReadyRead();
|
||||
|
||||
$data = @fread($this->stream, $length);
|
||||
|
||||
TeamSpeak3_Helper_Signal::getInstance()->emit(strtolower($this->getAdapterType()) . "DataRead", $data);
|
||||
|
||||
if($data === FALSE)
|
||||
{
|
||||
throw new TeamSpeak3_Transport_Exception("connection to server '" . $this->config["host"] . ":" . $this->config["port"] . "' lost");
|
||||
}
|
||||
|
||||
return new TeamSpeak3_Helper_String($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes data to the stream.
|
||||
*
|
||||
* @param string $data
|
||||
* @return void
|
||||
*/
|
||||
public function send($data)
|
||||
{
|
||||
$this->connect();
|
||||
|
||||
@stream_socket_sendto($this->stream, $data);
|
||||
|
||||
TeamSpeak3_Helper_Signal::getInstance()->emit(strtolower($this->getAdapterType()) . "DataSend", $data);
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Transport_UDP
|
||||
* @brief Class for connecting to a remote server through UDP.
|
||||
*/
|
||||
class TeamSpeak3_Transport_UDP extends TeamSpeak3_Transport_Abstract
|
||||
{
|
||||
/**
|
||||
* Connects to a remote server.
|
||||
*
|
||||
* @throws TeamSpeak3_Transport_Exception
|
||||
* @return void
|
||||
*/
|
||||
public function connect()
|
||||
{
|
||||
if($this->stream !== null) return;
|
||||
|
||||
$host = strval($this->config["host"]);
|
||||
$port = strval($this->config["port"]);
|
||||
|
||||
$address = "udp://" . (strstr($host, ":") !== FALSE ? "[" . $host . "]" : $host) . ":" . $port;
|
||||
$timeout = (int) $this->config["timeout"];
|
||||
|
||||
$this->stream = @stream_socket_client($address, $errno, $errstr, $timeout);
|
||||
|
||||
if($this->stream === FALSE)
|
||||
{
|
||||
throw new TeamSpeak3_Transport_Exception(TeamSpeak3_Helper_String::factory($errstr)->toUtf8()->toString(), $errno);
|
||||
}
|
||||
|
||||
@stream_set_timeout($this->stream, $timeout);
|
||||
@stream_set_blocking($this->stream, $this->config["blocking"] ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disconnects from a remote server.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function disconnect()
|
||||
{
|
||||
if($this->stream === null) return;
|
||||
|
||||
$this->stream = null;
|
||||
|
||||
TeamSpeak3_Helper_Signal::getInstance()->emit(strtolower($this->getAdapterType()) . "Disconnected");
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads data from the stream.
|
||||
*
|
||||
* @param integer $length
|
||||
* @throws TeamSpeak3_Transport_Exception
|
||||
* @return TeamSpeak3_Helper_String
|
||||
*/
|
||||
public function read($length = 4096)
|
||||
{
|
||||
$this->connect();
|
||||
$this->waitForReadyRead();
|
||||
|
||||
$data = @fread($this->stream, $length);
|
||||
|
||||
TeamSpeak3_Helper_Signal::getInstance()->emit(strtolower($this->getAdapterType()) . "DataRead", $data);
|
||||
|
||||
if($data === FALSE)
|
||||
{
|
||||
throw new TeamSpeak3_Transport_Exception("connection to server '" . $this->config["host"] . ":" . $this->config["port"] . "' lost");
|
||||
}
|
||||
|
||||
return new TeamSpeak3_Helper_String($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes data to the stream.
|
||||
*
|
||||
* @param string $data
|
||||
* @return void
|
||||
*/
|
||||
public function send($data)
|
||||
{
|
||||
$this->connect();
|
||||
|
||||
@stream_socket_sendto($this->stream, $data);
|
||||
|
||||
TeamSpeak3_Helper_Signal::getInstance()->emit(strtolower($this->getAdapterType()) . "DataSend", $data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,6 +90,7 @@ if (isset($mysqlcon) && ($config = $mysqlcon->query("SELECT * FROM `$dbname`.`co
|
||||
if(count($config) != 0) {
|
||||
$ts['host'] = $config['tshost'];
|
||||
$ts['query'] = $config['tsquery'];
|
||||
$ts['tsencrypt'] = $config['tsencrypt'];
|
||||
$ts['voice'] = $config['tsvoice'];
|
||||
$ts['user'] = $config['tsuser'];
|
||||
$ts['pass'] = $config['tspass'];
|
||||
|
||||
@@ -1,15 +1,23 @@
|
||||
<?PHP
|
||||
## Uncomment the command you need to run PHP
|
||||
## This are only examples
|
||||
## If you miss one, feel free to add it
|
||||
## Only one command should be active at the same time!
|
||||
$phpcommand = "php";
|
||||
#$phpcommand = "php56";
|
||||
#$phpcommand = "php70";
|
||||
#$phpcommand = "/usr/bin/php5";
|
||||
#$phpcommand = "/usr/bin/php7.2";
|
||||
#$phpcommand = "C:\PHP5\php.exe";
|
||||
#$phpcommand = "C:\PHP7\php.exe";
|
||||
#$phpcommand = "\"C:\Program Files (x86)\PHP\php.exe\""; // on blanks you need special marks \"
|
||||
#$phpcommand = "c:\wamp\bin\php\php.exe";
|
||||
<?PHP
|
||||
## Uncomment the command you need to run PHP
|
||||
## This are only examples
|
||||
## If you miss one, feel free to add it
|
||||
## Only one command should be active at the same time!
|
||||
##
|
||||
## Default, which should normally working on Linux and Windows
|
||||
$phpcommand = "php";
|
||||
##
|
||||
## Linux
|
||||
#$phpcommand = "php56";
|
||||
#$phpcommand = "php70";
|
||||
#$phpcommand = "/usr/bin/php5";
|
||||
#$phpcommand = "/usr/bin/php7.2";
|
||||
##
|
||||
## Windows
|
||||
#$phpcommand = 'C:\PHP5\php.exe';
|
||||
#$phpcommand = 'C:\PHP7\php.exe';
|
||||
#$phpcommand = 'c:\wamp\bin\php\php.exe';
|
||||
#$phpcommand = 'c:\xampp\php\php.exe';
|
||||
# On blanks inside the path you need to escape these with special marks --> \" <-- at the beginning and end of the path, see example below
|
||||
#$phpcommand = '\"C:\Program Files (x86)\PHP\php.exe\"';
|
||||
?>
|
||||
@@ -236,7 +236,7 @@ if((time() - $job_check['last_update']['timestamp']) < 259200 && !isset($_SESSIO
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-user"></i><?PHP echo ' ' . $_SESSION[$rspathhex.'tsname'] ?>
|
||||
<b class="caret"></b></a><ul class="dropdown-menu">
|
||||
<?PHP
|
||||
if($_SESSION[$rspathhex.'tsname'] == $lang['stag0016'] || $_SESSION[$rspathhex.'connected'] == 0) {
|
||||
if($_SESSION[$rspathhex.'tsname'] == $lang['stag0016'] || $_SESSION[$rspathhex.'tsname'] == "verification needed (multiple)!" || $_SESSION[$rspathhex.'connected'] == 0) {
|
||||
echo '<li><a href="verify.php"><i class="fa fa-fw fa-key"></i> '.$lang['stag0017'].'</a></li>';
|
||||
}
|
||||
if(isset($_SESSION[$rspathhex.'admin']) && $_SESSION[$rspathhex.'admin'] == TRUE) {
|
||||
|
||||
@@ -21,12 +21,6 @@ if(!isset($_SESSION[$rspathhex.'tsuid'])) {
|
||||
set_session_ts3($ts['voice'], $mysqlcon, $dbname, $language, $adminuuid);
|
||||
}
|
||||
|
||||
if (isset($_POST['verify']) && $_POST['csrf_token'] != $_SESSION[$rspathhex.'csrf_token']) {
|
||||
echo $lang['errcsrf'];
|
||||
rem_session_ts3($rspathhex);
|
||||
exit;
|
||||
}
|
||||
|
||||
if(isset($_REQUEST['token']) && isset($_SESSION[$rspathhex.'temp_uuid'])) {
|
||||
if($_REQUEST['token'] == NULL) {
|
||||
$err_msg = $lang['stve0003']; $err_lvl = 1;
|
||||
@@ -91,10 +85,14 @@ if((!isset($_SESSION[$rspathhex.'multiple']) || count($_SESSION[$rspathhex.'mult
|
||||
$err_msg = $lang['stve0005']; $err_lvl = 1;
|
||||
}
|
||||
|
||||
if(isset($_POST['uuid']) && !isset($_SESSION[$rspathhex.'temp_uuid']) && $_POST['csrf_token'] == $_SESSION[$rspathhex.'csrf_token']) {
|
||||
if(isset($_POST['uuid']) && !isset($_SESSION[$rspathhex.'temp_uuid'])) {
|
||||
require_once('../libs/ts3_lib/TeamSpeak3.php');
|
||||
try {
|
||||
$ts3 = TeamSpeak3::factory("serverquery://".rawurlencode($ts['user']).":".rawurlencode($ts['pass'])."@".$ts['host'].":".$ts['query']."/?server_port=".$ts['voice']."&blocking=0");
|
||||
if($ts['tsencrypt'] == 1) {
|
||||
$ts3 = TeamSpeak3::factory("serverquery://".rawurlencode($ts['user']).":".rawurlencode($ts['pass'])."@".$ts['host'].":".$ts['query']."/?server_port=".$ts['voice']."&ssh=1");
|
||||
} else {
|
||||
$ts3 = TeamSpeak3::factory("serverquery://".rawurlencode($ts['user']).":".rawurlencode($ts['pass'])."@".$ts['host'].":".$ts['query']."/?server_port=".$ts['voice']."&blocking=0");
|
||||
}
|
||||
|
||||
try {
|
||||
usleep($slowmode);
|
||||
@@ -134,8 +132,6 @@ if(isset($_POST['uuid']) && !isset($_SESSION[$rspathhex.'temp_uuid']) && $_POST[
|
||||
}
|
||||
}
|
||||
|
||||
$_SESSION[$rspathhex.'csrf_token'] = bin2hex(openssl_random_pseudo_bytes(32));
|
||||
|
||||
require_once('nav.php');
|
||||
?>
|
||||
<div id="page-wrapper">
|
||||
@@ -152,7 +148,6 @@ require_once('nav.php');
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<form name="verify" method="POST">
|
||||
<input type="hidden" name="csrf_token" value="<?PHP echo $_SESSION[$rspathhex.'csrf_token']; ?>">
|
||||
<?PHP
|
||||
if($_SESSION[$rspathhex.'connected'] == 0) {
|
||||
$ts3link = '<a href="ts3server://';
|
||||
|
||||
@@ -51,14 +51,14 @@ require_once('nav.php');
|
||||
|
||||
if(!isset($_POST['number']) || $_POST['number'] == "yes") {
|
||||
$_SESSION[$rspathhex.'showexcepted'] = "yes";
|
||||
$filter = " `except`='0'";
|
||||
$filter = " WHERE `except`='0'";
|
||||
} else {
|
||||
$_SESSION[$rspathhex.'showexcepted'] = "no";
|
||||
$filter = "";
|
||||
}
|
||||
|
||||
if(($dbuserdata = $mysqlcon->query("SELECT `uuid`,`cldbid`,`name` FROM `$dbname`.`user` WHERE $filter ORDER BY `name` ASC")) === false) {
|
||||
$err_msg = "DB Error: ".print_r($mysqlcon->errorInfo(), true); $err_lvl = 3;
|
||||
if(($dbuserdata = $mysqlcon->query("SELECT `uuid`,`cldbid`,`name` FROM `$dbname`.`user` $filter ORDER BY `name` ASC")) === false) {
|
||||
$err_msg = "DB Error1: ".print_r($mysqlcon->errorInfo(), true); $err_lvl = 3;
|
||||
}
|
||||
$user_arr = $dbuserdata->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
|
||||
@@ -51,13 +51,13 @@ require_once('nav.php');
|
||||
|
||||
if(!isset($_POST['number']) || $_POST['number'] == "yes") {
|
||||
$_SESSION[$rspathhex.'showexcepted'] = "yes";
|
||||
$filter = " `except`='0'";
|
||||
$filter = " WHERE `except`='0'";
|
||||
} else {
|
||||
$_SESSION[$rspathhex.'showexcepted'] = "no";
|
||||
$filter = "";
|
||||
}
|
||||
|
||||
if(($dbuserdata = $mysqlcon->query("SELECT `uuid`,`cldbid`,`name` FROM `$dbname`.`user` WHERE $filter ORDER BY `name` ASC")) === false) {
|
||||
if(($dbuserdata = $mysqlcon->query("SELECT `uuid`,`cldbid`,`name` FROM `$dbname`.`user` $filter ORDER BY `name` ASC")) === false) {
|
||||
$err_msg = "DB Error: ".print_r($mysqlcon->errorInfo(), true); $err_lvl = 3;
|
||||
}
|
||||
$user_arr = $dbuserdata->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
@@ -13,7 +13,7 @@ session_start();
|
||||
require_once('../other/config.php');
|
||||
require_once('../other/phpcommand.php');
|
||||
|
||||
function enter_logfile($logpath,$timezone,$loglevel,$logtext) {
|
||||
function enter_logfile($logpath,$timezone,$loglevel,$logtext,$norotate = false) {
|
||||
$file = $logpath.'ranksystem.log';
|
||||
if ($loglevel == 1) {
|
||||
$loglevel = " CRITICAL ";
|
||||
@@ -25,27 +25,22 @@ function enter_logfile($logpath,$timezone,$loglevel,$logtext) {
|
||||
$loglevel = " NOTICE ";
|
||||
} elseif ($loglevel == 5) {
|
||||
$loglevel = " INFO ";
|
||||
} elseif ($loglevel == 6) {
|
||||
$loglevel = " DEBUG ";
|
||||
}
|
||||
$input = DateTime::createFromFormat('U.u', number_format(microtime(true), 6, '.', ''))->setTimeZone(new DateTimeZone($timezone))->format("Y-m-d H:i:s.u ").$loglevel.$logtext."\n";
|
||||
$loghandle = fopen($file, 'a');
|
||||
fwrite($loghandle, $input);
|
||||
if (filesize($file) > 5242880) {
|
||||
fwrite($loghandle, DateTime::createFromFormat('U.u', number_format(microtime(true), 6, '.', ''))->setTimeZone(new DateTimeZone($timezone))->format("Y-m-d H:i:s.u ").$loglevel.$logtext."\n");
|
||||
fclose($loghandle);
|
||||
if($norotate == false && filesize($file) > 5242880) {
|
||||
$loghandle = fopen($file, 'a');
|
||||
fwrite($loghandle, DateTime::createFromFormat('U.u', number_format(microtime(true), 6, '.', ''))->setTimeZone(new DateTimeZone($timezone))->format("Y-m-d H:i:s.u ")." NOTICE Logfile filesie of 5 MiB reached.. Rotate logfile.\n");
|
||||
fwrite($loghandle, DateTime::createFromFormat('U.u', number_format(microtime(true), 6, '.', ''))->setTimeZone(new DateTimeZone($timezone))->format("Y-m-d H:i:s.u ")." NOTICE Restart Bot to continue with new log file...\n");
|
||||
fclose($loghandle);
|
||||
$file2 = "$file.old";
|
||||
if (file_exists($file2)) unlink($file2);
|
||||
rename($file, $file2);
|
||||
if (substr(php_uname(), 0, 7) == "Windows") {
|
||||
exec("del /F ".substr(__DIR__,0,-12).'logs/pid');
|
||||
$WshShell = new COM("WScript.Shell");
|
||||
$oExec = $WshShell->Run("cmd /C ".$phpcommand." ".substr(__DIR__,0,-12)."worker.php start", 0, false);
|
||||
exit;
|
||||
} else {
|
||||
exec("rm -f ".substr(__DIR__,0,-12).'logs/pid');
|
||||
exec($phpcommand." ".substr(__DIR__,0,-12)."worker.php start");
|
||||
exit;
|
||||
}
|
||||
$loghandle = fopen($file, 'a');
|
||||
fwrite($loghandle, DateTime::createFromFormat('U.u', number_format(microtime(true), 6, '.', ''))->setTimeZone(new DateTimeZone($timezone))->format("Y-m-d H:i:s.u ")." NOTICE Rotated logfile...\n");
|
||||
fclose($loghandle);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,11 +82,13 @@ if(($last_access[0]['last_access'] + 1) >= time()) {
|
||||
$_SESSION[$rspathhex.'clientip'] = getclientip();
|
||||
$_SESSION[$rspathhex.'newversion'] = $newversion;
|
||||
$_SESSION[$rspathhex.'csrf_token'] = bin2hex(openssl_random_pseudo_bytes(32));
|
||||
enter_logfile($logpath,$timezone,6,sprintf($lang['brute2'], getclientip()));
|
||||
if($mysqlcon->exec("UPDATE `$dbname`.`config` SET `count_access`='0'") === false) { }
|
||||
header("Location: //".$_SERVER['HTTP_HOST'].rtrim(dirname($_SERVER['PHP_SELF']), '/\\')."/bot.php");
|
||||
exit;
|
||||
} elseif(isset($_POST['username'])) {
|
||||
$nowtime = time();
|
||||
enter_logfile($logpath,$timezone,5,sprintf($lang['brute1'], getclientip(), $_POST['username']));
|
||||
if($mysqlcon->exec("UPDATE `$dbname`.`config` SET `last_access`='$nowtime',`count_access`=`count_access` + 1") === false) { }
|
||||
$err_msg = $lang['errlogin'];
|
||||
$err_lvl = 3;
|
||||
|
||||
@@ -173,7 +173,7 @@ if($adminuuid==NULL && $_SESSION[$rspathhex.'username'] == $webuser && !isset($e
|
||||
$err_msg = $lang['winav11']; $err_lvl = 3;
|
||||
}
|
||||
|
||||
if(!isset($_SERVER['HTTPS']) && !isset($err_msg) || $_SERVER['HTTPS'] != "on" && !isset($err_msg)) {
|
||||
if(!isset($_SERVER['HTTPS']) && !isset($err_msg) || isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != "on" && !isset($err_msg)) {
|
||||
$host = "<a href=\"https://".$_SERVER['HTTP_HOST'].rtrim(dirname($_SERVER['PHP_SELF']), '/\\')."\">";
|
||||
$err_msg = sprintf($lang['winav10'], $host,'</a>!<br>', '<br>'); $err_lvl = 2;
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ $newcsrf = bin2hex(openssl_random_pseudo_bytes(32));
|
||||
if (isset($_POST['update']) && $_SESSION[$rspathhex.'username'] == $webuser && $_SESSION[$rspathhex.'password'] == $webpass && $_SESSION[$rspathhex.'clientip'] == getclientip() && $_POST['csrf_token'] == $_SESSION[$rspathhex.'csrf_token']) {
|
||||
$tshost = $_POST['tshost'];
|
||||
$tsquery = $_POST['tsquery'];
|
||||
if (isset($_POST['tsencrypt'])) $tsencrypt = 1; else $tsencrypt = 0;
|
||||
$tsvoice = $_POST['tsvoice'];
|
||||
$tsuser = $_POST['tsuser'];
|
||||
$tspass = $_POST['tspass'];
|
||||
@@ -60,7 +61,7 @@ if (isset($_POST['update']) && $_SESSION[$rspathhex.'username'] == $webuser && $
|
||||
$defchid = $_POST['defchid'];
|
||||
$slowmode = $_POST['slowmode'];
|
||||
$avatar_delay= $_POST['avatar_delay'];
|
||||
if ($mysqlcon->exec("UPDATE `$dbname`.`config` SET `tshost`='$tshost',`tsquery`='$tsquery',`tsvoice`='$tsvoice',`tsuser`='$tsuser',`tspass`='$tspass',`queryname`='$queryname',`queryname2`='$queryname2',`slowmode`='$slowmode',`defchid`='$defchid',`avatar_delay`='$avatar_delay'") === false) {
|
||||
if ($mysqlcon->exec("UPDATE `$dbname`.`config` SET `tshost`='$tshost',`tsencrypt`='$tsencrypt',`tsquery`='$tsquery',`tsvoice`='$tsvoice',`tsuser`='$tsuser',`tspass`='$tspass',`queryname`='$queryname',`queryname2`='$queryname2',`slowmode`='$slowmode',`defchid`='$defchid',`avatar_delay`='$avatar_delay'") === false) {
|
||||
$err_msg = print_r($mysqlcon->errorInfo(), true);
|
||||
$err_lvl = 3;
|
||||
} else {
|
||||
@@ -70,6 +71,7 @@ if (isset($_POST['update']) && $_SESSION[$rspathhex.'username'] == $webuser && $
|
||||
}
|
||||
$ts['host'] = $_POST['tshost'];
|
||||
$ts['query'] = $_POST['tsquery'];
|
||||
$ts['tsencrypt']= $tsencrypt;
|
||||
$ts['voice'] = $_POST['tsvoice'];
|
||||
$ts['user'] = $_POST['tsuser'];
|
||||
$ts['pass'] = $_POST['tspass'];
|
||||
@@ -101,6 +103,16 @@ $_SESSION[$rspathhex.'csrf_token'] = $newcsrf;
|
||||
<div class="help-block with-errors"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-4 control-label" data-toggle="modal" data-target="#wits3encryptdesc"><?php echo $lang['wits3encrypt']; ?><i class="help-hover glyphicon glyphicon-question-sign"></i></label>
|
||||
<div class="col-sm-8">
|
||||
<?PHP if ($ts['tsencrypt'] == 1) {
|
||||
echo '<input class="switch-animate" type="checkbox" checked data-size="mini" name="tsencrypt" value="',$ts['tsencrypt'],'">';
|
||||
} else {
|
||||
echo '<input class="switch-animate" type="checkbox" data-size="mini" name="tsencrypt" value="',$ts['tsencrypt'],'">';
|
||||
} ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-4 control-label" data-toggle="modal" data-target="#wits3querydesc"><?php echo $lang['wits3query']; ?><i class="help-hover glyphicon glyphicon-question-sign"></i></label>
|
||||
<div class="col-sm-8 required-field-block-spin">
|
||||
@@ -248,6 +260,22 @@ $_SESSION[$rspathhex.'csrf_token'] = $newcsrf;
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal fade" id="wits3encryptdesc" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title"><?php echo $lang['wits3encrypt']; ?></h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<?php echo $lang['wits3encryptdesc']; ?>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal"><?PHP echo $lang['stnv0002']; ?></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal fade" id="wits3querydesc" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
|
||||
83
worker.php
83
worker.php
@@ -18,7 +18,7 @@ if (substr(php_uname(), 0, 7) == "Windows") {
|
||||
function checkProcess($pid = null) {
|
||||
if (substr(php_uname(), 0, 7) == "Windows") {
|
||||
if(!empty($pid)) {
|
||||
exec("wmic process where \"Name=\"php.exe\" and processid=\"".$pid."\"\" get processid 2>nul", $result);
|
||||
exec("wmic process where \"processid=".$pid."\" get processid 2>nul", $result);
|
||||
if(isset($result[1]) && is_numeric($result[1])) {
|
||||
return TRUE;
|
||||
} else {
|
||||
@@ -27,7 +27,7 @@ function checkProcess($pid = null) {
|
||||
} else {
|
||||
if (file_exists($GLOBALS['pidfile'])) {
|
||||
$pid = str_replace(array("\r", "\n"), '', file_get_contents($GLOBALS['pidfile']));
|
||||
exec("wmic process where \"Name=\"php.exe\" and processid=\"".$pid."\"\" get processid", $result);
|
||||
exec("wmic process where \"processid=".$pid."\" get processid 2>nul", $result);
|
||||
if(isset($result[1]) && is_numeric($result[1])) {
|
||||
return TRUE;
|
||||
} else {
|
||||
@@ -85,18 +85,19 @@ function start() {
|
||||
echo "\n Error due loading the PHP COM module (wrong server configuration!): ",$e->getMessage(),"\n";
|
||||
}
|
||||
try {
|
||||
$oExec = $WshShell->Run("cmd /C ".$phpcommand." ".__DIR__."\jobs\bot.php", 0, false);
|
||||
$wcmd = "cmd /C ".$phpcommand." ".__DIR__."\jobs\bot.php";
|
||||
$oExec = $WshShell->Run($wcmd, 0, false);
|
||||
} catch (Exception $e) {
|
||||
echo "\n Error due starting Bot (exec command enabled?): ",$e->getMessage(),"\n";
|
||||
}
|
||||
try {
|
||||
exec("wmic process WHERE \"Name=\"php.exe\" AND CommandLine LIKE \"%bot.php%\"\" get ProcessId", $pid);
|
||||
exec("wmic process where \"Name LIKE \"%php%\" AND CommandLine LIKE \"%bot.php%\"\" get ProcessId", $pid);
|
||||
} catch (Exception $e) {
|
||||
echo "\n Error due getting process list (wmic command enabled?): ",$e->getMessage(),"\n";
|
||||
}
|
||||
if(isset($pid[1]) && is_numeric($pid[1])) {
|
||||
exec("echo ".$pid[1]." > ".$GLOBALS['pidfile']);
|
||||
echo " [OK]\n";
|
||||
echo " [OK]";
|
||||
if (file_exists($GLOBALS['autostart'])) {
|
||||
unlink($GLOBALS['autostart']);
|
||||
}
|
||||
@@ -110,7 +111,7 @@ function start() {
|
||||
} else {
|
||||
if (checkProcess() == FALSE) {
|
||||
echo "Starting the Ranksystem Bot.";
|
||||
exec($phpcommand." ".dirname(__FILE__)."/jobs/bot.php >/dev/null 2>&1 & echo $! > ".$GLOBALS['pidfile']);
|
||||
exec($phpcommand." ".__DIR__."/jobs/bot.php >/dev/null 2>&1 & echo $! > ".$GLOBALS['pidfile']);
|
||||
if (checkProcess() == FALSE) {
|
||||
echo " [Failed]\n";
|
||||
} else {
|
||||
@@ -127,59 +128,35 @@ function start() {
|
||||
}
|
||||
|
||||
function stop() {
|
||||
if (substr(php_uname(), 0, 7) == "Windows") {
|
||||
if (checkProcess() == TRUE) {
|
||||
echo "Stopping the Ranksystem Bot.\n";
|
||||
$pid = str_replace(array("\r", "\n"), '', file_get_contents($GLOBALS['pidfile']));
|
||||
exec("del /F ".$GLOBALS['pidfile']);
|
||||
echo "Wait until Bot is down";
|
||||
$count_check=0;
|
||||
while (checkProcess($pid) == TRUE) {
|
||||
sleep(1);
|
||||
echo ".";
|
||||
$count_check ++;
|
||||
if($count_check > 10) {
|
||||
if (checkProcess() == TRUE) {
|
||||
echo "Stopping the Ranksystem Bot.\n";
|
||||
$pid = str_replace(array("\r", "\n"), '', file_get_contents($GLOBALS['pidfile']));
|
||||
unlink($GLOBALS['pidfile']);
|
||||
echo "Wait until Bot is down";
|
||||
$count_check=0;
|
||||
while (checkProcess($pid) == TRUE) {
|
||||
sleep(1);
|
||||
echo ".";
|
||||
$count_check ++;
|
||||
if($count_check > 10) {
|
||||
if (substr(php_uname(), 0, 7) == "Windows") {
|
||||
exec("taskkill /F /PID ".$pid);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (checkProcess($pid) == TRUE) {
|
||||
echo " [Failed]\n";
|
||||
} else {
|
||||
echo " [OK]\n";
|
||||
touch($GLOBALS['autostart']);
|
||||
}
|
||||
} else {
|
||||
echo "The Ranksystem seems not running.\n";
|
||||
}
|
||||
$GLOBALS['exec'] = TRUE;
|
||||
} else {
|
||||
if (checkProcess() == TRUE) {
|
||||
echo "Stopping the Ranksystem Bot.\n";
|
||||
$pid = str_replace(array("\r", "\n"), '', file_get_contents($GLOBALS['pidfile']));
|
||||
exec("rm -f ".$GLOBALS['pidfile']);
|
||||
echo "Wait until Bot is down";
|
||||
$count_check=0;
|
||||
while (checkProcess($pid) == TRUE) {
|
||||
sleep(1);
|
||||
echo ".";
|
||||
$count_check ++;
|
||||
if($count_check > 10) {
|
||||
} else {
|
||||
exec("kill -9 ".$pid);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (checkProcess($pid) == TRUE) {
|
||||
echo " [Failed]\n";
|
||||
} else {
|
||||
echo " [OK]\n";
|
||||
touch($GLOBALS['autostart']);
|
||||
}
|
||||
} else {
|
||||
echo "The Ranksystem seems not running.\n";
|
||||
}
|
||||
$GLOBALS['exec'] = TRUE;
|
||||
if (checkProcess($pid) == TRUE) {
|
||||
echo " [Failed]\n";
|
||||
} else {
|
||||
echo " [OK]\n";
|
||||
touch($GLOBALS['autostart']);
|
||||
}
|
||||
} else {
|
||||
echo "The Ranksystem seems not running.\n";
|
||||
}
|
||||
$GLOBALS['exec'] = TRUE;
|
||||
}
|
||||
|
||||
function check() {
|
||||
|
||||
Reference in New Issue
Block a user