ts3admin.class.php


SUBMITTED BY: Todlich

DATE: Aug. 13, 2016, 6:27 p.m.

FORMAT: Text only

SIZE: 67.5 kB

HITS: 949

  1. <?PHP
  2. /**
  3. * ts3admin.class.php
  4. * ------------------
  5. * begin : 18. December 2009
  6. * copyright : (C) 2009-2013 Par0noid Solutions
  7. * email : contact@ts3admin.info
  8. * version : 0.7.0.0
  9. * last modified : 28. January 2014
  10. *
  11. *
  12. * This file is a powerful library for querying TeamSpeak3 servers.
  13. *
  14. * This program is free software: you can redistribute it and/or modify
  15. * it under the terms of the GNU General Public License as published by
  16. * the Free Software Foundation, either version 3 of the License, or
  17. * (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  26. */
  27. /**
  28. * The ts3admin.class.php is a powerful library that offers functions to communicate with Teamspeak 3 Servers from your website!
  29. *
  30. * You can do everything, your creativity knows no bounds!
  31. * That library is faster than all other librarys because its optimized to find the shortest way to your information.
  32. * No unneeded PHP 5 OOP Stuff, just the basics!
  33. * There are a lot of professional developers and some big companys using my library.
  34. * The best thing is that you can use it for free under the terms of the GNU General Public License v3.
  35. * Take a look on the project website where you can find code examples, a manual and some other stuff.
  36. *
  37. * @author Par0noid Solutions <contact@ts3admin.info>
  38. * @version 0.7.0.0
  39. * @copyright Copyright (c) 2009-2014, Stefan Z.
  40. * @package ts3admin
  41. * @link http://ts3admin.info
  42. */
  43. class ts3admin {
  44. //*******************************************************************************************
  45. //****************************************** Vars *******************************************
  46. //*******************************************************************************************
  47. /**
  48. * runtime is an private handle and configuration storage
  49. *
  50. * @author Par0noid Solutions
  51. * @access private
  52. */
  53. private $runtime = array('socket' => '', 'selected' => false, 'host' => '', 'queryport' => '10011', 'timeout' => 2, 'debug' => array(), 'fileSocket' => '');
  54. //*******************************************************************************************
  55. //************************************ Public Functions *************************************
  56. //******************************************************************************************
  57. /**
  58. * banAddByIp
  59. *
  60. * Adds a new ban rule on the selected virtual server.
  61. *
  62. * <b>Output:</b>
  63. * <code>
  64. * Array
  65. * {
  66. * [banid] => 109
  67. * }
  68. * </code>
  69. *
  70. * @author Par0noid Solutions
  71. * @access public
  72. * @param string $ip clientIp
  73. * @param integer $time bantime in seconds (0=unlimited)
  74. * @param string $banreason Banreason [optional]
  75. * @return array banId
  76. */
  77. function banAddByIp($ip, $time, $banreason = NULL) {
  78. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  79. if(!empty($banreason)) { $msg = ' banreason='.$this->escapeText($banreason); } else { $msg = NULL; }
  80. return $this->getData('array', 'banadd ip='.$ip.' time='.$time.$msg);
  81. }
  82. /**
  83. * banAddByUid
  84. *
  85. * Adds a new ban rule on the selected virtual server.
  86. *
  87. * <b>Output:</b>
  88. * <code>
  89. * Array
  90. * {
  91. * [banid] => 110
  92. * }
  93. * </code>
  94. *
  95. * @author Par0noid Solutions
  96. * @access public
  97. * @param string $uid clientUniqueId
  98. * @param integer $time bantime in seconds (0=unlimited)
  99. * @param string $banreason Banreason [optional]
  100. * @return array banId
  101. */
  102. function banAddByUid($uid, $time, $banreason = NULL) {
  103. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  104. if(!empty($banreason)) { $msg = ' banreason='.$this->escapeText($banreason); } else { $msg = NULL; }
  105. return $this->getData('array', 'banadd uid='.$uid.' time='.$time.$msg);
  106. }
  107. /**
  108. * banAddByName
  109. *
  110. * Adds a new ban rule on the selected virtual server.
  111. *
  112. * <b>Output:</b>
  113. * <code>
  114. * Array
  115. * {
  116. * [banid] => 111
  117. * }
  118. * </code>
  119. *
  120. * @author Par0noid Solutions
  121. * @access public
  122. * @param string $name clientName
  123. * @param integer $time bantime in seconds (0=unlimited)
  124. * @param string $banreason Banreason [optional]
  125. * @return array banId
  126. */
  127. function banAddByName($name, $time, $banreason = NULL) {
  128. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  129. if(!empty($banreason)) { $msg = ' banreason='.$this->escapeText($banreason); } else { $msg = NULL; }
  130. return $this->getData('array', 'banadd name='.$this->escapeText($name).' time='.$time.$msg);
  131. }
  132. /**
  133. * banClient
  134. *
  135. * 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.
  136. *
  137. * <b>Output:</b>
  138. * <code>
  139. * Array
  140. * {
  141. * [1] => 129
  142. * [2] => 130
  143. * }
  144. * </code>
  145. *
  146. * @author Par0noid Solutions
  147. * @access public
  148. * @param integer $clid clientId
  149. * @param integer $time bantime in seconds (0=unlimited)
  150. * @param string $banreason Banreason [optional]
  151. * @return array banIds
  152. */
  153. function banClient($clid, $time, $banreason = NULL) {
  154. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  155. if(!empty($banreason)) { $msg = ' banreason='.$this->escapeText($banreason); } else { $msg = ''; }
  156. $result = $this->getData('plain', 'banclient clid='.$clid.' time='.$time.$msg);
  157. if($result['success']) {
  158. return $this->generateOutput(true, $result['errors'], $this->splitBanIds($result['data']));
  159. }else{
  160. return $this->generateOutput(false, $result['errors'], false);
  161. }
  162. }
  163. /**
  164. * banDelete
  165. *
  166. * Deletes the ban rule with ID banid from the server.
  167. *
  168. * @author Par0noid Solutions
  169. * @access public
  170. * @param integer $banID banID
  171. * @return boolean success
  172. */
  173. function banDelete($banID) {
  174. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  175. return $this->getData('boolean', 'bandel banid='.$banID);
  176. }
  177. /**
  178. * banDeleteAll
  179. *
  180. * Deletes all active ban rules from the server.
  181. *
  182. * @author Par0noid Solutions
  183. * @access public
  184. * @return boolean success
  185. */
  186. function banDeleteAll() {
  187. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  188. return $this->getData('boolean', 'bandelall');
  189. }
  190. /**
  191. * banList
  192. *
  193. * Displays a list of active bans on the selected virtual server.
  194. *
  195. * <b>Output:</b>
  196. * <code>
  197. * Array
  198. * {
  199. * [banid] => 131
  200. * [ip] => 1.2.3.4
  201. * [name] => eugen
  202. * [uid] => IYAntAcZHgVC7s3n3DNWmuJB/aM=
  203. * [created] => 1286660391
  204. * [duration] => 0
  205. * [invokername] => Par0noid
  206. * [invokercldbid] => 2086
  207. * [invokeruid] => nUixbsq/XakrrmbqU8O30R/D8Gc=
  208. * [reason] => insult
  209. * [enforcements] => 0
  210. * }
  211. * </code>
  212. *
  213. * @author Par0noid Solutions
  214. * @access public
  215. * @return array banlist
  216. */
  217. function banList() {
  218. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  219. return $this->getData('multi', 'banlist');
  220. }
  221. /**
  222. * bindingList
  223. *
  224. * Displays a list of IP addresses used by the server instance on multi-homed machines.
  225. *
  226. * <b>Output:</b><br>
  227. * <code>
  228. * Array
  229. * {
  230. * [ip] => 0.0.0.0
  231. * }
  232. * </code>
  233. *
  234. * @author Par0noid Solutions
  235. * @access public
  236. * @return array bindingList
  237. */
  238. function bindingList() {
  239. return $this->getData('multi', 'bindinglist');
  240. }
  241. /**
  242. * channelAddPerm
  243. *
  244. * 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.
  245. *
  246. * <b>Input-Array like this:</b>
  247. * <code>
  248. * $permissions = array();
  249. * $permissions['permissionID'] = 'permissionValue';
  250. * //or you could use Permission Name
  251. * $permissions['permissionName'] = 'permissionValue';
  252. * </code>
  253. *
  254. * @author Par0noid Solutions
  255. * @access public
  256. * @param integer $cid channelId
  257. * @param array $permissions permissions
  258. * @return boolean success
  259. */
  260. function channelAddPerm($cid, $permissions) {
  261. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  262. if(count($permissions) > 0) {
  263. //Permissions given
  264. //Errorcollector
  265. $errors = array();
  266. //Split Permissions to prevent query from overload
  267. $permissions = array_chunk($permissions, 50, true);
  268. //Action for each splitted part of permission
  269. foreach($permissions as $permission_part)
  270. {
  271. //Create command_string for each command that we could use implode later
  272. $command_string = array();
  273. foreach($permission_part as $key => $value)
  274. {
  275. $command_string[] = (is_numeric($key) ? "permid=" : "permsid=").$this->escapeText($key).' permvalue='.$value;
  276. }
  277. $result = $this->getData('boolean', 'channeladdperm cid='.$cid.' '.implode('|', $command_string));
  278. if(!$result['success'])
  279. {
  280. foreach($result['errors'] as $error)
  281. {
  282. $errors[] = $error;
  283. }
  284. }
  285. }
  286. if(count($errors) == 0)
  287. {
  288. return $this->generateOutput(true, array(), true);
  289. }else{
  290. return $this->generateOutput(false, $errors, false);
  291. }
  292. }else{
  293. // No permissions given
  294. $this->addDebugLog('no permissions given');
  295. return $this->generateOutput(false, array('Error: no permissions given'), false);
  296. }
  297. }
  298. /**
  299. * channelClientAddPerm
  300. *
  301. * 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.
  302. *
  303. * <b>Input-Array like this:</b>
  304. * <code>
  305. * $permissions = array();
  306. * $permissions['permissionID'] = 'permissionValue';
  307. * //or you could use Permission Name
  308. * $permissions['permissionName'] = 'permissionValue';
  309. * </code>
  310. *
  311. * @author Par0noid Solutions
  312. * @access public
  313. * @param integer $cid channelID
  314. * @param integer $cldbid clientDBID
  315. * @param array $permissions permissions
  316. * @return boolean success
  317. */
  318. function channelClientAddPerm($cid, $cldbid, $permissions) {
  319. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  320. if(count($permissions) > 0) {
  321. //Permissions given
  322. //Errorcollector
  323. $errors = array();
  324. //Split Permissions to prevent query from overload
  325. $permissions = array_chunk($permissions, 50, true);
  326. //Action for each splitted part of permission
  327. foreach($permissions as $permission_part)
  328. {
  329. //Create command_string for each command that we could use implode later
  330. $command_string = array();
  331. foreach($permission_part as $key => $value)
  332. {
  333. $command_string[] = (is_numeric($key) ? "permid=" : "permsid=").$this->escapeText($key).' permvalue='.$value;
  334. }
  335. $result = $this->getData('boolean', 'channelclientaddperm cid='.$cid.' cldbid='.$cldbid.' '.implode('|', $command_string));
  336. if(!$result['success'])
  337. {
  338. foreach($result['errors'] as $error)
  339. {
  340. $errors[] = $error;
  341. }
  342. }
  343. }
  344. if(count($errors) == 0)
  345. {
  346. return $this->generateOutput(true, array(), true);
  347. }else{
  348. return $this->generateOutput(false, $errors, false);
  349. }
  350. }else{
  351. // No permissions given
  352. $this->addDebugLog('no permissions given');
  353. return $this->generateOutput(false, array('Error: no permissions given'), false);
  354. }
  355. }
  356. /**
  357. * channelClientDelPerm
  358. *
  359. * 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.
  360. *
  361. * <b>Input-Array like this:</b>
  362. * <code>
  363. * $permissions = array();
  364. * $permissions[] = 'permissionID';
  365. * $permissions[] = 'permissionName';
  366. * //or
  367. * $permissions = array('permissionID', 'permissionName', 'permissionID');
  368. * </code>
  369. *
  370. * @author Par0noid Solutions
  371. * @access public
  372. * @param integer $cid channelID
  373. * @param integer $cldbid clientDBID
  374. * @param array $permissions permissions
  375. * @return boolean success
  376. */
  377. function channelClientDelPerm($cid, $cldbid, $permissions) {
  378. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  379. $permissionArray = array();
  380. if(count($permissions) > 0) {
  381. foreach($permissions AS $value) {
  382. $permissionArray[] = is_numeric($value) ? 'permid='.$value : 'permsid='.$value;
  383. }
  384. return $this->getData('boolean', 'channelclientdelperm cid='.$cid.' cldbid='.$cldbid.' '.implode('|', $permissionArray));
  385. }else{
  386. $this->addDebugLog('no permissions given');
  387. return $this->generateOutput(false, array('Error: no permissions given'), false);
  388. }
  389. }
  390. /**
  391. * channelClientPermList
  392. *
  393. * Displays a list of permissions defined for a client in a specific channel.
  394. *
  395. * <b>Output:</b><br>
  396. * <code>
  397. * Array
  398. * {
  399. * [cid] => 250 (only in first result)
  400. * [cldbid] => 2086 (only in first result)
  401. * [permid] => 12876 (if permsid = false)
  402. * [permsid] => b_client_info_view (if permsid = true)
  403. * [permvalue] => 1
  404. * [permnegated] => 0
  405. * [permskip] => 0
  406. * }
  407. * </code>
  408. *
  409. * @author Par0noid Solutions
  410. * @access public
  411. * @param integer $cid channelID
  412. * @param integer $cldbid clientDBID
  413. * @param boolean $permsid displays permissionName instead of permissionID
  414. * @return array channelclientpermlist
  415. */
  416. function channelClientPermList($cid, $cldbid, $permsid = false) {
  417. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  418. return $this->getData('multi', 'channelclientpermlist cid='.$cid.' cldbid='.$cldbid.($permsid ? ' -permsid' : ''));
  419. }
  420. /**
  421. * channelCreate
  422. *
  423. * 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.
  424. *
  425. * <b style="color:red">Hint:</b> don't forget to set channel_flag_semi_permanent = 1 or channel_flag_permanent = 1
  426. *
  427. * <b style="color:red">Hint:</b> you'll get an error if you want to create a channel without channel_name
  428. *
  429. * <b>Input-Array like this:</b>
  430. * <code>
  431. * $data = array();
  432. *
  433. * $data['setting'] = 'value';
  434. * $data['setting'] = 'value';
  435. * </code>
  436. *
  437. * <b>Output:</b>
  438. * <code>
  439. * Array
  440. * {
  441. * [cid] => 257
  442. * }
  443. * </code>
  444. *
  445. * @author Par0noid Solutions
  446. * @access public
  447. * @param array $data properties
  448. * @return array channelInfo
  449. */
  450. function channelCreate($data) {
  451. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  452. $propertiesString = '';
  453. foreach($data as $key => $value) {
  454. $propertiesString .= ' '.$key.'='.$this->escapeText($value);
  455. }
  456. return $this->getData('array', 'channelcreate '.$propertiesString);
  457. }
  458. /**
  459. * channelDelete
  460. *
  461. * 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.
  462. *
  463. * @author Par0noid Solutions
  464. * @access public
  465. * @param integer $cid channelID
  466. * @param integer $force {1|0} (default: 1)
  467. * @return boolean success
  468. */
  469. function channelDelete($cid, $force = 1) {
  470. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  471. return $this->getData('boolean', 'channeldelete cid='.$cid.' force='.$force);
  472. }
  473. /**
  474. * channelDelPerm
  475. *
  476. * 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.
  477. *
  478. * <b>Input-Array like this:</b>
  479. * <code>
  480. * $permissions = array();
  481. * $permissions[] = 'permissionID';
  482. * //or you could use
  483. * $permissions[] = 'permissionName';
  484. * </code>
  485. *
  486. * @author Par0noid Solutions
  487. * @access public
  488. * @param integer $cid channelID
  489. * @param array $permissions permissions
  490. * @return boolean success
  491. */
  492. function channelDelPerm($cid, $permissions) {
  493. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  494. $permissionArray = array();
  495. if(count($permissions) > 0) {
  496. foreach($permissions AS $value) {
  497. $permissionArray[] = (is_numeric($value) ? 'permid=' : 'permsid=').$value;
  498. }
  499. return $this->getData('boolean', 'channeldelperm cid='.$cid.' '.implode('|', $permissionArray));
  500. }else{
  501. $this->addDebugLog('no permissions given');
  502. return $this->generateOutput(false, array('Error: no permissions given'), false);
  503. }
  504. }
  505. /**
  506. * channelEdit
  507. *
  508. * 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.
  509. *
  510. * <b>Input-Array like this:</b>
  511. * <code>
  512. * $data = array();
  513. *
  514. * $data['setting'] = 'value';
  515. * $data['setting'] = 'value';
  516. * </code>
  517. *
  518. * @author Par0noid Solutions
  519. * @access public
  520. * @param integer $cid $channelID
  521. * @param array $data edited settings
  522. * @return boolean success
  523. */
  524. function channelEdit($cid, $data) {
  525. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  526. $settingsString = '';
  527. foreach($data as $key => $value) {
  528. $settingsString .= ' '.$key.'='.$this->escapeText($value);
  529. }
  530. return $this->getData('boolean', 'channeledit cid='.$cid.$settingsString);
  531. }
  532. /**
  533. * channelFind
  534. *
  535. * displays a list of channels matching a given name pattern.
  536. *
  537. * <b>Output:</b>
  538. * <code>
  539. * Array
  540. * {
  541. * [cid] => 2
  542. * [channel_name] => Lobby
  543. * }
  544. * </code>
  545. *
  546. * @author Par0noid Solutions
  547. * @access public
  548. * @param string $pattern channelName
  549. * @return array channelList
  550. */
  551. function channelFind($pattern) {
  552. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  553. return $this->getData('multi', 'channelfind pattern='.$this->escapeText($pattern));
  554. }
  555. /**
  556. * channelGroupAdd
  557. *
  558. * 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.
  559. *
  560. * <b>groupDbTypes:</b>
  561. * <ol start="0">
  562. * <li>template group (used for new virtual servers)</li>
  563. * <li>regular group (used for regular clients)</li>
  564. * <li>global query group (used for ServerQuery clients)</li>
  565. * </ol>
  566. *
  567. * <b>Output:</b>
  568. * <code>
  569. * Array
  570. * {
  571. * [cgid] => 86
  572. * }
  573. * </code>
  574. *
  575. * @author Par0noid Solutions
  576. * @access public
  577. * @param integer $name groupName
  578. * @param integer $type groupDbType [optional] (default: 1)
  579. * @return boolean success
  580. */
  581. function channelGroupAdd($name, $type = 1) {
  582. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  583. return $this->getData('array', 'channelgroupadd name='.$this->escapeText($name).' type='.$type);
  584. }
  585. /**
  586. * channelGroupAddPerm
  587. *
  588. * 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.
  589. *
  590. * <b>Input-Array like this:</b>
  591. * <code>
  592. * $permissions = array();
  593. * $permissions['permissionID'] = 'permissionValue';
  594. * //or you could use:
  595. * $permissions['permissionName'] = 'permissionValue';
  596. * </code>
  597. *
  598. * @author Par0noid Solutions
  599. * @access public
  600. * @param integer $cgid channelGroupID
  601. * @param array $permissions permissions
  602. * @return boolean success
  603. */
  604. function channelGroupAddPerm($cgid, $permissions) {
  605. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  606. if(count($permissions) > 0) {
  607. //Permissions given
  608. //Errorcollector
  609. $errors = array();
  610. //Split Permissions to prevent query from overload
  611. $permissions = array_chunk($permissions, 50, true);
  612. //Action for each splitted part of permission
  613. foreach($permissions as $permission_part)
  614. {
  615. //Create command_string for each command that we could use implode later
  616. $command_string = array();
  617. foreach($permission_part as $key => $value)
  618. {
  619. $command_string[] = (is_numeric($key) ? "permid=" : "permsid=").$this->escapeText($key).' permvalue='.$value;
  620. }
  621. $result = $this->getData('boolean', 'channelgroupaddperm cgid='.$cgid.' '.implode('|', $command_string));
  622. if(!$result['success'])
  623. {
  624. foreach($result['errors'] as $error)
  625. {
  626. $errors[] = $error;
  627. }
  628. }
  629. }
  630. if(count($errors) == 0) {
  631. return $this->generateOutput(true, array(), true);
  632. }else{
  633. return $this->generateOutput(false, $errors, false);
  634. }
  635. }else{
  636. // No permissions given
  637. $this->addDebugLog('no permissions given');
  638. return $this->generateOutput(false, array('Error: no permissions given'), false);
  639. }
  640. }
  641. /**
  642. * channelGroupClientList
  643. *
  644. * 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
  645. *
  646. * <b>Output:</b>
  647. * <code>
  648. * Array
  649. * {
  650. * [cid] => 2
  651. * [cldbid] => 9
  652. * [cgid] => 9
  653. * }
  654. * </code>
  655. *
  656. * @author Par0noid Solutions
  657. * @access public
  658. * @param integer $cid channelID [optional]
  659. * @param integer $cldbid clientDBID [optional]
  660. * @param integer $cgid channelGroupID [optional]
  661. * @return array channelGroupClientList
  662. */
  663. function channelGroupClientList($cid = NULL, $cldbid = NULL, $cgid = NULL) {
  664. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  665. return $this->getData('multi', 'channelgroupclientlist'.(!empty($cid) ? ' cid='.$cid : '').(!empty($cldbid) ? ' cldbid='.$cldbid : '').(!empty($cgid) ? ' cgid='.$cgid : ''));
  666. }
  667. /**
  668. * channelGroupCopy
  669. *
  670. * 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.
  671. *
  672. * <b>groupDbTypes:</b>
  673. * <ol start="0">
  674. * <li>template group (used for new virtual servers)</li>
  675. * <li>regular group (used for regular clients)</li>
  676. * <li>global query group (used for ServerQuery clients)</li>
  677. * </ol>
  678. *
  679. * <b>Output:</b>
  680. * <code>
  681. * Array
  682. * {
  683. * [cgid] => 86
  684. * }
  685. * </code>
  686. *
  687. * @author Par0noid Solutions
  688. * @access public
  689. * @param integer $scgid sourceChannelGroupID
  690. * @param integer $tcgid targetChannelGroupID
  691. * @param integer $name groupName
  692. * @param integer $type groupDbType
  693. * @return array groupId
  694. */
  695. function channelGroupCopy($scgid, $tcgid, $name, $type = 1) {
  696. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  697. return $this->getData('array', 'channelgroupcopy scgid='.$scgid.' tcgid='.$tcgid.' name='.$this->escapeText($name).' type='.$type);
  698. }
  699. /**
  700. * channelGroupDelete
  701. *
  702. * Deletes a channel group by ID. If force is set to 1, the channel group will be deleted even if there are clients within.
  703. *
  704. * @author Par0noid Solutions
  705. * @access public
  706. * @param integer $cgid channelGroupID
  707. * @param integer $force forces deleting channelGroup (default: 1)
  708. * @return boolean success
  709. */
  710. function channelGroupDelete($cgid, $force = 1) {
  711. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  712. return $this->getData('boolean', 'channelgroupdel cgid='.$cgid.' force='.$force);
  713. }
  714. /**
  715. * channelGroupDelPerm
  716. *
  717. * 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.
  718. *
  719. * <b>Input-Array like this:</b>
  720. * <code>
  721. * $permissions = array();
  722. * $permissions[] = 'permissionID';
  723. * $permissions[] = 'permissionName';
  724. * </code>
  725. *
  726. * @author Par0noid Solutions
  727. * @access public
  728. * @param integer $cgid channelGroupID
  729. * @param array $permissions permissions
  730. * @return boolean success
  731. */
  732. function channelGroupDelPerm($cgid, $permissions) {
  733. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  734. $permissionArray = array();
  735. if(count($permissions) > 0) {
  736. foreach($permissions AS $value) {
  737. $permissionArray[] = (is_numeric($value) ? 'permid=' : 'permsid=').$value;
  738. }
  739. return $this->getData('boolean', 'channelgroupdelperm cgid='.$cgid.' '.implode('|', $permissionArray));
  740. }else{
  741. $this->addDebugLog('no permissions given');
  742. return $this->generateOutput(false, array('Error: no permissions given'), false);
  743. }
  744. }
  745. /**
  746. * channelGroupList
  747. *
  748. * Displays a list of channel groups available on the selected virtual server.
  749. *
  750. * <b>Output:</b>
  751. * <code>
  752. * Array
  753. * {
  754. * [cgid] => 3
  755. * [name] => Testname
  756. * [type] => 0
  757. * [iconid] => 100
  758. * [savedb] => 1
  759. * [sortid] => 0
  760. * [namemode] => 0
  761. * [n_modifyp] => 75
  762. * [n_member_addp] => 50
  763. * [n_member_removep] => 50
  764. * }
  765. * </code>
  766. *
  767. * @author Par0noid Solutions
  768. * @access public
  769. * @return array channelGroupList
  770. */
  771. function channelGroupList() {
  772. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  773. return $this->getData('multi', 'channelgrouplist');
  774. }
  775. /**
  776. * channelGroupPermList
  777. *
  778. * Displays a list of permissions assigned to the channel group specified with cgid.
  779. * If the permsid option is specified, the output will contain the permission names instead of the internal IDs.
  780. *
  781. * <b>Output:</b>
  782. * <code>
  783. * Array
  784. * {
  785. * [permid] => 8471 (displayed if permsid is false)
  786. * [permsid] => i_channel_create_modify_with_codec_latency_factor_min (displayed if permsid is true)
  787. * [permvalue] => 1
  788. * [permnegated] => 0
  789. * [permskip] => 0
  790. * }
  791. * </code>
  792. *
  793. * @author Par0noid Solutions
  794. * @access public
  795. * @param integer $cgid channelGroupID
  796. * @param boolean $permsid permsid
  797. * @return array channelGroupPermlist
  798. */
  799. function channelGroupPermList($cgid, $permsid = false) {
  800. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  801. return $this->getData('multi', 'channelgrouppermlist cgid='.$cgid.($permsid ? ' -permsid' : ''));
  802. }
  803. /**
  804. * channelGroupRename
  805. *
  806. * Changes the name of a specified channel group.
  807. *
  808. * @author Par0noid Solutions
  809. * @access public
  810. * @param integer $cgid groupID
  811. * @param integer $name groupName
  812. * @return boolean success
  813. */
  814. function channelGroupRename($cgid, $name) {
  815. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  816. return $this->getData('boolean', 'channelgrouprename cgid='.$cgid.' name='.$this->escapeText($name));
  817. }
  818. /**
  819. * channelInfo
  820. *
  821. * Displays detailed configuration information about a channel including ID, topic, description, etc.
  822. * <b>Output:</b>
  823. * <code>
  824. * Array
  825. * {
  826. * [pid] => 0
  827. * [channel_name] => Test
  828. * [channel_topic] =>
  829. * [channel_description] =>
  830. * [channel_password] => cc97Pm4oOYq0J9fXDAgiWv/qScQ=
  831. * [channel_codec] => 2
  832. * [channel_codec_quality] => 7
  833. * [channel_maxclients] => -1
  834. * [channel_maxfamilyclients] => -1
  835. * [channel_order] => 1
  836. * [channel_flag_permanent] => 1
  837. * [channel_flag_semi_permanent] => 0
  838. * [channel_flag_default] => 0
  839. * [channel_flag_password] => 0
  840. * [channel_codec_latency_factor] => 1
  841. * [channel_codec_is_unencrypted] => 1
  842. * [channel_flag_maxclients_unlimited] => 1
  843. * [channel_flag_maxfamilyclients_unlimited] => 0
  844. * [channel_flag_maxfamilyclients_inherited] => 1
  845. * [channel_filepath] => files\\virtualserver_1\\channel_2
  846. * [channel_needed_talk_power] => 0
  847. * [channel_forced_silence] => 0
  848. * [channel_name_phonetic] =>
  849. * [channel_icon_id] => 0
  850. * [seconds_empty] => 61 (If it's a temporary channel with a channel delete delay)
  851. * }
  852. * </code>
  853. *
  854. * @author Par0noid Solutions
  855. * @access public
  856. * @param integer $cid channelID
  857. * @return array channelInfo
  858. */
  859. function channelInfo($cid) {
  860. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  861. return $this->getData('array', 'channelinfo cid='.$cid);
  862. }
  863. /**
  864. * channelList
  865. *
  866. * 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.
  867. *
  868. * <br><b>Possible parameters:</b> [-topic] [-flags] [-voice] [-limits] [-icon]<br><br>
  869. *
  870. * <b>Output: (without parameters)</b>
  871. * <code>
  872. * Array
  873. * {
  874. * [cid] => 2
  875. * [pid] => 0
  876. * [channel_order] => 1
  877. * [channel_name] => Test
  878. * [total_clients] => 0
  879. * [channel_needed_subscribe_power] => 0
  880. * }
  881. * </code><br>
  882. * <b>Output: (from parameters)</b>
  883. * <code>
  884. * Array
  885. * {
  886. * [-topic] => [channel_topic] => Default Channel has no topic
  887. * [-flags] => [channel_flag_default] => 1
  888. * [-flags] => [channel_flag_password] => 0
  889. * [-flags] => [channel_flag_permanent] => 1
  890. * [-flags] => [channel_flag_semi_permanent] => 0
  891. * [-voice] => [channel_codec] => 2
  892. * [-voice] => [channel_codec_quality] => 7
  893. * [-voice] => [channel_needed_talk_power] => 0
  894. * [-limits] => [total_clients_family] => 1
  895. * [-limits] => [channel_maxclients] => -1
  896. * [-limits] => [channel_maxfamilyclients] => -1
  897. * [-icon] => [channel_icon_id] => 0
  898. * }
  899. * </code><br>
  900. * <b>Usage:</b>
  901. * <code>
  902. * $ts3->channelList(); //No parameters
  903. * $ts3->channelList("-flags"); //Single parameter
  904. * $ts3->channelList("-topic -flags -voice -limits -icon"); //Multiple parameters / all
  905. * </code><br>
  906. *
  907. * @author Par0noid Solutions
  908. * @access public
  909. * @param string $params additional parameters [optional]
  910. * @return array channelList
  911. */
  912. function channelList($params = null) {
  913. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  914. if(!empty($params)) { $params = ' '.$params; }
  915. return $this->getData('multi', 'channellist'.$params);
  916. }
  917. /**
  918. * channelMove
  919. *
  920. * Moves a channel to a new parent channel with the ID cpid. If order is specified, the channel will be sorted right under the channel with the specified ID. If order is set to 0, the channel will be sorted right below the new parent.
  921. *
  922. * @author Par0noid Solutions
  923. * @access public
  924. * @param integer $cid channelID
  925. * @param integer $cpid channelParentID
  926. * @param integer $order channelSortOrder
  927. * @return boolean success
  928. */
  929. function channelMove($cid, $cpid, $order = null) {
  930. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  931. return $this->getData('boolean', 'channelmove cid='.$cid.' cpid='.$cpid.($order != null ? ' order='.$order : ''));
  932. }
  933. /**
  934. * channelPermList
  935. *
  936. * Displays a list of permissions defined for a channel.
  937. *
  938. * <b>Output:</b>
  939. * <code>
  940. * Array
  941. * {
  942. * [cid] => 2 (only in first result)
  943. * [permid] => 8471 (if permsid = false)
  944. * [permsid] => i_channel_needed_delete_power (if permsid = true)
  945. * [permvalue] => 1
  946. * [permnegated] => 0
  947. * [permskip] => 0
  948. * }
  949. * </code>
  950. *
  951. * @author Par0noid Solutions
  952. * @access public
  953. * @param integer $cid channelID
  954. * @param boolean $permsid displays permissionName instead of permissionID [optional]
  955. * @return array channelpermlist
  956. */
  957. function channelPermList($cid, $permsid = false) {
  958. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  959. return $this->getData('multi', 'channelpermlist cid='.$cid.($permsid ? ' -permsid' : ''));
  960. }
  961. /**
  962. * clientAddPerm
  963. *
  964. * Adds a set of specified permissions to a client. Multiple permissions can be added by providing the three parameters of each permission. A permission can be specified by permid or permsid.
  965. *
  966. * <b>Input-Array like this:</b>
  967. * <code>
  968. * $permissions = array();
  969. * $permissions['permissionID'] = array('permissionValue', 'permskip');
  970. * //or you could use Permission Name
  971. * $permissions['permissionName'] = array('permissionValue', 'permskip');
  972. * </code>
  973. *
  974. * @author Par0noid Solutions
  975. * @access public
  976. * @param integer $cldbid clientDBID
  977. * @param array $permissions permissions
  978. * @return boolean success
  979. */
  980. function clientAddPerm($cldbid, $permissions) {
  981. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  982. if(count($permissions) > 0) {
  983. //Permissions given
  984. //Errorcollector
  985. $errors = array();
  986. //Split Permissions to prevent query from overload
  987. $permissions = array_chunk($permissions, 50, true);
  988. //Action for each splitted part of permission
  989. foreach($permissions as $permission_part)
  990. {
  991. //Create command_string for each command that we could use implode later
  992. $command_string = array();
  993. foreach($permission_part as $key => $value)
  994. {
  995. $command_string[] = (is_numeric($key) ? "permid=" : "permsid=").$this->escapeText($key).' permvalue='.$this->escapeText($value[0]).' permskip='.$this->escapeText($value[1]);
  996. }
  997. $result = $this->getData('boolean', 'clientaddperm cldbid='.$cldbid.' '.implode('|', $command_string));
  998. if(!$result['success'])
  999. {
  1000. foreach($result['errors'] as $error)
  1001. {
  1002. $errors[] = $error;
  1003. }
  1004. }
  1005. }
  1006. if(count($errors) == 0)
  1007. {
  1008. return $this->generateOutput(true, array(), true);
  1009. }else{
  1010. return $this->generateOutput(false, $errors, false);
  1011. }
  1012. }else{
  1013. // No permissions given
  1014. $this->addDebugLog('no permissions given');
  1015. return $this->generateOutput(false, array('Error: no permissions given'), false);
  1016. }
  1017. }
  1018. /**
  1019. * clientDbDelete
  1020. *
  1021. * Deletes a clients properties from the database.
  1022. *
  1023. * @author Par0noid Solutions
  1024. * @access public
  1025. * @param integer $cldbid clientDBID
  1026. * @return boolean success
  1027. */
  1028. function clientDbDelete($cldbid) {
  1029. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  1030. return $this->getData('boolean', 'clientdbdelete cldbid='.$cldbid);
  1031. }
  1032. /**
  1033. * clientDbEdit
  1034. *
  1035. * Changes a clients settings using given properties.
  1036. *
  1037. * <b>Input-Array like this:</b><br>
  1038. * <br><code>
  1039. * $data = array();
  1040. *
  1041. * $data['property'] = 'value';
  1042. * $data['property'] = 'value';
  1043. * </code>
  1044. *
  1045. * @author Par0noid Solutions
  1046. * @access public
  1047. * @param integer $cldbid clientDBID
  1048. * @param array $data clientProperties
  1049. * @return boolean success
  1050. */
  1051. function clientDbEdit($cldbid, $data) {
  1052. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  1053. $settingsString = '';
  1054. foreach($data as $key => $value) {
  1055. $settingsString .= ' '.$key.'='.$this->escapeText($value);
  1056. }
  1057. return $this->getData('boolean', 'clientdbedit cldbid='.$cldbid.$settingsString);
  1058. }
  1059. /**
  1060. * clientDbFind
  1061. *
  1062. * Displays a list of client database IDs matching a given pattern. You can either search for a clients last known nickname or his unique identity by using the -uid option.
  1063. *
  1064. * <b>Output:</b><br>
  1065. * <code>
  1066. * Array
  1067. * {
  1068. * [cldbid] => 2
  1069. * }
  1070. * </code>
  1071. *
  1072. * @author Par0noid Solutions
  1073. * @access public
  1074. * @param string $pattern clientName
  1075. * @param boolean $uid set true to add -uid param [optional]
  1076. * @return array clientList
  1077. */
  1078. function clientDbFind($pattern, $uid = false) {
  1079. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  1080. return $this->getData('multi', 'clientdbfind pattern='.$this->escapeText($pattern).($uid ? ' -uid' : ''));
  1081. }
  1082. /**
  1083. * clientDbInfo
  1084. *
  1085. * Displays detailed database information about a client including unique ID, creation date, etc.
  1086. *
  1087. * <b>Output:</b>
  1088. * <code>
  1089. * Array
  1090. * {
  1091. * [client_unique_identifier] => nUixbsq/XakrrmbqU8O30R/D8Gc=
  1092. * [client_nickname] => par0noid
  1093. * [client_database_id] => 2
  1094. * [client_created] => 1361027850
  1095. * [client_lastconnected] => 1361027850
  1096. * [client_totalconnections] => 1
  1097. * [client_flag_avatar] =>
  1098. * [client_description] =>
  1099. * [client_month_bytes_uploaded] => 0
  1100. * [client_month_bytes_downloaded] => 0
  1101. * [client_total_bytes_uploaded] => 0
  1102. * [client_total_bytes_downloaded] => 0
  1103. * [client_icon_id] => 0
  1104. * [client_base64HashClientUID] => jneilbgomklpfnkjclkoggokfdmdlhnbbpmdpagh
  1105. * [client_lastip] => 127.0.0.1
  1106. * }
  1107. * </code>
  1108. *
  1109. * @author Par0noid Solutions
  1110. * @access public
  1111. * @param integer $cldbid clientDBID
  1112. * @return array clientDbInfo
  1113. */
  1114. function clientDbInfo($cldbid) {
  1115. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  1116. return $this->getData('array', 'clientdbinfo cldbid='.$cldbid);
  1117. }
  1118. /**
  1119. * clientDbList
  1120. *
  1121. * Displays a list of client identities known by the server including their database ID, last nickname, etc.
  1122. *
  1123. * <br><b>Possible params:</b> [start={offset}] [duration={limit}] [-count]<br><br>
  1124. *
  1125. * <b>Output:</b>
  1126. * <code>
  1127. * Array
  1128. * {
  1129. * [count] => 1 (if count parameter is set)
  1130. * [cldbid] => 2
  1131. * [client_unique_identifier] => nUixbsq/XakrrmbqU8O30R/D8Gc=
  1132. * [client_nickname] => par0noid
  1133. * [client_created] => 1361027850
  1134. * [client_lastconnected] => 1361027850
  1135. * [client_totalconnections] => 1
  1136. * [client_description] =>
  1137. * [client_lastip] => 127.0.0.1
  1138. * }
  1139. * </code>
  1140. *
  1141. * @author Par0noid Solutions
  1142. * @access public
  1143. * @param integer $start offset [optional] (Default: 0)
  1144. * @param integer $duration limit [optional] (Default: -1)
  1145. * @param boolean $count set true to add -count param [optional]
  1146. * @return array clientdblist
  1147. */
  1148. function clientDbList($start = 0, $duration = -1, $count = false) {
  1149. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  1150. return $this->getData('multi', 'clientdblist start='.$start.' duration='.$duration.($count ? ' -count' : ''));
  1151. }
  1152. /**
  1153. * clientDelPerm
  1154. *
  1155. * Removes a set of specified permissions from a client. Multiple permissions can be removed at once. A permission can be specified by permid or permsid.
  1156. *
  1157. * <b>Input-Array like this:</b>
  1158. * <code>
  1159. * $permissions = array();
  1160. * $permissions['permissionID'] = 'permissionValue';
  1161. * //or you could use Permission Name
  1162. * $permissions['permissionName'] = 'permissionValue';
  1163. * </code>
  1164. *
  1165. * @author Par0noid Solutions
  1166. * @access public
  1167. * @param integer $cldbid clientDBID
  1168. * @param array $permissionIds permissionIDs
  1169. * @return boolean success
  1170. */
  1171. function clientDelPerm($cldbid, $permissionIds) {
  1172. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  1173. $permissionArray = array();
  1174. if(count($permissionIds) > 0) {
  1175. foreach($permissionIds AS $value) {
  1176. $permissionArray[] = (is_numeric($value) ? 'permid=' : 'permsid=').$value;
  1177. }
  1178. return $this->getData('boolean', 'clientdelperm cldbid='.$cldbid.' '.implode('|', $permissionArray));
  1179. }else{
  1180. $this->addDebugLog('no permissions given');
  1181. return $this->generateOutput(false, array('Error: no permissions given'), false);
  1182. }
  1183. }
  1184. /**
  1185. * clientEdit
  1186. *
  1187. * Changes a clients settings using given properties.
  1188. *
  1189. * <b>Input-Array like this:</b>
  1190. * <code>
  1191. * $data = array();
  1192. *
  1193. * $data['property'] = 'value';
  1194. * $data['property'] = 'value';
  1195. * </code>
  1196. *
  1197. * @author Par0noid Solutions
  1198. * @access public
  1199. * @param integer $clid clientID
  1200. * @param array $data clientProperties
  1201. * @return boolean success
  1202. */
  1203. function clientEdit($clid, $data) {
  1204. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  1205. $settingsString = '';
  1206. foreach($data as $key => $value) {
  1207. $settingsString .= ' '.$key.'='.$this->escapeText($value);
  1208. }
  1209. return $this->getData('boolean', 'clientedit clid='.$clid.$settingsString);
  1210. }
  1211. /**
  1212. * clientFind
  1213. *
  1214. * Displays a list of clients matching a given name pattern.
  1215. *
  1216. * <b>Output:</b>
  1217. * <code>
  1218. * Array
  1219. * {
  1220. * [clid] => 18
  1221. * [client_nickname] => par0noid
  1222. * }
  1223. * </code>
  1224. *
  1225. * @author Par0noid Solutions
  1226. * @access public
  1227. * @param string $pattern clientName
  1228. * @return array clienList
  1229. */
  1230. function clientFind($pattern) {
  1231. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  1232. return $this->getData('multi', 'clientfind pattern='.$this->escapeText($pattern));
  1233. }
  1234. /**
  1235. * clientGetDbIdFromUid
  1236. *
  1237. * Displays the database ID matching the unique identifier specified by cluid.
  1238. *
  1239. * <b>Output:</b>
  1240. * <code>
  1241. * Array
  1242. * {
  1243. * [cluid] => nUixbsq/XakrrmbqU8O30R/D8Gc=
  1244. * [cldbid] => 2
  1245. * }
  1246. * </code>
  1247. *
  1248. * @author Par0noid Solutions
  1249. * @access public
  1250. * @param string $cluid clientUID
  1251. * @return array clientInfo
  1252. */
  1253. function clientGetDbIdFromUid($cluid) {
  1254. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  1255. return $this->getData('array', 'clientgetdbidfromuid cluid='.$cluid);
  1256. }
  1257. /**
  1258. * clientGetIds
  1259. *
  1260. * Displays all client IDs matching the unique identifier specified by cluid.
  1261. *
  1262. * <b>Output:</b>
  1263. * <code>
  1264. * Array
  1265. * {
  1266. * [cluid] => nUixbdf/XakrrmsdffO30R/D8Gc=
  1267. * [clid] => 7
  1268. * [name] => Par0noid
  1269. * }
  1270. * </code>
  1271. *
  1272. * @author Par0noid Solutions
  1273. * @access public
  1274. * @param string $cluid clientUID
  1275. * @return array clientList
  1276. */
  1277. function clientGetIds($cluid) {
  1278. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  1279. return $this->getData('multi', 'clientgetids cluid='.$cluid);
  1280. }
  1281. /**
  1282. * clientGetNameFromDbid
  1283. *
  1284. * Displays the unique identifier and nickname matching the database ID specified by cldbid.
  1285. *
  1286. * <b>Output:</b>
  1287. * <code>
  1288. * Array
  1289. * {
  1290. * [cluid] => nUixbsq/XakrrmbqU8O30R/D8Gc=
  1291. * [cldbid] => 2
  1292. * [name] => Par0noid
  1293. * }
  1294. * </code>
  1295. *
  1296. * @author Par0noid Solutions
  1297. * @access public
  1298. * @param integer $cldbid clientDBID
  1299. * @return array clientInfo
  1300. */
  1301. function clientGetNameFromDbid($cldbid) {
  1302. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  1303. return $this->getData('array', 'clientgetnamefromdbid cldbid='.$cldbid);
  1304. }
  1305. /**
  1306. * clientGetNameFromUid
  1307. *
  1308. * Displays the database ID and nickname matching the unique identifier specified by cluid.
  1309. *
  1310. * <b>Output:</b>
  1311. * <code>
  1312. * Array
  1313. * {
  1314. * [cluid] => nUixbsq/XakrrmbqU8O30R/D8Gc=
  1315. * [cldbid] => 2
  1316. * [name] => Par0noid
  1317. * }
  1318. * </code>
  1319. *
  1320. * @author Par0noid Solutions
  1321. * @access public
  1322. * @param string $cluid clientUID
  1323. * @return array clientInfo
  1324. */
  1325. function clientGetNameFromUid($cluid) {
  1326. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  1327. return $this->getData('array', 'clientgetnamefromuid cluid='.$cluid);
  1328. }
  1329. /**
  1330. * clientInfo
  1331. *
  1332. * Displays detailed configuration information about a client including unique ID, nickname, client version, etc.
  1333. *
  1334. * <b>Output:</b>
  1335. * <code>
  1336. * Array
  1337. * {
  1338. * [cid] => 2
  1339. * [client_idle_time] => 4445369
  1340. * [client_unique_identifier] => nUixbsq/XakrrmbqU8O30R/D8Gc=
  1341. * [client_nickname] => par0noid
  1342. * [client_version] => 3.0.9.2 [Build: 1351504843]
  1343. * [client_platform] => Windows
  1344. * [client_input_muted] => 1
  1345. * [client_output_muted] => 1
  1346. * [client_outputonly_muted] => 0
  1347. * [client_input_hardware] => 1
  1348. * [client_output_hardware] => 1
  1349. * [client_default_channel] =>
  1350. * [client_meta_data] =>
  1351. * [client_is_recording] => 0
  1352. * [client_login_name] =>
  1353. * [client_database_id] => 2
  1354. * [client_channel_group_id] => 5
  1355. * [client_servergroups] => 6
  1356. * [client_created] => 1361027850
  1357. * [client_lastconnected] => 1361027850
  1358. * [client_totalconnections] => 1
  1359. * [client_away] => 0
  1360. * [client_away_message] =>
  1361. * [client_type] => 0
  1362. * [client_flag_avatar] =>
  1363. * [client_talk_power] => 75
  1364. * [client_talk_request] => 0
  1365. * [client_talk_request_msg] =>
  1366. * [client_description] =>
  1367. * [client_is_talker] => 0
  1368. * [client_month_bytes_uploaded] => 0
  1369. * [client_month_bytes_downloaded] => 0
  1370. * [client_total_bytes_uploaded] => 0
  1371. * [client_total_bytes_downloaded] => 0
  1372. * [client_is_priority_speaker] => 0
  1373. * [client_nickname_phonetic] =>
  1374. * [client_needed_serverquery_view_power] => 75
  1375. * [client_default_token] =>
  1376. * [client_icon_id] => 0
  1377. * [client_is_channel_commander] => 0
  1378. * [client_country] =>
  1379. * [client_channel_group_inherited_channel_id] => 2
  1380. * [client_base64HashClientUID] => jneilbgomklpfnkjclkoggokfdmdlhnbbpmdpagh
  1381. * [connection_filetransfer_bandwidth_sent] => 0
  1382. * [connection_filetransfer_bandwidth_received] => 0
  1383. * [connection_packets_sent_total] => 12130
  1384. * [connection_bytes_sent_total] => 542353
  1385. * [connection_packets_received_total] => 12681
  1386. * [connection_bytes_received_total] => 592935
  1387. * [connection_bandwidth_sent_last_second_total] => 82
  1388. * [connection_bandwidth_sent_last_minute_total] => 92
  1389. * [connection_bandwidth_received_last_second_total] => 84
  1390. * [connection_bandwidth_received_last_minute_total] => 88
  1391. * [connection_connected_time] => 5908749
  1392. * [connection_client_ip] => 127.0.0.1
  1393. * }
  1394. * </code>
  1395. *
  1396. * @author Par0noid Solutions
  1397. * @access public
  1398. * @param integer $clid clientID
  1399. * @return array clientInformation
  1400. */
  1401. function clientInfo($clid) {
  1402. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  1403. return $this->getData('array', 'clientinfo clid='.$clid);
  1404. }
  1405. /**
  1406. * clientKick
  1407. *
  1408. * Kicks one or more clients specified with clid from their currently joined channel or from the server, depending on reasonid. The reasonmsg parameter specifies a text message sent to the kicked clients. This parameter is optional and may only have a maximum of 40 characters.
  1409. *
  1410. * @author Par0noid Solutions
  1411. * @access public
  1412. * @param integer $clid clientID
  1413. * @param string $kickMode kickMode (server or channel) (Default: servera)
  1414. * @param string $kickmsg kick reason [optional]
  1415. * @return boolean success
  1416. */
  1417. function clientKick($clid, $kickMode = "server", $kickmsg = "") {
  1418. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  1419. if(in_array($kickMode, array('server', 'channel'))) {
  1420. if($kickMode == 'server') { $from = '5'; }
  1421. if($kickMode == 'channel') { $from = '4'; }
  1422. if(!empty($kickmsg)) { $msg = ' reasonmsg='.$this->escapeText($kickmsg); } else{ $msg = ''; }
  1423. return $this->getData('boolean', 'clientkick clid='.$clid.' reasonid='.$from.$msg);
  1424. }else{
  1425. $this->addDebugLog('invalid kickMode');
  1426. return $this->generateOutput(false, array('Error: invalid kickMode'), false);
  1427. }
  1428. }
  1429. /**
  1430. * clientList
  1431. *
  1432. * Displays a list of clients online on a virtual server including their ID, nickname, status flags, etc. The output can be modified using several command options. Please note that the output will only contain clients which are currently in channels you're able to subscribe to.
  1433. *
  1434. * <br><b>Possible params:</b> [-uid] [-away] [-voice] [-times] [-groups] [-info] [-icon] [-country] [-ip] [-badges]<br><br>
  1435. *
  1436. * <b>Output: (without parameters)</b>
  1437. * <code>
  1438. * Array
  1439. * {
  1440. * [clid] => 1
  1441. * [cid] => 1
  1442. * [client_database_id] => 2
  1443. * [client_nickname] => Par0noid
  1444. * [client_type] => 0
  1445. * [-uid] => [client_unique_identifier] => nUixbsq/XakrrmbqU8O30R/D8Gc=
  1446. * [-away] => [client_away] => 0
  1447. * [-away] => [client_away_message] =>
  1448. * [-voice] => [client_flag_talking] => 0
  1449. * [-voice] => [client_input_muted] => 0
  1450. * [-voice] => [client_output_muted] => 0
  1451. * [-voice] => [client_input_hardware] => 0
  1452. * [-voice] => [client_output_hardware] => 0
  1453. * [-voice] => [client_talk_power] => 0
  1454. * [-voice] => [client_is_talker] => 0
  1455. * [-voice] => [client_is_priority_speaker] => 0
  1456. * [-voice] => [client_is_recording] => 0
  1457. * [-voice] => [client_is_channel_commander] => 0
  1458. * [-times] => [client_idle_time] => 1714
  1459. * [-times] => [client_created] => 1361027850
  1460. * [-times] => [client_lastconnected] => 1361042955
  1461. * [-groups] => [client_servergroups] => 6,7
  1462. * [-groups] => [client_channel_group_id] => 8
  1463. * [-groups] => [client_channel_group_inherited_channel_id] => 1
  1464. * [-info] => [client_version] => 3.0.9.2 [Build: 1351504843]
  1465. * [-info] => [client_platform] => Windows
  1466. * [-icon] => [client_icon_id] => 0
  1467. * [-country] => [client_country] =>
  1468. * [-ip] => [connection_client_ip] => 127.0.0.1
  1469. * [-badges] => [client_badges] => Overwolf=0
  1470. * }
  1471. * </code><br>
  1472. * <b>Usage:</b>
  1473. * <code>
  1474. * $ts3->clientList(); //No parameters
  1475. * $ts3->clientList("-uid"); //Single parameter
  1476. * $ts3->clientList("-uid -away -voice -times -groups -info -country -icon -ip -badges"); //Multiple parameters
  1477. * </code><br>
  1478. *
  1479. * @author Par0noid Solutions
  1480. * @access public
  1481. * @param string $params additional parameters [optional]
  1482. * @return array clientList
  1483. */
  1484. function clientList($params = null) {
  1485. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  1486. if(!empty($params)) { $params = ' '.$params; }
  1487. return $this->getData('multi', 'clientlist'.$params);
  1488. }
  1489. /**
  1490. * clientMove
  1491. *
  1492. * Moves one or more clients specified with clid to the channel with ID cid. If the target channel has a password, it needs to be specified with cpw. If the channel has no password, the parameter can be omitted.
  1493. *
  1494. * @author Par0noid Solutions
  1495. * @access public
  1496. * @param integer $clid clientID
  1497. * @param integer $cid channelID
  1498. * @param string $cpw channelPassword [optional]
  1499. * @return boolean success
  1500. */
  1501. function clientMove($clid, $cid, $cpw = null) {
  1502. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  1503. return $this->getData('boolean', 'clientmove clid='.$clid.' cid='.$cid.(!empty($cpw) ? ' cpw='.$this->escapeText($cpw) : ''));
  1504. }
  1505. /**
  1506. * clientPermList
  1507. *
  1508. * Displays a list of permissions defined for a client.
  1509. *
  1510. * <b>Output:</b>
  1511. * <code>
  1512. * Array
  1513. * {
  1514. * [permid] => 20654 //with permsid = false
  1515. * [permsid] => b_client_ignore_bans //with permsid = true
  1516. * [permvalue] => 1
  1517. * [permnegated] => 0
  1518. * [permskip] => 0
  1519. * }
  1520. * </code>
  1521. *
  1522. * @author Par0noid Solutions
  1523. * @access public
  1524. * @param intege $cldbid clientDBID
  1525. * @param boolean $permsid set true to add -permsid param [optional]
  1526. * @return array clientPermList
  1527. */
  1528. function clientPermList($cldbid, $permsid = false) {
  1529. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  1530. return $this->getData('multi', 'clientpermlist cldbid='.$cldbid.($permsid ? ' -permsid' : ''));
  1531. }
  1532. /**
  1533. * clientPoke
  1534. *
  1535. * Sends a poke message to the client specified with clid.
  1536. *
  1537. * @author Par0noid Solutions
  1538. * @access public
  1539. * @param integer $clid clientID
  1540. * @param string $msg pokeMessage
  1541. * @return boolean success
  1542. */
  1543. function clientPoke($clid, $msg) {
  1544. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  1545. return $this->getData('boolean', 'clientpoke clid='.$clid.' msg='.$this->escapeText($msg));
  1546. }
  1547. /**
  1548. * clientSetServerQueryLogin
  1549. *
  1550. * Updates your own ServerQuery login credentials using a specified username. The password will be auto-generated.
  1551. *
  1552. * <b>Output:</b>
  1553. * <code>
  1554. * Array
  1555. * {
  1556. * [client_login_password] => +r\/TQqvR
  1557. * }
  1558. * </code>
  1559. *
  1560. * @author Par0noid Solutions
  1561. * @access public
  1562. * @param string $username username
  1563. * @return array userInfomation
  1564. */
  1565. function clientSetServerQueryLogin($username) {
  1566. return $this->getData('array', 'clientsetserverquerylogin client_login_name='.$this->escapeText($username));
  1567. }
  1568. /**
  1569. * clientUpdate
  1570. *
  1571. * Change your ServerQuery clients settings using given properties.
  1572. *
  1573. * <b>Input-Array like this:</b>
  1574. * <code>
  1575. * $data = array();
  1576. * $data['property'] = 'value';
  1577. * $data['property'] = 'value';
  1578. * </code>
  1579. *
  1580. * @author Par0noid Solutions
  1581. * @access public
  1582. * @param array $data clientProperties
  1583. * @return boolean success
  1584. */
  1585. function clientUpdate($data) {
  1586. $settingsString = '';
  1587. foreach($data as $key => $value) {
  1588. $settingsString .= ' '.$key.'='.$this->escapeText($value);
  1589. }
  1590. return $this->getData('boolean', 'clientupdate '.$settingsString);
  1591. }
  1592. /**
  1593. * complainAdd
  1594. *
  1595. * Submits a complaint about the client with database ID tcldbid to the server.
  1596. *
  1597. * @author Par0noid Solutions
  1598. * @access public
  1599. * @param integer $tcldbid targetClientDBID
  1600. * @param string $msg complainMessage
  1601. * @return boolean success
  1602. */
  1603. function complainAdd($tcldbid, $msg) {
  1604. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  1605. return $this->getData('boolean', 'complainadd tcldbid='.$tcldbid.' message='.$this->escapeText($msg));
  1606. }
  1607. /**
  1608. * complainDelete
  1609. *
  1610. * Deletes the complaint about the client with ID tcldbid submitted by the client with ID fcldbid from the server.
  1611. *
  1612. * @author Par0noid Solutions
  1613. * @access public
  1614. * @param integer $tcldbid targetClientDBID
  1615. * @param integer $fcldbid fromClientDBID
  1616. * @return boolean success
  1617. */
  1618. function complainDelete($tcldbid, $fcldbid) {
  1619. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  1620. return $this->getData('boolean', 'complaindel tcldbid='.$tcldbid.' fcldbid='.$fcldbid);
  1621. }
  1622. /**
  1623. * complainDeleteAll
  1624. *
  1625. * Deletes all complaints about the client with database ID tcldbid from the server.
  1626. *
  1627. * @author Par0noid Solutions
  1628. * @access public
  1629. * @param integer $tcldbid targetClientDBID
  1630. * @return boolean success
  1631. */
  1632. function complainDeleteAll($tcldbid) {
  1633. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  1634. return $this->getData('boolean', 'complaindelall tcldbid='.$tcldbid);
  1635. }
  1636. /**
  1637. * complainList
  1638. *
  1639. * Displays a list of complaints on the selected virtual server. If tcldbid is specified, only complaints about the targeted client will be shown.
  1640. *
  1641. * <b>Output:</b>
  1642. * <code>
  1643. * Array
  1644. * {
  1645. * [tcldbid] => 2
  1646. * [tname] => par0noid
  1647. * [fcldbid] => 1
  1648. * [fname] => serveradmin from 127.0.0.1:6814
  1649. * [message] => Steals crayons
  1650. * [timestamp] => 1361044090
  1651. * }
  1652. * </code>
  1653. *
  1654. * @author Par0noid Solutions
  1655. * @access public
  1656. * @param string $tcldbid targetClientDBID [optional]
  1657. * @return array complainList
  1658. */
  1659. function complainList($tcldbid = null) {
  1660. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  1661. if(!empty($tcldbid)) { $tcldbid = ' tcldbid='.$tcldbid; }
  1662. return $this->getData('multi', 'complainlist'.$tcldbid);
  1663. }
  1664. /**
  1665. * execOwnCommand
  1666. *
  1667. * executes a command that isn't defined in class and returns data like your propose
  1668. *
  1669. * <b>Modes:</b>
  1670. * <ul>
  1671. * <li><b>0:</b> execute -> return boolean</li>
  1672. * <li><b>1:</b> execute -> return normal array</li>
  1673. * <li><b>2:</b> execute -> return multidimensional array</li>
  1674. * <li><b>3:</b> execute -> return plaintext serverquery</li>
  1675. * </ul>
  1676. *
  1677. * @author Par0noid Solutions
  1678. * @access public
  1679. * @param string $mode executionMode
  1680. * @param string $command command
  1681. * @return mixed result
  1682. */
  1683. function execOwnCommand($mode, $command) {
  1684. if($mode == '0') {
  1685. return $this->getData('boolean', $command);
  1686. }
  1687. if($mode == '1') {
  1688. return $this->getData('array', $command);
  1689. }
  1690. if($mode == '2') {
  1691. return $this->getData('multi', $command);
  1692. }
  1693. if($mode == '3') {
  1694. return $this->getData('plain', $command);
  1695. }
  1696. }
  1697. /**
  1698. * ftCreateDir
  1699. *
  1700. * Creates new directory in a channels file repository.
  1701. *
  1702. * @author Par0noid Solutions
  1703. * @access public
  1704. * @param string $cid channelId
  1705. * @param string $cpw channelPassword (leave blank if not needed)
  1706. * @param string $dirname dirPath
  1707. * @return boolean success
  1708. */
  1709. function ftCreateDir($cid, $cpw = null, $dirname) {
  1710. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  1711. return $this->getData('boolean', 'ftcreatedir cid='.$cid.' cpw='.$this->escapeText($cpw).' dirname='.$this->escapeText($dirname));
  1712. }
  1713. /**
  1714. * ftDeleteFile
  1715. *
  1716. * Deletes one or more files stored in a channels file repository.
  1717. *
  1718. * <b>Input-Array like this:</b>
  1719. * <code>
  1720. * $files = array();
  1721. *
  1722. * $files[] = '/pic1.jpg';
  1723. * $files[] = '/dokumente/test.txt';
  1724. * $files[] = '/dokumente';
  1725. * </code>
  1726. *
  1727. * @author Par0noid Solutions
  1728. * @access public
  1729. * @param string $cid channelID
  1730. * @param string $cpw channelPassword (leave blank if not needed)
  1731. * @param array $files files
  1732. * @return boolean success
  1733. */
  1734. function ftDeleteFile($cid, $cpw = '', $files) {
  1735. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  1736. $fileArray = array();
  1737. if(count($files) > 0) {
  1738. foreach($files AS $file) {
  1739. $fileArray[] = 'name='.$this->escapeText($file);
  1740. }
  1741. return $this->getData('boolean', 'ftdeletefile cid='.$cid.' cpw='.$this->escapeText($cpw).' '.implode('|', $fileArray));
  1742. }else{
  1743. $this->addDebugLog('no files given');
  1744. return $this->generateOutput(false, array('Error: no files given'), false);
  1745. }
  1746. }
  1747. /**
  1748. * ftDownloadFile
  1749. *
  1750. * Ddownloads a file and returns its contents
  1751. *
  1752. * @author Par0noid Solutions
  1753. * @access public
  1754. * @param array $data return of ftInitDownload
  1755. * @return array downloadedFile
  1756. */
  1757. function ftDownloadFile($data) {
  1758. $this->runtime['fileSocket'] = @fsockopen($this->runtime['host'], $data['data']['port'], $errnum, $errstr, $this->runtime['timeout']);
  1759. if($this->runtime['fileSocket']) {
  1760. $this->ftSendKey($data['data']['ftkey']);
  1761. $content = $this->ftRead($data['data']['size']);
  1762. @fclose($this->runtime['fileSocket']);
  1763. $this->runtime['fileSocket'] = '';
  1764. return $content;
  1765. }else{
  1766. $this->addDebugLog('fileSocket returns '.$errnum. ' | '.$errstr);
  1767. return $this->generateOutput(false, array('Error in fileSocket: '.$errnum. ' | '.$errstr), false);
  1768. }
  1769. }
  1770. /**
  1771. * ftGetFileInfo
  1772. *
  1773. * Displays detailed information about one or more specified files stored in a channels file repository.
  1774. *
  1775. * <b>Input-Array like this:</b>
  1776. * <code>
  1777. * $files = array();
  1778. *
  1779. * $files[] = '/pic1.jpg';
  1780. * $files[] = '/dokumente/test.txt';
  1781. * $files[] = '/dokumente';
  1782. * </code><br>
  1783. * <b>Output:</b>
  1784. * <code>
  1785. * Array
  1786. * {
  1787. * [cid] => 231
  1788. * [name] => /dfsdfsdf.txt
  1789. * [size] => 1412
  1790. * [datetime] => 1286634258
  1791. * }
  1792. * </code>
  1793. *
  1794. *
  1795. * @author Par0noid Solutions
  1796. * @access public
  1797. * @param string $cid channelID
  1798. * @param string $cpw channelPassword (leave blank if not needed)
  1799. * @param array $files files
  1800. * @return boolean success
  1801. */
  1802. function ftGetFileInfo($cid, $cpw = '', $files) {
  1803. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  1804. $fileArray = array();
  1805. if(count($files) > 0) {
  1806. foreach($files AS $file) {
  1807. $fileArray[] = 'name='.$this->escapeText($file);
  1808. }
  1809. return $this->getData('multi', 'ftgetfileinfo cid='.$cid.' cpw='.$this->escapeText($cpw).' '.implode('|', $fileArray));
  1810. }else{
  1811. $this->addDebugLog('no files given');
  1812. return $this->generateOutput(false, array('Error: no files given'), false);
  1813. }
  1814. }
  1815. /**
  1816. * ftGetFileList
  1817. *
  1818. * Displays a list of files and directories stored in the specified channels file repository.
  1819. *
  1820. * <b>Output:</b>
  1821. * <code>
  1822. * Array
  1823. * {
  1824. * [cid] => 231
  1825. * [path] => /
  1826. * [name] => Documents
  1827. * [size] => 0
  1828. * [datetime] => 1286633633
  1829. * [type] => 0
  1830. * }
  1831. * </code>
  1832. *
  1833. * @author Par0noid Solutions
  1834. * @access public
  1835. * @param string $cid channelID
  1836. * @param string $cpw channelPassword (leave blank if not needed)
  1837. * @param string $path filePath
  1838. * @return array fileList
  1839. */
  1840. function ftGetFileList($cid, $cpw = '', $path) {
  1841. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  1842. return $this->getData('multi', 'ftgetfilelist cid='.$cid.' cpw='.$this->escapeText($cpw).' path='.$this->escapeText($path));
  1843. }
  1844. /**
  1845. * ftInitDownload
  1846. *
  1847. * Initializes a file transfer download. clientftfid is an arbitrary ID to identify the file transfer on client-side. On success, the server generates a new ftkey which is required to start downloading the file through TeamSpeak 3's file transfer interface.
  1848. *
  1849. * <b>Output:</b>
  1850. * <code>
  1851. * Array
  1852. * {
  1853. * [clientftfid] => 89
  1854. * [serverftfid] => 3
  1855. * [ftkey] => jSzWiRmFGdZnoJzW7BSDYJRUWB2WAUhb
  1856. * [port] => 30033
  1857. * [size] => 94
  1858. * }
  1859. * </code>
  1860. *
  1861. * @author Par0noid Solutions
  1862. * @access public
  1863. * @param string $name filePath
  1864. * @param string $cid channelID
  1865. * @param string $cpw channelPassword (leave blank if not needed)
  1866. * @param integer $seekpos seekpos (default = 0) [optional]
  1867. * @return array initDownloadFileInfo
  1868. */
  1869. function ftInitDownload($name, $cid, $cpw = '', $seekpos = 0) {
  1870. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  1871. return $this->getData('array', 'ftinitdownload clientftfid='.rand(1,99).' name='.$this->escapeText($name).' cid='.$cid.' cpw='.$this->escapeText($cpw).' seekpos='.$seekpos);
  1872. }
  1873. /**
  1874. * ftInitUpload
  1875. *
  1876. * Initializes a file transfer upload. clientftfid is an arbitrary ID to identify the file transfer on client-side. On success, the server generates a new ftkey which is required to start uploading the file through TeamSpeak 3's file transfer interface.
  1877. *
  1878. * <b>Output:</b>
  1879. * <code>
  1880. * Array
  1881. * {
  1882. * [clientftfid] => 84
  1883. * [serverftfid] => 41
  1884. * [ftkey] => HCnXpunOdAorqj3dGqfiuLszX18O0PHP
  1885. * [port] => 30033
  1886. * [seekpos] => 0
  1887. * }
  1888. * </code>
  1889. *
  1890. * @author Par0noid Solutions
  1891. * @access public
  1892. * @param string $filename filePath
  1893. * @param string $cid channelID
  1894. * @param integer $size fileSize in bytes
  1895. * @param string $cpw channelPassword (leave blank if not needed)
  1896. * @param boolean $overwrite overwrite [optional] (default = 0)
  1897. * @param boolean $resume resume [optional] (default = 0)
  1898. * @return array initUploadFileInfo
  1899. */
  1900. function ftInitUpload($filename, $cid, $size, $cpw = '', $overwrite = false, $resume = false) {
  1901. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  1902. if($overwrite) { $overwrite = ' overwrite=1'; }else{ $overwrite = ' overwrite=0'; }
  1903. if($resume) { $resume = ' resume=1'; }else{ $resume = ' resume=0'; }
  1904. return $this->getData('array', 'ftinitupload clientftfid='.rand(1,99).' name='.$this->escapeText($filename).' cid='.$cid.' cpw='.$this->escapeText($cpw).' size='.($size + 1).$overwrite.$resume);
  1905. }
  1906. /**
  1907. * ftList
  1908. *
  1909. * Displays a list of running file transfers on the selected virtual server. The output contains the path to which a file is uploaded to, the current transfer rate in bytes per second, etc
  1910. *
  1911. * <b>Output:</b>
  1912. * <code>
  1913. * Array
  1914. * {
  1915. * [clid] => 1
  1916. * [cldbid] => 2019
  1917. * [path] => files/virtualserver_11/channel_231
  1918. * [name] => 1285412348878.png
  1919. * [size] => 1161281
  1920. * [sizedone] => 275888
  1921. * [clientftfid] => 15
  1922. * [serverftfid] => 52
  1923. * [sender] => 0
  1924. * [status] => 1
  1925. * [current_speed] => 101037.4453
  1926. * [average_speed] => 101037.4453
  1927. * [runtime] => 2163
  1928. * }
  1929. * </code>
  1930. *
  1931. * @author Par0noid Solutions
  1932. * @access public
  1933. * @return array fileTransferList
  1934. */
  1935. function ftList() {
  1936. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  1937. return $this->getData('multi', 'ftlist');
  1938. }
  1939. /**
  1940. * ftRenameFile
  1941. *
  1942. * Renames a file in a channels file repository. If the two parameters tcid and tcpw are specified, the file will be moved into another channels file repository.
  1943. *
  1944. * @author Par0noid Solutions
  1945. * @access public
  1946. * @param integer $cid channelID
  1947. * @param string $cpw channelPassword (leave blank if not needed)
  1948. * @param string $oldname oldFilePath
  1949. * @param string $newname newFilePath
  1950. * @param string $tcid targetChannelID [optional]
  1951. * @param string $tcpw targetChannelPassword [optional]
  1952. * @return boolean success
  1953. */
  1954. function ftRenameFile($cid, $cpw = null, $oldname, $newname, $tcid = null, $tcpw = null) {
  1955. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  1956. $newTarget = ($tcid != null ? ' tcid='.$tcid.' '.$tcpw : '');
  1957. return $this->getData('boolean', 'ftrenamefile cid='.$cid.' cpw='.$cpw.' oldname='.$this->escapeText($oldname).' newname='.$this->escapeText($newname).$newTarget);
  1958. }
  1959. /**
  1960. * ftStop
  1961. *
  1962. * Stops the running file transfer with server-side ID serverftfid.
  1963. *
  1964. * @author Par0noid Solutions
  1965. * @access public
  1966. * @param integer $serverftfid serverFileTransferID
  1967. * @param boolean $delete delete incomplete file [optional] (default: true)
  1968. * @return boolean success
  1969. */
  1970. function ftStop($serverftfid, $delete = true) {
  1971. if(!$this->runtime['selected']) { return $this->checkSelected(); }
  1972. return $this->getData('boolean', 'ftstop serverftfid='.$serverftfid.' delete='.($delete ? '1' : '0'));
  1973. }
  1974. /**
  1975. * ftUploadFile
  1976. *
  1977. * Uploads a file to server
  1978. * To check if upload was successful, you have to search for this file in fileList after
  1979. *
  1980. * @author Par0noid Solutions
  1981. * @access public
  1982. * @param array $data return of ftInitUpload
  1983. * @param string $uploadData data which should be uploaded
  1984. * @return array response
  1985. */
  1986. ?>

comments powered by Disqus