250 protected static $escape_patterns = array(
305 $adapter = self::getAdapterName($uri->getScheme());
306 $options = array(
"host" => $uri->getHost(),
"port" => $uri->getPort(),
"timeout" => intval($uri->getQueryVar(
"timeout", 10)),
"blocking" => intval($uri->getQueryVar(
"blocking", 1)));
308 self::loadClass($adapter);
310 $object =
new $adapter($options);
314 $node = $object->getHost();
316 if($uri->hasUser() && $uri->hasPass())
318 $node->login($uri->getUser(), $uri->getPass());
322 if($uri->hasQueryVar(
"nickname"))
324 $node->setPredefinedQueryName($uri->getQueryVar(
"nickname"));
328 if($uri->getFragment() ==
"use_offline_as_virtual")
330 $node->setUseOfflineAsVirtual(TRUE);
332 elseif($uri->hasQueryVar(
"use_offline_as_virtual"))
334 $node->setUseOfflineAsVirtual($uri->getQueryVar(
"use_offline_as_virtual") ? TRUE : FALSE);
338 if($uri->getFragment() ==
"clients_before_channels")
340 $node->setLoadClientlistFirst(TRUE);
342 elseif($uri->hasQueryVar(
"clients_before_channels"))
344 $node->setLoadClientlistFirst($uri->getQueryVar(
"clients_before_channels") ? TRUE : FALSE);
348 if($uri->getFragment() ==
"no_query_clients")
350 $node->setExcludeQueryClients(TRUE);
352 elseif($uri->hasQueryVar(
"no_query_clients"))
354 $node->setExcludeQueryClients($uri->getQueryVar(
"no_query_clients") ? TRUE : FALSE);
358 if($uri->hasQueryVar(
"server_id"))
360 $node = $node->serverGetById($uri->getQueryVar(
"server_id"));
362 elseif($uri->hasQueryVar(
"server_uid"))
364 $node = $node->serverGetByUid($uri->getQueryVar(
"server_uid"));
366 elseif($uri->hasQueryVar(
"server_port"))
368 $node = $node->serverGetByPort($uri->getQueryVar(
"server_port"));
370 elseif($uri->hasQueryVar(
"server_name"))
372 $node = $node->serverGetByName($uri->getQueryVar(
"server_name"));
374 elseif($uri->hasQueryVar(
"server_tsdns"))
376 $node = $node->serverGetByTSDNS($uri->getQueryVar(
"server_tsdns"));
383 if($uri->hasQueryVar(
"channel_id"))
385 $node = $node->channelGetById($uri->getQueryVar(
"channel_id"));
387 elseif($uri->hasQueryVar(
"channel_name"))
389 $node = $node->channelGetByName($uri->getQueryVar(
"channel_name"));
393 if($uri->hasQueryVar(
"client_id"))
395 $node = $node->clientGetById($uri->getQueryVar(
"client_id"));
397 if($uri->hasQueryVar(
"client_uid"))
399 $node = $node->clientGetByUid($uri->getQueryVar(
"client_uid"));
401 elseif($uri->hasQueryVar(
"client_name"))
403 $node = $node->clientGetByName($uri->getQueryVar(
"client_name"));
425 if(class_exists($class, FALSE) || interface_exists($class, FALSE))
430 if(preg_match(
"/[^a-z0-9\\/\\\\_.-]/i", $class))
432 throw new LogicException(
"illegal characters in classname '" . $class .
"'");
435 $file = self::getFilePath($class) .
".php";
437 if(!file_exists($file) || !is_readable($file))
439 throw new LogicException(
"file '" . $file .
"' does not exist or is not readable");
442 if(class_exists($class, FALSE) || interface_exists($class, FALSE))
444 throw new LogicException(
"class '" . $class .
"' does not exist");
447 return include_once($file);
458 $path = str_replace(
"_", DIRECTORY_SEPARATOR, $name);
459 $path = str_replace(__CLASS__, dirname(__FILE__), $path);
472 protected static function getAdapterName($name, $namespace =
"TeamSpeak3_Adapter_")
474 $path = self::getFilePath($namespace);
475 $scan = scandir($path);
477 foreach($scan as $node)
481 if($file->startsWith($name) && $file->endsWith(
".php"))
483 return $namespace . str_replace(
".php",
"", $node);
498 if(substr($class, 0, strlen(__CLASS__)) != __CLASS__)
return;
502 self::loadClass($class);
520 if(version_compare(phpversion(),
"5.2.1") == -1)
522 throw new LogicException(
"this particular software cannot be used with the installed version of PHP");
525 if(!function_exists(
"stream_socket_client"))
527 throw new LogicException(
"network functions are not available in this PHP installation");
530 if(!function_exists(
"spl_autoload_register"))
532 throw new LogicException(
"autoload functions are not available in this PHP installation");
535 if(!class_exists(
"TeamSpeak3_Helper_Profiler"))
537 spl_autoload_register(array(__CLASS__,
"autoload"));
551 return self::$escape_patterns;
562 public static function dump($var, $echo = TRUE)
567 $output = ob_get_clean();
568 $output = preg_replace(
"/\]\=>\n(\s+)/m",
"] => ", $output);
570 if(PHP_SAPI ==
"cli")
572 $output = PHP_EOL . PHP_EOL . $output . PHP_EOL;
576 $output =
"<pre>" . htmlspecialchars($output, ENT_QUOTES) .
"</pre>";
579 if($echo) echo($output);