-
Notifications
You must be signed in to change notification settings - Fork 1
/
ts3admin.class.php
4207 lines (3905 loc) · 131 KB
/
ts3admin.class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?PHP
/**
* ts3admin.class.php
* ------------------
* begin : 18. December 2009
* copyright : (C) 2009-2013 Par0noid Solutions
* email : [email protected]
* version : 0.7.0.0
* last modified : 28. January 2014
*
*
* This file is a powerful library for querying TeamSpeak3 servers.
*
* 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/>.
*/
/**
* The ts3admin.class.php is a powerful library that offers functions to communicate with Teamspeak 3 Servers from your website!
*
* You can do everything, your creativity knows no bounds!
* That library is faster than all other librarys because its optimized to find the shortest way to your information.
* No unneeded PHP 5 OOP Stuff, just the basics!
* There are a lot of professional developers and some big companys using my library.
* The best thing is that you can use it for free under the terms of the GNU General Public License v3.
* Take a look on the project website where you can find code examples, a manual and some other stuff.
*
* @author Par0noid Solutions <[email protected]>
* @version 0.7.0.0
* @copyright Copyright (c) 2009-2014, Stefan Z.
* @package ts3admin
* @link http://ts3admin.info
*/
class ts3admin {
//*******************************************************************************************
//****************************************** Vars *******************************************
//*******************************************************************************************
/**
* runtime is an private handle and configuration storage
*
* @author Par0noid Solutions
* @access private
*/
private $runtime = array('socket' => '', 'selected' => false, 'host' => '', 'queryport' => '10011', 'timeout' => 2, 'debug' => array(), 'fileSocket' => '');
//*******************************************************************************************
//************************************ Public Functions *************************************
//******************************************************************************************
/**
* banAddByIp
*
* Adds a new ban rule on the selected virtual server.
*
* <b>Output:</b>
* <code>
* Array
* {
* [banid] => 109
* }
* </code>
*
* @author Par0noid Solutions
* @access public
* @param string $ip clientIp
* @param integer $time bantime in seconds (0=unlimited)
* @param string $banreason Banreason [optional]
* @return array banId
*/
function banAddByIp($ip, $time, $banreason = NULL) {
if(!$this->runtime['selected']) { return $this->checkSelected(); }
if(!empty($banreason)) { $msg = ' banreason='.$this->escapeText($banreason); } else { $msg = NULL; }
return $this->getData('array', 'banadd ip='.$ip.' time='.$time.$msg);
}
/**
* banAddByUid
*
* Adds a new ban rule on the selected virtual server.
*
* <b>Output:</b>
* <code>
* Array
* {
* [banid] => 110
* }
* </code>
*
* @author Par0noid Solutions
* @access public
* @param string $uid clientUniqueId
* @param integer $time bantime in seconds (0=unlimited)
* @param string $banreason Banreason [optional]
* @return array banId
*/
function banAddByUid($uid, $time, $banreason = NULL) {
if(!$this->runtime['selected']) { return $this->checkSelected(); }
if(!empty($banreason)) { $msg = ' banreason='.$this->escapeText($banreason); } else { $msg = NULL; }
return $this->getData('array', 'banadd uid='.$uid.' time='.$time.$msg);
}
/**
* banAddByName
*
* Adds a new ban rule on the selected virtual server.
*
* <b>Output:</b>
* <code>
* Array
* {
* [banid] => 111
* }
* </code>
*
* @author Par0noid Solutions
* @access public
* @param string $name clientName
* @param integer $time bantime in seconds (0=unlimited)
* @param string $banreason Banreason [optional]
* @return array banId
*/
function banAddByName($name, $time, $banreason = NULL) {
if(!$this->runtime['selected']) { return $this->checkSelected(); }
if(!empty($banreason)) { $msg = ' banreason='.$this->escapeText($banreason); } else { $msg = NULL; }
return $this->getData('array', 'banadd name='.$this->escapeText($name).' time='.$time.$msg);
}
/**
* banClient
*
* Bans the client specified with ID clid from the server. Please note that this will create two separate ban rules for the targeted clients IP address and his unique identifier.
*
* <b>Output:</b>
* <code>
* Array
* {
* [1] => 129
* [2] => 130
* }
* </code>
*
* @author Par0noid Solutions
* @access public
* @param integer $clid clientId
* @param integer $time bantime in seconds (0=unlimited)
* @param string $banreason Banreason [optional]
* @return array banIds
*/
function banClient($clid, $time, $banreason = NULL) {
if(!$this->runtime['selected']) { return $this->checkSelected(); }
if(!empty($banreason)) { $msg = ' banreason='.$this->escapeText($banreason); } else { $msg = ''; }
$result = $this->getData('plain', 'banclient clid='.$clid.' time='.$time.$msg);
if($result['success']) {
return $this->generateOutput(true, $result['errors'], $this->splitBanIds($result['data']));
}else{
return $this->generateOutput(false, $result['errors'], false);
}
}
/**
* banDelete
*
* Deletes the ban rule with ID banid from the server.
*
* @author Par0noid Solutions
* @access public
* @param integer $banID banID
* @return boolean success
*/
function banDelete($banID) {
if(!$this->runtime['selected']) { return $this->checkSelected(); }
return $this->getData('boolean', 'bandel banid='.$banID);
}
/**
* banDeleteAll
*
* Deletes all active ban rules from the server.
*
* @author Par0noid Solutions
* @access public
* @return boolean success
*/
function banDeleteAll() {
if(!$this->runtime['selected']) { return $this->checkSelected(); }
return $this->getData('boolean', 'bandelall');
}
/**
* banList
*
* Displays a list of active bans on the selected virtual server.
*
* <b>Output:</b>
* <code>
* Array
* {
* [banid] => 131
* [ip] => 1.2.3.4
* [name] => eugen
* [uid] => IYAntAcZHgVC7s3n3DNWmuJB/aM=
* [created] => 1286660391
* [duration] => 0
* [invokername] => Par0noid
* [invokercldbid] => 2086
* [invokeruid] => nUixbsq/XakrrmbqU8O30R/D8Gc=
* [reason] => insult
* [enforcements] => 0
* }
* </code>
*
* @author Par0noid Solutions
* @access public
* @return array banlist
*/
function banList() {
if(!$this->runtime['selected']) { return $this->checkSelected(); }
return $this->getData('multi', 'banlist');
}
/**
* bindingList
*
* Displays a list of IP addresses used by the server instance on multi-homed machines.
*
* <b>Output:</b><br>
* <code>
* Array
* {
* [ip] => 0.0.0.0
* }
* </code>
*
* @author Par0noid Solutions
* @access public
* @return array bindingList
*/
function bindingList() {
return $this->getData('multi', 'bindinglist');
}
/**
* channelAddPerm
*
* Adds a set of specified permissions to a channel. Multiple permissions can be added by providing the two parameters of each permission. A permission can be specified by permid or permsid.
*
* <b>Input-Array like this:</b>
* <code>
* $permissions = array();
* $permissions['permissionID'] = 'permissionValue';
* //or you could use Permission Name
* $permissions['permissionName'] = 'permissionValue';
* </code>
*
* @author Par0noid Solutions
* @access public
* @param integer $cid channelId
* @param array $permissions permissions
* @return boolean success
*/
function channelAddPerm($cid, $permissions) {
if(!$this->runtime['selected']) { return $this->checkSelected(); }
if(count($permissions) > 0) {
//Permissions given
//Errorcollector
$errors = array();
//Split Permissions to prevent query from overload
$permissions = array_chunk($permissions, 50, true);
//Action for each splitted part of permission
foreach($permissions as $permission_part)
{
//Create command_string for each command that we could use implode later
$command_string = array();
foreach($permission_part as $key => $value)
{
$command_string[] = (is_numeric($key) ? "permid=" : "permsid=").$this->escapeText($key).' permvalue='.$value;
}
$result = $this->getData('boolean', 'channeladdperm cid='.$cid.' '.implode('|', $command_string));
if(!$result['success'])
{
foreach($result['errors'] as $error)
{
$errors[] = $error;
}
}
}
if(count($errors) == 0)
{
return $this->generateOutput(true, array(), true);
}else{
return $this->generateOutput(false, $errors, false);
}
}else{
// No permissions given
$this->addDebugLog('no permissions given');
return $this->generateOutput(false, array('Error: no permissions given'), false);
}
}
/**
* channelClientAddPerm
*
* Adds a set of specified permissions to a client in a specific channel. Multiple permissions can be added by providing the three parameters of each permission. A permission can be specified by permid or permsid.
*
* <b>Input-Array like this:</b>
* <code>
* $permissions = array();
* $permissions['permissionID'] = 'permissionValue';
* //or you could use Permission Name
* $permissions['permissionName'] = 'permissionValue';
* </code>
*
* @author Par0noid Solutions
* @access public
* @param integer $cid channelID
* @param integer $cldbid clientDBID
* @param array $permissions permissions
* @return boolean success
*/
function channelClientAddPerm($cid, $cldbid, $permissions) {
if(!$this->runtime['selected']) { return $this->checkSelected(); }
if(count($permissions) > 0) {
//Permissions given
//Errorcollector
$errors = array();
//Split Permissions to prevent query from overload
$permissions = array_chunk($permissions, 50, true);
//Action for each splitted part of permission
foreach($permissions as $permission_part)
{
//Create command_string for each command that we could use implode later
$command_string = array();
foreach($permission_part as $key => $value)
{
$command_string[] = (is_numeric($key) ? "permid=" : "permsid=").$this->escapeText($key).' permvalue='.$value;
}
$result = $this->getData('boolean', 'channelclientaddperm cid='.$cid.' cldbid='.$cldbid.' '.implode('|', $command_string));
if(!$result['success'])
{
foreach($result['errors'] as $error)
{
$errors[] = $error;
}
}
}
if(count($errors) == 0)
{
return $this->generateOutput(true, array(), true);
}else{
return $this->generateOutput(false, $errors, false);
}
}else{
// No permissions given
$this->addDebugLog('no permissions given');
return $this->generateOutput(false, array('Error: no permissions given'), false);
}
}
/**
* channelClientDelPerm
*
* Removes a set of specified permissions from a client in a specific channel. Multiple permissions can be removed at once. A permission can be specified by permid or permsid.
*
* <b>Input-Array like this:</b>
* <code>
* $permissions = array();
* $permissions[] = 'permissionID';
* $permissions[] = 'permissionName';
* //or
* $permissions = array('permissionID', 'permissionName', 'permissionID');
* </code>
*
* @author Par0noid Solutions
* @access public
* @param integer $cid channelID
* @param integer $cldbid clientDBID
* @param array $permissions permissions
* @return boolean success
*/
function channelClientDelPerm($cid, $cldbid, $permissions) {
if(!$this->runtime['selected']) { return $this->checkSelected(); }
$permissionArray = array();
if(count($permissions) > 0) {
foreach($permissions AS $value) {
$permissionArray[] = is_numeric($value) ? 'permid='.$value : 'permsid='.$value;
}
return $this->getData('boolean', 'channelclientdelperm cid='.$cid.' cldbid='.$cldbid.' '.implode('|', $permissionArray));
}else{
$this->addDebugLog('no permissions given');
return $this->generateOutput(false, array('Error: no permissions given'), false);
}
}
/**
* channelClientPermList
*
* Displays a list of permissions defined for a client in a specific channel.
*
* <b>Output:</b><br>
* <code>
* Array
* {
* [cid] => 250 (only in first result)
* [cldbid] => 2086 (only in first result)
* [permid] => 12876 (if permsid = false)
* [permsid] => b_client_info_view (if permsid = true)
* [permvalue] => 1
* [permnegated] => 0
* [permskip] => 0
* }
* </code>
*
* @author Par0noid Solutions
* @access public
* @param integer $cid channelID
* @param integer $cldbid clientDBID
* @param boolean $permsid displays permissionName instead of permissionID
* @return array channelclientpermlist
*/
function channelClientPermList($cid, $cldbid, $permsid = false) {
if(!$this->runtime['selected']) { return $this->checkSelected(); }
return $this->getData('multi', 'channelclientpermlist cid='.$cid.' cldbid='.$cldbid.($permsid ? ' -permsid' : ''));
}
/**
* channelCreate
*
* Creates a new channel using the given properties and displays its ID. Note that this command accepts multiple properties which means that you're able to specifiy all settings of the new channel at once.
*
* <b style="color:red">Hint:</b> don't forget to set channel_flag_semi_permanent = 1 or channel_flag_permanent = 1
*
* <b style="color:red">Hint:</b> you'll get an error if you want to create a channel without channel_name
*
* <b>Input-Array like this:</b>
* <code>
* $data = array();
*
* $data['setting'] = 'value';
* $data['setting'] = 'value';
* </code>
*
* <b>Output:</b>
* <code>
* Array
* {
* [cid] => 257
* }
* </code>
*
* @author Par0noid Solutions
* @access public
* @param array $data properties
* @return array channelInfo
*/
function channelCreate($data) {
if(!$this->runtime['selected']) { return $this->checkSelected(); }
$propertiesString = '';
foreach($data as $key => $value) {
$propertiesString .= ' '.$key.'='.$this->escapeText($value);
}
return $this->getData('array', 'channelcreate '.$propertiesString);
}
/**
* channelDelete
*
* Deletes an existing channel by ID. If force is set to 1, the channel will be deleted even if there are clients within. The clients will be kicked to the default channel with an appropriate reason message.
*
* @author Par0noid Solutions
* @access public
* @param integer $cid channelID
* @param integer $force {1|0} (default: 1)
* @return boolean success
*/
function channelDelete($cid, $force = 1) {
if(!$this->runtime['selected']) { return $this->checkSelected(); }
return $this->getData('boolean', 'channeldelete cid='.$cid.' force='.$force);
}
/**
* channelDelPerm
*
* Removes a set of specified permissions from a channel. Multiple permissions can be removed at once. A permission can be specified by permid or permsid.
*
* <b>Input-Array like this:</b>
* <code>
* $permissions = array();
* $permissions[] = 'permissionID';
* //or you could use
* $permissions[] = 'permissionName';
* </code>
*
* @author Par0noid Solutions
* @access public
* @param integer $cid channelID
* @param array $permissions permissions
* @return boolean success
*/
function channelDelPerm($cid, $permissions) {
if(!$this->runtime['selected']) { return $this->checkSelected(); }
$permissionArray = array();
if(count($permissions) > 0) {
foreach($permissions AS $value) {
$permissionArray[] = (is_numeric($value) ? 'permid=' : 'permsid=').$value;
}
return $this->getData('boolean', 'channeldelperm cid='.$cid.' '.implode('|', $permissionArray));
}else{
$this->addDebugLog('no permissions given');
return $this->generateOutput(false, array('Error: no permissions given'), false);
}
}
/**
* channelEdit
*
* Changes a channels configuration using given properties. Note that this command accepts multiple properties which means that you're able to change all settings of the channel specified with cid at once.
*
* <b>Input-Array like this:</b>
* <code>
* $data = array();
*
* $data['setting'] = 'value';
* $data['setting'] = 'value';
* </code>
*
* @author Par0noid Solutions
* @access public
* @param integer $cid $channelID
* @param array $data edited settings
* @return boolean success
*/
function channelEdit($cid, $data) {
if(!$this->runtime['selected']) { return $this->checkSelected(); }
$settingsString = '';
foreach($data as $key => $value) {
$settingsString .= ' '.$key.'='.$this->escapeText($value);
}
return $this->getData('boolean', 'channeledit cid='.$cid.$settingsString);
}
/**
* channelFind
*
* displays a list of channels matching a given name pattern.
*
* <b>Output:</b>
* <code>
* Array
* {
* [cid] => 2
* [channel_name] => Lobby
* }
* </code>
*
* @author Par0noid Solutions
* @access public
* @param string $pattern channelName
* @return array channelList
*/
function channelFind($pattern) {
if(!$this->runtime['selected']) { return $this->checkSelected(); }
return $this->getData('multi', 'channelfind pattern='.$this->escapeText($pattern));
}
/**
* channelGroupAdd
*
* Creates a new channel group using a given name and displays its ID. The optional type parameter can be used to create ServerQuery groups and template groups.
*
* <b>groupDbTypes:</b>
* <ol start="0">
* <li>template group (used for new virtual servers)</li>
* <li>regular group (used for regular clients)</li>
* <li>global query group (used for ServerQuery clients)</li>
* </ol>
*
* <b>Output:</b>
* <code>
* Array
* {
* [cgid] => 86
* }
* </code>
*
* @author Par0noid Solutions
* @access public
* @param integer $name groupName
* @param integer $type groupDbType [optional] (default: 1)
* @return boolean success
*/
function channelGroupAdd($name, $type = 1) {
if(!$this->runtime['selected']) { return $this->checkSelected(); }
return $this->getData('array', 'channelgroupadd name='.$this->escapeText($name).' type='.$type);
}
/**
* channelGroupAddPerm
*
* Adds a set of specified permissions to a channel group. Multiple permissions can be added by providing the two parameters of each permission. A permission can be specified by permid or permsid.
*
* <b>Input-Array like this:</b>
* <code>
* $permissions = array();
* $permissions['permissionID'] = 'permissionValue';
* //or you could use:
* $permissions['permissionName'] = 'permissionValue';
* </code>
*
* @author Par0noid Solutions
* @access public
* @param integer $cgid channelGroupID
* @param array $permissions permissions
* @return boolean success
*/
function channelGroupAddPerm($cgid, $permissions) {
if(!$this->runtime['selected']) { return $this->checkSelected(); }
if(count($permissions) > 0) {
//Permissions given
//Errorcollector
$errors = array();
//Split Permissions to prevent query from overload
$permissions = array_chunk($permissions, 50, true);
//Action for each splitted part of permission
foreach($permissions as $permission_part)
{
//Create command_string for each command that we could use implode later
$command_string = array();
foreach($permission_part as $key => $value)
{
$command_string[] = (is_numeric($key) ? "permid=" : "permsid=").$this->escapeText($key).' permvalue='.$value;
}
$result = $this->getData('boolean', 'channelgroupaddperm cgid='.$cgid.' '.implode('|', $command_string));
if(!$result['success'])
{
foreach($result['errors'] as $error)
{
$errors[] = $error;
}
}
}
if(count($errors) == 0) {
return $this->generateOutput(true, array(), true);
}else{
return $this->generateOutput(false, $errors, false);
}
}else{
// No permissions given
$this->addDebugLog('no permissions given');
return $this->generateOutput(false, array('Error: no permissions given'), false);
}
}
/**
* channelGroupClientList
*
* Displays all the client and/or channel IDs currently assigned to channel groups. All three parameters are optional so you're free to choose the most suitable combination for your requirement
*
* <b>Output:</b>
* <code>
* Array
* {
* [cid] => 2
* [cldbid] => 9
* [cgid] => 9
* }
* </code>
*
* @author Par0noid Solutions
* @access public
* @param integer $cid channelID [optional]
* @param integer $cldbid clientDBID [optional]
* @param integer $cgid channelGroupID [optional]
* @return array channelGroupClientList
*/
function channelGroupClientList($cid = NULL, $cldbid = NULL, $cgid = NULL) {
if(!$this->runtime['selected']) { return $this->checkSelected(); }
return $this->getData('multi', 'channelgroupclientlist'.(!empty($cid) ? ' cid='.$cid : '').(!empty($cldbid) ? ' cldbid='.$cldbid : '').(!empty($cgid) ? ' cgid='.$cgid : ''));
}
/**
* channelGroupCopy
*
* Creates a copy of the channel group specified with scgid. If tcgid is set to 0, the server will create a new group. To overwrite an existing group, simply set tcgid to the ID of a designated target group. If a target group is set, the name parameter will be ignored. The type parameter can be used to create ServerQuery groups and template groups.
*
* <b>groupDbTypes:</b>
* <ol start="0">
* <li>template group (used for new virtual servers)</li>
* <li>regular group (used for regular clients)</li>
* <li>global query group (used for ServerQuery clients)</li>
* </ol>
*
* <b>Output:</b>
* <code>
* Array
* {
* [cgid] => 86
* }
* </code>
*
* @author Par0noid Solutions
* @access public
* @param integer $scgid sourceChannelGroupID
* @param integer $tcgid targetChannelGroupID
* @param integer $name groupName
* @param integer $type groupDbType
* @return array groupId
*/
function channelGroupCopy($scgid, $tcgid, $name, $type = 1) {
if(!$this->runtime['selected']) { return $this->checkSelected(); }
return $this->getData('array', 'channelgroupcopy scgid='.$scgid.' tcgid='.$tcgid.' name='.$this->escapeText($name).' type='.$type);
}
/**
* channelGroupDelete
*
* Deletes a channel group by ID. If force is set to 1, the channel group will be deleted even if there are clients within.
*
* @author Par0noid Solutions
* @access public
* @param integer $cgid channelGroupID
* @param integer $force forces deleting channelGroup (default: 1)
* @return boolean success
*/
function channelGroupDelete($cgid, $force = 1) {
if(!$this->runtime['selected']) { return $this->checkSelected(); }
return $this->getData('boolean', 'channelgroupdel cgid='.$cgid.' force='.$force);
}
/**
* channelGroupDelPerm
*
* Removes a set of specified permissions from the channel group. Multiple permissions can be removed at once. A permission can be specified by permid or permsid.
*
* <b>Input-Array like this:</b>
* <code>
* $permissions = array();
* $permissions[] = 'permissionID';
* $permissions[] = 'permissionName';
* </code>
*
* @author Par0noid Solutions
* @access public
* @param integer $cgid channelGroupID
* @param array $permissions permissions
* @return boolean success
*/
function channelGroupDelPerm($cgid, $permissions) {
if(!$this->runtime['selected']) { return $this->checkSelected(); }
$permissionArray = array();
if(count($permissions) > 0) {
foreach($permissions AS $value) {
$permissionArray[] = (is_numeric($value) ? 'permid=' : 'permsid=').$value;
}
return $this->getData('boolean', 'channelgroupdelperm cgid='.$cgid.' '.implode('|', $permissionArray));
}else{
$this->addDebugLog('no permissions given');
return $this->generateOutput(false, array('Error: no permissions given'), false);
}
}
/**
* channelGroupList
*
* Displays a list of channel groups available on the selected virtual server.
*
* <b>Output:</b>
* <code>
* Array
* {
* [cgid] => 3
* [name] => Testname
* [type] => 0
* [iconid] => 100
* [savedb] => 1
* [sortid] => 0
* [namemode] => 0
* [n_modifyp] => 75
* [n_member_addp] => 50
* [n_member_removep] => 50
* }
* </code>
*
* @author Par0noid Solutions
* @access public
* @return array channelGroupList
*/
function channelGroupList() {
if(!$this->runtime['selected']) { return $this->checkSelected(); }
return $this->getData('multi', 'channelgrouplist');
}
/**
* channelGroupPermList
*
* Displays a list of permissions assigned to the channel group specified with cgid.
* If the permsid option is specified, the output will contain the permission names instead of the internal IDs.
*
* <b>Output:</b>
* <code>
* Array
* {
* [permid] => 8471 (displayed if permsid is false)
* [permsid] => i_channel_create_modify_with_codec_latency_factor_min (displayed if permsid is true)
* [permvalue] => 1
* [permnegated] => 0
* [permskip] => 0
* }
* </code>
*
* @author Par0noid Solutions
* @access public
* @param integer $cgid channelGroupID
* @param boolean $permsid permsid
* @return array channelGroupPermlist
*/
function channelGroupPermList($cgid, $permsid = false) {
if(!$this->runtime['selected']) { return $this->checkSelected(); }
return $this->getData('multi', 'channelgrouppermlist cgid='.$cgid.($permsid ? ' -permsid' : ''));
}
/**
* channelGroupRename
*
* Changes the name of a specified channel group.
*
* @author Par0noid Solutions
* @access public
* @param integer $cgid groupID
* @param integer $name groupName
* @return boolean success
*/
function channelGroupRename($cgid, $name) {
if(!$this->runtime['selected']) { return $this->checkSelected(); }
return $this->getData('boolean', 'channelgrouprename cgid='.$cgid.' name='.$this->escapeText($name));
}
/**
* channelInfo
*
* Displays detailed configuration information about a channel including ID, topic, description, etc.
* <b>Output:</b>
* <code>
* Array
* {
* [pid] => 0
* [channel_name] => Test
* [channel_topic] =>
* [channel_description] =>
* [channel_password] => cc97Pm4oOYq0J9fXDAgiWv/qScQ=
* [channel_codec] => 2
* [channel_codec_quality] => 7
* [channel_maxclients] => -1
* [channel_maxfamilyclients] => -1
* [channel_order] => 1
* [channel_flag_permanent] => 1
* [channel_flag_semi_permanent] => 0
* [channel_flag_default] => 0
* [channel_flag_password] => 0
* [channel_codec_latency_factor] => 1
* [channel_codec_is_unencrypted] => 1
* [channel_flag_maxclients_unlimited] => 1
* [channel_flag_maxfamilyclients_unlimited] => 0
* [channel_flag_maxfamilyclients_inherited] => 1
* [channel_filepath] => files\\virtualserver_1\\channel_2
* [channel_needed_talk_power] => 0
* [channel_forced_silence] => 0
* [channel_name_phonetic] =>
* [channel_icon_id] => 0
* [seconds_empty] => 61 (If it's a temporary channel with a channel delete delay)
* }
* </code>
*
* @author Par0noid Solutions
* @access public
* @param integer $cid channelID
* @return array channelInfo
*/
function channelInfo($cid) {
if(!$this->runtime['selected']) { return $this->checkSelected(); }
return $this->getData('array', 'channelinfo cid='.$cid);
}
/**
* channelList
*
* Displays a list of channels created on a virtual server including their ID, order, name, etc. The output can be modified using several command options.
*
* <br><b>Possible parameters:</b> [-topic] [-flags] [-voice] [-limits] [-icon]<br><br>
*
* <b>Output: (without parameters)</b>
* <code>
* Array
* {
* [cid] => 2
* [pid] => 0
* [channel_order] => 1
* [channel_name] => Test
* [total_clients] => 0
* [channel_needed_subscribe_power] => 0
* }
* </code><br>
* <b>Output: (from parameters)</b>
* <code>
* Array
* {
* [-topic] => [channel_topic] => Default Channel has no topic
* [-flags] => [channel_flag_default] => 1
* [-flags] => [channel_flag_password] => 0
* [-flags] => [channel_flag_permanent] => 1
* [-flags] => [channel_flag_semi_permanent] => 0
* [-voice] => [channel_codec] => 2
* [-voice] => [channel_codec_quality] => 7
* [-voice] => [channel_needed_talk_power] => 0
* [-limits] => [total_clients_family] => 1
* [-limits] => [channel_maxclients] => -1
* [-limits] => [channel_maxfamilyclients] => -1
* [-icon] => [channel_icon_id] => 0
* }
* </code><br>
* <b>Usage:</b>
* <code>
* $ts3->channelList(); //No parameters
* $ts3->channelList("-flags"); //Single parameter
* $ts3->channelList("-topic -flags -voice -limits -icon"); //Multiple parameters / all
* </code><br>
*
* @author Par0noid Solutions
* @access public
* @param string $params additional parameters [optional]
* @return array channelList
*/
function channelList($params = null) {
if(!$this->runtime['selected']) { return $this->checkSelected(); }
if(!empty($params)) { $params = ' '.$params; }
return $this->getData('multi', 'channellist'.$params);
}