1
0

ts3remote.class.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983
  1. <?php
  2. /**
  3. * ts3remote.class.php <br />
  4. * ------------------- <br />
  5. * begin : Sunday, Dec 22, 2009 <br />
  6. * copyright : (C) 2009-2010 RK Programming <br />
  7. * email : [email protected] <br />
  8. * version : 0.9.1 <br />
  9. * last modified : Tuesday, Dec 29, 2009 <br />
  10. *
  11. * @author RK Programming <[email protected]>
  12. * @copyright Copyright (c) 2009-2010, Robin K.
  13. * @version 0.9.1
  14. TS3remote and TS3lib is free software. You can redistribute it and/or
  15. modify it under the terms of the GNU General Public License as published
  16. by the Free Software Foundation, version 1.3.
  17. **/
  18. define('TS3REMOTE_VERSION', '0.9.0');
  19. require_once('ts3lib.class.php');
  20. class TS3remote extends TS3lib
  21. {
  22. protected $loggedin;
  23. function __construct($ip, $port)
  24. {
  25. parent::__construct($ip, $port);
  26. $this->loggedin = false;
  27. }
  28. function __destruct()
  29. {
  30. parent::__destruct();
  31. }
  32. public function r_login($user, $password)
  33. {
  34. $user = $this->escape($user);
  35. $password = $this->escape($password);
  36. if( $this->performResultless("login client_login_name=$user client_login_password=$password") )
  37. {
  38. $this->loggedin = true;
  39. return true;
  40. }
  41. else
  42. {
  43. return false;
  44. }
  45. }
  46. public function r_logout()
  47. {
  48. $this->loggedin = false;
  49. return $this->performResultless('logout');
  50. }
  51. public function r_version($parse=TS3_PARSED) // or TS3_RAW
  52. {
  53. return $this->perform('version', $parse);
  54. }
  55. public function r_hostinfo($parse=TS3_PARSED)
  56. {
  57. return $this->perform('hostinfo', $parse);
  58. }
  59. public function r_instanceinfo($parse=TS3_PARSED)
  60. {
  61. return $this->perform('instanceinfo', $parse);
  62. }
  63. public function r_instanceedeit($var, $value)
  64. {
  65. $var = $this->escape($var);
  66. $value = $this->escape($value);
  67. return $this->performResultless("instanceedit $var=$value");
  68. }
  69. public function r_bindinglist($parse=TS3_PARSED)
  70. {
  71. return $this->perform('bindinglist', $parse);
  72. }
  73. public function r_use($sid, $port=0)
  74. {
  75. $sid = $this->escape($sid);
  76. $this->vserver = $sid;
  77. if( $port > 0 )
  78. {
  79. $port = $this->escape($port);
  80. return $this->performResultless("use sid=$sid port=$port");
  81. }
  82. else
  83. {
  84. return $this->performResultless("use sid=$sid");
  85. }
  86. }
  87. public function r_serverlist($all=true, $parse=TS3_PARSED)
  88. {
  89. if( $all ) $all = ' -all';
  90. else $all = '';
  91. return $this->perform("serverlist$all", $parse);
  92. }
  93. public function r_serveridgetbyport($sid, $parse=TS3_PARSED)
  94. {
  95. $sid = $this->escape($sid);
  96. return $this->perform("serveridgetbyport virtualserver_port=$sid", $parse);
  97. }
  98. public function r_serverdelete($sid)
  99. {
  100. $sid = $this->escape($sid);
  101. return $this->performResultless("serverdelete sid=$sid");
  102. }
  103. public function r_servercreate($vServerName, $props, $parse=TS3_PARSED)
  104. {
  105. $vServerName = $this->escape($vServerName);
  106. $countProps = count($props);
  107. for($i=0; $i<$countProps; $i++)
  108. {
  109. $props[$i] = $this->escape($props[$i][0]).'='.$this->escape($props[$i][1]);
  110. }
  111. $propString = implode(' ', $props);
  112. return $this->perform("servercreate virtualserver_name=$vServerName $propString", $parse);
  113. }
  114. public function r_serverstart($sid)
  115. {
  116. $sid = $this->escape($sid);
  117. return $this->performResultless("serverstart sid=$sid");
  118. }
  119. public function r_serverstop($sid)
  120. {
  121. $sid = $this->escape($sid);
  122. return $this->performResultless("serverstop sid=$sid");
  123. }
  124. /*
  125. serverprocessstop
  126. */
  127. public function r_serverinfo($parse=TS3_PARSED)
  128. {
  129. return $this->perform('serverinfo', $parse);
  130. }
  131. public function r_serverrequestconnectioninfo($parse=TS3_PARSED)
  132. {
  133. return $this->perform('serverrequestconnectioninfo', $parse);
  134. }
  135. public function r_serveredit($props)
  136. {
  137. //print_r($props);
  138. //$props = $this->escape($props);
  139. //print_r($props);
  140. $countProps = count($props);
  141. for($i=0; $i<$countProps; $i++)
  142. {
  143. $props[$i] = $this->escape($props[$i][0]).'='.$this->escape($props[$i][1]);
  144. }
  145. $propString = implode(' ', $props);
  146. //echo $propString;
  147. return $this->performResultless("serveredit $propString");
  148. }
  149. public function r_servergrouplist($parse=TS3_PARSED)
  150. {
  151. if( $this->vserver > 0 )
  152. return $this->perform('servergrouplist', $parse);
  153. else
  154. return false;
  155. }
  156. public function r_servergroupadd($grpName, $parse=TS3_PARSED)
  157. {
  158. $grpName = $this->escape($grpName);
  159. return $this->perform("servergroupadd name=$grpName", $parse);
  160. }
  161. public function r_servergroupdel($sgid, $force=1)
  162. {
  163. $sgid = $this->escape($sgid);
  164. if( $force != 0 ) $force = 1;
  165. return $this->performResultless("servergroupdel sgid=$sgid force=$force");
  166. }
  167. public function r_servergrouprename($sgid, $newName)
  168. {
  169. $sgid = $this->escape($sgid);
  170. $newName = $this->escape($newName);
  171. return $this->performResultless("servergrouprename sgid=$sgid name=$newName");
  172. }
  173. public function r_servergrouppermlist($sgid, $parse=TS3_PARSED)
  174. {
  175. $sgid = $this->escape($sgid);
  176. return $this->perform("servergrouppermlist sgid=$sgid", $parse);
  177. }
  178. public function r_servergroupaddperm($sgid, $permid, $value, $negated, $skip)
  179. {
  180. $sgid = $this->escape($sgid);
  181. $permid = $this->escape($permid);
  182. $value = $this->escape($value);
  183. $negated = $this->escape($negated);
  184. $skip = $this->escape($skip);
  185. return $this->performResultless("servergroupaddperm sgid=$sgid permid=$permid permvalue=$value permnegated=$negated permskip=$skip");
  186. }
  187. public function r_servergroupdelperm($sgid, $permid)
  188. {
  189. $sgid = $this->escape($sgid);
  190. $permid = $this->escape($permid);
  191. return $this->performResultless("servergroupdelperm sgid=$sgid permid=$permid");
  192. }
  193. public function r_servergroupaddclient($sgid, $clientdbid)
  194. {
  195. $sgid = $this->escape($sgid);
  196. $clientdbid = $this->escape($clientdbid);
  197. return $this->performResultless("servergroupaddclient sgid=$sgid cldbid=$clientdbid");
  198. }
  199. public function r_servergroupdelclient($sgid, $clientdbid)
  200. {
  201. $sgid = $this->escape($sgid);
  202. $clientdbid = $this->escape($clientdbid);
  203. return $this->performResultless("servergroupdelclient sgid=$sgid cldbid=$clientdbid");
  204. }
  205. public function r_servergroupclientlist($sgid, $names=true, $parse=TS3_PARSED)
  206. {
  207. if( $names ) $names = ' -names';
  208. else $names = '';
  209. return $this->perform("servergroupclientlist sgid=$sgid$names", $parse);
  210. }
  211. public function r_servergroupsbyclientid($clientdbid, $parse=TS3_PARSED)
  212. {
  213. $sgid = $this->escape($sgid);
  214. return $this->perform("servergroupsbyclientid cldbid=$clientdbid", $parse);
  215. }
  216. public function r_serversnapshotcreate($parse=TS3_PARSED)
  217. {
  218. return $this->perform("serversnapshotcreate", $parse);
  219. }
  220. /*
  221. * serversnapshotdeploy
  222. * servernotifyregister
  223. * servernotifyunregister
  224. */
  225. public function r_gm($msg)
  226. {
  227. $msg = $this->escape($msg);
  228. return $this->performResultless("gm msg=$msg");
  229. }
  230. public function r_sendtextmessage($targetmode, $target, $msg)
  231. {
  232. $targetmode = $this->escape($targetmode);
  233. $target = $this->escape($target);
  234. $msg = $this->escape($msg);
  235. return $this->performResultless("sendtextmessage targetmode=$targetmode target=$target msg=$msg");
  236. }
  237. public function r_logview($limit=50, $parse=TS3_PARSED)
  238. {
  239. $limit = $this->escape($limit);
  240. return $this->perform("logview limitcount=$limit", $parse);
  241. }
  242. public function r_logadd($level, $msg)
  243. {
  244. $level = $this->escape($level);
  245. $msg = $this->escape($msg);
  246. return $this->performResultless("logadd loglevel=$level logmsg=$msg");
  247. }
  248. public function r_channellist($topic='', $flags='', $voice='', $limits='', $parse=TS3_PARSED)
  249. {
  250. if( $topic !== '' ) $topic = ' -topic';
  251. if( $flags !== '' ) $flags = ' -flags';
  252. if( $voice !== '' ) $voice = ' -voice';
  253. if( $limits !== '' ) $limits = ' -limits';
  254. return $this->perform("channellist$topic$flags$voice$limits", $parse);
  255. }
  256. public function r_channelinfo($cid, $parse=TS3_PARSED)
  257. {
  258. $cid = $this->escape($cid);
  259. return $this->perform("channelinfo cid=$cid", $parse);
  260. }
  261. /*
  262. channelfind (page 16 pdf)
  263. ...
  264. ...
  265. */
  266. public function r_channelfind($pattern, $parse=TS3_PARSED)
  267. {
  268. $pattern = $this->escape($pattern);
  269. return $this->perform("channelfind pattern=$cid", $parse);
  270. }
  271. public function r_channelmove($cid, $newParentid, $sortorder='')
  272. {
  273. $cid = $this->escape($cid);
  274. $newParentid = $this->escape($newParentid);
  275. if( $sortorder !== '' ) $sortorder = ' order='.$this->escape($sortorder);
  276. //echo "channelmove cid=$cid cpid=$newParentid$sortorder\n";
  277. return $this->performResultless("channelmove cid=$cid cpid=$newParentid$sortorder");
  278. }
  279. public function r_channelcreate($name, $props, $parse=TS3_PARSED, $escape=true)
  280. {
  281. if( !is_array($props) ) return false;
  282. if( $escape )
  283. {
  284. $name = $this->escape($name);
  285. $props = $this->escape($props);
  286. }
  287. $countProps = count($props);
  288. for($i=0; $i<$countProps; $i++)
  289. {
  290. $props[$i] = $props[$i][0].'='.$props[$i][1];
  291. }
  292. $propString = implode(' ', $props);
  293. return $this->perform("channelcreate channel_name=$name $propString", $parse);
  294. }
  295. public function r_channeledit($cid, $props)
  296. {
  297. if( !is_array($props) ) return false;
  298. $cid = $this->escape($cid);
  299. $props = $this->escape($props);
  300. $countProps = count($props);
  301. for($i=0; $i<$countProps; $i++)
  302. {
  303. $props[$i] = $props[$i][0].'='.$props[$i][1];
  304. }
  305. $propString = implode(' ', $props);
  306. return $this->performResultless("channeledit cid=$cid $propString");
  307. }
  308. public function r_channeldelete($cid, $force=1)
  309. {
  310. $cid = $this->escape($cid);
  311. if( $force != 0 ) $force = 1;
  312. return $this->performResultless("channeldelete cid=$cid force=$force");
  313. }
  314. public function r_channelpermlist($cid, $parse=TS3_PARSED)
  315. {
  316. $cid = $this->escape($cid);
  317. return $this->perform("channelpermlist cid=$cid", $parse);
  318. }
  319. public function r_channeladdperm($cid, $perms)
  320. {
  321. $cid = $this->escape($cid);
  322. $perms = $this->escape($perms);
  323. $countPerms = count($perms);
  324. for($i=0; $i<$countPerms; $i++)
  325. {
  326. $perms[$i] = $perms[$i][0].'='.$perms[$i][1].' '.$perms[$i][2].'='.$perms[$i][3];
  327. }
  328. $permString = implode('|', $perms);
  329. return $this->performResultless("channeladdperm cid=$cid $permString");
  330. }
  331. public function r_channeldelperm($cid, $perms)
  332. {
  333. $cid = $this->escape($cid);
  334. $perms = $this->escape($perms);
  335. $countPerms = count($perms);
  336. for($i=0; $i<$countPerms; $i++)
  337. {
  338. $perms[$i] = $perms[$i][0].'='.$perms[$i][1];
  339. }
  340. $permString = implode('|', $perms);
  341. return $this->performResultless("channeldelperm cid=$cid $permString");
  342. }
  343. public function r_channelgrouplist($parse=TS3_PARSED)
  344. {
  345. return $this->perform("channelgrouplist", $parse);
  346. }
  347. public function r_channelgroupadd($name, $parse=TS3_PARSED)
  348. {
  349. $name = $this->escape($name);
  350. return $this->perform("channelgroupadd name=$name", $parse);
  351. }
  352. public function r_channelgroupdel($cgid, $force=1)
  353. {
  354. $cgid = $this->escape($cgid);
  355. if( $force != 0 ) $force = 1;
  356. return $this->performResultless("channelgroupdel cgid=$cgid force=$force");
  357. }
  358. public function r_channelgrouprename($cgid, $name)
  359. {
  360. $cgid = $this->escape($cgid);
  361. $name = $this->escape($name);
  362. return $this->performResultless("channelgrouprename cgid=$cgid name=$name");
  363. }
  364. public function r_channelgroupaddperm($cgid, $perms)
  365. {
  366. $cgid = $this->escape($cgid);
  367. $perms = $this->escape($perms);
  368. $countPerms = count($perms);
  369. for($i=0; $i<$countPerms; $i++)
  370. {
  371. $perms[$i] = $perms[$i][0].'='.$perms[$i][1].' '.$perms[$i][2].'='.$perms[$i][3];
  372. }
  373. $permString = implode('|', $perms);
  374. return $this->performResultless("channelgroupaddperm cid=$cgid $permString");
  375. }
  376. public function r_channelgroupdelperm($cgid, $perms)
  377. {
  378. $cgid = $this->escape($cgid);
  379. $perms = $this->escape($perms);
  380. $countPerms = count($perms);
  381. for($i=0; $i<$countPerms; $i++)
  382. {
  383. $perms[$i] = $perms[$i][0].'='.$perms[$i][1];
  384. }
  385. $permString = implode('|', $perms);
  386. return $this->performResultless("channelgroupdelperm cid=$cgid $permString");
  387. }
  388. public function r_channelgrouppermlist($cgid, $parse=TS3_PARSED)
  389. {
  390. $cgid = $this->escape($cgid);
  391. return $this->perform("channelgrouppermlist cgid=$cgid", $parse);
  392. }
  393. public function r_channelgroupclientlist($cid=0, $clid=0, $cgid=0, $parse=TS3_PARSED)
  394. {
  395. if( $cid != 0 && $cid != false ) $cid = ' cid='.$this->escape($cid);
  396. if( $clid != 0 && $clid != false ) $clid = ' clid='.$this->escape($clid);
  397. if( $cgid != 0 && $cgid != false ) $cgid = ' cgid='.$this->escape($cgid);
  398. return $this->perform("channelgroupclientlist$cid$clid$cgid", $parse);
  399. }
  400. public function r_setclientchannelgroup($cgid, $cid, $cldbid)
  401. {
  402. $cgid = $this->escape($cgid);
  403. $cid = $this->escape($cid);
  404. $cldbid = $this->escape($cldbid);
  405. return $this->performResultless("setclientchannelgroup cgid=$cgid cid=$cid cldbid=$cldbid");
  406. }
  407. public function r_clientlist($uid='', $away='', $voice='', $groups='', $info='', $parse=TS3_PARSED)
  408. {
  409. if( $uid != '' ) $uid = ' -uid';
  410. if( $away != '' ) $away = ' -away';
  411. if( $voice != '' ) $voice = ' -voice';
  412. if( $groups != '' ) $groups = ' -groups';
  413. if( $info != '' ) $info = ' -info';
  414. return $this->perform("clientlist$uid$away$voice$groups$info", $parse);
  415. }
  416. public function r_clientinfo($clid, $parse=TS3_PARSED)
  417. {
  418. $clid = $this->escape($clid);
  419. return $this->perform("clientinfo clid=$clid", $parse);
  420. }
  421. public function r_clientfind($namePattern, $parse=TS3_PARSED)
  422. {
  423. $namePattern = $this->escape($namePattern);
  424. return $this->perform("clientfind pattern=$namePattern", $parse);
  425. }
  426. public function r_clientedit($clid, $props)
  427. {
  428. $clid = $this->escape($clid);
  429. $props = $this->escape($props);
  430. $countProps = count($props);
  431. for($i=0; $i<$countProps; $i++)
  432. {
  433. $props[$i] = $props[$i][0].'='.$props[$i][1];
  434. }
  435. $propString = implode(' ', $props);
  436. return $this->performResultless("clientedit clid=$clid $propString");
  437. }
  438. public function r_clientdblist($parse=TS3_PARSED)
  439. {
  440. return $this->perform("clientdblist", $parse);
  441. }
  442. public function r_clientdbfind($clPattern, $uid='', $parse=TS3_PARSED)
  443. {
  444. $clPattern = $this->escape($clPattern);
  445. if( $uid != '' ) $uid = ' -uid';
  446. return $this->perform("clientdbfind pattern=$clPattern$uid", $parse);
  447. }
  448. public function r_clientdbedit($cldbid, $props)
  449. {
  450. $cldbid = $this->escape($cldbid);
  451. $countProps = count($props);
  452. for($i=0; $i<$countProps; $i++)
  453. {
  454. $props[$i] = $props[$i][0].'='.$props[$i][1];
  455. }
  456. $propString = implode(' ', $props);
  457. return $this->performResultless("clientdbedit cldbid=$cldbid $propString");
  458. }
  459. public function r_clientdbdelete($cldbid)
  460. {
  461. $cldbid = $this->escape($cldbid);
  462. return $this->performResultless("clientdbdelete cldbid=$cldbid");
  463. }
  464. public function r_clientgetids($cluid, $parse=TS3_PARSED)
  465. {
  466. $cluid = $this->escape($cluid);
  467. return $this->perform("clientgetids cluid=$cluid", $parse);
  468. }
  469. public function r_clientgetdbidfromuid($cluid, $parse=TS3_PARSED)
  470. {
  471. $cluid = $this->escape($cluid);
  472. return $this->perform("clientgetdbidfromuid cluid=$cluid", $parse);
  473. }
  474. public function r_clientgetnamefromuid($cluid, $parse=TS3_PARSED)
  475. {
  476. $cluid = $this->escape($cluid);
  477. return $this->perform("clientgetnamefromuid cluid=$cluid", $parse);
  478. }
  479. public function r_clientgetnamefromdbid($cldbid, $parse=TS3_PARSED)
  480. {
  481. $cldbid = $this->escape($cldbid);
  482. return $this->perform("clientgetnamefromdbid cldbid=$cldbid", $parse);
  483. }
  484. public function r_clientsetserverquerylogin($name, $parse=TS3_PARSED)
  485. {
  486. $name = $this->escape($name);
  487. return $this->perform("clientsetserverquerylogin client_login_name=$name", $parse);
  488. }
  489. public function r_clientupdate($props)
  490. {
  491. $countProps = count($props);
  492. for($i=0; $i<$countProps; $i++)
  493. {
  494. $props[$i] = $this->escape($props[$i][0]).'='.$this->escape($props[$i][1]);
  495. }
  496. $propString = implode(' ', $props);
  497. return $this->performResultless("clientupdate $propString");
  498. }
  499. public function r_clientmove($clid, $cid, $cpw='')
  500. {
  501. $clid = $this->escape($clid);
  502. $cid = $this->escape($cid);
  503. if( $cpw != '' ) $cpw = ' cpw='.$this->escape($cpw);
  504. if( is_array($clid) )
  505. {
  506. $countClid = count($clid);
  507. for($i=0; $i<$countClid; $i++)
  508. {
  509. $clid[$i] = $clid[$i][0].'='.$clid[$i][1];
  510. }
  511. $clidString = implode('|', $clid);
  512. }
  513. else
  514. {
  515. $clidString = ' clid='.$clid;
  516. }
  517. return $this->performResultless("clientmove $clidString cid=$cid$cpw");
  518. }
  519. public function r_clientkick($clid, $reasonid=5, $reasonmsg='')
  520. {
  521. $clid = $this->escape($clid);
  522. $reasonid = $this->escape($reasonid);
  523. if( $reasonmsg != '' ) $reasonmsg = ' reasonmsg='.$this->escape($reasonmsg);
  524. if( is_array($clid) )
  525. {
  526. $countClid = count($clid);
  527. for($i=0; $i<$countClid; $i++)
  528. {
  529. $clid[$i] = $clid[$i][0].'='.$clid[$i][1];
  530. }
  531. $clidString = implode('|', $clid);
  532. }
  533. else
  534. {
  535. $clidString = ' clid='.$clid;
  536. }
  537. return $this->performResultless("clientkick $clidString reasonid=$reasonid$reasonmsg");
  538. }
  539. public function r_clientpoke($clid, $msg)
  540. {
  541. $clid = $this->escape($clid);
  542. $msg = $this->escape($msg);
  543. if( is_array($clid) )
  544. {
  545. $countClid = count($clid);
  546. for($i=0; $i<$countClid; $i++)
  547. {
  548. $clid[$i] = $clid[$i][0].'='.$clid[$i][1];
  549. }
  550. $clidString = implode('|', $clid);
  551. }
  552. else
  553. {
  554. $clidString = ' clid='.$clid;
  555. }
  556. return $this->performResultless("clientpoke $clidString msg=$msg");
  557. }
  558. public function r_clientpermlist($cldbid, $parse=TS3_PARSED)
  559. {
  560. $cldbid = $this->escape($cldbid);
  561. return $this->perform("clientpermlist cldbid=$cldbid", $parse);
  562. }
  563. public function r_clientaddperm($cldbid, $perms)
  564. {
  565. $cldbid = $this->escape($cldbid);
  566. $perms = $this->escape($perms);
  567. $countPerms = count($perms);
  568. for($i=0; $i<$countPerms; $i++)
  569. {
  570. $perms[$i] = $perms[$i][0].'='.$perms[$i][1].' '.$perms[$i][2].'='.$perms[$i][3].' '.$perms[$i][4].'='.$perms[$i][5];
  571. }
  572. $permString = implode('|', $perms);
  573. return $this->performResultless("clientaddperm cldbid=$cldbid $permString");
  574. }
  575. public function r_clientdelperm($cldbid, $perms)
  576. {
  577. $cldbid = $this->escape($cldbid);
  578. $perms = $this->escape($perms);
  579. $countPerms = count($perms);
  580. for($i=0; $i<$countPerms; $i++)
  581. {
  582. $perms[$i] = $perms[$i][0].'='.$perms[$i][1];
  583. }
  584. $permString = implode('|', $perms);
  585. return $this->performResultless("clientdelperm cldbid=$cldbid $permString");
  586. }
  587. public function r_channelclientpermlist($cid, $cldbid, $parse=TS3_PARSED)
  588. {
  589. $cid = $this->escape($cid);
  590. $cldbid = $this->escape($cldbid);
  591. return $this->perform("channelclientpermlist cid=$cid cldbid=$cldbid", $parse);
  592. }
  593. public function r_channelclientaddperm($cid, $cldbid, $perms)
  594. {
  595. $cid = $this->escape($cid);
  596. $cldbid = $this->escape($cldbid);
  597. $perms = $this->escape($perms);
  598. $countPerms = count($perms);
  599. for($i=0; $i<$countPerms; $i++)
  600. {
  601. $perms[$i] = $perms[$i][0].'='.$perms[$i][1].' '.$perms[$i][2].'='.$perms[$i][3];
  602. }
  603. $permString = implode('|', $perms);
  604. return $this->performResultless("channelclientaddperm cid=$cid cldbid=$cldbid $permString");
  605. }
  606. public function r_channelclientdelperm($cid, $cldbid, $perms)
  607. {
  608. $cid = $this->escape($cid);
  609. $cldbid = $this->escape($cldbid);
  610. $perms = $this->escape($perms);
  611. $countPerms = count($perms);
  612. for($i=0; $i<$countPerms; $i++)
  613. {
  614. $perms[$i] = $perms[$i][0].'='.$perms[$i][1];
  615. }
  616. $permString = implode('|', $perms);
  617. return $this->performResultless("channelclientdelperm cid=$cid cldbid=$cldbid $permString");
  618. }
  619. public function r_permissionlist($parse=TS3_PARSED)
  620. {
  621. return $this->perform("permissionlist", $parse);
  622. }
  623. public function r_permoverview($cid, $cldbid, $permid=0, $parse=TS3_PARSED)
  624. {
  625. $cid = $this->escape($cid);
  626. $cldbid = $this->escape($cldbid);
  627. $permid = $this->escape($permid);
  628. return $this->perform("permoverview cid=$cid cldbid=$cldbid permid=$permid", $parse);
  629. }
  630. public function r_permfind($permid, $parse=TS3_PARSED)
  631. {
  632. $permid = $this->escape($permid);
  633. return $this->perform("permfind permid=$permid", $parse);
  634. }
  635. public function r_tokenlist($parse=TS3_PARSED)
  636. {
  637. return $this->perform("tokenlist", $parse);
  638. }
  639. public function r_tokenadd($tokentype, $tokenid1, $tokenid2=0, $parse=TS3_PARSED)
  640. {
  641. $tokentype = $this->escape($tokentype);
  642. $tokenid1 = $this->escape($tokenid1);
  643. $tokenid2 = $this->escape($tokenid2);
  644. return $this->perform("tokenadd tokentype=$tokentype tokenid1=$tokenid1 tokenid2=$tokenid2", $parse);
  645. }
  646. public function r_tokendelete($tokenkey)
  647. {
  648. $tokenkey = $this->escape($tokenkey);
  649. return $this->performResultless("tokendelete token=$tokenkey");
  650. }
  651. public function r_tokenuse($tokenkey)
  652. {
  653. $tokenkey = $this->escape($tokenkey);
  654. return $this->performResultless("tokenuse token=$tokenkey");
  655. }
  656. public function r_messagelist($parse=TS3_PARSED)
  657. {
  658. return $this->perform("messagelist", $parse);
  659. }
  660. public function r_messageadd($cluid, $subject, $msg)
  661. {
  662. $cluid = $this->escape($cluid);
  663. $subject = $this->escape($subject);
  664. $msg = $this->escape($msg);
  665. return $this->performResultless("messageadd cluid=$cluid subject=$subject message=$msg");
  666. }
  667. public function r_messageget($msgid, $parse=TS3_PARSED)
  668. {
  669. $msgid = $this->escape($msgid);
  670. return $this->perform("messageget msgid=$msgid", $parse);
  671. }
  672. public function r_messageupdateflag($msgid, $readflag)
  673. {
  674. $msgid = $this->escape($msgid);
  675. if( $readflag != 0 ) $readflag = 1;
  676. return $this->performResultless("messageupdateflag msgid=$msgid flag=$readflag");
  677. }
  678. public function r_messagedel($msgid)
  679. {
  680. $msgid = $this->escape($msgid);
  681. return $this->performResultless("messagedel msgid=$msgid");
  682. }
  683. public function r_complainlist($targetcldbid="", $parse=TS3_PARSED)
  684. {
  685. if( $targetcldbid != "" ) $targetcldbid = ' tcldbid='.$this->escape($targetcldbid);
  686. return $this->perform("complainlist$targetcldbid", $parse);
  687. }
  688. public function r_complainadd($targetcldbid, $msg, $parse=TS3_PARSED)
  689. {
  690. $targetcldbid = $this->escape($targetcldbid);
  691. $msg = $this->escape($msg);
  692. return $this->perform("complainadd tcldbid=$targetcldbid message=$msg", $parse);
  693. }
  694. // 2. from id = client who complained about the target
  695. public function r_complaindel($targetcldbid, $fromcldbid)
  696. {
  697. $targetcldbid = $this->escape($targetcldbid);
  698. $fromcldbid = $this->escape($fromcldbid);
  699. return $this->performResultless("complaindel tcldbid=$targetcldbid fcldbid=$fromcldbid");
  700. }
  701. public function r_complaindelall($targetcldbid)
  702. {
  703. $targetcldbid = $this->escape($targetcldbid);
  704. return $this->performResultless("complaindelall tcldbid=$targetcldbid");
  705. }
  706. public function r_banclient($clid, $time=0, $reason="", $parse=TS3_PARSED)
  707. {
  708. $clid = $this->escape($clid);
  709. if( $time != 0 ) $time = ' time='.$this->escape($time);
  710. else $time = '';
  711. if( $reason != '' ) $reason = ' banreason='.$this->escape($reason);
  712. return $this->perform("banclient clid=$clid$time$reason", $parse);
  713. }
  714. public function r_banlist($parse=TS3_PARSED)
  715. {
  716. return $this->perform("banlist", $parse);
  717. }
  718. public function r_banadd($ip='', $name='', $uid='', $time=0, $reason="", $parse=TS3_PARSED)
  719. {
  720. if( $ip != '' ) $ip = ' ip='.$this->escape($ip);
  721. if( $name != '' ) $name = ' name='.$this->escape($name);
  722. if( $uid != '' ) $uid = ' uid='.$this->escape($uid);
  723. if( $ip == '' && $name == '' && $uid == '' ) return false;
  724. if( $time != 0 ) $time = ' time='.$this->escape($time);
  725. else $time = '';
  726. if( $reason != '' ) $reason = ' banreason='.$this->escape($reason);
  727. return $this->perform("banadd$ip$name$uid$time$reason", $parse);
  728. }
  729. public function r_bandel($banid)
  730. {
  731. $banid = $this->escape($banid);
  732. return $this->performResultless("bandel banid=$banid");
  733. }
  734. public function r_bandelall()
  735. {
  736. return $this->performResultless("bandelall");
  737. }
  738. /*
  739. * ALL FILETRANSFER COMMANDS ARE STILL MISSING
  740. */
  741. public function r_whoami($parse=TS3_PARSED)
  742. {
  743. return $this->perform("whoami", $parse);
  744. }
  745. /*
  746. public function r_($parse=TS3_PARSED)
  747. {
  748. return $this->perform("", $parse);
  749. }
  750. public function r_()
  751. {
  752. return $this->performResultless("");
  753. }
  754. */
  755. }
  756. //$remote = new TS3remote('xxx.xxx.xxx.xxx', 10011);
  757. //var_dump($remote->r_login('admin', 'xxxxxxxx'));
  758. //var_dump($remote->r_use(8));
  759. //var_dump($remote->r_sendtextmessage(1, 2, 'Hi!'));
  760. //var_dump($remote->r_clientpoke(2, 'p0k3d!'));
  761. //var_dump($remote->r_serveredit('virtualserver_name','TS3 Server'));
  762. ?>