本文整理匯總了PHP中MailSo\Base\Utils::ConvertSystemString方法的典型用法代碼示例。如果您正苦於以下問題:PHP Utils::ConvertSystemString方法的具體用法?PHP Utils::ConvertSystemString怎麽用?PHP Utils::ConvertSystemString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MailSo\Base\Utils
的用法示例。
在下文中一共展示了Utils::ConvertSystemString方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: Connect
/**
* @param string $sServerName
* @param int $iPort
* @param int $iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT
* @param bool $bVerifySsl = false
*
* @return void
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\SocketAlreadyConnectedException
* @throws \MailSo\Net\Exceptions\SocketCanNotConnectToHostException
*/
public function Connect($sServerName, $iPort, $iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT, $bVerifySsl = false)
{
if (!\MailSo\Base\Validator::NotEmptyString($sServerName, true) || !\MailSo\Base\Validator::PortInt($iPort)) {
$this->writeLogException(new \MailSo\Base\Exceptions\InvalidArgumentException(), \MailSo\Log\Enumerations\Type::ERROR, true);
}
if ($this->IsConnected()) {
$this->writeLogException(new Exceptions\SocketAlreadyConnectedException(), \MailSo\Log\Enumerations\Type::ERROR, true);
}
$sServerName = \trim($sServerName);
$sErrorStr = '';
$iErrorNo = 0;
$this->sConnectedHost = $sServerName;
$this->iConnectedPort = $iPort;
$this->iSecurityType = $iSecurityType;
$this->bSecure = \MailSo\Net\Enumerations\ConnectionSecurityType::UseSSL($this->iConnectedPort, $this->iSecurityType);
$this->sConnectedHost = \in_array(\strtolower(\substr($this->sConnectedHost, 0, 6)), array('ssl://', 'tcp://')) ? \substr($this->sConnectedHost, 6) : $this->sConnectedHost;
$this->sConnectedHost = ($this->bSecure ? 'ssl://' : 'tcp://') . $this->sConnectedHost;
// $this->sConnectedHost = ($this->bSecure ? 'ssl://' : '').$this->sConnectedHost;
if (!$this->bSecure && \MailSo\Net\Enumerations\ConnectionSecurityType::SSL === $this->iSecurityType) {
$this->writeLogException(new \MailSo\Net\Exceptions\SocketUnsuppoterdSecureConnectionException('SSL isn\'t supported: (' . \implode(', ', \stream_get_transports()) . ')'), \MailSo\Log\Enumerations\Type::ERROR, true);
}
$this->iStartConnectTime = \microtime(true);
$this->writeLog('Start connection to "' . $this->sConnectedHost . ':' . $this->iConnectedPort . '"', \MailSo\Log\Enumerations\Type::NOTE);
// $this->rConnect = @\fsockopen($this->sConnectedHost, $this->iConnectedPort,
// $iErrorNo, $sErrorStr, $this->iConnectTimeOut);
$bVerifySsl = !!$bVerifySsl;
$aStreamContextSettings = array('ssl' => array('verify_host' => $bVerifySsl, 'verify_peer' => $bVerifySsl, 'verify_peer_name' => $bVerifySsl, 'allow_self_signed' => !$bVerifySsl));
\MailSo\Hooks::Run('Net.NetClient.StreamContextSettings/Filter', array(&$aStreamContextSettings));
$rStreamContext = \stream_context_create($aStreamContextSettings);
\set_error_handler(array(&$this, 'capturePhpErrorWithException'));
try {
$this->rConnect = \stream_socket_client($this->sConnectedHost . ':' . $this->iConnectedPort, $iErrorNo, $sErrorStr, $this->iConnectTimeOut, STREAM_CLIENT_CONNECT, $rStreamContext);
} catch (\Exception $oExc) {
$sErrorStr = $oExc->getMessage();
$iErrorNo = $oExc->getCode();
}
\restore_error_handler();
if (!\is_resource($this->rConnect)) {
$this->writeLogException(new Exceptions\SocketCanNotConnectToHostException(\MailSo\Base\Utils::ConvertSystemString($sErrorStr), (int) $iErrorNo, 'Can\'t connect to host "' . $this->sConnectedHost . ':' . $this->iConnectedPort . '"'), \MailSo\Log\Enumerations\Type::NOTICE, true);
}
$this->writeLog(\microtime(true) - $this->iStartConnectTime . ' (raw connection)', \MailSo\Log\Enumerations\Type::TIME);
if ($this->rConnect) {
if (\MailSo\Base\Utils::FunctionExistsAndEnabled('stream_set_timeout')) {
@\stream_set_timeout($this->rConnect, $this->iSocketTimeOut);
}
}
}
示例2: Connect
/**
* @param string $sServerName
* @param int $iPort
* @param int $iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT
*
* @return void
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\SocketAlreadyConnectedException
* @throws \MailSo\Net\Exceptions\SocketCanNotConnectToHostException
*/
public function Connect($sServerName, $iPort, $iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT)
{
if (!\MailSo\Base\Validator::NotEmptyString($sServerName, true) || !\MailSo\Base\Validator::PortInt($iPort)) {
$this->writeLogException(new \MailSo\Base\Exceptions\InvalidArgumentException(), \MailSo\Log\Enumerations\Type::ERROR, true);
}
if ($this->IsConnected()) {
$this->writeLogException(new Exceptions\SocketAlreadyConnectedException(), \MailSo\Log\Enumerations\Type::ERROR, true);
}
$sServerName = \trim($sServerName);
$sErrorStr = '';
$iErrorNo = 0;
$this->iSecurityType = $iSecurityType;
$this->iConnectedPort = $iPort;
$this->bSecure = \MailSo\Net\Enumerations\ConnectionSecurityType::UseSSL($iPort, $iSecurityType);
$this->sConnectedHost = $this->bSecure ? 'ssl://' . $sServerName : $sServerName;
if (!$this->bSecure && \MailSo\Net\Enumerations\ConnectionSecurityType::SSL === $this->iSecurityType) {
$this->writeLogException(new \MailSo\Net\Exceptions\SocketUnsuppoterdSecureConnectionException('SSL isn\'t supported'), \MailSo\Log\Enumerations\Type::ERROR, true);
}
$this->iStartConnectTime = \microtime(true);
$this->writeLog('Start connection to "' . $this->sConnectedHost . ':' . $this->iConnectedPort . '"', \MailSo\Log\Enumerations\Type::NOTE);
$this->rConnect = @\fsockopen($this->sConnectedHost, $this->iConnectedPort, $iErrorNo, $sErrorStr, $this->iConnectTimeOut);
if (!\is_resource($this->rConnect)) {
$this->writeLogException(new Exceptions\SocketCanNotConnectToHostException(\MailSo\Base\Utils::ConvertSystemString($sErrorStr), (int) $iErrorNo, 'Can\'t connect to host "' . $this->sConnectedHost . ':' . $this->iConnectedPort . '"'), \MailSo\Log\Enumerations\Type::NOTICE, true);
}
$this->writeLog(\microtime(true) - $this->iStartConnectTime . ' (raw connection)', \MailSo\Log\Enumerations\Type::TIME);
if ($this->rConnect) {
if (\MailSo\Base\Utils::FunctionExistsAndEnabled('stream_set_timeout')) {
@\stream_set_timeout($this->rConnect, $this->iSocketTimeOut);
}
}
}