Completed
Pull Request — master (#1)
by
unknown
02:17
created
API/TeamSpeak3.php 3 patches
Indentation   +4192 added lines, -4193 removed lines patch added patch discarded remove patch
@@ -49,11 +49,11 @@  discard block
 block discarded – undo
49 49
 //*******************************************************************************************
50 50
 
51 51
 /**
52
-  * runtime is an private handle and configuration storage
53
-  *
54
-  * @author     Par0noid Solutions
55
-  */
56
-	private $runtime = array('socket' => '', 'selected' => false, 'host' => '', 'queryport' => '10011', 'timeout' => 2, 'debug' => array(), 'fileSocket' => '');
52
+ * runtime is an private handle and configuration storage
53
+ *
54
+ * @author     Par0noid Solutions
55
+ */
56
+    private $runtime = array('socket' => '', 'selected' => false, 'host' => '', 'queryport' => '10011', 'timeout' => 2, 'debug' => array(), 'fileSocket' => '');
57 57
 
58 58
 
59 59
 //*******************************************************************************************	
@@ -61,3958 +61,3957 @@  discard block
 block discarded – undo
61 61
 //******************************************************************************************
62 62
 
63 63
 /**
64
-  * banAddByIp
65
-  *
66
-  * Adds a new ban rule on the selected virtual server.
67
-  *
68
-  *	<b>Output:</b>
69
-  * <pre>
70
-  * Array
71
-  * {
72
-  *  [banid] => 109
73
-  * }
74
-  * </pre>
75
-  *
76
-  * @author     Par0noid Solutions
77
-  * @param		string	$ip			clientIp
78
-  * @param		integer	$time		bantime in seconds (0=unlimited/default)  [optional]
79
-  * @param		string	$banreason	Banreason [optional]
80
-  * @return     array banId
81
-  */
82
-	function banAddByIp($ip, $time = 0, $banreason = NULL) {
83
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
64
+ * banAddByIp
65
+ *
66
+ * Adds a new ban rule on the selected virtual server.
67
+ *
68
+ *	<b>Output:</b>
69
+ * <pre>
70
+ * Array
71
+ * {
72
+ *  [banid] => 109
73
+ * }
74
+ * </pre>
75
+ *
76
+ * @author     Par0noid Solutions
77
+ * @param		string	$ip			clientIp
78
+ * @param		integer	$time		bantime in seconds (0=unlimited/default)  [optional]
79
+ * @param		string	$banreason	Banreason [optional]
80
+ * @return     array banId
81
+ */
82
+    function banAddByIp($ip, $time = 0, $banreason = NULL) {
83
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
84 84
 		
85
-		if(!empty($banreason)) { $msg = ' banreason='.$this->escapeText($banreason); } else { $msg = NULL; }
86
-
87
-		return $this->getData('array', 'banadd ip='.$ip.' time='.$time.$msg);
88
-	}
89
-
90
-/**
91
-  * banAddByUid
92
-  *
93
-  *	Adds a new ban rule on the selected virtual server.
94
-  *
95
-  * <b>Output:</b>
96
-  * <pre>
97
-  * Array
98
-  * {
99
-  *  [banid] => 110
100
-  * }
101
-  * </pre>
102
-  *
103
-  * @author     Par0noid Solutions
104
-  * @param		string	$uid		clientUniqueId
105
-  * @param		integer	$time		bantime in seconds (0=unlimited/default)  [optional]
106
-  * @param		string	$banreason	Banreason [optional]
107
-  * @return     array banId
108
-  */
109
-	function banAddByUid($uid, $time = 0, $banreason = NULL) {
110
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
85
+        if(!empty($banreason)) { $msg = ' banreason='.$this->escapeText($banreason); } else { $msg = NULL; }
86
+
87
+        return $this->getData('array', 'banadd ip='.$ip.' time='.$time.$msg);
88
+    }
89
+
90
+/**
91
+ * banAddByUid
92
+ *
93
+ *	Adds a new ban rule on the selected virtual server.
94
+ *
95
+ * <b>Output:</b>
96
+ * <pre>
97
+ * Array
98
+ * {
99
+ *  [banid] => 110
100
+ * }
101
+ * </pre>
102
+ *
103
+ * @author     Par0noid Solutions
104
+ * @param		string	$uid		clientUniqueId
105
+ * @param		integer	$time		bantime in seconds (0=unlimited/default)  [optional]
106
+ * @param		string	$banreason	Banreason [optional]
107
+ * @return     array banId
108
+ */
109
+    function banAddByUid($uid, $time = 0, $banreason = NULL) {
110
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
111 111
 		
112
-		if(!empty($banreason)) { $msg = ' banreason='.$this->escapeText($banreason); } else { $msg = NULL; }
112
+        if(!empty($banreason)) { $msg = ' banreason='.$this->escapeText($banreason); } else { $msg = NULL; }
113 113
 		
114
-		return $this->getData('array', 'banadd uid='.$uid.' time='.$time.$msg);
115
-	}
116
-
117
-/**
118
-  * banAddByName
119
-  *
120
-  *	Adds a new ban rule on the selected virtual server.
121
-  *
122
-  * <b>Output:</b>
123
-  * <pre>
124
-  * Array
125
-  * {
126
-  *  [banid] => 111
127
-  * }
128
-  * </pre>
129
-  *
130
-  * @author     Par0noid Solutions
131
-  * @param		string	$name		clientName
132
-  * @param		integer	$time		bantime in seconds (0=unlimited/default)  [optional]
133
-  * @param		string	$banreason	Banreason [optional]
134
-  * @return     array banId
135
-  */
136
-	function banAddByName($name, $time = 0, $banreason = NULL) {
137
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
114
+        return $this->getData('array', 'banadd uid='.$uid.' time='.$time.$msg);
115
+    }
116
+
117
+/**
118
+ * banAddByName
119
+ *
120
+ *	Adds a new ban rule on the selected virtual server.
121
+ *
122
+ * <b>Output:</b>
123
+ * <pre>
124
+ * Array
125
+ * {
126
+ *  [banid] => 111
127
+ * }
128
+ * </pre>
129
+ *
130
+ * @author     Par0noid Solutions
131
+ * @param		string	$name		clientName
132
+ * @param		integer	$time		bantime in seconds (0=unlimited/default)  [optional]
133
+ * @param		string	$banreason	Banreason [optional]
134
+ * @return     array banId
135
+ */
136
+    function banAddByName($name, $time = 0, $banreason = NULL) {
137
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
138 138
 		
139
-		if(!empty($banreason)) { $msg = ' banreason='.$this->escapeText($banreason); } else { $msg = NULL; }
139
+        if(!empty($banreason)) { $msg = ' banreason='.$this->escapeText($banreason); } else { $msg = NULL; }
140 140
 										
141
-		return $this->getData('array', 'banadd name='.$this->escapeText($name).' time='.$time.$msg);
142
-	}
143
-
144
-/**
145
-  * banClient
146
-  * 
147
-  * 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.
148
-  *
149
-  * <b>Output:</b>
150
-  * <pre>
151
-  * Array
152
-  * {
153
-  *  [1] => 129
154
-  *  [2] => 130
155
-  * }
156
-  * </pre>
157
-  *
158
-  * @author     Par0noid Solutions
159
-  * @param		integer $clid		clientId
160
-  * @param		integer $time		bantime in seconds (0=unlimited/default)  [optional]
161
-  * @param		string	$banreason	Banreason [optional]
162
-  * @return     array banIds
163
-  */
164
-	function banClient($clid, $time = 0, $banreason = NULL) {
165
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
141
+        return $this->getData('array', 'banadd name='.$this->escapeText($name).' time='.$time.$msg);
142
+    }
143
+
144
+/**
145
+ * banClient
146
+ * 
147
+ * 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.
148
+ *
149
+ * <b>Output:</b>
150
+ * <pre>
151
+ * Array
152
+ * {
153
+ *  [1] => 129
154
+ *  [2] => 130
155
+ * }
156
+ * </pre>
157
+ *
158
+ * @author     Par0noid Solutions
159
+ * @param		integer $clid		clientId
160
+ * @param		integer $time		bantime in seconds (0=unlimited/default)  [optional]
161
+ * @param		string	$banreason	Banreason [optional]
162
+ * @return     array banIds
163
+ */
164
+    function banClient($clid, $time = 0, $banreason = NULL) {
165
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
166 166
 		
167
-		if(!empty($banreason)) { $msg = ' banreason='.$this->escapeText($banreason); } else { $msg = ''; }
167
+        if(!empty($banreason)) { $msg = ' banreason='.$this->escapeText($banreason); } else { $msg = ''; }
168 168
 		
169
-		$result = $this->getData('plain', 'banclient clid='.$clid.' time='.$time.$msg);
169
+        $result = $this->getData('plain', 'banclient clid='.$clid.' time='.$time.$msg);
170 170
 		
171
-		if($result['success']) {
172
-			return $this->generateOutput(true, $result['errors'], $this->splitBanIds($result['data']));
173
-		}else{
174
-			return $this->generateOutput(false, $result['errors'], false);
175
-		}
176
-	}
177
-
178
-/**
179
-  * banDelete
180
-  * 
181
-  * Deletes the ban rule with ID banid from the server.
182
-  *
183
-  * @author     Par0noid Solutions
184
-  * @param		integer $banID	banID
185
-  * @return     boolean success
186
-  */
187
-	function banDelete($banID) {
188
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
189
-		return $this->getData('boolean', 'bandel banid='.$banID);
190
-	}
191
-
192
-/**
193
-  * banDeleteAll
194
-  * 
195
-  * Deletes all active ban rules from the server.
196
-  *
197
-  * @author     Par0noid Solutions
198
-  * @return     boolean success
199
-  */
200
-	function banDeleteAll() {
201
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
202
-		return $this->getData('boolean', 'bandelall');
203
-	}
204
-
205
-/**
206
-  * banList
207
-  * 
208
-  * Displays a list of active bans on the selected virtual server.
209
-  * 
210
-  * <b>Output:</b>
211
-  * <pre>
212
-  * Array
213
-  * {
214
-  *  [banid] => 131
215
-  *  [ip] => 1.2.3.4
216
-  *  [name] => eugen
217
-  *  [uid] => IYAntAcZHgVC7s3n3DNWmuJB/aM=
218
-  *  [created] => 1286660391
219
-  *  [duration] => 0
220
-  *  [invokername] => Par0noid
221
-  *  [invokercldbid] => 2086
222
-  *  [invokeruid] => nUixbsq/XakrrmbqU8O30R/D8Gc=
223
-  *  [reason] => insult
224
-  *  [enforcements] => 0
225
-  * }
226
-  * </pre>
227
-  *
228
-  * @author     Par0noid Solutions
229
-  * @return     array banlist
230
-  */
231
-	function banList() {
232
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }		
233
-		return $this->getData('multi', 'banlist');
234
-	}
235
-
236
-/**
237
-  * bindingList
238
-  * 
239
-  * Displays a list of IP addresses used by the server instance on multi-homed machines.
240
-  *
241
-  * <b>Output:</b>
242
-  * <pre>
243
-  * Array
244
-  * {
245
-  *  [ip] => 0.0.0.0
246
-  * }
247
-  * </pre>
248
-  *
249
-  * @author     Par0noid Solutions
250
-  * @return     array bindingList
251
-  */
252
-	function bindingList() {
253
-		return $this->getData('multi', 'bindinglist');
254
-	}
255
-
256
-/**
257
-  * channelAddPerm
258
-  * 
259
-  * 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.
260
-  * 
261
-  * <b>Input-Array like this:</b>
262
-  * <pre>
263
-  * $permissions = array();
264
-  * $permissions['permissionID'] = 'permissionValue';
265
-  * //or you could use Permission Name
266
-  * $permissions['permissionName'] = 'permissionValue';
267
-  * </pre>
268
-  *
269
-  * @author     Par0noid Solutions
270
-  * @param		integer	$cid			channelId
271
-  * @param		array	$permissions	permissions
272
-  * @return     boolean success
273
-  */
274
-	function channelAddPerm($cid, $permissions) {
275
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
171
+        if($result['success']) {
172
+            return $this->generateOutput(true, $result['errors'], $this->splitBanIds($result['data']));
173
+        }else{
174
+            return $this->generateOutput(false, $result['errors'], false);
175
+        }
176
+    }
177
+
178
+/**
179
+ * banDelete
180
+ * 
181
+ * Deletes the ban rule with ID banid from the server.
182
+ *
183
+ * @author     Par0noid Solutions
184
+ * @param		integer $banID	banID
185
+ * @return     boolean success
186
+ */
187
+    function banDelete($banID) {
188
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
189
+        return $this->getData('boolean', 'bandel banid='.$banID);
190
+    }
191
+
192
+/**
193
+ * banDeleteAll
194
+ * 
195
+ * Deletes all active ban rules from the server.
196
+ *
197
+ * @author     Par0noid Solutions
198
+ * @return     boolean success
199
+ */
200
+    function banDeleteAll() {
201
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
202
+        return $this->getData('boolean', 'bandelall');
203
+    }
204
+
205
+/**
206
+ * banList
207
+ * 
208
+ * Displays a list of active bans on the selected virtual server.
209
+ * 
210
+ * <b>Output:</b>
211
+ * <pre>
212
+ * Array
213
+ * {
214
+ *  [banid] => 131
215
+ *  [ip] => 1.2.3.4
216
+ *  [name] => eugen
217
+ *  [uid] => IYAntAcZHgVC7s3n3DNWmuJB/aM=
218
+ *  [created] => 1286660391
219
+ *  [duration] => 0
220
+ *  [invokername] => Par0noid
221
+ *  [invokercldbid] => 2086
222
+ *  [invokeruid] => nUixbsq/XakrrmbqU8O30R/D8Gc=
223
+ *  [reason] => insult
224
+ *  [enforcements] => 0
225
+ * }
226
+ * </pre>
227
+ *
228
+ * @author     Par0noid Solutions
229
+ * @return     array banlist
230
+ */
231
+    function banList() {
232
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }		
233
+        return $this->getData('multi', 'banlist');
234
+    }
235
+
236
+/**
237
+ * bindingList
238
+ * 
239
+ * Displays a list of IP addresses used by the server instance on multi-homed machines.
240
+ *
241
+ * <b>Output:</b>
242
+ * <pre>
243
+ * Array
244
+ * {
245
+ *  [ip] => 0.0.0.0
246
+ * }
247
+ * </pre>
248
+ *
249
+ * @author     Par0noid Solutions
250
+ * @return     array bindingList
251
+ */
252
+    function bindingList() {
253
+        return $this->getData('multi', 'bindinglist');
254
+    }
255
+
256
+/**
257
+ * channelAddPerm
258
+ * 
259
+ * 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.
260
+ * 
261
+ * <b>Input-Array like this:</b>
262
+ * <pre>
263
+ * $permissions = array();
264
+ * $permissions['permissionID'] = 'permissionValue';
265
+ * //or you could use Permission Name
266
+ * $permissions['permissionName'] = 'permissionValue';
267
+ * </pre>
268
+ *
269
+ * @author     Par0noid Solutions
270
+ * @param		integer	$cid			channelId
271
+ * @param		array	$permissions	permissions
272
+ * @return     boolean success
273
+ */
274
+    function channelAddPerm($cid, $permissions) {
275
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
276 276
 		
277
-		if(count($permissions) > 0) {
278
-			//Permissions given
277
+        if(count($permissions) > 0) {
278
+            //Permissions given
279 279
 			
280
-			//Errorcollector
281
-			$errors = array();
280
+            //Errorcollector
281
+            $errors = array();
282 282
 			
283
-			//Split Permissions to prevent query from overload
284
-			$permissions = array_chunk($permissions, 50, true);
283
+            //Split Permissions to prevent query from overload
284
+            $permissions = array_chunk($permissions, 50, true);
285 285
 			
286
-			//Action for each splitted part of permission
287
-			foreach($permissions as $permission_part)
288
-			{
289
-				//Create command_string for each command that we could use implode later
290
-				$command_string = array();
286
+            //Action for each splitted part of permission
287
+            foreach($permissions as $permission_part)
288
+            {
289
+                //Create command_string for each command that we could use implode later
290
+                $command_string = array();
291 291
 				
292
-				foreach($permission_part as $key => $value)
293
-				{
294
-					$command_string[] = (is_numeric($key) ? "permid=" : "permsid=").$this->escapeText($key).' permvalue='.$value;
295
-				}
292
+                foreach($permission_part as $key => $value)
293
+                {
294
+                    $command_string[] = (is_numeric($key) ? "permid=" : "permsid=").$this->escapeText($key).' permvalue='.$value;
295
+                }
296 296
 				
297
-				$result = $this->getData('boolean', 'channeladdperm cid='.$cid.' '.implode('|', $command_string));
297
+                $result = $this->getData('boolean', 'channeladdperm cid='.$cid.' '.implode('|', $command_string));
298 298
 				
299
-				if(!$result['success'])
300
-				{
301
-					foreach($result['errors'] as $error)
302
-					{
303
-						$errors[] = $error;
304
-					}
305
-				}
306
-			}
299
+                if(!$result['success'])
300
+                {
301
+                    foreach($result['errors'] as $error)
302
+                    {
303
+                        $errors[] = $error;
304
+                    }
305
+                }
306
+            }
307 307
 			
308
-			if(count($errors) == 0)
309
-			{
310
-				return $this->generateOutput(true, array(), true);
311
-			}else{
312
-				return $this->generateOutput(false, $errors, false);
313
-			}
308
+            if(count($errors) == 0)
309
+            {
310
+                return $this->generateOutput(true, array(), true);
311
+            }else{
312
+                return $this->generateOutput(false, $errors, false);
313
+            }
314 314
 			
315
-		}else{
316
-			// No permissions given
317
-			$this->addDebugLog('no permissions given');
318
-			return $this->generateOutput(false, array('Error: no permissions given'), false);
319
-		}
320
-	}
321
-
322
-/**
323
-  * channelClientAddPerm
324
-  * 
325
-  * 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.
326
-  * 
327
-  * <b>Input-Array like this:</b>
328
-  * <pre>
329
-  * $permissions = array();
330
-  * $permissions['permissionID'] = 'permissionValue';
331
-  * //or you could use Permission Name
332
-  * $permissions['permissionName'] = 'permissionValue';
333
-  * </pre>
334
-  *
335
-  * @author     Par0noid Solutions
336
-  * @param		integer		$cid			channelID
337
-  * @param		integer		$cldbid			clientDBID
338
-  * @param		array		$permissions	permissions
339
-  * @return     boolean success
340
-  */
341
-	function channelClientAddPerm($cid, $cldbid, $permissions) {
342
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
315
+        }else{
316
+            // No permissions given
317
+            $this->addDebugLog('no permissions given');
318
+            return $this->generateOutput(false, array('Error: no permissions given'), false);
319
+        }
320
+    }
321
+
322
+/**
323
+ * channelClientAddPerm
324
+ * 
325
+ * 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.
326
+ * 
327
+ * <b>Input-Array like this:</b>
328
+ * <pre>
329
+ * $permissions = array();
330
+ * $permissions['permissionID'] = 'permissionValue';
331
+ * //or you could use Permission Name
332
+ * $permissions['permissionName'] = 'permissionValue';
333
+ * </pre>
334
+ *
335
+ * @author     Par0noid Solutions
336
+ * @param		integer		$cid			channelID
337
+ * @param		integer		$cldbid			clientDBID
338
+ * @param		array		$permissions	permissions
339
+ * @return     boolean success
340
+ */
341
+    function channelClientAddPerm($cid, $cldbid, $permissions) {
342
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
343 343
 		
344
-		if(count($permissions) > 0) {
345
-			//Permissions given
344
+        if(count($permissions) > 0) {
345
+            //Permissions given
346 346
 				
347
-			//Errorcollector
348
-			$errors = array();
347
+            //Errorcollector
348
+            $errors = array();
349 349
 				
350
-			//Split Permissions to prevent query from overload
351
-			$permissions = array_chunk($permissions, 50, true);
350
+            //Split Permissions to prevent query from overload
351
+            $permissions = array_chunk($permissions, 50, true);
352 352
 				
353
-			//Action for each splitted part of permission
354
-			foreach($permissions as $permission_part)
355
-			{
356
-				//Create command_string for each command that we could use implode later
357
-				$command_string = array();
353
+            //Action for each splitted part of permission
354
+            foreach($permissions as $permission_part)
355
+            {
356
+                //Create command_string for each command that we could use implode later
357
+                $command_string = array();
358 358
 		
359
-				foreach($permission_part as $key => $value)
360
-				{
361
-					$command_string[] = (is_numeric($key) ? "permid=" : "permsid=").$this->escapeText($key).' permvalue='.$value;
362
-				}
359
+                foreach($permission_part as $key => $value)
360
+                {
361
+                    $command_string[] = (is_numeric($key) ? "permid=" : "permsid=").$this->escapeText($key).' permvalue='.$value;
362
+                }
363 363
 		
364
-				$result = $this->getData('boolean', 'channelclientaddperm cid='.$cid.' cldbid='.$cldbid.' '.implode('|', $command_string));
364
+                $result = $this->getData('boolean', 'channelclientaddperm cid='.$cid.' cldbid='.$cldbid.' '.implode('|', $command_string));
365 365
 		
366
-				if(!$result['success'])
367
-				{
368
-					foreach($result['errors'] as $error)
369
-					{
370
-						$errors[] = $error;
371
-					}
372
-				}
373
-			}
366
+                if(!$result['success'])
367
+                {
368
+                    foreach($result['errors'] as $error)
369
+                    {
370
+                        $errors[] = $error;
371
+                    }
372
+                }
373
+            }
374 374
 				
375
-			if(count($errors) == 0)
376
-			{
377
-				return $this->generateOutput(true, array(), true);
378
-			}else{
379
-				return $this->generateOutput(false, $errors, false);
380
-			}
375
+            if(count($errors) == 0)
376
+            {
377
+                return $this->generateOutput(true, array(), true);
378
+            }else{
379
+                return $this->generateOutput(false, $errors, false);
380
+            }
381 381
 				
382
-		}else{
383
-			// No permissions given
384
-			$this->addDebugLog('no permissions given');
385
-			return $this->generateOutput(false, array('Error: no permissions given'), false);
386
-		}
387
-	}
388
-
389
-/**
390
-  * channelClientDelPerm
391
-  * 
392
-  * 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.
393
-  *
394
-  * <b>Input-Array like this:</b>
395
-  * <pre>
396
-  * $permissions = array();
397
-  * $permissions[] = 'permissionID';
398
-  * $permissions[] = 'permissionName';
399
-  * //or
400
-  * $permissions = array('permissionID', 'permissionName', 'permissionID');
401
-  * </pre>
402
-  *
403
-  * @author     Par0noid Solutions
404
-  * @param		integer		$cid				channelID
405
-  * @param		integer		$cldbid				clientDBID
406
-  * @param		array		$permissions		permissions
407
-  * @return     boolean success
408
-  */
409
-	function channelClientDelPerm($cid, $cldbid, $permissions) {
410
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
411
-		$permissionArray = array();
382
+        }else{
383
+            // No permissions given
384
+            $this->addDebugLog('no permissions given');
385
+            return $this->generateOutput(false, array('Error: no permissions given'), false);
386
+        }
387
+    }
388
+
389
+/**
390
+ * channelClientDelPerm
391
+ * 
392
+ * 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.
393
+ *
394
+ * <b>Input-Array like this:</b>
395
+ * <pre>
396
+ * $permissions = array();
397
+ * $permissions[] = 'permissionID';
398
+ * $permissions[] = 'permissionName';
399
+ * //or
400
+ * $permissions = array('permissionID', 'permissionName', 'permissionID');
401
+ * </pre>
402
+ *
403
+ * @author     Par0noid Solutions
404
+ * @param		integer		$cid				channelID
405
+ * @param		integer		$cldbid				clientDBID
406
+ * @param		array		$permissions		permissions
407
+ * @return     boolean success
408
+ */
409
+    function channelClientDelPerm($cid, $cldbid, $permissions) {
410
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
411
+        $permissionArray = array();
412 412
 		
413
-		if(count($permissions) > 0) {
414
-			foreach($permissions AS $value) {
415
-				$permissionArray[] = is_numeric($value) ? 'permid='.$value : 'permsid='.$value;
416
-			}
417
-			return $this->getData('boolean', 'channelclientdelperm cid='.$cid.' cldbid='.$cldbid.' '.implode('|', $permissionArray));
418
-		}else{
419
-			$this->addDebugLog('no permissions given');
420
-			return $this->generateOutput(false, array('Error: no permissions given'), false);
421
-		}
422
-	}
423
-
424
-/**
425
-  * channelClientPermList
426
-  * 
427
-  * Displays a list of permissions defined for a client in a specific channel.
428
-  *
429
-  * <b>Output:</b>
430
-  * <pre>
431
-  * Array
432
-  * {
433
-  *  [cid] => 250 (only in first result)
434
-  *  [cldbid] => 2086 (only in first result)
435
-  *  [permid] => 12876 (if permsid = false)
436
-  *  [permsid] => b_client_info_view (if permsid = true)
437
-  *  [permvalue] => 1
438
-  *  [permnegated] => 0
439
-  *  [permskip] => 0
440
-  * }
441
-  * </pre>
442
-  *
443
-  * @author     Par0noid Solutions
444
-  * @param		integer		$cid		channelID
445
-  * @param		integer		$cldbid		clientDBID
446
-  * @param		boolean		$permsid	displays permissionName instead of permissionID
447
-  * @return     array	channelclientpermlist
448
-  */
449
-	function channelClientPermList($cid, $cldbid, $permsid = false) {
450
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }		
451
-		return $this->getData('multi', 'channelclientpermlist cid='.$cid.' cldbid='.$cldbid.($permsid ? ' -permsid' : ''));
452
-	}
453
-
454
-/**
455
-  * channelCreate
456
-  * 
457
-  * 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.
458
-  * 
459
-  * <b style="color:red">Hint:</b> don't forget to set channel_flag_semi_permanent = 1 or channel_flag_permanent = 1
460
-  * 
461
-  * <b style="color:red">Hint:</b> you'll get an error if you want to create a channel without channel_name
462
-  * 
463
-  * <b>Input-Array like this:</b>
464
-  * <pre>
465
-  * $data = array();
466
-  * 
467
-  * $data['setting'] = 'value';
468
-  * $data['setting'] = 'value';
469
-  * </pre>
470
-  * 
471
-  * <b>Output:</b>
472
-  * <pre>
473
-  * Array
474
-  * {
475
-  *  [cid] => 257
476
-  * }
477
-  * </pre>
478
-  *
479
-  * @author     Par0noid Solutions
480
-  * @param		array $data properties
481
-  * @return     array channelInfo
482
-  */
483
-	function channelCreate($data) {
484
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
413
+        if(count($permissions) > 0) {
414
+            foreach($permissions AS $value) {
415
+                $permissionArray[] = is_numeric($value) ? 'permid='.$value : 'permsid='.$value;
416
+            }
417
+            return $this->getData('boolean', 'channelclientdelperm cid='.$cid.' cldbid='.$cldbid.' '.implode('|', $permissionArray));
418
+        }else{
419
+            $this->addDebugLog('no permissions given');
420
+            return $this->generateOutput(false, array('Error: no permissions given'), false);
421
+        }
422
+    }
423
+
424
+/**
425
+ * channelClientPermList
426
+ * 
427
+ * Displays a list of permissions defined for a client in a specific channel.
428
+ *
429
+ * <b>Output:</b>
430
+ * <pre>
431
+ * Array
432
+ * {
433
+ *  [cid] => 250 (only in first result)
434
+ *  [cldbid] => 2086 (only in first result)
435
+ *  [permid] => 12876 (if permsid = false)
436
+ *  [permsid] => b_client_info_view (if permsid = true)
437
+ *  [permvalue] => 1
438
+ *  [permnegated] => 0
439
+ *  [permskip] => 0
440
+ * }
441
+ * </pre>
442
+ *
443
+ * @author     Par0noid Solutions
444
+ * @param		integer		$cid		channelID
445
+ * @param		integer		$cldbid		clientDBID
446
+ * @param		boolean		$permsid	displays permissionName instead of permissionID
447
+ * @return     array	channelclientpermlist
448
+ */
449
+    function channelClientPermList($cid, $cldbid, $permsid = false) {
450
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }		
451
+        return $this->getData('multi', 'channelclientpermlist cid='.$cid.' cldbid='.$cldbid.($permsid ? ' -permsid' : ''));
452
+    }
453
+
454
+/**
455
+ * channelCreate
456
+ * 
457
+ * 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.
458
+ * 
459
+ * <b style="color:red">Hint:</b> don't forget to set channel_flag_semi_permanent = 1 or channel_flag_permanent = 1
460
+ * 
461
+ * <b style="color:red">Hint:</b> you'll get an error if you want to create a channel without channel_name
462
+ * 
463
+ * <b>Input-Array like this:</b>
464
+ * <pre>
465
+ * $data = array();
466
+ * 
467
+ * $data['setting'] = 'value';
468
+ * $data['setting'] = 'value';
469
+ * </pre>
470
+ * 
471
+ * <b>Output:</b>
472
+ * <pre>
473
+ * Array
474
+ * {
475
+ *  [cid] => 257
476
+ * }
477
+ * </pre>
478
+ *
479
+ * @author     Par0noid Solutions
480
+ * @param		array $data properties
481
+ * @return     array channelInfo
482
+ */
483
+    function channelCreate($data) {
484
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
485 485
 		
486
-		$propertiesString = '';
486
+        $propertiesString = '';
487 487
 		
488
-		foreach($data as $key => $value) {
489
-			$propertiesString .= ' '.$key.'='.$this->escapeText($value);
490
-		}
488
+        foreach($data as $key => $value) {
489
+            $propertiesString .= ' '.$key.'='.$this->escapeText($value);
490
+        }
491 491
 		
492
-		return $this->getData('array', 'channelcreate '.$propertiesString);
493
-	}
494
-
495
-/**
496
-  * channelDelete
497
-  * 
498
-  * 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.
499
-  *
500
-  * @author     Par0noid Solutions
501
-  * @param		integer $cid channelID
502
-  * @param		integer $force {1|0} (default: 1)
503
-  * @return     boolean success
504
-  */
505
-	function channelDelete($cid, $force = 1) {
506
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
507
-		return $this->getData('boolean', 'channeldelete cid='.$cid.' force='.$force);
508
-	}
509
-
510
-/**
511
-  * channelDelPerm
512
-  * 
513
-  * 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.
514
-  *
515
-  * <b>Input-Array like this:</b>
516
-  * <pre>
517
-  * $permissions = array();
518
-  * $permissions[] = 'permissionID';
519
-  * //or you could use
520
-  * $permissions[] = 'permissionName';
521
-  * </pre>
522
-  *
523
-  * @author     Par0noid Solutions
524
-  * @param		integer		$cid				channelID
525
-  * @param		array		$permissions		permissions
526
-  * @return     boolean	success
527
-  */
528
-	function channelDelPerm($cid, $permissions) {
529
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
530
-		$permissionArray = array();
492
+        return $this->getData('array', 'channelcreate '.$propertiesString);
493
+    }
494
+
495
+/**
496
+ * channelDelete
497
+ * 
498
+ * 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.
499
+ *
500
+ * @author     Par0noid Solutions
501
+ * @param		integer $cid channelID
502
+ * @param		integer $force {1|0} (default: 1)
503
+ * @return     boolean success
504
+ */
505
+    function channelDelete($cid, $force = 1) {
506
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
507
+        return $this->getData('boolean', 'channeldelete cid='.$cid.' force='.$force);
508
+    }
509
+
510
+/**
511
+ * channelDelPerm
512
+ * 
513
+ * 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.
514
+ *
515
+ * <b>Input-Array like this:</b>
516
+ * <pre>
517
+ * $permissions = array();
518
+ * $permissions[] = 'permissionID';
519
+ * //or you could use
520
+ * $permissions[] = 'permissionName';
521
+ * </pre>
522
+ *
523
+ * @author     Par0noid Solutions
524
+ * @param		integer		$cid				channelID
525
+ * @param		array		$permissions		permissions
526
+ * @return     boolean	success
527
+ */
528
+    function channelDelPerm($cid, $permissions) {
529
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
530
+        $permissionArray = array();
531 531
 		
532
-		if(count($permissions) > 0) {
533
-			foreach($permissions AS $value) {
534
-				$permissionArray[] = (is_numeric($value) ? 'permid=' : 'permsid=').$value;
535
-			}
536
-			return $this->getData('boolean', 'channeldelperm cid='.$cid.' '.implode('|', $permissionArray));
537
-		}else{
538
-			$this->addDebugLog('no permissions given');
539
-			return $this->generateOutput(false, array('Error: no permissions given'), false);
540
-		}
541
-	}
542
-
543
-/**
544
-  * channelEdit
545
-  * 
546
-  * 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.
547
-  *
548
-  * <b>Input-Array like this:</b>
532
+        if(count($permissions) > 0) {
533
+            foreach($permissions AS $value) {
534
+                $permissionArray[] = (is_numeric($value) ? 'permid=' : 'permsid=').$value;
535
+            }
536
+            return $this->getData('boolean', 'channeldelperm cid='.$cid.' '.implode('|', $permissionArray));
537
+        }else{
538
+            $this->addDebugLog('no permissions given');
539
+            return $this->generateOutput(false, array('Error: no permissions given'), false);
540
+        }
541
+    }
542
+
543
+/**
544
+ * channelEdit
545
+ * 
546
+ * 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.
547
+ *
548
+ * <b>Input-Array like this:</b>
549 549
 	<pre>
550 550
 	$data = array();
551 551
 		
552 552
 	$data['setting'] = 'value';
553 553
 	$data['setting'] = 'value';
554 554
 	</pre>
555
-  *
556
-  * @author     Par0noid Solutions
557
-  * @param		integer	$cid	$channelID
558
-  * @param		array	$data	edited settings
559
-  * @return     boolean success
560
-  */
561
-	function channelEdit($cid, $data) {
562
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
563
-		
564
-		$settingsString = '';
565
-		
566
-		foreach($data as $key => $value) {
567
-			$settingsString .= ' '.$key.'='.$this->escapeText($value);
568
-		}
569
-
570
-		return $this->getData('boolean', 'channeledit cid='.$cid.$settingsString);
571
-	}
572
-
573
-/**
574
-  * channelFind
575
-  * 
576
-  * displays a list of channels matching a given name pattern.
577
-  *
578
-  * <b>Output:</b>
579
-  * <pre>
580
-  * Array
581
-  * {
582
-  *  [cid] => 2
583
-  *  [channel_name] => Lobby
584
-  * }
585
-  * </pre>
586
-  *
587
-  * @author     Par0noid Solutions
588
-  * @param		string	$pattern	channelName
589
-  * @return     array channelList 
590
-  */
591
-	function channelFind($pattern) {
592
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
593
-		return $this->getData('multi', 'channelfind pattern='.$this->escapeText($pattern));
594
-	}
595
-
596
-/**
597
-  * channelGroupAdd
598
-  * 
599
-  * 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.
600
-  *
601
-  * <b>groupDbTypes:</b>
602
-  *	<ol start="0">
603
-  *		<li>template group (used for new virtual servers)</li>
604
-  *		<li>regular group (used for regular clients)</li>
605
-  *		<li>global query group (used for ServerQuery clients)</li>
606
-  *	</ol>
607
-  *
608
-  * <b>Output:</b>
609
-  * <pre>
610
-  * Array
611
-  * {
612
-  *  [cgid] => 86
613
-  * }
614
-  * </pre>
615
-  *
616
-  * @author     Par0noid Solutions
617
-  * @param		integer	$name	groupName
618
-  * @param		integer	$type   groupDbType [optional] (default: 1)
619
-  * @return     boolean success
620
-  */
621
-	function channelGroupAdd($name, $type = 1) {
622
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
623
-		return $this->getData('array', 'channelgroupadd name='.$this->escapeText($name).' type='.$type);
624
-	}
625
-
626
-/**
627
-  * channelGroupAddPerm
628
-  * 
629
-  * 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.
630
-  *
631
-  * <b>Input-Array like this:</b>
632
-  * <pre>
633
-  * $permissions = array();
634
-  * $permissions['permissionID'] = 'permissionValue';
635
-  * //or you could use:
636
-  * $permissions['permissionName'] = 'permissionValue';
637
-  * </pre>
638
-  *
639
-  * @author     Par0noid Solutions
640
-  * @param		integer		$cgid			channelGroupID
641
-  * @param		array		$permissions	permissions
642
-  * @return     boolean success
643
-  */
644
-	function channelGroupAddPerm($cgid, $permissions) {
645
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
646
-		
647
-		if(count($permissions) > 0) {
648
-			//Permissions given
649
-		
650
-			//Errorcollector
651
-			$errors = array();
652
-		
653
-			//Split Permissions to prevent query from overload
654
-			$permissions = array_chunk($permissions, 50, true);
655
-		
656
-			//Action for each splitted part of permission
657
-			foreach($permissions as $permission_part)
658
-			{
659
-				//Create command_string for each command that we could use implode later
660
-				$command_string = array();
661
-		
662
-				foreach($permission_part as $key => $value)
663
-				{
664
-					$command_string[] = (is_numeric($key) ? "permid=" : "permsid=").$this->escapeText($key).' permvalue='.$value;
665
-				}
666
-		
667
-				$result = $this->getData('boolean', 'channelgroupaddperm cgid='.$cgid.' '.implode('|', $command_string));
668
-		
669
-				if(!$result['success'])
670
-				{
671
-					foreach($result['errors'] as $error)
672
-					{
673
-						$errors[] = $error;
674
-					}
675
-				}
676
-			}
677
-		
678
-			if(count($errors) == 0) {
679
-				return $this->generateOutput(true, array(), true);
680
-			}else{
681
-				return $this->generateOutput(false, $errors, false);
682
-			}
683
-		
684
-		}else{
685
-			// No permissions given
686
-			$this->addDebugLog('no permissions given');
687
-			return $this->generateOutput(false, array('Error: no permissions given'), false);
688
-		}
689
-	}
690
-
691
-/**
692
-  * channelGroupClientList
693
-  * 
694
-  * 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
695
-  *
696
-  * <b>Output:</b>
697
-  * <pre>
698
-  * Array
699
-  * {
700
-  *  [cid] => 2
701
-  *  [cldbid] => 9
702
-  *  [cgid] => 9
703
-  * }
704
-  * </pre>
705
-  *
706
-  * @author     Par0noid Solutions
707
-  * @param		integer $cid		channelID [optional]
708
-  * @param		integer $cldbid		clientDBID [optional]
709
-  * @param		integer $cgid		channelGroupID [optional]
710
-  * @return     array channelGroupClientList
711
-  */
712
-	function channelGroupClientList($cid = NULL, $cldbid = NULL, $cgid = NULL) {
713
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
714
-		
715
-		return $this->getData('multi', 'channelgroupclientlist'.(!empty($cid) ? ' cid='.$cid : '').(!empty($cldbid) ? ' cldbid='.$cldbid : '').(!empty($cgid) ? ' cgid='.$cgid : ''));
716
-	}
717
-
718
-/**
719
-  * channelGroupCopy
720
-  * 
721
-  * 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.
722
-  *
723
-  * <b>groupDbTypes:</b>
724
-  *	<ol start="0">
725
-  *		<li>template group (used for new virtual servers)</li>
726
-  *		<li>regular group (used for regular clients)</li>
727
-  *		<li>global query group (used for ServerQuery clients)</li>
728
-  *	</ol>
729
-  *
730
-  * <b>Output:</b>
731
-  * <pre>
732
-  * Array
733
-  * {
734
-  *  [cgid] => 86
735
-  * }
736
-  * </pre>
737
-  *
738
-  * @author     Par0noid Solutions
739
-  * @param		integer	$scgid	sourceChannelGroupID
740
-  * @param		integer	$tcgid	targetChannelGroupID 
741
-  * @param		integer $name	groupName
742
-  * @param		integer	$type	groupDbType
743
-  * @return     array groupId
744
-  */
745
-	function channelGroupCopy($scgid, $tcgid, $name, $type = 1) {
746
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
747
-		return $this->getData('array', 'channelgroupcopy scgid='.$scgid.' tcgid='.$tcgid.' name='.$this->escapeText($name).' type='.$type);
748
-	}
749
-
750
-/**
751
-  * channelGroupDelete
752
-  * 
753
-  * Deletes a channel group by ID. If force is set to 1, the channel group will be deleted even if there are clients within.
754
-  *
755
-  * @author     Par0noid Solutions
756
-  * @param		integer $cgid	channelGroupID
757
-  * @param		integer $force	forces deleting channelGroup (default: 1)
758
-  * @return     boolean success
759
-  */
760
-	function channelGroupDelete($cgid, $force = 1) {
761
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
762
-		return $this->getData('boolean', 'channelgroupdel cgid='.$cgid.' force='.$force);
763
-	}
764
-
765
-/**
766
-  * channelGroupDelPerm
767
-  * 
768
-  * 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.
769
-  *
770
-  * <b>Input-Array like this:</b>
771
-  * <pre>
772
-  * $permissions = array();
773
-  * $permissions[] = 'permissionID';
774
-  * $permissions[] = 'permissionName';
775
-  * </pre>
776
-  *
777
-  * @author     Par0noid Solutions
778
-  * @param		integer		$cgid				channelGroupID
779
-  * @param		array		$permissions		permissions
780
-  * @return     boolean success
781
-  */
782
-	function channelGroupDelPerm($cgid, $permissions) {
783
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
784
-		$permissionArray = array();
785
-		
786
-		if(count($permissions) > 0) {
787
-			foreach($permissions AS $value) {
788
-				$permissionArray[] = (is_numeric($value) ? 'permid=' : 'permsid=').$value;
789
-			}
790
-			return $this->getData('boolean', 'channelgroupdelperm cgid='.$cgid.' '.implode('|', $permissionArray));
791
-		}else{
792
-			$this->addDebugLog('no permissions given');
793
-			return $this->generateOutput(false, array('Error: no permissions given'), false);
794
-		}
795
-	}
796
-
797
-/**
798
-  * channelGroupList
799
-  * 
800
-  * Displays a list of channel groups available on the selected virtual server.
801
-  * 
802
-  * <b>Output:</b>
803
-  * <pre>
804
-  * Array
805
-  * {
806
-  *  [cgid] => 3
807
-  *  [name] => Testname
808
-  *  [type] => 0
809
-  *  [iconid] => 100
810
-  *  [savedb] => 1
811
-  *  [sortid] => 0
812
-  *  [namemode] => 0
813
-  *  [n_modifyp] => 75
814
-  *  [n_member_addp] => 50
815
-  *  [n_member_removep] => 50
816
-  * }
817
-  * </pre>
818
-  *
819
-  * @author     Par0noid Solutions
820
-  * @return     array channelGroupList
821
-  */
822
-	function channelGroupList() {
823
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
824
-		
825
-		return $this->getData('multi', 'channelgrouplist');
826
-	}
827
-
828
-/**
829
-  * channelGroupPermList
830
-  * 
831
-  * Displays a list of permissions assigned to the channel group specified with cgid.
832
-  * If the permsid option is specified, the output will contain the permission names instead of the internal IDs.
833
-  * 
834
-  * <b>Output:</b>
835
-  * <pre>
836
-  * Array
837
-  * {
838
-  *  [permid] => 8471 (displayed if permsid is false)
839
-  *  [permsid] => i_channel_create_modify_with_codec_latency_factor_min (displayed if permsid is true)
840
-  *  [permvalue] => 1
841
-  *  [permnegated] => 0
842
-  *  [permskip] => 0
843
-  * }
844
-  * </pre>
845
-  *
846
-  * @author     Par0noid Solutions
847
-  * @param		integer		$cgid		channelGroupID
848
-  * @param		boolean		$permsid	permsid
849
-  * @return		array	channelGroupPermlist
850
-  */
851
-  	function channelGroupPermList($cgid, $permsid = false) {
852
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }		
853
-		return $this->getData('multi', 'channelgrouppermlist cgid='.$cgid.($permsid ? ' -permsid' : ''));
854
-	}
855
-
856
-/**
857
-  * channelGroupRename
858
-  * 
859
-  * Changes the name of a specified channel group.
860
-  *
861
-  * @author     Par0noid Solutions
862
-  * @param		integer $cgid groupID
863
-  * @param		integer $name groupName
864
-  * @return     boolean success
865
-  */
866
-	function channelGroupRename($cgid, $name) {
867
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
868
-		return $this->getData('boolean', 'channelgrouprename cgid='.$cgid.' name='.$this->escapeText($name));
869
-	}
870
-
871
-/**
872
-  * channelInfo
873
-  *
874
-  *	Displays detailed configuration information about a channel including ID, topic, description, etc.
875
-
876
-  * <b>Output:</b>
877
-  * <pre>
878
-  * Array
879
-  * {
880
-  *  [pid] => 0
881
-  *  [channel_name] => Test
882
-  *  [channel_topic] => 
883
-  *  [channel_description] => 
884
-  *  [channel_password] => cc97Pm4oOYq0J9fXDAgiWv/qScQ=
885
-  *  [channel_codec] => 2
886
-  *  [channel_codec_quality] => 7
887
-  *  [channel_maxclients] => -1
888
-  *  [channel_maxfamilyclients] => -1
889
-  *  [channel_order] => 1
890
-  *  [channel_flag_permanent] => 1
891
-  *  [channel_flag_semi_permanent] => 0
892
-  *  [channel_flag_default] => 0
893
-  *  [channel_flag_password] => 0
894
-  *  [channel_codec_latency_factor] => 1
895
-  *  [channel_codec_is_unencrypted] => 1
896
-  *	 [channel_security_salt] => 
897
-  *  [channel_delete_delay] => 0
898
-  *  [channel_flag_maxclients_unlimited] => 1
899
-  *  [channel_flag_maxfamilyclients_unlimited] => 0
900
-  *  [channel_flag_maxfamilyclients_inherited] => 1
901
-  *  [channel_filepath] => files\\virtualserver_1\\channel_2
902
-  *  [channel_needed_talk_power] => 0
903
-  *  [channel_forced_silence] => 0
904
-  *  [channel_name_phonetic] => 
905
-  *  [channel_icon_id] => 0
906
-  *	 [channel_flag_private] => 0
907
-  *  [seconds_empty] => 61 (If it's a temporary channel with a channel delete delay)
908
-  * }
909
-  * </pre>
910
-  *
911
-  * @author     Par0noid Solutions
912
-  * @param		integer $cid channelID
913
-  * @return     array channelInfo
914
-  */
915
-	function channelInfo($cid) {
916
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
917
-		return $this->getData('array', 'channelinfo cid='.$cid);
918
-	}
919
-
920
-/**
921
-  * channelList
922
-  * 
923
-  * 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.
924
-  *
925
-  * <b>Possible parameters:</b> [-topic] [-flags] [-voice] [-limits] [-icon] [-seconds_empty]
926
-  *
927
-  * <b>Output: (without parameters)</b>
928
-  * <pre>
929
-  * Array
930
-  * {
931
-  *  [cid] => 2
932
-  *  [pid] => 0
933
-  *  [channel_order] => 1
934
-  *  [channel_name] => Test
935
-  *  [total_clients] => 0
936
-  *  [channel_needed_subscribe_power] => 0
937
-  * }
938
-  * </pre>
939
-  * <b>Output: (from parameters)</b>
940
-  * <pre>
941
-  * Array
942
-  * {
943
-  *  [-topic] => [channel_topic] => Default Channel has no topic
944
-  *  [-flags] => [channel_flag_default] => 1
945
-  *  [-flags] => [channel_flag_password] => 0
946
-  *  [-flags] => [channel_flag_permanent] => 1
947
-  *  [-flags] => [channel_flag_semi_permanent] => 0
948
-  *  [-voice] => [channel_codec] => 2
949
-  *  [-voice] => [channel_codec_quality] => 7
950
-  *  [-voice] => [channel_needed_talk_power] => 0
951
-  *  [-limits] => [total_clients_family] => 1
952
-  *  [-limits] => [channel_maxclients] => -1
953
-  *  [-limits] => [channel_maxfamilyclients] => -1
954
-  *  [-icon] => [channel_icon_id] => 0
955
-  *  [-seconds_empty] => [seconds_empty] => -1
956
-  * }
957
-  * </pre>
958
-  * <b>Usage:</b>
959
-  * <pre>
960
-  * $ts3->channelList(); //No parameters
961
-  * $ts3->channelList("-flags"); //Single parameter
962
-  * $ts3->channelList("-topic -flags -voice -limits -icon"); //Multiple parameters / all
963
-  * </pre>
964
-  *
965
-  * @author     Par0noid Solutions
966
-  * @param		string		$params		additional parameters [optional]
967
-  * @return		array	channelList
968
-  */
969
-	function channelList($params = null) {
970
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
971
-		if(!empty($params)) { $params = ' '.$params; }
972
-		
973
-		return $this->getData('multi', 'channellist'.$params);
974
-	}
975
-
976
-/**
977
-  * channelMove
978
-  * 
979
-  * 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.
980
-  *
981
-  * @author     Par0noid Solutions
982
-  * @param		integer $cid	channelID
983
-  * @param		integer $cpid	channelParentID
984
-  * @param		integer $order	channelSortOrder
985
-  * @return     boolean success
986
-  */
987
-	function channelMove($cid, $cpid, $order = null) {
988
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }		
989
-		return $this->getData('boolean', 'channelmove cid='.$cid.' cpid='.$cpid.($order != null ? ' order='.$order : ''));
990
-	}
991
-
992
-/**
993
-  * channelPermList
994
-  * 
995
-  * Displays a list of permissions defined for a channel.
996
-  *
997
-  * <b>Output:</b>
998
-  * <pre>
999
-  * Array
1000
-  * {
1001
-  *  [cid] => 2 (only in first result)
1002
-  *  [permid] => 8471 (if permsid = false)
1003
-  *  [permsid] => i_channel_needed_delete_power (if permsid = true)
1004
-  *  [permvalue] => 1
1005
-  *  [permnegated] => 0
1006
-  *  [permskip] => 0
1007
-  * }
1008
-  * </pre>
1009
-  *
1010
-  * @author     Par0noid Solutions
1011
-  * @param		integer		$cid		channelID
1012
-  * @param		boolean		$permsid	displays permissionName instead of permissionID [optional]
1013
-  * @return     array channelpermlist
1014
-  */
1015
-	function channelPermList($cid, $permsid = false) {
1016
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }	
1017
-		return $this->getData('multi', 'channelpermlist cid='.$cid.($permsid ? ' -permsid' : ''));
1018
-	}
1019
-
1020
-/**
1021
-  * clientAddPerm
1022
-  * 
1023
-  * 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.
1024
-  *
1025
-  * <b>Input-Array like this:</b>
1026
-  * <pre>
1027
-  * $permissions = array();
1028
-  * $permissions['permissionID'] = array('permissionValue', 'permskip');
1029
-  * //or you could use Permission Name
1030
-  * $permissions['permissionName'] = array('permissionValue', 'permskip');
1031
-  * </pre>
1032
-  *
1033
-  * @author     Par0noid Solutions
1034
-  * @param		integer	$cldbid			clientDBID
1035
-  * @param		array	$permissions	permissions
1036
-  * @return     boolean success
1037
-  */
1038
-	function clientAddPerm($cldbid, $permissions) {
1039
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
1040
-		
1041
-		if(count($permissions) > 0) {
1042
-			//Permissions given
1043
-				
1044
-			//Errorcollector
1045
-			$errors = array();
1046
-				
1047
-			//Split Permissions to prevent query from overload
1048
-			$permissions = array_chunk($permissions, 50, true);
1049
-				
1050
-			//Action for each splitted part of permission
1051
-			foreach($permissions as $permission_part)
1052
-			{
1053
-				//Create command_string for each command that we could use implode later
1054
-				$command_string = array();
1055
-		
1056
-				foreach($permission_part as $key => $value)
1057
-				{
1058
-					$command_string[] = (is_numeric($key) ? "permid=" : "permsid=").$this->escapeText($key).' permvalue='.$this->escapeText($value[0]).' permskip='.$this->escapeText($value[1]);
1059
-				}
555
+ *
556
+ * @author     Par0noid Solutions
557
+ * @param		integer	$cid	$channelID
558
+ * @param		array	$data	edited settings
559
+ * @return     boolean success
560
+ */
561
+    function channelEdit($cid, $data) {
562
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
1060 563
 		
1061
-				$result = $this->getData('boolean', 'clientaddperm cldbid='.$cldbid.' '.implode('|', $command_string));
564
+        $settingsString = '';
1062 565
 		
1063
-				if(!$result['success'])
1064
-				{
1065
-					foreach($result['errors'] as $error)
1066
-					{
1067
-						$errors[] = $error;
1068
-					}
1069
-				}
1070
-			}
1071
-				
1072
-			if(count($errors) == 0)
1073
-			{
1074
-				return $this->generateOutput(true, array(), true);
1075
-			}else{
1076
-				return $this->generateOutput(false, $errors, false);
1077
-			}
1078
-		}else{
1079
-			// No permissions given
1080
-			$this->addDebugLog('no permissions given');
1081
-			return $this->generateOutput(false, array('Error: no permissions given'), false);
1082
-		}
1083
-	}
566
+        foreach($data as $key => $value) {
567
+            $settingsString .= ' '.$key.'='.$this->escapeText($value);
568
+        }
569
+
570
+        return $this->getData('boolean', 'channeledit cid='.$cid.$settingsString);
571
+    }
1084 572
 
1085 573
 /**
1086
- * clientAvatar
1087
- *
1088
- * Will return the base64 encoded binary of the clients avatar
574
+ * channelFind
1089 575
  * 
576
+ * displays a list of channels matching a given name pattern.
577
+ *
578
+ * <b>Output:</b>
1090 579
  * <pre>
1091
- * $result = $tsAdmin->clientAvatar($uid);
1092
- * You can display it like: echo '<img src="data:image/png;base64,'.$result["data"].'" />';
580
+ * Array
581
+ * {
582
+ *  [cid] => 2
583
+ *  [channel_name] => Lobby
584
+ * }
1093 585
  * </pre>
1094 586
  *
1095
- * @author  Par0noid Solutions
1096
- * @param  string  $uid  clientUID
1097
- * @return array  base64 image
587
+ * @author     Par0noid Solutions
588
+ * @param		string	$pattern	channelName
589
+ * @return     array channelList 
1098 590
  */
1099
-	function clientAvatar($uid) {
1100
-	  if(!$this->runtime['selected']) { return $this->checkSelected(); }
1101
-
1102
-	  if(empty($uid))
1103
-	  {
1104
-		return $this->generateOutput(false, array('Error: empty uid'), false);
1105
-	  }
1106
-
1107
-	  $newChars = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p');
1108
-	  $auid = '';
1109
-
1110
-	  for ($i = 0; $i <= 19; $i++) {
1111
-			  $char = ord(substr(base64_decode($uid), $i, 1));
1112
-			  $auid .= $newChars[($char & 0xF0) >> 4];
1113
-			  $auid .= $newChars[$char & 0x0F];
1114
-	  }
1115
-
1116
-	  $check = $this->ftgetfileinfo(0, '', '/avatar_'.$auid);
1117
-
1118
-	  if(!$check["success"])
1119
-	  {
1120
-		return $this->generateOutput(false, array('Error: avatar does not exist'), false);
1121
-	  }
1122
-
1123
-	  $init = $this->ftInitDownload('/avatar_'.$auid, 0, '');
1124
-
1125
-	  if(!$init["success"])
1126
-	  {
1127
-		return $this->generateOutput(false, array('Error: init failed'), false);
1128
-	  }
1129
-
1130
-	  $download = $this->ftDownloadFile($init);
591
+    function channelFind($pattern) {
592
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
593
+        return $this->getData('multi', 'channelfind pattern='.$this->escapeText($pattern));
594
+    }
1131 595
 
1132
-	  if(is_array($download))
1133
-	  {
1134
-		return $download;
1135
-	  }else{
1136
-		return $this->generateOutput(true, false, base64_encode($download));
1137
-	  }
596
+/**
597
+ * channelGroupAdd
598
+ * 
599
+ * 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.
600
+ *
601
+ * <b>groupDbTypes:</b>
602
+ *	<ol start="0">
603
+ *		<li>template group (used for new virtual servers)</li>
604
+ *		<li>regular group (used for regular clients)</li>
605
+ *		<li>global query group (used for ServerQuery clients)</li>
606
+ *	</ol>
607
+ *
608
+ * <b>Output:</b>
609
+ * <pre>
610
+ * Array
611
+ * {
612
+ *  [cgid] => 86
613
+ * }
614
+ * </pre>
615
+ *
616
+ * @author     Par0noid Solutions
617
+ * @param		integer	$name	groupName
618
+ * @param		integer	$type   groupDbType [optional] (default: 1)
619
+ * @return     boolean success
620
+ */
621
+    function channelGroupAdd($name, $type = 1) {
622
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
623
+        return $this->getData('array', 'channelgroupadd name='.$this->escapeText($name).' type='.$type);
624
+    }
1138 625
 
1139
-	}
1140
-	
1141 626
 /**
1142
-  * clientDbDelete
1143
-  * 
1144
-  * Deletes a clients properties from the database.
1145
-  *
1146
-  * @author     Par0noid Solutions
1147
-  * @param		integer $cldbid	clientDBID
1148
-  * @return     boolean success
1149
-  */
1150
-	function clientDbDelete($cldbid) {
1151
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
1152
-		return $this->getData('boolean', 'clientdbdelete cldbid='.$cldbid);
1153
-	}
1154
-
1155
-/**
1156
-  * clientDbEdit
1157
-  * 
1158
-  * Changes a clients settings using given properties.
1159
-  *
1160
-  * <b>Input-Array like this:</b>
1161
-  * <pre>
1162
-  * $data = array();
1163
-  * 
1164
-  * $data['property'] = 'value';
1165
-  * $data['property'] = 'value';
1166
-  * </pre>
1167
-  *
1168
-  * @author     Par0noid Solutions
1169
-  * @param		integer		$cldbid		clientDBID
1170
-  * @param		array		$data	 	clientProperties
1171
-  * @return     boolean success
1172
-  */
1173
-	function clientDbEdit($cldbid, $data) {
1174
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
1175
-		
1176
-		$settingsString = '';
1177
-		
1178
-		foreach($data as $key => $value) {
1179
-			$settingsString .= ' '.$key.'='.$this->escapeText($value);
1180
-		}
1181
-		
1182
-		return $this->getData('boolean', 'clientdbedit cldbid='.$cldbid.$settingsString);
1183
-	}
1184
-
1185
-/**
1186
-  * clientDbFind
1187
-  * 
1188
-  * 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.
1189
-  *
1190
-  * <b>Output:</b>
1191
-  * <pre>
1192
-  * Array
1193
-  * {
1194
-  *  [cldbid] => 2
1195
-  * }
1196
-  *	</pre>
1197
-  *
1198
-  * @author     Par0noid Solutions
1199
-  * @param		string	$pattern	clientName
1200
-  * @param		boolean	$uid		set true to add -uid param [optional]
1201
-  * @return     array clientList 
1202
-  */
1203
-	function clientDbFind($pattern, $uid = false) {
1204
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
1205
-		return $this->getData('multi', 'clientdbfind pattern='.$this->escapeText($pattern).($uid ? ' -uid' : ''));
1206
-	}
1207
-
1208
-/**
1209
-  * clientDbInfo
1210
-  *
1211
-  * Displays detailed database information about a client including unique ID, creation date, etc.
1212
-  *
1213
-  * <b>Output:</b>
1214
-  * <pre>
1215
-  * Array
1216
-  * {
1217
-  *  [client_unique_identifier] => nUixbsq/XakrrmbqU8O30R/D8Gc=
1218
-  *  [client_nickname] => par0noid
1219
-  *  [client_database_id] => 2
1220
-  *  [client_created] => 1361027850
1221
-  *  [client_lastconnected] => 1361027850
1222
-  *  [client_totalconnections] => 1
1223
-  *  [client_flag_avatar] => 
1224
-  *  [client_description] => 
1225
-  *  [client_month_bytes_uploaded] => 0
1226
-  *  [client_month_bytes_downloaded] => 0
1227
-  *  [client_total_bytes_uploaded] => 0
1228
-  *  [client_total_bytes_downloaded] => 0
1229
-  *  [client_icon_id] => 0
1230
-  *  [client_base64HashClientUID] => jneilbgomklpfnkjclkoggokfdmdlhnbbpmdpagh
1231
-  *  [client_lastip] => 127.0.0.1
1232
-  * }
1233
-  * </pre>
1234
-  *
1235
-  * @author     Par0noid Solutions
1236
-  * @param		integer		$cldbid		clientDBID
1237
-  * @return     array	clientDbInfo
1238
-  */
1239
-	function clientDbInfo($cldbid) {
1240
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
1241
-		return $this->getData('array', 'clientdbinfo cldbid='.$cldbid);
1242
-	}
1243
-
1244
-/**
1245
-  * clientDbList
1246
-  * 
1247
-  * Displays a list of client identities known by the server including their database ID, last nickname, etc.
1248
-  *
1249
-  * <b>Possible params:</b> [start={offset}] [duration={limit}] [-count]
1250
-  *
1251
-  * <b>Output:</b>
1252
-  * <pre>
1253
-  * Array
1254
-  * {
1255
-  *  [count] => 1 (if count parameter is set)
1256
-  *  [cldbid] => 2
1257
-  *  [client_unique_identifier] => nUixbsq/XakrrmbqU8O30R/D8Gc=
1258
-  *  [client_nickname] => par0noid
1259
-  *  [client_created] => 1361027850
1260
-  *  [client_lastconnected] => 1361027850
1261
-  *  [client_totalconnections] => 1
1262
-  *  [client_description] => 
1263
-  *  [client_lastip] => 127.0.0.1
1264
-  * }
1265
-  * </pre>
1266
-  *
1267
-  * @author     Par0noid Solutions
1268
-  * @param		integer	$start		offset [optional] (Default: 0)
1269
-  * @param		integer	$duration	limit [optional] (Default: -1)
1270
-  * @param		boolean	$count		set true to add -count param [optional]
1271
-  * @return     array clientdblist
1272
-  */
1273
-	function clientDbList($start = 0, $duration = -1, $count = false) {
1274
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
1275
-		return $this->getData('multi', 'clientdblist start='.$start.' duration='.$duration.($count ? ' -count' : ''));
1276
-	}
1277
-
1278
-/**
1279
-  * clientDelPerm
1280
-  * 
1281
-  * 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.
1282
-  *
1283
-  * <b>Input-Array like this:</b>
1284
-  * <pre>
1285
-  * $permissions = array();
1286
-  * $permissions['permissionID'] = 'permissionValue';
1287
-  * //or you could use Permission Name
1288
-  * $permissions['permissionName'] = 'permissionValue';
1289
-  * </pre>
1290
-  *
1291
-  * @author     Par0noid Solutions
1292
-  * @param		integer		$cldbid				clientDBID
1293
-  * @param		array		$permissionIds		permissionIDs
1294
-  * @return     boolean success
1295
-  */
1296
-	function clientDelPerm($cldbid, $permissionIds) {
1297
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
1298
-		
1299
-		$permissionArray = array();
1300
-		
1301
-		if(count($permissionIds) > 0) {
1302
-			foreach($permissionIds AS $value) {
1303
-				$permissionArray[] = (is_numeric($value) ? 'permid=' : 'permsid=').$value;
1304
-			}
1305
-			return $this->getData('boolean', 'clientdelperm cldbid='.$cldbid.' '.implode('|', $permissionArray));
1306
-		}else{
1307
-			$this->addDebugLog('no permissions given');
1308
-			return $this->generateOutput(false, array('Error: no permissions given'), false);
1309
-		}
1310
-	}
1311
-
1312
-/**
1313
-  * clientEdit
1314
-  * 
1315
-  * Changes a clients settings using given properties.
1316
-  *
1317
-  * <b>Input-Array like this:</b>
1318
-  * <pre>
1319
-  * $data = array();
1320
-  *	
1321
-  * $data['property'] = 'value';
1322
-  * $data['property'] = 'value';
1323
-  * </pre>
1324
-  *
1325
-  * @author     Par0noid Solutions
1326
-  * @param		integer	$clid 			clientID
1327
-  * @param		array	$data			clientProperties
1328
-  * @return     boolean success
1329
-  */
1330
-	function clientEdit($clid, $data) {
1331
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
627
+ * channelGroupAddPerm
628
+ * 
629
+ * 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.
630
+ *
631
+ * <b>Input-Array like this:</b>
632
+ * <pre>
633
+ * $permissions = array();
634
+ * $permissions['permissionID'] = 'permissionValue';
635
+ * //or you could use:
636
+ * $permissions['permissionName'] = 'permissionValue';
637
+ * </pre>
638
+ *
639
+ * @author     Par0noid Solutions
640
+ * @param		integer		$cgid			channelGroupID
641
+ * @param		array		$permissions	permissions
642
+ * @return     boolean success
643
+ */
644
+    function channelGroupAddPerm($cgid, $permissions) {
645
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
1332 646
 		
1333
-		$settingsString = '';
647
+        if(count($permissions) > 0) {
648
+            //Permissions given
1334 649
 		
1335
-		foreach($data as $key => $value) {
1336
-			$settingsString .= ' '.$key.'='.$this->escapeText($value);
1337
-		}
650
+            //Errorcollector
651
+            $errors = array();
1338 652
 		
1339
-		return $this->getData('boolean', 'clientedit clid='.$clid.$settingsString);
1340
-	}
1341
-
1342
-/**
1343
-  * clientFind
1344
-  * 
1345
-  * Displays a list of clients matching a given name pattern.
1346
-  *
1347
-  * <b>Output:</b>
1348
-  * <pre>
1349
-  * Array
1350
-  * {
1351
-  *  [clid] => 18
1352
-  *  [client_nickname] => par0noid
1353
-  * }
1354
-  * </pre>
1355
-  *
1356
-  * @author     Par0noid Solutions
1357
-  * @param		string	$pattern	clientName
1358
-  * @return     array clienList
1359
-  */
1360
-	function clientFind($pattern) {
1361
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
1362
-		return $this->getData('multi', 'clientfind pattern='.$this->escapeText($pattern));
1363
-	}
1364
-
1365
-/**
1366
-  * clientGetDbIdFromUid
1367
-  * 
1368
-  * Displays the database ID matching the unique identifier specified by cluid.
1369
-  *
1370
-  *	<b>Output:</b>
1371
-  * <pre>
1372
-  * Array
1373
-  * {
1374
-  *  [cluid] => nUixbsq/XakrrmbqU8O30R/D8Gc=
1375
-  *  [cldbid] => 2
1376
-  * }
1377
-  * </pre>
1378
-  *
1379
-  * @author     Par0noid Solutions
1380
-  * @param		string	$cluid	clientUID
1381
-  * @return     array clientInfo
1382
-  */
1383
-	function clientGetDbIdFromUid($cluid) {
1384
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
1385
-		return $this->getData('array', 'clientgetdbidfromuid cluid='.$cluid);
1386
-	}
1387
-
1388
-/**
1389
-  * clientGetIds
1390
-  * 
1391
-  * Displays all client IDs matching the unique identifier specified by cluid.
1392
-  *
1393
-  * <b>Output:</b>
1394
-  * <pre>
1395
-  * Array
1396
-  * {
1397
-  *  [cluid] => nUixbdf/XakrrmsdffO30R/D8Gc=
1398
-  *  [clid] => 7
1399
-  *  [name] => Par0noid
1400
-  * }
1401
-  * </pre>
1402
-  *
1403
-  * @author     Par0noid Solutions
1404
-  * @param		string	$cluid	clientUID
1405
-  * @return     array clientList 
1406
-  */
1407
-	function clientGetIds($cluid) {
1408
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
1409
-		return $this->getData('multi', 'clientgetids cluid='.$cluid);
1410
-	}
1411
-
1412
-/**
1413
-  * clientGetNameFromDbid
1414
-  * 
1415
-  * Displays the unique identifier and nickname matching the database ID specified by cldbid.
1416
-  *
1417
-  *	<b>Output:</b>
1418
-  * <pre>
1419
-  * Array
1420
-  * {
1421
-  *  [cluid] => nUixbsq/XakrrmbqU8O30R/D8Gc=
1422
-  *  [cldbid] => 2
1423
-  *  [name] => Par0noid
1424
-  * }
1425
-  * </pre>
1426
-  *
1427
-  * @author     Par0noid Solutions
1428
-  * @param		integer	$cldbid	clientDBID
1429
-  * @return     array clientInfo
1430
-  */
1431
-	function clientGetNameFromDbid($cldbid) {
1432
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
1433
-		return $this->getData('array', 'clientgetnamefromdbid cldbid='.$cldbid);
1434
-	}
1435
-	
1436
-/**
1437
-  * clientGetNameFromUid
1438
-  * 
1439
-  * Displays the database ID and nickname matching the unique identifier specified by cluid.
1440
-  *
1441
-  *	<b>Output:</b>
1442
-  * <pre>
1443
-  * Array
1444
-  * {
1445
-  *  [cluid] => nUixbsq/XakrrmbqU8O30R/D8Gc=
1446
-  *  [cldbid] => 2
1447
-  *  [name] => Par0noid
1448
-  * }
1449
-  * </pre>
1450
-  *
1451
-  * @author     Par0noid Solutions
1452
-  * @param		string	$cluid	clientUID
1453
-  * @return     array clientInfo
1454
-  */
1455
-	function clientGetNameFromUid($cluid) {
1456
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
1457
-		return $this->getData('array', 'clientgetnamefromuid cluid='.$cluid);
1458
-	}
1459
-
1460
-/**
1461
-  * clientInfo
1462
-  * 
1463
-  * Displays detailed configuration information about a client including unique ID, nickname, client version, etc.
1464
-  *
1465
-  * <b>Output:</b>
1466
-  * <pre>
1467
-  * Array
1468
-  * {
1469
-  *  [cid] => 2
1470
-  *  [client_idle_time] => 4445369
1471
-  *  [client_unique_identifier] => nUixbsq/XakrrmbqU8O30R/D8Gc=
1472
-  *  [client_nickname] => par0noid
1473
-  *  [client_version] => 3.0.9.2 [Build: 1351504843]
1474
-  *  [client_platform] => Windows
1475
-  *  [client_input_muted] => 1
1476
-  *  [client_output_muted] => 1
1477
-  *  [client_outputonly_muted] => 0
1478
-  *  [client_input_hardware] => 1
1479
-  *  [client_output_hardware] => 1
1480
-  *  [client_default_channel] => 
1481
-  *  [client_meta_data] => 
1482
-  *  [client_is_recording] => 0
1483
-  *  [client_version_sign] => ldWL49uDKC3N9uxdgWRMTOzUabc1nBqUiOa+Nal5HvdxJiN4fsTnmmPo5tvglN7WqoVoFfuuKuYq1LzodtEtCg==
1484
-  *  [client_security_hash] => 
1485
-  *  [client_login_name] => 
1486
-  *  [client_database_id] => 2
1487
-  *  [client_channel_group_id] => 5
1488
-  *  [client_servergroups] => 6
1489
-  *  [client_created] => 1361027850
1490
-  *  [client_lastconnected] => 1361027850
1491
-  *  [client_totalconnections] => 1
1492
-  *  [client_away] => 0
1493
-  *  [client_away_message] => 
1494
-  *  [client_type] => 0
1495
-  *  [client_flag_avatar] => 
1496
-  *  [client_talk_power] => 75
1497
-  *  [client_talk_request] => 0
1498
-  *  [client_talk_request_msg] => 
1499
-  *  [client_description] => 
1500
-  *  [client_is_talker] => 0
1501
-  *  [client_month_bytes_uploaded] => 0
1502
-  *  [client_month_bytes_downloaded] => 0
1503
-  *  [client_total_bytes_uploaded] => 0
1504
-  *  [client_total_bytes_downloaded] => 0
1505
-  *  [client_is_priority_speaker] => 0
1506
-  *  [client_nickname_phonetic] => 
1507
-  *  [client_needed_serverquery_view_power] => 75
1508
-  *  [client_default_token] => 
1509
-  *  [client_icon_id] => 0
1510
-  *  [client_is_channel_commander] => 0
1511
-  *  [client_country] => 
1512
-  *  [client_channel_group_inherited_channel_id] => 2
1513
-  *  [client_badges] => Overwolf=0
1514
-  *  [client_base64HashClientUID] => jneilbgomklpfnkjclkoggokfdmdlhnbbpmdpagh
1515
-  *  [connection_filetransfer_bandwidth_sent] => 0
1516
-  *  [connection_filetransfer_bandwidth_received] => 0
1517
-  *  [connection_packets_sent_total] => 12130
1518
-  *  [connection_bytes_sent_total] => 542353
1519
-  *  [connection_packets_received_total] => 12681
1520
-  *  [connection_bytes_received_total] => 592935
1521
-  *  [connection_bandwidth_sent_last_second_total] => 82
1522
-  *  [connection_bandwidth_sent_last_minute_total] => 92
1523
-  *  [connection_bandwidth_received_last_second_total] => 84
1524
-  *  [connection_bandwidth_received_last_minute_total] => 88
1525
-  *  [connection_connected_time] => 5908749
1526
-  *  [connection_client_ip] => 127.0.0.1
1527
-  * } 
1528
-  * </pre>
1529
-  *
1530
-  * @author     Par0noid Solutions
1531
-  * @param		integer	$clid	clientID
1532
-  * @return     array	clientInformation
1533
-  */
1534
-	function clientInfo($clid) {
1535
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
1536
-		return $this->getData('array', 'clientinfo clid='.$clid);
1537
-	}
1538
-
1539
-/**
1540
-  * clientKick
1541
-  * 
1542
-  * 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.
1543
-  *
1544
-  * @author     Par0noid Solutions
1545
-  * @param		integer $clid		clientID
1546
-  * @param		string	$kickMode	kickMode (server or channel) (Default: server)
1547
-  * @param		string	$kickmsg 	kick reason [optional]
1548
-  * @return     boolean success
1549
-  */
1550
-	function clientKick($clid, $kickMode = "server", $kickmsg = "") {
1551
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
653
+            //Split Permissions to prevent query from overload
654
+            $permissions = array_chunk($permissions, 50, true);
1552 655
 		
1553
-		if(in_array($kickMode, array('server', 'channel'))) {
656
+            //Action for each splitted part of permission
657
+            foreach($permissions as $permission_part)
658
+            {
659
+                //Create command_string for each command that we could use implode later
660
+                $command_string = array();
1554 661
 		
1555
-			if($kickMode == 'server') { $from = '5'; }
1556
-			if($kickMode == 'channel') { $from = '4'; }
1557
-			
1558
-			if(!empty($kickmsg)) { $msg = ' reasonmsg='.$this->escapeText($kickmsg); } else{ $msg = ''; }
1559
-			
1560
-			return $this->getData('boolean', 'clientkick clid='.$clid.' reasonid='.$from.$msg);
1561
-		}else{
1562
-			$this->addDebugLog('invalid kickMode');
1563
-			return $this->generateOutput(false, array('Error: invalid kickMode'), false);
1564
-		}
1565
-	}
1566
-
1567
-/**
1568
-  * clientList
1569
-  * 
1570
-  * 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.
1571
-  *
1572
-  * <b>Possible params:</b> [-uid] [-away] [-voice] [-times] [-groups] [-info] [-icon] [-country] [-ip] [-badges]
1573
-  *
1574
-  * <b>Output: (without parameters)</b>
1575
-  * <pre>
1576
-  * Array
1577
-  * {
1578
-  *  [clid] => 1
1579
-  *  [cid] => 1
1580
-  *  [client_database_id] => 2
1581
-  *  [client_nickname] => Par0noid
1582
-  *  [client_type] => 0
1583
-  *  [-uid] => [client_unique_identifier] => nUixbsq/XakrrmbqU8O30R/D8Gc=
1584
-  *  [-away] => [client_away] => 0
1585
-  *  [-away] => [client_away_message] => 
1586
-  *  [-voice] => [client_flag_talking] => 0
1587
-  *  [-voice] => [client_input_muted] => 0
1588
-  *  [-voice] => [client_output_muted] => 0
1589
-  *  [-voice] => [client_input_hardware] => 0
1590
-  *  [-voice] => [client_output_hardware] => 0
1591
-  *  [-voice] => [client_talk_power] => 0
1592
-  *  [-voice] => [client_is_talker] => 0
1593
-  *  [-voice] => [client_is_priority_speaker] => 0
1594
-  *  [-voice] => [client_is_recording] => 0
1595
-  *  [-voice] => [client_is_channel_commander] => 0
1596
-  *  [-times] => [client_idle_time] => 1714
1597
-  *  [-times] => [client_created] => 1361027850
1598
-  *  [-times] => [client_lastconnected] => 1361042955
1599
-  *  [-groups] => [client_servergroups] => 6,7
1600
-  *  [-groups] => [client_channel_group_id] => 8
1601
-  *  [-groups] => [client_channel_group_inherited_channel_id] => 1
1602
-  *  [-info] => [client_version] => 3.0.9.2 [Build: 1351504843]
1603
-  *  [-info] => [client_platform] => Windows
1604
-  *  [-icon] => [client_icon_id] => 0
1605
-  *  [-country] => [client_country] => 
1606
-  *  [-ip] => [connection_client_ip] => 127.0.0.1
1607
-  *  [-badges] => [client_badges] => Overwolf=0
1608
-  * }
1609
-  * 
1610
-  * <b>Usage:</b>
1611
-  * 
1612
-  * $ts3->clientList(); //No parameters
1613
-  * $ts3->clientList("-uid"); //Single parameter
1614
-  * $ts3->clientList("-uid -away -voice -times -groups -info -country -icon -ip -badges"); //Multiple parameters
1615
-  * </pre>
1616
-  *
1617
-  * @author     Par0noid Solutions
1618
-  * @param		string	$params	additional parameters [optional]
1619
-  * @return     array clientList 
1620
-  */
1621
-	function clientList($params = null) {
1622
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
662
+                foreach($permission_part as $key => $value)
663
+                {
664
+                    $command_string[] = (is_numeric($key) ? "permid=" : "permsid=").$this->escapeText($key).' permvalue='.$value;
665
+                }
1623 666
 		
1624
-		if(!empty($params)) { $params = ' '.$params; }
667
+                $result = $this->getData('boolean', 'channelgroupaddperm cgid='.$cgid.' '.implode('|', $command_string));
1625 668
 		
1626
-		return $this->getData('multi', 'clientlist'.$params);
1627
-	}
1628
-
1629
-/**
1630
-  * clientMove
1631
-  * 
1632
-  * 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.
1633
-  *
1634
-  * @author     Par0noid Solutions
1635
-  * @param		integer $clid	clientID
1636
-  * @param		integer $cid	channelID
1637
-  * @param		string	$cpw	channelPassword [optional]
1638
-  * @return     boolean success
1639
-  */
1640
-	function clientMove($clid, $cid, $cpw = null) {
1641
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
1642
-		return $this->getData('boolean', 'clientmove clid='.$clid.' cid='.$cid.(!empty($cpw) ? ' cpw='.$this->escapeText($cpw) : ''));
1643
-	}
1644
-
1645
-/**
1646
-  * clientPermList
1647
-  * 
1648
-  * Displays a list of permissions defined for a client.
1649
-  *
1650
-  * <b>Output:</b>
1651
-  * <pre>
1652
-  * Array
1653
-  * {
1654
-  *  [permid] => 20654 //with permsid = false
1655
-  *  [permsid] => b_client_ignore_bans //with permsid = true
1656
-  *  [permvalue] => 1
1657
-  *  [permnegated] => 0
1658
-  *  [permskip] => 0
1659
-  * }
1660
-  * </pre>
1661
-  *
1662
-  * @author     Par0noid Solutions
1663
-  * @param		intege		$cldbid 	clientDBID
1664
-  * @param		boolean		$permsid	set true to add -permsid param [optional]
1665
-  * @return     array clientPermList
1666
-  */
1667
-	function clientPermList($cldbid, $permsid = false) {
1668
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }		
1669
-		return $this->getData('multi', 'clientpermlist cldbid='.$cldbid.($permsid ? ' -permsid' : ''));
1670
-	}
1671
-
1672
-/**
1673
-  * clientPoke
1674
-  * 
1675
-  * Sends a poke message to the client specified with clid.
1676
-  *
1677
-  * @author     Par0noid Solutions
1678
-  * @param		integer $clid	clientID
1679
-  * @param		string 	$msg 	pokeMessage
1680
-  * @return     boolean success
1681
-  */
1682
-	function clientPoke($clid, $msg) {
1683
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
1684
-		return $this->getData('boolean', 'clientpoke clid='.$clid.' msg='.$this->escapeText($msg));
1685
-	}
1686
-
1687
-/**
1688
-  * clientSetServerQueryLogin
1689
-  * 
1690
-  * Updates your own ServerQuery login credentials using a specified username. The password will be auto-generated.
1691
-  * 
1692
-  * <b>Output:</b>
1693
-  * <pre>
1694
-  * Array
1695
-  * {
1696
-  *  [client_login_password] => +r\/TQqvR
1697
-  * }
1698
-  * </pre>
1699
-  *
1700
-  * @author     Par0noid Solutions
1701
-  * @param		string	$username	username
1702
-  * @return     array userInfomation
1703
-  */
1704
-	function clientSetServerQueryLogin($username) {
1705
-		return $this->getData('array', 'clientsetserverquerylogin client_login_name='.$this->escapeText($username));
1706
-	}
1707
-
1708
-/**
1709
-  * clientUpdate
1710
-  * 
1711
-  * Change your ServerQuery clients settings using given properties.
1712
-  * 
1713
-  * <b>Input-Array like this:</b>
1714
-  * <pre>
1715
-  * $data = array();
1716
-  * $data['property'] = 'value';
1717
-  * $data['property'] = 'value';
1718
-  * </pre>
1719
-  *
1720
-  * @author     Par0noid Solutions
1721
-  * @param		array	$data	clientProperties
1722
-  * @return     boolean success
1723
-  */
1724
-	function clientUpdate($data) {
1725
-		$settingsString = '';
669
+                if(!$result['success'])
670
+                {
671
+                    foreach($result['errors'] as $error)
672
+                    {
673
+                        $errors[] = $error;
674
+                    }
675
+                }
676
+            }
1726 677
 		
1727
-		foreach($data as $key => $value) {
1728
-			$settingsString .= ' '.$key.'='.$this->escapeText($value);
1729
-		}
678
+            if(count($errors) == 0) {
679
+                return $this->generateOutput(true, array(), true);
680
+            }else{
681
+                return $this->generateOutput(false, $errors, false);
682
+            }
1730 683
 		
1731
-		return $this->getData('boolean', 'clientupdate '.$settingsString);
1732
-	}
1733
-
1734
-/**
1735
-  * complainAdd
1736
-  *
1737
-  * Submits a complaint about the client with database ID tcldbid to the server.
1738
-  *
1739
-  * @author     Par0noid Solutions
1740
-  * @param		integer $tcldbid	targetClientDBID
1741
-  * @param		string	$msg		complainMessage
1742
-  * @return     boolean success
1743
-  */
1744
-	function complainAdd($tcldbid, $msg) {
1745
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
1746
-		return $this->getData('boolean', 'complainadd tcldbid='.$tcldbid.' message='.$this->escapeText($msg));
1747
-	}
1748
-
1749
-/**
1750
-  * complainDelete
1751
-  * 
1752
-  * Deletes the complaint about the client with ID tcldbid submitted by the client with ID fcldbid from the server.
1753
-  *
1754
-  * @author     Par0noid Solutions
1755
-  * @param		integer $tcldbid targetClientDBID
1756
-  * @param		integer $fcldbid fromClientDBID
1757
-  * @return     boolean success
1758
-  */
1759
-	function complainDelete($tcldbid, $fcldbid) {
1760
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
1761
-		return $this->getData('boolean', 'complaindel tcldbid='.$tcldbid.' fcldbid='.$fcldbid);
1762
-	}
1763
-
1764
-/**
1765
-  * complainDeleteAll
1766
-  * 
1767
-  * Deletes all complaints about the client with database ID tcldbid from the server.
1768
-  *
1769
-  * @author     Par0noid Solutions
1770
-  * @param		integer $tcldbid targetClientDBID
1771
-  * @return     boolean success
1772
-  */
1773
-	function complainDeleteAll($tcldbid) {
1774
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
1775
-		return $this->getData('boolean', 'complaindelall tcldbid='.$tcldbid);
1776
-	}
1777
-
1778
-/**
1779
-  * complainList
1780
-  * 
1781
-  * Displays a list of complaints on the selected virtual server. If tcldbid is specified, only complaints about the targeted client will be shown.
1782
-  *
1783
-  * <b>Output:</b>
1784
-  * <pre>
1785
-  * Array
1786
-  * {
1787
-  *  [tcldbid] => 2
1788
-  *  [tname] => par0noid
1789
-  *  [fcldbid] => 1
1790
-  *  [fname] => serveradmin from 127.0.0.1:6814
1791
-  *  [message] => Steals crayons
1792
-  *  [timestamp] => 1361044090
1793
-  * }
1794
-  * </pre>
1795
-  *
1796
-  * @author     Par0noid Solutions
1797
-  * @param		string $tcldbid	targetClientDBID [optional]
1798
-  * @return     array complainList
1799
-  */
1800
-	function complainList($tcldbid = null) {
1801
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
1802
-		if(!empty($tcldbid)) { $tcldbid = ' tcldbid='.$tcldbid; }
1803
-		return $this->getData('multi', 'complainlist'.$tcldbid);
1804
-	}
1805
-	
684
+        }else{
685
+            // No permissions given
686
+            $this->addDebugLog('no permissions given');
687
+            return $this->generateOutput(false, array('Error: no permissions given'), false);
688
+        }
689
+    }
1806 690
 
1807 691
 /**
1808
-  * customInfo
1809
-  * 
1810
-  * Displays a list of custom properties for the client specified with cldbid.
1811
-  *
1812
-  * <b>Output:</b>
1813
-  * <pre>
1814
-  * Array
1815
-  * {
1816
-  * 	[0] => Array
1817
-  *  	{
1818
-  *  		[cldbid] => 1
1819
-  *			[ident] => abc
1820
-  *			[value] => def
1821
-  *	  	}
1822
-  * 	[1] => Array
1823
-  *  	{
1824
-  *			[ident] => ghi
1825
-  *			[value] => jkl
1826
-  *	  	}
1827
-  * }
1828
-  * </pre>
1829
-  *
1830
-  * @author     Par0noid Solutions
1831
-  * @param		string $cldbid	clientDBID
1832
-  * @return     array customInfos
1833
-  */
1834
-	function customInfo($cldbid) {
1835
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
1836
-		return $this->getData('multi', 'custominfo cldbid='.$cldbid);
1837
-	}
1838
-
1839
-/**
1840
-  * customSearch
1841
-  * 
1842
-  * Searches for custom client properties specified by ident and value. The value parameter can include regular characters and SQL wildcard characters (e.g. %).
1843
-  *
1844
-  * <b>Output: (ident=abc, pattern=%)</b>
1845
-  * <pre>
1846
-  * Array
1847
-  * {
1848
-  * 	[0] => Array
1849
-  *  	{
1850
-  *  		[cldbid] => 1
1851
-  *			[ident] => abc
1852
-  *			[value] => def
1853
-  *	  	}
1854
-  * 	[1] => Array
1855
-  *  	{
1856
-  *  		[cldbid] => 2
1857
-  *			[ident] => abc
1858
-  *			[value] => def
1859
-  *	  	}
1860
-  * }
1861
-  * </pre>
1862
-  *
1863
-  * @author     Par0noid Solutions
1864
-  * @param		string	$ident		customIdent
1865
-  * @param		string	$pattern	searchpattern
1866
-  * @return     array	customSearchInfos
1867
-  */
1868
-	function customSearch($ident, $pattern) {
1869
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
1870
-		return $this->getData('multi', 'customsearch ident='.$this->escapeText($ident).' pattern='.$this->escapeText($pattern));
1871
-	}
1872
-
1873
-/**
1874
-  * execOwnCommand
1875
-  * 
1876
-  * executes a command that isn't defined in class and returns data like your propose
1877
-  * 
1878
-  * <b>Modes:</b>
1879
-  * <ul>
1880
-  * 	<li><b>0:</b> execute -> return boolean</li>
1881
-  * 	<li><b>1:</b> execute -> return normal array</li>
1882
-  * 	<li><b>2:</b> execute -> return multidimensional array</li>
1883
-  * 	<li><b>3:</b> execute -> return plaintext serverquery</li>
1884
-  * </ul>
1885
-  *
1886
-  * @author     Par0noid Solutions
1887
-  * @param		string	$mode		executionMode
1888
-  * @param		string	$command	command
1889
-  * @return     mixed result
1890
-  */
1891
-	function execOwnCommand($mode, $command) {
1892
-		if($mode == '0') {
1893
-			return $this->getData('boolean', $command);
1894
-		}
1895
-		if($mode == '1') {
1896
-			return $this->getData('array', $command);
1897
-		}
1898
-		if($mode == '2') {
1899
-			return $this->getData('multi', $command);
1900
-		}
1901
-		if($mode == '3') {
1902
-			return $this->getData('plain', $command);
1903
-		}
1904
-	}
1905
-
1906
-/**
1907
-  * ftCreateDir
1908
-  * 
1909
-  * Creates new directory in a channels file repository.
1910
-  *
1911
-  * @author     Par0noid Solutions
1912
-  * @param		string	$cid		channelId
1913
-  * @param		string	$cpw		channelPassword (leave blank if not needed)
1914
-  * @param		string	$dirname	dirPath
1915
-  * @return     boolean success
1916
-  */
1917
-	function ftCreateDir($cid, $cpw = null, $dirname) {
1918
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
1919
-		return $this->getData('boolean', 'ftcreatedir cid='.$cid.' cpw='.$this->escapeText($cpw).' dirname='.$this->escapeText($dirname));
1920
-	}
1921
-
1922
-/**
1923
-  * ftDeleteFile
1924
-  * 
1925
-  * Deletes one or more files stored in a channels file repository.
1926
-  *
1927
-  * <b>Input-Array like this:</b>
1928
-  * <pre>
1929
-  * $files = array();
1930
-  *	
1931
-  * $files[] = '/pic1.jpg';
1932
-  * $files[] = '/dokumente/test.txt';
1933
-  * $files[] = '/dokumente';
1934
-  * </pre>
1935
-  *
1936
-  * @author     Par0noid Solutions
1937
-  * @param		string	$cid	channelID
1938
-  * @param		string	$cpw	channelPassword (leave blank if not needed)
1939
-  * @param		array	$files	files
1940
-  * @return     boolean success
1941
-  */
1942
-	function ftDeleteFile($cid, $cpw = '', $files) {
1943
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
1944
-		$fileArray = array();
1945
-		
1946
-		if(count($files) > 0) {
1947
-			foreach($files AS $file) {
1948
-				$fileArray[] = 'name='.$this->escapeText($file);
1949
-			}
1950
-			return $this->getData('boolean', 'ftdeletefile cid='.$cid.' cpw='.$this->escapeText($cpw).' '.implode('|', $fileArray));
1951
-		}else{
1952
-			$this->addDebugLog('no files given');
1953
-			return $this->generateOutput(false, array('Error: no files given'), false);
1954
-		}
1955
-	}
1956
-
1957
-/**
1958
-  * ftDownloadFile
1959
-  * 
1960
-  * Ddownloads a file and returns its contents
1961
-  *
1962
-  * @author     Par0noid Solutions
1963
-  * @param		array	$data	return of ftInitDownload
1964
-  * @return     array downloadedFile
1965
-  */
1966
-	function ftDownloadFile($data) {
1967
-		$errnum = null;
1968
-		$errstr = null;
1969
-  		$this->runtime['fileSocket'] = @fsockopen($this->runtime['host'], $data['data']['port'], $errnum, $errstr, $this->runtime['timeout']);
1970
-  		if($this->runtime['fileSocket']) {
1971
-  			$this->ftSendKey($data['data']['ftkey']);
1972
-  			$content = $this->ftRead($data['data']['size']);
1973
-  			@fclose($this->runtime['fileSocket']);
1974
-  			$this->runtime['fileSocket'] = '';
1975
-  			return $content;
1976
-  		}else{
1977
-  			$this->addDebugLog('fileSocket returns '.$errnum. ' | '.$errstr);
1978
-  			return $this->generateOutput(false, array('Error in fileSocket: '.$errnum. ' | '.$errstr), false);
1979
-  		}
1980
-	}
1981
-	
1982
-/**
1983
-  * ftGetFileInfo
1984
-  * 
1985
-  * Displays detailed information about one or more specified files stored in a channels file repository.
1986
-  * 
1987
-  *
1988
-  * @author     Par0noid Solutions
1989
-  * @param		string	$cid	channelID
1990
-  * @param		string	$cpw	channelPassword (leave blank if not needed)
1991
-  * @param		string 	$file	path to file
1992
-  * @return     boolean success
1993
-  */
1994
-	function ftGetFileInfo($cid, $cpw = '', $file) {
1995
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
1996
-
1997
-		return $this->getData('multi', 'ftgetfileinfo cid='.$cid.' cpw='.$this->escapeText($cpw).' name='.$this->escapeText($file));
1998
-	}
1999
-
2000
-/**
2001
-  * ftGetFileList
2002
-  *
2003
-  * Displays a list of files and directories stored in the specified channels file repository.
2004
-  *
2005
-  * <b>Output:</b>
2006
-  * <pre>
2007
-  * Array
2008
-  * {
2009
-  *  [cid] => 231
2010
-  *  [path] => /
2011
-  *  [name] => Documents
2012
-  *  [size] => 0
2013
-  *  [datetime] => 1286633633
2014
-  *  [type] => 0
2015
-  * }
2016
-  * </pre>
2017
-  *
2018
-  * @author     Par0noid Solutions
2019
-  * @param		string	$cid	channelID
2020
-  * @param		string	$cpw	channelPassword (leave blank if not needed)
2021
-  * @param		string	$path	filePath
2022
-  * @return     array	fileList
2023
-  */
2024
-	function ftGetFileList($cid, $cpw = '', $path) {
2025
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
2026
-		return $this->getData('multi', 'ftgetfilelist cid='.$cid.' cpw='.$this->escapeText($cpw).' path='.$this->escapeText($path));
2027
-	}
2028
-	
2029
-/**
2030
-  * ftInitDownload
2031
-  * 
2032
-  * 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.
2033
-  *
2034
-  * <b>Output:</b>
2035
-  * <pre>
2036
-  * Array
2037
-  * {
2038
-  *  [clientftfid] => 89
2039
-  *  [serverftfid] => 3
2040
-  *  [ftkey] => jSzWiRmFGdZnoJzW7BSDYJRUWB2WAUhb
2041
-  *  [port] => 30033
2042
-  *  [size] => 94
2043
-  * }
2044
-  * </pre>
2045
-  *
2046
-  * @author     Par0noid Solutions
2047
-  * @param		string	$name			filePath
2048
-  * @param		string	$cid			channelID
2049
-  * @param		string	$cpw			channelPassword (leave blank if not needed)
2050
-  * @param		integer	$seekpos		seekpos (default = 0) [optional]
2051
-  * @return     array	initDownloadFileInfo
2052
-  */	
2053
-	function ftInitDownload($name, $cid, $cpw = '', $seekpos = 0) {
2054
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
2055
-		return $this->getData('array', 'ftinitdownload clientftfid='.rand(1,99).' name='.$this->escapeText($name).' cid='.$cid.' cpw='.$this->escapeText($cpw).' seekpos='.$seekpos);
2056
-	}
2057
-
2058
-/**
2059
-  * ftInitUpload
2060
-  * 
2061
-  * 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.
2062
-  *
2063
-  * <b>Output:</b>
2064
-  * <pre>
2065
-  * Array
2066
-  * {
2067
-  *  [clientftfid] => 84
2068
-  *  [serverftfid] => 41
2069
-  *  [ftkey] => HCnXpunOdAorqj3dGqfiuLszX18O0PHP
2070
-  *  [port] => 30033
2071
-  *  [seekpos] => 0
2072
-  * }
2073
-  * </pre>
2074
-  *
2075
-  * @author     Par0noid Solutions
2076
-  * @param		string	$filename	filePath
2077
-  * @param		string	$cid		channelID
2078
-  * @param		integer	$size		fileSize in bytes
2079
-  * @param		string	$cpw		channelPassword (leave blank if not needed)
2080
-  * @param		boolean	$overwrite	overwrite	[optional] (default = 0)
2081
-  * @param		boolean	$resume		resume		[optional] (default = 0)
2082
-  * @return     array	initUploadFileInfo
2083
-  */	
2084
-	function ftInitUpload($filename, $cid, $size, $cpw = '', $overwrite = false, $resume = false) {
2085
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
2086
-		
2087
-		if($overwrite) { $overwrite = ' overwrite=1'; }else{ $overwrite = ' overwrite=0'; }
2088
-		if($resume) { $resume = ' resume=1'; }else{ $resume = ' resume=0'; }
692
+ * channelGroupClientList
693
+ * 
694
+ * 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
695
+ *
696
+ * <b>Output:</b>
697
+ * <pre>
698
+ * Array
699
+ * {
700
+ *  [cid] => 2
701
+ *  [cldbid] => 9
702
+ *  [cgid] => 9
703
+ * }
704
+ * </pre>
705
+ *
706
+ * @author     Par0noid Solutions
707
+ * @param		integer $cid		channelID [optional]
708
+ * @param		integer $cldbid		clientDBID [optional]
709
+ * @param		integer $cgid		channelGroupID [optional]
710
+ * @return     array channelGroupClientList
711
+ */
712
+    function channelGroupClientList($cid = NULL, $cldbid = NULL, $cgid = NULL) {
713
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
2089 714
 		
2090
-		return $this->getData('array', 'ftinitupload clientftfid='.rand(1,99).' name='.$this->escapeText($filename).' cid='.$cid.' cpw='.$this->escapeText($cpw).' size='.($size + 1).$overwrite.$resume);
2091
-	}
2092
-	
715
+        return $this->getData('multi', 'channelgroupclientlist'.(!empty($cid) ? ' cid='.$cid : '').(!empty($cldbid) ? ' cldbid='.$cldbid : '').(!empty($cgid) ? ' cgid='.$cgid : ''));
716
+    }
717
+
2093 718
 /**
2094
-  * ftList
2095
-  * 
2096
-  * 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
2097
-  *
2098
-  * <b>Output:</b>
2099
-  * <pre>
2100
-  * Array
2101
-  * {
2102
-  *  [clid] => 1
2103
-  *  [cldbid] => 2019
2104
-  *  [path] => files/virtualserver_11/channel_231
2105
-  *  [name] => 1285412348878.png
2106
-  *  [size] => 1161281
2107
-  *  [sizedone] => 275888
2108
-  *  [clientftfid] => 15
2109
-  *  [serverftfid] => 52
2110
-  *  [sender] => 0
2111
-  *  [status] => 1
2112
-  *  [current_speed] => 101037.4453
2113
-  *  [average_speed] => 101037.4453
2114
-  *  [runtime] => 2163
2115
-  * }
2116
-  * </pre>
2117
-  *
2118
-  * @author     Par0noid Solutions
2119
-  * @return     array	fileTransferList
2120
-  */
2121
-	function ftList() {
2122
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
2123
-		return $this->getData('multi', 'ftlist');
2124
-	}
2125
-
2126
-/**
2127
-  * ftRenameFile
2128
-  * 
2129
-  * 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.
2130
-  *
2131
-  * @author     Par0noid Solutions
2132
-  * @param		integer	$cid		channelID
2133
-  * @param		string	$cpw		channelPassword (leave blank if not needed)
2134
-  * @param		string	$oldname	oldFilePath
2135
-  * @param		string	$newname	newFilePath
2136
-  * @param		string  $tcid		targetChannelID [optional]
2137
-  * @param		string  $tcpw		targetChannelPassword [optional]
2138
-  * @return     boolean success
2139
-  */
2140
-	function ftRenameFile($cid, $cpw = null, $oldname, $newname, $tcid = null,  $tcpw = null) {
2141
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
2142
-		$newTarget = ($tcid != null ? ' tcid='.$tcid.' '.$tcpw : '');
2143
-		return $this->getData('boolean', 'ftrenamefile cid='.$cid.' cpw='.$cpw.' oldname='.$this->escapeText($oldname).' newname='.$this->escapeText($newname).$newTarget);
2144
-	}
2145
-
2146
-/**
2147
-  * ftStop
2148
-  * 
2149
-  * Stops the running file transfer with server-side ID serverftfid.
2150
-  *
2151
-  * @author     Par0noid Solutions
2152
-  * @param		integer	$serverftfid	serverFileTransferID
2153
-  * @param		boolean	$delete			delete incomplete file [optional] (default: true) 
2154
-  * @return     boolean success
2155
-  */
2156
-	function ftStop($serverftfid, $delete = true) {
2157
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }		
2158
-		return $this->getData('boolean', 'ftstop serverftfid='.$serverftfid.' delete='.($delete ? '1' : '0'));
2159
-	}
2160
-
2161
-/**
2162
-  * ftUploadFile
2163
-  * 
2164
-  * Uploads a file to server
2165
-  * To check if upload was successful, you have to search for this file in fileList after
2166
-  *
2167
-  * @author     Par0noid Solutions
2168
-  * @param		array	$data			return of ftInitUpload
2169
-  * @param		string	$uploadData		data which should be uploaded
2170
-  * @return     array response
2171
-  */
2172
-	function ftUploadFile($data, $uploadData) {
2173
-  		$this->runtime['fileSocket'] = @fsockopen($this->runtime['host'], $data['data']['port'], $errnum, $errstr, $this->runtime['timeout']);
2174
-  		if($this->runtime['fileSocket']) {
2175
-  			$this->ftSendKey($data['data']['ftkey'], "\n");
2176
-  			$this->ftSendData($uploadData);
2177
-  			@fclose($this->runtime['fileSocket']);
2178
-  			$this->runtime['fileSocket'] = '';
2179
-  			return $this->generateOutput(true, array(), true);
2180
-  		}else{
2181
-  			$this->addDebugLog('fileSocket returns '.$errnum. ' | '.$errstr);
2182
-  			return $this->generateOutput(false, array('Error in fileSocket: '.$errnum. ' | '.$errstr), false);
2183
-  		}
2184
-	}
2185
-
2186
-/**
2187
-  * gm
2188
-  * 
2189
-  * Sends a text message to all clients on all virtual servers in the TeamSpeak 3 Server instance.
2190
-  *
2191
-  * @author     Par0noid Solutions
2192
-  * @param		string	$msg	message
2193
-  * @return     boolean success
2194
-  */
2195
-	function gm($msg) {
2196
-		if(empty($msg)) {
2197
-			$this->addDebugLog('empty message given');
2198
-			return $this->generateOutput(false, array('Error: empty message given'), false);
2199
-		}
2200
-		return $this->getData('boolean', 'gm msg='.$this->escapeText($msg));
2201
-	}
2202
-
2203
-/**
2204
-  * hostInfo
2205
-  * 
2206
-  * Displays detailed connection information about the server instance including uptime, number of virtual servers online, traffic information, etc.
2207
-  *
2208
-  * <b>Output:</b>
2209
-  * <pre>
2210
-  * Array
2211
-  * {
2212
-  *  [instance_uptime] => 19038
2213
-  *  [host_timestamp_utc] => 1361046825
2214
-  *  [virtualservers_running_total] => 1
2215
-  *  [virtualservers_total_maxclients] => 32
2216
-  *  [virtualservers_total_clients_online] => 1
2217
-  *  [virtualservers_total_channels_online] => 2
2218
-  *  [connection_filetransfer_bandwidth_sent] => 0
2219
-  *  [connection_filetransfer_bandwidth_received] => 0
2220
-  *  [connection_filetransfer_bytes_sent_total] => 0
2221
-  *  [connection_filetransfer_bytes_received_total] => 0
2222
-  *  [connection_packets_sent_total] => 24853
2223
-  *  [connection_bytes_sent_total] => 1096128
2224
-  *  [connection_packets_received_total] => 25404
2225
-  *  [connection_bytes_received_total] => 1153918
2226
-  *  [connection_bandwidth_sent_last_second_total] => 82
2227
-  *  [connection_bandwidth_sent_last_minute_total] => 81
2228
-  *  [connection_bandwidth_received_last_second_total] => 84
2229
-  *  [connection_bandwidth_received_last_minute_total] => 87
2230
-  * }
2231
-  * </pre>
2232
-  *
2233
-  * @author     Par0noid Solutions
2234
-  * @return     array hostInformation
2235
-  */
2236
-	function hostInfo() {
2237
-		return $this->getData('array', 'hostinfo');
2238
-	}
2239
-
2240
-/**
2241
-  * instanceEdit
2242
-  * 
2243
-  * Changes the server instance configuration using given properties.
2244
-  *
2245
-  * <b>Input-Array like this:</b>
2246
-  * <pre>
2247
-  * $data = array();
2248
-  *	
2249
-  * $data['setting'] = 'value';
2250
-  * $data['setting'] = 'value';
2251
-  * </pre>
2252
-  *
2253
-  * @author     Par0noid Solutions
2254
-  * @param		array	$data	instanceProperties
2255
-  * @return     boolean success
2256
-  */
2257
-	function instanceEdit($data) {
2258
-		if(count($data) > 0) {
2259
-			$settingsString = '';
2260
-			
2261
-			foreach($data as $key => $val) {
2262
-				$settingsString .= ' '.$key.'='.$this->escapeText($val);
2263
-			}
2264
-			return $this->getData('boolean', 'instanceedit '.$settingsString);
2265
-		}else{
2266
-			$this->addDebugLog('empty array entered');
2267
-			return $this->generateOutput(false, array('Error: You can \'t give an empty array'), false);
2268
-		}
2269
-	}
2270
-
2271
-/**
2272
-  * instanceInfo
2273
-  * 
2274
-  * Displays the server instance configuration including database revision number, the file transfer port, default group IDs, etc.
2275
-  *
2276
-  * <b>Output:</b>
2277
-  * <pre>
2278
-  * Array
2279
-  * {
2280
-  *  [serverinstance_database_version] => 20
2281
-  *  [serverinstance_filetransfer_port] => 30033
2282
-  *  [serverinstance_max_download_total_bandwidth] => 18446744073709551615
2283
-  *  [serverinstance_max_upload_total_bandwidth] => 18446744073709551615
2284
-  *  [serverinstance_guest_serverquery_group] => 1
2285
-  *  [serverinstance_serverquery_flood_commands] => 10
2286
-  *  [serverinstance_serverquery_flood_time] => 3
2287
-  *  [serverinstance_serverquery_ban_time] => 600
2288
-  *  [serverinstance_template_serveradmin_group] => 3
2289
-  *  [serverinstance_template_serverdefault_group] => 5
2290
-  *  [serverinstance_template_channeladmin_group] => 1
2291
-  *  [serverinstance_template_channeldefault_group] => 4
2292
-  *  [serverinstance_permissions_version] => 15
2293
-  * }
2294
-  * </pre>
2295
-  *
2296
-  * @author     Par0noid Solutions
2297
-  * @return     array instanceInformation
2298
-  */
2299
-	function instanceInfo() {
2300
-		return $this->getData('array', 'instanceinfo');
2301
-	}
2302
-
2303
-/**
2304
-  * logAdd
2305
-  * 
2306
-  * Writes a custom entry into the servers log. Depending on your permissions, you'll be able to add entries into the server instance log and/or your virtual servers log. The loglevel parameter specifies the type of the entry.
2307
-  *
2308
-  * @author     Par0noid Solutions
2309
-  * @param		integer	$logLevel	loglevel between 1 and 4
2310
-  * @param		string	$logMsg		logMessage
2311
-  * @return     boolean success
2312
-  */
2313
-	function logAdd($logLevel, $logMsg) {
2314
-		if($logLevel >=1 and $logLevel <= 4) { 
2315
-			if(!empty($logMsg)) {
2316
-				return $this->getData('boolean', 'logadd loglevel='.$logLevel.' logmsg='.$this->escapeText($logMsg));
2317
-			}else{
2318
-				$this->addDebugLog('logMessage empty!');
2319
-				return $this->generateOutput(false, array('Error: logMessage empty!'), false);
2320
-			}
2321
-		}else{
2322
-			$this->addDebugLog('invalid logLevel!');
2323
-			return $this->generateOutput(false, array('Error: invalid logLevel!'), false);
2324
-		}
2325
-	}
2326
-
2327
-/**
2328
-  * login
2329
-  * 
2330
-  * Authenticates with the TeamSpeak 3 Server instance using given ServerQuery login credentials.
2331
-  *
2332
-  * @author     Par0noid Solutions
2333
-  * @param		string	$username	username
2334
-  * @param		string	$password	password
2335
-  * @return     boolean success
2336
-  */
2337
-	function login($username, $password) {
2338
-		return $this->getData('boolean', 'login '.$this->escapeText($username).' '.$this->escapeText($password));
2339
-	}
2340
-
2341
-/**
2342
-  * logout
2343
-  * 
2344
-  * Deselects the active virtual server and logs out from the server instance.
2345
-  *
2346
-  * @author     Par0noid Solutions
2347
-  * @return     boolean success
2348
-  */
2349
-	function logout() {
2350
-		$this->runtime['selected'] = false;
2351
-		return $this->getData('boolean', 'logout');
2352
-	}
2353
-
2354
-/**
2355
-  * logView
2356
-  * 
2357
-  * Displays a specified number of entries from the servers log. If instance is set to 1, the server will return lines from the master logfile (ts3server_0.log) instead of the selected virtual server logfile.
2358
-  * 
2359
-  * <b>Output:</b>
2360
-  * <pre>
2361
-  * Array
2362
-  * {
2363
-  *  [last_pos] => 0
2364
-  *  [file_size] => 1085
2365
-  *  [l] => 2012-01-10 20:34:31.379260|INFO    |ServerLibPriv |   | TeamSpeak 3 Server 3.0.1 (2011-11-17 07:34:30)
2366
-  * }
2367
-  * {
2368
-  *  [l] => 2012-01-10 20:34:31.380260|INFO    |DatabaseQuery |   | dbPlugin name:    SQLite3 plugin, Version 2, (c)TeamSpeak Systems GmbH
2369
-  * }
2370
-  * {
2371
-  *  [l] => 2012-01-10 20:34:31.380260|INFO    |DatabaseQuery |   | dbPlugin version: 3.7.3
2372
-  * }
2373
-  * </pre>
2374
-  *
2375
-  * @author     Par0noid Solutions
2376
-  * @param		integer	$lines	between 1 and 100
2377
-  * @param		integer	$reverse	{1|0} [optional]
2378
-  * @param		integer	$instance	{1|0} [optional]
2379
-  * @param		integer	$begin_pos	{1|0} [optional]
2380
-  * @return     multidimensional-array logEntries
2381
-  */
2382
-	function logView($lines, $reverse = 0, $instance = 0, $begin_pos = 0) {		
2383
-		if($lines >=1 and $lines <=100) {
2384
-			return $this->getData('multi', 'logview lines='.$lines.' reverse='.($reverse == 0 ? '0' : '1').' instance='.($instance == 0 ? '0' : '1').' begin_pos='.($begin_pos == 0 ? '0' : $begin_pos));
2385
-		}else{
2386
-			$this->addDebugLog('please choose a limit between 1 and 100');
2387
-			$this->generateOutput(false, array('Error: please choose a limit between 1 and 100'), false);
2388
-		}
2389
-	}
2390
-
2391
-/**
2392
-  * messageAdd
2393
-  * 
2394
-  * Sends an offline message to the client specified by cluid.
2395
-  *
2396
-  * @author     Par0noid Solutions
2397
-  * @param		string	$cluid		clientUID
2398
-  * @param		string	$subject	Subject of the message
2399
-  * @param		string	$message	Text of the message
2400
-  * @return     boolean success
2401
-  */
2402
-	function messageAdd($cluid, $subject, $message) {		
2403
-        if(!$this->runtime['selected']) { return $this->checkSelected(); }
2404
-        return $this->getData('boolean', 'messageadd cluid='.$cluid.' subject='.$this->escapeText($subject).' message='.$this->escapeText($message)); 
2405
-	}
2406
-
2407
-/**
2408
-  * messageDelete
2409
-  * 
2410
-  * Deletes an existing offline message with ID msgid from your inbox.
2411
-  *
2412
-  * @author     Par0noid Solutions
2413
-  * @param		string	$messageID		messageID
2414
-  * @return     boolean success
2415
-  */
2416
-	function messageDelete($messageID) {		
719
+ * channelGroupCopy
720
+ * 
721
+ * 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.
722
+ *
723
+ * <b>groupDbTypes:</b>
724
+ *	<ol start="0">
725
+ *		<li>template group (used for new virtual servers)</li>
726
+ *		<li>regular group (used for regular clients)</li>
727
+ *		<li>global query group (used for ServerQuery clients)</li>
728
+ *	</ol>
729
+ *
730
+ * <b>Output:</b>
731
+ * <pre>
732
+ * Array
733
+ * {
734
+ *  [cgid] => 86
735
+ * }
736
+ * </pre>
737
+ *
738
+ * @author     Par0noid Solutions
739
+ * @param		integer	$scgid	sourceChannelGroupID
740
+ * @param		integer	$tcgid	targetChannelGroupID 
741
+ * @param		integer $name	groupName
742
+ * @param		integer	$type	groupDbType
743
+ * @return     array groupId
744
+ */
745
+    function channelGroupCopy($scgid, $tcgid, $name, $type = 1) {
2417 746
         if(!$this->runtime['selected']) { return $this->checkSelected(); }
2418
-        return $this->getData('boolean', 'messagedel msgid='.$messageID); 
2419
-	}
2420
-
2421
-/**
2422
-  * messageGet
2423
-  * 
2424
-  * Displays an existing offline message with ID msgid from your inbox. Please note that this does not automatically set the flag_read property of the message.
2425
-  *
2426
-  * @author     Par0noid Solutions
2427
-  * @param		string	$messageID		messageID
2428
-  * @return     array messageInformation
2429
-  */
2430
-	function messageGet($messageID) {		
747
+        return $this->getData('array', 'channelgroupcopy scgid='.$scgid.' tcgid='.$tcgid.' name='.$this->escapeText($name).' type='.$type);
748
+    }
749
+
750
+/**
751
+ * channelGroupDelete
752
+ * 
753
+ * Deletes a channel group by ID. If force is set to 1, the channel group will be deleted even if there are clients within.
754
+ *
755
+ * @author     Par0noid Solutions
756
+ * @param		integer $cgid	channelGroupID
757
+ * @param		integer $force	forces deleting channelGroup (default: 1)
758
+ * @return     boolean success
759
+ */
760
+    function channelGroupDelete($cgid, $force = 1) {
761
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
762
+        return $this->getData('boolean', 'channelgroupdel cgid='.$cgid.' force='.$force);
763
+    }
764
+
765
+/**
766
+ * channelGroupDelPerm
767
+ * 
768
+ * 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.
769
+ *
770
+ * <b>Input-Array like this:</b>
771
+ * <pre>
772
+ * $permissions = array();
773
+ * $permissions[] = 'permissionID';
774
+ * $permissions[] = 'permissionName';
775
+ * </pre>
776
+ *
777
+ * @author     Par0noid Solutions
778
+ * @param		integer		$cgid				channelGroupID
779
+ * @param		array		$permissions		permissions
780
+ * @return     boolean success
781
+ */
782
+    function channelGroupDelPerm($cgid, $permissions) {
783
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
784
+        $permissionArray = array();
785
+		
786
+        if(count($permissions) > 0) {
787
+            foreach($permissions AS $value) {
788
+                $permissionArray[] = (is_numeric($value) ? 'permid=' : 'permsid=').$value;
789
+            }
790
+            return $this->getData('boolean', 'channelgroupdelperm cgid='.$cgid.' '.implode('|', $permissionArray));
791
+        }else{
792
+            $this->addDebugLog('no permissions given');
793
+            return $this->generateOutput(false, array('Error: no permissions given'), false);
794
+        }
795
+    }
796
+
797
+/**
798
+ * channelGroupList
799
+ * 
800
+ * Displays a list of channel groups available on the selected virtual server.
801
+ * 
802
+ * <b>Output:</b>
803
+ * <pre>
804
+ * Array
805
+ * {
806
+ *  [cgid] => 3
807
+ *  [name] => Testname
808
+ *  [type] => 0
809
+ *  [iconid] => 100
810
+ *  [savedb] => 1
811
+ *  [sortid] => 0
812
+ *  [namemode] => 0
813
+ *  [n_modifyp] => 75
814
+ *  [n_member_addp] => 50
815
+ *  [n_member_removep] => 50
816
+ * }
817
+ * </pre>
818
+ *
819
+ * @author     Par0noid Solutions
820
+ * @return     array channelGroupList
821
+ */
822
+    function channelGroupList() {
823
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
824
+		
825
+        return $this->getData('multi', 'channelgrouplist');
826
+    }
827
+
828
+/**
829
+ * channelGroupPermList
830
+ * 
831
+ * Displays a list of permissions assigned to the channel group specified with cgid.
832
+ * If the permsid option is specified, the output will contain the permission names instead of the internal IDs.
833
+ * 
834
+ * <b>Output:</b>
835
+ * <pre>
836
+ * Array
837
+ * {
838
+ *  [permid] => 8471 (displayed if permsid is false)
839
+ *  [permsid] => i_channel_create_modify_with_codec_latency_factor_min (displayed if permsid is true)
840
+ *  [permvalue] => 1
841
+ *  [permnegated] => 0
842
+ *  [permskip] => 0
843
+ * }
844
+ * </pre>
845
+ *
846
+ * @author     Par0noid Solutions
847
+ * @param		integer		$cgid		channelGroupID
848
+ * @param		boolean		$permsid	permsid
849
+ * @return		array	channelGroupPermlist
850
+ */
851
+        function channelGroupPermList($cgid, $permsid = false) {
852
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }		
853
+        return $this->getData('multi', 'channelgrouppermlist cgid='.$cgid.($permsid ? ' -permsid' : ''));
854
+    }
855
+
856
+/**
857
+ * channelGroupRename
858
+ * 
859
+ * Changes the name of a specified channel group.
860
+ *
861
+ * @author     Par0noid Solutions
862
+ * @param		integer $cgid groupID
863
+ * @param		integer $name groupName
864
+ * @return     boolean success
865
+ */
866
+    function channelGroupRename($cgid, $name) {
867
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
868
+        return $this->getData('boolean', 'channelgrouprename cgid='.$cgid.' name='.$this->escapeText($name));
869
+    }
870
+
871
+/**
872
+ * channelInfo
873
+ *
874
+ *	Displays detailed configuration information about a channel including ID, topic, description, etc.
875
+ * <b>Output:</b>
876
+ * <pre>
877
+ * Array
878
+ * {
879
+ *  [pid] => 0
880
+ *  [channel_name] => Test
881
+ *  [channel_topic] => 
882
+ *  [channel_description] => 
883
+ *  [channel_password] => cc97Pm4oOYq0J9fXDAgiWv/qScQ=
884
+ *  [channel_codec] => 2
885
+ *  [channel_codec_quality] => 7
886
+ *  [channel_maxclients] => -1
887
+ *  [channel_maxfamilyclients] => -1
888
+ *  [channel_order] => 1
889
+ *  [channel_flag_permanent] => 1
890
+ *  [channel_flag_semi_permanent] => 0
891
+ *  [channel_flag_default] => 0
892
+ *  [channel_flag_password] => 0
893
+ *  [channel_codec_latency_factor] => 1
894
+ *  [channel_codec_is_unencrypted] => 1
895
+ *	 [channel_security_salt] => 
896
+ *  [channel_delete_delay] => 0
897
+ *  [channel_flag_maxclients_unlimited] => 1
898
+ *  [channel_flag_maxfamilyclients_unlimited] => 0
899
+ *  [channel_flag_maxfamilyclients_inherited] => 1
900
+ *  [channel_filepath] => files\\virtualserver_1\\channel_2
901
+ *  [channel_needed_talk_power] => 0
902
+ *  [channel_forced_silence] => 0
903
+ *  [channel_name_phonetic] => 
904
+ *  [channel_icon_id] => 0
905
+ *	 [channel_flag_private] => 0
906
+ *  [seconds_empty] => 61 (If it's a temporary channel with a channel delete delay)
907
+ * }
908
+ * </pre>
909
+ *
910
+ * @author     Par0noid Solutions
911
+ * @param		integer $cid channelID
912
+ * @return     array channelInfo
913
+ */
914
+    function channelInfo($cid) {
915
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
916
+        return $this->getData('array', 'channelinfo cid='.$cid);
917
+    }
918
+
919
+/**
920
+ * channelList
921
+ * 
922
+ * 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.
923
+ *
924
+ * <b>Possible parameters:</b> [-topic] [-flags] [-voice] [-limits] [-icon] [-seconds_empty]
925
+ *
926
+ * <b>Output: (without parameters)</b>
927
+ * <pre>
928
+ * Array
929
+ * {
930
+ *  [cid] => 2
931
+ *  [pid] => 0
932
+ *  [channel_order] => 1
933
+ *  [channel_name] => Test
934
+ *  [total_clients] => 0
935
+ *  [channel_needed_subscribe_power] => 0
936
+ * }
937
+ * </pre>
938
+ * <b>Output: (from parameters)</b>
939
+ * <pre>
940
+ * Array
941
+ * {
942
+ *  [-topic] => [channel_topic] => Default Channel has no topic
943
+ *  [-flags] => [channel_flag_default] => 1
944
+ *  [-flags] => [channel_flag_password] => 0
945
+ *  [-flags] => [channel_flag_permanent] => 1
946
+ *  [-flags] => [channel_flag_semi_permanent] => 0
947
+ *  [-voice] => [channel_codec] => 2
948
+ *  [-voice] => [channel_codec_quality] => 7
949
+ *  [-voice] => [channel_needed_talk_power] => 0
950
+ *  [-limits] => [total_clients_family] => 1
951
+ *  [-limits] => [channel_maxclients] => -1
952
+ *  [-limits] => [channel_maxfamilyclients] => -1
953
+ *  [-icon] => [channel_icon_id] => 0
954
+ *  [-seconds_empty] => [seconds_empty] => -1
955
+ * }
956
+ * </pre>
957
+ * <b>Usage:</b>
958
+ * <pre>
959
+ * $ts3->channelList(); //No parameters
960
+ * $ts3->channelList("-flags"); //Single parameter
961
+ * $ts3->channelList("-topic -flags -voice -limits -icon"); //Multiple parameters / all
962
+ * </pre>
963
+ *
964
+ * @author     Par0noid Solutions
965
+ * @param		string		$params		additional parameters [optional]
966
+ * @return		array	channelList
967
+ */
968
+    function channelList($params = null) {
969
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
970
+        if(!empty($params)) { $params = ' '.$params; }
971
+		
972
+        return $this->getData('multi', 'channellist'.$params);
973
+    }
974
+
975
+/**
976
+ * channelMove
977
+ * 
978
+ * 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.
979
+ *
980
+ * @author     Par0noid Solutions
981
+ * @param		integer $cid	channelID
982
+ * @param		integer $cpid	channelParentID
983
+ * @param		integer $order	channelSortOrder
984
+ * @return     boolean success
985
+ */
986
+    function channelMove($cid, $cpid, $order = null) {
987
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }		
988
+        return $this->getData('boolean', 'channelmove cid='.$cid.' cpid='.$cpid.($order != null ? ' order='.$order : ''));
989
+    }
990
+
991
+/**
992
+ * channelPermList
993
+ * 
994
+ * Displays a list of permissions defined for a channel.
995
+ *
996
+ * <b>Output:</b>
997
+ * <pre>
998
+ * Array
999
+ * {
1000
+ *  [cid] => 2 (only in first result)
1001
+ *  [permid] => 8471 (if permsid = false)
1002
+ *  [permsid] => i_channel_needed_delete_power (if permsid = true)
1003
+ *  [permvalue] => 1
1004
+ *  [permnegated] => 0
1005
+ *  [permskip] => 0
1006
+ * }
1007
+ * </pre>
1008
+ *
1009
+ * @author     Par0noid Solutions
1010
+ * @param		integer		$cid		channelID
1011
+ * @param		boolean		$permsid	displays permissionName instead of permissionID [optional]
1012
+ * @return     array channelpermlist
1013
+ */
1014
+    function channelPermList($cid, $permsid = false) {
1015
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }	
1016
+        return $this->getData('multi', 'channelpermlist cid='.$cid.($permsid ? ' -permsid' : ''));
1017
+    }
1018
+
1019
+/**
1020
+ * clientAddPerm
1021
+ * 
1022
+ * 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.
1023
+ *
1024
+ * <b>Input-Array like this:</b>
1025
+ * <pre>
1026
+ * $permissions = array();
1027
+ * $permissions['permissionID'] = array('permissionValue', 'permskip');
1028
+ * //or you could use Permission Name
1029
+ * $permissions['permissionName'] = array('permissionValue', 'permskip');
1030
+ * </pre>
1031
+ *
1032
+ * @author     Par0noid Solutions
1033
+ * @param		integer	$cldbid			clientDBID
1034
+ * @param		array	$permissions	permissions
1035
+ * @return     boolean success
1036
+ */
1037
+    function clientAddPerm($cldbid, $permissions) {
1038
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
1039
+		
1040
+        if(count($permissions) > 0) {
1041
+            //Permissions given
1042
+				
1043
+            //Errorcollector
1044
+            $errors = array();
1045
+				
1046
+            //Split Permissions to prevent query from overload
1047
+            $permissions = array_chunk($permissions, 50, true);
1048
+				
1049
+            //Action for each splitted part of permission
1050
+            foreach($permissions as $permission_part)
1051
+            {
1052
+                //Create command_string for each command that we could use implode later
1053
+                $command_string = array();
1054
+		
1055
+                foreach($permission_part as $key => $value)
1056
+                {
1057
+                    $command_string[] = (is_numeric($key) ? "permid=" : "permsid=").$this->escapeText($key).' permvalue='.$this->escapeText($value[0]).' permskip='.$this->escapeText($value[1]);
1058
+                }
1059
+		
1060
+                $result = $this->getData('boolean', 'clientaddperm cldbid='.$cldbid.' '.implode('|', $command_string));
1061
+		
1062
+                if(!$result['success'])
1063
+                {
1064
+                    foreach($result['errors'] as $error)
1065
+                    {
1066
+                        $errors[] = $error;
1067
+                    }
1068
+                }
1069
+            }
1070
+				
1071
+            if(count($errors) == 0)
1072
+            {
1073
+                return $this->generateOutput(true, array(), true);
1074
+            }else{
1075
+                return $this->generateOutput(false, $errors, false);
1076
+            }
1077
+        }else{
1078
+            // No permissions given
1079
+            $this->addDebugLog('no permissions given');
1080
+            return $this->generateOutput(false, array('Error: no permissions given'), false);
1081
+        }
1082
+    }
1083
+
1084
+/**
1085
+ * clientAvatar
1086
+ *
1087
+ * Will return the base64 encoded binary of the clients avatar
1088
+ * 
1089
+ * <pre>
1090
+ * $result = $tsAdmin->clientAvatar($uid);
1091
+ * You can display it like: echo '<img src="data:image/png;base64,'.$result["data"].'" />';
1092
+ * </pre>
1093
+ *
1094
+ * @author  Par0noid Solutions
1095
+ * @param  string  $uid  clientUID
1096
+ * @return array  base64 image
1097
+ */
1098
+    function clientAvatar($uid) {
1099
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
1100
+
1101
+        if(empty($uid))
1102
+        {
1103
+        return $this->generateOutput(false, array('Error: empty uid'), false);
1104
+        }
1105
+
1106
+        $newChars = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p');
1107
+        $auid = '';
1108
+
1109
+        for ($i = 0; $i <= 19; $i++) {
1110
+                $char = ord(substr(base64_decode($uid), $i, 1));
1111
+                $auid .= $newChars[($char & 0xF0) >> 4];
1112
+                $auid .= $newChars[$char & 0x0F];
1113
+        }
1114
+
1115
+        $check = $this->ftgetfileinfo(0, '', '/avatar_'.$auid);
1116
+
1117
+        if(!$check["success"])
1118
+        {
1119
+        return $this->generateOutput(false, array('Error: avatar does not exist'), false);
1120
+        }
1121
+
1122
+        $init = $this->ftInitDownload('/avatar_'.$auid, 0, '');
1123
+
1124
+        if(!$init["success"])
1125
+        {
1126
+        return $this->generateOutput(false, array('Error: init failed'), false);
1127
+        }
1128
+
1129
+        $download = $this->ftDownloadFile($init);
1130
+
1131
+        if(is_array($download))
1132
+        {
1133
+        return $download;
1134
+        }else{
1135
+        return $this->generateOutput(true, false, base64_encode($download));
1136
+        }
1137
+
1138
+    }
1139
+	
1140
+/**
1141
+ * clientDbDelete
1142
+ * 
1143
+ * Deletes a clients properties from the database.
1144
+ *
1145
+ * @author     Par0noid Solutions
1146
+ * @param		integer $cldbid	clientDBID
1147
+ * @return     boolean success
1148
+ */
1149
+    function clientDbDelete($cldbid) {
1150
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
1151
+        return $this->getData('boolean', 'clientdbdelete cldbid='.$cldbid);
1152
+    }
1153
+
1154
+/**
1155
+ * clientDbEdit
1156
+ * 
1157
+ * Changes a clients settings using given properties.
1158
+ *
1159
+ * <b>Input-Array like this:</b>
1160
+ * <pre>
1161
+ * $data = array();
1162
+ * 
1163
+ * $data['property'] = 'value';
1164
+ * $data['property'] = 'value';
1165
+ * </pre>
1166
+ *
1167
+ * @author     Par0noid Solutions
1168
+ * @param		integer		$cldbid		clientDBID
1169
+ * @param		array		$data	 	clientProperties
1170
+ * @return     boolean success
1171
+ */
1172
+    function clientDbEdit($cldbid, $data) {
1173
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
1174
+		
1175
+        $settingsString = '';
1176
+		
1177
+        foreach($data as $key => $value) {
1178
+            $settingsString .= ' '.$key.'='.$this->escapeText($value);
1179
+        }
1180
+		
1181
+        return $this->getData('boolean', 'clientdbedit cldbid='.$cldbid.$settingsString);
1182
+    }
1183
+
1184
+/**
1185
+ * clientDbFind
1186
+ * 
1187
+ * 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.
1188
+ *
1189
+ * <b>Output:</b>
1190
+ * <pre>
1191
+ * Array
1192
+ * {
1193
+ *  [cldbid] => 2
1194
+ * }
1195
+ *	</pre>
1196
+ *
1197
+ * @author     Par0noid Solutions
1198
+ * @param		string	$pattern	clientName
1199
+ * @param		boolean	$uid		set true to add -uid param [optional]
1200
+ * @return     array clientList 
1201
+ */
1202
+    function clientDbFind($pattern, $uid = false) {
1203
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
1204
+        return $this->getData('multi', 'clientdbfind pattern='.$this->escapeText($pattern).($uid ? ' -uid' : ''));
1205
+    }
1206
+
1207
+/**
1208
+ * clientDbInfo
1209
+ *
1210
+ * Displays detailed database information about a client including unique ID, creation date, etc.
1211
+ *
1212
+ * <b>Output:</b>
1213
+ * <pre>
1214
+ * Array
1215
+ * {
1216
+ *  [client_unique_identifier] => nUixbsq/XakrrmbqU8O30R/D8Gc=
1217
+ *  [client_nickname] => par0noid
1218
+ *  [client_database_id] => 2
1219
+ *  [client_created] => 1361027850
1220
+ *  [client_lastconnected] => 1361027850
1221
+ *  [client_totalconnections] => 1
1222
+ *  [client_flag_avatar] => 
1223
+ *  [client_description] => 
1224
+ *  [client_month_bytes_uploaded] => 0
1225
+ *  [client_month_bytes_downloaded] => 0
1226
+ *  [client_total_bytes_uploaded] => 0
1227
+ *  [client_total_bytes_downloaded] => 0
1228
+ *  [client_icon_id] => 0
1229
+ *  [client_base64HashClientUID] => jneilbgomklpfnkjclkoggokfdmdlhnbbpmdpagh
1230
+ *  [client_lastip] => 127.0.0.1
1231
+ * }
1232
+ * </pre>
1233
+ *
1234
+ * @author     Par0noid Solutions
1235
+ * @param		integer		$cldbid		clientDBID
1236
+ * @return     array	clientDbInfo
1237
+ */
1238
+    function clientDbInfo($cldbid) {
1239
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
1240
+        return $this->getData('array', 'clientdbinfo cldbid='.$cldbid);
1241
+    }
1242
+
1243
+/**
1244
+ * clientDbList
1245
+ * 
1246
+ * Displays a list of client identities known by the server including their database ID, last nickname, etc.
1247
+ *
1248
+ * <b>Possible params:</b> [start={offset}] [duration={limit}] [-count]
1249
+ *
1250
+ * <b>Output:</b>
1251
+ * <pre>
1252
+ * Array
1253
+ * {
1254
+ *  [count] => 1 (if count parameter is set)
1255
+ *  [cldbid] => 2
1256
+ *  [client_unique_identifier] => nUixbsq/XakrrmbqU8O30R/D8Gc=
1257
+ *  [client_nickname] => par0noid
1258
+ *  [client_created] => 1361027850
1259
+ *  [client_lastconnected] => 1361027850
1260
+ *  [client_totalconnections] => 1
1261
+ *  [client_description] => 
1262
+ *  [client_lastip] => 127.0.0.1
1263
+ * }
1264
+ * </pre>
1265
+ *
1266
+ * @author     Par0noid Solutions
1267
+ * @param		integer	$start		offset [optional] (Default: 0)
1268
+ * @param		integer	$duration	limit [optional] (Default: -1)
1269
+ * @param		boolean	$count		set true to add -count param [optional]
1270
+ * @return     array clientdblist
1271
+ */
1272
+    function clientDbList($start = 0, $duration = -1, $count = false) {
1273
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
1274
+        return $this->getData('multi', 'clientdblist start='.$start.' duration='.$duration.($count ? ' -count' : ''));
1275
+    }
1276
+
1277
+/**
1278
+ * clientDelPerm
1279
+ * 
1280
+ * 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.
1281
+ *
1282
+ * <b>Input-Array like this:</b>
1283
+ * <pre>
1284
+ * $permissions = array();
1285
+ * $permissions['permissionID'] = 'permissionValue';
1286
+ * //or you could use Permission Name
1287
+ * $permissions['permissionName'] = 'permissionValue';
1288
+ * </pre>
1289
+ *
1290
+ * @author     Par0noid Solutions
1291
+ * @param		integer		$cldbid				clientDBID
1292
+ * @param		array		$permissionIds		permissionIDs
1293
+ * @return     boolean success
1294
+ */
1295
+    function clientDelPerm($cldbid, $permissionIds) {
1296
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
1297
+		
1298
+        $permissionArray = array();
1299
+		
1300
+        if(count($permissionIds) > 0) {
1301
+            foreach($permissionIds AS $value) {
1302
+                $permissionArray[] = (is_numeric($value) ? 'permid=' : 'permsid=').$value;
1303
+            }
1304
+            return $this->getData('boolean', 'clientdelperm cldbid='.$cldbid.' '.implode('|', $permissionArray));
1305
+        }else{
1306
+            $this->addDebugLog('no permissions given');
1307
+            return $this->generateOutput(false, array('Error: no permissions given'), false);
1308
+        }
1309
+    }
1310
+
1311
+/**
1312
+ * clientEdit
1313
+ * 
1314
+ * Changes a clients settings using given properties.
1315
+ *
1316
+ * <b>Input-Array like this:</b>
1317
+ * <pre>
1318
+ * $data = array();
1319
+ *	
1320
+ * $data['property'] = 'value';
1321
+ * $data['property'] = 'value';
1322
+ * </pre>
1323
+ *
1324
+ * @author     Par0noid Solutions
1325
+ * @param		integer	$clid 			clientID
1326
+ * @param		array	$data			clientProperties
1327
+ * @return     boolean success
1328
+ */
1329
+    function clientEdit($clid, $data) {
1330
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
1331
+		
1332
+        $settingsString = '';
1333
+		
1334
+        foreach($data as $key => $value) {
1335
+            $settingsString .= ' '.$key.'='.$this->escapeText($value);
1336
+        }
1337
+		
1338
+        return $this->getData('boolean', 'clientedit clid='.$clid.$settingsString);
1339
+    }
1340
+
1341
+/**
1342
+ * clientFind
1343
+ * 
1344
+ * Displays a list of clients matching a given name pattern.
1345
+ *
1346
+ * <b>Output:</b>
1347
+ * <pre>
1348
+ * Array
1349
+ * {
1350
+ *  [clid] => 18
1351
+ *  [client_nickname] => par0noid
1352
+ * }
1353
+ * </pre>
1354
+ *
1355
+ * @author     Par0noid Solutions
1356
+ * @param		string	$pattern	clientName
1357
+ * @return     array clienList
1358
+ */
1359
+    function clientFind($pattern) {
1360
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
1361
+        return $this->getData('multi', 'clientfind pattern='.$this->escapeText($pattern));
1362
+    }
1363
+
1364
+/**
1365
+ * clientGetDbIdFromUid
1366
+ * 
1367
+ * Displays the database ID matching the unique identifier specified by cluid.
1368
+ *
1369
+ *	<b>Output:</b>
1370
+ * <pre>
1371
+ * Array
1372
+ * {
1373
+ *  [cluid] => nUixbsq/XakrrmbqU8O30R/D8Gc=
1374
+ *  [cldbid] => 2
1375
+ * }
1376
+ * </pre>
1377
+ *
1378
+ * @author     Par0noid Solutions
1379
+ * @param		string	$cluid	clientUID
1380
+ * @return     array clientInfo
1381
+ */
1382
+    function clientGetDbIdFromUid($cluid) {
1383
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
1384
+        return $this->getData('array', 'clientgetdbidfromuid cluid='.$cluid);
1385
+    }
1386
+
1387
+/**
1388
+ * clientGetIds
1389
+ * 
1390
+ * Displays all client IDs matching the unique identifier specified by cluid.
1391
+ *
1392
+ * <b>Output:</b>
1393
+ * <pre>
1394
+ * Array
1395
+ * {
1396
+ *  [cluid] => nUixbdf/XakrrmsdffO30R/D8Gc=
1397
+ *  [clid] => 7
1398
+ *  [name] => Par0noid
1399
+ * }
1400
+ * </pre>
1401
+ *
1402
+ * @author     Par0noid Solutions
1403
+ * @param		string	$cluid	clientUID
1404
+ * @return     array clientList 
1405
+ */
1406
+    function clientGetIds($cluid) {
1407
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
1408
+        return $this->getData('multi', 'clientgetids cluid='.$cluid);
1409
+    }
1410
+
1411
+/**
1412
+ * clientGetNameFromDbid
1413
+ * 
1414
+ * Displays the unique identifier and nickname matching the database ID specified by cldbid.
1415
+ *
1416
+ *	<b>Output:</b>
1417
+ * <pre>
1418
+ * Array
1419
+ * {
1420
+ *  [cluid] => nUixbsq/XakrrmbqU8O30R/D8Gc=
1421
+ *  [cldbid] => 2
1422
+ *  [name] => Par0noid
1423
+ * }
1424
+ * </pre>
1425
+ *
1426
+ * @author     Par0noid Solutions
1427
+ * @param		integer	$cldbid	clientDBID
1428
+ * @return     array clientInfo
1429
+ */
1430
+    function clientGetNameFromDbid($cldbid) {
1431
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
1432
+        return $this->getData('array', 'clientgetnamefromdbid cldbid='.$cldbid);
1433
+    }
1434
+	
1435
+/**
1436
+ * clientGetNameFromUid
1437
+ * 
1438
+ * Displays the database ID and nickname matching the unique identifier specified by cluid.
1439
+ *
1440
+ *	<b>Output:</b>
1441
+ * <pre>
1442
+ * Array
1443
+ * {
1444
+ *  [cluid] => nUixbsq/XakrrmbqU8O30R/D8Gc=
1445
+ *  [cldbid] => 2
1446
+ *  [name] => Par0noid
1447
+ * }
1448
+ * </pre>
1449
+ *
1450
+ * @author     Par0noid Solutions
1451
+ * @param		string	$cluid	clientUID
1452
+ * @return     array clientInfo
1453
+ */
1454
+    function clientGetNameFromUid($cluid) {
1455
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
1456
+        return $this->getData('array', 'clientgetnamefromuid cluid='.$cluid);
1457
+    }
1458
+
1459
+/**
1460
+ * clientInfo
1461
+ * 
1462
+ * Displays detailed configuration information about a client including unique ID, nickname, client version, etc.
1463
+ *
1464
+ * <b>Output:</b>
1465
+ * <pre>
1466
+ * Array
1467
+ * {
1468
+ *  [cid] => 2
1469
+ *  [client_idle_time] => 4445369
1470
+ *  [client_unique_identifier] => nUixbsq/XakrrmbqU8O30R/D8Gc=
1471
+ *  [client_nickname] => par0noid
1472
+ *  [client_version] => 3.0.9.2 [Build: 1351504843]
1473
+ *  [client_platform] => Windows
1474
+ *  [client_input_muted] => 1
1475
+ *  [client_output_muted] => 1
1476
+ *  [client_outputonly_muted] => 0
1477
+ *  [client_input_hardware] => 1
1478
+ *  [client_output_hardware] => 1
1479
+ *  [client_default_channel] => 
1480
+ *  [client_meta_data] => 
1481
+ *  [client_is_recording] => 0
1482
+ *  [client_version_sign] => ldWL49uDKC3N9uxdgWRMTOzUabc1nBqUiOa+Nal5HvdxJiN4fsTnmmPo5tvglN7WqoVoFfuuKuYq1LzodtEtCg==
1483
+ *  [client_security_hash] => 
1484
+ *  [client_login_name] => 
1485
+ *  [client_database_id] => 2
1486
+ *  [client_channel_group_id] => 5
1487
+ *  [client_servergroups] => 6
1488
+ *  [client_created] => 1361027850
1489
+ *  [client_lastconnected] => 1361027850
1490
+ *  [client_totalconnections] => 1
1491
+ *  [client_away] => 0
1492
+ *  [client_away_message] => 
1493
+ *  [client_type] => 0
1494
+ *  [client_flag_avatar] => 
1495
+ *  [client_talk_power] => 75
1496
+ *  [client_talk_request] => 0
1497
+ *  [client_talk_request_msg] => 
1498
+ *  [client_description] => 
1499
+ *  [client_is_talker] => 0
1500
+ *  [client_month_bytes_uploaded] => 0
1501
+ *  [client_month_bytes_downloaded] => 0
1502
+ *  [client_total_bytes_uploaded] => 0
1503
+ *  [client_total_bytes_downloaded] => 0
1504
+ *  [client_is_priority_speaker] => 0
1505
+ *  [client_nickname_phonetic] => 
1506
+ *  [client_needed_serverquery_view_power] => 75
1507
+ *  [client_default_token] => 
1508
+ *  [client_icon_id] => 0
1509
+ *  [client_is_channel_commander] => 0
1510
+ *  [client_country] => 
1511
+ *  [client_channel_group_inherited_channel_id] => 2
1512
+ *  [client_badges] => Overwolf=0
1513
+ *  [client_base64HashClientUID] => jneilbgomklpfnkjclkoggokfdmdlhnbbpmdpagh
1514
+ *  [connection_filetransfer_bandwidth_sent] => 0
1515
+ *  [connection_filetransfer_bandwidth_received] => 0
1516
+ *  [connection_packets_sent_total] => 12130
1517
+ *  [connection_bytes_sent_total] => 542353
1518
+ *  [connection_packets_received_total] => 12681
1519
+ *  [connection_bytes_received_total] => 592935
1520
+ *  [connection_bandwidth_sent_last_second_total] => 82
1521
+ *  [connection_bandwidth_sent_last_minute_total] => 92
1522
+ *  [connection_bandwidth_received_last_second_total] => 84
1523
+ *  [connection_bandwidth_received_last_minute_total] => 88
1524
+ *  [connection_connected_time] => 5908749
1525
+ *  [connection_client_ip] => 127.0.0.1
1526
+ * } 
1527
+ * </pre>
1528
+ *
1529
+ * @author     Par0noid Solutions
1530
+ * @param		integer	$clid	clientID
1531
+ * @return     array	clientInformation
1532
+ */
1533
+    function clientInfo($clid) {
1534
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
1535
+        return $this->getData('array', 'clientinfo clid='.$clid);
1536
+    }
1537
+
1538
+/**
1539
+ * clientKick
1540
+ * 
1541
+ * 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.
1542
+ *
1543
+ * @author     Par0noid Solutions
1544
+ * @param		integer $clid		clientID
1545
+ * @param		string	$kickMode	kickMode (server or channel) (Default: server)
1546
+ * @param		string	$kickmsg 	kick reason [optional]
1547
+ * @return     boolean success
1548
+ */
1549
+    function clientKick($clid, $kickMode = "server", $kickmsg = "") {
1550
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
1551
+		
1552
+        if(in_array($kickMode, array('server', 'channel'))) {
1553
+		
1554
+            if($kickMode == 'server') { $from = '5'; }
1555
+            if($kickMode == 'channel') { $from = '4'; }
1556
+			
1557
+            if(!empty($kickmsg)) { $msg = ' reasonmsg='.$this->escapeText($kickmsg); } else{ $msg = ''; }
1558
+			
1559
+            return $this->getData('boolean', 'clientkick clid='.$clid.' reasonid='.$from.$msg);
1560
+        }else{
1561
+            $this->addDebugLog('invalid kickMode');
1562
+            return $this->generateOutput(false, array('Error: invalid kickMode'), false);
1563
+        }
1564
+    }
1565
+
1566
+/**
1567
+ * clientList
1568
+ * 
1569
+ * 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.
1570
+ *
1571
+ * <b>Possible params:</b> [-uid] [-away] [-voice] [-times] [-groups] [-info] [-icon] [-country] [-ip] [-badges]
1572
+ *
1573
+ * <b>Output: (without parameters)</b>
1574
+ * <pre>
1575
+ * Array
1576
+ * {
1577
+ *  [clid] => 1
1578
+ *  [cid] => 1
1579
+ *  [client_database_id] => 2
1580
+ *  [client_nickname] => Par0noid
1581
+ *  [client_type] => 0
1582
+ *  [-uid] => [client_unique_identifier] => nUixbsq/XakrrmbqU8O30R/D8Gc=
1583
+ *  [-away] => [client_away] => 0
1584
+ *  [-away] => [client_away_message] => 
1585
+ *  [-voice] => [client_flag_talking] => 0
1586
+ *  [-voice] => [client_input_muted] => 0
1587
+ *  [-voice] => [client_output_muted] => 0
1588
+ *  [-voice] => [client_input_hardware] => 0
1589
+ *  [-voice] => [client_output_hardware] => 0
1590
+ *  [-voice] => [client_talk_power] => 0
1591
+ *  [-voice] => [client_is_talker] => 0
1592
+ *  [-voice] => [client_is_priority_speaker] => 0
1593
+ *  [-voice] => [client_is_recording] => 0
1594
+ *  [-voice] => [client_is_channel_commander] => 0
1595
+ *  [-times] => [client_idle_time] => 1714
1596
+ *  [-times] => [client_created] => 1361027850
1597
+ *  [-times] => [client_lastconnected] => 1361042955
1598
+ *  [-groups] => [client_servergroups] => 6,7
1599
+ *  [-groups] => [client_channel_group_id] => 8
1600
+ *  [-groups] => [client_channel_group_inherited_channel_id] => 1
1601
+ *  [-info] => [client_version] => 3.0.9.2 [Build: 1351504843]
1602
+ *  [-info] => [client_platform] => Windows
1603
+ *  [-icon] => [client_icon_id] => 0
1604
+ *  [-country] => [client_country] => 
1605
+ *  [-ip] => [connection_client_ip] => 127.0.0.1
1606
+ *  [-badges] => [client_badges] => Overwolf=0
1607
+ * }
1608
+ * 
1609
+ * <b>Usage:</b>
1610
+ * 
1611
+ * $ts3->clientList(); //No parameters
1612
+ * $ts3->clientList("-uid"); //Single parameter
1613
+ * $ts3->clientList("-uid -away -voice -times -groups -info -country -icon -ip -badges"); //Multiple parameters
1614
+ * </pre>
1615
+ *
1616
+ * @author     Par0noid Solutions
1617
+ * @param		string	$params	additional parameters [optional]
1618
+ * @return     array clientList 
1619
+ */
1620
+    function clientList($params = null) {
1621
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
1622
+		
1623
+        if(!empty($params)) { $params = ' '.$params; }
1624
+		
1625
+        return $this->getData('multi', 'clientlist'.$params);
1626
+    }
1627
+
1628
+/**
1629
+ * clientMove
1630
+ * 
1631
+ * 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.
1632
+ *
1633
+ * @author     Par0noid Solutions
1634
+ * @param		integer $clid	clientID
1635
+ * @param		integer $cid	channelID
1636
+ * @param		string	$cpw	channelPassword [optional]
1637
+ * @return     boolean success
1638
+ */
1639
+    function clientMove($clid, $cid, $cpw = null) {
1640
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
1641
+        return $this->getData('boolean', 'clientmove clid='.$clid.' cid='.$cid.(!empty($cpw) ? ' cpw='.$this->escapeText($cpw) : ''));
1642
+    }
1643
+
1644
+/**
1645
+ * clientPermList
1646
+ * 
1647
+ * Displays a list of permissions defined for a client.
1648
+ *
1649
+ * <b>Output:</b>
1650
+ * <pre>
1651
+ * Array
1652
+ * {
1653
+ *  [permid] => 20654 //with permsid = false
1654
+ *  [permsid] => b_client_ignore_bans //with permsid = true
1655
+ *  [permvalue] => 1
1656
+ *  [permnegated] => 0
1657
+ *  [permskip] => 0
1658
+ * }
1659
+ * </pre>
1660
+ *
1661
+ * @author     Par0noid Solutions
1662
+ * @param		intege		$cldbid 	clientDBID
1663
+ * @param		boolean		$permsid	set true to add -permsid param [optional]
1664
+ * @return     array clientPermList
1665
+ */
1666
+    function clientPermList($cldbid, $permsid = false) {
1667
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }		
1668
+        return $this->getData('multi', 'clientpermlist cldbid='.$cldbid.($permsid ? ' -permsid' : ''));
1669
+    }
1670
+
1671
+/**
1672
+ * clientPoke
1673
+ * 
1674
+ * Sends a poke message to the client specified with clid.
1675
+ *
1676
+ * @author     Par0noid Solutions
1677
+ * @param		integer $clid	clientID
1678
+ * @param		string 	$msg 	pokeMessage
1679
+ * @return     boolean success
1680
+ */
1681
+    function clientPoke($clid, $msg) {
1682
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
1683
+        return $this->getData('boolean', 'clientpoke clid='.$clid.' msg='.$this->escapeText($msg));
1684
+    }
1685
+
1686
+/**
1687
+ * clientSetServerQueryLogin
1688
+ * 
1689
+ * Updates your own ServerQuery login credentials using a specified username. The password will be auto-generated.
1690
+ * 
1691
+ * <b>Output:</b>
1692
+ * <pre>
1693
+ * Array
1694
+ * {
1695
+ *  [client_login_password] => +r\/TQqvR
1696
+ * }
1697
+ * </pre>
1698
+ *
1699
+ * @author     Par0noid Solutions
1700
+ * @param		string	$username	username
1701
+ * @return     array userInfomation
1702
+ */
1703
+    function clientSetServerQueryLogin($username) {
1704
+        return $this->getData('array', 'clientsetserverquerylogin client_login_name='.$this->escapeText($username));
1705
+    }
1706
+
1707
+/**
1708
+ * clientUpdate
1709
+ * 
1710
+ * Change your ServerQuery clients settings using given properties.
1711
+ * 
1712
+ * <b>Input-Array like this:</b>
1713
+ * <pre>
1714
+ * $data = array();
1715
+ * $data['property'] = 'value';
1716
+ * $data['property'] = 'value';
1717
+ * </pre>
1718
+ *
1719
+ * @author     Par0noid Solutions
1720
+ * @param		array	$data	clientProperties
1721
+ * @return     boolean success
1722
+ */
1723
+    function clientUpdate($data) {
1724
+        $settingsString = '';
1725
+		
1726
+        foreach($data as $key => $value) {
1727
+            $settingsString .= ' '.$key.'='.$this->escapeText($value);
1728
+        }
1729
+		
1730
+        return $this->getData('boolean', 'clientupdate '.$settingsString);
1731
+    }
1732
+
1733
+/**
1734
+ * complainAdd
1735
+ *
1736
+ * Submits a complaint about the client with database ID tcldbid to the server.
1737
+ *
1738
+ * @author     Par0noid Solutions
1739
+ * @param		integer $tcldbid	targetClientDBID
1740
+ * @param		string	$msg		complainMessage
1741
+ * @return     boolean success
1742
+ */
1743
+    function complainAdd($tcldbid, $msg) {
1744
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
1745
+        return $this->getData('boolean', 'complainadd tcldbid='.$tcldbid.' message='.$this->escapeText($msg));
1746
+    }
1747
+
1748
+/**
1749
+ * complainDelete
1750
+ * 
1751
+ * Deletes the complaint about the client with ID tcldbid submitted by the client with ID fcldbid from the server.
1752
+ *
1753
+ * @author     Par0noid Solutions
1754
+ * @param		integer $tcldbid targetClientDBID
1755
+ * @param		integer $fcldbid fromClientDBID
1756
+ * @return     boolean success
1757
+ */
1758
+    function complainDelete($tcldbid, $fcldbid) {
1759
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
1760
+        return $this->getData('boolean', 'complaindel tcldbid='.$tcldbid.' fcldbid='.$fcldbid);
1761
+    }
1762
+
1763
+/**
1764
+ * complainDeleteAll
1765
+ * 
1766
+ * Deletes all complaints about the client with database ID tcldbid from the server.
1767
+ *
1768
+ * @author     Par0noid Solutions
1769
+ * @param		integer $tcldbid targetClientDBID
1770
+ * @return     boolean success
1771
+ */
1772
+    function complainDeleteAll($tcldbid) {
1773
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
1774
+        return $this->getData('boolean', 'complaindelall tcldbid='.$tcldbid);
1775
+    }
1776
+
1777
+/**
1778
+ * complainList
1779
+ * 
1780
+ * Displays a list of complaints on the selected virtual server. If tcldbid is specified, only complaints about the targeted client will be shown.
1781
+ *
1782
+ * <b>Output:</b>
1783
+ * <pre>
1784
+ * Array
1785
+ * {
1786
+ *  [tcldbid] => 2
1787
+ *  [tname] => par0noid
1788
+ *  [fcldbid] => 1
1789
+ *  [fname] => serveradmin from 127.0.0.1:6814
1790
+ *  [message] => Steals crayons
1791
+ *  [timestamp] => 1361044090
1792
+ * }
1793
+ * </pre>
1794
+ *
1795
+ * @author     Par0noid Solutions
1796
+ * @param		string $tcldbid	targetClientDBID [optional]
1797
+ * @return     array complainList
1798
+ */
1799
+    function complainList($tcldbid = null) {
1800
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
1801
+        if(!empty($tcldbid)) { $tcldbid = ' tcldbid='.$tcldbid; }
1802
+        return $this->getData('multi', 'complainlist'.$tcldbid);
1803
+    }
1804
+	
1805
+
1806
+/**
1807
+ * customInfo
1808
+ * 
1809
+ * Displays a list of custom properties for the client specified with cldbid.
1810
+ *
1811
+ * <b>Output:</b>
1812
+ * <pre>
1813
+ * Array
1814
+ * {
1815
+ * 	[0] => Array
1816
+ *  	{
1817
+ *  		[cldbid] => 1
1818
+ *			[ident] => abc
1819
+ *			[value] => def
1820
+ *	  	}
1821
+ * 	[1] => Array
1822
+ *  	{
1823
+ *			[ident] => ghi
1824
+ *			[value] => jkl
1825
+ *	  	}
1826
+ * }
1827
+ * </pre>
1828
+ *
1829
+ * @author     Par0noid Solutions
1830
+ * @param		string $cldbid	clientDBID
1831
+ * @return     array customInfos
1832
+ */
1833
+    function customInfo($cldbid) {
1834
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
1835
+        return $this->getData('multi', 'custominfo cldbid='.$cldbid);
1836
+    }
1837
+
1838
+/**
1839
+ * customSearch
1840
+ * 
1841
+ * Searches for custom client properties specified by ident and value. The value parameter can include regular characters and SQL wildcard characters (e.g. %).
1842
+ *
1843
+ * <b>Output: (ident=abc, pattern=%)</b>
1844
+ * <pre>
1845
+ * Array
1846
+ * {
1847
+ * 	[0] => Array
1848
+ *  	{
1849
+ *  		[cldbid] => 1
1850
+ *			[ident] => abc
1851
+ *			[value] => def
1852
+ *	  	}
1853
+ * 	[1] => Array
1854
+ *  	{
1855
+ *  		[cldbid] => 2
1856
+ *			[ident] => abc
1857
+ *			[value] => def
1858
+ *	  	}
1859
+ * }
1860
+ * </pre>
1861
+ *
1862
+ * @author     Par0noid Solutions
1863
+ * @param		string	$ident		customIdent
1864
+ * @param		string	$pattern	searchpattern
1865
+ * @return     array	customSearchInfos
1866
+ */
1867
+    function customSearch($ident, $pattern) {
1868
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
1869
+        return $this->getData('multi', 'customsearch ident='.$this->escapeText($ident).' pattern='.$this->escapeText($pattern));
1870
+    }
1871
+
1872
+/**
1873
+ * execOwnCommand
1874
+ * 
1875
+ * executes a command that isn't defined in class and returns data like your propose
1876
+ * 
1877
+ * <b>Modes:</b>
1878
+ * <ul>
1879
+ * 	<li><b>0:</b> execute -> return boolean</li>
1880
+ * 	<li><b>1:</b> execute -> return normal array</li>
1881
+ * 	<li><b>2:</b> execute -> return multidimensional array</li>
1882
+ * 	<li><b>3:</b> execute -> return plaintext serverquery</li>
1883
+ * </ul>
1884
+ *
1885
+ * @author     Par0noid Solutions
1886
+ * @param		string	$mode		executionMode
1887
+ * @param		string	$command	command
1888
+ * @return     mixed result
1889
+ */
1890
+    function execOwnCommand($mode, $command) {
1891
+        if($mode == '0') {
1892
+            return $this->getData('boolean', $command);
1893
+        }
1894
+        if($mode == '1') {
1895
+            return $this->getData('array', $command);
1896
+        }
1897
+        if($mode == '2') {
1898
+            return $this->getData('multi', $command);
1899
+        }
1900
+        if($mode == '3') {
1901
+            return $this->getData('plain', $command);
1902
+        }
1903
+    }
1904
+
1905
+/**
1906
+ * ftCreateDir
1907
+ * 
1908
+ * Creates new directory in a channels file repository.
1909
+ *
1910
+ * @author     Par0noid Solutions
1911
+ * @param		string	$cid		channelId
1912
+ * @param		string	$cpw		channelPassword (leave blank if not needed)
1913
+ * @param		string	$dirname	dirPath
1914
+ * @return     boolean success
1915
+ */
1916
+    function ftCreateDir($cid, $cpw = null, $dirname) {
1917
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
1918
+        return $this->getData('boolean', 'ftcreatedir cid='.$cid.' cpw='.$this->escapeText($cpw).' dirname='.$this->escapeText($dirname));
1919
+    }
1920
+
1921
+/**
1922
+ * ftDeleteFile
1923
+ * 
1924
+ * Deletes one or more files stored in a channels file repository.
1925
+ *
1926
+ * <b>Input-Array like this:</b>
1927
+ * <pre>
1928
+ * $files = array();
1929
+ *	
1930
+ * $files[] = '/pic1.jpg';
1931
+ * $files[] = '/dokumente/test.txt';
1932
+ * $files[] = '/dokumente';
1933
+ * </pre>
1934
+ *
1935
+ * @author     Par0noid Solutions
1936
+ * @param		string	$cid	channelID
1937
+ * @param		string	$cpw	channelPassword (leave blank if not needed)
1938
+ * @param		array	$files	files
1939
+ * @return     boolean success
1940
+ */
1941
+    function ftDeleteFile($cid, $cpw = '', $files) {
1942
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
1943
+        $fileArray = array();
1944
+		
1945
+        if(count($files) > 0) {
1946
+            foreach($files AS $file) {
1947
+                $fileArray[] = 'name='.$this->escapeText($file);
1948
+            }
1949
+            return $this->getData('boolean', 'ftdeletefile cid='.$cid.' cpw='.$this->escapeText($cpw).' '.implode('|', $fileArray));
1950
+        }else{
1951
+            $this->addDebugLog('no files given');
1952
+            return $this->generateOutput(false, array('Error: no files given'), false);
1953
+        }
1954
+    }
1955
+
1956
+/**
1957
+ * ftDownloadFile
1958
+ * 
1959
+ * Ddownloads a file and returns its contents
1960
+ *
1961
+ * @author     Par0noid Solutions
1962
+ * @param		array	$data	return of ftInitDownload
1963
+ * @return     array downloadedFile
1964
+ */
1965
+    function ftDownloadFile($data) {
1966
+        $errnum = null;
1967
+        $errstr = null;
1968
+            $this->runtime['fileSocket'] = @fsockopen($this->runtime['host'], $data['data']['port'], $errnum, $errstr, $this->runtime['timeout']);
1969
+            if($this->runtime['fileSocket']) {
1970
+                $this->ftSendKey($data['data']['ftkey']);
1971
+                $content = $this->ftRead($data['data']['size']);
1972
+                @fclose($this->runtime['fileSocket']);
1973
+                $this->runtime['fileSocket'] = '';
1974
+                return $content;
1975
+            }else{
1976
+                $this->addDebugLog('fileSocket returns '.$errnum. ' | '.$errstr);
1977
+                return $this->generateOutput(false, array('Error in fileSocket: '.$errnum. ' | '.$errstr), false);
1978
+            }
1979
+    }
1980
+	
1981
+/**
1982
+ * ftGetFileInfo
1983
+ * 
1984
+ * Displays detailed information about one or more specified files stored in a channels file repository.
1985
+ * 
1986
+ *
1987
+ * @author     Par0noid Solutions
1988
+ * @param		string	$cid	channelID
1989
+ * @param		string	$cpw	channelPassword (leave blank if not needed)
1990
+ * @param		string 	$file	path to file
1991
+ * @return     boolean success
1992
+ */
1993
+    function ftGetFileInfo($cid, $cpw = '', $file) {
1994
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
1995
+
1996
+        return $this->getData('multi', 'ftgetfileinfo cid='.$cid.' cpw='.$this->escapeText($cpw).' name='.$this->escapeText($file));
1997
+    }
1998
+
1999
+/**
2000
+ * ftGetFileList
2001
+ *
2002
+ * Displays a list of files and directories stored in the specified channels file repository.
2003
+ *
2004
+ * <b>Output:</b>
2005
+ * <pre>
2006
+ * Array
2007
+ * {
2008
+ *  [cid] => 231
2009
+ *  [path] => /
2010
+ *  [name] => Documents
2011
+ *  [size] => 0
2012
+ *  [datetime] => 1286633633
2013
+ *  [type] => 0
2014
+ * }
2015
+ * </pre>
2016
+ *
2017
+ * @author     Par0noid Solutions
2018
+ * @param		string	$cid	channelID
2019
+ * @param		string	$cpw	channelPassword (leave blank if not needed)
2020
+ * @param		string	$path	filePath
2021
+ * @return     array	fileList
2022
+ */
2023
+    function ftGetFileList($cid, $cpw = '', $path) {
2024
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
2025
+        return $this->getData('multi', 'ftgetfilelist cid='.$cid.' cpw='.$this->escapeText($cpw).' path='.$this->escapeText($path));
2026
+    }
2027
+	
2028
+/**
2029
+ * ftInitDownload
2030
+ * 
2031
+ * 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.
2032
+ *
2033
+ * <b>Output:</b>
2034
+ * <pre>
2035
+ * Array
2036
+ * {
2037
+ *  [clientftfid] => 89
2038
+ *  [serverftfid] => 3
2039
+ *  [ftkey] => jSzWiRmFGdZnoJzW7BSDYJRUWB2WAUhb
2040
+ *  [port] => 30033
2041
+ *  [size] => 94
2042
+ * }
2043
+ * </pre>
2044
+ *
2045
+ * @author     Par0noid Solutions
2046
+ * @param		string	$name			filePath
2047
+ * @param		string	$cid			channelID
2048
+ * @param		string	$cpw			channelPassword (leave blank if not needed)
2049
+ * @param		integer	$seekpos		seekpos (default = 0) [optional]
2050
+ * @return     array	initDownloadFileInfo
2051
+ */	
2052
+    function ftInitDownload($name, $cid, $cpw = '', $seekpos = 0) {
2053
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
2054
+        return $this->getData('array', 'ftinitdownload clientftfid='.rand(1,99).' name='.$this->escapeText($name).' cid='.$cid.' cpw='.$this->escapeText($cpw).' seekpos='.$seekpos);
2055
+    }
2056
+
2057
+/**
2058
+ * ftInitUpload
2059
+ * 
2060
+ * 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.
2061
+ *
2062
+ * <b>Output:</b>
2063
+ * <pre>
2064
+ * Array
2065
+ * {
2066
+ *  [clientftfid] => 84
2067
+ *  [serverftfid] => 41
2068
+ *  [ftkey] => HCnXpunOdAorqj3dGqfiuLszX18O0PHP
2069
+ *  [port] => 30033
2070
+ *  [seekpos] => 0
2071
+ * }
2072
+ * </pre>
2073
+ *
2074
+ * @author     Par0noid Solutions
2075
+ * @param		string	$filename	filePath
2076
+ * @param		string	$cid		channelID
2077
+ * @param		integer	$size		fileSize in bytes
2078
+ * @param		string	$cpw		channelPassword (leave blank if not needed)
2079
+ * @param		boolean	$overwrite	overwrite	[optional] (default = 0)
2080
+ * @param		boolean	$resume		resume		[optional] (default = 0)
2081
+ * @return     array	initUploadFileInfo
2082
+ */	
2083
+    function ftInitUpload($filename, $cid, $size, $cpw = '', $overwrite = false, $resume = false) {
2084
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
2085
+		
2086
+        if($overwrite) { $overwrite = ' overwrite=1'; }else{ $overwrite = ' overwrite=0'; }
2087
+        if($resume) { $resume = ' resume=1'; }else{ $resume = ' resume=0'; }
2088
+		
2089
+        return $this->getData('array', 'ftinitupload clientftfid='.rand(1,99).' name='.$this->escapeText($filename).' cid='.$cid.' cpw='.$this->escapeText($cpw).' size='.($size + 1).$overwrite.$resume);
2090
+    }
2091
+	
2092
+/**
2093
+ * ftList
2094
+ * 
2095
+ * 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
2096
+ *
2097
+ * <b>Output:</b>
2098
+ * <pre>
2099
+ * Array
2100
+ * {
2101
+ *  [clid] => 1
2102
+ *  [cldbid] => 2019
2103
+ *  [path] => files/virtualserver_11/channel_231
2104
+ *  [name] => 1285412348878.png
2105
+ *  [size] => 1161281
2106
+ *  [sizedone] => 275888
2107
+ *  [clientftfid] => 15
2108
+ *  [serverftfid] => 52
2109
+ *  [sender] => 0
2110
+ *  [status] => 1
2111
+ *  [current_speed] => 101037.4453
2112
+ *  [average_speed] => 101037.4453
2113
+ *  [runtime] => 2163
2114
+ * }
2115
+ * </pre>
2116
+ *
2117
+ * @author     Par0noid Solutions
2118
+ * @return     array	fileTransferList
2119
+ */
2120
+    function ftList() {
2121
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
2122
+        return $this->getData('multi', 'ftlist');
2123
+    }
2124
+
2125
+/**
2126
+ * ftRenameFile
2127
+ * 
2128
+ * 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.
2129
+ *
2130
+ * @author     Par0noid Solutions
2131
+ * @param		integer	$cid		channelID
2132
+ * @param		string	$cpw		channelPassword (leave blank if not needed)
2133
+ * @param		string	$oldname	oldFilePath
2134
+ * @param		string	$newname	newFilePath
2135
+ * @param		string  $tcid		targetChannelID [optional]
2136
+ * @param		string  $tcpw		targetChannelPassword [optional]
2137
+ * @return     boolean success
2138
+ */
2139
+    function ftRenameFile($cid, $cpw = null, $oldname, $newname, $tcid = null,  $tcpw = null) {
2140
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
2141
+        $newTarget = ($tcid != null ? ' tcid='.$tcid.' '.$tcpw : '');
2142
+        return $this->getData('boolean', 'ftrenamefile cid='.$cid.' cpw='.$cpw.' oldname='.$this->escapeText($oldname).' newname='.$this->escapeText($newname).$newTarget);
2143
+    }
2144
+
2145
+/**
2146
+ * ftStop
2147
+ * 
2148
+ * Stops the running file transfer with server-side ID serverftfid.
2149
+ *
2150
+ * @author     Par0noid Solutions
2151
+ * @param		integer	$serverftfid	serverFileTransferID
2152
+ * @param		boolean	$delete			delete incomplete file [optional] (default: true) 
2153
+ * @return     boolean success
2154
+ */
2155
+    function ftStop($serverftfid, $delete = true) {
2156
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }		
2157
+        return $this->getData('boolean', 'ftstop serverftfid='.$serverftfid.' delete='.($delete ? '1' : '0'));
2158
+    }
2159
+
2160
+/**
2161
+ * ftUploadFile
2162
+ * 
2163
+ * Uploads a file to server
2164
+ * To check if upload was successful, you have to search for this file in fileList after
2165
+ *
2166
+ * @author     Par0noid Solutions
2167
+ * @param		array	$data			return of ftInitUpload
2168
+ * @param		string	$uploadData		data which should be uploaded
2169
+ * @return     array response
2170
+ */
2171
+    function ftUploadFile($data, $uploadData) {
2172
+            $this->runtime['fileSocket'] = @fsockopen($this->runtime['host'], $data['data']['port'], $errnum, $errstr, $this->runtime['timeout']);
2173
+            if($this->runtime['fileSocket']) {
2174
+                $this->ftSendKey($data['data']['ftkey'], "\n");
2175
+                $this->ftSendData($uploadData);
2176
+                @fclose($this->runtime['fileSocket']);
2177
+                $this->runtime['fileSocket'] = '';
2178
+                return $this->generateOutput(true, array(), true);
2179
+            }else{
2180
+                $this->addDebugLog('fileSocket returns '.$errnum. ' | '.$errstr);
2181
+                return $this->generateOutput(false, array('Error in fileSocket: '.$errnum. ' | '.$errstr), false);
2182
+            }
2183
+    }
2184
+
2185
+/**
2186
+ * gm
2187
+ * 
2188
+ * Sends a text message to all clients on all virtual servers in the TeamSpeak 3 Server instance.
2189
+ *
2190
+ * @author     Par0noid Solutions
2191
+ * @param		string	$msg	message
2192
+ * @return     boolean success
2193
+ */
2194
+    function gm($msg) {
2195
+        if(empty($msg)) {
2196
+            $this->addDebugLog('empty message given');
2197
+            return $this->generateOutput(false, array('Error: empty message given'), false);
2198
+        }
2199
+        return $this->getData('boolean', 'gm msg='.$this->escapeText($msg));
2200
+    }
2201
+
2202
+/**
2203
+ * hostInfo
2204
+ * 
2205
+ * Displays detailed connection information about the server instance including uptime, number of virtual servers online, traffic information, etc.
2206
+ *
2207
+ * <b>Output:</b>
2208
+ * <pre>
2209
+ * Array
2210
+ * {
2211
+ *  [instance_uptime] => 19038
2212
+ *  [host_timestamp_utc] => 1361046825
2213
+ *  [virtualservers_running_total] => 1
2214
+ *  [virtualservers_total_maxclients] => 32
2215
+ *  [virtualservers_total_clients_online] => 1
2216
+ *  [virtualservers_total_channels_online] => 2
2217
+ *  [connection_filetransfer_bandwidth_sent] => 0
2218
+ *  [connection_filetransfer_bandwidth_received] => 0
2219
+ *  [connection_filetransfer_bytes_sent_total] => 0
2220
+ *  [connection_filetransfer_bytes_received_total] => 0
2221
+ *  [connection_packets_sent_total] => 24853
2222
+ *  [connection_bytes_sent_total] => 1096128
2223
+ *  [connection_packets_received_total] => 25404
2224
+ *  [connection_bytes_received_total] => 1153918
2225
+ *  [connection_bandwidth_sent_last_second_total] => 82
2226
+ *  [connection_bandwidth_sent_last_minute_total] => 81
2227
+ *  [connection_bandwidth_received_last_second_total] => 84
2228
+ *  [connection_bandwidth_received_last_minute_total] => 87
2229
+ * }
2230
+ * </pre>
2231
+ *
2232
+ * @author     Par0noid Solutions
2233
+ * @return     array hostInformation
2234
+ */
2235
+    function hostInfo() {
2236
+        return $this->getData('array', 'hostinfo');
2237
+    }
2238
+
2239
+/**
2240
+ * instanceEdit
2241
+ * 
2242
+ * Changes the server instance configuration using given properties.
2243
+ *
2244
+ * <b>Input-Array like this:</b>
2245
+ * <pre>
2246
+ * $data = array();
2247
+ *	
2248
+ * $data['setting'] = 'value';
2249
+ * $data['setting'] = 'value';
2250
+ * </pre>
2251
+ *
2252
+ * @author     Par0noid Solutions
2253
+ * @param		array	$data	instanceProperties
2254
+ * @return     boolean success
2255
+ */
2256
+    function instanceEdit($data) {
2257
+        if(count($data) > 0) {
2258
+            $settingsString = '';
2259
+			
2260
+            foreach($data as $key => $val) {
2261
+                $settingsString .= ' '.$key.'='.$this->escapeText($val);
2262
+            }
2263
+            return $this->getData('boolean', 'instanceedit '.$settingsString);
2264
+        }else{
2265
+            $this->addDebugLog('empty array entered');
2266
+            return $this->generateOutput(false, array('Error: You can \'t give an empty array'), false);
2267
+        }
2268
+    }
2269
+
2270
+/**
2271
+ * instanceInfo
2272
+ * 
2273
+ * Displays the server instance configuration including database revision number, the file transfer port, default group IDs, etc.
2274
+ *
2275
+ * <b>Output:</b>
2276
+ * <pre>
2277
+ * Array
2278
+ * {
2279
+ *  [serverinstance_database_version] => 20
2280
+ *  [serverinstance_filetransfer_port] => 30033
2281
+ *  [serverinstance_max_download_total_bandwidth] => 18446744073709551615
2282
+ *  [serverinstance_max_upload_total_bandwidth] => 18446744073709551615
2283
+ *  [serverinstance_guest_serverquery_group] => 1
2284
+ *  [serverinstance_serverquery_flood_commands] => 10
2285
+ *  [serverinstance_serverquery_flood_time] => 3
2286
+ *  [serverinstance_serverquery_ban_time] => 600
2287
+ *  [serverinstance_template_serveradmin_group] => 3
2288
+ *  [serverinstance_template_serverdefault_group] => 5
2289
+ *  [serverinstance_template_channeladmin_group] => 1
2290
+ *  [serverinstance_template_channeldefault_group] => 4
2291
+ *  [serverinstance_permissions_version] => 15
2292
+ * }
2293
+ * </pre>
2294
+ *
2295
+ * @author     Par0noid Solutions
2296
+ * @return     array instanceInformation
2297
+ */
2298
+    function instanceInfo() {
2299
+        return $this->getData('array', 'instanceinfo');
2300
+    }
2301
+
2302
+/**
2303
+ * logAdd
2304
+ * 
2305
+ * Writes a custom entry into the servers log. Depending on your permissions, you'll be able to add entries into the server instance log and/or your virtual servers log. The loglevel parameter specifies the type of the entry.
2306
+ *
2307
+ * @author     Par0noid Solutions
2308
+ * @param		integer	$logLevel	loglevel between 1 and 4
2309
+ * @param		string	$logMsg		logMessage
2310
+ * @return     boolean success
2311
+ */
2312
+    function logAdd($logLevel, $logMsg) {
2313
+        if($logLevel >=1 and $logLevel <= 4) { 
2314
+            if(!empty($logMsg)) {
2315
+                return $this->getData('boolean', 'logadd loglevel='.$logLevel.' logmsg='.$this->escapeText($logMsg));
2316
+            }else{
2317
+                $this->addDebugLog('logMessage empty!');
2318
+                return $this->generateOutput(false, array('Error: logMessage empty!'), false);
2319
+            }
2320
+        }else{
2321
+            $this->addDebugLog('invalid logLevel!');
2322
+            return $this->generateOutput(false, array('Error: invalid logLevel!'), false);
2323
+        }
2324
+    }
2325
+
2326
+/**
2327
+ * login
2328
+ * 
2329
+ * Authenticates with the TeamSpeak 3 Server instance using given ServerQuery login credentials.
2330
+ *
2331
+ * @author     Par0noid Solutions
2332
+ * @param		string	$username	username
2333
+ * @param		string	$password	password
2334
+ * @return     boolean success
2335
+ */
2336
+    function login($username, $password) {
2337
+        return $this->getData('boolean', 'login '.$this->escapeText($username).' '.$this->escapeText($password));
2338
+    }
2339
+
2340
+/**
2341
+ * logout
2342
+ * 
2343
+ * Deselects the active virtual server and logs out from the server instance.
2344
+ *
2345
+ * @author     Par0noid Solutions
2346
+ * @return     boolean success
2347
+ */
2348
+    function logout() {
2349
+        $this->runtime['selected'] = false;
2350
+        return $this->getData('boolean', 'logout');
2351
+    }
2352
+
2353
+/**
2354
+ * logView
2355
+ * 
2356
+ * Displays a specified number of entries from the servers log. If instance is set to 1, the server will return lines from the master logfile (ts3server_0.log) instead of the selected virtual server logfile.
2357
+ * 
2358
+ * <b>Output:</b>
2359
+ * <pre>
2360
+ * Array
2361
+ * {
2362
+ *  [last_pos] => 0
2363
+ *  [file_size] => 1085
2364
+ *  [l] => 2012-01-10 20:34:31.379260|INFO    |ServerLibPriv |   | TeamSpeak 3 Server 3.0.1 (2011-11-17 07:34:30)
2365
+ * }
2366
+ * {
2367
+ *  [l] => 2012-01-10 20:34:31.380260|INFO    |DatabaseQuery |   | dbPlugin name:    SQLite3 plugin, Version 2, (c)TeamSpeak Systems GmbH
2368
+ * }
2369
+ * {
2370
+ *  [l] => 2012-01-10 20:34:31.380260|INFO    |DatabaseQuery |   | dbPlugin version: 3.7.3
2371
+ * }
2372
+ * </pre>
2373
+ *
2374
+ * @author     Par0noid Solutions
2375
+ * @param		integer	$lines	between 1 and 100
2376
+ * @param		integer	$reverse	{1|0} [optional]
2377
+ * @param		integer	$instance	{1|0} [optional]
2378
+ * @param		integer	$begin_pos	{1|0} [optional]
2379
+ * @return     multidimensional-array logEntries
2380
+ */
2381
+    function logView($lines, $reverse = 0, $instance = 0, $begin_pos = 0) {		
2382
+        if($lines >=1 and $lines <=100) {
2383
+            return $this->getData('multi', 'logview lines='.$lines.' reverse='.($reverse == 0 ? '0' : '1').' instance='.($instance == 0 ? '0' : '1').' begin_pos='.($begin_pos == 0 ? '0' : $begin_pos));
2384
+        }else{
2385
+            $this->addDebugLog('please choose a limit between 1 and 100');
2386
+            $this->generateOutput(false, array('Error: please choose a limit between 1 and 100'), false);
2387
+        }
2388
+    }
2389
+
2390
+/**
2391
+ * messageAdd
2392
+ * 
2393
+ * Sends an offline message to the client specified by cluid.
2394
+ *
2395
+ * @author     Par0noid Solutions
2396
+ * @param		string	$cluid		clientUID
2397
+ * @param		string	$subject	Subject of the message
2398
+ * @param		string	$message	Text of the message
2399
+ * @return     boolean success
2400
+ */
2401
+    function messageAdd($cluid, $subject, $message) {		
2402
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
2403
+        return $this->getData('boolean', 'messageadd cluid='.$cluid.' subject='.$this->escapeText($subject).' message='.$this->escapeText($message)); 
2404
+    }
2405
+
2406
+/**
2407
+ * messageDelete
2408
+ * 
2409
+ * Deletes an existing offline message with ID msgid from your inbox.
2410
+ *
2411
+ * @author     Par0noid Solutions
2412
+ * @param		string	$messageID		messageID
2413
+ * @return     boolean success
2414
+ */
2415
+    function messageDelete($messageID) {		
2416
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
2417
+        return $this->getData('boolean', 'messagedel msgid='.$messageID); 
2418
+    }
2419
+
2420
+/**
2421
+ * messageGet
2422
+ * 
2423
+ * Displays an existing offline message with ID msgid from your inbox. Please note that this does not automatically set the flag_read property of the message.
2424
+ *
2425
+ * @author     Par0noid Solutions
2426
+ * @param		string	$messageID		messageID
2427
+ * @return     array messageInformation
2428
+ */
2429
+    function messageGet($messageID) {		
2431 2430
         if(!$this->runtime['selected']) { return $this->checkSelected(); }
2432 2431
         return $this->getData('array', 'messageget msgid='.$messageID); 
2433
-	}
2432
+    }
2433
+
2434
+/**
2435
+ * messageList
2436
+ * 
2437
+ * Displays a list of offline messages you've received. The output contains the senders unique identifier, the messages subject, etc.
2438
+ *
2439
+ * @author     Par0noid Solutions
2440
+ * @return     array messageInformation
2441
+ */
2442
+    function messageList() {		
2443
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
2444
+        return $this->getData('array', 'messagelist'); 
2445
+    }
2446
+
2447
+/**
2448
+ * messageUpdateFlag
2449
+ * 
2450
+ * Updates the flag_read property of the offline message specified with msgid. If flag is set to 1, the message will be marked as read.
2451
+ *
2452
+ * @author     Par0noid Solutions
2453
+ * @param		string	$messageID		messageID
2454
+ * @param		integer	$flag			flag {1|0}
2455
+ * @return     array messageInformation
2456
+ */
2457
+    function messageUpdateFlag($messageID, $flag = 1) {		
2458
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
2459
+        return $this->getData('boolean', 'messageupdateflag msgid='.$messageID.' flag='.$flag); 
2460
+    }
2461
+
2462
+/**
2463
+ * permFind
2464
+ * 
2465
+ * Displays detailed information about all assignments of the permission specified with permid. The output is similar to permoverview which includes the type and the ID of the client, channel or group associated with the permission. A permission can be specified by permid or permsid.
2466
+ *
2467
+ * <b>Output:</b>
2468
+ * <pre>
2469
+ * Array
2470
+ * {
2471
+ *  [token] => eKnFZQ9EK7G7MhtuQB6+N2B1PNZZ6OZL3ycDp2OW
2472
+ * }
2473
+ * </pre>
2474
+ *
2475
+ * @author     Par0noid Solutions
2476
+ * @param		mixed	$perm	permid or permsid
2477
+ * @return     array permissionInfoList
2478
+ */
2479
+    function permFind($perm) { 
2480
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
2481
+        return $this->getData('multi', 'permfind '.(is_int($perm) || ctype_digit($perm) ? 'permid=' : 'permsid=').$perm); 
2482
+    }
2483
+	
2484
+	
2485
+/**
2486
+ * permGet
2487
+ * 
2488
+ * Displays the current value of the permission specified with permid or permsid for your own connection. This can be useful when you need to check your own privileges.
2489
+ *
2490
+ * The perm parameter can be used as permid or permsid, it will switch the mode automatically.
2491
+ *
2492
+ * <b>Output:</b>
2493
+ * <pre>
2494
+ * Array
2495
+ * {
2496
+ *		[permsid] => i_channel_create_modify_with_codec_maxquality
2497
+ *     [permid] => 96
2498
+ *     [permvalue] => 10	
2499
+ * }
2500
+ * </pre>
2501
+ *
2502
+ * @author     Par0noid Solutions
2503
+ * @param		mixed	$perm	permid or permsid
2504
+ * @return     array permissionInfo
2505
+ */
2506
+    function permGet($perm) { 
2507
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
2508
+        return $this->getData('array', 'permget '.(is_int($perm) || ctype_digit($perm) ? 'permid=' : 'permsid=').$perm); 
2509
+    }	
2510
+	
2511
+/**
2512
+ * permIdGetByName
2513
+ * 
2514
+ * Displays the database ID of one or more permissions specified by permsid.
2515
+ *
2516
+ * <b>Input-Array like this:</b>
2517
+ * <pre>
2518
+ * $permissions = array();
2519
+ * $permissions[] = 'permissionName';
2520
+ * </pre>
2521
+ * <b>Output:</b>
2522
+ * <pre>
2523
+ * Array
2524
+ * {
2525
+ *  [permsid] => b_serverinstance_help_view
2526
+ *  [permid] => 4353
2527
+ * }
2528
+ * </pre>
2529
+ *
2530
+ * @author     Par0noid Solutions
2531
+ * @param		string	$permsids		permNames
2532
+ * @return     array	permissionList 
2533
+ */
2534
+    function permIdGetByName($permsids) {
2535
+        $permissionArray = array();
2536
+		
2537
+        if(count($permsids) > 0) {
2538
+            foreach($permsids AS $value) {
2539
+                $permissionArray[] = 'permsid='.$value;
2540
+            }
2541
+            return $this->getData('multi', 'permidgetbyname '.$this->escapeText(implode('|', $permissionArray)));
2542
+        }else{
2543
+            $this->addDebugLog('no permissions given');
2544
+            return $this->generateOutput(false, array('Error: no permissions given'), false);
2545
+        }
2546
+		
2547
+    }
2548
+
2549
+
2550
+/**
2551
+ * permissionList
2552
+ * 
2553
+ * Displays a list of permissions available on the server instance including ID, name and description.
2554
+ * If the new parameter is set the permissionlist will return with the new output format.
2555
+ *
2556
+ * <b>Output: (with new parameter)</b>
2557
+ * <pre>
2558
+ * [0] => Array
2559
+ *     (
2560
+ *         [num] => 1
2561
+ *         [group_id_end] => 0
2562
+ *         [pcount] => 0
2563
+ *     )
2564
+ *
2565
+ * [1] => Array
2566
+ *     (
2567
+ *         [num] => 2
2568
+ *         [group_id_end] => 7
2569
+ *         [pcount] => 7
2570
+ *         [permissions] => Array
2571
+ *             (
2572
+ *                 [0] => Array
2573
+ *                     (
2574
+ *                         [permid] => 1
2575
+ *                         [permname] => b_serverinstance_help_view
2576
+ *                         [permdesc] => Retrieve information about ServerQuery commands
2577
+ *                         [grantpermid] => 32769
2578
+ *                     )
2579
+ *
2580
+ *                 [1] => Array
2581
+ *                     (
2582
+ *                         [permid] => 2
2583
+ *                         [permname] => b_serverinstance_version_view
2584
+ *                         [permdesc] => Retrieve global server version (including platform and build number)
2585
+ *                         [grantpermid] => 32770
2586
+ *                     )
2587
+ *
2588
+ *                 [2] => Array
2589
+ *                     (
2590
+ *                         [permid] => 3
2591
+ *                         [permname] => b_serverinstance_info_view
2592
+ *                         [permdesc] => Retrieve global server information
2593
+ *                         [grantpermid] => 32771
2594
+ *                     )
2595
+ *
2596
+ *                 [3] => Array
2597
+ *                     (
2598
+ *                         [permid] => 4
2599
+ *                         [permname] => b_serverinstance_virtualserver_list
2600
+ *                         [permdesc] => List virtual servers stored in the database
2601
+ *                         [grantpermid] => 32772
2602
+ *                     )
2603
+ *
2604
+ *                 [4] => Array
2605
+ *                     (
2606
+ *                         [permid] => 5
2607
+ *                         [permname] => b_serverinstance_binding_list
2608
+ *                         [permdesc] => List active IP bindings on multi-homed machines
2609
+ *                         [grantpermid] => 32773
2610
+ *                     )
2611
+ *
2612
+ *                [5] => Array
2613
+ *                     (
2614
+ *                         [permid] => 6
2615
+ *                         [permname] => b_serverinstance_permission_list
2616
+ *                         [permdesc] => List permissions available available on the server instance
2617
+ *                         [grantpermid] => 32774
2618
+ *                     )
2619
+ *
2620
+ *                 [6] => Array
2621
+ *                     (
2622
+ *                         [permid] => 7
2623
+ *                         [permname] => b_serverinstance_permission_find
2624
+ *                         [permdesc] => Search permission assignments by name or ID
2625
+ *                         [grantpermid] => 32775
2626
+ *                     )
2627
+ *
2628
+ *             )
2629
+ *
2630
+ *     )
2631
+ * </pre>
2632
+ *
2633
+ * @author     Par0noid Solutions
2634
+ * @param		boolean		$new		[optional] add new parameter
2635
+ * @return     array permissionList
2636
+ */
2637
+    function permissionList($new = false) {
2638
+        if($new === true) {
2639
+            $groups = array();
2640
+            $permissions = array();
2641
+			
2642
+            $response = $this->getElement('data', $this->getData('multi', 'permissionlist -new'));
2643
+			
2644
+            $gc = 1;
2645
+			
2646
+            foreach($response as $field) {
2647
+                if(isset($field['group_id_end'])) {
2648
+                    $groups[] = array('num' => $gc, 'group_id_end' => $field['group_id_end']);
2649
+                    $gc++;
2650
+                }else{
2651
+                    $permissions[] = $field;
2652
+                }
2653
+            }
2654
+			
2655
+            $counter = 0;
2656
+			
2657
+            for($i = 0; $i < count($groups); $i++) {
2658
+                $rounds = $groups[$i]['group_id_end'] - $counter;
2659
+                $groups[$i]['pcount'] = $rounds;
2660
+                for($j = 0; $j < $rounds; $j++) {
2661
+                    $groups[$i]['permissions'][] = array('permid' => ($counter + 1), 'permname' => $permissions[$counter]['permname'], 'permdesc' => $permissions[$counter]['permdesc'], 'grantpermid' => ($counter + 32769));
2662
+                    $counter++;
2663
+                }
2664
+            }
2665
+			
2666
+            return $groups;
2667
+			
2668
+        }else{
2669
+            return $this->getData('multi', 'permissionlist');
2670
+        }
2671
+    }
2672
+
2673
+/**
2674
+ * permOverview
2675
+ * 
2676
+ * Displays all permissions assigned to a client for the channel specified with cid. If permid is set to 0, all permissions will be displayed. A permission can be specified by permid or permsid.
2677
+ *
2678
+ * If you set the permsid parameter, the permid parameter will be ignored.
2679
+ *
2680
+ * <b>Output:</b>
2681
+ * <pre>
2682
+ * Array
2683
+ * {
2684
+ *  [t] => 0
2685
+ *  [id1] => 2
2686
+ *  [id2] => 0
2687
+ *  [p] => 16777
2688
+ *  [v] => 1
2689
+ *  [n] => 0
2690
+ *  [s] => 0
2691
+ * }
2692
+ * </pre>
2693
+ *
2694
+ * @author     Par0noid Solutions
2695
+ * @param		integer		$cid		cchannelId
2696
+ * @param		integer 	$cldbid		clientDbId
2697
+ * @param		integer 	$permid		permId (Default: 0)
2698
+ * @param		string	 	$permsid	permName
2699
+ * @return     array permOverview
2700
+ */
2701
+    function permOverview($cid, $cldbid, $permid='0', $permsid=false ) { 
2702
+        if(!$this->runtime['selected']) { return $this->checkSelected(); } 
2703
+        if($permsid) { $additional = ' permsid='.$permsid; }else{ $additional = ''; } 
2704
+         
2705
+        return $this->getData('multi', 'permoverview cid='.$cid.' cldbid='.$cldbid.($permsid == false ? ' permid='.$permid : '').$additional); 
2706
+    }
2707
+
2708
+/**
2709
+ * permReset
2710
+ * 
2711
+ * Restores the default permission settings on the selected virtual server and creates a new initial administrator token. Please note that in case of an error during the permreset call - e.g. when the database has been modified or corrupted - the virtual server will be deleted from the database.
2712
+ *
2713
+ * <b>Output:</b>
2714
+ * <pre>
2715
+ * Array
2716
+ * {
2717
+ *  [token] => eKnFZQ9EK7G7MhtuQB6+N2B1PNZZ6OZL3ycDp2OW
2718
+ * }
2719
+ * </pre>
2720
+ *
2721
+ * @author     Par0noid Solutions
2722
+ * @return     array token
2723
+ */
2724
+    function permReset() { 
2725
+        if(!$this->runtime['selected']) { return $this->checkSelected(); } 
2726
+        return $this->getData('array', 'permreset'); 
2727
+    }
2728
+	
2729
+/**
2730
+ * privilegekeyAdd
2731
+ * 
2732
+ * Create a new token. If tokentype is set to 0, the ID specified with tokenid1 will be a server group ID. Otherwise, tokenid1 is used as a channel group ID and you need to provide a valid channel ID using tokenid2. The tokencustomset parameter allows you to specify a set of custom client properties. This feature can be used when generating tokens to combine a website account database with a TeamSpeak user. The syntax of the value needs to be escaped using the ServerQuery escape patterns and has to follow the general syntax of:
2733
+ * ident=ident1 value=value1|ident=ident2 value=value2|ident=ident3 value=value3
2734
+ *
2735
+ * <b>Input-Array like this:</b>
2736
+ * <pre>
2737
+ * $customFieldSet = array();
2738
+ *	
2739
+ * $customFieldSet['ident'] = 'value';
2740
+ * $customFieldSet['ident'] = 'value';
2741
+ * </pre>
2742
+ *
2743
+ * @author     Par0noid Solutions
2744
+ * @param		integer	$tokentype				token type
2745
+ * @param		integer	$tokenid1				groupID
2746
+ * @param		integer	$tokenid2				channelID
2747
+ * @param		string	$description			token description [optional]
2748
+ * @param		array	$customFieldSet			customFieldSet [optional]
2749
+ * @return     array	tokenInformation
2750
+ */
2751
+    function privilegekeyAdd($tokentype, $tokenid1, $tokenid2, $description ='', $customFieldSet = array()) {
2752
+        return $this->tokenAdd($tokentype, $tokenid1, $tokenid2, $description, $customFieldSet);
2753
+    }
2754
+
2755
+/**
2756
+ * privilegekeyDelete
2757
+ * 
2758
+ * Deletes an existing token matching the token key specified with token.
2759
+ *
2760
+ * @author     Par0noid Solutions
2761
+ * @param		string	$token	token
2762
+ * @return     boolean success
2763
+ */
2764
+    function privilegekeyDelete($token) {
2765
+        return $this->tokenDelete($token);
2766
+    }
2767
+
2768
+/**
2769
+ * privilegekeyList
2770
+ * 
2771
+ * Displays a list of privilege keys available including their type and group IDs. Tokens can be used to gain access to specified server or channel groups. A privilege key is similar to a client with administrator privileges that adds you to a certain permission group, but without the necessity of a such a client with administrator privileges to actually exist. It is a long (random looking) string that can be used as a ticket into a specific server group.
2772
+ *
2773
+ * <b>Output:</b>
2774
+ * <pre>
2775
+ * Array
2776
+ * {
2777
+ *  [token] => GdqedxSEDle3e9+LtR3o9dO09bURH+vymvF5hOJg
2778
+ *  [token_type] => 0
2779
+ *  [token_id1] => 71
2780
+ *  [token_id2] => 0
2781
+ *  [token_created] => 1286625908
2782
+ *  [token_description] => for you
2783
+ * }
2784
+ * </pre>
2785
+ *
2786
+ * @author     Par0noid Solutions
2787
+ * @return     array tokenListist 
2788
+ */
2789
+    function privilegekeyList() {
2790
+        return $this->tokenList();
2791
+    }
2792
+
2793
+/**
2794
+ * privilegekeyUse
2795
+ * 
2796
+ * Use a token key gain access to a server or channel group. Please note that the server will automatically delete the token after it has been used.
2797
+ *
2798
+ * @author     Par0noid Solutions
2799
+ * @param		string	$token	token
2800
+ * @return     boolean success
2801
+ */
2802
+    function privilegekeyUse($token) {		
2803
+        return $this->tokenUse($token);
2804
+    }
2805
+ 
2806
+/**
2807
+ * quit closes the connection to host 
2808
+ *
2809
+ * @author     Par0noid Solutions
2810
+ * @return 	none
2811
+ */
2812
+    private function quit() {
2813
+        $this->logout();
2814
+        @fputs($this->runtime['socket'], "quit\n");
2815
+        @fclose($this->runtime['socket']);
2816
+    }
2817
+
2818
+/**
2819
+ * selectServer
2820
+ * 
2821
+ * Selects the virtual server specified with sid or port to allow further interaction. The ServerQuery client will appear on the virtual server and acts like a real TeamSpeak 3 Client, except it's unable to send or receive voice data. If your database contains multiple virtual servers using the same UDP port, use will select a random virtual server using the specified port.
2822
+ *
2823
+ * @author     Par0noid Solutions
2824
+ * @param		integer	$value		Port or ID
2825
+ * @param		string	$type		value type ('port', 'serverId') (default='port')
2826
+ * @param		boolean	$virtual	set true to add -virtual param [optional]
2827
+ * @return     boolean success
2828
+ */
2829
+    function selectServer($value, $type = 'port', $virtual = false) { 
2830
+        if(in_array($type, array('port', 'serverId'))) { 
2831
+            if($type == 'port') { 
2832
+                if($virtual) { $virtual = ' -virtual'; }else{ $virtual = ''; } 
2833
+                $res = $this->getData('boolean', 'use port='.$value.$virtual); 
2834
+                if($res['success']) { 
2835
+                    $this->runtime['selected'] = true; 
2836
+                } 
2837
+                return $res; 
2838
+            }else{ 
2839
+                if($virtual) { $virtual = ' -virtual'; }else{ $virtual = ''; } 
2840
+                $res = $this->getData('boolean', 'use sid='.$value.$virtual); 
2841
+                if($res['success']) { 
2842
+                    $this->runtime['selected'] = true; 
2843
+                } 
2844
+                return $res; 
2845
+            } 
2846
+        }else{ 
2847
+            $this->addDebugLog('wrong value type'); 
2848
+            return $this->generateOutput(false, array('Error: wrong value type'), false); 
2849
+        } 
2850
+    }
2851
+
2852
+/**
2853
+ * sendMessage
2854
+ * 
2855
+ * Sends a text message a specified target. The type of the target is determined by targetmode while target specifies the ID of the recipient, whether it be a virtual server, a channel or a client.
2856
+ * <b>Hint:</b> You can just write to the channel the query client is in. See link in description for details.
2857
+ *
2858
+ * <b>Modes:</b>
2859
+ * <ul>
2860
+ * 	<li><b>1:</b> send to client</li>
2861
+ * 	<li><b>2:</b> send to channel</li>
2862
+ * 	<li><b>3:</b> send to server</li>
2863
+ * </ul>
2864
+ * <b>Targets:</b>
2865
+ * <ul>
2866
+ * 	<li>clientID</li>
2867
+ * 	<li>channelID</li>
2868
+ * 	<li>serverID</li>
2869
+ * </ul>
2870
+ *
2871
+ * @author     Par0noid Solutions
2872
+ * @param		integer $mode
2873
+ * @param		integer $target
2874
+ * @param		string	$msg	Message
2875
+ * @see		http://forum.teamspeak.com/showthread.php/84280-Sendtextmessage-by-query-client http://forum.teamspeak.com/showthread.php/84280-Sendtextmessage-by-query-client
2876
+ * @return     boolean	success
2877
+ */
2878
+    function sendMessage($mode, $target, $msg) {
2879
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
2880
+        return $this->getData('boolean', 'sendtextmessage targetmode='.$mode.' target='.$target.' msg='.$this->escapeText($msg));
2881
+    }
2882
+
2883
+/**
2884
+ * serverCreate
2885
+ * 
2886
+ * Creates a new virtual server using the given properties and displays its ID, port and initial administrator privilege key. If virtualserver_port is not specified, the server will test for the first unused UDP port. The first virtual server will be running on UDP port 9987 by default. Subsequently started virtual servers will be running on increasing UDP port numbers.
2887
+ * 
2888
+ * <b>Input-Array like this:</b>
2889
+ * <pre>
2890
+ * $data = array();
2891
+ *	
2892
+ * $data['setting'] = 'value';
2893
+ * $data['setting'] = 'value';
2894
+ * </pre>
2895
+ *
2896
+ * <b>Output:</b>
2897
+ * <pre>
2898
+ * Array
2899
+ * {
2900
+ *  [sid] => 2
2901
+ *  [virtualserver_port] => 9988
2902
+ *  [token] => eKnFZQ9EK7G7MhtuQB6+N2B1PNZZ6OZL3ycDp2OW
2903
+ * }
2904
+ * </pre>
2905
+ *
2906
+ * @author     Par0noid Solutions
2907
+ * @param		array	$data	serverSettings	[optional]
2908
+ * @return     array serverInfo
2909
+ */
2910
+    function serverCreate($data = array()) {
2911
+        $settingsString = '';
2912
+		
2913
+        if(count($data) == 0) {	$data['virtualserver_name'] = 'Teamspeak 3 Server'; }
2914
+		
2915
+		
2916
+        foreach($data as $key => $value) {
2917
+            if(!empty($value)) { $settingsString .= ' '.$key.'='.$this->escapeText($value); }
2918
+        }
2919
+		
2920
+        return $this->getData('array', 'servercreate'.$settingsString);
2921
+    }
2922
+
2923
+/**
2924
+ * serverDelete
2925
+ * 
2926
+ * Deletes the virtual server specified with sid. Please note that only virtual servers in stopped state can be deleted.
2927
+ *
2928
+ * @author     Par0noid Solutions
2929
+ * @param		integer	$sid	serverID
2930
+ * @return     boolean success
2931
+ */
2932
+    function serverDelete($sid) {
2933
+        $this->serverStop($sid);
2934
+        return $this->getdata('boolean', 'serverdelete sid='.$sid);
2935
+    }
2936
+
2937
+/**
2938
+ * serverEdit
2939
+ * 
2940
+ * Changes the selected virtual servers configuration using given properties. Note that this command accepts multiple properties which means that you're able to change all settings of the selected virtual server at once.
2941
+ *
2942
+ * <b>Input-Array like this:</b>
2943
+ * <pre>
2944
+ * $data = array();
2945
+ *	
2946
+ * $data['setting'] = 'value';
2947
+ * $data['setting'] = 'value';
2948
+ * </pre>
2949
+ *
2950
+ * @author     Par0noid Solutions
2951
+ * @param		array	$data	serverSettings
2952
+ * @return     boolean success
2953
+ */
2954
+    function serverEdit($data) {
2955
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
2956
+		
2957
+        $settingsString = '';
2958
+		
2959
+        foreach($data as $key => $value) {
2960
+            $settingsString .= ' '.$key.'='.$this->escapeText($value);
2961
+        }
2962
+		
2963
+        return $this->getData('boolean', 'serveredit'.$settingsString);
2964
+    }
2965
+
2966
+/**
2967
+ * serverGroupAdd
2968
+ * 
2969
+ * Creates a new server group using the name specified with name and displays its ID. The optional type parameter can be used to create ServerQuery groups and template groups. For detailed information, see
2970
+ *
2971
+ * <b>Output:</b>
2972
+ * <pre>
2973
+ * Array
2974
+ * {
2975
+ *  [sgid] => 86
2976
+ * }
2977
+ * </pre>
2978
+ *
2979
+ * @author     Par0noid Solutions
2980
+ * @param		integer $name	groupName
2981
+ * @param		integer	$type	groupDbType (0 = template, 1 = normal, 2 = query | Default: 1)
2982
+ * @return     array groupId
2983
+ */
2984
+    function serverGroupAdd($name, $type = 1) {
2985
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
2986
+        return $this->getData('array', 'servergroupadd name='.$this->escapeText($name).' type='.$type);
2987
+    }
2988
+
2989
+/**
2990
+ * serverGroupAddClient
2991
+ * 
2992
+ * Adds a client to the server group specified with sgid. Please note that a client cannot be added to default groups or template groups.
2993
+ *
2994
+ * @author     Par0noid Solutions
2995
+ * @param		integer $sgid	serverGroupId
2996
+ * @param		integer $cldbid	clientDBID
2997
+ * @return     boolean success
2998
+ */
2999
+    function serverGroupAddClient($sgid, $cldbid) {
3000
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
3001
+        return $this->getData('boolean', 'servergroupaddclient sgid='.$sgid.' cldbid='.$cldbid);
3002
+    }
3003
+
3004
+/**
3005
+ * serverGroupAddPerm
3006
+ * 
3007
+ * Adds a set of specified permissions to the server group specified with sgid. Multiple permissions can be added by providing the four parameters of each permission. A permission can be specified by permid or permsid.
3008
+ *
3009
+ * <b>Input-Array like this:</b>
3010
+ * <pre>
3011
+ * $permissions = array();
3012
+ * $permissions['permissionID'] = array('permissionValue', 'permskip', 'permnegated');
3013
+ * //or you could use
3014
+ * $permissions['permissionName'] = array('permissionValue', 'permskip', 'permnegated');
3015
+ * </pre>
3016
+ * 
3017
+ * @author     Par0noid Solutions
3018
+ * @param		integer $sgid	serverGroupID
3019
+ * @param		array	$permissions	permissions
3020
+ * @return     boolean success
3021
+ */
3022
+    function serverGroupAddPerm($sgid, $permissions) {
3023
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
3024
+		
3025
+        if(count($permissions) > 0) {
3026
+            //Permissions given
3027
+				
3028
+            //Errorcollector
3029
+            $errors = array();
3030
+				
3031
+            //Split Permissions to prevent query from overload
3032
+            $permissions = array_chunk($permissions, 50, true);
3033
+				
3034
+            //Action for each splitted part of permission
3035
+            foreach($permissions as $permission_part)
3036
+            {
3037
+                //Create command_string for each command that we could use implode later
3038
+                $command_string = array();
3039
+		
3040
+                foreach($permission_part as $key => $value)
3041
+                {
3042
+                    $command_string[] = (is_numeric($key) ? "permid=" : "permsid=").$this->escapeText($key).' permvalue='.$value[0].' permskip='.$value[1].' permnegated='.$value[2];
3043
+                }
3044
+		
3045
+                $result = $this->getData('boolean', 'servergroupaddperm sgid='.$sgid.' '.implode('|', $command_string));
3046
+		
3047
+                if(!$result['success'])
3048
+                {
3049
+                    foreach($result['errors'] as $error)
3050
+                    {
3051
+                        $errors[] = $error;
3052
+                    }
3053
+                }
3054
+            }
3055
+				
3056
+            if(count($errors) == 0)
3057
+            {
3058
+                return $this->generateOutput(true, array(), true);
3059
+            }else{
3060
+                return $this->generateOutput(false, $errors, false);
3061
+            }
3062
+				
3063
+        }else{
3064
+            // No permissions given
3065
+            $this->addDebugLog('no permissions given');
3066
+            return $this->generateOutput(false, array('Error: no permissions given'), false);
3067
+        }
3068
+    }
3069
+
3070
+/**
3071
+ * serverGroupAutoAddPerm
3072
+ * 
3073
+ * Adds a set of specified permissions to *ALL* regular server groups on all virtual servers. The target groups will be identified by the value of their i_group_auto_update_type permission specified with sgtype. Multiple permissions can be added at once. A permission can be specified by permid or permsid. The known values for sgtype are: 10: Channel Guest 15: Server Guest 20: Query Guest 25: Channel Voice 30: Server Normal 35: Channel Operator 40: Channel Admin 45: Server Admin 50: Query Admin
3074
+ *
3075
+ * <b>Input-Array like this:</b>
3076
+ * <pre>
3077
+ * $permissions = array();
3078
+ * $permissions['permissionID'] = array('permissionValue', 'permskip', 'permnegated');
3079
+ * //or you could use
3080
+ * $permissions['permissionName'] = array('permissionValue', 'permskip', 'permnegated');
3081
+ * </pre>
3082
+ * 
3083
+ * @author     Par0noid Solutions
3084
+ * @param		integer	$sgtype			serverGroupType
3085
+ * @param		array	$permissions	permissions
3086
+ * @return     boolean success
3087
+ */
3088
+    function serverGroupAutoAddPerm($sgtype, $permissions) {
3089
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
3090
+		
3091
+        if(count($permissions) > 0) {
3092
+            //Permissions given
3093
+				
3094
+            //Errorcollector
3095
+            $errors = array();
3096
+				
3097
+            //Split Permissions to prevent query from overload
3098
+            $permissions = array_chunk($permissions, 50, true);
3099
+				
3100
+            //Action for each splitted part of permission
3101
+            foreach($permissions as $permission_part)
3102
+            {
3103
+                //Create command_string for each command that we could use implode later
3104
+                $command_string = array();
3105
+		
3106
+                foreach($permission_part as $key => $value)
3107
+                {
3108
+                    $command_string[] = (is_numeric($key) ? "permid=" : "permsid=").$this->escapeText($key).' permvalue='.$value[0].' permskip='.$value[1].' permnegated='.$value[2];
3109
+                }
3110
+		
3111
+                $result = $this->getData('boolean', 'servergroupautoaddperm sgtype='.$sgtype.' '.implode('|', $command_string));
3112
+		
3113
+                if(!$result['success'])
3114
+                {
3115
+                    foreach($result['errors'] as $error)
3116
+                    {
3117
+                        $errors[] = $error;
3118
+                    }
3119
+                }
3120
+            }
3121
+				
3122
+            if(count($errors) == 0)
3123
+            {
3124
+                return $this->generateOutput(true, array(), true);
3125
+            }else{
3126
+                return $this->generateOutput(false, $errors, false);
3127
+            }
3128
+				
3129
+        }else{
3130
+            // No permissions given
3131
+            $this->addDebugLog('no permissions given');
3132
+            return $this->generateOutput(false, array('Error: no permissions given'), false);
3133
+        }
3134
+    }
3135
+
3136
+/**
3137
+ * serverGroupAutoDeletePerm
3138
+ * 
3139
+ * Removes a set of specified permissions from *ALL* regular server groups on all virtual servers. The target groups will be identified by the value of their i_group_auto_update_type permission specified with sgtype. Multiple permissions can be removed at once. A permission can be specified by permid or permsid. The known values for sgtype are: 10: Channel Guest 15: Server Guest 20: Query Guest 25: Channel Voice 30: Server Normal 35: Channel Operator 40: Channel Admin 45: Server Admin 50: Query Admin
3140
+ *
3141
+ * <b>Input-Array like this:</b>
3142
+ * <pre>
3143
+ * $permissions = array();
3144
+ * $permissions[] = 'permissionID';
3145
+ * //or you could use
3146
+ * $permissions[] = 'permissionName';
3147
+ * </pre>
3148
+ *
3149
+ * @author     Par0noid Solutions
3150
+ * @param		integer		$sgtype				serverGroupType
3151
+ * @param		array		$permissions		permissions
3152
+ * @return     boolean success
3153
+ */
3154
+    function serverGroupAutoDeletePerm($sgtype, $permissions) {
3155
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
3156
+        $permissionArray = array();
3157
+		
3158
+        if(count($permissions) > 0) {
3159
+            foreach($permissions AS $value) {
3160
+                $permissionArray[] = is_numeric($value) ? 'permid='.$value : 'permsid='.$this->escapeText($value);
3161
+            }
3162
+            return $this->getData('boolean', 'servergroupautodelperm sgtype='.$sgtype.' '.implode('|', $permissionArray));
3163
+        }else{
3164
+            $this->addDebugLog('no permissions given');
3165
+            return $this->generateOutput(false, array('Error: no permissions given'), false);
3166
+        }
3167
+    }
3168
+
3169
+/**
3170
+ * serverGroupClientList
3171
+ * 
3172
+ * Displays the IDs of all clients currently residing in the server group specified with sgid. If you're using the optional -names option, the output will also contain the last known nickname and the unique identifier of the clients.
3173
+ *
3174
+ * <b>Possible params:</b> -names
3175
+ *
3176
+ * <b>Output: (with -names param)</b>
3177
+ * <pre>
3178
+ * Array
3179
+ * {
3180
+ *  [cldbid] => 2017
3181
+ *  [client_nickname] => Par0noid //with -names parameter
3182
+ *  [client_unique_identifier] => nUixbsq/XakrrmbqU8O30R/D8Gc=
3183
+ * }
3184
+ * </pre>
3185
+ *
3186
+ * @author     Par0noid Solutions
3187
+ * @param		integer	$sgid		groupId
3188
+ * @param		boolean	$names		set true to add -names param [optional]
3189
+ * @return     multidimensional-array	serverGroupClientList
3190
+ */
3191
+    function serverGroupClientList($sgid, $names = false) {
3192
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
3193
+        if($names) { $names = ' -names'; }else{ $names = ''; }
3194
+        return $this->getData('multi', 'servergroupclientlist sgid='.$sgid.$names);
3195
+    }
3196
+
3197
+/**
3198
+ * serverGroupCopy
3199
+ * 
3200
+ * Creates a copy of the server group specified with ssgid. If tsgid is set to 0, the server will create a new group. To overwrite an existing group, simply set tsgid to the ID of a designated target group. If a target group is set, the name parameter will be ignored.
3201
+ *
3202
+ * <b>Output:</b>
3203
+ * <pre>
3204
+ * Array
3205
+ * {
3206
+ *  [sgid] => 86
3207
+ * }
3208
+ * </pre>
3209
+ *
3210
+ * @author     Par0noid Solutions
3211
+ * @param		integer	$ssgid	sourceGroupID
3212
+ * @param		integer	$tsgid	targetGroupID
3213
+ * @param		integer $name	groupName
3214
+ * @param		integer	$type	groupDbType (0 = template, 1 = normal, 2 = query | Default: 1)
3215
+ * @return     array groupId
3216
+ */
3217
+    function serverGroupCopy($ssgid, $tsgid, $name, $type = 1) {
3218
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
3219
+        return $this->getData('array', 'servergroupcopy ssgid='.$ssgid.' tsgid='.$tsgid.' name='.$this->escapeText($name).' type='.$type);
3220
+    }
3221
+
3222
+/**
3223
+ * serverGroupDelete
3224
+ * 
3225
+ * Deletes the server group specified with sgid. If force is set to 1, the server group will be deleted even if there are clients within.
3226
+ *
3227
+ * @author     Par0noid Solutions
3228
+ * @param		integer $sgid	serverGroupID
3229
+ * @param		integer $force 	forces deleting group (Default: 1)
3230
+ * @return     boolean success
3231
+ */
3232
+    function serverGroupDelete($sgid, $force = 1) {
3233
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
3234
+        return $this->getData('boolean', 'servergroupdel sgid='.$sgid.' force='.$force);
3235
+    }
3236
+
3237
+/**
3238
+ * serverGroupDeleteClient
3239
+ * 
3240
+ * Removes a client specified with cldbid from the server group specified with sgid.
3241
+ *
3242
+ * @author     Par0noid Solutions
3243
+ * @param		integer $sgid	groupID
3244
+ * @param		integer $cldbid	clientDBID
3245
+ * @return     boolean success
3246
+ */
3247
+    function serverGroupDeleteClient($sgid, $cldbid) {
3248
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
3249
+        return $this->getData('boolean', 'servergroupdelclient sgid='.$sgid.' cldbid='.$cldbid);
3250
+    }
3251
+
3252
+/**
3253
+ * serverGroupDeletePerm
3254
+ * 
3255
+ * Removes a set of specified permissions from the server group specified with sgid. Multiple permissions can be removed at once. A permission can be specified by permid or permsid.
3256
+ *
3257
+ * <b>Input-Array like this:</b>
3258
+ * <pre>
3259
+ * $permissions = array();
3260
+ * $permissions[] = 'permissionID';
3261
+ * //or you could use
3262
+ * $permissions[] = 'permissionName';
3263
+ * </pre>
3264
+ *
3265
+ * @author     Par0noid Solutions
3266
+ * @param		integer		$sgid				serverGroupID
3267
+ * @param		array		$permissionIds		permissionIds
3268
+ * @return     boolean success
3269
+ */
3270
+    function serverGroupDeletePerm($sgid, $permissionIds) {
3271
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
3272
+        $permissionArray = array();
3273
+		
3274
+        if(count($permissionIds) > 0) {
3275
+            foreach($permissionIds AS $value) {
3276
+                $permissionArray[] = is_numeric($value) ? 'permid='.$value : 'permsid='.$this->escapeText($value);
3277
+            }
3278
+            return $this->getData('boolean', 'servergroupdelperm sgid='.$sgid.' '.implode('|', $permissionArray));
3279
+        }else{
3280
+            $this->addDebugLog('no permissions given');
3281
+            return $this->generateOutput(false, array('Error: no permissions given'), false);
3282
+        }
3283
+    }
3284
+
3285
+/**
3286
+ * serverGroupList
3287
+ * 
3288
+ * Displays a list of server groups available. Depending on your permissions, the output may also contain global ServerQuery groups and template groups.
3289
+ *
3290
+ * <b>Output:</b>
3291
+ * <pre>
3292
+ * Array
3293
+ * {
3294
+ *  [sgid] => 1
3295
+ *  [name] => Guest Server Query
3296
+ *  [type] => 2
3297
+ *  [iconid] => 0
3298
+ *  [savedb] => 0
3299
+ * }
3300
+ * </pre>
3301
+ *
3302
+ * @author     Par0noid Solutions
3303
+ * @return     array serverGroupList
3304
+ */
3305
+    function serverGroupList() {
3306
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
3307
+        return $this->getData('multi', 'servergrouplist');
3308
+    }
3309
+
3310
+/**
3311
+ * serverGroupPermList
3312
+ * 
3313
+ * Displays a list of permissions assigned to the server group specified with sgid. If the permsid option is specified, the output will contain the permission names instead of the internal IDs.
3314
+ *
3315
+ * <b>Output:</b>
3316
+ * <pre>
3317
+ * Array
3318
+ * {
3319
+ *  [permid] => 12876 (if permsid = false)
3320
+ *  [permsid] => b_client_info_view (if permsid = true)
3321
+ *  [permvalue] => 1
3322
+ *  [permnegated] => 0
3323
+ *  [permskip] => 0
3324
+ * }
3325
+ * </pre>
3326
+ *
3327
+ * @author     Par0noid Solutions
3328
+ * @param		integer	$sgid		serverGroupID
3329
+ * @param		boolean	$permsid	set true to add -permsid param [optional]
3330
+ * @return     array serverGroupPermList
3331
+ */
3332
+    function serverGroupPermList($sgid, $permsid = false) {
3333
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
3334
+        if($permsid) { $additional = ' -permsid'; }else{ $additional = ''; }
3335
+        return $this->getData('multi', 'servergrouppermlist sgid='.$sgid.$additional);
3336
+    }
3337
+
3338
+/**
3339
+ * serverGroupRename
3340
+ * 
3341
+ * Changes the name of the server group specified with sgid.
3342
+ *
3343
+ * @author     Par0noid Solutions
3344
+ * @param		integer $sgid	serverGroupID
3345
+ * @param		integer $name	groupName
3346
+ * @return     boolean success
3347
+ */
3348
+    function serverGroupRename($sgid, $name) {
3349
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
3350
+        return $this->getData('boolean', 'servergrouprename sgid='.$sgid.' name='.$this->escapeText($name));
3351
+    }
3352
+
3353
+/**
3354
+ * serverGroupsByClientID
3355
+ * 
3356
+ * Displays all server groups the client specified with cldbid is currently residing in.
3357
+ *
3358
+ * <b>Output:</b>
3359
+ * <pre>
3360
+ * Array
3361
+ * {
3362
+ *  [name] => Guest
3363
+ *  [sgid] => 73
3364
+ *  [cldbid] => 2
3365
+ * }
3366
+ * </pre>
3367
+ *
3368
+ * @author     Par0noid Solutions
3369
+ * @param		integer	$cldbid	clientDBID
3370
+ * @return     array serverGroupsByClientId
3371
+ */
3372
+    function serverGroupsByClientID($cldbid) {
3373
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
3374
+        return $this->getData('multi', 'servergroupsbyclientid cldbid='.$cldbid);
3375
+    }
3376
+
3377
+/**
3378
+ * serverIdGetByPort
3379
+ * 
3380
+ * Displays the database ID of the virtual server running on the UDP port specified by virtualserver_port.
3381
+ * 
3382
+ * <b>Output:</b>
3383
+ * <pre>
3384
+ * Array
3385
+ * {
3386
+ *  [server_id] => 1
3387
+ * }
3388
+ * </pre>
3389
+ *
3390
+ * @author     Par0noid Solutions
3391
+ * @param		integer $port	serverPort
3392
+ * @return     array serverInfo
3393
+ */
3394
+    function serverIdGetByPort($port) {
3395
+        return $this->getData('array', 'serveridgetbyport virtualserver_port='.$port);
3396
+    }
3397
+
3398
+/**
3399
+ * serverInfo
3400
+ * 
3401
+ * Displays detailed configuration information about the selected virtual server including unique ID, number of clients online, configuration, etc.
3402
+ *	
3403
+ * <b>Output:</b>
3404
+ * <pre>
3405
+ * Array
3406
+ * {
3407
+ *  [virtualserver_unique_identifier] => 1GvKR12fg/mY75flwN/u7pn7KIs=
3408
+ *  [virtualserver_name] => TeamSpeak ]I[ Server
3409
+ *  [virtualserver_welcomemessage] => Welcome to TeamSpeak, check [URL]www.teamspeak.com[/URL] for latest information
3410
+ *  [virtualserver_platform] => Windows
3411
+ *  [virtualserver_version] => 3.0.12.4 [Build: 1461597405]
3412
+ *  [virtualserver_maxclients] => 32
3413
+ *  [virtualserver_password] => 
3414
+ *  [virtualserver_clientsonline] => 2
3415
+ *  [virtualserver_channelsonline] => 1
3416
+ *  [virtualserver_created] => 0
3417
+ *  [virtualserver_uptime] => 6517
3418
+ *  [virtualserver_codec_encryption_mode] => 0
3419
+ *  [virtualserver_hostmessage] => 
3420
+ *  [virtualserver_hostmessage_mode] => 0
3421
+ *  [virtualserver_filebase] => files\\virtualserver_1
3422
+ *  [virtualserver_default_server_group] => 11
3423
+ *  [virtualserver_default_channel_group] => 12
3424
+ *  [virtualserver_flag_password] => 0
3425
+ *  [virtualserver_default_channel_admin_group] => 9
3426
+ *  [virtualserver_max_download_total_bandwidth] => 18446744073709551615
3427
+ *  [virtualserver_max_upload_total_bandwidth] => 18446744073709551615
3428
+ *  [virtualserver_hostbanner_url] => 
3429
+ *  [virtualserver_hostbanner_gfx_url] => 
3430
+ *  [virtualserver_hostbanner_gfx_interval] => 0
3431
+ *  [virtualserver_complain_autoban_count] => 5
3432
+ *  [virtualserver_complain_autoban_time] => 1200
3433
+ *  [virtualserver_complain_remove_time] => 3600
3434
+ *  [virtualserver_min_clients_in_channel_before_forced_silence] => 100
3435
+ *  [virtualserver_priority_speaker_dimm_modificator] => -18.0000
3436
+ *  [virtualserver_id] => 1
3437
+ *  [virtualserver_antiflood_points_tick_reduce] => 5
3438
+ *  [virtualserver_antiflood_points_needed_command_block] => 150
3439
+ *  [virtualserver_antiflood_points_needed_ip_block] => 250
3440
+ *  [virtualserver_client_connections] => 1
3441
+ *  [virtualserver_query_client_connections] => 54
3442
+ *  [virtualserver_hostbutton_tooltip] => 
3443
+ *  [virtualserver_hostbutton_url] => 
3444
+ *  [virtualserver_hostbutton_gfx_url] => 
3445
+ *  [virtualserver_queryclientsonline] => 1
3446
+ *  [virtualserver_download_quota] => 18446744073709551615
3447
+ *  [virtualserver_upload_quota] => 18446744073709551615
3448
+ *  [virtualserver_month_bytes_downloaded] => 0
3449
+ *  [virtualserver_month_bytes_uploaded] => 16045
3450
+ *  [virtualserver_total_bytes_downloaded] => 0
3451
+ *  [virtualserver_total_bytes_uploaded] => 16045
3452
+ *  [virtualserver_port] => 9987
3453
+ *  [virtualserver_autostart] => 1
3454
+ *  [virtualserver_machine_id] => 
3455
+ *  [virtualserver_needed_identity_security_level] => 8
3456
+ *  [virtualserver_log_client] => 0
3457
+ *  [virtualserver_log_query] => 0
3458
+ *  [virtualserver_log_channel] => 0
3459
+ *  [virtualserver_log_permissions] => 1
3460
+ *  [virtualserver_log_server] => 0
3461
+ *  [virtualserver_log_filetransfer] => 0
3462
+ *  [virtualserver_min_client_version] => 1445512488
3463
+ *  [virtualserver_name_phonetic] => 
3464
+ *  [virtualserver_icon_id] => 0
3465
+ *  [virtualserver_reserved_slots] => 0
3466
+ *  [virtualserver_total_packetloss_speech] => 0.0000
3467
+ *  [virtualserver_total_packetloss_keepalive] => 0.0000
3468
+ *  [virtualserver_total_packetloss_control] => 0.0000
3469
+ *  [virtualserver_total_packetloss_total] => 0.0000
3470
+ *  [virtualserver_total_ping] => 0.0000
3471
+ *  [virtualserver_ip] => 
3472
+ *  [virtualserver_weblist_enabled] => 1
3473
+ *  [virtualserver_ask_for_privilegekey] => 0
3474
+ *  [virtualserver_hostbanner_mode] => 0
3475
+ *  [virtualserver_channel_temp_delete_delay_default] => 0
3476
+ *  [virtualserver_min_android_version] => 1407159763
3477
+ *  [virtualserver_min_ios_version] => 1407159763
3478
+ *  [virtualserver_status] => online
3479
+ *  [connection_filetransfer_bandwidth_sent] => 0
3480
+ *  [connection_filetransfer_bandwidth_received] => 0
3481
+ *  [connection_filetransfer_bytes_sent_total] => 0
3482
+ *  [connection_filetransfer_bytes_received_total] => 0
3483
+ *  [connection_packets_sent_speech] => 0
3484
+ *  [connection_bytes_sent_speech] => 0
3485
+ *  [connection_packets_received_speech] => 0
3486
+ *  [connection_bytes_received_speech] => 0
3487
+ *  [connection_packets_sent_keepalive] => 12959
3488
+ *  [connection_bytes_sent_keepalive] => 531319
3489
+ *  [connection_packets_received_keepalive] => 12959
3490
+ *  [connection_bytes_received_keepalive] => 544277
3491
+ *  [connection_packets_sent_control] => 396
3492
+ *  [connection_bytes_sent_control] => 65555
3493
+ *  [connection_packets_received_control] => 397
3494
+ *  [connection_bytes_received_control] => 44930
3495
+ *  [connection_packets_sent_total] => 13355
3496
+ *  [connection_bytes_sent_total] => 596874
3497
+ *  [connection_packets_received_total] => 13356
3498
+ *  [connection_bytes_received_total] => 589207
3499
+ *  [connection_bandwidth_sent_last_second_total] => 81
3500
+ *  [connection_bandwidth_sent_last_minute_total] => 92
3501
+ *  [connection_bandwidth_received_last_second_total] => 83
3502
+ *  [connection_bandwidth_received_last_minute_total] => 88
3503
+ * }
3504
+ * </pre>
3505
+ *
3506
+ * @author     Par0noid Solutions
3507
+ * @return     array serverInformation
3508
+ */
3509
+    function serverInfo() {
3510
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
3511
+        return $this->getData('array', 'serverinfo');
3512
+    }
3513
+
3514
+/**
3515
+ * serverList
3516
+ * 
3517
+ * Displays a list of virtual servers including their ID, status, number of clients online, etc. If you're using the -all option, the server will list all virtual servers stored in the database. This can be useful when multiple server instances with different machine IDs are using the same database. The machine ID is used to identify the server instance a virtual server is associated with. The status of a virtual server can be either online, offline, deploy running, booting up, shutting down and virtual online. While most of them are self-explanatory, virtual online is a bit more complicated. Please note that whenever you select a virtual server which is currently stopped, it will be started in virtual mode which means you are able to change its configuration, create channels or change permissions, but no regular TeamSpeak 3 Client can connect. As soon as the last ServerQuery client deselects the virtual server, its status will be changed back to offline.
3518
+ *
3519
+ * <b>Possible params:</b> [-uid] [-short] [-all] [-onlyoffline]
3520
+ *
3521
+ * <b>Output:</b>
3522
+ * <pre>
3523
+ * Array
3524
+ * {
3525
+ *  [virtualserver_id] => 1 //displayed on -short
3526
+ *  [virtualserver_port] => 9987 //displayed on -short
3527
+ *  [virtualserver_status] => online //displayed on -short
3528
+ *  [virtualserver_clientsonline] => 2
3529
+ *  [virtualserver_queryclientsonline] => 1
3530
+ *  [virtualserver_maxclients] => 32
3531
+ *  [virtualserver_uptime] => 3045
3532
+ *  [virtualserver_name] => TeamSpeak ]I[ Server
3533
+ *  [virtualserver_autostart] => 1
3534
+ *  [virtualserver_machine_id] =>
3535
+ *  [-uid] => [virtualserver_unique_identifier] => bYrybKl/APfKq7xzpIJ1Xb6C06U= 
3536
+ * }
3537
+ * </pre>
3538
+ *
3539
+ * @author     Par0noid Solutions
3540
+ * @param		string		$options		optional parameters
3541
+ * @return     array serverList
3542
+ */
3543
+    function serverList($options = NULL) {
3544
+        return $this->getData('multi', 'serverlist'.(!empty($options) ? ' '.$options : ''));
3545
+    }
3546
+
3547
+/**
3548
+ * serverProcessStop
3549
+ * 
3550
+ * Stops the entire TeamSpeak 3 Server instance by shutting down the process.
3551
+ *
3552
+ * @author     Par0noid Solutions
3553
+ * @return     boolean success
3554
+ */
3555
+    function serverProcessStop() {
3556
+        return $this->getData('boolean', 'serverprocessstop');
3557
+    }
3558
+
3559
+/**
3560
+ * serverRequestConnectionInfo
3561
+ * 
3562
+ * Displays detailed connection information about the selected virtual server including uptime, traffic information, etc.
3563
+ *
3564
+ * <b>Output:</b>
3565
+ * <pre>
3566
+ * Array
3567
+ * {
3568
+ *  [connection_filetransfer_bandwidth_sent] => 0
3569
+ *  [connection_filetransfer_bandwidth_received] => 0
3570
+ *  [connection_filetransfer_bytes_sent_total] => 0
3571
+ *  [connection_filetransfer_bytes_received_total] => 0
3572
+ *  [connection_packets_sent_total] => 3333
3573
+ *  [connection_bytes_sent_total] => 149687
3574
+ *  [connection_packets_received_total] => 3333
3575
+ *  [connection_bytes_received_total] => 147653
3576
+ *  [connection_bandwidth_sent_last_second_total] => 123
3577
+ *  [connection_bandwidth_sent_last_minute_total] => 81
3578
+ *  [connection_bandwidth_received_last_second_total] => 352
3579
+ *  [connection_bandwidth_received_last_minute_total] => 87
3580
+ *  [connection_connected_time] => 3387
3581
+ *  [connection_packetloss_total] => 0.0000
3582
+ *  [connection_ping] => 0.0000
3583
+ * }
3584
+ * </pre>
3585
+ *
3586
+ * @author     Par0noid Solutions
3587
+ * @return     array serverRequestConnectionInfo
3588
+ */
3589
+    function serverRequestConnectionInfo() {
3590
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
3591
+        return $this->getData('array', 'serverrequestconnectioninfo');
3592
+    }
3593
+
3594
+/**
3595
+ * serverSnapshotCreate
3596
+ * 
3597
+ * Displays a snapshot of the selected virtual server containing all settings, groups and known client identities. The data from a server snapshot can be used to restore a virtual servers configuration, channels and permissions using the serversnapshotdeploy command.
3598
+ *
3599
+ * @author     Par0noid Solutions
3600
+ * @return     string snapshot
3601
+ */
3602
+    function serverSnapshotCreate() {
3603
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
3604
+        return $this->getData('plain', 'serversnapshotcreate');
3605
+    }
3606
+
3607
+/**
3608
+ * serverSnapshotDeploy
3609
+ * 
3610
+ * Restores the selected virtual servers configuration using the data from a previously created server snapshot. Please note that the TeamSpeak 3 Server does NOT check for necessary permissions while deploying a snapshot so the command could be abused to gain additional privileges.
3611
+ *
3612
+ * + added "-mapping" to the serversnapshotdeploy command. This optional parameters will add a mapping of the old and new channelid's in the return
3613
+ *
3614
+ * @author     Par0noid Solutions
3615
+ * @param		string	$snapshot	snapshot
3616
+ * @param		bool	$mapping	mapping [optional]
3617
+ * @return     boolean success
3618
+ */
3619
+    function serverSnapshotDeploy($snapshot, $mapping = false) {
3620
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
3621
+        return $this->getData('boolean', 'serversnapshotdeploy '.($mapping ? '-mapping ' : '').$snapshot);
3622
+    }
3623
+	
3624
+/**
3625
+ * serverStart
3626
+ * 
3627
+ * Starts the virtual server specified with sid. Depending on your permissions, you're able to start either your own virtual server only or all virtual servers in the server instance.
3628
+ *
3629
+ * @author     Par0noid Solutions
3630
+ * @param		integer $sid	serverID
3631
+ * @return     boolean success
3632
+ */
3633
+    function serverStart($sid) {
3634
+        return $this->getdata('boolean', 'serverstart sid='.$sid);
3635
+    }	
3636
+
3637
+/**
3638
+ * serverStop
3639
+ * 
3640
+ * Stops the virtual server specified with sid. Depending on your permissions, you're able to stop either your own virtual server only or all virtual servers in the server instance.
3641
+ *
3642
+ * @author     Par0noid Solutions
3643
+ * @param		integer $sid	serverID
3644
+ * @return     boolean success
3645
+ */
3646
+    function serverStop($sid) {
3647
+        return $this->getdata('boolean', 'serverstop sid='.$sid);
3648
+    }
3649
+
3650
+/**
3651
+ * serverTemppasswordAdd
3652
+ * 
3653
+ * Sets a new temporary server password specified with pw. The temporary password will be valid for the number of seconds specified with duration. The client connecting with this password will automatically join the channel specified with tcid. If tcid is set to 0, the client will join the default channel.
3654
+ *
3655
+ * @author     Par0noid Solutions
3656
+ * @param		string	$pw				temporary password
3657
+ * @param		string	$duration		durations in seconds
3658
+ * @param		string	$desc			description [optional]
3659
+ * @param		string	$tcid			cid user enters on connect (0 = Default channel) [optional]
3660
+ * @param		string	$tcpw			channelPW
3661
+ * @return     boolean success
3662
+ */
3663
+    function serverTempPasswordAdd($pw, $duration, $desc = 'none', $tcid = 0, $tcpw = null) {
3664
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
3665
+        return $this->getdata('boolean', 'servertemppasswordadd pw='.$this->escapeText($pw).' desc='.(!empty($desc) ? $this->escapeText($desc) : 'none').' duration='.$duration.' tcid='.$tcid.(!empty($tcpw) ? ' tcpw='.$this->escapeText($tcpw) : ''));
3666
+    }
3667
+
3668
+/**
3669
+ * serverTemppasswordDel
3670
+ * 
3671
+ * Deletes the temporary server password specified with pw.
3672
+ * 
3673
+ * @author     Par0noid Solutions
3674
+ * @param		string	$pw		temporary password
3675
+ * @return     boolean success
3676
+ */	
3677
+    function serverTempPasswordDel($pw) {
3678
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
3679
+        return $this->getdata('boolean', 'servertemppassworddel pw='.$this->escapeText($pw));
3680
+    }
2434 3681
 
2435 3682
 /**
2436
-  * messageList
2437
-  * 
2438
-  * Displays a list of offline messages you've received. The output contains the senders unique identifier, the messages subject, etc.
2439
-  *
2440
-  * @author     Par0noid Solutions
2441
-  * @return     array messageInformation
2442
-  */
2443
-	function messageList() {		
2444
-        if(!$this->runtime['selected']) { return $this->checkSelected(); }
2445
-        return $this->getData('array', 'messagelist'); 
2446
-	}
2447
-
2448
-/**
2449
-  * messageUpdateFlag
2450
-  * 
2451
-  * Updates the flag_read property of the offline message specified with msgid. If flag is set to 1, the message will be marked as read.
2452
-  *
2453
-  * @author     Par0noid Solutions
2454
-  * @param		string	$messageID		messageID
2455
-  * @param		integer	$flag			flag {1|0}
2456
-  * @return     array messageInformation
2457
-  */
2458
-	function messageUpdateFlag($messageID, $flag = 1) {		
2459
-        if(!$this->runtime['selected']) { return $this->checkSelected(); }
2460
-        return $this->getData('boolean', 'messageupdateflag msgid='.$messageID.' flag='.$flag); 
2461
-	}
2462
-
2463
-/**
2464
-  * permFind
2465
-  * 
2466
-  * Displays detailed information about all assignments of the permission specified with permid. The output is similar to permoverview which includes the type and the ID of the client, channel or group associated with the permission. A permission can be specified by permid or permsid.
2467
-  *
2468
-  * <b>Output:</b>
2469
-  * <pre>
2470
-  * Array
2471
-  * {
2472
-  *  [token] => eKnFZQ9EK7G7MhtuQB6+N2B1PNZZ6OZL3ycDp2OW
2473
-  * }
2474
-  * </pre>
2475
-  *
2476
-  * @author     Par0noid Solutions
2477
-  * @param		mixed	$perm	permid or permsid
2478
-  * @return     array permissionInfoList
2479
-  */
2480
-	function permFind($perm) { 
3683
+ * serverTemppasswordList
3684
+ * 
3685
+ * Returns a list of active temporary server passwords. The output contains the clear-text password, the nickname and unique identifier of the creating client.
3686
+ *
3687
+ * <b>Output:</b>
3688
+ * <pre>
3689
+ * Array
3690
+ * {
3691
+ *  [nickname] => serveradmin
3692
+ *  [uid] => 1
3693
+ *  [desc] => none
3694
+ *  [pw_clear] => test
3695
+ *  [start] => 1334996838
3696
+ *  [end] => 1335000438
3697
+ *  [tcid] => 0
3698
+ * }
3699
+ * </pre>
3700
+ *
3701
+ * @author     Par0noid Solutions
3702
+ * @return     array	serverTemppasswordList
3703
+ */
3704
+    function serverTempPasswordList() {
2481 3705
         if(!$this->runtime['selected']) { return $this->checkSelected(); }
2482
-        return $this->getData('multi', 'permfind '.(is_int($perm) || ctype_digit($perm) ? 'permid=' : 'permsid=').$perm); 
3706
+        return $this->getData('multi', 'servertemppasswordlist');
2483 3707
     }
2484 3708
 	
2485
-	
3709
+
2486 3710
 /**
2487
-  * permGet
2488
-  * 
2489
-  * Displays the current value of the permission specified with permid or permsid for your own connection. This can be useful when you need to check your own privileges.
2490
-  *
2491
-  * The perm parameter can be used as permid or permsid, it will switch the mode automatically.
2492
-  *
2493
-  * <b>Output:</b>
2494
-  * <pre>
2495
-  * Array
2496
-  * {
2497
-  *		[permsid] => i_channel_create_modify_with_codec_maxquality
2498
-  *     [permid] => 96
2499
-  *     [permvalue] => 10	
2500
-  * }
2501
-  * </pre>
2502
-  *
2503
-  * @author     Par0noid Solutions
2504
-  * @param		mixed	$perm	permid or permsid
2505
-  * @return     array permissionInfo
2506
-  */
2507
-	function permGet($perm) { 
3711
+ *	setClientChannelGroup
3712
+ *
3713
+ * Sets the channel group of a client to the ID specified with cgid.
3714
+ *
3715
+ * @author     Par0noid Solutions
3716
+ * @param		integer $cgid	groupID
3717
+ * @param		integer $cid	channelID
3718
+ * @param		integer $cldbid	clientDBID
3719
+ * @return     boolean success
3720
+ */
3721
+    function setClientChannelGroup($cgid, $cid, $cldbid) {
2508 3722
         if(!$this->runtime['selected']) { return $this->checkSelected(); }
2509
-        return $this->getData('array', 'permget '.(is_int($perm) || ctype_digit($perm) ? 'permid=' : 'permsid=').$perm); 
2510
-    }	
2511
-	
3723
+        return $this->getData('boolean', 'setclientchannelgroup cgid='.$cgid.' cid='.$cid.' cldbid='.$cldbid);
3724
+    }
3725
+
3726
+/**
3727
+ * setName
3728
+ * 
3729
+ * Sets your nickname in server query
3730
+ *
3731
+ * @author     Par0noid Solutions
3732
+ * @param		string	$newName	new name in server query
3733
+ * @return     boolean success
3734
+ */
3735
+    function setName($newName) {
3736
+        return $this->getData('boolean', 'clientupdate client_nickname='.$this->escapeText($newName));
3737
+    }
3738
+
2512 3739
 /**
2513
-  * permIdGetByName
2514
-  * 
2515
-  * Displays the database ID of one or more permissions specified by permsid.
2516
-  *
2517
-  * <b>Input-Array like this:</b>
2518
-  * <pre>
2519
-  * $permissions = array();
2520
-  * $permissions[] = 'permissionName';
2521
-  * </pre>
2522
-  * <b>Output:</b>
2523
-  * <pre>
2524
-  * Array
2525
-  * {
2526
-  *  [permsid] => b_serverinstance_help_view
2527
-  *  [permid] => 4353
2528
-  * }
2529
-  * </pre>
2530
-  *
2531
-  * @author     Par0noid Solutions
2532
-  * @param		string	$permsids		permNames
2533
-  * @return     array	permissionList 
2534
-  */
2535
-	function permIdGetByName($permsids) {
2536
-		$permissionArray = array();
3740
+ * tokenAdd
3741
+ * 
3742
+ * Create a new token. If tokentype is set to 0, the ID specified with tokenid1 will be a server group ID. Otherwise, tokenid1 is used as a channel group ID and you need to provide a valid channel ID using tokenid2. The tokencustomset parameter allows you to specify a set of custom client properties. This feature can be used when generating tokens to combine a website account database with a TeamSpeak user. The syntax of the value needs to be escaped using the ServerQuery escape patterns and has to follow the general syntax of:
3743
+ * ident=ident1 value=value1|ident=ident2 value=value2|ident=ident3 value=value3
3744
+ *
3745
+ * <b>Input-Array like this:</b>
3746
+ * <pre>
3747
+ * $customFieldSet = array();
3748
+ *	
3749
+ * $customFieldSet['ident'] = 'value';
3750
+ * $customFieldSet['ident'] = 'value';
3751
+ * </pre>
3752
+ *
3753
+ * @author     Par0noid Solutions
3754
+ * @param		integer	$tokentype				token type
3755
+ * @param		integer	$tokenid1				groupID
3756
+ * @param		integer	$tokenid2				channelID
3757
+ * @param		string	$description			token description [optional]
3758
+ * @param		array	$customFieldSet			customFieldSet [optional]
3759
+ * @return     array	tokenInformation
3760
+ */
3761
+    function tokenAdd($tokentype, $tokenid1, $tokenid2, $description ='', $customFieldSet = array()) {
3762
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
2537 3763
 		
2538
-		if(count($permsids) > 0) {
2539
-			foreach($permsids AS $value) {
2540
-				$permissionArray[] = 'permsid='.$value;
2541
-			}
2542
-			return $this->getData('multi', 'permidgetbyname '.$this->escapeText(implode('|', $permissionArray)));
2543
-		}else{
2544
-			$this->addDebugLog('no permissions given');
2545
-			return $this->generateOutput(false, array('Error: no permissions given'), false);
2546
-		}
3764
+        if(!empty($description)) { $description = ' tokendescription=' . $this->escapeText($description); }
3765
+
3766
+        if($tokentype == '0') { $tokenid2 = '0'; }
2547 3767
 		
2548
-	}
2549
-
2550
-
2551
-/**
2552
-  * permissionList
2553
-  * 
2554
-  * Displays a list of permissions available on the server instance including ID, name and description.
2555
-  * If the new parameter is set the permissionlist will return with the new output format.
2556
-  *
2557
-  * <b>Output: (with new parameter)</b>
2558
-  * <pre>
2559
-  * [0] => Array
2560
-  *     (
2561
-  *         [num] => 1
2562
-  *         [group_id_end] => 0
2563
-  *         [pcount] => 0
2564
-  *     )
2565
-  *
2566
-  * [1] => Array
2567
-  *     (
2568
-  *         [num] => 2
2569
-  *         [group_id_end] => 7
2570
-  *         [pcount] => 7
2571
-  *         [permissions] => Array
2572
-  *             (
2573
-  *                 [0] => Array
2574
-  *                     (
2575
-  *                         [permid] => 1
2576
-  *                         [permname] => b_serverinstance_help_view
2577
-  *                         [permdesc] => Retrieve information about ServerQuery commands
2578
-  *                         [grantpermid] => 32769
2579
-  *                     )
2580
-  *
2581
-  *                 [1] => Array
2582
-  *                     (
2583
-  *                         [permid] => 2
2584
-  *                         [permname] => b_serverinstance_version_view
2585
-  *                         [permdesc] => Retrieve global server version (including platform and build number)
2586
-  *                         [grantpermid] => 32770
2587
-  *                     )
2588
-  *
2589
-  *                 [2] => Array
2590
-  *                     (
2591
-  *                         [permid] => 3
2592
-  *                         [permname] => b_serverinstance_info_view
2593
-  *                         [permdesc] => Retrieve global server information
2594
-  *                         [grantpermid] => 32771
2595
-  *                     )
2596
-  *
2597
-  *                 [3] => Array
2598
-  *                     (
2599
-  *                         [permid] => 4
2600
-  *                         [permname] => b_serverinstance_virtualserver_list
2601
-  *                         [permdesc] => List virtual servers stored in the database
2602
-  *                         [grantpermid] => 32772
2603
-  *                     )
2604
-  *
2605
-  *                 [4] => Array
2606
-  *                     (
2607
-  *                         [permid] => 5
2608
-  *                         [permname] => b_serverinstance_binding_list
2609
-  *                         [permdesc] => List active IP bindings on multi-homed machines
2610
-  *                         [grantpermid] => 32773
2611
-  *                     )
2612
-  *
2613
-  *                [5] => Array
2614
-  *                     (
2615
-  *                         [permid] => 6
2616
-  *                         [permname] => b_serverinstance_permission_list
2617
-  *                         [permdesc] => List permissions available available on the server instance
2618
-  *                         [grantpermid] => 32774
2619
-  *                     )
2620
-  *
2621
-  *                 [6] => Array
2622
-  *                     (
2623
-  *                         [permid] => 7
2624
-  *                         [permname] => b_serverinstance_permission_find
2625
-  *                         [permdesc] => Search permission assignments by name or ID
2626
-  *                         [grantpermid] => 32775
2627
-  *                     )
2628
-  *
2629
-  *             )
2630
-  *
2631
-  *     )
2632
-  * </pre>
2633
-  *
2634
-  * @author     Par0noid Solutions
2635
-  * @param		boolean		$new		[optional] add new parameter
2636
-  * @return     array permissionList
2637
-  */
2638
-	function permissionList($new = false) {
2639
-		if($new === true) {
2640
-			$groups = array();
2641
-			$permissions = array();
2642
-			
2643
-			$response = $this->getElement('data', $this->getData('multi', 'permissionlist -new'));
2644
-			
2645
-			$gc = 1;
2646
-			
2647
-			foreach($response as $field) {
2648
-				if(isset($field['group_id_end'])) {
2649
-					$groups[] = array('num' => $gc, 'group_id_end' => $field['group_id_end']);
2650
-					$gc++;
2651
-				}else{
2652
-					$permissions[] = $field;
2653
-				}
2654
-			}
2655
-			
2656
-			$counter = 0;
2657
-			
2658
-			for($i = 0; $i < count($groups); $i++) {
2659
-				$rounds = $groups[$i]['group_id_end'] - $counter;
2660
-				$groups[$i]['pcount'] = $rounds;
2661
-				for($j = 0; $j < $rounds; $j++) {
2662
-					$groups[$i]['permissions'][] = array('permid' => ($counter + 1), 'permname' => $permissions[$counter]['permname'], 'permdesc' => $permissions[$counter]['permdesc'], 'grantpermid' => ($counter + 32769));
2663
-					$counter++;
2664
-				}
2665
-			}
2666
-			
2667
-			return $groups;
3768
+        if(count($customFieldSet)) {
3769
+            $settingsString = array();
3770
+		
3771
+            foreach($customFieldSet as $key => $value) {
3772
+                $settingsString[] = 'ident='.$this->escapeText($key).'\svalue='.$this->escapeText($value);
3773
+            }
2668 3774
 			
2669
-		}else{
2670
-			return $this->getData('multi', 'permissionlist');
2671
-		}
2672
-	}
2673
-
2674
-/**
2675
-  * permOverview
2676
-  * 
2677
-  * Displays all permissions assigned to a client for the channel specified with cid. If permid is set to 0, all permissions will be displayed. A permission can be specified by permid or permsid.
2678
-  *
2679
-  * If you set the permsid parameter, the permid parameter will be ignored.
2680
-  *
2681
-  * <b>Output:</b>
2682
-  * <pre>
2683
-  * Array
2684
-  * {
2685
-  *  [t] => 0
2686
-  *  [id1] => 2
2687
-  *  [id2] => 0
2688
-  *  [p] => 16777
2689
-  *  [v] => 1
2690
-  *  [n] => 0
2691
-  *  [s] => 0
2692
-  * }
2693
-  * </pre>
2694
-  *
2695
-  * @author     Par0noid Solutions
2696
-  * @param		integer		$cid		cchannelId
2697
-  * @param		integer 	$cldbid		clientDbId
2698
-  * @param		integer 	$permid		permId (Default: 0)
2699
-  * @param		string	 	$permsid	permName
2700
-  * @return     array permOverview
2701
-  */
2702
-	function permOverview($cid, $cldbid, $permid='0', $permsid=false ) { 
2703
-        if(!$this->runtime['selected']) { return $this->checkSelected(); } 
2704
-        if($permsid) { $additional = ' permsid='.$permsid; }else{ $additional = ''; } 
2705
-         
2706
-        return $this->getData('multi', 'permoverview cid='.$cid.' cldbid='.$cldbid.($permsid == false ? ' permid='.$permid : '').$additional); 
3775
+            $customFieldSet = ' tokencustomset='.implode('\p', $settingsString);
3776
+        }else{
3777
+            $customFieldSet = '';
3778
+        }
3779
+		
3780
+        return $this->getData('array', 'privilegekeyadd tokentype='.$tokentype.' tokenid1='.$tokenid1.' tokenid2='.$tokenid2.$description.$customFieldSet);
2707 3781
     }
2708 3782
 
2709 3783
 /**
2710
-  * permReset
2711
-  * 
2712
-  * Restores the default permission settings on the selected virtual server and creates a new initial administrator token. Please note that in case of an error during the permreset call - e.g. when the database has been modified or corrupted - the virtual server will be deleted from the database.
2713
-  *
2714
-  * <b>Output:</b>
2715
-  * <pre>
2716
-  * Array
2717
-  * {
2718
-  *  [token] => eKnFZQ9EK7G7MhtuQB6+N2B1PNZZ6OZL3ycDp2OW
2719
-  * }
2720
-  * </pre>
2721
-  *
2722
-  * @author     Par0noid Solutions
2723
-  * @return     array token
2724
-  */
2725
-	function permReset() { 
2726
-        if(!$this->runtime['selected']) { return $this->checkSelected(); } 
2727
-        return $this->getData('array', 'permreset'); 
3784
+ * tokenDelete
3785
+ * 
3786
+ * Deletes an existing token matching the token key specified with token.
3787
+ *
3788
+ * @author     Par0noid Solutions
3789
+ * @param		string	$token	token
3790
+ * @return     boolean success
3791
+ */
3792
+    function tokenDelete($token) {
3793
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }			
3794
+        return $this->getData('boolean', 'privilegekeydelete token='.$token);
2728 3795
     }
2729
-	
2730
-/**
2731
-  * privilegekeyAdd
2732
-  * 
2733
-  * Create a new token. If tokentype is set to 0, the ID specified with tokenid1 will be a server group ID. Otherwise, tokenid1 is used as a channel group ID and you need to provide a valid channel ID using tokenid2. The tokencustomset parameter allows you to specify a set of custom client properties. This feature can be used when generating tokens to combine a website account database with a TeamSpeak user. The syntax of the value needs to be escaped using the ServerQuery escape patterns and has to follow the general syntax of:
2734
-  * ident=ident1 value=value1|ident=ident2 value=value2|ident=ident3 value=value3
2735
-  *
2736
-  * <b>Input-Array like this:</b>
2737
-  * <pre>
2738
-  * $customFieldSet = array();
2739
-  *	
2740
-  * $customFieldSet['ident'] = 'value';
2741
-  * $customFieldSet['ident'] = 'value';
2742
-  * </pre>
2743
-  *
2744
-  * @author     Par0noid Solutions
2745
-  * @param		integer	$tokentype				token type
2746
-  * @param		integer	$tokenid1				groupID
2747
-  * @param		integer	$tokenid2				channelID
2748
-  * @param		string	$description			token description [optional]
2749
-  * @param		array	$customFieldSet			customFieldSet [optional]
2750
-  * @return     array	tokenInformation
2751
-  */
2752
-	function privilegekeyAdd($tokentype, $tokenid1, $tokenid2, $description ='', $customFieldSet = array()) {
2753
-		return $this->tokenAdd($tokentype, $tokenid1, $tokenid2, $description, $customFieldSet);
2754
-	}
2755
-
2756
-/**
2757
-  * privilegekeyDelete
2758
-  * 
2759
-  * Deletes an existing token matching the token key specified with token.
2760
-  *
2761
-  * @author     Par0noid Solutions
2762
-  * @param		string	$token	token
2763
-  * @return     boolean success
2764
-  */
2765
-	function privilegekeyDelete($token) {
2766
-		return $this->tokenDelete($token);
2767
-	}
2768
-
2769
-/**
2770
-  * privilegekeyList
2771
-  * 
2772
-  * Displays a list of privilege keys available including their type and group IDs. Tokens can be used to gain access to specified server or channel groups. A privilege key is similar to a client with administrator privileges that adds you to a certain permission group, but without the necessity of a such a client with administrator privileges to actually exist. It is a long (random looking) string that can be used as a ticket into a specific server group.
2773
-  *
2774
-  * <b>Output:</b>
2775
-  * <pre>
2776
-  * Array
2777
-  * {
2778
-  *  [token] => GdqedxSEDle3e9+LtR3o9dO09bURH+vymvF5hOJg
2779
-  *  [token_type] => 0
2780
-  *  [token_id1] => 71
2781
-  *  [token_id2] => 0
2782
-  *  [token_created] => 1286625908
2783
-  *  [token_description] => for you
2784
-  * }
2785
-  * </pre>
2786
-  *
2787
-  * @author     Par0noid Solutions
2788
-  * @return     array tokenListist 
2789
-  */
2790
-	function privilegekeyList() {
2791
-		return $this->tokenList();
2792
-	}
2793
-
2794
-/**
2795
-  * privilegekeyUse
2796
-  * 
2797
-  * Use a token key gain access to a server or channel group. Please note that the server will automatically delete the token after it has been used.
2798
-  *
2799
-  * @author     Par0noid Solutions
2800
-  * @param		string	$token	token
2801
-  * @return     boolean success
2802
-  */
2803
-	function privilegekeyUse($token) {		
2804
-		return $this->tokenUse($token);
2805
-	}
2806
- 
3796
+
2807 3797
 /**
2808
-  * quit closes the connection to host 
2809
-  *
2810
-  * @author     Par0noid Solutions
2811
-  * @return 	none
2812
-  */
2813
-	private function quit() {
2814
-		$this->logout();
2815
-		@fputs($this->runtime['socket'], "quit\n");
2816
-		@fclose($this->runtime['socket']);
2817
-	}
2818
-
2819
-/**
2820
-  * selectServer
2821
-  * 
2822
-  * Selects the virtual server specified with sid or port to allow further interaction. The ServerQuery client will appear on the virtual server and acts like a real TeamSpeak 3 Client, except it's unable to send or receive voice data. If your database contains multiple virtual servers using the same UDP port, use will select a random virtual server using the specified port.
2823
-  *
2824
-  * @author     Par0noid Solutions
2825
-  * @param		integer	$value		Port or ID
2826
-  * @param		string	$type		value type ('port', 'serverId') (default='port')
2827
-  * @param		boolean	$virtual	set true to add -virtual param [optional]
2828
-  * @return     boolean success
2829
-  */
2830
-	function selectServer($value, $type = 'port', $virtual = false) { 
2831
-        if(in_array($type, array('port', 'serverId'))) { 
2832
-            if($type == 'port') { 
2833
-                if($virtual) { $virtual = ' -virtual'; }else{ $virtual = ''; } 
2834
-                $res = $this->getData('boolean', 'use port='.$value.$virtual); 
2835
-                if($res['success']) { 
2836
-                    $this->runtime['selected'] = true; 
2837
-                } 
2838
-                return $res; 
2839
-            }else{ 
2840
-                if($virtual) { $virtual = ' -virtual'; }else{ $virtual = ''; } 
2841
-                $res = $this->getData('boolean', 'use sid='.$value.$virtual); 
2842
-                if($res['success']) { 
2843
-                    $this->runtime['selected'] = true; 
2844
-                } 
2845
-                return $res; 
2846
-            } 
2847
-        }else{ 
2848
-            $this->addDebugLog('wrong value type'); 
2849
-            return $this->generateOutput(false, array('Error: wrong value type'), false); 
2850
-        } 
3798
+ * tokenList
3799
+ * 
3800
+ * Displays a list of privilege keys available including their type and group IDs. Tokens can be used to gain access to specified server or channel groups. A privilege key is similar to a client with administrator privileges that adds you to a certain permission group, but without the necessity of a such a client with administrator privileges to actually exist. It is a long (random looking) string that can be used as a ticket into a specific server group.
3801
+ *
3802
+ * <b>Output:</b>
3803
+ * <pre>
3804
+ * Array
3805
+ * {
3806
+ *  [token] => GdqedxSEDle3e9+LtR3o9dO09bURH+vymvF5hOJg
3807
+ *  [token_type] => 0
3808
+ *  [token_id1] => 71
3809
+ *  [token_id2] => 0
3810
+ *  [token_created] => 1286625908
3811
+ *  [token_description] => for you
3812
+ * }
3813
+ * </pre>
3814
+ *
3815
+ * @author     Par0noid Solutions
3816
+ * @return     array tokenListist 
3817
+ */
3818
+    function tokenList() {
3819
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }
3820
+
3821
+        return $this->getData('multi', 'privilegekeylist');
2851 3822
     }
2852 3823
 
2853 3824
 /**
2854
-  * sendMessage
2855
-  * 
2856
-  * Sends a text message a specified target. The type of the target is determined by targetmode while target specifies the ID of the recipient, whether it be a virtual server, a channel or a client.
2857
-  * <b>Hint:</b> You can just write to the channel the query client is in. See link in description for details.
2858
-  *
2859
-  * <b>Modes:</b>
2860
-  * <ul>
2861
-  * 	<li><b>1:</b> send to client</li>
2862
-  * 	<li><b>2:</b> send to channel</li>
2863
-  * 	<li><b>3:</b> send to server</li>
2864
-  * </ul>
2865
-  * <b>Targets:</b>
2866
-  * <ul>
2867
-  * 	<li>clientID</li>
2868
-  * 	<li>channelID</li>
2869
-  * 	<li>serverID</li>
2870
-  * </ul>
2871
-  *
2872
-  * @author     Par0noid Solutions
2873
-  * @param		integer $mode
2874
-  * @param		integer $target
2875
-  * @param		string	$msg	Message
2876
-  * @see		http://forum.teamspeak.com/showthread.php/84280-Sendtextmessage-by-query-client http://forum.teamspeak.com/showthread.php/84280-Sendtextmessage-by-query-client
2877
-  * @return     boolean	success
2878
-  */
2879
-	function sendMessage($mode, $target, $msg) {
2880
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
2881
-		return $this->getData('boolean', 'sendtextmessage targetmode='.$mode.' target='.$target.' msg='.$this->escapeText($msg));
2882
-	}
2883
-
2884
-/**
2885
-  * serverCreate
2886
-  * 
2887
-  * Creates a new virtual server using the given properties and displays its ID, port and initial administrator privilege key. If virtualserver_port is not specified, the server will test for the first unused UDP port. The first virtual server will be running on UDP port 9987 by default. Subsequently started virtual servers will be running on increasing UDP port numbers.
2888
-  * 
2889
-  * <b>Input-Array like this:</b>
2890
-  * <pre>
2891
-  * $data = array();
2892
-  *	
2893
-  * $data['setting'] = 'value';
2894
-  * $data['setting'] = 'value';
2895
-  * </pre>
2896
-  *
2897
-  * <b>Output:</b>
2898
-  * <pre>
2899
-  * Array
2900
-  * {
2901
-  *  [sid] => 2
2902
-  *  [virtualserver_port] => 9988
2903
-  *  [token] => eKnFZQ9EK7G7MhtuQB6+N2B1PNZZ6OZL3ycDp2OW
2904
-  * }
2905
-  * </pre>
2906
-  *
2907
-  * @author     Par0noid Solutions
2908
-  * @param		array	$data	serverSettings	[optional]
2909
-  * @return     array serverInfo
2910
-  */
2911
-	function serverCreate($data = array()) {
2912
-		$settingsString = '';
2913
-		
2914
-		if(count($data) == 0) {	$data['virtualserver_name'] = 'Teamspeak 3 Server'; }
2915
-		
2916
-		
2917
-		foreach($data as $key => $value) {
2918
-			if(!empty($value)) { $settingsString .= ' '.$key.'='.$this->escapeText($value); }
2919
-		}
2920
-		
2921
-		return $this->getData('array', 'servercreate'.$settingsString);
2922
-	}
2923
-
2924
-/**
2925
-  * serverDelete
2926
-  * 
2927
-  * Deletes the virtual server specified with sid. Please note that only virtual servers in stopped state can be deleted.
2928
-  *
2929
-  * @author     Par0noid Solutions
2930
-  * @param		integer	$sid	serverID
2931
-  * @return     boolean success
2932
-  */
2933
-	function serverDelete($sid) {
2934
-		$this->serverStop($sid);
2935
-		return $this->getdata('boolean', 'serverdelete sid='.$sid);
2936
-	}
2937
-
2938
-/**
2939
-  * serverEdit
2940
-  * 
2941
-  * Changes the selected virtual servers configuration using given properties. Note that this command accepts multiple properties which means that you're able to change all settings of the selected virtual server at once.
2942
-  *
2943
-  * <b>Input-Array like this:</b>
2944
-  * <pre>
2945
-  * $data = array();
2946
-  *	
2947
-  * $data['setting'] = 'value';
2948
-  * $data['setting'] = 'value';
2949
-  * </pre>
2950
-  *
2951
-  * @author     Par0noid Solutions
2952
-  * @param		array	$data	serverSettings
2953
-  * @return     boolean success
2954
-  */
2955
-	function serverEdit($data) {
2956
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
2957
-		
2958
-		$settingsString = '';
2959
-		
2960
-		foreach($data as $key => $value) {
2961
-			$settingsString .= ' '.$key.'='.$this->escapeText($value);
2962
-		}
2963
-		
2964
-		return $this->getData('boolean', 'serveredit'.$settingsString);
2965
-	}
2966
-
2967
-/**
2968
-  * serverGroupAdd
2969
-  * 
2970
-  * Creates a new server group using the name specified with name and displays its ID. The optional type parameter can be used to create ServerQuery groups and template groups. For detailed information, see
2971
-  *
2972
-  * <b>Output:</b>
2973
-  * <pre>
2974
-  * Array
2975
-  * {
2976
-  *  [sgid] => 86
2977
-  * }
2978
-  * </pre>
2979
-  *
2980
-  * @author     Par0noid Solutions
2981
-  * @param		integer $name	groupName
2982
-  * @param		integer	$type	groupDbType (0 = template, 1 = normal, 2 = query | Default: 1)
2983
-  * @return     array groupId
2984
-  */
2985
-	function serverGroupAdd($name, $type = 1) {
2986
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
2987
-		return $this->getData('array', 'servergroupadd name='.$this->escapeText($name).' type='.$type);
2988
-	}
2989
-
2990
-/**
2991
-  * serverGroupAddClient
2992
-  * 
2993
-  * Adds a client to the server group specified with sgid. Please note that a client cannot be added to default groups or template groups.
2994
-  *
2995
-  * @author     Par0noid Solutions
2996
-  * @param		integer $sgid	serverGroupId
2997
-  * @param		integer $cldbid	clientDBID
2998
-  * @return     boolean success
2999
-  */
3000
-	function serverGroupAddClient($sgid, $cldbid) {
3001
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
3002
-		return $this->getData('boolean', 'servergroupaddclient sgid='.$sgid.' cldbid='.$cldbid);
3003
-	}
3004
-
3005
-/**
3006
-  * serverGroupAddPerm
3007
-  * 
3008
-  * Adds a set of specified permissions to the server group specified with sgid. Multiple permissions can be added by providing the four parameters of each permission. A permission can be specified by permid or permsid.
3009
-  *
3010
-  * <b>Input-Array like this:</b>
3011
-  * <pre>
3012
-  * $permissions = array();
3013
-  * $permissions['permissionID'] = array('permissionValue', 'permskip', 'permnegated');
3014
-  * //or you could use
3015
-  * $permissions['permissionName'] = array('permissionValue', 'permskip', 'permnegated');
3016
-  * </pre>
3017
-  * 
3018
-  * @author     Par0noid Solutions
3019
-  * @param		integer $sgid	serverGroupID
3020
-  * @param		array	$permissions	permissions
3021
-  * @return     boolean success
3022
-  */
3023
-	function serverGroupAddPerm($sgid, $permissions) {
3024
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
3025
-		
3026
-		if(count($permissions) > 0) {
3027
-			//Permissions given
3028
-				
3029
-			//Errorcollector
3030
-			$errors = array();
3031
-				
3032
-			//Split Permissions to prevent query from overload
3033
-			$permissions = array_chunk($permissions, 50, true);
3034
-				
3035
-			//Action for each splitted part of permission
3036
-			foreach($permissions as $permission_part)
3037
-			{
3038
-				//Create command_string for each command that we could use implode later
3039
-				$command_string = array();
3040
-		
3041
-				foreach($permission_part as $key => $value)
3042
-				{
3043
-					$command_string[] = (is_numeric($key) ? "permid=" : "permsid=").$this->escapeText($key).' permvalue='.$value[0].' permskip='.$value[1].' permnegated='.$value[2];
3044
-				}
3045
-		
3046
-				$result = $this->getData('boolean', 'servergroupaddperm sgid='.$sgid.' '.implode('|', $command_string));
3047
-		
3048
-				if(!$result['success'])
3049
-				{
3050
-					foreach($result['errors'] as $error)
3051
-					{
3052
-						$errors[] = $error;
3053
-					}
3054
-				}
3055
-			}
3056
-				
3057
-			if(count($errors) == 0)
3058
-			{
3059
-				return $this->generateOutput(true, array(), true);
3060
-			}else{
3061
-				return $this->generateOutput(false, $errors, false);
3062
-			}
3063
-				
3064
-		}else{
3065
-			// No permissions given
3066
-			$this->addDebugLog('no permissions given');
3067
-			return $this->generateOutput(false, array('Error: no permissions given'), false);
3068
-		}
3069
-	}
3070
-
3071
-/**
3072
-  * serverGroupAutoAddPerm
3073
-  * 
3074
-  * Adds a set of specified permissions to *ALL* regular server groups on all virtual servers. The target groups will be identified by the value of their i_group_auto_update_type permission specified with sgtype. Multiple permissions can be added at once. A permission can be specified by permid or permsid. The known values for sgtype are: 10: Channel Guest 15: Server Guest 20: Query Guest 25: Channel Voice 30: Server Normal 35: Channel Operator 40: Channel Admin 45: Server Admin 50: Query Admin
3075
-  *
3076
-  * <b>Input-Array like this:</b>
3077
-  * <pre>
3078
-  * $permissions = array();
3079
-  * $permissions['permissionID'] = array('permissionValue', 'permskip', 'permnegated');
3080
-  * //or you could use
3081
-  * $permissions['permissionName'] = array('permissionValue', 'permskip', 'permnegated');
3082
-  * </pre>
3083
-  * 
3084
-  * @author     Par0noid Solutions
3085
-  * @param		integer	$sgtype			serverGroupType
3086
-  * @param		array	$permissions	permissions
3087
-  * @return     boolean success
3088
-  */
3089
-	function serverGroupAutoAddPerm($sgtype, $permissions) {
3090
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
3091
-		
3092
-		if(count($permissions) > 0) {
3093
-			//Permissions given
3094
-				
3095
-			//Errorcollector
3096
-			$errors = array();
3097
-				
3098
-			//Split Permissions to prevent query from overload
3099
-			$permissions = array_chunk($permissions, 50, true);
3100
-				
3101
-			//Action for each splitted part of permission
3102
-			foreach($permissions as $permission_part)
3103
-			{
3104
-				//Create command_string for each command that we could use implode later
3105
-				$command_string = array();
3106
-		
3107
-				foreach($permission_part as $key => $value)
3108
-				{
3109
-					$command_string[] = (is_numeric($key) ? "permid=" : "permsid=").$this->escapeText($key).' permvalue='.$value[0].' permskip='.$value[1].' permnegated='.$value[2];
3110
-				}
3111
-		
3112
-				$result = $this->getData('boolean', 'servergroupautoaddperm sgtype='.$sgtype.' '.implode('|', $command_string));
3113
-		
3114
-				if(!$result['success'])
3115
-				{
3116
-					foreach($result['errors'] as $error)
3117
-					{
3118
-						$errors[] = $error;
3119
-					}
3120
-				}
3121
-			}
3122
-				
3123
-			if(count($errors) == 0)
3124
-			{
3125
-				return $this->generateOutput(true, array(), true);
3126
-			}else{
3127
-				return $this->generateOutput(false, $errors, false);
3128
-			}
3129
-				
3130
-		}else{
3131
-			// No permissions given
3132
-			$this->addDebugLog('no permissions given');
3133
-			return $this->generateOutput(false, array('Error: no permissions given'), false);
3134
-		}
3135
-	}
3136
-
3137
-/**
3138
-  * serverGroupAutoDeletePerm
3139
-  * 
3140
-  * Removes a set of specified permissions from *ALL* regular server groups on all virtual servers. The target groups will be identified by the value of their i_group_auto_update_type permission specified with sgtype. Multiple permissions can be removed at once. A permission can be specified by permid or permsid. The known values for sgtype are: 10: Channel Guest 15: Server Guest 20: Query Guest 25: Channel Voice 30: Server Normal 35: Channel Operator 40: Channel Admin 45: Server Admin 50: Query Admin
3141
-  *
3142
-  * <b>Input-Array like this:</b>
3143
-  * <pre>
3144
-  * $permissions = array();
3145
-  * $permissions[] = 'permissionID';
3146
-  * //or you could use
3147
-  * $permissions[] = 'permissionName';
3148
-  * </pre>
3149
-  *
3150
-  * @author     Par0noid Solutions
3151
-  * @param		integer		$sgtype				serverGroupType
3152
-  * @param		array		$permissions		permissions
3153
-  * @return     boolean success
3154
-  */
3155
-	function serverGroupAutoDeletePerm($sgtype, $permissions) {
3156
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
3157
-		$permissionArray = array();
3158
-		
3159
-		if(count($permissions) > 0) {
3160
-			foreach($permissions AS $value) {
3161
-				$permissionArray[] = is_numeric($value) ? 'permid='.$value : 'permsid='.$this->escapeText($value);
3162
-			}
3163
-			return $this->getData('boolean', 'servergroupautodelperm sgtype='.$sgtype.' '.implode('|', $permissionArray));
3164
-		}else{
3165
-			$this->addDebugLog('no permissions given');
3166
-			return $this->generateOutput(false, array('Error: no permissions given'), false);
3167
-		}
3168
-	}
3169
-
3170
-/**
3171
-  * serverGroupClientList
3172
-  * 
3173
-  * Displays the IDs of all clients currently residing in the server group specified with sgid. If you're using the optional -names option, the output will also contain the last known nickname and the unique identifier of the clients.
3174
-  *
3175
-  * <b>Possible params:</b> -names
3176
-  *
3177
-  * <b>Output: (with -names param)</b>
3178
-  * <pre>
3179
-  * Array
3180
-  * {
3181
-  *  [cldbid] => 2017
3182
-  *  [client_nickname] => Par0noid //with -names parameter
3183
-  *  [client_unique_identifier] => nUixbsq/XakrrmbqU8O30R/D8Gc=
3184
-  * }
3185
-  * </pre>
3186
-  *
3187
-  * @author     Par0noid Solutions
3188
-  * @param		integer	$sgid		groupId
3189
-  * @param		boolean	$names		set true to add -names param [optional]
3190
-  * @return     multidimensional-array	serverGroupClientList
3191
-  */
3192
-	function serverGroupClientList($sgid, $names = false) {
3193
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
3194
-		if($names) { $names = ' -names'; }else{ $names = ''; }
3195
-		return $this->getData('multi', 'servergroupclientlist sgid='.$sgid.$names);
3196
-	}
3197
-
3198
-/**
3199
-  * serverGroupCopy
3200
-  * 
3201
-  * Creates a copy of the server group specified with ssgid. If tsgid is set to 0, the server will create a new group. To overwrite an existing group, simply set tsgid to the ID of a designated target group. If a target group is set, the name parameter will be ignored.
3202
-  *
3203
-  * <b>Output:</b>
3204
-  * <pre>
3205
-  * Array
3206
-  * {
3207
-  *  [sgid] => 86
3208
-  * }
3209
-  * </pre>
3210
-  *
3211
-  * @author     Par0noid Solutions
3212
-  * @param		integer	$ssgid	sourceGroupID
3213
-  * @param		integer	$tsgid	targetGroupID
3214
-  * @param		integer $name	groupName
3215
-  * @param		integer	$type	groupDbType (0 = template, 1 = normal, 2 = query | Default: 1)
3216
-  * @return     array groupId
3217
-  */
3218
-	function serverGroupCopy($ssgid, $tsgid, $name, $type = 1) {
3219
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
3220
-		return $this->getData('array', 'servergroupcopy ssgid='.$ssgid.' tsgid='.$tsgid.' name='.$this->escapeText($name).' type='.$type);
3221
-	}
3222
-
3223
-/**
3224
-  * serverGroupDelete
3225
-  * 
3226
-  * Deletes the server group specified with sgid. If force is set to 1, the server group will be deleted even if there are clients within.
3227
-  *
3228
-  * @author     Par0noid Solutions
3229
-  * @param		integer $sgid	serverGroupID
3230
-  * @param		integer $force 	forces deleting group (Default: 1)
3231
-  * @return     boolean success
3232
-  */
3233
-	function serverGroupDelete($sgid, $force = 1) {
3234
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
3235
-		return $this->getData('boolean', 'servergroupdel sgid='.$sgid.' force='.$force);
3236
-	}
3237
-
3238
-/**
3239
-  * serverGroupDeleteClient
3240
-  * 
3241
-  * Removes a client specified with cldbid from the server group specified with sgid.
3242
-  *
3243
-  * @author     Par0noid Solutions
3244
-  * @param		integer $sgid	groupID
3245
-  * @param		integer $cldbid	clientDBID
3246
-  * @return     boolean success
3247
-  */
3248
-	function serverGroupDeleteClient($sgid, $cldbid) {
3249
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
3250
-		return $this->getData('boolean', 'servergroupdelclient sgid='.$sgid.' cldbid='.$cldbid);
3251
-	}
3252
-
3253
-/**
3254
-  * serverGroupDeletePerm
3255
-  * 
3256
-  * Removes a set of specified permissions from the server group specified with sgid. Multiple permissions can be removed at once. A permission can be specified by permid or permsid.
3257
-  *
3258
-  * <b>Input-Array like this:</b>
3259
-  * <pre>
3260
-  * $permissions = array();
3261
-  * $permissions[] = 'permissionID';
3262
-  * //or you could use
3263
-  * $permissions[] = 'permissionName';
3264
-  * </pre>
3265
-  *
3266
-  * @author     Par0noid Solutions
3267
-  * @param		integer		$sgid				serverGroupID
3268
-  * @param		array		$permissionIds		permissionIds
3269
-  * @return     boolean success
3270
-  */
3271
-	function serverGroupDeletePerm($sgid, $permissionIds) {
3272
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
3273
-		$permissionArray = array();
3274
-		
3275
-		if(count($permissionIds) > 0) {
3276
-			foreach($permissionIds AS $value) {
3277
-				$permissionArray[] = is_numeric($value) ? 'permid='.$value : 'permsid='.$this->escapeText($value);
3278
-			}
3279
-			return $this->getData('boolean', 'servergroupdelperm sgid='.$sgid.' '.implode('|', $permissionArray));
3280
-		}else{
3281
-			$this->addDebugLog('no permissions given');
3282
-			return $this->generateOutput(false, array('Error: no permissions given'), false);
3283
-		}
3284
-	}
3285
-
3286
-/**
3287
-  * serverGroupList
3288
-  * 
3289
-  * Displays a list of server groups available. Depending on your permissions, the output may also contain global ServerQuery groups and template groups.
3290
-  *
3291
-  * <b>Output:</b>
3292
-  * <pre>
3293
-  * Array
3294
-  * {
3295
-  *  [sgid] => 1
3296
-  *  [name] => Guest Server Query
3297
-  *  [type] => 2
3298
-  *  [iconid] => 0
3299
-  *  [savedb] => 0
3300
-  * }
3301
-  * </pre>
3302
-  *
3303
-  * @author     Par0noid Solutions
3304
-  * @return     array serverGroupList
3305
-  */
3306
-	function serverGroupList() {
3307
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
3308
-		return $this->getData('multi', 'servergrouplist');
3309
-	}
3310
-
3311
-/**
3312
-  * serverGroupPermList
3313
-  * 
3314
-  * Displays a list of permissions assigned to the server group specified with sgid. If the permsid option is specified, the output will contain the permission names instead of the internal IDs.
3315
-  *
3316
-  * <b>Output:</b>
3317
-  * <pre>
3318
-  * Array
3319
-  * {
3320
-  *  [permid] => 12876 (if permsid = false)
3321
-  *  [permsid] => b_client_info_view (if permsid = true)
3322
-  *  [permvalue] => 1
3323
-  *  [permnegated] => 0
3324
-  *  [permskip] => 0
3325
-  * }
3326
-  * </pre>
3327
-  *
3328
-  * @author     Par0noid Solutions
3329
-  * @param		integer	$sgid		serverGroupID
3330
-  * @param		boolean	$permsid	set true to add -permsid param [optional]
3331
-  * @return     array serverGroupPermList
3332
-  */
3333
-	function serverGroupPermList($sgid, $permsid = false) {
3334
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
3335
-		if($permsid) { $additional = ' -permsid'; }else{ $additional = ''; }
3336
-		return $this->getData('multi', 'servergrouppermlist sgid='.$sgid.$additional);
3337
-	}
3338
-
3339
-/**
3340
-  * serverGroupRename
3341
-  * 
3342
-  * Changes the name of the server group specified with sgid.
3343
-  *
3344
-  * @author     Par0noid Solutions
3345
-  * @param		integer $sgid	serverGroupID
3346
-  * @param		integer $name	groupName
3347
-  * @return     boolean success
3348
-  */
3349
-	function serverGroupRename($sgid, $name) {
3350
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
3351
-		return $this->getData('boolean', 'servergrouprename sgid='.$sgid.' name='.$this->escapeText($name));
3352
-	}
3353
-
3354
-/**
3355
-  * serverGroupsByClientID
3356
-  * 
3357
-  * Displays all server groups the client specified with cldbid is currently residing in.
3358
-  *
3359
-  * <b>Output:</b>
3360
-  * <pre>
3361
-  * Array
3362
-  * {
3363
-  *  [name] => Guest
3364
-  *  [sgid] => 73
3365
-  *  [cldbid] => 2
3366
-  * }
3367
-  * </pre>
3368
-  *
3369
-  * @author     Par0noid Solutions
3370
-  * @param		integer	$cldbid	clientDBID
3371
-  * @return     array serverGroupsByClientId
3372
-  */
3373
-	function serverGroupsByClientID($cldbid) {
3374
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
3375
-		return $this->getData('multi', 'servergroupsbyclientid cldbid='.$cldbid);
3376
-	}
3377
-
3378
-/**
3379
-  * serverIdGetByPort
3380
-  * 
3381
-  * Displays the database ID of the virtual server running on the UDP port specified by virtualserver_port.
3382
-  * 
3383
-  * <b>Output:</b>
3384
-  * <pre>
3385
-  * Array
3386
-  * {
3387
-  *  [server_id] => 1
3388
-  * }
3389
-  * </pre>
3390
-  *
3391
-  * @author     Par0noid Solutions
3392
-  * @param		integer $port	serverPort
3393
-  * @return     array serverInfo
3394
-  */
3395
-	function serverIdGetByPort($port) {
3396
-		return $this->getData('array', 'serveridgetbyport virtualserver_port='.$port);
3397
-	}
3398
-
3399
-/**
3400
-  * serverInfo
3401
-  * 
3402
-  * Displays detailed configuration information about the selected virtual server including unique ID, number of clients online, configuration, etc.
3403
-  *	
3404
-  * <b>Output:</b>
3405
-  * <pre>
3406
-  * Array
3407
-  * {
3408
-  *  [virtualserver_unique_identifier] => 1GvKR12fg/mY75flwN/u7pn7KIs=
3409
-  *  [virtualserver_name] => TeamSpeak ]I[ Server
3410
-  *  [virtualserver_welcomemessage] => Welcome to TeamSpeak, check [URL]www.teamspeak.com[/URL] for latest information
3411
-  *  [virtualserver_platform] => Windows
3412
-  *  [virtualserver_version] => 3.0.12.4 [Build: 1461597405]
3413
-  *  [virtualserver_maxclients] => 32
3414
-  *  [virtualserver_password] => 
3415
-  *  [virtualserver_clientsonline] => 2
3416
-  *  [virtualserver_channelsonline] => 1
3417
-  *  [virtualserver_created] => 0
3418
-  *  [virtualserver_uptime] => 6517
3419
-  *  [virtualserver_codec_encryption_mode] => 0
3420
-  *  [virtualserver_hostmessage] => 
3421
-  *  [virtualserver_hostmessage_mode] => 0
3422
-  *  [virtualserver_filebase] => files\\virtualserver_1
3423
-  *  [virtualserver_default_server_group] => 11
3424
-  *  [virtualserver_default_channel_group] => 12
3425
-  *  [virtualserver_flag_password] => 0
3426
-  *  [virtualserver_default_channel_admin_group] => 9
3427
-  *  [virtualserver_max_download_total_bandwidth] => 18446744073709551615
3428
-  *  [virtualserver_max_upload_total_bandwidth] => 18446744073709551615
3429
-  *  [virtualserver_hostbanner_url] => 
3430
-  *  [virtualserver_hostbanner_gfx_url] => 
3431
-  *  [virtualserver_hostbanner_gfx_interval] => 0
3432
-  *  [virtualserver_complain_autoban_count] => 5
3433
-  *  [virtualserver_complain_autoban_time] => 1200
3434
-  *  [virtualserver_complain_remove_time] => 3600
3435
-  *  [virtualserver_min_clients_in_channel_before_forced_silence] => 100
3436
-  *  [virtualserver_priority_speaker_dimm_modificator] => -18.0000
3437
-  *  [virtualserver_id] => 1
3438
-  *  [virtualserver_antiflood_points_tick_reduce] => 5
3439
-  *  [virtualserver_antiflood_points_needed_command_block] => 150
3440
-  *  [virtualserver_antiflood_points_needed_ip_block] => 250
3441
-  *  [virtualserver_client_connections] => 1
3442
-  *  [virtualserver_query_client_connections] => 54
3443
-  *  [virtualserver_hostbutton_tooltip] => 
3444
-  *  [virtualserver_hostbutton_url] => 
3445
-  *  [virtualserver_hostbutton_gfx_url] => 
3446
-  *  [virtualserver_queryclientsonline] => 1
3447
-  *  [virtualserver_download_quota] => 18446744073709551615
3448
-  *  [virtualserver_upload_quota] => 18446744073709551615
3449
-  *  [virtualserver_month_bytes_downloaded] => 0
3450
-  *  [virtualserver_month_bytes_uploaded] => 16045
3451
-  *  [virtualserver_total_bytes_downloaded] => 0
3452
-  *  [virtualserver_total_bytes_uploaded] => 16045
3453
-  *  [virtualserver_port] => 9987
3454
-  *  [virtualserver_autostart] => 1
3455
-  *  [virtualserver_machine_id] => 
3456
-  *  [virtualserver_needed_identity_security_level] => 8
3457
-  *  [virtualserver_log_client] => 0
3458
-  *  [virtualserver_log_query] => 0
3459
-  *  [virtualserver_log_channel] => 0
3460
-  *  [virtualserver_log_permissions] => 1
3461
-  *  [virtualserver_log_server] => 0
3462
-  *  [virtualserver_log_filetransfer] => 0
3463
-  *  [virtualserver_min_client_version] => 1445512488
3464
-  *  [virtualserver_name_phonetic] => 
3465
-  *  [virtualserver_icon_id] => 0
3466
-  *  [virtualserver_reserved_slots] => 0
3467
-  *  [virtualserver_total_packetloss_speech] => 0.0000
3468
-  *  [virtualserver_total_packetloss_keepalive] => 0.0000
3469
-  *  [virtualserver_total_packetloss_control] => 0.0000
3470
-  *  [virtualserver_total_packetloss_total] => 0.0000
3471
-  *  [virtualserver_total_ping] => 0.0000
3472
-  *  [virtualserver_ip] => 
3473
-  *  [virtualserver_weblist_enabled] => 1
3474
-  *  [virtualserver_ask_for_privilegekey] => 0
3475
-  *  [virtualserver_hostbanner_mode] => 0
3476
-  *  [virtualserver_channel_temp_delete_delay_default] => 0
3477
-  *  [virtualserver_min_android_version] => 1407159763
3478
-  *  [virtualserver_min_ios_version] => 1407159763
3479
-  *  [virtualserver_status] => online
3480
-  *  [connection_filetransfer_bandwidth_sent] => 0
3481
-  *  [connection_filetransfer_bandwidth_received] => 0
3482
-  *  [connection_filetransfer_bytes_sent_total] => 0
3483
-  *  [connection_filetransfer_bytes_received_total] => 0
3484
-  *  [connection_packets_sent_speech] => 0
3485
-  *  [connection_bytes_sent_speech] => 0
3486
-  *  [connection_packets_received_speech] => 0
3487
-  *  [connection_bytes_received_speech] => 0
3488
-  *  [connection_packets_sent_keepalive] => 12959
3489
-  *  [connection_bytes_sent_keepalive] => 531319
3490
-  *  [connection_packets_received_keepalive] => 12959
3491
-  *  [connection_bytes_received_keepalive] => 544277
3492
-  *  [connection_packets_sent_control] => 396
3493
-  *  [connection_bytes_sent_control] => 65555
3494
-  *  [connection_packets_received_control] => 397
3495
-  *  [connection_bytes_received_control] => 44930
3496
-  *  [connection_packets_sent_total] => 13355
3497
-  *  [connection_bytes_sent_total] => 596874
3498
-  *  [connection_packets_received_total] => 13356
3499
-  *  [connection_bytes_received_total] => 589207
3500
-  *  [connection_bandwidth_sent_last_second_total] => 81
3501
-  *  [connection_bandwidth_sent_last_minute_total] => 92
3502
-  *  [connection_bandwidth_received_last_second_total] => 83
3503
-  *  [connection_bandwidth_received_last_minute_total] => 88
3504
-  * }
3505
-  * </pre>
3506
-  *
3507
-  * @author     Par0noid Solutions
3508
-  * @return     array serverInformation
3509
-  */
3510
-	function serverInfo() {
3511
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
3512
-		return $this->getData('array', 'serverinfo');
3513
-	}
3514
-
3515
-/**
3516
-  * serverList
3517
-  * 
3518
-  * Displays a list of virtual servers including their ID, status, number of clients online, etc. If you're using the -all option, the server will list all virtual servers stored in the database. This can be useful when multiple server instances with different machine IDs are using the same database. The machine ID is used to identify the server instance a virtual server is associated with. The status of a virtual server can be either online, offline, deploy running, booting up, shutting down and virtual online. While most of them are self-explanatory, virtual online is a bit more complicated. Please note that whenever you select a virtual server which is currently stopped, it will be started in virtual mode which means you are able to change its configuration, create channels or change permissions, but no regular TeamSpeak 3 Client can connect. As soon as the last ServerQuery client deselects the virtual server, its status will be changed back to offline.
3519
-  *
3520
-  * <b>Possible params:</b> [-uid] [-short] [-all] [-onlyoffline]
3521
-  *
3522
-  * <b>Output:</b>
3523
-  * <pre>
3524
-  * Array
3525
-  * {
3526
-  *  [virtualserver_id] => 1 //displayed on -short
3527
-  *  [virtualserver_port] => 9987 //displayed on -short
3528
-  *  [virtualserver_status] => online //displayed on -short
3529
-  *  [virtualserver_clientsonline] => 2
3530
-  *  [virtualserver_queryclientsonline] => 1
3531
-  *  [virtualserver_maxclients] => 32
3532
-  *  [virtualserver_uptime] => 3045
3533
-  *  [virtualserver_name] => TeamSpeak ]I[ Server
3534
-  *  [virtualserver_autostart] => 1
3535
-  *  [virtualserver_machine_id] =>
3536
-  *  [-uid] => [virtualserver_unique_identifier] => bYrybKl/APfKq7xzpIJ1Xb6C06U= 
3537
-  * }
3538
-  * </pre>
3539
-  *
3540
-  * @author     Par0noid Solutions
3541
-  * @param		string		$options		optional parameters
3542
-  * @return     array serverList
3543
-  */
3544
-	function serverList($options = NULL) {
3545
-		return $this->getData('multi', 'serverlist'.(!empty($options) ? ' '.$options : ''));
3546
-	}
3547
-
3548
-/**
3549
-  * serverProcessStop
3550
-  * 
3551
-  * Stops the entire TeamSpeak 3 Server instance by shutting down the process.
3552
-  *
3553
-  * @author     Par0noid Solutions
3554
-  * @return     boolean success
3555
-  */
3556
-	function serverProcessStop() {
3557
-		return $this->getData('boolean', 'serverprocessstop');
3558
-	}
3559
-
3560
-/**
3561
-  * serverRequestConnectionInfo
3562
-  * 
3563
-  * Displays detailed connection information about the selected virtual server including uptime, traffic information, etc.
3564
-  *
3565
-  * <b>Output:</b>
3566
-  * <pre>
3567
-  * Array
3568
-  * {
3569
-  *  [connection_filetransfer_bandwidth_sent] => 0
3570
-  *  [connection_filetransfer_bandwidth_received] => 0
3571
-  *  [connection_filetransfer_bytes_sent_total] => 0
3572
-  *  [connection_filetransfer_bytes_received_total] => 0
3573
-  *  [connection_packets_sent_total] => 3333
3574
-  *  [connection_bytes_sent_total] => 149687
3575
-  *  [connection_packets_received_total] => 3333
3576
-  *  [connection_bytes_received_total] => 147653
3577
-  *  [connection_bandwidth_sent_last_second_total] => 123
3578
-  *  [connection_bandwidth_sent_last_minute_total] => 81
3579
-  *  [connection_bandwidth_received_last_second_total] => 352
3580
-  *  [connection_bandwidth_received_last_minute_total] => 87
3581
-  *  [connection_connected_time] => 3387
3582
-  *  [connection_packetloss_total] => 0.0000
3583
-  *  [connection_ping] => 0.0000
3584
-  * }
3585
-  * </pre>
3586
-  *
3587
-  * @author     Par0noid Solutions
3588
-  * @return     array serverRequestConnectionInfo
3589
-  */
3590
-	function serverRequestConnectionInfo() {
3591
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
3592
-		return $this->getData('array', 'serverrequestconnectioninfo');
3593
-	}
3594
-
3595
-/**
3596
-  * serverSnapshotCreate
3597
-  * 
3598
-  * Displays a snapshot of the selected virtual server containing all settings, groups and known client identities. The data from a server snapshot can be used to restore a virtual servers configuration, channels and permissions using the serversnapshotdeploy command.
3599
-  *
3600
-  * @author     Par0noid Solutions
3601
-  * @return     string snapshot
3602
-  */
3603
-	function serverSnapshotCreate() {
3604
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
3605
-		return $this->getData('plain', 'serversnapshotcreate');
3606
-	}
3607
-
3608
-/**
3609
-  * serverSnapshotDeploy
3610
-  * 
3611
-  * Restores the selected virtual servers configuration using the data from a previously created server snapshot. Please note that the TeamSpeak 3 Server does NOT check for necessary permissions while deploying a snapshot so the command could be abused to gain additional privileges.
3612
-  *
3613
-  * + added "-mapping" to the serversnapshotdeploy command. This optional parameters will add a mapping of the old and new channelid's in the return
3614
-  *
3615
-  * @author     Par0noid Solutions
3616
-  * @param		string	$snapshot	snapshot
3617
-  * @param		bool	$mapping	mapping [optional]
3618
-  * @return     boolean success
3619
-  */
3620
-	function serverSnapshotDeploy($snapshot, $mapping = false) {
3621
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
3622
-		return $this->getData('boolean', 'serversnapshotdeploy '.($mapping ? '-mapping ' : '').$snapshot);
3623
-	}
3624
-	
3625
-/**
3626
-  * serverStart
3627
-  * 
3628
-  * Starts the virtual server specified with sid. Depending on your permissions, you're able to start either your own virtual server only or all virtual servers in the server instance.
3629
-  *
3630
-  * @author     Par0noid Solutions
3631
-  * @param		integer $sid	serverID
3632
-  * @return     boolean success
3633
-  */
3634
-	function serverStart($sid) {
3635
-		return $this->getdata('boolean', 'serverstart sid='.$sid);
3636
-	}	
3637
-
3638
-/**
3639
-  * serverStop
3640
-  * 
3641
-  * Stops the virtual server specified with sid. Depending on your permissions, you're able to stop either your own virtual server only or all virtual servers in the server instance.
3642
-  *
3643
-  * @author     Par0noid Solutions
3644
-  * @param		integer $sid	serverID
3645
-  * @return     boolean success
3646
-  */
3647
-	function serverStop($sid) {
3648
-		return $this->getdata('boolean', 'serverstop sid='.$sid);
3649
-	}
3650
-
3651
-/**
3652
-  * serverTemppasswordAdd
3653
-  * 
3654
-  * Sets a new temporary server password specified with pw. The temporary password will be valid for the number of seconds specified with duration. The client connecting with this password will automatically join the channel specified with tcid. If tcid is set to 0, the client will join the default channel.
3655
-  *
3656
-  * @author     Par0noid Solutions
3657
-  * @param		string	$pw				temporary password
3658
-  * @param		string	$duration		durations in seconds
3659
-  * @param		string	$desc			description [optional]
3660
-  * @param		string	$tcid			cid user enters on connect (0 = Default channel) [optional]
3661
-  * @param		string	$tcpw			channelPW
3662
-  * @return     boolean success
3663
-  */
3664
-	function serverTempPasswordAdd($pw, $duration, $desc = 'none', $tcid = 0, $tcpw = null) {
3665
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
3666
-		return $this->getdata('boolean', 'servertemppasswordadd pw='.$this->escapeText($pw).' desc='.(!empty($desc) ? $this->escapeText($desc) : 'none').' duration='.$duration.' tcid='.$tcid.(!empty($tcpw) ? ' tcpw='.$this->escapeText($tcpw) : ''));
3667
-	}
3668
-
3669
-/**
3670
-  * serverTemppasswordDel
3671
-  * 
3672
-  * Deletes the temporary server password specified with pw.
3673
-  * 
3674
-  * @author     Par0noid Solutions
3675
-  * @param		string	$pw		temporary password
3676
-  * @return     boolean success
3677
-  */	
3678
-	function serverTempPasswordDel($pw) {
3679
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
3680
-		return $this->getdata('boolean', 'servertemppassworddel pw='.$this->escapeText($pw));
3681
-	}
3682
-
3683
-/**
3684
-  * serverTemppasswordList
3685
-  * 
3686
-  * Returns a list of active temporary server passwords. The output contains the clear-text password, the nickname and unique identifier of the creating client.
3687
-  *
3688
-  * <b>Output:</b>
3689
-  * <pre>
3690
-  * Array
3691
-  * {
3692
-  *  [nickname] => serveradmin
3693
-  *  [uid] => 1
3694
-  *  [desc] => none
3695
-  *  [pw_clear] => test
3696
-  *  [start] => 1334996838
3697
-  *  [end] => 1335000438
3698
-  *  [tcid] => 0
3699
-  * }
3700
-  * </pre>
3701
-  *
3702
-  * @author     Par0noid Solutions
3703
-  * @return     array	serverTemppasswordList
3704
-  */
3705
-	function serverTempPasswordList() {
3706
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
3707
-		return $this->getData('multi', 'servertemppasswordlist');
3708
-	}
3709
-	
3825
+ * tokenUse
3826
+ * 
3827
+ * Use a token key gain access to a server or channel group. Please note that the server will automatically delete the token after it has been used.
3828
+ *
3829
+ * @author     Par0noid Solutions
3830
+ * @param		string	$token	token
3831
+ * @return     boolean success
3832
+ */
3833
+    function tokenUse($token) {
3834
+        if(!$this->runtime['selected']) { return $this->checkSelected(); }			
3835
+        return $this->getData('boolean', 'privilegekeyuse token='.$token);
3836
+    }
3710 3837
 
3711 3838
 /**
3712
-  *	setClientChannelGroup
3713
-  *
3714
-  * Sets the channel group of a client to the ID specified with cgid.
3715
-  *
3716
-  * @author     Par0noid Solutions
3717
-  * @param		integer $cgid	groupID
3718
-  * @param		integer $cid	channelID
3719
-  * @param		integer $cldbid	clientDBID
3720
-  * @return     boolean success
3721
-  */
3722
-	function setClientChannelGroup($cgid, $cid, $cldbid) {
3723
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
3724
-		return $this->getData('boolean', 'setclientchannelgroup cgid='.$cgid.' cid='.$cid.' cldbid='.$cldbid);
3725
-	}
3726
-
3727
-/**
3728
-  * setName
3729
-  * 
3730
-  * Sets your nickname in server query
3731
-  *
3732
-  * @author     Par0noid Solutions
3733
-  * @param		string	$newName	new name in server query
3734
-  * @return     boolean success
3735
-  */
3736
-	function setName($newName) {
3737
-		return $this->getData('boolean', 'clientupdate client_nickname='.$this->escapeText($newName));
3738
-	}
3739
-
3740
-/**
3741
-  * tokenAdd
3742
-  * 
3743
-  * Create a new token. If tokentype is set to 0, the ID specified with tokenid1 will be a server group ID. Otherwise, tokenid1 is used as a channel group ID and you need to provide a valid channel ID using tokenid2. The tokencustomset parameter allows you to specify a set of custom client properties. This feature can be used when generating tokens to combine a website account database with a TeamSpeak user. The syntax of the value needs to be escaped using the ServerQuery escape patterns and has to follow the general syntax of:
3744
-  * ident=ident1 value=value1|ident=ident2 value=value2|ident=ident3 value=value3
3745
-  *
3746
-  * <b>Input-Array like this:</b>
3747
-  * <pre>
3748
-  * $customFieldSet = array();
3749
-  *	
3750
-  * $customFieldSet['ident'] = 'value';
3751
-  * $customFieldSet['ident'] = 'value';
3752
-  * </pre>
3753
-  *
3754
-  * @author     Par0noid Solutions
3755
-  * @param		integer	$tokentype				token type
3756
-  * @param		integer	$tokenid1				groupID
3757
-  * @param		integer	$tokenid2				channelID
3758
-  * @param		string	$description			token description [optional]
3759
-  * @param		array	$customFieldSet			customFieldSet [optional]
3760
-  * @return     array	tokenInformation
3761
-  */
3762
-	function tokenAdd($tokentype, $tokenid1, $tokenid2, $description ='', $customFieldSet = array()) {
3763
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
3764
-		
3765
-		if(!empty($description)) { $description = ' tokendescription=' . $this->escapeText($description); }
3839
+ * version
3840
+ * 
3841
+ * Displays the servers version information including platform and build number.
3842
+ *
3843
+ * <b>Output:</b>
3844
+ * <pre>
3845
+ * Array
3846
+ * {
3847
+ *  [version] => 3.0.6.1
3848
+ *  [build] => 1340956745
3849
+ *  [platform] => Windows
3850
+ * }
3851
+ * </pre>
3852
+ *
3853
+ * @author     Par0noid Solutions
3854
+ * @return     array versionInformation
3855
+ */
3856
+    function version() {
3857
+        return $this->getData('array', 'version');
3858
+    }
3766 3859
 
3767
-		if($tokentype == '0') { $tokenid2 = '0'; }
3768
-		
3769
-		if(count($customFieldSet)) {
3770
-			$settingsString = array();
3771
-		
3772
-			foreach($customFieldSet as $key => $value) {
3773
-				$settingsString[] = 'ident='.$this->escapeText($key).'\svalue='.$this->escapeText($value);
3774
-			}
3775
-			
3776
-			$customFieldSet = ' tokencustomset='.implode('\p', $settingsString);
3777
-		}else{
3778
-			$customFieldSet = '';
3779
-		}
3780
-		
3781
-		return $this->getData('array', 'privilegekeyadd tokentype='.$tokentype.' tokenid1='.$tokenid1.' tokenid2='.$tokenid2.$description.$customFieldSet);
3782
-	}
3783
-
3784
-/**
3785
-  * tokenDelete
3786
-  * 
3787
-  * Deletes an existing token matching the token key specified with token.
3788
-  *
3789
-  * @author     Par0noid Solutions
3790
-  * @param		string	$token	token
3791
-  * @return     boolean success
3792
-  */
3793
-	function tokenDelete($token) {
3794
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }			
3795
-		return $this->getData('boolean', 'privilegekeydelete token='.$token);
3796
-	}
3797
-
3798
-/**
3799
-  * tokenList
3800
-  * 
3801
-  * Displays a list of privilege keys available including their type and group IDs. Tokens can be used to gain access to specified server or channel groups. A privilege key is similar to a client with administrator privileges that adds you to a certain permission group, but without the necessity of a such a client with administrator privileges to actually exist. It is a long (random looking) string that can be used as a ticket into a specific server group.
3802
-  *
3803
-  * <b>Output:</b>
3804
-  * <pre>
3805
-  * Array
3806
-  * {
3807
-  *  [token] => GdqedxSEDle3e9+LtR3o9dO09bURH+vymvF5hOJg
3808
-  *  [token_type] => 0
3809
-  *  [token_id1] => 71
3810
-  *  [token_id2] => 0
3811
-  *  [token_created] => 1286625908
3812
-  *  [token_description] => for you
3813
-  * }
3814
-  * </pre>
3815
-  *
3816
-  * @author     Par0noid Solutions
3817
-  * @return     array tokenListist 
3818
-  */
3819
-	function tokenList() {
3820
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
3821
-
3822
-		return $this->getData('multi', 'privilegekeylist');
3823
-	}
3824
-
3825
-/**
3826
-  * tokenUse
3827
-  * 
3828
-  * Use a token key gain access to a server or channel group. Please note that the server will automatically delete the token after it has been used.
3829
-  *
3830
-  * @author     Par0noid Solutions
3831
-  * @param		string	$token	token
3832
-  * @return     boolean success
3833
-  */
3834
-	function tokenUse($token) {
3835
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }			
3836
-		return $this->getData('boolean', 'privilegekeyuse token='.$token);
3837
-	}
3838
-
3839
-/**
3840
-  * version
3841
-  * 
3842
-  * Displays the servers version information including platform and build number.
3843
-  *
3844
-  * <b>Output:</b>
3845
-  * <pre>
3846
-  * Array
3847
-  * {
3848
-  *  [version] => 3.0.6.1
3849
-  *  [build] => 1340956745
3850
-  *  [platform] => Windows
3851
-  * }
3852
-  * </pre>
3853
-  *
3854
-  * @author     Par0noid Solutions
3855
-  * @return     array versionInformation
3856
-  */
3857
-	function version() {
3858
-		return $this->getData('array', 'version');
3859
-	}
3860
-
3861
-/**
3862
-  * whoAmI
3863
-  * 
3864
-  * Displays information about your current ServerQuery connection including your loginname, etc.
3865
-  *
3866
-  * <b>Output:</b>
3867
-  * <pre>
3868
-  * Array
3869
-  * {
3870
-  *  [virtualserver_status] => online
3871
-  *  [virtualserver_id] => 1
3872
-  *  [virtualserver_unique_identifier] => bYrybKl/APfKq7xzpIJ1Xb6C06U=
3873
-  *  [virtualserver_port] => 9987
3874
-  *  [client_id] => 5
3875
-  *  [client_channel_id] => 1
3876
-  *  [client_nickname] => serveradmin from 127.0.0.1:15208
3877
-  *  [client_database_id] => 1
3878
-  *  [client_login_name] => serveradmin
3879
-  *  [client_unique_identifier] => serveradmin
3880
-  *  [client_origin_server_id] => 0
3881
-  * }
3882
-  * </pre>
3883
-  *
3884
-  * @author     Par0noid Solutions
3885
-  * @return     array clientinformation
3886
-  */
3887
-	function whoAmI() {
3888
-		return $this->getData('array', 'whoami');
3889
-	}
3860
+/**
3861
+ * whoAmI
3862
+ * 
3863
+ * Displays information about your current ServerQuery connection including your loginname, etc.
3864
+ *
3865
+ * <b>Output:</b>
3866
+ * <pre>
3867
+ * Array
3868
+ * {
3869
+ *  [virtualserver_status] => online
3870
+ *  [virtualserver_id] => 1
3871
+ *  [virtualserver_unique_identifier] => bYrybKl/APfKq7xzpIJ1Xb6C06U=
3872
+ *  [virtualserver_port] => 9987
3873
+ *  [client_id] => 5
3874
+ *  [client_channel_id] => 1
3875
+ *  [client_nickname] => serveradmin from 127.0.0.1:15208
3876
+ *  [client_database_id] => 1
3877
+ *  [client_login_name] => serveradmin
3878
+ *  [client_unique_identifier] => serveradmin
3879
+ *  [client_origin_server_id] => 0
3880
+ * }
3881
+ * </pre>
3882
+ *
3883
+ * @author     Par0noid Solutions
3884
+ * @return     array clientinformation
3885
+ */
3886
+    function whoAmI() {
3887
+        return $this->getData('array', 'whoami');
3888
+    }
3890 3889
 
3891 3890
 //*******************************************************************************************	
3892 3891
 //************************************ Helper Functions ************************************
3893 3892
 //*******************************************************************************************
3894 3893
 
3895 3894
 /**
3896
-  * checkSelected throws out 2 errors
3897
-  *
3898
-  * <b>Output:</b>
3899
-  * <pre>
3900
-  * Array
3901
-  * {
3902
-  *  [success] => false
3903
-  *  [errors] => Array 
3904
-  *  [data] => false
3905
-  * }
3906
-  * </pre>
3907
-  *
3908
-  * @author     Par0noid Solutions
3909
-  * @return     array error
3910
-  */
3911
-	private function checkSelected() {
3912
-		$backtrace = debug_backtrace();
3913
-		$this->addDebugLog('you can\'t use this function if no server is selected', $backtrace[1]['function'], $backtrace[0]['line']);
3914
-		return $this->generateOutput(false, array('you can\'t use this function if no server is selected'), false);
3915
-	}
3916
-
3917
-/**
3918
-  * convertSecondsToStrTime
3919
-  * 
3920
-  * Converts seconds to a strTime (bsp. 5d 1h 23m 19s)
3921
-  *
3922
-  * @author     Par0noid Solutions
3923
-  * @param		integer	$seconds	time in seconds
3924
-  * @return     string strTime
3925
-  */
3926
- 	public function convertSecondsToStrTime($seconds) {
3927
-		$conv_time = $this->convertSecondsToArrayTime($seconds);
3928
-    	return $conv_time['days'].'d '.$conv_time['hours'].'h '.$conv_time['minutes'].'m '.$conv_time['seconds'].'s';
3929
-	}
3930
-
3931
-/**
3932
-  * convertSecondsToArrayTime
3933
-  * 
3934
-  * Converts seconds to a array: time
3935
-  *
3936
-  * <b>Output:</b>
3937
-  * <pre>
3938
-  * Array
3939
-  * {
3940
-  *  [days] => 3
3941
-  *  [hours] => 9
3942
-  *  [minutes] => 45
3943
-  *  [seconds] => 17
3944
-  * }
3945
-  * </pre>
3946
-  *
3947
-  * @author     Par0noid Solutions
3948
-  * @param		integer	$seconds	time in seconds
3949
-  * @return     array time
3950
-  */
3951
- 	public function convertSecondsToArrayTime($seconds) {
3952
-		$conv_time = array();
3953
-		$conv_time['days']=floor($seconds / 86400);
3954
-		$conv_time['hours']=floor(($seconds - ($conv_time['days'] * 86400)) / 3600);
3955
-		$conv_time['minutes']=floor(($seconds - (($conv_time['days'] * 86400)+($conv_time['hours']*3600))) / 60);
3956
-		$conv_time['seconds']=floor(($seconds - (($conv_time['days'] * 86400)+($conv_time['hours']*3600)+($conv_time['minutes'] * 60))));
3957
-		return $conv_time;
3958
-	}
3959
-
3960
-/**
3961
-  * getElement
3962
-  * 
3963
-  * Returns the given associated element from an array
3964
-  * This can be used to get a result in a one line operation
3965
-  * 
3966
-  * For example you got this array:
3967
-  * <pre>
3968
-  * Array
3969
-  * {
3970
-  *  [success] => false
3971
-  *  [errors] => Array 
3972
-  *  [data] => false
3973
-  * }
3974
-  * </pre>
3975
-  * Now you can grab the element like this:
3976
-  * <pre>
3977
-  * $ts = new ts3admin('***', '***');
3978
-  * 
3979
-  * if($ts->getElement('success', $ts->connect())) {
3980
-  *  //operation
3981
-  * }
3982
-  * </pre>
3983
-  *
3984
-  * @author     Par0noid Solutions
3985
-  * @param		string	$element	key of element
3986
-  * @param		array	$array		array
3987
-  * @return     mixed
3988
-  */
3989
-	public function getElement($element, $array) {
3990
-		return $array[$element];
3991
-	}
3992
-
3993
-/**
3994
-  * succeeded
3995
-  * 
3996
-  * Succeeded will check the success element of a return array
3997
-  * <pre>
3998
-  * $ts = new ts3admin('***', '***');
3999
-  * 
4000
-  * if($ts->succeeded($ts->connect())) {
4001
-  *  //operation
4002
-  * }
4003
-  * </pre>
4004
-  *
4005
-  * @author     Par0noid Solutions
4006
-  * @param		array	$array	result
4007
-  * @return     boolean
4008
-  */
4009
-	public function succeeded($array) {
4010
-		if(isset($array['success'])) {
4011
-			return $array['success'];
4012
-		}else{
4013
-			return false;
4014
-		}
4015
-	}
3895
+ * checkSelected throws out 2 errors
3896
+ *
3897
+ * <b>Output:</b>
3898
+ * <pre>
3899
+ * Array
3900
+ * {
3901
+ *  [success] => false
3902
+ *  [errors] => Array 
3903
+ *  [data] => false
3904
+ * }
3905
+ * </pre>
3906
+ *
3907
+ * @author     Par0noid Solutions
3908
+ * @return     array error
3909
+ */
3910
+    private function checkSelected() {
3911
+        $backtrace = debug_backtrace();
3912
+        $this->addDebugLog('you can\'t use this function if no server is selected', $backtrace[1]['function'], $backtrace[0]['line']);
3913
+        return $this->generateOutput(false, array('you can\'t use this function if no server is selected'), false);
3914
+    }
3915
+
3916
+/**
3917
+ * convertSecondsToStrTime
3918
+ * 
3919
+ * Converts seconds to a strTime (bsp. 5d 1h 23m 19s)
3920
+ *
3921
+ * @author     Par0noid Solutions
3922
+ * @param		integer	$seconds	time in seconds
3923
+ * @return     string strTime
3924
+ */
3925
+        public function convertSecondsToStrTime($seconds) {
3926
+        $conv_time = $this->convertSecondsToArrayTime($seconds);
3927
+        return $conv_time['days'].'d '.$conv_time['hours'].'h '.$conv_time['minutes'].'m '.$conv_time['seconds'].'s';
3928
+    }
3929
+
3930
+/**
3931
+ * convertSecondsToArrayTime
3932
+ * 
3933
+ * Converts seconds to a array: time
3934
+ *
3935
+ * <b>Output:</b>
3936
+ * <pre>
3937
+ * Array
3938
+ * {
3939
+ *  [days] => 3
3940
+ *  [hours] => 9
3941
+ *  [minutes] => 45
3942
+ *  [seconds] => 17
3943
+ * }
3944
+ * </pre>
3945
+ *
3946
+ * @author     Par0noid Solutions
3947
+ * @param		integer	$seconds	time in seconds
3948
+ * @return     array time
3949
+ */
3950
+        public function convertSecondsToArrayTime($seconds) {
3951
+        $conv_time = array();
3952
+        $conv_time['days']=floor($seconds / 86400);
3953
+        $conv_time['hours']=floor(($seconds - ($conv_time['days'] * 86400)) / 3600);
3954
+        $conv_time['minutes']=floor(($seconds - (($conv_time['days'] * 86400)+($conv_time['hours']*3600))) / 60);
3955
+        $conv_time['seconds']=floor(($seconds - (($conv_time['days'] * 86400)+($conv_time['hours']*3600)+($conv_time['minutes'] * 60))));
3956
+        return $conv_time;
3957
+    }
3958
+
3959
+/**
3960
+ * getElement
3961
+ * 
3962
+ * Returns the given associated element from an array
3963
+ * This can be used to get a result in a one line operation
3964
+ * 
3965
+ * For example you got this array:
3966
+ * <pre>
3967
+ * Array
3968
+ * {
3969
+ *  [success] => false
3970
+ *  [errors] => Array 
3971
+ *  [data] => false
3972
+ * }
3973
+ * </pre>
3974
+ * Now you can grab the element like this:
3975
+ * <pre>
3976
+ * $ts = new ts3admin('***', '***');
3977
+ * 
3978
+ * if($ts->getElement('success', $ts->connect())) {
3979
+ *  //operation
3980
+ * }
3981
+ * </pre>
3982
+ *
3983
+ * @author     Par0noid Solutions
3984
+ * @param		string	$element	key of element
3985
+ * @param		array	$array		array
3986
+ * @return     mixed
3987
+ */
3988
+    public function getElement($element, $array) {
3989
+        return $array[$element];
3990
+    }
3991
+
3992
+/**
3993
+ * succeeded
3994
+ * 
3995
+ * Succeeded will check the success element of a return array
3996
+ * <pre>
3997
+ * $ts = new ts3admin('***', '***');
3998
+ * 
3999
+ * if($ts->succeeded($ts->connect())) {
4000
+ *  //operation
4001
+ * }
4002
+ * </pre>
4003
+ *
4004
+ * @author     Par0noid Solutions
4005
+ * @param		array	$array	result
4006
+ * @return     boolean
4007
+ */
4008
+    public function succeeded($array) {
4009
+        if(isset($array['success'])) {
4010
+            return $array['success'];
4011
+        }else{
4012
+            return false;
4013
+        }
4014
+    }
4016 4015
 	
4017 4016
 	
4018 4017
 
@@ -4029,19 +4028,19 @@  discard block
 block discarded – undo
4029 4028
  * @param	integer	$timeout	socket timeout (default = 2) [optional]
4030 4029
  * @return	void
4031 4030
 */
4032
-	function __construct($host, $queryport, $timeout = 2) {
4033
-		if($queryport >= 1 and $queryport <= 65536) {
4034
-			if($timeout >= 1) {
4035
-				$this->runtime['host'] = $host;
4036
-				$this->runtime['queryport'] = $queryport;
4037
-				$this->runtime['timeout'] = $timeout;
4038
-			}else{
4039
-				$this->addDebugLog('invalid timeout value');
4040
-			}
4041
-		}else{
4042
-			$this->addDebugLog('invalid queryport');
4043
-		}
4044
-	}
4031
+    function __construct($host, $queryport, $timeout = 2) {
4032
+        if($queryport >= 1 and $queryport <= 65536) {
4033
+            if($timeout >= 1) {
4034
+                $this->runtime['host'] = $host;
4035
+                $this->runtime['queryport'] = $queryport;
4036
+                $this->runtime['timeout'] = $timeout;
4037
+            }else{
4038
+                $this->addDebugLog('invalid timeout value');
4039
+            }
4040
+        }else{
4041
+            $this->addDebugLog('invalid queryport');
4042
+        }
4043
+    }
4045 4044
 
4046 4045
 /**
4047 4046
  * __destruct
@@ -4049,9 +4048,9 @@  discard block
 block discarded – undo
4049 4048
  * @author	Par0noid Solutions
4050 4049
  * @return	void
4051 4050
 */
4052
-	function __destruct() {
4053
-		$this->quit();
4054
-	}
4051
+    function __destruct() {
4052
+        $this->quit();
4053
+    }
4055 4054
 
4056 4055
 /**
4057 4056
  * __call
@@ -4063,181 +4062,181 @@  discard block
 block discarded – undo
4063 4062
  * @param	array	$args	method arguments
4064 4063
  * @return	void
4065 4064
 */
4066
-	function __call($name, $args) {
4067
-		$this->addDebugLog('Method '.$name.' doesn\'t exist', $name, 0);
4068
-		return $this->generateOutput(false, array('Method '.$name.' doesn\'t exist'), false);
4069
-	}
4070
-
4071
-/**
4072
-  * isConnected
4073
-  * 
4074
-  * Checks if the connection is established
4075
-  *
4076
-  * @author     Par0noid Solutions
4077
-  * @return     boolean connected
4078
-  */
4079
-	private function isConnected() {
4080
-		if(empty($this->runtime['socket'])) {
4081
-			return false;
4082
-		}else{
4083
-			return true;
4084
-		}
4085
-	}
4086
-
4087
-/**
4088
-  * generateOutput
4089
-  * 
4090
-  * Builds a method return as array
4091
-  *
4092
-  * @author     Par0noid Solutions
4093
-  * @param		boolean		$success	true/false
4094
-  * @param		array		$errors		all errors which occured while executing a method
4095
-  * @param		mixed		$data		parsed data from server
4096
-  * @return     array output
4097
-  */
4098
-	private function generateOutput($success, $errors, $data) {
4099
-		return array('success' => $success, 'errors' => $errors, 'data' => $data);
4100
-	}
4101
-
4102
-/**
4103
-  * unEscapeText
4104
-  * 
4105
-  * Turns escaped chars to normals
4106
-  *
4107
-  * @author     Par0noid Solutions
4108
-  * @param		string	$text	text which should be escaped
4109
-  * @return     string	text
4110
-  */
4111
- 	private function unEscapeText($text) {
4112
- 		$escapedChars = array("\t", "\v", "\r", "\n", "\f", "\s", "\p", "\/");
4113
- 		$unEscapedChars = array('', '', '', '', '', ' ', '|', '/');
4114
-		$text = str_replace($escapedChars, $unEscapedChars, $text);
4115
-		return $text;
4116
-	}
4117
-
4118
-/**
4119
-  * escapeText
4120
-  * 
4121
-  * Escapes chars that we can use it in the query
4122
-  *
4123
-  * @author     Par0noid Solutions
4124
-  * @param		string	$text	text which should be escaped
4125
-  * @return     string	text
4126
-  */
4127
- 	private function escapeText($text) {
4128
- 		$text = str_replace("\t", '\t', $text);
4129
-		$text = str_replace("\v", '\v', $text);
4130
-		$text = str_replace("\r", '\r', $text);
4131
-		$text = str_replace("\n", '\n', $text);
4132
-		$text = str_replace("\f", '\f', $text);
4133
-		$text = str_replace(' ', '\s', $text);
4134
-		$text = str_replace('|', '\p', $text);
4135
-		$text = str_replace('/', '\/', $text);
4136
-		return $text;
4137
-	}
4138
-
4139
-/**
4140
-  * splitBanIds
4141
-  * 
4142
-  * Splits banIds to array
4143
-  *
4144
-  * @author     Par0noid Solutions
4145
-  * @param		string	$text	plain text server response
4146
-  * @return     string	text
4147
-  */
4148
- 	private function splitBanIds($text) {
4149
-		$data = array();
4150
-		$text = str_replace(array("\n", "\r"), '', $text);
4151
-		$ids = explode("banid=", $text);
4152
-		unset($ids[0]);
4153
-		return $ids;
4154
-	}
4065
+    function __call($name, $args) {
4066
+        $this->addDebugLog('Method '.$name.' doesn\'t exist', $name, 0);
4067
+        return $this->generateOutput(false, array('Method '.$name.' doesn\'t exist'), false);
4068
+    }
4069
+
4070
+/**
4071
+ * isConnected
4072
+ * 
4073
+ * Checks if the connection is established
4074
+ *
4075
+ * @author     Par0noid Solutions
4076
+ * @return     boolean connected
4077
+ */
4078
+    private function isConnected() {
4079
+        if(empty($this->runtime['socket'])) {
4080
+            return false;
4081
+        }else{
4082
+            return true;
4083
+        }
4084
+    }
4085
+
4086
+/**
4087
+ * generateOutput
4088
+ * 
4089
+ * Builds a method return as array
4090
+ *
4091
+ * @author     Par0noid Solutions
4092
+ * @param		boolean		$success	true/false
4093
+ * @param		array		$errors		all errors which occured while executing a method
4094
+ * @param		mixed		$data		parsed data from server
4095
+ * @return     array output
4096
+ */
4097
+    private function generateOutput($success, $errors, $data) {
4098
+        return array('success' => $success, 'errors' => $errors, 'data' => $data);
4099
+    }
4100
+
4101
+/**
4102
+ * unEscapeText
4103
+ * 
4104
+ * Turns escaped chars to normals
4105
+ *
4106
+ * @author     Par0noid Solutions
4107
+ * @param		string	$text	text which should be escaped
4108
+ * @return     string	text
4109
+ */
4110
+        private function unEscapeText($text) {
4111
+            $escapedChars = array("\t", "\v", "\r", "\n", "\f", "\s", "\p", "\/");
4112
+            $unEscapedChars = array('', '', '', '', '', ' ', '|', '/');
4113
+        $text = str_replace($escapedChars, $unEscapedChars, $text);
4114
+        return $text;
4115
+    }
4116
+
4117
+/**
4118
+ * escapeText
4119
+ * 
4120
+ * Escapes chars that we can use it in the query
4121
+ *
4122
+ * @author     Par0noid Solutions
4123
+ * @param		string	$text	text which should be escaped
4124
+ * @return     string	text
4125
+ */
4126
+        private function escapeText($text) {
4127
+            $text = str_replace("\t", '\t', $text);
4128
+        $text = str_replace("\v", '\v', $text);
4129
+        $text = str_replace("\r", '\r', $text);
4130
+        $text = str_replace("\n", '\n', $text);
4131
+        $text = str_replace("\f", '\f', $text);
4132
+        $text = str_replace(' ', '\s', $text);
4133
+        $text = str_replace('|', '\p', $text);
4134
+        $text = str_replace('/', '\/', $text);
4135
+        return $text;
4136
+    }
4137
+
4138
+/**
4139
+ * splitBanIds
4140
+ * 
4141
+ * Splits banIds to array
4142
+ *
4143
+ * @author     Par0noid Solutions
4144
+ * @param		string	$text	plain text server response
4145
+ * @return     string	text
4146
+ */
4147
+        private function splitBanIds($text) {
4148
+        $data = array();
4149
+        $text = str_replace(array("\n", "\r"), '', $text);
4150
+        $ids = explode("banid=", $text);
4151
+        unset($ids[0]);
4152
+        return $ids;
4153
+    }
4155 4154
 
4156 4155
 //*******************************************************************************************	
4157 4156
 //************************************ Network Functions ************************************
4158 4157
 //*******************************************************************************************
4159 4158
 
4160 4159
 /**
4161
-  * connect
4162
-  * 
4163
-  * Connects to a ts3instance query port
4164
-  *
4165
-  * @author     Par0noid Solutions
4166
-  * @return		boolean success
4167
-  */
4168
-	function connect() {
4169
-		if($this->isConnected()) { 
4170
-			$this->addDebugLog('Error: you are already connected!');
4171
-			return $this->generateOutput(false, array('Error: the script is already connected!'), false);
4172
-		}
4173
-		$socket = @fsockopen($this->runtime['host'], $this->runtime['queryport'], $errnum, $errstr, $this->runtime['timeout']);
4174
-
4175
-		if(!$socket) {
4176
-			$this->addDebugLog('Error: connection failed!');
4177
-			return $this->generateOutput(false, array('Error: connection failed!', 'Server returns: '.$errstr), false);
4178
-		}else{
4179
-			if(strpos(fgets($socket), 'TS3') !== false) {
4180
-				$tmpVar = fgets($socket);
4181
-				$this->runtime['socket'] = $socket;
4182
-				return $this->generateOutput(true, array(), true);
4183
-			}else{
4184
-				$this->addDebugLog('host isn\'t a ts3 instance!');
4185
-				return $this->generateOutput(false, array('Error: host isn\'t a ts3 instance!'), false);
4186
-			}
4187
-		}
4188
-	}
4189
-
4190
-/**
4191
-  * executeCommand
4192
-  * 
4193
-  * Executes a command and fetches the response
4194
-  *
4195
-  * @author     Par0noid Solutions
4196
-  * @param		string	$command	command which should be executed
4197
-  * @param		array	$tracert	array with information from first exec
4198
-  * @return     mixed data
4199
-  */
4200
-	private function executeCommand($command, $tracert) {
4201
-		if(!$this->isConnected()) {
4202
-			$this->addDebugLog('script isn\'t connected to server', $tracert[1]['function'], $tracert[0]['line']);
4203
-			return $this->generateOutput(false, array('Error: script isn\'t connected to server'), false);
4204
-		}
4160
+ * connect
4161
+ * 
4162
+ * Connects to a ts3instance query port
4163
+ *
4164
+ * @author     Par0noid Solutions
4165
+ * @return		boolean success
4166
+ */
4167
+    function connect() {
4168
+        if($this->isConnected()) { 
4169
+            $this->addDebugLog('Error: you are already connected!');
4170
+            return $this->generateOutput(false, array('Error: the script is already connected!'), false);
4171
+        }
4172
+        $socket = @fsockopen($this->runtime['host'], $this->runtime['queryport'], $errnum, $errstr, $this->runtime['timeout']);
4173
+
4174
+        if(!$socket) {
4175
+            $this->addDebugLog('Error: connection failed!');
4176
+            return $this->generateOutput(false, array('Error: connection failed!', 'Server returns: '.$errstr), false);
4177
+        }else{
4178
+            if(strpos(fgets($socket), 'TS3') !== false) {
4179
+                $tmpVar = fgets($socket);
4180
+                $this->runtime['socket'] = $socket;
4181
+                return $this->generateOutput(true, array(), true);
4182
+            }else{
4183
+                $this->addDebugLog('host isn\'t a ts3 instance!');
4184
+                return $this->generateOutput(false, array('Error: host isn\'t a ts3 instance!'), false);
4185
+            }
4186
+        }
4187
+    }
4188
+
4189
+/**
4190
+ * executeCommand
4191
+ * 
4192
+ * Executes a command and fetches the response
4193
+ *
4194
+ * @author     Par0noid Solutions
4195
+ * @param		string	$command	command which should be executed
4196
+ * @param		array	$tracert	array with information from first exec
4197
+ * @return     mixed data
4198
+ */
4199
+    private function executeCommand($command, $tracert) {
4200
+        if(!$this->isConnected()) {
4201
+            $this->addDebugLog('script isn\'t connected to server', $tracert[1]['function'], $tracert[0]['line']);
4202
+            return $this->generateOutput(false, array('Error: script isn\'t connected to server'), false);
4203
+        }
4205 4204
 		
4206
-		$data = '';
4205
+        $data = '';
4207 4206
 
4208 4207
 		
4209
-		$splittedCommand = str_split($command, 1024);
4208
+        $splittedCommand = str_split($command, 1024);
4210 4209
 		
4211
-		$splittedCommand[(count($splittedCommand) - 1)] .= "\n";
4210
+        $splittedCommand[(count($splittedCommand) - 1)] .= "\n";
4212 4211
 		
4213
-		foreach($splittedCommand as $commandPart) {
4214
-			fputs($this->runtime['socket'], $commandPart);
4215
-		}
4212
+        foreach($splittedCommand as $commandPart) {
4213
+            fputs($this->runtime['socket'], $commandPart);
4214
+        }
4216 4215
 
4217
-		do {
4218
-			$data .= fgets($this->runtime['socket'], 4096);
4216
+        do {
4217
+            $data .= fgets($this->runtime['socket'], 4096);
4219 4218
 			
4220
-			if(strpos($data, 'error id=3329 msg=connection') !== false) {
4221
-				$this->runtime['socket'] = '';
4222
-				$this->addDebugLog('You got banned from server. Socket closed.', $tracert[1]['function'], $tracert[0]['line']);
4223
-				return $this->generateOutput(false, array('You got banned from server. Connection closed.'), false);
4224
-			}
4219
+            if(strpos($data, 'error id=3329 msg=connection') !== false) {
4220
+                $this->runtime['socket'] = '';
4221
+                $this->addDebugLog('You got banned from server. Socket closed.', $tracert[1]['function'], $tracert[0]['line']);
4222
+                return $this->generateOutput(false, array('You got banned from server. Connection closed.'), false);
4223
+            }
4225 4224
 			
4226
-		} while(strpos($data, 'msg=') === false or strpos($data, 'error id=') === false);
4225
+        } while(strpos($data, 'msg=') === false or strpos($data, 'error id=') === false);
4227 4226
 
4228
-		if(strpos($data, 'error id=0 msg=ok') === false) {
4229
-			$splittedResponse = explode('error id=', $data);
4230
-			$chooseEnd = count($splittedResponse) - 1;
4227
+        if(strpos($data, 'error id=0 msg=ok') === false) {
4228
+            $splittedResponse = explode('error id=', $data);
4229
+            $chooseEnd = count($splittedResponse) - 1;
4231 4230
 			
4232
-			$cutIdAndMsg = explode(' msg=', $splittedResponse[$chooseEnd]);
4231
+            $cutIdAndMsg = explode(' msg=', $splittedResponse[$chooseEnd]);
4233 4232
 			
4234
-			$this->addDebugLog('ErrorID: '.$cutIdAndMsg[0].' | Message: '.$this->unEscapeText($cutIdAndMsg[1]), $tracert[1]['function'], $tracert[0]['line']);
4233
+            $this->addDebugLog('ErrorID: '.$cutIdAndMsg[0].' | Message: '.$this->unEscapeText($cutIdAndMsg[1]), $tracert[1]['function'], $tracert[0]['line']);
4235 4234
 			
4236
-			return $this->generateOutput(false, array('ErrorID: '.$cutIdAndMsg[0].' | Message: '.$this->unEscapeText($cutIdAndMsg[1])), false);
4237
-		}else{
4238
-			return $this->generateOutput(true, array(), $data);
4239
-		}
4240
-	}
4235
+            return $this->generateOutput(false, array('ErrorID: '.$cutIdAndMsg[0].' | Message: '.$this->unEscapeText($cutIdAndMsg[1])), false);
4236
+        }else{
4237
+            return $this->generateOutput(true, array(), $data);
4238
+        }
4239
+    }
4241 4240
 
4242 4241
 /**
4243 4242
  * getData
@@ -4250,184 +4249,184 @@  discard block
 block discarded – undo
4250 4249
  * @param		string	$command	command which should be executed
4251 4250
  * @return		mixed data
4252 4251
  */
4253
-	private function getData($mode, $command) {
4252
+    private function getData($mode, $command) {
4254 4253
 	
4255
-		$validModes = array('boolean', 'array', 'multi', 'plain');
4254
+        $validModes = array('boolean', 'array', 'multi', 'plain');
4256 4255
 	
4257
-		if(!in_array($mode, $validModes)) {
4258
-			$this->addDebugLog($mode.' is an invalid mode');
4259
-			return $this->generateOutput(false, array('Error: '.$mode.' is an invalid mode'), false);
4260
-		}
4256
+        if(!in_array($mode, $validModes)) {
4257
+            $this->addDebugLog($mode.' is an invalid mode');
4258
+            return $this->generateOutput(false, array('Error: '.$mode.' is an invalid mode'), false);
4259
+        }
4261 4260
 		
4262
-		if(empty($command)) {
4263
-			$this->addDebugLog('you have to enter a command');
4264
-			return $this->generateOutput(false, array('Error: you have to enter a command'), false);
4265
-		}
4261
+        if(empty($command)) {
4262
+            $this->addDebugLog('you have to enter a command');
4263
+            return $this->generateOutput(false, array('Error: you have to enter a command'), false);
4264
+        }
4266 4265
 		
4267
-		$fetchData = $this->executeCommand($command, debug_backtrace());
4266
+        $fetchData = $this->executeCommand($command, debug_backtrace());
4268 4267
 		
4269 4268
 		
4270
-		$fetchData['data'] = str_replace(array('error id=0 msg=ok', chr('01')), '', $fetchData['data']);
4269
+        $fetchData['data'] = str_replace(array('error id=0 msg=ok', chr('01')), '', $fetchData['data']);
4271 4270
 		
4272 4271
 		
4273
-		if($fetchData['success']) {
4274
-			if($mode == 'boolean') {
4275
-				return $this->generateOutput(true, array(), true);
4276
-			}
4272
+        if($fetchData['success']) {
4273
+            if($mode == 'boolean') {
4274
+                return $this->generateOutput(true, array(), true);
4275
+            }
4277 4276
 			
4278
-			if($mode == 'array') {
4279
-				if(empty($fetchData['data'])) { return $this->generateOutput(true, array(), array()); }
4280
-				$datasets = explode(' ', $fetchData['data']);
4277
+            if($mode == 'array') {
4278
+                if(empty($fetchData['data'])) { return $this->generateOutput(true, array(), array()); }
4279
+                $datasets = explode(' ', $fetchData['data']);
4281 4280
 				
4282
-				$output = array();
4281
+                $output = array();
4283 4282
 				
4284
-				foreach($datasets as $dataset) {
4285
-					$dataset = explode('=', $dataset);
4283
+                foreach($datasets as $dataset) {
4284
+                    $dataset = explode('=', $dataset);
4286 4285
 					
4287
-					if(count($dataset) > 2) {
4288
-						for($i = 2; $i < count($dataset); $i++) {
4289
-							$dataset[1] .= '='.$dataset[$i];
4290
-						}
4291
-						$output[$this->unEscapeText($dataset[0])] = $this->unEscapeText($dataset[1]);
4292
-					}else{
4293
-						if(count($dataset) == 1) {
4294
-							$output[$this->unEscapeText($dataset[0])] = '';
4295
-						}else{
4296
-							$output[$this->unEscapeText($dataset[0])] = $this->unEscapeText($dataset[1]);
4297
-						}
4286
+                    if(count($dataset) > 2) {
4287
+                        for($i = 2; $i < count($dataset); $i++) {
4288
+                            $dataset[1] .= '='.$dataset[$i];
4289
+                        }
4290
+                        $output[$this->unEscapeText($dataset[0])] = $this->unEscapeText($dataset[1]);
4291
+                    }else{
4292
+                        if(count($dataset) == 1) {
4293
+                            $output[$this->unEscapeText($dataset[0])] = '';
4294
+                        }else{
4295
+                            $output[$this->unEscapeText($dataset[0])] = $this->unEscapeText($dataset[1]);
4296
+                        }
4298 4297
 						
4299
-					}
4300
-				}
4301
-				return $this->generateOutput(true, array(), $output);
4302
-			}
4303
-			if($mode == 'multi') {
4304
-				if(empty($fetchData['data'])) { return $this->generateOutput(true, array(), array()); }
4305
-				$datasets = explode('|', $fetchData['data']);
4298
+                    }
4299
+                }
4300
+                return $this->generateOutput(true, array(), $output);
4301
+            }
4302
+            if($mode == 'multi') {
4303
+                if(empty($fetchData['data'])) { return $this->generateOutput(true, array(), array()); }
4304
+                $datasets = explode('|', $fetchData['data']);
4306 4305
 				
4307
-				$output = array();
4306
+                $output = array();
4308 4307
 				
4309
-				foreach($datasets as $datablock) {
4310
-					$datablock = explode(' ', $datablock);
4308
+                foreach($datasets as $datablock) {
4309
+                    $datablock = explode(' ', $datablock);
4311 4310
 					
4312
-					$tmpArray = array();
4311
+                    $tmpArray = array();
4313 4312
 					
4314
-					foreach($datablock as $dataset) {
4315
-						$dataset = explode('=', $dataset);
4316
-						if(count($dataset) > 2) {
4317
-							for($i = 2; $i < count($dataset); $i++) {
4318
-								$dataset[1] .= '='.$dataset[$i];
4319
-							}
4320
-							$tmpArray[$this->unEscapeText($dataset[0])] = $this->unEscapeText($dataset[1]);
4321
-						}else{
4322
-							if(count($dataset) == 1) {
4323
-								$tmpArray[$this->unEscapeText($dataset[0])] = '';
4324
-							}else{
4325
-								$tmpArray[$this->unEscapeText($dataset[0])] = $this->unEscapeText($dataset[1]);
4326
-							}
4327
-						}					
4328
-					}
4329
-					$output[] = $tmpArray;
4330
-				}
4331
-				return $this->generateOutput(true, array(), $output);
4332
-			}
4333
-			if($mode == 'plain') {
4334
-				return $fetchData;
4335
-			}
4336
-		}else{
4337
-			return $this->generateOutput(false, $fetchData['errors'], false);
4338
-		}
4339
-	}
4340
-
4341
-/**
4342
-  * ftSendKey
4343
-  * 
4344
-  * Sends down/upload-key to ftHost
4345
-  * 
4346
-  * @author     Par0noid Solutions
4347
-  * @param		string	$key
4348
-  * @param		string $additional
4349
-  * @return     none
4350
- */
4351
-	private function ftSendKey($key, $additional = NULL) {
4352
-		fputs($this->runtime['fileSocket'], $key.$additional);
4353
-	}
4354
-
4355
-/**
4356
-  * ftSendData
4357
-  * 
4358
-  * Sends data to ftHost
4359
-  * 
4360
-  * @author     Par0noid Solutions
4361
-  * @param		mixed	$data
4362
-  * @return     none
4363
- */
4364
-	private function ftSendData($data) {
4365
-		$data = str_split($data, 4096);
4366
-		foreach($data as $dat) {
4367
-			fputs($this->runtime['fileSocket'], $dat);
4368
-		}
4369
-	}
4370
-
4371
-/**
4372
-  * ftRead
4373
-  * 
4374
-  * Reads data from ftHost
4375
-  * 
4376
-  * @author     Par0noid Solutions
4377
-  * @param		int	$size
4378
-  * @return     string data
4379
- */
4380
-	private function ftRead($size) {
4381
-		$data = '';
4382
-		while(strlen($data) < $size) {		
4383
-			$data .= fgets($this->runtime['fileSocket'], 4096);
4384
-		}
4385
-		return $data;
4386
-	}
4313
+                    foreach($datablock as $dataset) {
4314
+                        $dataset = explode('=', $dataset);
4315
+                        if(count($dataset) > 2) {
4316
+                            for($i = 2; $i < count($dataset); $i++) {
4317
+                                $dataset[1] .= '='.$dataset[$i];
4318
+                            }
4319
+                            $tmpArray[$this->unEscapeText($dataset[0])] = $this->unEscapeText($dataset[1]);
4320
+                        }else{
4321
+                            if(count($dataset) == 1) {
4322
+                                $tmpArray[$this->unEscapeText($dataset[0])] = '';
4323
+                            }else{
4324
+                                $tmpArray[$this->unEscapeText($dataset[0])] = $this->unEscapeText($dataset[1]);
4325
+                            }
4326
+                        }					
4327
+                    }
4328
+                    $output[] = $tmpArray;
4329
+                }
4330
+                return $this->generateOutput(true, array(), $output);
4331
+            }
4332
+            if($mode == 'plain') {
4333
+                return $fetchData;
4334
+            }
4335
+        }else{
4336
+            return $this->generateOutput(false, $fetchData['errors'], false);
4337
+        }
4338
+    }
4339
+
4340
+/**
4341
+ * ftSendKey
4342
+ * 
4343
+ * Sends down/upload-key to ftHost
4344
+ * 
4345
+ * @author     Par0noid Solutions
4346
+ * @param		string	$key
4347
+ * @param		string $additional
4348
+ * @return     none
4349
+ */
4350
+    private function ftSendKey($key, $additional = NULL) {
4351
+        fputs($this->runtime['fileSocket'], $key.$additional);
4352
+    }
4353
+
4354
+/**
4355
+ * ftSendData
4356
+ * 
4357
+ * Sends data to ftHost
4358
+ * 
4359
+ * @author     Par0noid Solutions
4360
+ * @param		mixed	$data
4361
+ * @return     none
4362
+ */
4363
+    private function ftSendData($data) {
4364
+        $data = str_split($data, 4096);
4365
+        foreach($data as $dat) {
4366
+            fputs($this->runtime['fileSocket'], $dat);
4367
+        }
4368
+    }
4369
+
4370
+/**
4371
+ * ftRead
4372
+ * 
4373
+ * Reads data from ftHost
4374
+ * 
4375
+ * @author     Par0noid Solutions
4376
+ * @param		int	$size
4377
+ * @return     string data
4378
+ */
4379
+    private function ftRead($size) {
4380
+        $data = '';
4381
+        while(strlen($data) < $size) {		
4382
+            $data .= fgets($this->runtime['fileSocket'], 4096);
4383
+        }
4384
+        return $data;
4385
+    }
4387 4386
 
4388 4387
 //*******************************************************************************************	
4389 4388
 //************************************* Debug Functions *************************************
4390 4389
 //*******************************************************************************************
4391 4390
 
4392 4391
 /**
4393
-  * getDebugLog
4394
-  * 
4395
-  * Returns the debug log
4396
-  *
4397
-  * <b>Output:</b>
4398
-  * <pre>
4399
-  * Array
4400
-  * {
4401
-  *  [0] => Error in login() on line 1908: ErrorID: 520 | Message: invalid loginname or password
4402
-  *  [1] => Error in selectServer() on line 2044: ErrorID: 1540 | Message: convert error
4403
-  * }
4404
-  * </pre>
4405
-  *
4406
-  * @author     Par0noid Solutions
4407
-  * @return     array debugLog
4408
-  */
4409
- 	public function getDebugLog() {
4410
-		return $this->runtime['debug'];
4411
-	}
4412
-
4413
-/**
4414
-  * addDebugLog
4415
-  * 
4416
-  * Adds an entry to debugLog
4417
-  *
4418
-  * @author     Par0noid Solutions
4419
-  * @param		string	$text			text which should added to debugLog
4420
-  * @param		string	$methodName		name of the executed method [optional]
4421
-  * @param		string	$line			line where error triggered [optional]
4422
-  * @return     array debugLog
4423
-  */
4424
-	private function addDebugLog($text, $methodName = '', $line = '') {
4425
-		if(empty($methodName) and empty($line)) {
4426
-			$backtrace = debug_backtrace();
4427
-			$methodName = $backtrace[1]['function'];
4428
-			$line = $backtrace[0]['line'];
4429
-		}
4430
-		$this->runtime['debug'][] = 'Error in '.$methodName.'() on line '.$line.': '.$text;	
4431
-	}
4392
+ * getDebugLog
4393
+ * 
4394
+ * Returns the debug log
4395
+ *
4396
+ * <b>Output:</b>
4397
+ * <pre>
4398
+ * Array
4399
+ * {
4400
+ *  [0] => Error in login() on line 1908: ErrorID: 520 | Message: invalid loginname or password
4401
+ *  [1] => Error in selectServer() on line 2044: ErrorID: 1540 | Message: convert error
4402
+ * }
4403
+ * </pre>
4404
+ *
4405
+ * @author     Par0noid Solutions
4406
+ * @return     array debugLog
4407
+ */
4408
+        public function getDebugLog() {
4409
+        return $this->runtime['debug'];
4410
+    }
4411
+
4412
+/**
4413
+ * addDebugLog
4414
+ * 
4415
+ * Adds an entry to debugLog
4416
+ *
4417
+ * @author     Par0noid Solutions
4418
+ * @param		string	$text			text which should added to debugLog
4419
+ * @param		string	$methodName		name of the executed method [optional]
4420
+ * @param		string	$line			line where error triggered [optional]
4421
+ * @return     array debugLog
4422
+ */
4423
+    private function addDebugLog($text, $methodName = '', $line = '') {
4424
+        if(empty($methodName) and empty($line)) {
4425
+            $backtrace = debug_backtrace();
4426
+            $methodName = $backtrace[1]['function'];
4427
+            $line = $backtrace[0]['line'];
4428
+        }
4429
+        $this->runtime['debug'][] = 'Error in '.$methodName.'() on line '.$line.': '.$text;	
4430
+    }
4432 4431
 }
4433 4432
 ?>
4434 4433
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +303 added lines, -303 removed lines patch added patch discarded remove patch
@@ -80,9 +80,9 @@  discard block
 block discarded – undo
80 80
   * @return     array banId
81 81
   */
82 82
 	function banAddByIp($ip, $time = 0, $banreason = NULL) {
83
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
83
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
84 84
 		
85
-		if(!empty($banreason)) { $msg = ' banreason='.$this->escapeText($banreason); } else { $msg = NULL; }
85
+		if (!empty($banreason)) { $msg = ' banreason='.$this->escapeText($banreason); } else { $msg = NULL; }
86 86
 
87 87
 		return $this->getData('array', 'banadd ip='.$ip.' time='.$time.$msg);
88 88
 	}
@@ -107,9 +107,9 @@  discard block
 block discarded – undo
107 107
   * @return     array banId
108 108
   */
109 109
 	function banAddByUid($uid, $time = 0, $banreason = NULL) {
110
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
110
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
111 111
 		
112
-		if(!empty($banreason)) { $msg = ' banreason='.$this->escapeText($banreason); } else { $msg = NULL; }
112
+		if (!empty($banreason)) { $msg = ' banreason='.$this->escapeText($banreason); } else { $msg = NULL; }
113 113
 		
114 114
 		return $this->getData('array', 'banadd uid='.$uid.' time='.$time.$msg);
115 115
 	}
@@ -134,9 +134,9 @@  discard block
 block discarded – undo
134 134
   * @return     array banId
135 135
   */
136 136
 	function banAddByName($name, $time = 0, $banreason = NULL) {
137
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
137
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
138 138
 		
139
-		if(!empty($banreason)) { $msg = ' banreason='.$this->escapeText($banreason); } else { $msg = NULL; }
139
+		if (!empty($banreason)) { $msg = ' banreason='.$this->escapeText($banreason); } else { $msg = NULL; }
140 140
 										
141 141
 		return $this->getData('array', 'banadd name='.$this->escapeText($name).' time='.$time.$msg);
142 142
 	}
@@ -162,15 +162,15 @@  discard block
 block discarded – undo
162 162
   * @return     array banIds
163 163
   */
164 164
 	function banClient($clid, $time = 0, $banreason = NULL) {
165
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
165
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
166 166
 		
167
-		if(!empty($banreason)) { $msg = ' banreason='.$this->escapeText($banreason); } else { $msg = ''; }
167
+		if (!empty($banreason)) { $msg = ' banreason='.$this->escapeText($banreason); } else { $msg = ''; }
168 168
 		
169 169
 		$result = $this->getData('plain', 'banclient clid='.$clid.' time='.$time.$msg);
170 170
 		
171
-		if($result['success']) {
171
+		if ($result['success']) {
172 172
 			return $this->generateOutput(true, $result['errors'], $this->splitBanIds($result['data']));
173
-		}else{
173
+		} else {
174 174
 			return $this->generateOutput(false, $result['errors'], false);
175 175
 		}
176 176
 	}
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
   * @return     boolean success
186 186
   */
187 187
 	function banDelete($banID) {
188
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
188
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
189 189
 		return $this->getData('boolean', 'bandel banid='.$banID);
190 190
 	}
191 191
 
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
   * @return     boolean success
199 199
   */
200 200
 	function banDeleteAll() {
201
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
201
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
202 202
 		return $this->getData('boolean', 'bandelall');
203 203
 	}
204 204
 
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
   * @return     array banlist
230 230
   */
231 231
 	function banList() {
232
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }		
232
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }		
233 233
 		return $this->getData('multi', 'banlist');
234 234
 	}
235 235
 
@@ -272,9 +272,9 @@  discard block
 block discarded – undo
272 272
   * @return     boolean success
273 273
   */
274 274
 	function channelAddPerm($cid, $permissions) {
275
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
275
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
276 276
 		
277
-		if(count($permissions) > 0) {
277
+		if (count($permissions) > 0) {
278 278
 			//Permissions given
279 279
 			
280 280
 			//Errorcollector
@@ -284,35 +284,35 @@  discard block
 block discarded – undo
284 284
 			$permissions = array_chunk($permissions, 50, true);
285 285
 			
286 286
 			//Action for each splitted part of permission
287
-			foreach($permissions as $permission_part)
287
+			foreach ($permissions as $permission_part)
288 288
 			{
289 289
 				//Create command_string for each command that we could use implode later
290 290
 				$command_string = array();
291 291
 				
292
-				foreach($permission_part as $key => $value)
292
+				foreach ($permission_part as $key => $value)
293 293
 				{
294 294
 					$command_string[] = (is_numeric($key) ? "permid=" : "permsid=").$this->escapeText($key).' permvalue='.$value;
295 295
 				}
296 296
 				
297 297
 				$result = $this->getData('boolean', 'channeladdperm cid='.$cid.' '.implode('|', $command_string));
298 298
 				
299
-				if(!$result['success'])
299
+				if (!$result['success'])
300 300
 				{
301
-					foreach($result['errors'] as $error)
301
+					foreach ($result['errors'] as $error)
302 302
 					{
303 303
 						$errors[] = $error;
304 304
 					}
305 305
 				}
306 306
 			}
307 307
 			
308
-			if(count($errors) == 0)
308
+			if (count($errors) == 0)
309 309
 			{
310 310
 				return $this->generateOutput(true, array(), true);
311
-			}else{
311
+			} else {
312 312
 				return $this->generateOutput(false, $errors, false);
313 313
 			}
314 314
 			
315
-		}else{
315
+		} else {
316 316
 			// No permissions given
317 317
 			$this->addDebugLog('no permissions given');
318 318
 			return $this->generateOutput(false, array('Error: no permissions given'), false);
@@ -339,9 +339,9 @@  discard block
 block discarded – undo
339 339
   * @return     boolean success
340 340
   */
341 341
 	function channelClientAddPerm($cid, $cldbid, $permissions) {
342
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
342
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
343 343
 		
344
-		if(count($permissions) > 0) {
344
+		if (count($permissions) > 0) {
345 345
 			//Permissions given
346 346
 				
347 347
 			//Errorcollector
@@ -351,35 +351,35 @@  discard block
 block discarded – undo
351 351
 			$permissions = array_chunk($permissions, 50, true);
352 352
 				
353 353
 			//Action for each splitted part of permission
354
-			foreach($permissions as $permission_part)
354
+			foreach ($permissions as $permission_part)
355 355
 			{
356 356
 				//Create command_string for each command that we could use implode later
357 357
 				$command_string = array();
358 358
 		
359
-				foreach($permission_part as $key => $value)
359
+				foreach ($permission_part as $key => $value)
360 360
 				{
361 361
 					$command_string[] = (is_numeric($key) ? "permid=" : "permsid=").$this->escapeText($key).' permvalue='.$value;
362 362
 				}
363 363
 		
364 364
 				$result = $this->getData('boolean', 'channelclientaddperm cid='.$cid.' cldbid='.$cldbid.' '.implode('|', $command_string));
365 365
 		
366
-				if(!$result['success'])
366
+				if (!$result['success'])
367 367
 				{
368
-					foreach($result['errors'] as $error)
368
+					foreach ($result['errors'] as $error)
369 369
 					{
370 370
 						$errors[] = $error;
371 371
 					}
372 372
 				}
373 373
 			}
374 374
 				
375
-			if(count($errors) == 0)
375
+			if (count($errors) == 0)
376 376
 			{
377 377
 				return $this->generateOutput(true, array(), true);
378
-			}else{
378
+			} else {
379 379
 				return $this->generateOutput(false, $errors, false);
380 380
 			}
381 381
 				
382
-		}else{
382
+		} else {
383 383
 			// No permissions given
384 384
 			$this->addDebugLog('no permissions given');
385 385
 			return $this->generateOutput(false, array('Error: no permissions given'), false);
@@ -407,15 +407,15 @@  discard block
 block discarded – undo
407 407
   * @return     boolean success
408 408
   */
409 409
 	function channelClientDelPerm($cid, $cldbid, $permissions) {
410
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
410
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
411 411
 		$permissionArray = array();
412 412
 		
413
-		if(count($permissions) > 0) {
414
-			foreach($permissions AS $value) {
413
+		if (count($permissions) > 0) {
414
+			foreach ($permissions AS $value) {
415 415
 				$permissionArray[] = is_numeric($value) ? 'permid='.$value : 'permsid='.$value;
416 416
 			}
417 417
 			return $this->getData('boolean', 'channelclientdelperm cid='.$cid.' cldbid='.$cldbid.' '.implode('|', $permissionArray));
418
-		}else{
418
+		} else {
419 419
 			$this->addDebugLog('no permissions given');
420 420
 			return $this->generateOutput(false, array('Error: no permissions given'), false);
421 421
 		}
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
   * @return     array	channelclientpermlist
448 448
   */
449 449
 	function channelClientPermList($cid, $cldbid, $permsid = false) {
450
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }		
450
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }		
451 451
 		return $this->getData('multi', 'channelclientpermlist cid='.$cid.' cldbid='.$cldbid.($permsid ? ' -permsid' : ''));
452 452
 	}
453 453
 
@@ -481,11 +481,11 @@  discard block
 block discarded – undo
481 481
   * @return     array channelInfo
482 482
   */
483 483
 	function channelCreate($data) {
484
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
484
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
485 485
 		
486 486
 		$propertiesString = '';
487 487
 		
488
-		foreach($data as $key => $value) {
488
+		foreach ($data as $key => $value) {
489 489
 			$propertiesString .= ' '.$key.'='.$this->escapeText($value);
490 490
 		}
491 491
 		
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
   * @return     boolean success
504 504
   */
505 505
 	function channelDelete($cid, $force = 1) {
506
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
506
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
507 507
 		return $this->getData('boolean', 'channeldelete cid='.$cid.' force='.$force);
508 508
 	}
509 509
 
@@ -526,15 +526,15 @@  discard block
 block discarded – undo
526 526
   * @return     boolean	success
527 527
   */
528 528
 	function channelDelPerm($cid, $permissions) {
529
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
529
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
530 530
 		$permissionArray = array();
531 531
 		
532
-		if(count($permissions) > 0) {
533
-			foreach($permissions AS $value) {
532
+		if (count($permissions) > 0) {
533
+			foreach ($permissions AS $value) {
534 534
 				$permissionArray[] = (is_numeric($value) ? 'permid=' : 'permsid=').$value;
535 535
 			}
536 536
 			return $this->getData('boolean', 'channeldelperm cid='.$cid.' '.implode('|', $permissionArray));
537
-		}else{
537
+		} else {
538 538
 			$this->addDebugLog('no permissions given');
539 539
 			return $this->generateOutput(false, array('Error: no permissions given'), false);
540 540
 		}
@@ -559,11 +559,11 @@  discard block
 block discarded – undo
559 559
   * @return     boolean success
560 560
   */
561 561
 	function channelEdit($cid, $data) {
562
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
562
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
563 563
 		
564 564
 		$settingsString = '';
565 565
 		
566
-		foreach($data as $key => $value) {
566
+		foreach ($data as $key => $value) {
567 567
 			$settingsString .= ' '.$key.'='.$this->escapeText($value);
568 568
 		}
569 569
 
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
   * @return     array channelList 
590 590
   */
591 591
 	function channelFind($pattern) {
592
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
592
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
593 593
 		return $this->getData('multi', 'channelfind pattern='.$this->escapeText($pattern));
594 594
 	}
595 595
 
@@ -619,7 +619,7 @@  discard block
 block discarded – undo
619 619
   * @return     boolean success
620 620
   */
621 621
 	function channelGroupAdd($name, $type = 1) {
622
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
622
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
623 623
 		return $this->getData('array', 'channelgroupadd name='.$this->escapeText($name).' type='.$type);
624 624
 	}
625 625
 
@@ -642,9 +642,9 @@  discard block
 block discarded – undo
642 642
   * @return     boolean success
643 643
   */
644 644
 	function channelGroupAddPerm($cgid, $permissions) {
645
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
645
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
646 646
 		
647
-		if(count($permissions) > 0) {
647
+		if (count($permissions) > 0) {
648 648
 			//Permissions given
649 649
 		
650 650
 			//Errorcollector
@@ -654,34 +654,34 @@  discard block
 block discarded – undo
654 654
 			$permissions = array_chunk($permissions, 50, true);
655 655
 		
656 656
 			//Action for each splitted part of permission
657
-			foreach($permissions as $permission_part)
657
+			foreach ($permissions as $permission_part)
658 658
 			{
659 659
 				//Create command_string for each command that we could use implode later
660 660
 				$command_string = array();
661 661
 		
662
-				foreach($permission_part as $key => $value)
662
+				foreach ($permission_part as $key => $value)
663 663
 				{
664 664
 					$command_string[] = (is_numeric($key) ? "permid=" : "permsid=").$this->escapeText($key).' permvalue='.$value;
665 665
 				}
666 666
 		
667 667
 				$result = $this->getData('boolean', 'channelgroupaddperm cgid='.$cgid.' '.implode('|', $command_string));
668 668
 		
669
-				if(!$result['success'])
669
+				if (!$result['success'])
670 670
 				{
671
-					foreach($result['errors'] as $error)
671
+					foreach ($result['errors'] as $error)
672 672
 					{
673 673
 						$errors[] = $error;
674 674
 					}
675 675
 				}
676 676
 			}
677 677
 		
678
-			if(count($errors) == 0) {
678
+			if (count($errors) == 0) {
679 679
 				return $this->generateOutput(true, array(), true);
680
-			}else{
680
+			} else {
681 681
 				return $this->generateOutput(false, $errors, false);
682 682
 			}
683 683
 		
684
-		}else{
684
+		} else {
685 685
 			// No permissions given
686 686
 			$this->addDebugLog('no permissions given');
687 687
 			return $this->generateOutput(false, array('Error: no permissions given'), false);
@@ -710,7 +710,7 @@  discard block
 block discarded – undo
710 710
   * @return     array channelGroupClientList
711 711
   */
712 712
 	function channelGroupClientList($cid = NULL, $cldbid = NULL, $cgid = NULL) {
713
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
713
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
714 714
 		
715 715
 		return $this->getData('multi', 'channelgroupclientlist'.(!empty($cid) ? ' cid='.$cid : '').(!empty($cldbid) ? ' cldbid='.$cldbid : '').(!empty($cgid) ? ' cgid='.$cgid : ''));
716 716
 	}
@@ -743,7 +743,7 @@  discard block
 block discarded – undo
743 743
   * @return     array groupId
744 744
   */
745 745
 	function channelGroupCopy($scgid, $tcgid, $name, $type = 1) {
746
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
746
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
747 747
 		return $this->getData('array', 'channelgroupcopy scgid='.$scgid.' tcgid='.$tcgid.' name='.$this->escapeText($name).' type='.$type);
748 748
 	}
749 749
 
@@ -758,7 +758,7 @@  discard block
 block discarded – undo
758 758
   * @return     boolean success
759 759
   */
760 760
 	function channelGroupDelete($cgid, $force = 1) {
761
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
761
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
762 762
 		return $this->getData('boolean', 'channelgroupdel cgid='.$cgid.' force='.$force);
763 763
 	}
764 764
 
@@ -780,15 +780,15 @@  discard block
 block discarded – undo
780 780
   * @return     boolean success
781 781
   */
782 782
 	function channelGroupDelPerm($cgid, $permissions) {
783
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
783
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
784 784
 		$permissionArray = array();
785 785
 		
786
-		if(count($permissions) > 0) {
787
-			foreach($permissions AS $value) {
786
+		if (count($permissions) > 0) {
787
+			foreach ($permissions AS $value) {
788 788
 				$permissionArray[] = (is_numeric($value) ? 'permid=' : 'permsid=').$value;
789 789
 			}
790 790
 			return $this->getData('boolean', 'channelgroupdelperm cgid='.$cgid.' '.implode('|', $permissionArray));
791
-		}else{
791
+		} else {
792 792
 			$this->addDebugLog('no permissions given');
793 793
 			return $this->generateOutput(false, array('Error: no permissions given'), false);
794 794
 		}
@@ -820,7 +820,7 @@  discard block
 block discarded – undo
820 820
   * @return     array channelGroupList
821 821
   */
822 822
 	function channelGroupList() {
823
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
823
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
824 824
 		
825 825
 		return $this->getData('multi', 'channelgrouplist');
826 826
 	}
@@ -849,7 +849,7 @@  discard block
 block discarded – undo
849 849
   * @return		array	channelGroupPermlist
850 850
   */
851 851
   	function channelGroupPermList($cgid, $permsid = false) {
852
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }		
852
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }		
853 853
 		return $this->getData('multi', 'channelgrouppermlist cgid='.$cgid.($permsid ? ' -permsid' : ''));
854 854
 	}
855 855
 
@@ -864,7 +864,7 @@  discard block
 block discarded – undo
864 864
   * @return     boolean success
865 865
   */
866 866
 	function channelGroupRename($cgid, $name) {
867
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
867
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
868 868
 		return $this->getData('boolean', 'channelgrouprename cgid='.$cgid.' name='.$this->escapeText($name));
869 869
 	}
870 870
 
@@ -913,7 +913,7 @@  discard block
 block discarded – undo
913 913
   * @return     array channelInfo
914 914
   */
915 915
 	function channelInfo($cid) {
916
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
916
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
917 917
 		return $this->getData('array', 'channelinfo cid='.$cid);
918 918
 	}
919 919
 
@@ -967,8 +967,8 @@  discard block
 block discarded – undo
967 967
   * @return		array	channelList
968 968
   */
969 969
 	function channelList($params = null) {
970
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
971
-		if(!empty($params)) { $params = ' '.$params; }
970
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
971
+		if (!empty($params)) { $params = ' '.$params; }
972 972
 		
973 973
 		return $this->getData('multi', 'channellist'.$params);
974 974
 	}
@@ -985,7 +985,7 @@  discard block
 block discarded – undo
985 985
   * @return     boolean success
986 986
   */
987 987
 	function channelMove($cid, $cpid, $order = null) {
988
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }		
988
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }		
989 989
 		return $this->getData('boolean', 'channelmove cid='.$cid.' cpid='.$cpid.($order != null ? ' order='.$order : ''));
990 990
 	}
991 991
 
@@ -1013,7 +1013,7 @@  discard block
 block discarded – undo
1013 1013
   * @return     array channelpermlist
1014 1014
   */
1015 1015
 	function channelPermList($cid, $permsid = false) {
1016
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }	
1016
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }	
1017 1017
 		return $this->getData('multi', 'channelpermlist cid='.$cid.($permsid ? ' -permsid' : ''));
1018 1018
 	}
1019 1019
 
@@ -1036,9 +1036,9 @@  discard block
 block discarded – undo
1036 1036
   * @return     boolean success
1037 1037
   */
1038 1038
 	function clientAddPerm($cldbid, $permissions) {
1039
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
1039
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
1040 1040
 		
1041
-		if(count($permissions) > 0) {
1041
+		if (count($permissions) > 0) {
1042 1042
 			//Permissions given
1043 1043
 				
1044 1044
 			//Errorcollector
@@ -1048,34 +1048,34 @@  discard block
 block discarded – undo
1048 1048
 			$permissions = array_chunk($permissions, 50, true);
1049 1049
 				
1050 1050
 			//Action for each splitted part of permission
1051
-			foreach($permissions as $permission_part)
1051
+			foreach ($permissions as $permission_part)
1052 1052
 			{
1053 1053
 				//Create command_string for each command that we could use implode later
1054 1054
 				$command_string = array();
1055 1055
 		
1056
-				foreach($permission_part as $key => $value)
1056
+				foreach ($permission_part as $key => $value)
1057 1057
 				{
1058 1058
 					$command_string[] = (is_numeric($key) ? "permid=" : "permsid=").$this->escapeText($key).' permvalue='.$this->escapeText($value[0]).' permskip='.$this->escapeText($value[1]);
1059 1059
 				}
1060 1060
 		
1061 1061
 				$result = $this->getData('boolean', 'clientaddperm cldbid='.$cldbid.' '.implode('|', $command_string));
1062 1062
 		
1063
-				if(!$result['success'])
1063
+				if (!$result['success'])
1064 1064
 				{
1065
-					foreach($result['errors'] as $error)
1065
+					foreach ($result['errors'] as $error)
1066 1066
 					{
1067 1067
 						$errors[] = $error;
1068 1068
 					}
1069 1069
 				}
1070 1070
 			}
1071 1071
 				
1072
-			if(count($errors) == 0)
1072
+			if (count($errors) == 0)
1073 1073
 			{
1074 1074
 				return $this->generateOutput(true, array(), true);
1075
-			}else{
1075
+			} else {
1076 1076
 				return $this->generateOutput(false, $errors, false);
1077 1077
 			}
1078
-		}else{
1078
+		} else {
1079 1079
 			// No permissions given
1080 1080
 			$this->addDebugLog('no permissions given');
1081 1081
 			return $this->generateOutput(false, array('Error: no permissions given'), false);
@@ -1097,9 +1097,9 @@  discard block
 block discarded – undo
1097 1097
  * @return array  base64 image
1098 1098
  */
1099 1099
 	function clientAvatar($uid) {
1100
-	  if(!$this->runtime['selected']) { return $this->checkSelected(); }
1100
+	  if (!$this->runtime['selected']) { return $this->checkSelected(); }
1101 1101
 
1102
-	  if(empty($uid))
1102
+	  if (empty($uid))
1103 1103
 	  {
1104 1104
 		return $this->generateOutput(false, array('Error: empty uid'), false);
1105 1105
 	  }
@@ -1115,24 +1115,24 @@  discard block
 block discarded – undo
1115 1115
 
1116 1116
 	  $check = $this->ftgetfileinfo(0, '', '/avatar_'.$auid);
1117 1117
 
1118
-	  if(!$check["success"])
1118
+	  if (!$check["success"])
1119 1119
 	  {
1120 1120
 		return $this->generateOutput(false, array('Error: avatar does not exist'), false);
1121 1121
 	  }
1122 1122
 
1123 1123
 	  $init = $this->ftInitDownload('/avatar_'.$auid, 0, '');
1124 1124
 
1125
-	  if(!$init["success"])
1125
+	  if (!$init["success"])
1126 1126
 	  {
1127 1127
 		return $this->generateOutput(false, array('Error: init failed'), false);
1128 1128
 	  }
1129 1129
 
1130 1130
 	  $download = $this->ftDownloadFile($init);
1131 1131
 
1132
-	  if(is_array($download))
1132
+	  if (is_array($download))
1133 1133
 	  {
1134 1134
 		return $download;
1135
-	  }else{
1135
+	  } else {
1136 1136
 		return $this->generateOutput(true, false, base64_encode($download));
1137 1137
 	  }
1138 1138
 
@@ -1148,7 +1148,7 @@  discard block
 block discarded – undo
1148 1148
   * @return     boolean success
1149 1149
   */
1150 1150
 	function clientDbDelete($cldbid) {
1151
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
1151
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
1152 1152
 		return $this->getData('boolean', 'clientdbdelete cldbid='.$cldbid);
1153 1153
 	}
1154 1154
 
@@ -1171,11 +1171,11 @@  discard block
 block discarded – undo
1171 1171
   * @return     boolean success
1172 1172
   */
1173 1173
 	function clientDbEdit($cldbid, $data) {
1174
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
1174
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
1175 1175
 		
1176 1176
 		$settingsString = '';
1177 1177
 		
1178
-		foreach($data as $key => $value) {
1178
+		foreach ($data as $key => $value) {
1179 1179
 			$settingsString .= ' '.$key.'='.$this->escapeText($value);
1180 1180
 		}
1181 1181
 		
@@ -1201,7 +1201,7 @@  discard block
 block discarded – undo
1201 1201
   * @return     array clientList 
1202 1202
   */
1203 1203
 	function clientDbFind($pattern, $uid = false) {
1204
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
1204
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
1205 1205
 		return $this->getData('multi', 'clientdbfind pattern='.$this->escapeText($pattern).($uid ? ' -uid' : ''));
1206 1206
 	}
1207 1207
 
@@ -1237,7 +1237,7 @@  discard block
 block discarded – undo
1237 1237
   * @return     array	clientDbInfo
1238 1238
   */
1239 1239
 	function clientDbInfo($cldbid) {
1240
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
1240
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
1241 1241
 		return $this->getData('array', 'clientdbinfo cldbid='.$cldbid);
1242 1242
 	}
1243 1243
 
@@ -1271,7 +1271,7 @@  discard block
 block discarded – undo
1271 1271
   * @return     array clientdblist
1272 1272
   */
1273 1273
 	function clientDbList($start = 0, $duration = -1, $count = false) {
1274
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
1274
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
1275 1275
 		return $this->getData('multi', 'clientdblist start='.$start.' duration='.$duration.($count ? ' -count' : ''));
1276 1276
 	}
1277 1277
 
@@ -1294,16 +1294,16 @@  discard block
 block discarded – undo
1294 1294
   * @return     boolean success
1295 1295
   */
1296 1296
 	function clientDelPerm($cldbid, $permissionIds) {
1297
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
1297
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
1298 1298
 		
1299 1299
 		$permissionArray = array();
1300 1300
 		
1301
-		if(count($permissionIds) > 0) {
1302
-			foreach($permissionIds AS $value) {
1301
+		if (count($permissionIds) > 0) {
1302
+			foreach ($permissionIds AS $value) {
1303 1303
 				$permissionArray[] = (is_numeric($value) ? 'permid=' : 'permsid=').$value;
1304 1304
 			}
1305 1305
 			return $this->getData('boolean', 'clientdelperm cldbid='.$cldbid.' '.implode('|', $permissionArray));
1306
-		}else{
1306
+		} else {
1307 1307
 			$this->addDebugLog('no permissions given');
1308 1308
 			return $this->generateOutput(false, array('Error: no permissions given'), false);
1309 1309
 		}
@@ -1328,11 +1328,11 @@  discard block
 block discarded – undo
1328 1328
   * @return     boolean success
1329 1329
   */
1330 1330
 	function clientEdit($clid, $data) {
1331
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
1331
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
1332 1332
 		
1333 1333
 		$settingsString = '';
1334 1334
 		
1335
-		foreach($data as $key => $value) {
1335
+		foreach ($data as $key => $value) {
1336 1336
 			$settingsString .= ' '.$key.'='.$this->escapeText($value);
1337 1337
 		}
1338 1338
 		
@@ -1358,7 +1358,7 @@  discard block
 block discarded – undo
1358 1358
   * @return     array clienList
1359 1359
   */
1360 1360
 	function clientFind($pattern) {
1361
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
1361
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
1362 1362
 		return $this->getData('multi', 'clientfind pattern='.$this->escapeText($pattern));
1363 1363
 	}
1364 1364
 
@@ -1381,7 +1381,7 @@  discard block
 block discarded – undo
1381 1381
   * @return     array clientInfo
1382 1382
   */
1383 1383
 	function clientGetDbIdFromUid($cluid) {
1384
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
1384
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
1385 1385
 		return $this->getData('array', 'clientgetdbidfromuid cluid='.$cluid);
1386 1386
 	}
1387 1387
 
@@ -1405,7 +1405,7 @@  discard block
 block discarded – undo
1405 1405
   * @return     array clientList 
1406 1406
   */
1407 1407
 	function clientGetIds($cluid) {
1408
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
1408
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
1409 1409
 		return $this->getData('multi', 'clientgetids cluid='.$cluid);
1410 1410
 	}
1411 1411
 
@@ -1429,7 +1429,7 @@  discard block
 block discarded – undo
1429 1429
   * @return     array clientInfo
1430 1430
   */
1431 1431
 	function clientGetNameFromDbid($cldbid) {
1432
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
1432
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
1433 1433
 		return $this->getData('array', 'clientgetnamefromdbid cldbid='.$cldbid);
1434 1434
 	}
1435 1435
 	
@@ -1453,7 +1453,7 @@  discard block
 block discarded – undo
1453 1453
   * @return     array clientInfo
1454 1454
   */
1455 1455
 	function clientGetNameFromUid($cluid) {
1456
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
1456
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
1457 1457
 		return $this->getData('array', 'clientgetnamefromuid cluid='.$cluid);
1458 1458
 	}
1459 1459
 
@@ -1532,7 +1532,7 @@  discard block
 block discarded – undo
1532 1532
   * @return     array	clientInformation
1533 1533
   */
1534 1534
 	function clientInfo($clid) {
1535
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
1535
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
1536 1536
 		return $this->getData('array', 'clientinfo clid='.$clid);
1537 1537
 	}
1538 1538
 
@@ -1548,17 +1548,17 @@  discard block
 block discarded – undo
1548 1548
   * @return     boolean success
1549 1549
   */
1550 1550
 	function clientKick($clid, $kickMode = "server", $kickmsg = "") {
1551
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
1551
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
1552 1552
 		
1553
-		if(in_array($kickMode, array('server', 'channel'))) {
1553
+		if (in_array($kickMode, array('server', 'channel'))) {
1554 1554
 		
1555
-			if($kickMode == 'server') { $from = '5'; }
1556
-			if($kickMode == 'channel') { $from = '4'; }
1555
+			if ($kickMode == 'server') { $from = '5'; }
1556
+			if ($kickMode == 'channel') { $from = '4'; }
1557 1557
 			
1558
-			if(!empty($kickmsg)) { $msg = ' reasonmsg='.$this->escapeText($kickmsg); } else{ $msg = ''; }
1558
+			if (!empty($kickmsg)) { $msg = ' reasonmsg='.$this->escapeText($kickmsg); } else { $msg = ''; }
1559 1559
 			
1560 1560
 			return $this->getData('boolean', 'clientkick clid='.$clid.' reasonid='.$from.$msg);
1561
-		}else{
1561
+		} else {
1562 1562
 			$this->addDebugLog('invalid kickMode');
1563 1563
 			return $this->generateOutput(false, array('Error: invalid kickMode'), false);
1564 1564
 		}
@@ -1619,9 +1619,9 @@  discard block
 block discarded – undo
1619 1619
   * @return     array clientList 
1620 1620
   */
1621 1621
 	function clientList($params = null) {
1622
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
1622
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
1623 1623
 		
1624
-		if(!empty($params)) { $params = ' '.$params; }
1624
+		if (!empty($params)) { $params = ' '.$params; }
1625 1625
 		
1626 1626
 		return $this->getData('multi', 'clientlist'.$params);
1627 1627
 	}
@@ -1638,7 +1638,7 @@  discard block
 block discarded – undo
1638 1638
   * @return     boolean success
1639 1639
   */
1640 1640
 	function clientMove($clid, $cid, $cpw = null) {
1641
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
1641
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
1642 1642
 		return $this->getData('boolean', 'clientmove clid='.$clid.' cid='.$cid.(!empty($cpw) ? ' cpw='.$this->escapeText($cpw) : ''));
1643 1643
 	}
1644 1644
 
@@ -1665,7 +1665,7 @@  discard block
 block discarded – undo
1665 1665
   * @return     array clientPermList
1666 1666
   */
1667 1667
 	function clientPermList($cldbid, $permsid = false) {
1668
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }		
1668
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }		
1669 1669
 		return $this->getData('multi', 'clientpermlist cldbid='.$cldbid.($permsid ? ' -permsid' : ''));
1670 1670
 	}
1671 1671
 
@@ -1680,7 +1680,7 @@  discard block
 block discarded – undo
1680 1680
   * @return     boolean success
1681 1681
   */
1682 1682
 	function clientPoke($clid, $msg) {
1683
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
1683
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
1684 1684
 		return $this->getData('boolean', 'clientpoke clid='.$clid.' msg='.$this->escapeText($msg));
1685 1685
 	}
1686 1686
 
@@ -1724,7 +1724,7 @@  discard block
 block discarded – undo
1724 1724
 	function clientUpdate($data) {
1725 1725
 		$settingsString = '';
1726 1726
 		
1727
-		foreach($data as $key => $value) {
1727
+		foreach ($data as $key => $value) {
1728 1728
 			$settingsString .= ' '.$key.'='.$this->escapeText($value);
1729 1729
 		}
1730 1730
 		
@@ -1742,7 +1742,7 @@  discard block
 block discarded – undo
1742 1742
   * @return     boolean success
1743 1743
   */
1744 1744
 	function complainAdd($tcldbid, $msg) {
1745
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
1745
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
1746 1746
 		return $this->getData('boolean', 'complainadd tcldbid='.$tcldbid.' message='.$this->escapeText($msg));
1747 1747
 	}
1748 1748
 
@@ -1757,7 +1757,7 @@  discard block
 block discarded – undo
1757 1757
   * @return     boolean success
1758 1758
   */
1759 1759
 	function complainDelete($tcldbid, $fcldbid) {
1760
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
1760
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
1761 1761
 		return $this->getData('boolean', 'complaindel tcldbid='.$tcldbid.' fcldbid='.$fcldbid);
1762 1762
 	}
1763 1763
 
@@ -1771,7 +1771,7 @@  discard block
 block discarded – undo
1771 1771
   * @return     boolean success
1772 1772
   */
1773 1773
 	function complainDeleteAll($tcldbid) {
1774
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
1774
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
1775 1775
 		return $this->getData('boolean', 'complaindelall tcldbid='.$tcldbid);
1776 1776
 	}
1777 1777
 
@@ -1798,8 +1798,8 @@  discard block
 block discarded – undo
1798 1798
   * @return     array complainList
1799 1799
   */
1800 1800
 	function complainList($tcldbid = null) {
1801
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
1802
-		if(!empty($tcldbid)) { $tcldbid = ' tcldbid='.$tcldbid; }
1801
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
1802
+		if (!empty($tcldbid)) { $tcldbid = ' tcldbid='.$tcldbid; }
1803 1803
 		return $this->getData('multi', 'complainlist'.$tcldbid);
1804 1804
 	}
1805 1805
 	
@@ -1832,7 +1832,7 @@  discard block
 block discarded – undo
1832 1832
   * @return     array customInfos
1833 1833
   */
1834 1834
 	function customInfo($cldbid) {
1835
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
1835
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
1836 1836
 		return $this->getData('multi', 'custominfo cldbid='.$cldbid);
1837 1837
 	}
1838 1838
 
@@ -1866,7 +1866,7 @@  discard block
 block discarded – undo
1866 1866
   * @return     array	customSearchInfos
1867 1867
   */
1868 1868
 	function customSearch($ident, $pattern) {
1869
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
1869
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
1870 1870
 		return $this->getData('multi', 'customsearch ident='.$this->escapeText($ident).' pattern='.$this->escapeText($pattern));
1871 1871
 	}
1872 1872
 
@@ -1889,16 +1889,16 @@  discard block
 block discarded – undo
1889 1889
   * @return     mixed result
1890 1890
   */
1891 1891
 	function execOwnCommand($mode, $command) {
1892
-		if($mode == '0') {
1892
+		if ($mode == '0') {
1893 1893
 			return $this->getData('boolean', $command);
1894 1894
 		}
1895
-		if($mode == '1') {
1895
+		if ($mode == '1') {
1896 1896
 			return $this->getData('array', $command);
1897 1897
 		}
1898
-		if($mode == '2') {
1898
+		if ($mode == '2') {
1899 1899
 			return $this->getData('multi', $command);
1900 1900
 		}
1901
-		if($mode == '3') {
1901
+		if ($mode == '3') {
1902 1902
 			return $this->getData('plain', $command);
1903 1903
 		}
1904 1904
 	}
@@ -1915,7 +1915,7 @@  discard block
 block discarded – undo
1915 1915
   * @return     boolean success
1916 1916
   */
1917 1917
 	function ftCreateDir($cid, $cpw = null, $dirname) {
1918
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
1918
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
1919 1919
 		return $this->getData('boolean', 'ftcreatedir cid='.$cid.' cpw='.$this->escapeText($cpw).' dirname='.$this->escapeText($dirname));
1920 1920
 	}
1921 1921
 
@@ -1940,15 +1940,15 @@  discard block
 block discarded – undo
1940 1940
   * @return     boolean success
1941 1941
   */
1942 1942
 	function ftDeleteFile($cid, $cpw = '', $files) {
1943
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
1943
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
1944 1944
 		$fileArray = array();
1945 1945
 		
1946
-		if(count($files) > 0) {
1947
-			foreach($files AS $file) {
1946
+		if (count($files) > 0) {
1947
+			foreach ($files AS $file) {
1948 1948
 				$fileArray[] = 'name='.$this->escapeText($file);
1949 1949
 			}
1950 1950
 			return $this->getData('boolean', 'ftdeletefile cid='.$cid.' cpw='.$this->escapeText($cpw).' '.implode('|', $fileArray));
1951
-		}else{
1951
+		} else {
1952 1952
 			$this->addDebugLog('no files given');
1953 1953
 			return $this->generateOutput(false, array('Error: no files given'), false);
1954 1954
 		}
@@ -1967,15 +1967,15 @@  discard block
 block discarded – undo
1967 1967
 		$errnum = null;
1968 1968
 		$errstr = null;
1969 1969
   		$this->runtime['fileSocket'] = @fsockopen($this->runtime['host'], $data['data']['port'], $errnum, $errstr, $this->runtime['timeout']);
1970
-  		if($this->runtime['fileSocket']) {
1970
+  		if ($this->runtime['fileSocket']) {
1971 1971
   			$this->ftSendKey($data['data']['ftkey']);
1972 1972
   			$content = $this->ftRead($data['data']['size']);
1973 1973
   			@fclose($this->runtime['fileSocket']);
1974 1974
   			$this->runtime['fileSocket'] = '';
1975 1975
   			return $content;
1976
-  		}else{
1977
-  			$this->addDebugLog('fileSocket returns '.$errnum. ' | '.$errstr);
1978
-  			return $this->generateOutput(false, array('Error in fileSocket: '.$errnum. ' | '.$errstr), false);
1976
+  		} else {
1977
+  			$this->addDebugLog('fileSocket returns '.$errnum.' | '.$errstr);
1978
+  			return $this->generateOutput(false, array('Error in fileSocket: '.$errnum.' | '.$errstr), false);
1979 1979
   		}
1980 1980
 	}
1981 1981
 	
@@ -1992,7 +1992,7 @@  discard block
 block discarded – undo
1992 1992
   * @return     boolean success
1993 1993
   */
1994 1994
 	function ftGetFileInfo($cid, $cpw = '', $file) {
1995
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
1995
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
1996 1996
 
1997 1997
 		return $this->getData('multi', 'ftgetfileinfo cid='.$cid.' cpw='.$this->escapeText($cpw).' name='.$this->escapeText($file));
1998 1998
 	}
@@ -2022,7 +2022,7 @@  discard block
 block discarded – undo
2022 2022
   * @return     array	fileList
2023 2023
   */
2024 2024
 	function ftGetFileList($cid, $cpw = '', $path) {
2025
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
2025
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
2026 2026
 		return $this->getData('multi', 'ftgetfilelist cid='.$cid.' cpw='.$this->escapeText($cpw).' path='.$this->escapeText($path));
2027 2027
 	}
2028 2028
 	
@@ -2051,8 +2051,8 @@  discard block
 block discarded – undo
2051 2051
   * @return     array	initDownloadFileInfo
2052 2052
   */	
2053 2053
 	function ftInitDownload($name, $cid, $cpw = '', $seekpos = 0) {
2054
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
2055
-		return $this->getData('array', 'ftinitdownload clientftfid='.rand(1,99).' name='.$this->escapeText($name).' cid='.$cid.' cpw='.$this->escapeText($cpw).' seekpos='.$seekpos);
2054
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
2055
+		return $this->getData('array', 'ftinitdownload clientftfid='.rand(1, 99).' name='.$this->escapeText($name).' cid='.$cid.' cpw='.$this->escapeText($cpw).' seekpos='.$seekpos);
2056 2056
 	}
2057 2057
 
2058 2058
 /**
@@ -2082,12 +2082,12 @@  discard block
 block discarded – undo
2082 2082
   * @return     array	initUploadFileInfo
2083 2083
   */	
2084 2084
 	function ftInitUpload($filename, $cid, $size, $cpw = '', $overwrite = false, $resume = false) {
2085
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
2085
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
2086 2086
 		
2087
-		if($overwrite) { $overwrite = ' overwrite=1'; }else{ $overwrite = ' overwrite=0'; }
2088
-		if($resume) { $resume = ' resume=1'; }else{ $resume = ' resume=0'; }
2087
+		if ($overwrite) { $overwrite = ' overwrite=1'; } else { $overwrite = ' overwrite=0'; }
2088
+		if ($resume) { $resume = ' resume=1'; } else { $resume = ' resume=0'; }
2089 2089
 		
2090
-		return $this->getData('array', 'ftinitupload clientftfid='.rand(1,99).' name='.$this->escapeText($filename).' cid='.$cid.' cpw='.$this->escapeText($cpw).' size='.($size + 1).$overwrite.$resume);
2090
+		return $this->getData('array', 'ftinitupload clientftfid='.rand(1, 99).' name='.$this->escapeText($filename).' cid='.$cid.' cpw='.$this->escapeText($cpw).' size='.($size + 1).$overwrite.$resume);
2091 2091
 	}
2092 2092
 	
2093 2093
 /**
@@ -2119,7 +2119,7 @@  discard block
 block discarded – undo
2119 2119
   * @return     array	fileTransferList
2120 2120
   */
2121 2121
 	function ftList() {
2122
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
2122
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
2123 2123
 		return $this->getData('multi', 'ftlist');
2124 2124
 	}
2125 2125
 
@@ -2137,8 +2137,8 @@  discard block
 block discarded – undo
2137 2137
   * @param		string  $tcpw		targetChannelPassword [optional]
2138 2138
   * @return     boolean success
2139 2139
   */
2140
-	function ftRenameFile($cid, $cpw = null, $oldname, $newname, $tcid = null,  $tcpw = null) {
2141
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
2140
+	function ftRenameFile($cid, $cpw = null, $oldname, $newname, $tcid = null, $tcpw = null) {
2141
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
2142 2142
 		$newTarget = ($tcid != null ? ' tcid='.$tcid.' '.$tcpw : '');
2143 2143
 		return $this->getData('boolean', 'ftrenamefile cid='.$cid.' cpw='.$cpw.' oldname='.$this->escapeText($oldname).' newname='.$this->escapeText($newname).$newTarget);
2144 2144
 	}
@@ -2154,7 +2154,7 @@  discard block
 block discarded – undo
2154 2154
   * @return     boolean success
2155 2155
   */
2156 2156
 	function ftStop($serverftfid, $delete = true) {
2157
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }		
2157
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }		
2158 2158
 		return $this->getData('boolean', 'ftstop serverftfid='.$serverftfid.' delete='.($delete ? '1' : '0'));
2159 2159
 	}
2160 2160
 
@@ -2171,15 +2171,15 @@  discard block
 block discarded – undo
2171 2171
   */
2172 2172
 	function ftUploadFile($data, $uploadData) {
2173 2173
   		$this->runtime['fileSocket'] = @fsockopen($this->runtime['host'], $data['data']['port'], $errnum, $errstr, $this->runtime['timeout']);
2174
-  		if($this->runtime['fileSocket']) {
2174
+  		if ($this->runtime['fileSocket']) {
2175 2175
   			$this->ftSendKey($data['data']['ftkey'], "\n");
2176 2176
   			$this->ftSendData($uploadData);
2177 2177
   			@fclose($this->runtime['fileSocket']);
2178 2178
   			$this->runtime['fileSocket'] = '';
2179 2179
   			return $this->generateOutput(true, array(), true);
2180
-  		}else{
2181
-  			$this->addDebugLog('fileSocket returns '.$errnum. ' | '.$errstr);
2182
-  			return $this->generateOutput(false, array('Error in fileSocket: '.$errnum. ' | '.$errstr), false);
2180
+  		} else {
2181
+  			$this->addDebugLog('fileSocket returns '.$errnum.' | '.$errstr);
2182
+  			return $this->generateOutput(false, array('Error in fileSocket: '.$errnum.' | '.$errstr), false);
2183 2183
   		}
2184 2184
 	}
2185 2185
 
@@ -2193,7 +2193,7 @@  discard block
 block discarded – undo
2193 2193
   * @return     boolean success
2194 2194
   */
2195 2195
 	function gm($msg) {
2196
-		if(empty($msg)) {
2196
+		if (empty($msg)) {
2197 2197
 			$this->addDebugLog('empty message given');
2198 2198
 			return $this->generateOutput(false, array('Error: empty message given'), false);
2199 2199
 		}
@@ -2255,14 +2255,14 @@  discard block
 block discarded – undo
2255 2255
   * @return     boolean success
2256 2256
   */
2257 2257
 	function instanceEdit($data) {
2258
-		if(count($data) > 0) {
2258
+		if (count($data) > 0) {
2259 2259
 			$settingsString = '';
2260 2260
 			
2261
-			foreach($data as $key => $val) {
2261
+			foreach ($data as $key => $val) {
2262 2262
 				$settingsString .= ' '.$key.'='.$this->escapeText($val);
2263 2263
 			}
2264 2264
 			return $this->getData('boolean', 'instanceedit '.$settingsString);
2265
-		}else{
2265
+		} else {
2266 2266
 			$this->addDebugLog('empty array entered');
2267 2267
 			return $this->generateOutput(false, array('Error: You can \'t give an empty array'), false);
2268 2268
 		}
@@ -2311,14 +2311,14 @@  discard block
 block discarded – undo
2311 2311
   * @return     boolean success
2312 2312
   */
2313 2313
 	function logAdd($logLevel, $logMsg) {
2314
-		if($logLevel >=1 and $logLevel <= 4) { 
2315
-			if(!empty($logMsg)) {
2314
+		if ($logLevel >= 1 and $logLevel <= 4) { 
2315
+			if (!empty($logMsg)) {
2316 2316
 				return $this->getData('boolean', 'logadd loglevel='.$logLevel.' logmsg='.$this->escapeText($logMsg));
2317
-			}else{
2317
+			} else {
2318 2318
 				$this->addDebugLog('logMessage empty!');
2319 2319
 				return $this->generateOutput(false, array('Error: logMessage empty!'), false);
2320 2320
 			}
2321
-		}else{
2321
+		} else {
2322 2322
 			$this->addDebugLog('invalid logLevel!');
2323 2323
 			return $this->generateOutput(false, array('Error: invalid logLevel!'), false);
2324 2324
 		}
@@ -2380,9 +2380,9 @@  discard block
 block discarded – undo
2380 2380
   * @return     multidimensional-array logEntries
2381 2381
   */
2382 2382
 	function logView($lines, $reverse = 0, $instance = 0, $begin_pos = 0) {		
2383
-		if($lines >=1 and $lines <=100) {
2383
+		if ($lines >= 1 and $lines <= 100) {
2384 2384
 			return $this->getData('multi', 'logview lines='.$lines.' reverse='.($reverse == 0 ? '0' : '1').' instance='.($instance == 0 ? '0' : '1').' begin_pos='.($begin_pos == 0 ? '0' : $begin_pos));
2385
-		}else{
2385
+		} else {
2386 2386
 			$this->addDebugLog('please choose a limit between 1 and 100');
2387 2387
 			$this->generateOutput(false, array('Error: please choose a limit between 1 and 100'), false);
2388 2388
 		}
@@ -2400,7 +2400,7 @@  discard block
 block discarded – undo
2400 2400
   * @return     boolean success
2401 2401
   */
2402 2402
 	function messageAdd($cluid, $subject, $message) {		
2403
-        if(!$this->runtime['selected']) { return $this->checkSelected(); }
2403
+        if (!$this->runtime['selected']) { return $this->checkSelected(); }
2404 2404
         return $this->getData('boolean', 'messageadd cluid='.$cluid.' subject='.$this->escapeText($subject).' message='.$this->escapeText($message)); 
2405 2405
 	}
2406 2406
 
@@ -2414,7 +2414,7 @@  discard block
 block discarded – undo
2414 2414
   * @return     boolean success
2415 2415
   */
2416 2416
 	function messageDelete($messageID) {		
2417
-        if(!$this->runtime['selected']) { return $this->checkSelected(); }
2417
+        if (!$this->runtime['selected']) { return $this->checkSelected(); }
2418 2418
         return $this->getData('boolean', 'messagedel msgid='.$messageID); 
2419 2419
 	}
2420 2420
 
@@ -2428,7 +2428,7 @@  discard block
 block discarded – undo
2428 2428
   * @return     array messageInformation
2429 2429
   */
2430 2430
 	function messageGet($messageID) {		
2431
-        if(!$this->runtime['selected']) { return $this->checkSelected(); }
2431
+        if (!$this->runtime['selected']) { return $this->checkSelected(); }
2432 2432
         return $this->getData('array', 'messageget msgid='.$messageID); 
2433 2433
 	}
2434 2434
 
@@ -2441,7 +2441,7 @@  discard block
 block discarded – undo
2441 2441
   * @return     array messageInformation
2442 2442
   */
2443 2443
 	function messageList() {		
2444
-        if(!$this->runtime['selected']) { return $this->checkSelected(); }
2444
+        if (!$this->runtime['selected']) { return $this->checkSelected(); }
2445 2445
         return $this->getData('array', 'messagelist'); 
2446 2446
 	}
2447 2447
 
@@ -2456,7 +2456,7 @@  discard block
 block discarded – undo
2456 2456
   * @return     array messageInformation
2457 2457
   */
2458 2458
 	function messageUpdateFlag($messageID, $flag = 1) {		
2459
-        if(!$this->runtime['selected']) { return $this->checkSelected(); }
2459
+        if (!$this->runtime['selected']) { return $this->checkSelected(); }
2460 2460
         return $this->getData('boolean', 'messageupdateflag msgid='.$messageID.' flag='.$flag); 
2461 2461
 	}
2462 2462
 
@@ -2478,7 +2478,7 @@  discard block
 block discarded – undo
2478 2478
   * @return     array permissionInfoList
2479 2479
   */
2480 2480
 	function permFind($perm) { 
2481
-        if(!$this->runtime['selected']) { return $this->checkSelected(); }
2481
+        if (!$this->runtime['selected']) { return $this->checkSelected(); }
2482 2482
         return $this->getData('multi', 'permfind '.(is_int($perm) || ctype_digit($perm) ? 'permid=' : 'permsid=').$perm); 
2483 2483
     }
2484 2484
 	
@@ -2505,7 +2505,7 @@  discard block
 block discarded – undo
2505 2505
   * @return     array permissionInfo
2506 2506
   */
2507 2507
 	function permGet($perm) { 
2508
-        if(!$this->runtime['selected']) { return $this->checkSelected(); }
2508
+        if (!$this->runtime['selected']) { return $this->checkSelected(); }
2509 2509
         return $this->getData('array', 'permget '.(is_int($perm) || ctype_digit($perm) ? 'permid=' : 'permsid=').$perm); 
2510 2510
     }	
2511 2511
 	
@@ -2535,12 +2535,12 @@  discard block
 block discarded – undo
2535 2535
 	function permIdGetByName($permsids) {
2536 2536
 		$permissionArray = array();
2537 2537
 		
2538
-		if(count($permsids) > 0) {
2539
-			foreach($permsids AS $value) {
2538
+		if (count($permsids) > 0) {
2539
+			foreach ($permsids AS $value) {
2540 2540
 				$permissionArray[] = 'permsid='.$value;
2541 2541
 			}
2542 2542
 			return $this->getData('multi', 'permidgetbyname '.$this->escapeText(implode('|', $permissionArray)));
2543
-		}else{
2543
+		} else {
2544 2544
 			$this->addDebugLog('no permissions given');
2545 2545
 			return $this->generateOutput(false, array('Error: no permissions given'), false);
2546 2546
 		}
@@ -2636,7 +2636,7 @@  discard block
 block discarded – undo
2636 2636
   * @return     array permissionList
2637 2637
   */
2638 2638
 	function permissionList($new = false) {
2639
-		if($new === true) {
2639
+		if ($new === true) {
2640 2640
 			$groups = array();
2641 2641
 			$permissions = array();
2642 2642
 			
@@ -2644,21 +2644,21 @@  discard block
 block discarded – undo
2644 2644
 			
2645 2645
 			$gc = 1;
2646 2646
 			
2647
-			foreach($response as $field) {
2648
-				if(isset($field['group_id_end'])) {
2647
+			foreach ($response as $field) {
2648
+				if (isset($field['group_id_end'])) {
2649 2649
 					$groups[] = array('num' => $gc, 'group_id_end' => $field['group_id_end']);
2650 2650
 					$gc++;
2651
-				}else{
2651
+				} else {
2652 2652
 					$permissions[] = $field;
2653 2653
 				}
2654 2654
 			}
2655 2655
 			
2656 2656
 			$counter = 0;
2657 2657
 			
2658
-			for($i = 0; $i < count($groups); $i++) {
2658
+			for ($i = 0; $i < count($groups); $i++) {
2659 2659
 				$rounds = $groups[$i]['group_id_end'] - $counter;
2660 2660
 				$groups[$i]['pcount'] = $rounds;
2661
-				for($j = 0; $j < $rounds; $j++) {
2661
+				for ($j = 0; $j < $rounds; $j++) {
2662 2662
 					$groups[$i]['permissions'][] = array('permid' => ($counter + 1), 'permname' => $permissions[$counter]['permname'], 'permdesc' => $permissions[$counter]['permdesc'], 'grantpermid' => ($counter + 32769));
2663 2663
 					$counter++;
2664 2664
 				}
@@ -2666,7 +2666,7 @@  discard block
 block discarded – undo
2666 2666
 			
2667 2667
 			return $groups;
2668 2668
 			
2669
-		}else{
2669
+		} else {
2670 2670
 			return $this->getData('multi', 'permissionlist');
2671 2671
 		}
2672 2672
 	}
@@ -2699,9 +2699,9 @@  discard block
 block discarded – undo
2699 2699
   * @param		string	 	$permsid	permName
2700 2700
   * @return     array permOverview
2701 2701
   */
2702
-	function permOverview($cid, $cldbid, $permid='0', $permsid=false ) { 
2703
-        if(!$this->runtime['selected']) { return $this->checkSelected(); } 
2704
-        if($permsid) { $additional = ' permsid='.$permsid; }else{ $additional = ''; } 
2702
+	function permOverview($cid, $cldbid, $permid = '0', $permsid = false) { 
2703
+        if (!$this->runtime['selected']) { return $this->checkSelected(); } 
2704
+        if ($permsid) { $additional = ' permsid='.$permsid; } else { $additional = ''; } 
2705 2705
          
2706 2706
         return $this->getData('multi', 'permoverview cid='.$cid.' cldbid='.$cldbid.($permsid == false ? ' permid='.$permid : '').$additional); 
2707 2707
     }
@@ -2723,7 +2723,7 @@  discard block
 block discarded – undo
2723 2723
   * @return     array token
2724 2724
   */
2725 2725
 	function permReset() { 
2726
-        if(!$this->runtime['selected']) { return $this->checkSelected(); } 
2726
+        if (!$this->runtime['selected']) { return $this->checkSelected(); } 
2727 2727
         return $this->getData('array', 'permreset'); 
2728 2728
     }
2729 2729
 	
@@ -2749,7 +2749,7 @@  discard block
 block discarded – undo
2749 2749
   * @param		array	$customFieldSet			customFieldSet [optional]
2750 2750
   * @return     array	tokenInformation
2751 2751
   */
2752
-	function privilegekeyAdd($tokentype, $tokenid1, $tokenid2, $description ='', $customFieldSet = array()) {
2752
+	function privilegekeyAdd($tokentype, $tokenid1, $tokenid2, $description = '', $customFieldSet = array()) {
2753 2753
 		return $this->tokenAdd($tokentype, $tokenid1, $tokenid2, $description, $customFieldSet);
2754 2754
 	}
2755 2755
 
@@ -2828,23 +2828,23 @@  discard block
 block discarded – undo
2828 2828
   * @return     boolean success
2829 2829
   */
2830 2830
 	function selectServer($value, $type = 'port', $virtual = false) { 
2831
-        if(in_array($type, array('port', 'serverId'))) { 
2832
-            if($type == 'port') { 
2833
-                if($virtual) { $virtual = ' -virtual'; }else{ $virtual = ''; } 
2831
+        if (in_array($type, array('port', 'serverId'))) { 
2832
+            if ($type == 'port') { 
2833
+                if ($virtual) { $virtual = ' -virtual'; } else { $virtual = ''; } 
2834 2834
                 $res = $this->getData('boolean', 'use port='.$value.$virtual); 
2835
-                if($res['success']) { 
2835
+                if ($res['success']) { 
2836 2836
                     $this->runtime['selected'] = true; 
2837 2837
                 } 
2838 2838
                 return $res; 
2839
-            }else{ 
2840
-                if($virtual) { $virtual = ' -virtual'; }else{ $virtual = ''; } 
2839
+            } else { 
2840
+                if ($virtual) { $virtual = ' -virtual'; } else { $virtual = ''; } 
2841 2841
                 $res = $this->getData('boolean', 'use sid='.$value.$virtual); 
2842
-                if($res['success']) { 
2842
+                if ($res['success']) { 
2843 2843
                     $this->runtime['selected'] = true; 
2844 2844
                 } 
2845 2845
                 return $res; 
2846 2846
             } 
2847
-        }else{ 
2847
+        } else { 
2848 2848
             $this->addDebugLog('wrong value type'); 
2849 2849
             return $this->generateOutput(false, array('Error: wrong value type'), false); 
2850 2850
         } 
@@ -2877,7 +2877,7 @@  discard block
 block discarded – undo
2877 2877
   * @return     boolean	success
2878 2878
   */
2879 2879
 	function sendMessage($mode, $target, $msg) {
2880
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
2880
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
2881 2881
 		return $this->getData('boolean', 'sendtextmessage targetmode='.$mode.' target='.$target.' msg='.$this->escapeText($msg));
2882 2882
 	}
2883 2883
 
@@ -2911,11 +2911,11 @@  discard block
 block discarded – undo
2911 2911
 	function serverCreate($data = array()) {
2912 2912
 		$settingsString = '';
2913 2913
 		
2914
-		if(count($data) == 0) {	$data['virtualserver_name'] = 'Teamspeak 3 Server'; }
2914
+		if (count($data) == 0) {	$data['virtualserver_name'] = 'Teamspeak 3 Server'; }
2915 2915
 		
2916 2916
 		
2917
-		foreach($data as $key => $value) {
2918
-			if(!empty($value)) { $settingsString .= ' '.$key.'='.$this->escapeText($value); }
2917
+		foreach ($data as $key => $value) {
2918
+			if (!empty($value)) { $settingsString .= ' '.$key.'='.$this->escapeText($value); }
2919 2919
 		}
2920 2920
 		
2921 2921
 		return $this->getData('array', 'servercreate'.$settingsString);
@@ -2953,11 +2953,11 @@  discard block
 block discarded – undo
2953 2953
   * @return     boolean success
2954 2954
   */
2955 2955
 	function serverEdit($data) {
2956
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
2956
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
2957 2957
 		
2958 2958
 		$settingsString = '';
2959 2959
 		
2960
-		foreach($data as $key => $value) {
2960
+		foreach ($data as $key => $value) {
2961 2961
 			$settingsString .= ' '.$key.'='.$this->escapeText($value);
2962 2962
 		}
2963 2963
 		
@@ -2983,7 +2983,7 @@  discard block
 block discarded – undo
2983 2983
   * @return     array groupId
2984 2984
   */
2985 2985
 	function serverGroupAdd($name, $type = 1) {
2986
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
2986
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
2987 2987
 		return $this->getData('array', 'servergroupadd name='.$this->escapeText($name).' type='.$type);
2988 2988
 	}
2989 2989
 
@@ -2998,7 +2998,7 @@  discard block
 block discarded – undo
2998 2998
   * @return     boolean success
2999 2999
   */
3000 3000
 	function serverGroupAddClient($sgid, $cldbid) {
3001
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
3001
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
3002 3002
 		return $this->getData('boolean', 'servergroupaddclient sgid='.$sgid.' cldbid='.$cldbid);
3003 3003
 	}
3004 3004
 
@@ -3021,9 +3021,9 @@  discard block
 block discarded – undo
3021 3021
   * @return     boolean success
3022 3022
   */
3023 3023
 	function serverGroupAddPerm($sgid, $permissions) {
3024
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
3024
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
3025 3025
 		
3026
-		if(count($permissions) > 0) {
3026
+		if (count($permissions) > 0) {
3027 3027
 			//Permissions given
3028 3028
 				
3029 3029
 			//Errorcollector
@@ -3033,35 +3033,35 @@  discard block
 block discarded – undo
3033 3033
 			$permissions = array_chunk($permissions, 50, true);
3034 3034
 				
3035 3035
 			//Action for each splitted part of permission
3036
-			foreach($permissions as $permission_part)
3036
+			foreach ($permissions as $permission_part)
3037 3037
 			{
3038 3038
 				//Create command_string for each command that we could use implode later
3039 3039
 				$command_string = array();
3040 3040
 		
3041
-				foreach($permission_part as $key => $value)
3041
+				foreach ($permission_part as $key => $value)
3042 3042
 				{
3043 3043
 					$command_string[] = (is_numeric($key) ? "permid=" : "permsid=").$this->escapeText($key).' permvalue='.$value[0].' permskip='.$value[1].' permnegated='.$value[2];
3044 3044
 				}
3045 3045
 		
3046 3046
 				$result = $this->getData('boolean', 'servergroupaddperm sgid='.$sgid.' '.implode('|', $command_string));
3047 3047
 		
3048
-				if(!$result['success'])
3048
+				if (!$result['success'])
3049 3049
 				{
3050
-					foreach($result['errors'] as $error)
3050
+					foreach ($result['errors'] as $error)
3051 3051
 					{
3052 3052
 						$errors[] = $error;
3053 3053
 					}
3054 3054
 				}
3055 3055
 			}
3056 3056
 				
3057
-			if(count($errors) == 0)
3057
+			if (count($errors) == 0)
3058 3058
 			{
3059 3059
 				return $this->generateOutput(true, array(), true);
3060
-			}else{
3060
+			} else {
3061 3061
 				return $this->generateOutput(false, $errors, false);
3062 3062
 			}
3063 3063
 				
3064
-		}else{
3064
+		} else {
3065 3065
 			// No permissions given
3066 3066
 			$this->addDebugLog('no permissions given');
3067 3067
 			return $this->generateOutput(false, array('Error: no permissions given'), false);
@@ -3087,9 +3087,9 @@  discard block
 block discarded – undo
3087 3087
   * @return     boolean success
3088 3088
   */
3089 3089
 	function serverGroupAutoAddPerm($sgtype, $permissions) {
3090
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
3090
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
3091 3091
 		
3092
-		if(count($permissions) > 0) {
3092
+		if (count($permissions) > 0) {
3093 3093
 			//Permissions given
3094 3094
 				
3095 3095
 			//Errorcollector
@@ -3099,35 +3099,35 @@  discard block
 block discarded – undo
3099 3099
 			$permissions = array_chunk($permissions, 50, true);
3100 3100
 				
3101 3101
 			//Action for each splitted part of permission
3102
-			foreach($permissions as $permission_part)
3102
+			foreach ($permissions as $permission_part)
3103 3103
 			{
3104 3104
 				//Create command_string for each command that we could use implode later
3105 3105
 				$command_string = array();
3106 3106
 		
3107
-				foreach($permission_part as $key => $value)
3107
+				foreach ($permission_part as $key => $value)
3108 3108
 				{
3109 3109
 					$command_string[] = (is_numeric($key) ? "permid=" : "permsid=").$this->escapeText($key).' permvalue='.$value[0].' permskip='.$value[1].' permnegated='.$value[2];
3110 3110
 				}
3111 3111
 		
3112 3112
 				$result = $this->getData('boolean', 'servergroupautoaddperm sgtype='.$sgtype.' '.implode('|', $command_string));
3113 3113
 		
3114
-				if(!$result['success'])
3114
+				if (!$result['success'])
3115 3115
 				{
3116
-					foreach($result['errors'] as $error)
3116
+					foreach ($result['errors'] as $error)
3117 3117
 					{
3118 3118
 						$errors[] = $error;
3119 3119
 					}
3120 3120
 				}
3121 3121
 			}
3122 3122
 				
3123
-			if(count($errors) == 0)
3123
+			if (count($errors) == 0)
3124 3124
 			{
3125 3125
 				return $this->generateOutput(true, array(), true);
3126
-			}else{
3126
+			} else {
3127 3127
 				return $this->generateOutput(false, $errors, false);
3128 3128
 			}
3129 3129
 				
3130
-		}else{
3130
+		} else {
3131 3131
 			// No permissions given
3132 3132
 			$this->addDebugLog('no permissions given');
3133 3133
 			return $this->generateOutput(false, array('Error: no permissions given'), false);
@@ -3153,15 +3153,15 @@  discard block
 block discarded – undo
3153 3153
   * @return     boolean success
3154 3154
   */
3155 3155
 	function serverGroupAutoDeletePerm($sgtype, $permissions) {
3156
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
3156
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
3157 3157
 		$permissionArray = array();
3158 3158
 		
3159
-		if(count($permissions) > 0) {
3160
-			foreach($permissions AS $value) {
3159
+		if (count($permissions) > 0) {
3160
+			foreach ($permissions AS $value) {
3161 3161
 				$permissionArray[] = is_numeric($value) ? 'permid='.$value : 'permsid='.$this->escapeText($value);
3162 3162
 			}
3163 3163
 			return $this->getData('boolean', 'servergroupautodelperm sgtype='.$sgtype.' '.implode('|', $permissionArray));
3164
-		}else{
3164
+		} else {
3165 3165
 			$this->addDebugLog('no permissions given');
3166 3166
 			return $this->generateOutput(false, array('Error: no permissions given'), false);
3167 3167
 		}
@@ -3190,8 +3190,8 @@  discard block
 block discarded – undo
3190 3190
   * @return     multidimensional-array	serverGroupClientList
3191 3191
   */
3192 3192
 	function serverGroupClientList($sgid, $names = false) {
3193
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
3194
-		if($names) { $names = ' -names'; }else{ $names = ''; }
3193
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
3194
+		if ($names) { $names = ' -names'; } else { $names = ''; }
3195 3195
 		return $this->getData('multi', 'servergroupclientlist sgid='.$sgid.$names);
3196 3196
 	}
3197 3197
 
@@ -3216,7 +3216,7 @@  discard block
 block discarded – undo
3216 3216
   * @return     array groupId
3217 3217
   */
3218 3218
 	function serverGroupCopy($ssgid, $tsgid, $name, $type = 1) {
3219
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
3219
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
3220 3220
 		return $this->getData('array', 'servergroupcopy ssgid='.$ssgid.' tsgid='.$tsgid.' name='.$this->escapeText($name).' type='.$type);
3221 3221
 	}
3222 3222
 
@@ -3231,7 +3231,7 @@  discard block
 block discarded – undo
3231 3231
   * @return     boolean success
3232 3232
   */
3233 3233
 	function serverGroupDelete($sgid, $force = 1) {
3234
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
3234
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
3235 3235
 		return $this->getData('boolean', 'servergroupdel sgid='.$sgid.' force='.$force);
3236 3236
 	}
3237 3237
 
@@ -3246,7 +3246,7 @@  discard block
 block discarded – undo
3246 3246
   * @return     boolean success
3247 3247
   */
3248 3248
 	function serverGroupDeleteClient($sgid, $cldbid) {
3249
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
3249
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
3250 3250
 		return $this->getData('boolean', 'servergroupdelclient sgid='.$sgid.' cldbid='.$cldbid);
3251 3251
 	}
3252 3252
 
@@ -3269,15 +3269,15 @@  discard block
 block discarded – undo
3269 3269
   * @return     boolean success
3270 3270
   */
3271 3271
 	function serverGroupDeletePerm($sgid, $permissionIds) {
3272
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
3272
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
3273 3273
 		$permissionArray = array();
3274 3274
 		
3275
-		if(count($permissionIds) > 0) {
3276
-			foreach($permissionIds AS $value) {
3275
+		if (count($permissionIds) > 0) {
3276
+			foreach ($permissionIds AS $value) {
3277 3277
 				$permissionArray[] = is_numeric($value) ? 'permid='.$value : 'permsid='.$this->escapeText($value);
3278 3278
 			}
3279 3279
 			return $this->getData('boolean', 'servergroupdelperm sgid='.$sgid.' '.implode('|', $permissionArray));
3280
-		}else{
3280
+		} else {
3281 3281
 			$this->addDebugLog('no permissions given');
3282 3282
 			return $this->generateOutput(false, array('Error: no permissions given'), false);
3283 3283
 		}
@@ -3304,7 +3304,7 @@  discard block
 block discarded – undo
3304 3304
   * @return     array serverGroupList
3305 3305
   */
3306 3306
 	function serverGroupList() {
3307
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
3307
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
3308 3308
 		return $this->getData('multi', 'servergrouplist');
3309 3309
 	}
3310 3310
 
@@ -3331,8 +3331,8 @@  discard block
 block discarded – undo
3331 3331
   * @return     array serverGroupPermList
3332 3332
   */
3333 3333
 	function serverGroupPermList($sgid, $permsid = false) {
3334
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
3335
-		if($permsid) { $additional = ' -permsid'; }else{ $additional = ''; }
3334
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
3335
+		if ($permsid) { $additional = ' -permsid'; } else { $additional = ''; }
3336 3336
 		return $this->getData('multi', 'servergrouppermlist sgid='.$sgid.$additional);
3337 3337
 	}
3338 3338
 
@@ -3347,7 +3347,7 @@  discard block
 block discarded – undo
3347 3347
   * @return     boolean success
3348 3348
   */
3349 3349
 	function serverGroupRename($sgid, $name) {
3350
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
3350
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
3351 3351
 		return $this->getData('boolean', 'servergrouprename sgid='.$sgid.' name='.$this->escapeText($name));
3352 3352
 	}
3353 3353
 
@@ -3371,7 +3371,7 @@  discard block
 block discarded – undo
3371 3371
   * @return     array serverGroupsByClientId
3372 3372
   */
3373 3373
 	function serverGroupsByClientID($cldbid) {
3374
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
3374
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
3375 3375
 		return $this->getData('multi', 'servergroupsbyclientid cldbid='.$cldbid);
3376 3376
 	}
3377 3377
 
@@ -3508,7 +3508,7 @@  discard block
 block discarded – undo
3508 3508
   * @return     array serverInformation
3509 3509
   */
3510 3510
 	function serverInfo() {
3511
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
3511
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
3512 3512
 		return $this->getData('array', 'serverinfo');
3513 3513
 	}
3514 3514
 
@@ -3588,7 +3588,7 @@  discard block
 block discarded – undo
3588 3588
   * @return     array serverRequestConnectionInfo
3589 3589
   */
3590 3590
 	function serverRequestConnectionInfo() {
3591
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
3591
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
3592 3592
 		return $this->getData('array', 'serverrequestconnectioninfo');
3593 3593
 	}
3594 3594
 
@@ -3601,7 +3601,7 @@  discard block
 block discarded – undo
3601 3601
   * @return     string snapshot
3602 3602
   */
3603 3603
 	function serverSnapshotCreate() {
3604
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
3604
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
3605 3605
 		return $this->getData('plain', 'serversnapshotcreate');
3606 3606
 	}
3607 3607
 
@@ -3618,7 +3618,7 @@  discard block
 block discarded – undo
3618 3618
   * @return     boolean success
3619 3619
   */
3620 3620
 	function serverSnapshotDeploy($snapshot, $mapping = false) {
3621
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
3621
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
3622 3622
 		return $this->getData('boolean', 'serversnapshotdeploy '.($mapping ? '-mapping ' : '').$snapshot);
3623 3623
 	}
3624 3624
 	
@@ -3662,7 +3662,7 @@  discard block
 block discarded – undo
3662 3662
   * @return     boolean success
3663 3663
   */
3664 3664
 	function serverTempPasswordAdd($pw, $duration, $desc = 'none', $tcid = 0, $tcpw = null) {
3665
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
3665
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
3666 3666
 		return $this->getdata('boolean', 'servertemppasswordadd pw='.$this->escapeText($pw).' desc='.(!empty($desc) ? $this->escapeText($desc) : 'none').' duration='.$duration.' tcid='.$tcid.(!empty($tcpw) ? ' tcpw='.$this->escapeText($tcpw) : ''));
3667 3667
 	}
3668 3668
 
@@ -3676,7 +3676,7 @@  discard block
 block discarded – undo
3676 3676
   * @return     boolean success
3677 3677
   */	
3678 3678
 	function serverTempPasswordDel($pw) {
3679
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
3679
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
3680 3680
 		return $this->getdata('boolean', 'servertemppassworddel pw='.$this->escapeText($pw));
3681 3681
 	}
3682 3682
 
@@ -3703,7 +3703,7 @@  discard block
 block discarded – undo
3703 3703
   * @return     array	serverTemppasswordList
3704 3704
   */
3705 3705
 	function serverTempPasswordList() {
3706
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
3706
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
3707 3707
 		return $this->getData('multi', 'servertemppasswordlist');
3708 3708
 	}
3709 3709
 	
@@ -3720,7 +3720,7 @@  discard block
 block discarded – undo
3720 3720
   * @return     boolean success
3721 3721
   */
3722 3722
 	function setClientChannelGroup($cgid, $cid, $cldbid) {
3723
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
3723
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
3724 3724
 		return $this->getData('boolean', 'setclientchannelgroup cgid='.$cgid.' cid='.$cid.' cldbid='.$cldbid);
3725 3725
 	}
3726 3726
 
@@ -3759,22 +3759,22 @@  discard block
 block discarded – undo
3759 3759
   * @param		array	$customFieldSet			customFieldSet [optional]
3760 3760
   * @return     array	tokenInformation
3761 3761
   */
3762
-	function tokenAdd($tokentype, $tokenid1, $tokenid2, $description ='', $customFieldSet = array()) {
3763
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
3762
+	function tokenAdd($tokentype, $tokenid1, $tokenid2, $description = '', $customFieldSet = array()) {
3763
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
3764 3764
 		
3765
-		if(!empty($description)) { $description = ' tokendescription=' . $this->escapeText($description); }
3765
+		if (!empty($description)) { $description = ' tokendescription='.$this->escapeText($description); }
3766 3766
 
3767
-		if($tokentype == '0') { $tokenid2 = '0'; }
3767
+		if ($tokentype == '0') { $tokenid2 = '0'; }
3768 3768
 		
3769
-		if(count($customFieldSet)) {
3769
+		if (count($customFieldSet)) {
3770 3770
 			$settingsString = array();
3771 3771
 		
3772
-			foreach($customFieldSet as $key => $value) {
3772
+			foreach ($customFieldSet as $key => $value) {
3773 3773
 				$settingsString[] = 'ident='.$this->escapeText($key).'\svalue='.$this->escapeText($value);
3774 3774
 			}
3775 3775
 			
3776 3776
 			$customFieldSet = ' tokencustomset='.implode('\p', $settingsString);
3777
-		}else{
3777
+		} else {
3778 3778
 			$customFieldSet = '';
3779 3779
 		}
3780 3780
 		
@@ -3791,7 +3791,7 @@  discard block
 block discarded – undo
3791 3791
   * @return     boolean success
3792 3792
   */
3793 3793
 	function tokenDelete($token) {
3794
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }			
3794
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }			
3795 3795
 		return $this->getData('boolean', 'privilegekeydelete token='.$token);
3796 3796
 	}
3797 3797
 
@@ -3817,7 +3817,7 @@  discard block
 block discarded – undo
3817 3817
   * @return     array tokenListist 
3818 3818
   */
3819 3819
 	function tokenList() {
3820
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }
3820
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }
3821 3821
 
3822 3822
 		return $this->getData('multi', 'privilegekeylist');
3823 3823
 	}
@@ -3832,7 +3832,7 @@  discard block
 block discarded – undo
3832 3832
   * @return     boolean success
3833 3833
   */
3834 3834
 	function tokenUse($token) {
3835
-		if(!$this->runtime['selected']) { return $this->checkSelected(); }			
3835
+		if (!$this->runtime['selected']) { return $this->checkSelected(); }			
3836 3836
 		return $this->getData('boolean', 'privilegekeyuse token='.$token);
3837 3837
 	}
3838 3838
 
@@ -3950,10 +3950,10 @@  discard block
 block discarded – undo
3950 3950
   */
3951 3951
  	public function convertSecondsToArrayTime($seconds) {
3952 3952
 		$conv_time = array();
3953
-		$conv_time['days']=floor($seconds / 86400);
3954
-		$conv_time['hours']=floor(($seconds - ($conv_time['days'] * 86400)) / 3600);
3955
-		$conv_time['minutes']=floor(($seconds - (($conv_time['days'] * 86400)+($conv_time['hours']*3600))) / 60);
3956
-		$conv_time['seconds']=floor(($seconds - (($conv_time['days'] * 86400)+($conv_time['hours']*3600)+($conv_time['minutes'] * 60))));
3953
+		$conv_time['days'] = floor($seconds / 86400);
3954
+		$conv_time['hours'] = floor(($seconds - ($conv_time['days'] * 86400)) / 3600);
3955
+		$conv_time['minutes'] = floor(($seconds - (($conv_time['days'] * 86400) + ($conv_time['hours'] * 3600))) / 60);
3956
+		$conv_time['seconds'] = floor(($seconds - (($conv_time['days'] * 86400) + ($conv_time['hours'] * 3600) + ($conv_time['minutes'] * 60))));
3957 3957
 		return $conv_time;
3958 3958
 	}
3959 3959
 
@@ -4007,9 +4007,9 @@  discard block
 block discarded – undo
4007 4007
   * @return     boolean
4008 4008
   */
4009 4009
 	public function succeeded($array) {
4010
-		if(isset($array['success'])) {
4010
+		if (isset($array['success'])) {
4011 4011
 			return $array['success'];
4012
-		}else{
4012
+		} else {
4013 4013
 			return false;
4014 4014
 		}
4015 4015
 	}
@@ -4030,15 +4030,15 @@  discard block
 block discarded – undo
4030 4030
  * @return	void
4031 4031
 */
4032 4032
 	function __construct($host, $queryport, $timeout = 2) {
4033
-		if($queryport >= 1 and $queryport <= 65536) {
4034
-			if($timeout >= 1) {
4033
+		if ($queryport >= 1 and $queryport <= 65536) {
4034
+			if ($timeout >= 1) {
4035 4035
 				$this->runtime['host'] = $host;
4036 4036
 				$this->runtime['queryport'] = $queryport;
4037 4037
 				$this->runtime['timeout'] = $timeout;
4038
-			}else{
4038
+			} else {
4039 4039
 				$this->addDebugLog('invalid timeout value');
4040 4040
 			}
4041
-		}else{
4041
+		} else {
4042 4042
 			$this->addDebugLog('invalid queryport');
4043 4043
 		}
4044 4044
 	}
@@ -4077,9 +4077,9 @@  discard block
 block discarded – undo
4077 4077
   * @return     boolean connected
4078 4078
   */
4079 4079
 	private function isConnected() {
4080
-		if(empty($this->runtime['socket'])) {
4080
+		if (empty($this->runtime['socket'])) {
4081 4081
 			return false;
4082
-		}else{
4082
+		} else {
4083 4083
 			return true;
4084 4084
 		}
4085 4085
 	}
@@ -4166,21 +4166,21 @@  discard block
 block discarded – undo
4166 4166
   * @return		boolean success
4167 4167
   */
4168 4168
 	function connect() {
4169
-		if($this->isConnected()) { 
4169
+		if ($this->isConnected()) { 
4170 4170
 			$this->addDebugLog('Error: you are already connected!');
4171 4171
 			return $this->generateOutput(false, array('Error: the script is already connected!'), false);
4172 4172
 		}
4173 4173
 		$socket = @fsockopen($this->runtime['host'], $this->runtime['queryport'], $errnum, $errstr, $this->runtime['timeout']);
4174 4174
 
4175
-		if(!$socket) {
4175
+		if (!$socket) {
4176 4176
 			$this->addDebugLog('Error: connection failed!');
4177 4177
 			return $this->generateOutput(false, array('Error: connection failed!', 'Server returns: '.$errstr), false);
4178
-		}else{
4179
-			if(strpos(fgets($socket), 'TS3') !== false) {
4178
+		} else {
4179
+			if (strpos(fgets($socket), 'TS3') !== false) {
4180 4180
 				$tmpVar = fgets($socket);
4181 4181
 				$this->runtime['socket'] = $socket;
4182 4182
 				return $this->generateOutput(true, array(), true);
4183
-			}else{
4183
+			} else {
4184 4184
 				$this->addDebugLog('host isn\'t a ts3 instance!');
4185 4185
 				return $this->generateOutput(false, array('Error: host isn\'t a ts3 instance!'), false);
4186 4186
 			}
@@ -4198,7 +4198,7 @@  discard block
 block discarded – undo
4198 4198
   * @return     mixed data
4199 4199
   */
4200 4200
 	private function executeCommand($command, $tracert) {
4201
-		if(!$this->isConnected()) {
4201
+		if (!$this->isConnected()) {
4202 4202
 			$this->addDebugLog('script isn\'t connected to server', $tracert[1]['function'], $tracert[0]['line']);
4203 4203
 			return $this->generateOutput(false, array('Error: script isn\'t connected to server'), false);
4204 4204
 		}
@@ -4210,22 +4210,22 @@  discard block
 block discarded – undo
4210 4210
 		
4211 4211
 		$splittedCommand[(count($splittedCommand) - 1)] .= "\n";
4212 4212
 		
4213
-		foreach($splittedCommand as $commandPart) {
4213
+		foreach ($splittedCommand as $commandPart) {
4214 4214
 			fputs($this->runtime['socket'], $commandPart);
4215 4215
 		}
4216 4216
 
4217 4217
 		do {
4218 4218
 			$data .= fgets($this->runtime['socket'], 4096);
4219 4219
 			
4220
-			if(strpos($data, 'error id=3329 msg=connection') !== false) {
4220
+			if (strpos($data, 'error id=3329 msg=connection') !== false) {
4221 4221
 				$this->runtime['socket'] = '';
4222 4222
 				$this->addDebugLog('You got banned from server. Socket closed.', $tracert[1]['function'], $tracert[0]['line']);
4223 4223
 				return $this->generateOutput(false, array('You got banned from server. Connection closed.'), false);
4224 4224
 			}
4225 4225
 			
4226
-		} while(strpos($data, 'msg=') === false or strpos($data, 'error id=') === false);
4226
+		} while (strpos($data, 'msg=') === false or strpos($data, 'error id=') === false);
4227 4227
 
4228
-		if(strpos($data, 'error id=0 msg=ok') === false) {
4228
+		if (strpos($data, 'error id=0 msg=ok') === false) {
4229 4229
 			$splittedResponse = explode('error id=', $data);
4230 4230
 			$chooseEnd = count($splittedResponse) - 1;
4231 4231
 			
@@ -4234,7 +4234,7 @@  discard block
 block discarded – undo
4234 4234
 			$this->addDebugLog('ErrorID: '.$cutIdAndMsg[0].' | Message: '.$this->unEscapeText($cutIdAndMsg[1]), $tracert[1]['function'], $tracert[0]['line']);
4235 4235
 			
4236 4236
 			return $this->generateOutput(false, array('ErrorID: '.$cutIdAndMsg[0].' | Message: '.$this->unEscapeText($cutIdAndMsg[1])), false);
4237
-		}else{
4237
+		} else {
4238 4238
 			return $this->generateOutput(true, array(), $data);
4239 4239
 		}
4240 4240
 	}
@@ -4254,12 +4254,12 @@  discard block
 block discarded – undo
4254 4254
 	
4255 4255
 		$validModes = array('boolean', 'array', 'multi', 'plain');
4256 4256
 	
4257
-		if(!in_array($mode, $validModes)) {
4257
+		if (!in_array($mode, $validModes)) {
4258 4258
 			$this->addDebugLog($mode.' is an invalid mode');
4259 4259
 			return $this->generateOutput(false, array('Error: '.$mode.' is an invalid mode'), false);
4260 4260
 		}
4261 4261
 		
4262
-		if(empty($command)) {
4262
+		if (empty($command)) {
4263 4263
 			$this->addDebugLog('you have to enter a command');
4264 4264
 			return $this->generateOutput(false, array('Error: you have to enter a command'), false);
4265 4265
 		}
@@ -4270,29 +4270,29 @@  discard block
 block discarded – undo
4270 4270
 		$fetchData['data'] = str_replace(array('error id=0 msg=ok', chr('01')), '', $fetchData['data']);
4271 4271
 		
4272 4272
 		
4273
-		if($fetchData['success']) {
4274
-			if($mode == 'boolean') {
4273
+		if ($fetchData['success']) {
4274
+			if ($mode == 'boolean') {
4275 4275
 				return $this->generateOutput(true, array(), true);
4276 4276
 			}
4277 4277
 			
4278
-			if($mode == 'array') {
4279
-				if(empty($fetchData['data'])) { return $this->generateOutput(true, array(), array()); }
4278
+			if ($mode == 'array') {
4279
+				if (empty($fetchData['data'])) { return $this->generateOutput(true, array(), array()); }
4280 4280
 				$datasets = explode(' ', $fetchData['data']);
4281 4281
 				
4282 4282
 				$output = array();
4283 4283
 				
4284
-				foreach($datasets as $dataset) {
4284
+				foreach ($datasets as $dataset) {
4285 4285
 					$dataset = explode('=', $dataset);
4286 4286
 					
4287
-					if(count($dataset) > 2) {
4288
-						for($i = 2; $i < count($dataset); $i++) {
4287
+					if (count($dataset) > 2) {
4288
+						for ($i = 2; $i < count($dataset); $i++) {
4289 4289
 							$dataset[1] .= '='.$dataset[$i];
4290 4290
 						}
4291 4291
 						$output[$this->unEscapeText($dataset[0])] = $this->unEscapeText($dataset[1]);
4292
-					}else{
4293
-						if(count($dataset) == 1) {
4292
+					} else {
4293
+						if (count($dataset) == 1) {
4294 4294
 							$output[$this->unEscapeText($dataset[0])] = '';
4295
-						}else{
4295
+						} else {
4296 4296
 							$output[$this->unEscapeText($dataset[0])] = $this->unEscapeText($dataset[1]);
4297 4297
 						}
4298 4298
 						
@@ -4300,28 +4300,28 @@  discard block
 block discarded – undo
4300 4300
 				}
4301 4301
 				return $this->generateOutput(true, array(), $output);
4302 4302
 			}
4303
-			if($mode == 'multi') {
4304
-				if(empty($fetchData['data'])) { return $this->generateOutput(true, array(), array()); }
4303
+			if ($mode == 'multi') {
4304
+				if (empty($fetchData['data'])) { return $this->generateOutput(true, array(), array()); }
4305 4305
 				$datasets = explode('|', $fetchData['data']);
4306 4306
 				
4307 4307
 				$output = array();
4308 4308
 				
4309
-				foreach($datasets as $datablock) {
4309
+				foreach ($datasets as $datablock) {
4310 4310
 					$datablock = explode(' ', $datablock);
4311 4311
 					
4312 4312
 					$tmpArray = array();
4313 4313
 					
4314
-					foreach($datablock as $dataset) {
4314
+					foreach ($datablock as $dataset) {
4315 4315
 						$dataset = explode('=', $dataset);
4316
-						if(count($dataset) > 2) {
4317
-							for($i = 2; $i < count($dataset); $i++) {
4316
+						if (count($dataset) > 2) {
4317
+							for ($i = 2; $i < count($dataset); $i++) {
4318 4318
 								$dataset[1] .= '='.$dataset[$i];
4319 4319
 							}
4320 4320
 							$tmpArray[$this->unEscapeText($dataset[0])] = $this->unEscapeText($dataset[1]);
4321
-						}else{
4322
-							if(count($dataset) == 1) {
4321
+						} else {
4322
+							if (count($dataset) == 1) {
4323 4323
 								$tmpArray[$this->unEscapeText($dataset[0])] = '';
4324
-							}else{
4324
+							} else {
4325 4325
 								$tmpArray[$this->unEscapeText($dataset[0])] = $this->unEscapeText($dataset[1]);
4326 4326
 							}
4327 4327
 						}					
@@ -4330,10 +4330,10 @@  discard block
 block discarded – undo
4330 4330
 				}
4331 4331
 				return $this->generateOutput(true, array(), $output);
4332 4332
 			}
4333
-			if($mode == 'plain') {
4333
+			if ($mode == 'plain') {
4334 4334
 				return $fetchData;
4335 4335
 			}
4336
-		}else{
4336
+		} else {
4337 4337
 			return $this->generateOutput(false, $fetchData['errors'], false);
4338 4338
 		}
4339 4339
 	}
@@ -4363,7 +4363,7 @@  discard block
 block discarded – undo
4363 4363
  */
4364 4364
 	private function ftSendData($data) {
4365 4365
 		$data = str_split($data, 4096);
4366
-		foreach($data as $dat) {
4366
+		foreach ($data as $dat) {
4367 4367
 			fputs($this->runtime['fileSocket'], $dat);
4368 4368
 		}
4369 4369
 	}
@@ -4379,7 +4379,7 @@  discard block
 block discarded – undo
4379 4379
  */
4380 4380
 	private function ftRead($size) {
4381 4381
 		$data = '';
4382
-		while(strlen($data) < $size) {		
4382
+		while (strlen($data) < $size) {		
4383 4383
 			$data .= fgets($this->runtime['fileSocket'], 4096);
4384 4384
 		}
4385 4385
 		return $data;
@@ -4422,7 +4422,7 @@  discard block
 block discarded – undo
4422 4422
   * @return     array debugLog
4423 4423
   */
4424 4424
 	private function addDebugLog($text, $methodName = '', $line = '') {
4425
-		if(empty($methodName) and empty($line)) {
4425
+		if (empty($methodName) and empty($line)) {
4426 4426
 			$backtrace = debug_backtrace();
4427 4427
 			$methodName = $backtrace[1]['function'];
4428 4428
 			$line = $backtrace[0]['line'];
Please login to merge, or discard this patch.
Braces   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 		
171 171
 		if($result['success']) {
172 172
 			return $this->generateOutput(true, $result['errors'], $this->splitBanIds($result['data']));
173
-		}else{
173
+		} else{
174 174
 			return $this->generateOutput(false, $result['errors'], false);
175 175
 		}
176 176
 	}
@@ -308,11 +308,11 @@  discard block
 block discarded – undo
308 308
 			if(count($errors) == 0)
309 309
 			{
310 310
 				return $this->generateOutput(true, array(), true);
311
-			}else{
311
+			} else{
312 312
 				return $this->generateOutput(false, $errors, false);
313 313
 			}
314 314
 			
315
-		}else{
315
+		} else{
316 316
 			// No permissions given
317 317
 			$this->addDebugLog('no permissions given');
318 318
 			return $this->generateOutput(false, array('Error: no permissions given'), false);
@@ -375,11 +375,11 @@  discard block
 block discarded – undo
375 375
 			if(count($errors) == 0)
376 376
 			{
377 377
 				return $this->generateOutput(true, array(), true);
378
-			}else{
378
+			} else{
379 379
 				return $this->generateOutput(false, $errors, false);
380 380
 			}
381 381
 				
382
-		}else{
382
+		} else{
383 383
 			// No permissions given
384 384
 			$this->addDebugLog('no permissions given');
385 385
 			return $this->generateOutput(false, array('Error: no permissions given'), false);
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
 				$permissionArray[] = is_numeric($value) ? 'permid='.$value : 'permsid='.$value;
416 416
 			}
417 417
 			return $this->getData('boolean', 'channelclientdelperm cid='.$cid.' cldbid='.$cldbid.' '.implode('|', $permissionArray));
418
-		}else{
418
+		} else{
419 419
 			$this->addDebugLog('no permissions given');
420 420
 			return $this->generateOutput(false, array('Error: no permissions given'), false);
421 421
 		}
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
 				$permissionArray[] = (is_numeric($value) ? 'permid=' : 'permsid=').$value;
535 535
 			}
536 536
 			return $this->getData('boolean', 'channeldelperm cid='.$cid.' '.implode('|', $permissionArray));
537
-		}else{
537
+		} else{
538 538
 			$this->addDebugLog('no permissions given');
539 539
 			return $this->generateOutput(false, array('Error: no permissions given'), false);
540 540
 		}
@@ -677,11 +677,11 @@  discard block
 block discarded – undo
677 677
 		
678 678
 			if(count($errors) == 0) {
679 679
 				return $this->generateOutput(true, array(), true);
680
-			}else{
680
+			} else{
681 681
 				return $this->generateOutput(false, $errors, false);
682 682
 			}
683 683
 		
684
-		}else{
684
+		} else{
685 685
 			// No permissions given
686 686
 			$this->addDebugLog('no permissions given');
687 687
 			return $this->generateOutput(false, array('Error: no permissions given'), false);
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
 				$permissionArray[] = (is_numeric($value) ? 'permid=' : 'permsid=').$value;
789 789
 			}
790 790
 			return $this->getData('boolean', 'channelgroupdelperm cgid='.$cgid.' '.implode('|', $permissionArray));
791
-		}else{
791
+		} else{
792 792
 			$this->addDebugLog('no permissions given');
793 793
 			return $this->generateOutput(false, array('Error: no permissions given'), false);
794 794
 		}
@@ -1072,10 +1072,10 @@  discard block
 block discarded – undo
1072 1072
 			if(count($errors) == 0)
1073 1073
 			{
1074 1074
 				return $this->generateOutput(true, array(), true);
1075
-			}else{
1075
+			} else{
1076 1076
 				return $this->generateOutput(false, $errors, false);
1077 1077
 			}
1078
-		}else{
1078
+		} else{
1079 1079
 			// No permissions given
1080 1080
 			$this->addDebugLog('no permissions given');
1081 1081
 			return $this->generateOutput(false, array('Error: no permissions given'), false);
@@ -1132,7 +1132,7 @@  discard block
 block discarded – undo
1132 1132
 	  if(is_array($download))
1133 1133
 	  {
1134 1134
 		return $download;
1135
-	  }else{
1135
+	  } else{
1136 1136
 		return $this->generateOutput(true, false, base64_encode($download));
1137 1137
 	  }
1138 1138
 
@@ -1303,7 +1303,7 @@  discard block
 block discarded – undo
1303 1303
 				$permissionArray[] = (is_numeric($value) ? 'permid=' : 'permsid=').$value;
1304 1304
 			}
1305 1305
 			return $this->getData('boolean', 'clientdelperm cldbid='.$cldbid.' '.implode('|', $permissionArray));
1306
-		}else{
1306
+		} else{
1307 1307
 			$this->addDebugLog('no permissions given');
1308 1308
 			return $this->generateOutput(false, array('Error: no permissions given'), false);
1309 1309
 		}
@@ -1558,7 +1558,7 @@  discard block
 block discarded – undo
1558 1558
 			if(!empty($kickmsg)) { $msg = ' reasonmsg='.$this->escapeText($kickmsg); } else{ $msg = ''; }
1559 1559
 			
1560 1560
 			return $this->getData('boolean', 'clientkick clid='.$clid.' reasonid='.$from.$msg);
1561
-		}else{
1561
+		} else{
1562 1562
 			$this->addDebugLog('invalid kickMode');
1563 1563
 			return $this->generateOutput(false, array('Error: invalid kickMode'), false);
1564 1564
 		}
@@ -1948,7 +1948,7 @@  discard block
 block discarded – undo
1948 1948
 				$fileArray[] = 'name='.$this->escapeText($file);
1949 1949
 			}
1950 1950
 			return $this->getData('boolean', 'ftdeletefile cid='.$cid.' cpw='.$this->escapeText($cpw).' '.implode('|', $fileArray));
1951
-		}else{
1951
+		} else{
1952 1952
 			$this->addDebugLog('no files given');
1953 1953
 			return $this->generateOutput(false, array('Error: no files given'), false);
1954 1954
 		}
@@ -1973,7 +1973,7 @@  discard block
 block discarded – undo
1973 1973
   			@fclose($this->runtime['fileSocket']);
1974 1974
   			$this->runtime['fileSocket'] = '';
1975 1975
   			return $content;
1976
-  		}else{
1976
+  		} else{
1977 1977
   			$this->addDebugLog('fileSocket returns '.$errnum. ' | '.$errstr);
1978 1978
   			return $this->generateOutput(false, array('Error in fileSocket: '.$errnum. ' | '.$errstr), false);
1979 1979
   		}
@@ -2084,8 +2084,8 @@  discard block
 block discarded – undo
2084 2084
 	function ftInitUpload($filename, $cid, $size, $cpw = '', $overwrite = false, $resume = false) {
2085 2085
 		if(!$this->runtime['selected']) { return $this->checkSelected(); }
2086 2086
 		
2087
-		if($overwrite) { $overwrite = ' overwrite=1'; }else{ $overwrite = ' overwrite=0'; }
2088
-		if($resume) { $resume = ' resume=1'; }else{ $resume = ' resume=0'; }
2087
+		if($overwrite) { $overwrite = ' overwrite=1'; } else{ $overwrite = ' overwrite=0'; }
2088
+		if($resume) { $resume = ' resume=1'; } else{ $resume = ' resume=0'; }
2089 2089
 		
2090 2090
 		return $this->getData('array', 'ftinitupload clientftfid='.rand(1,99).' name='.$this->escapeText($filename).' cid='.$cid.' cpw='.$this->escapeText($cpw).' size='.($size + 1).$overwrite.$resume);
2091 2091
 	}
@@ -2177,7 +2177,7 @@  discard block
 block discarded – undo
2177 2177
   			@fclose($this->runtime['fileSocket']);
2178 2178
   			$this->runtime['fileSocket'] = '';
2179 2179
   			return $this->generateOutput(true, array(), true);
2180
-  		}else{
2180
+  		} else{
2181 2181
   			$this->addDebugLog('fileSocket returns '.$errnum. ' | '.$errstr);
2182 2182
   			return $this->generateOutput(false, array('Error in fileSocket: '.$errnum. ' | '.$errstr), false);
2183 2183
   		}
@@ -2262,7 +2262,7 @@  discard block
 block discarded – undo
2262 2262
 				$settingsString .= ' '.$key.'='.$this->escapeText($val);
2263 2263
 			}
2264 2264
 			return $this->getData('boolean', 'instanceedit '.$settingsString);
2265
-		}else{
2265
+		} else{
2266 2266
 			$this->addDebugLog('empty array entered');
2267 2267
 			return $this->generateOutput(false, array('Error: You can \'t give an empty array'), false);
2268 2268
 		}
@@ -2314,11 +2314,11 @@  discard block
 block discarded – undo
2314 2314
 		if($logLevel >=1 and $logLevel <= 4) { 
2315 2315
 			if(!empty($logMsg)) {
2316 2316
 				return $this->getData('boolean', 'logadd loglevel='.$logLevel.' logmsg='.$this->escapeText($logMsg));
2317
-			}else{
2317
+			} else{
2318 2318
 				$this->addDebugLog('logMessage empty!');
2319 2319
 				return $this->generateOutput(false, array('Error: logMessage empty!'), false);
2320 2320
 			}
2321
-		}else{
2321
+		} else{
2322 2322
 			$this->addDebugLog('invalid logLevel!');
2323 2323
 			return $this->generateOutput(false, array('Error: invalid logLevel!'), false);
2324 2324
 		}
@@ -2382,7 +2382,7 @@  discard block
 block discarded – undo
2382 2382
 	function logView($lines, $reverse = 0, $instance = 0, $begin_pos = 0) {		
2383 2383
 		if($lines >=1 and $lines <=100) {
2384 2384
 			return $this->getData('multi', 'logview lines='.$lines.' reverse='.($reverse == 0 ? '0' : '1').' instance='.($instance == 0 ? '0' : '1').' begin_pos='.($begin_pos == 0 ? '0' : $begin_pos));
2385
-		}else{
2385
+		} else{
2386 2386
 			$this->addDebugLog('please choose a limit between 1 and 100');
2387 2387
 			$this->generateOutput(false, array('Error: please choose a limit between 1 and 100'), false);
2388 2388
 		}
@@ -2540,7 +2540,7 @@  discard block
 block discarded – undo
2540 2540
 				$permissionArray[] = 'permsid='.$value;
2541 2541
 			}
2542 2542
 			return $this->getData('multi', 'permidgetbyname '.$this->escapeText(implode('|', $permissionArray)));
2543
-		}else{
2543
+		} else{
2544 2544
 			$this->addDebugLog('no permissions given');
2545 2545
 			return $this->generateOutput(false, array('Error: no permissions given'), false);
2546 2546
 		}
@@ -2648,7 +2648,7 @@  discard block
 block discarded – undo
2648 2648
 				if(isset($field['group_id_end'])) {
2649 2649
 					$groups[] = array('num' => $gc, 'group_id_end' => $field['group_id_end']);
2650 2650
 					$gc++;
2651
-				}else{
2651
+				} else{
2652 2652
 					$permissions[] = $field;
2653 2653
 				}
2654 2654
 			}
@@ -2666,7 +2666,7 @@  discard block
 block discarded – undo
2666 2666
 			
2667 2667
 			return $groups;
2668 2668
 			
2669
-		}else{
2669
+		} else{
2670 2670
 			return $this->getData('multi', 'permissionlist');
2671 2671
 		}
2672 2672
 	}
@@ -2701,7 +2701,7 @@  discard block
 block discarded – undo
2701 2701
   */
2702 2702
 	function permOverview($cid, $cldbid, $permid='0', $permsid=false ) { 
2703 2703
         if(!$this->runtime['selected']) { return $this->checkSelected(); } 
2704
-        if($permsid) { $additional = ' permsid='.$permsid; }else{ $additional = ''; } 
2704
+        if($permsid) { $additional = ' permsid='.$permsid; } else{ $additional = ''; } 
2705 2705
          
2706 2706
         return $this->getData('multi', 'permoverview cid='.$cid.' cldbid='.$cldbid.($permsid == false ? ' permid='.$permid : '').$additional); 
2707 2707
     }
@@ -2830,21 +2830,21 @@  discard block
 block discarded – undo
2830 2830
 	function selectServer($value, $type = 'port', $virtual = false) { 
2831 2831
         if(in_array($type, array('port', 'serverId'))) { 
2832 2832
             if($type == 'port') { 
2833
-                if($virtual) { $virtual = ' -virtual'; }else{ $virtual = ''; } 
2833
+                if($virtual) { $virtual = ' -virtual'; } else{ $virtual = ''; } 
2834 2834
                 $res = $this->getData('boolean', 'use port='.$value.$virtual); 
2835 2835
                 if($res['success']) { 
2836 2836
                     $this->runtime['selected'] = true; 
2837 2837
                 } 
2838 2838
                 return $res; 
2839
-            }else{ 
2840
-                if($virtual) { $virtual = ' -virtual'; }else{ $virtual = ''; } 
2839
+            } else{ 
2840
+                if($virtual) { $virtual = ' -virtual'; } else{ $virtual = ''; } 
2841 2841
                 $res = $this->getData('boolean', 'use sid='.$value.$virtual); 
2842 2842
                 if($res['success']) { 
2843 2843
                     $this->runtime['selected'] = true; 
2844 2844
                 } 
2845 2845
                 return $res; 
2846 2846
             } 
2847
-        }else{ 
2847
+        } else{ 
2848 2848
             $this->addDebugLog('wrong value type'); 
2849 2849
             return $this->generateOutput(false, array('Error: wrong value type'), false); 
2850 2850
         } 
@@ -3057,11 +3057,11 @@  discard block
 block discarded – undo
3057 3057
 			if(count($errors) == 0)
3058 3058
 			{
3059 3059
 				return $this->generateOutput(true, array(), true);
3060
-			}else{
3060
+			} else{
3061 3061
 				return $this->generateOutput(false, $errors, false);
3062 3062
 			}
3063 3063
 				
3064
-		}else{
3064
+		} else{
3065 3065
 			// No permissions given
3066 3066
 			$this->addDebugLog('no permissions given');
3067 3067
 			return $this->generateOutput(false, array('Error: no permissions given'), false);
@@ -3123,11 +3123,11 @@  discard block
 block discarded – undo
3123 3123
 			if(count($errors) == 0)
3124 3124
 			{
3125 3125
 				return $this->generateOutput(true, array(), true);
3126
-			}else{
3126
+			} else{
3127 3127
 				return $this->generateOutput(false, $errors, false);
3128 3128
 			}
3129 3129
 				
3130
-		}else{
3130
+		} else{
3131 3131
 			// No permissions given
3132 3132
 			$this->addDebugLog('no permissions given');
3133 3133
 			return $this->generateOutput(false, array('Error: no permissions given'), false);
@@ -3161,7 +3161,7 @@  discard block
 block discarded – undo
3161 3161
 				$permissionArray[] = is_numeric($value) ? 'permid='.$value : 'permsid='.$this->escapeText($value);
3162 3162
 			}
3163 3163
 			return $this->getData('boolean', 'servergroupautodelperm sgtype='.$sgtype.' '.implode('|', $permissionArray));
3164
-		}else{
3164
+		} else{
3165 3165
 			$this->addDebugLog('no permissions given');
3166 3166
 			return $this->generateOutput(false, array('Error: no permissions given'), false);
3167 3167
 		}
@@ -3191,7 +3191,7 @@  discard block
 block discarded – undo
3191 3191
   */
3192 3192
 	function serverGroupClientList($sgid, $names = false) {
3193 3193
 		if(!$this->runtime['selected']) { return $this->checkSelected(); }
3194
-		if($names) { $names = ' -names'; }else{ $names = ''; }
3194
+		if($names) { $names = ' -names'; } else{ $names = ''; }
3195 3195
 		return $this->getData('multi', 'servergroupclientlist sgid='.$sgid.$names);
3196 3196
 	}
3197 3197
 
@@ -3277,7 +3277,7 @@  discard block
 block discarded – undo
3277 3277
 				$permissionArray[] = is_numeric($value) ? 'permid='.$value : 'permsid='.$this->escapeText($value);
3278 3278
 			}
3279 3279
 			return $this->getData('boolean', 'servergroupdelperm sgid='.$sgid.' '.implode('|', $permissionArray));
3280
-		}else{
3280
+		} else{
3281 3281
 			$this->addDebugLog('no permissions given');
3282 3282
 			return $this->generateOutput(false, array('Error: no permissions given'), false);
3283 3283
 		}
@@ -3332,7 +3332,7 @@  discard block
 block discarded – undo
3332 3332
   */
3333 3333
 	function serverGroupPermList($sgid, $permsid = false) {
3334 3334
 		if(!$this->runtime['selected']) { return $this->checkSelected(); }
3335
-		if($permsid) { $additional = ' -permsid'; }else{ $additional = ''; }
3335
+		if($permsid) { $additional = ' -permsid'; } else{ $additional = ''; }
3336 3336
 		return $this->getData('multi', 'servergrouppermlist sgid='.$sgid.$additional);
3337 3337
 	}
3338 3338
 
@@ -3774,7 +3774,7 @@  discard block
 block discarded – undo
3774 3774
 			}
3775 3775
 			
3776 3776
 			$customFieldSet = ' tokencustomset='.implode('\p', $settingsString);
3777
-		}else{
3777
+		} else{
3778 3778
 			$customFieldSet = '';
3779 3779
 		}
3780 3780
 		
@@ -4009,7 +4009,7 @@  discard block
 block discarded – undo
4009 4009
 	public function succeeded($array) {
4010 4010
 		if(isset($array['success'])) {
4011 4011
 			return $array['success'];
4012
-		}else{
4012
+		} else{
4013 4013
 			return false;
4014 4014
 		}
4015 4015
 	}
@@ -4035,10 +4035,10 @@  discard block
 block discarded – undo
4035 4035
 				$this->runtime['host'] = $host;
4036 4036
 				$this->runtime['queryport'] = $queryport;
4037 4037
 				$this->runtime['timeout'] = $timeout;
4038
-			}else{
4038
+			} else{
4039 4039
 				$this->addDebugLog('invalid timeout value');
4040 4040
 			}
4041
-		}else{
4041
+		} else{
4042 4042
 			$this->addDebugLog('invalid queryport');
4043 4043
 		}
4044 4044
 	}
@@ -4079,7 +4079,7 @@  discard block
 block discarded – undo
4079 4079
 	private function isConnected() {
4080 4080
 		if(empty($this->runtime['socket'])) {
4081 4081
 			return false;
4082
-		}else{
4082
+		} else{
4083 4083
 			return true;
4084 4084
 		}
4085 4085
 	}
@@ -4175,12 +4175,12 @@  discard block
 block discarded – undo
4175 4175
 		if(!$socket) {
4176 4176
 			$this->addDebugLog('Error: connection failed!');
4177 4177
 			return $this->generateOutput(false, array('Error: connection failed!', 'Server returns: '.$errstr), false);
4178
-		}else{
4178
+		} else{
4179 4179
 			if(strpos(fgets($socket), 'TS3') !== false) {
4180 4180
 				$tmpVar = fgets($socket);
4181 4181
 				$this->runtime['socket'] = $socket;
4182 4182
 				return $this->generateOutput(true, array(), true);
4183
-			}else{
4183
+			} else{
4184 4184
 				$this->addDebugLog('host isn\'t a ts3 instance!');
4185 4185
 				return $this->generateOutput(false, array('Error: host isn\'t a ts3 instance!'), false);
4186 4186
 			}
@@ -4234,7 +4234,7 @@  discard block
 block discarded – undo
4234 4234
 			$this->addDebugLog('ErrorID: '.$cutIdAndMsg[0].' | Message: '.$this->unEscapeText($cutIdAndMsg[1]), $tracert[1]['function'], $tracert[0]['line']);
4235 4235
 			
4236 4236
 			return $this->generateOutput(false, array('ErrorID: '.$cutIdAndMsg[0].' | Message: '.$this->unEscapeText($cutIdAndMsg[1])), false);
4237
-		}else{
4237
+		} else{
4238 4238
 			return $this->generateOutput(true, array(), $data);
4239 4239
 		}
4240 4240
 	}
@@ -4289,10 +4289,10 @@  discard block
 block discarded – undo
4289 4289
 							$dataset[1] .= '='.$dataset[$i];
4290 4290
 						}
4291 4291
 						$output[$this->unEscapeText($dataset[0])] = $this->unEscapeText($dataset[1]);
4292
-					}else{
4292
+					} else{
4293 4293
 						if(count($dataset) == 1) {
4294 4294
 							$output[$this->unEscapeText($dataset[0])] = '';
4295
-						}else{
4295
+						} else{
4296 4296
 							$output[$this->unEscapeText($dataset[0])] = $this->unEscapeText($dataset[1]);
4297 4297
 						}
4298 4298
 						
@@ -4318,10 +4318,10 @@  discard block
 block discarded – undo
4318 4318
 								$dataset[1] .= '='.$dataset[$i];
4319 4319
 							}
4320 4320
 							$tmpArray[$this->unEscapeText($dataset[0])] = $this->unEscapeText($dataset[1]);
4321
-						}else{
4321
+						} else{
4322 4322
 							if(count($dataset) == 1) {
4323 4323
 								$tmpArray[$this->unEscapeText($dataset[0])] = '';
4324
-							}else{
4324
+							} else{
4325 4325
 								$tmpArray[$this->unEscapeText($dataset[0])] = $this->unEscapeText($dataset[1]);
4326 4326
 							}
4327 4327
 						}					
@@ -4333,7 +4333,7 @@  discard block
 block discarded – undo
4333 4333
 			if($mode == 'plain') {
4334 4334
 				return $fetchData;
4335 4335
 			}
4336
-		}else{
4336
+		} else{
4337 4337
 			return $this->generateOutput(false, $fetchData['errors'], false);
4338 4338
 		}
4339 4339
 	}
Please login to merge, or discard this patch.