本文整理汇总了PHP中Backend::normalizeAddress方法的典型用法代码示例。如果您正苦于以下问题:PHP Backend::normalizeAddress方法的具体用法?PHP Backend::normalizeAddress怎么用?PHP Backend::normalizeAddress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Backend
的用法示例。
在下文中一共展示了Backend::normalizeAddress方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getNonProxiedUrl
/**
* Returns the absolute URL to the specified path
* @param string $path a path returned from an API call
* @param boolean $omitCredentials whether to omit credentials from the URL
* @return string the URL
*/
private function getNonProxiedUrl($path, $omitCredentials)
{
$hostname = Backend::normalizeAddress($this->_backend->hostname);
$port = $this->_backend->port;
$url = 'http://{credentials}' . $hostname . ':' . $port . '/' . $path;
if ($omitCredentials) {
$url = str_replace('{credentials}', '', $url);
} else {
$url = str_replace('{credentials}', $this->_backend->username . ':' . $this->_backend->password . '@', $url);
}
return $url;
}
示例2: init
/**
* Initializes the component
*/
public function init()
{
// Connect to the current backend
$this->_backend = Yii::app()->backendManager->getCurrent();
$hostname = Backend::normalizeAddress($this->_backend->hostname);
$endpoint = 'http://' . $hostname . ':' . $this->_backend->port . '/jsonrpc';
$clientFlags = JsonRPCClient::FLAG_ATTEMPT_UTF8_RECOVERY;
$clientOptions = array('timeout' => Setting::getInteger('requestTimeout'));
$this->_client = new JsonRPCClient($endpoint, $this->_backend->username, $this->_backend->password, $clientFlags, $clientOptions);
// Initialize the VFS helper
$this->_vfsHelper = new VFSHelper();
parent::init();
}
示例3: isConnectable
/**
* @return boolean whether this backend is connectable
* @param int $port the port to try to connect to. Defaults to null, meaning
* the HTTP port configured for this backend
* @param boolean $logFailure whether unsuccessful attempts should be logged. Defaults
* to true.
*/
public function isConnectable($port = null, $logFailure = true)
{
$errno = 0;
$errStr = '';
if ($port === null) {
$port = $this->port;
}
if (@fsockopen(Backend::normalizeAddress($this->hostname), $port, $errno, $errStr, self::SOCKET_TIMEOUT) === false || $errno !== 0) {
if ($logFailure) {
Yii::log('Failed to connect to ' . $this->hostname . ':' . $this->port . '. The exact error was: ' . $errStr . ' (' . $errno . ')', CLogger::LEVEL_ERROR, 'Backend');
}
return false;
}
return true;
}
示例4: getHostInfo
/**
* @return string the hostname:port combination
*/
public function getHostInfo()
{
return Backend::normalizeAddress($this->_hostname) . ':' . $this->_port;
}
示例5: getAbsoluteVfsUrl
/**
* Returns the absolute URL to the specified API path
* @param string $path a path returned from an API call
* @param boolean $omitCredentials whether to omit the XBMC credentials in
* the generated URLs
* @return string
*/
public function getAbsoluteVfsUrl($path, $omitCredentials = false)
{
$backend = Yii::app()->backendManager->getCurrent();
// Use reverse proxy for vfs:// paths (if specified)
$proxyLocation = $backend->proxyLocation;
if (!empty($proxyLocation) && substr($path, 0, 3) === 'vfs') {
// Only use HTTPS if user has explicitly enabled it
$scheme = 'http://';
if (Setting::getBoolean('useHttpsForVfsUrls') && Yii::app()->request->isSecureConnection) {
$scheme = 'https://';
}
// Remove the beginning "vfs/" from the path
$path = substr($path, 4);
return $scheme . $_SERVER['HTTP_HOST'] . $proxyLocation . '/' . $path;
} else {
$url = 'http://{credentials}' . Backend::normalizeAddress($backend->hostname) . ':' . $backend->port . '/' . $path;
if ($omitCredentials) {
$url = str_replace('{credentials}', '', $url);
} else {
$url = str_replace('{credentials}', $backend->username . ':' . $backend->password . '@', $url);
}
return $url;
}
}