260 protected static $escape_patterns = array(
315 $adapter = self::getAdapterName($uri->getScheme());
316 $options = array(
"host" => $uri->getHost(),
"port" => $uri->getPort(),
"timeout" => intval($uri->getQueryVar(
"timeout", 10)),
"blocking" => intval($uri->getQueryVar(
"blocking", 1)));
318 self::loadClass($adapter);
320 $object =
new $adapter($options);
324 $node = $object->getHost();
326 if($uri->hasUser() && $uri->hasPass())
328 $node->login($uri->getUser(), $uri->getPass());
332 if($uri->hasQueryVar(
"nickname"))
334 $node->setPredefinedQueryName($uri->getQueryVar(
"nickname"));
338 if($uri->getFragment() ==
"use_offline_as_virtual")
340 $node->setUseOfflineAsVirtual(TRUE);
342 elseif($uri->hasQueryVar(
"use_offline_as_virtual"))
344 $node->setUseOfflineAsVirtual($uri->getQueryVar(
"use_offline_as_virtual") ? TRUE : FALSE);
348 if($uri->getFragment() ==
"clients_before_channels")
350 $node->setLoadClientlistFirst(TRUE);
352 elseif($uri->hasQueryVar(
"clients_before_channels"))
354 $node->setLoadClientlistFirst($uri->getQueryVar(
"clients_before_channels") ? TRUE : FALSE);
358 if($uri->getFragment() ==
"no_query_clients")
360 $node->setExcludeQueryClients(TRUE);
362 elseif($uri->hasQueryVar(
"no_query_clients"))
364 $node->setExcludeQueryClients($uri->getQueryVar(
"no_query_clients") ? TRUE : FALSE);
368 if($uri->hasQueryVar(
"server_id"))
370 $node = $node->serverGetById($uri->getQueryVar(
"server_id"));
372 elseif($uri->hasQueryVar(
"server_uid"))
374 $node = $node->serverGetByUid($uri->getQueryVar(
"server_uid"));
376 elseif($uri->hasQueryVar(
"server_port"))
378 $node = $node->serverGetByPort($uri->getQueryVar(
"server_port"));
380 elseif($uri->hasQueryVar(
"server_name"))
382 $node = $node->serverGetByName($uri->getQueryVar(
"server_name"));
384 elseif($uri->hasQueryVar(
"server_tsdns"))
386 $node = $node->serverGetByTSDNS($uri->getQueryVar(
"server_tsdns"));
393 if($uri->hasQueryVar(
"channel_id"))
395 $node = $node->channelGetById($uri->getQueryVar(
"channel_id"));
397 elseif($uri->hasQueryVar(
"channel_name"))
399 $node = $node->channelGetByName($uri->getQueryVar(
"channel_name"));
403 if($uri->hasQueryVar(
"client_id"))
405 $node = $node->clientGetById($uri->getQueryVar(
"client_id"));
407 if($uri->hasQueryVar(
"client_uid"))
409 $node = $node->clientGetByUid($uri->getQueryVar(
"client_uid"));
411 elseif($uri->hasQueryVar(
"client_name"))
413 $node = $node->clientGetByName($uri->getQueryVar(
"client_name"));
435 if(class_exists($class, FALSE) || interface_exists($class, FALSE))
440 if(preg_match(
"/[^a-z0-9\\/\\\\_.-]/i", $class))
442 throw new LogicException(
"illegal characters in classname '" . $class .
"'");
445 $file = self::getFilePath($class) .
".php";
447 if(!file_exists($file) || !is_readable($file))
449 throw new LogicException(
"file '" . $file .
"' does not exist or is not readable");
452 if(class_exists($class, FALSE) || interface_exists($class, FALSE))
454 throw new LogicException(
"class '" . $class .
"' does not exist");
457 return include_once($file);
468 $path = str_replace(
"_", DIRECTORY_SEPARATOR, $name);
469 $path = str_replace(__CLASS__, dirname(__FILE__), $path);
482 protected static function getAdapterName($name, $namespace =
"TeamSpeak3_Adapter_")
484 $path = self::getFilePath($namespace);
485 $scan = scandir($path);
487 foreach($scan as $node)
491 if($file->startsWith($name) && $file->endsWith(
".php"))
493 return $namespace . str_replace(
".php",
"", $node);
508 if(substr($class, 0, strlen(__CLASS__)) != __CLASS__)
return;
512 self::loadClass($class);
530 if(version_compare(phpversion(),
"5.2.1") == -1)
532 throw new LogicException(
"this particular software cannot be used with the installed version of PHP");
535 if(!function_exists(
"stream_socket_client"))
537 throw new LogicException(
"network functions are not available in this PHP installation");
540 if(!function_exists(
"spl_autoload_register"))
542 throw new LogicException(
"autoload functions are not available in this PHP installation");
545 if(!class_exists(
"TeamSpeak3_Helper_Profiler"))
547 spl_autoload_register(array(__CLASS__,
"autoload"));
561 return self::$escape_patterns;
572 public static function dump($var, $echo = TRUE)
577 $output = ob_get_clean();
578 $output = preg_replace(
"/\]\=>\n(\s+)/m",
"] => ", $output);
580 if(PHP_SAPI ==
"cli")
582 $output = PHP_EOL . PHP_EOL . $output . PHP_EOL;
586 $output =
"<pre>" . htmlspecialchars($output, ENT_QUOTES) .
"</pre>";
589 if($echo) echo($output);