本文整理汇总了PHP中CBXPunycode类的典型用法代码示例。如果您正苦于以下问题:PHP CBXPunycode类的具体用法?PHP CBXPunycode怎么用?PHP CBXPunycode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CBXPunycode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: CSeoPageChecker
function CSeoPageChecker($site, $url, $get = true, $check_errors = true)
{
global $APPLICATION;
if (CModule::IncludeModule('search')) {
$this->bSearch = true;
} else {
$APPLICATION->ThrowException(GetMessage('SEO_ERROR_NO_SEARCH'));
}
// don't return false or set bError!
$this->__bCheckErrors = $check_errors;
$this->__site = $site;
$dbRes = CSite::GetByID($this->__site);
if ($arRes = $dbRes->Fetch()) {
$this->__lang = $arRes['LANGUAGE_ID'];
$this->__server_name = $arRes['SERVER_NAME'];
if (strlen($this->__server_name) <= 0) {
$this->__server_name = COption::GetOptionString('main', 'server_name', '');
}
if (strlen($this->__server_name) > 0) {
$this->__url = (CMain::IsHTTPS() ? "https://" : "http://") . CBXPunycode::ToASCII($this->__server_name, $e = null) . $url;
return $get ? $this->GetHTTPData() : true;
} else {
$this->bError = true;
$APPLICATION->ThrowException(str_replace('#SITE_ID#', $this->__site, GetMessage('SEO_ERROR_NO_SERVER_NAME')));
return false;
}
}
return false;
}
示例2: getConfiguredDomains
public function getConfiguredDomains()
{
$result = array();
$converter = CBXPunycode::GetConverter();
$domainName = COption::GetOptionString("main", "server_name", "");
if ($domainName != "") {
$result[$domainName] = $domainName;
}
$by = "";
$order = "";
$siteList = CSite::GetList($by, $order, array("ACTIVE" => "Y"));
while ($site = $siteList->Fetch()) {
$domains = explode("\r\n", $site["DOMAINS"]);
foreach ($domains as $domainName) {
if ($domainName != "") {
$punyName = $converter->Encode($domainName);
if ($punyName !== false) {
$result[$punyName] = $domainName;
}
}
}
}
ksort($result);
return $result;
}
示例3: getCurrentHost
/**
* Return current domain name (in puny code for cyrillic domain)
*
* @return string
*/
public static function getCurrentHost()
{
$host = COption::GetOptionString("main", "server_name", $_SERVER["HTTP_HOST"]);
if ($host == "") {
$host = $_SERVER["HTTP_HOST"];
}
return CBXPunycode::ToASCII($host, $arErrors);
}
示例4: appendIBlockEntry
public function appendIBlockEntry($url, $modifiedDate, $priority = 0)
{
if ($this->isExists()) {
$this->appendEntry(array('XML_LOC' => $this->settings['PROTOCOL'] . '://' . \CBXPunycode::toASCII($this->settings['DOMAIN'], $e = null) . $url, 'XML_LASTMOD' => date('c', $modifiedDate - \CTimeZone::getOffset()), 'XML_PRIORITY' => $priority ? $priority : self::DEFAULT_PRIORITY));
} else {
$this->addHeader();
$this->addIBlockEntry($url, $modifiedDate, $priority);
$this->addFooter();
}
}
示例5: findCorrectFile
function findCorrectFile($path, &$strWarn, $warning = false)
{
$arUrl = CHTTP::ParseURL($path);
if ($arUrl && is_array($arUrl)) {
if (isset($arUrl['host'], $arUrl['scheme'])) {
if (strpos($arUrl['host'], 'xn--') !== false) {
// Do nothing
} else {
$originalPath = $path;
$path = $arUrl['scheme'] . '://' . $arUrl['host'];
$arErrors = array();
if (defined("BX_UTF")) {
$punicodedPath = CBXPunycode::ToUnicode($path, $arErrors);
} else {
$punicodedPath = CBXPunycode::ToASCII($path, $arErrors);
}
if ($pathPunicoded == $path) {
return $originalPath;
} else {
$path = $punicodedPath;
}
if ($arUrl['port'] && ($arUrl['scheme'] != 'http' || $arUrl['port'] != 80) && ($arUrl['scheme'] != 'https' || $arUrl['port'] != 443)) {
$path .= ':' . $arUrl['port'];
}
$path .= $arUrl['path_query'];
}
} else {
$DOC_ROOT = $_SERVER["DOCUMENT_ROOT"];
$path = Rel2Abs("/", $path);
$path_ = $path;
$io = CBXVirtualIo::GetInstance();
if (!$io->FileExists($DOC_ROOT . $path)) {
if (CModule::IncludeModule('clouds')) {
$path = CCloudStorage::FindFileURIByURN($path, "component:player");
if ($path == "") {
if ($warning) {
$strWarn .= $warning . "<br />";
}
$path = $path_;
}
} else {
if ($warning) {
$strWarn .= $warning . "<br />";
}
$path = $path_;
}
} elseif (strpos($_SERVER['HTTP_HOST'], 'xn--') !== false) {
$path = CHTTP::URN2URI($path);
}
}
}
return $path;
}
示例6: getDomainsList
public static function getDomainsList()
{
static $arDomains = null;
if($arDomains === null)
{
$arDomains = array();
$dbSites = Freetrix\Main\SiteDomainTable::getList(
array(
'select'=>array(
'DOMAIN', 'LID',
'SITE_NAME'=>'SITE.NAME', 'SITE_ACTIVE' => 'SITE.ACTIVE',
'SITE_DIR' => 'SITE.DIR', 'SITE_DOC_ROOT' => 'SITE.DOC_ROOT'
)
)
);
$defaultDomain = CBXPunycode::ToASCII(Freetrix\Main\Config\Option::getRealValue('main', 'server_name'), $e = null);
$bCurrentHostFound = false;
while($arSite = $dbSites->fetch())
{
$arDomains[] = $arSite;
if($arSite['DOMAIN'] == $defaultDomain)
$bCurrentHostFound = true;
}
if(!$bCurrentHostFound)
{
$dbDefSite = Freetrix\Main\SiteTable::getList(array(
'filter' => array('DEF' => 'Y'),
'select' => array('LID', 'NAME', 'ACTIVE'),
));
$arDefSite = $dbDefSite->fetch();
if($arDefSite)
{
array_unshift($arDomains, array(
'DOMAIN' => $defaultDomain,
'LID' => $arDefSite['LID'],
'SITE_NAME' => $arDefSite['NAME'],
'SITE_ACTIVE' => $arDefSite['ACTIVE'],
'SITE_DIR' => $arDefSite['DIR'],
'SITE_DOC_ROOT' => $arDefSite['DOC_ROOT'],
));
}
}
}
return $arDomains;
}
示例7: getActionURL
/**
* Returns URL to update policy
*
* @param array[string]string $arParams
* @return string
*
*/
protected function getActionURL($arParams = array())
{
$arErrors = array();
$domainTmp = CBXPunycode::ToASCII($this->domain, $arErrors);
if (strlen($domainTmp) > 0) {
$domain = $domainTmp;
} else {
$domain = $this->domain;
}
$arParams["license"] = md5(LICENSE_KEY);
$arParams["domain"] = $domain;
$url = COption::GetOptionString("bitrixcloud", "cdn_policy_url");
$url = CHTTP::urlAddParams($url, $arParams, array("encode" => true));
return $url;
}
示例8: appendIndexEntry
public function appendIndexEntry($file)
{
if ($this->isExists()) {
$fileUrlEnc = Converter::getXmlConverter()->encode($this->settings['PROTOCOL'] . '://' . \CBXPunycode::toASCII($this->settings['DOMAIN'], $e = null) . $this->getFileUrl($file));
$contents = $this->getContents();
$reg = "/" . sprintf(preg_quote(self::ENTRY_TPL, "/"), preg_quote($fileUrlEnc, "/"), "[^<]*") . "/";
$newEntry = sprintf(self::ENTRY_TPL, $fileUrlEnc, date(c, $file->getModificationTime($file)));
$count = 0;
$contents = preg_replace($reg, $newEntry, $contents, 1, $count);
if ($count <= 0) {
$contents = substr($contents, 0, -strlen(self::FILE_FOOTER)) . $newEntry . self::FILE_FOOTER;
}
$this->putContents($contents);
} else {
$this->createIndex(array($file));
}
}
示例9: __construct
function __construct($step = 0, $fast = 0, $fix_mode = 0)
{
if (!$this->step = intval($step))
$this->arTestVars['site_checker_success'] = 'Y';
$this->test_percent = 0;
$this->strError = '';
$this->timeout = 10; // sec for one step
$this->strResult = '';
$this->fix_mode = intval($fix_mode);
$this->cafile = $_SERVER['DOCUMENT_ROOT'].'/bitrix/tmp/cacert.pem';
$this->host = $_REQUEST['HTTP_HOST'] ? $_REQUEST['HTTP_HOST'] : 'localhost';
if (!$fix_mode) // no need to know the host in fix mode
{
if (!preg_match('/^[a-z0-9\.\-]+$/i', $this->host)) // cyrillic domain hack
{
$host = $this->host;
$host0 = CharsetConverter::ConvertCharset($host, 'utf8', 'cp1251');
if (preg_match("/[\xC0-\xFF]/",$host0))
{
// utf-8;
if (!defined('BX_UTF') && BX_UTF !== true)
$host = $host0;
}
elseif (preg_match("/[\xC0-\xFF]/",$host))
{
// windows-1251
if (defined('BX_UTF') && BX_UTF === true)
$host = CharsetConverter::ConvertCharset($host, 'cp1251', 'utf8');
}
$converter = new CBXPunycode();
$host = $converter->Encode($host);
$this->host = $host;
}
}
$this->ssl = $_REQUEST['HTTPS'] == 'on';
$this->port = $_REQUEST['SERVER_PORT'] ? $_REQUEST['SERVER_PORT'] : ($this->ssl ? 443 : 80);
$arTestGroup = array();
$arGroupName = array();
$arGroupName[1] = IsModuleInstalled('intranet') ? GetMessage("MAIN_SC_GENERAL") : GetMessage("MAIN_SC_GENERAL_SITE");
$arGroupDesc[1] = GetMessage("MAIN_SC_REQUIRED_MODS_DESC");
$arTestGroup[1] = array(
array('check_php_modules' =>GetMessage('SC_T_MODULES')),
array('check_php_settings' =>GetMessage('SC_T_PHP')),
array('check_security' => GetMessage('SC_T_APACHE')),
array('check_server_vars' =>GetMessage('SC_T_SERVER')),
array('check_session' => GetMessage('SC_T_SESS')),
array('check_mbstring' =>GetMessage('SC_T_MBSTRING')),
array('check_socket' => GetMessage('SC_T_SOCK')),
);
$arGroupName[2] = GetMessage("MAIN_SC_BUSINESS");
$arGroupDesc[2] = GetMessage("MAIN_SC_CORRECT_DESC");
$arTestGroup[2] = array(
array('check_pull_stream' => GetMessage("MAIN_SC_TEST_CHAT")),
array('check_pull_comments' => GetMessage("MAIN_SC_TEST_COMMENTS")),
array('check_turn' => GetMessage("MAIN_SC_TEST_VIDEO")),
array('check_access_mobile' => GetMessage("MAIN_SC_TEST_MOBILE")),
array('check_push_bitrix' => GetMessage("MAIN_SC_TEST_PUSH")),
array('check_access_docs' => GetMessage("MAIN_SC_TEST_DOCS")),
array('check_fast_download' => GetMessage("MAIN_SC_TEST_FAST_FILES")),
array('check_search' => GetMessage("MAIN_SC_TEST_SEARCH_CONTENTS")),
array('check_mail' => GetMessage("MAIN_SC_MAIL_TEST")),
array('check_ca_file' => GetMessage("MAIN_SC_CLOUD_TEST")),
array('check_connect_mail' => GetMessage("MAIN_SC_TEST_MAIL_INTEGRATION")),
array('check_socnet' => GetMessage("MAIN_SC_TEST_SOCNET_INTEGRATION")),
);
if (IsModuleInstalled('extranet'))
$arTestGroup[2][] = array('check_extranet' => GetMessage("MAIN_SC_EXTRANET_ACCESS"));
$arGroupName[4] = GetMessage("MAIN_SC_WINDOWS_ENV");
$arGroupDesc[4] = '';
$arTestGroup[4] = array(
array('check_webdav' => GetMessage("MAIN_SC_DOCS_EDIT_MS_OFFICE")),
array('check_socket_ssl' => GetMessage("MAIN_SC_EXTERNAL_APPS_TEST")),
array('check_ad' => GetMessage("MAIN_SC_TEST_LDAP")),
array('check_ntlm' => GetMessage("MAIN_SC_TEST_NTLM")),
);
$arGroupName[8] = GetMessage("MAIN_SC_PERFORM");
$arGroupDesc[8] = '';
$arTestGroup[8] = array(
array('check_perf' => GetMessage("MAIN_SC_PERF_TEST")),
array('check_compression' => GetMessage("MAIN_SC_COMPRESSION_TEST")),
);
$arGroupName[16] = GetMessage('SC_GR_EXTENDED');
$arTestGroup[16] = array(
array('check_dbconn_settings' => GetMessage('SC_T_DBCONN_SETTINGS')),
array('check_dbconn' => GetMessage('SC_T_DBCONN')),
array('check_bx_crontab' => GetMessage("MAIN_SC_AGENTS_CRON")),
array('check_session_ua' => GetMessage('SC_T_SESS_UA')),
array('check_sites' => GetMessage('SC_T_SITES')),
array('check_install_scripts' => GetMessage('SC_T_INSTALL_SCRIPTS')),
array('check_clone' => GetMessage('SC_T_CLONE')),
array('check_pcre_recursion' => GetMessage('SC_T_RECURSION')),
array('check_method_exists' => GetMessage('SC_T_METHOD_EXISTS')),
//.........这里部分代码省略.........
示例10: getFeeds
public function getFeeds()
{
$queryResult = $this->queryJson(self::QUERY_BASE . self::SCOPE_FEED_SITES);
if ($queryResult->getStatus() == self::HTTP_STATUS_OK && strlen($queryResult->getResult()) > 0) {
$result = Json::decode($queryResult->getResult());
$response = array();
if (is_array($result)) {
foreach ($result['siteEntry'] as $key => $siteInfo) {
$siteUrlInfo = parse_url($siteInfo['siteUrl']);
if ($siteUrlInfo) {
$errors = array();
$hostKey = \CBXPunycode::toASCII($siteUrlInfo["host"], $errors);
if (count($errors) > 0) {
$hostKey = $siteUrlInfo["host"];
}
$response[$hostKey] = array('binded' => $siteInfo["permissionLevel"] !== "siteRestrictedUser", 'verified' => $siteInfo["permissionLevel"] !== "siteRestrictedUser" && $siteInfo["permissionLevel"] !== "siteUnverifiedUser");
}
}
}
return $response;
} else {
throw new \Exception('Query error! ' . $queryResult->getStatus() . ': ' . $queryResult->getResult());
}
}
示例11: URLEncode
function URLEncode($str, $charset)
{
global $APPLICATION;
$strEncodedURL = '';
$arUrlComponents = preg_split("#(://|/|\\?|=|&)#", $str, -1, PREG_SPLIT_DELIM_CAPTURE);
foreach ($arUrlComponents as $i => $part_of_url) {
if ($i % 2) {
$strEncodedURL .= $part_of_url;
} else {
if ($i > 1 && $arUrlComponents[$i - 1] === "://") {
$converter = CBXPunycode::GetConverter();
$strEncodedURL .= $converter->Encode($part_of_url);
} else {
$strEncodedURL .= urlencode($APPLICATION->ConvertCharset(urldecode($part_of_url), LANG_CHARSET, $charset));
}
}
}
return $strEncodedURL;
}
示例12:
$domain = false;
}
if(!$domain)
{
require($_SERVER["DOCUMENT_ROOT"]."/freetrix/modules/main/include/prolog_admin_after.php");
ShowError(Loc::getMessage("SEO_ERROR_NO_DOMAIN"));
require($_SERVER["DOCUMENT_ROOT"]."/freetrix/modules/main/include/epilog_admin.php");
}
$APPLICATION->SetAdditionalCSS('/freetrix/panel/seo/seo.css');
$engine = new Engine\Google();
$siteDomainEnc = Converter::getHtmlConverter()->encode($arDomain['DOMAIN']);
$siteDomainEncView = Converter::getHtmlConverter()->encode(\CBXPunycode::ToUnicode($arDomain['DOMAIN'], $e = null));
$siteDirEnc = Converter::getHtmlConverter()->encode($arDomain['SITE_DIR']);
try
{
$arSiteInfo = $engine->getSiteInfo($arDomain['DOMAIN'], $arDomain['SITE_DIR']);
}
catch(Exception $e)
{
require($_SERVER["DOCUMENT_ROOT"]."/freetrix/modules/main/include/prolog_admin_after.php");
ShowError($e->getMessage());
require($_SERVER["DOCUMENT_ROOT"]."/freetrix/modules/main/include/epilog_admin.php");
}
$bSiteVerified = $arSiteInfo[$domain]['verified'] == 'true';
示例13: GetServerPath
public static function GetServerPath()
{
if (defined("SITE_SERVER_NAME") && strlen(SITE_SERVER_NAME) > 0)
$server_name = SITE_SERVER_NAME;
if (!$server_name)
$server_name = COption::GetOptionString("main", "server_name", "");
if (!$server_name)
$server_name = $_SERVER['HTTP_HOST'];
$server_name = rtrim($server_name, '/');
if (!preg_match('/^[a-z0-9\.\-]+$/i', $server_name)) // cyrillic domain hack
{
$converter = new CBXPunycode(defined('BX_UTF') && BX_UTF === true ? 'UTF-8' : 'windows-1251');
$host = $converter->Encode($server_name);
if (!preg_match('#--p1ai$#', $host)) // trying to guess
$host = $converter->Encode(CharsetConverter::ConvertCharset($server_name, 'utf-8', 'windows-1251'));
$server_name = $host;
}
$serverPath = (CMain::IsHTTPS() ? "https://" : "http://").$server_name;
return $serverPath;
}
示例14: GetServerName
public static function GetServerName()
{
if (defined("SITE_SERVER_NAME") && strlen(SITE_SERVER_NAME) > 0) {
$server_name = SITE_SERVER_NAME;
}
if (!$server_name) {
$server_name = COption::GetOptionString("main", "server_name", "");
}
if (!$server_name) {
$server_name = $_SERVER['HTTP_HOST'];
}
$server_name = rtrim($server_name, '/');
if (!preg_match('/^[a-z0-9\\.\\-]+$/i', $server_name)) {
$converter = new CBXPunycode(defined('BX_UTF') && BX_UTF === true ? 'UTF-8' : 'windows-1251');
$host = $converter->Encode($server_name);
if (!preg_match('#--p1ai$#', $host)) {
// trying to guess
$host = $converter->Encode(CharsetConverter::ConvertCharset($server_name, 'utf-8', 'windows-1251'));
}
$server_name = $host;
}
return $server_name;
}
示例15: getUrl
/**
* Returns sitemap file URL
*
* @return string
*/
public function getUrl()
{
return $this->settings['PROTOCOL'].'://'.\CBXPunycode::toASCII($this->settings['DOMAIN'], $e = null).$this->getFileUrl($this);
}