本文整理匯總了PHP中MailSo\Base\Utils::FunctionExistsAndEnabled方法的典型用法代碼示例。如果您正苦於以下問題:PHP Utils::FunctionExistsAndEnabled方法的具體用法?PHP Utils::FunctionExistsAndEnabled怎麽用?PHP Utils::FunctionExistsAndEnabled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MailSo\Base\Utils
的用法示例。
在下文中一共展示了Utils::FunctionExistsAndEnabled方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: Connect
/**
* @return bool
*/
public function Connect()
{
$sHost = $this->bUseSsl ? 'ssl://' . $this->sHost : $this->sHost;
if ($this->IsConnected()) {
CApi::Log('already connected[' . $sHost . ':' . $this->iPort . ']: result = false', ELogLevel::Error);
$this->Disconnect();
return false;
}
$sErrorStr = '';
$iErrorNo = 0;
CApi::Log('start connect to ' . $sHost . ':' . $this->iPort);
$this->rConnect = @fsockopen($sHost, $this->iPort, $iErrorNo, $sErrorStr, $this->iConnectTimeOut);
if (!$this->IsConnected()) {
CApi::Log('connection error[' . $sHost . ':' . $this->iPort . ']: fsockopen = false (' . $iErrorNo . ': ' . $sErrorStr . ')', ELogLevel::Error);
return false;
} else {
CApi::Log('connected');
}
if (\MailSo\Base\Utils::FunctionExistsAndEnabled('stream_set_timeout')) {
@stream_set_timeout($this->rConnect, $this->iSocketTimeOut);
}
if (\MailSo\Base\Utils::FunctionExistsAndEnabled('@stream_set_blocking')) {
@stream_set_blocking($this->rConnect, true);
}
return true;
}
示例2: clearImplementation
/**
* @return bool
*/
protected function clearImplementation()
{
if (\defined('PHP_SAPI') && 'cli' === PHP_SAPI && \MailSo\Base\Utils::FunctionExistsAndEnabled('system')) {
\system('clear');
}
return true;
}
示例3: __construct
/**
* @param string $sFileName
* @param string $sFileHeader = ''
*
* @return void
*/
public function __construct($sFileName, $sFileHeader = '')
{
$this->sFile = \APP_PRIVATE_DATA . 'configs/' . $sFileName;
$this->sFileHeader = $sFileHeader;
$this->aData = $this->defaultValues();
$this->bUseApcCache = APP_USE_APC_CACHE && \MailSo\Base\Utils::FunctionExistsAndEnabled(array('apc_fetch', 'apc_store'));
}
示例4: UseStartTLS
/**
* @param bool $bSupported
* @param int $iSecurityType
* @param bool $bHasSupportedAuth = true
*
* @return bool
*/
public static function UseStartTLS($bSupported, $iSecurityType, $bHasSupportedAuth = true)
{
return ($bSupported &&
(self::STARTTLS === $iSecurityType ||
(self::AUTO_DETECT === $iSecurityType && (!$bHasSupportedAuth || \MailSo\Config::$PreferStartTlsIfAutoDetect))) &&
\defined('STREAM_CRYPTO_METHOD_TLS_CLIENT') && \MailSo\Base\Utils::FunctionExistsAndEnabled('stream_socket_enable_crypto'));
}
示例5: __construct
/**
* @param string $sFileName
* @param string $sFileHeader = ''
* @param string $sAdditionalFileName = ''
*
* @return void
*/
public function __construct($sFileName, $sFileHeader = '', $sAdditionalFileName = '')
{
$this->sFile = \APP_PRIVATE_DATA . 'configs/' . \trim($sFileName);
$sAdditionalFileName = \trim($sAdditionalFileName);
$this->sAdditionalFile = \APP_PRIVATE_DATA . 'configs/' . $sAdditionalFileName;
$this->sAdditionalFile = 0 < \strlen($sAdditionalFileName) && \file_exists($this->sAdditionalFile) ? $this->sAdditionalFile : '';
$this->sFileHeader = $sFileHeader;
$this->aData = $this->defaultValues();
$this->bUseApcCache = APP_USE_APC_CACHE && \MailSo\Base\Utils::FunctionExistsAndEnabled(array('apc_fetch', 'apc_store'));
}
示例6: GetDomFromText
/**
* @param string $sText
*
* @return \DOMDocument | bool
*/
public static function GetDomFromText($sText)
{
static $bOnce = true;
if ($bOnce) {
$bOnce = false;
if (\MailSo\Base\Utils::FunctionExistsAndEnabled('libxml_use_internal_errors')) {
@\libxml_use_internal_errors(true);
}
}
$oDom = new \DOMDocument('1.0', 'utf-8');
$oDom->encoding = 'UTF-8';
@$oDom->loadHTML('<' . '?xml version="1.0" encoding="utf-8"?' . '>' . '<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body>' . $sText . '</body></html>');
return $oDom;
}
示例7: Statistic
/**
* @return array|null
*/
public static function Statistic()
{
$aResult = null;
if (self::$StoreStatistic) {
$aResult = array('php' => array('phpversion' => PHP_VERSION, 'ssl' => (int) \function_exists('openssl_open'), 'iconv' => (int) \function_exists('iconv')));
if (\MailSo\Base\Utils::FunctionExistsAndEnabled('memory_get_usage') && \MailSo\Base\Utils::FunctionExistsAndEnabled('memory_get_peak_usage')) {
$aResult['php']['memory_get_usage'] = Utils::FormatFileSize(\memory_get_usage(true), 2);
$aResult['php']['memory_get_peak_usage'] = Utils::FormatFileSize(\memory_get_peak_usage(true), 2);
}
self::SetStatistic('TimeDelta', \microtime(true) - self::GetStatistic('Inited'));
$aResult['statistic'] = self::$aSetStatistic;
$aResult['counts'] = self::$aIncStatistic;
}
return $aResult;
}
示例8: GetDomFromText
/**
* @param string $sText
* @param string $sHtmlAttrs = ''
* @param string $sBodyAttrs = ''
*
* @return \DOMDocument|bool
*/
public static function GetDomFromText($sText, $sHtmlAttrs = '', $sBodyAttrs = '')
{
$bState = true;
if (\MailSo\Base\Utils::FunctionExistsAndEnabled('libxml_use_internal_errors')) {
$bState = \libxml_use_internal_errors(true);
}
$oDom = new \DOMDocument('1.0', 'utf-8');
$oDom->encoding = 'UTF-8';
$oDom->strictErrorChecking = false;
$oDom->formatOutput = false;
@$oDom->loadHTML('<' . '?xml version="1.0" encoding="utf-8"?' . '>' . '<html ' . $sHtmlAttrs . '><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body ' . $sBodyAttrs . '>' . $sText . '</body></html>');
@$oDom->normalizeDocument();
if (\MailSo\Base\Utils::FunctionExistsAndEnabled('libxml_use_internal_errors')) {
@\libxml_clear_errors();
}
if (\MailSo\Base\Utils::FunctionExistsAndEnabled('libxml_use_internal_errors')) {
\libxml_use_internal_errors($bState);
}
return $oDom;
}
示例9: generateNewMessageId
/**
* @param string $sHostName = ''
*
* @return string
*/
private function generateNewMessageId($sHostName = '')
{
if (0 === \strlen($sHostName)) {
$sHostName = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : '';
}
if (empty($sHostName) && \MailSo\Base\Utils::FunctionExistsAndEnabled('php_uname')) {
$sHostName = \php_uname('n');
}
if (empty($sHostName)) {
$sHostName = 'localhost';
}
return '<' . \md5(\rand(100000, 999999) . \time() . $sHostName . (\MailSo\Base\Utils::FunctionExistsAndEnabled('getmypid') ? @\getmypid() : '')) . '@' . $sHostName . '>';
}
示例10: GetHeader
/**
* @param string $sHeader
*
* @return string
*/
public function GetHeader($sHeader)
{
$sResultHeader = '';
$sServerKey = 'HTTP_' . \strtoupper(\str_replace('-', '_', $sHeader));
$sResultHeader = $this->GetServer($sServerKey, '');
if (0 === \strlen($sResultHeader) && \MailSo\Base\Utils::FunctionExistsAndEnabled('apache_request_headers')) {
$sHeaders = \apache_request_headers();
if (isset($sHeaders[$sHeader])) {
$sResultHeader = $sHeaders[$sHeader];
}
}
return $sResultHeader;
}
示例11: CustomParseIniFile
/**
* @param string $sFileName
* @param bool $bProcessSections = false
*
* @return array
*/
public static function CustomParseIniFile($sFileName, $bProcessSections = false)
{
if (\MailSo\Base\Utils::FunctionExistsAndEnabled('parse_ini_file')) {
return @\parse_ini_file($sFileName, !!$bProcessSections);
}
$sData = @\file_get_contents($sFileName);
return \is_string($sData) ? @\parse_ini_string($sData, !!$bProcessSections) : null;
}
示例12: 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($sErrorStr, $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);
}
if (\MailSo\Base\Utils::FunctionExistsAndEnabled('stream_set_blocking')) {
@\stream_set_blocking($this->rConnect, 1);
}
}
}
示例13: specialConvertSearchValueLower
/**
* @param string $sSearch
* @param string $sEscapeSign = '='
*
* @return string
*/
private function specialConvertSearchValueLower($sSearch, $sEscapeSign = '=')
{
if (!\MailSo\Base\Utils::FunctionExistsAndEnabled('mb_strtolower')) {
return '';
}
return '%' . \str_replace(array($sEscapeSign, '_', '%'), array($sEscapeSign . $sEscapeSign, $sEscapeSign . '_', $sEscapeSign . '%'), (string) @\mb_strtolower($sSearch, 'UTF-8')) . '%';
}
示例14: UpdateDependentValues
public function UpdateDependentValues()
{
$this->Value = \trim($this->Value);
$this->ValueCustom = \trim($this->ValueCustom);
$this->TypeStr = \trim($this->TypeStr);
$this->ValueLower = '';
if (0 < \strlen($this->Value)) {
// lower
if ($this->IsEmail()) {
$this->Value = \MailSo\Base\Utils::StrToLowerIfAscii($this->Value);
}
if ($this->IsName()) {
$this->Value = \MailSo\Base\Utils::StripSpaces($this->Value);
}
// lower value for searching
if (\MailSo\Base\Utils::FunctionExistsAndEnabled('mb_strtolower')) {
$this->ValueLower = (string) @\mb_strtolower($this->Value, 'UTF-8');
}
// phone value for searching
if ($this->IsPhone()) {
$sPhone = \trim($this->Value);
$sPhone = \preg_replace('/^[+]+/', '', $sPhone);
$sPhone = \preg_replace('/[^\\d]/', '', $sPhone);
$this->ValueCustom = \trim($sPhone);
}
}
}
示例15: GetHeaders
/**
* @param string $sHeader
*
* @return string
*/
public function GetHeaders()
{
$aHeaders = array();
if (\MailSo\Base\Utils::FunctionExistsAndEnabled('apache_request_headers')) {
$aHeaders = \apache_request_headers();
}
return $aHeaders;
}