本文整理汇总了PHP中CharsetConverter类的典型用法代码示例。如果您正苦于以下问题:PHP CharsetConverter类的具体用法?PHP CharsetConverter怎么用?PHP CharsetConverter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CharsetConverter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public static function execute()
{
global $USER;
$result = array();
$error = false;
if (!CModule::IncludeModule('voximplant')) {
$error = 'Module voximplant is not installed.';
} else {
if (!is_object($USER) || !$USER->IsAuthorized()) {
$error = GetMessage('ACCESS_DENIED');
} else {
if (!CVoxImplantMain::CheckAccess()) {
$error = GetMessage('ACCESS_DENIED');
} else {
if (!check_bitrix_sessid()) {
$error = GetMessage('ACCESS_DENIED');
} else {
if ($_REQUEST["act"] == "edit") {
$result = self::executeEditPhones($error);
} else {
if ($_REQUEST["act"] == "getInfo") {
$result = self::executeGetInfo($error);
} else {
if ($_REQUEST["act"] == "option") {
$result = self::executeSaveOption($error);
}
}
}
}
}
}
}
self::returnJson(array_merge(array('result' => $error === false ? 'ok' : 'error', 'error' => CharsetConverter::ConvertCharset($error, SITE_CHARSET, 'UTF-8')), $result));
}
示例2: referenceItemsStart
public function referenceItemsStart($path, $attr)
{
if ($this->NS["fp"] <= 0) {
$this->error = GetMessage("CC_BCIH_XML_PARSE_ERROR", array("#CODE#" => 10));
} else {
$this->deleteBySessid($this->NS["HL"], $this->NS["SESSID"]);
$xmlPosition = $this->xmlStream->getPosition();
$filePosition = $this->decodePostion($xmlPosition);
$xmlString = $this->xmlStream->readFilePart($this->NS["fp"], $filePosition);
$error = "";
if ($xmlPosition[0]) {
$xmlString = CharsetConverter::convertCharset($xmlString, $xmlPosition[0], LANG_CHARSET, $error);
}
$xmlString .= "</" . GetMessage("CC_BCIH_XML_REFERENCE") . ">";
$xmlObject = new CDataXML();
if ($xmlObject->loadString($xmlString)) {
$highBlockID = $this->checkReference($xmlObject->GetArray());
$this->dataClass = "";
$this->step = true;
$this->message = GetMessage("CC_BCIH_REFERENCE_FOUND_OR_CREATED", array("#CODE#" => $highBlockID));
if ($highBlockID > 0) {
$this->NS["HL"] = $highBlockID;
$this->NS["FM"] = array();
$this->NS["C"] = 0;
} else {
$this->error = GetMessage("CC_BCIH_XML_PARSE_ERROR", array("#CODE#" => 30));
}
} else {
$this->error = GetMessage("CC_BCIH_XML_PARSE_ERROR", array("#CODE#" => 20));
}
}
}
示例3: GetInstance
/**
* @static
* @return CharsetConverter
*/
public static function GetInstance()
{
if (!isset(self::$instance))
{
$c = __CLASS__;
self::$instance = new $c;
}
return self::$instance;
}
示例4: qiwiWalletXmlResponse
function qiwiWalletXmlResponse($code)
{
global $APPLICATION;
$APPLICATION->RestartBuffer();
header("Content-Type: text/xml");
header("Pragma: no-cache");
$xml = '<?xml version="1.0" encoding="UTF-8"?><result><result_code>' . $code . '</result_code></result>';
$siteCharset = Application::getInstance()->getContext()->getCulture()->getCharset();
print \CharsetConverter::getInstance()->ConvertCharset($xml, $siteCharset, "utf-8");
die;
}
示例5: createDomain
public static function createDomain($user, $password, $domain, $params, &$error)
{
$domain = CharsetConverter::ConvertCharset($domain, SITE_CHARSET, 'UTF-8');
$result = CMailRegru::createDomain($user, $password, $domain, array('period' => 1, 'enduser_ip' => $params['ip'], 'profile_type' => $params['profile_type'], 'profile_name' => $params['profile_name'], 'nss' => array('ns0' => 'ns1.reg.ru.', 'ns1' => 'ns2.reg.ru.')), $error);
if ($result !== false) {
if (isset($result['dname']) && strtolower($result['dname']) == strtolower($domain)) {
return true;
} else {
$error = 'unknown';
}
}
$error = self::getErrorCode($result['error_code']);
return null;
}
示例6: readXml
/**
* Reads xml chunk from the file preserving it's position
*
* @param int $startPosition
* @param int $endPosition
* @return CDataXML|false
*/
private function readXml($startPosition, $endPosition)
{
$savedPosition = ftell($this->fileHandler);
fseek($this->fileHandler, $startPosition);
$xmlChunk = fread($this->fileHandler, $endPosition - $startPosition);
fseek($this->fileHandler, $savedPosition);
if ($xmlChunk && $this->fileCharset) {
$error = "";
$xmlChunk = CharsetConverter::convertCharset($xmlChunk, $this->fileCharset, LANG_CHARSET, $error);
}
$xmlObject = new CDataXML();
if ($xmlObject->loadString($xmlChunk)) {
return $xmlObject;
} else {
return false;
}
}
示例7: _extractFile
private function _extractFile(&$arEntry, $path, $removePath, $removeAllPath, &$arParams)
{
if (($res = $this->_readFileHeader($header)) != 1) {
return $res;
}
//to be checked: file header should be coherent with $arEntry info
$arEntry["filename"] = CharsetConverter::ConvertCharset($arEntry["filename"], "cp866", $this->fileSystemEncoding);
$arEntry["stored_filename"] = CharsetConverter::ConvertCharset($arEntry["stored_filename"], "cp866", $this->fileSystemEncoding);
//protecting against ../ etc in file path
//only absolute path should be in the $arEntry
$arEntry['filename'] = _normalizePath($arEntry['filename']);
$arEntry['stored_filename'] = _normalizePath($arEntry['stored_filename']);
if ($removeAllPath == true) {
$arEntry['filename'] = basename($arEntry['filename']);
} else {
if ($removePath != "") {
if ($this->_containsPath($removePath, $arEntry['filename']) == 2) {
//change file status
$arEntry['status'] = "filtered";
return $res;
}
$removePath_size = strlen($removePath);
if (substr($arEntry['filename'], 0, $removePath_size) == $removePath) {
//remove path
$arEntry['filename'] = substr($arEntry['filename'], $removePath_size);
}
}
}
//making absolute path to the extracted file out of filename stored in the zip header and passed extracting path
if ($path != '') {
$arEntry['filename'] = $path . "/" . $arEntry['filename'];
}
//pre-extract callback
if (isset($arParams['callback_pre_extract']) && $arParams['callback_pre_extract'] != '') {
//generate local info
$arLocalHeader = array();
$this->_convertHeader2FileInfo($arEntry, $arLocalHeader);
//callback call
eval('$res = ' . $arParams['callback_pre_extract'] . '(\'callback_pre_extract\', $arLocalHeader);');
//change file status
if ($res == 0) {
$arEntry['status'] = "skipped";
$res = 1;
}
//update the info, only some fields can be modified
$arEntry['filename'] = $arLocalHeader['filename'];
}
//check if extraction should be done
if ($arEntry['status'] == 'ok') {
$logicalFilename = $this->io->GetLogicalName($arEntry['filename']);
if ((HasScriptExtension($arEntry['filename']) || IsFileUnsafe($arEntry['filename']) || !$this->io->ValidatePathString($logicalFilename) || !$this->io->ValidateFilenameString(GetFileName($logicalFilename))) && $this->checkBXPermissions == true) {
$arEntry['status'] = "no_permissions";
} else {
//if the file exists, change status
if (file_exists($arEntry['filename'])) {
if (is_dir($arEntry['filename'])) {
$arEntry['status'] = "already_a_directory";
} else {
if (!is_writeable($arEntry['filename'])) {
$arEntry['status'] = "write_protected";
} else {
if (filemtime($arEntry['filename']) > $arEntry['mtime'] && !$this->replaceExistentFiles) {
$arEntry['status'] = "newer_exist";
}
}
}
} else {
//check the directory availability and create it if necessary
if (($arEntry['external'] & 0x10) == 0x10 || substr($arEntry['filename'], -1) == '/') {
$checkDir = $arEntry['filename'];
} else {
if (!strstr($arEntry['filename'], "/")) {
$checkDir = "";
} else {
$checkDir = dirname($arEntry['filename']);
}
}
if (($res = $this->_checkDir($checkDir, ($arEntry['external'] & 0x10) == 0x10)) != 1) {
//change file status
$arEntry['status'] = "path_creation_fail";
//return $res;
$res = 1;
}
}
}
}
//check if extraction should be done
if ($arEntry['status'] == 'ok') {
//if not a folder - extract
if (!(($arEntry['external'] & 0x10) == 0x10)) {
//if zip file with 0 compression
if ($arEntry['compression'] == 0 && $arEntry['compressed_size'] == $arEntry['size']) {
if (($destFile = @fopen($arEntry['filename'], 'wb')) == 0) {
$arEntry['status'] = "write_error";
return $res;
}
//reading the fileby by self::ReadBlockSize octets blocks
$size = $arEntry['compressed_size'];
while ($size != 0) {
$length = $size < self::ReadBlockSize ? $size : self::ReadBlockSize;
//.........这里部分代码省略.........
示例8: chr
protected static function chr($a)
{
return \CharsetConverter::ConvertCharset($a, 'cp1251', SITE_CHARSET);
}
示例9: LocalRedirect
if (!empty($arResult['SETTINGS']['link'])) {
LocalRedirect($arResult['SETTINGS']['link'], true);
} else {
LocalRedirect($APPLICATION->GetCurPage() . '?STEP=setup');
}
}
}
break;
case 'check':
$APPLICATION->RestartBuffer();
$error = false;
$unseen = CMailUtil::CheckImapMailbox($acc['SERVER'], $acc['PORT'], $acc['USE_TLS'], $acc['LOGIN'], $acc['PASSWORD'], $error, 30);
CUserCounter::Set($USER->GetID(), 'mail_unseen', $unseen, SITE_ID);
CUserOptions::SetOption('global', 'last_mail_check_' . SITE_ID, time());
CUserOptions::SetOption('global', 'last_mail_check_success_' . SITE_ID, $unseen >= 0);
$response = array('result' => $error === false ? 'ok' : 'error', 'unseen' => $unseen, 'error' => CharsetConverter::ConvertCharset($error, SITE_CHARSET, 'UTF-8'));
header('Content-Type: application/x-javascript; charset=' . LANG_CHARSET);
echo json_encode($response);
die;
break;
case 'setup':
if ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_POST['SERVICE'])) {
$arResult['ERRORS'] = array();
$arResult['SETTINGS'] = $arParams['SERVICES'][$arResult['SERVICE']];
foreach ($arParams['OPTIONS'] as $option) {
if (empty($arResult['SETTINGS'][$option])) {
unset($error);
$arResult['SETTINGS'][$option] = isset($_REQUEST[$option]) ? $_REQUEST[$option] : null;
$arResult['SETTINGS'][$option] = CheckOption($option, $arResult['SETTINGS'][$option], $error);
if (!empty($error)) {
$arResult['ERRORS'][] = $error;
示例10: prepareAnswer
protected function prepareAnswer($result)
{
if (!defined("BX_UTF")) {
$result = CharsetConverter::ConvertCharset($result, "utf-8", LANG_CHARSET);
}
$res = CUtil::JsObjectToPhp($result);
if (!$res) {
AddMessage2Log('Strange answer from Network! ' . $result . print_r($res, 1));
}
return $res;
}
示例11: GetVideoOembed
public static function GetVideoOembed($url = '')
{
// Get oembed url
$oembed = self::GetOembedUrlInfo($url);
$output = array('result' => false, 'error' => "");
$http = new \Bitrix\Main\Web\HttpClient();
$resp = $http->get($oembed['url']);
if ($resp === false)
{
$error = $http->getError();
foreach($error as $errorCode => $errorMessage)
{
$output['error'] .= '['.$errorCode.'] '.$errorMessage.";\n";
}
}
else
{
$resParams = json_decode($resp, true);
if ($resParams && is_array($resParams))
{
if (!defined('BX_UTF') || BX_UTF !== true)
{
$resParams['title'] = CharsetConverter::ConvertCharset($resParams['title'], 'UTF-8', SITE_CHARSET);
$resParams['html'] = CharsetConverter::ConvertCharset($resParams['html'], 'UTF-8', SITE_CHARSET);
$resParams['provider_name'] = CharsetConverter::ConvertCharset($resParams['provider_name'], 'UTF-8', SITE_CHARSET);
}
$resParams['html'] = preg_replace("/https?:\/\//is", '//', $resParams['html']);
$output['result'] = true;
$output['data'] = array(
'html' => $resParams['html'],
'title' => $resParams['title'],
'width' => intval($resParams['width']),
'height' => intval($resParams['height']),
'provider' => $resParams['provider_name']
);
}
else
{
$output['error'] .= '[FVID404] '.GetMessage('HTMLED_VIDEO_NOT_FOUND').";\n";
}
}
return $output;
}
示例12: query
protected function query($url)
{
if ($this->access_token === false) {
return false;
}
$http = new HttpClient();
$http->setHeader("authorization", "Bearer " . $this->access_token);
$result = $http->get($url);
if (!defined("BX_UTF")) {
$result = CharsetConverter::ConvertCharset($result, "utf-8", LANG_CHARSET);
}
$result = CUtil::JsObjectToPhp($result);
return $result;
}
示例13: StrangeUrlEncode
public static function StrangeUrlEncode($url)
{
if (!defined('BX_UTF')) {
$url = CharsetConverter::ConvertCharset($url, SITE_CHARSET, "UTF-8");
}
$ind = strpos($url, "?");
$url = str_replace("%2F", "/", rawurlencode(substr($url, 0, $ind))) . substr($url, $ind);
return $url;
}
示例14: array
<?php
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php";
include_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/bizproc/include.php";
if (!check_bitrix_sessid()) {
die;
}
if (!CBPDocument::CanUserOperateDocumentType(CBPCanUserOperateOperation::CreateWorkflow, $GLOBALS["USER"]->GetID(), $_REQUEST['DocumentType'])) {
die;
}
$runtime = CBPRuntime::GetRuntime();
$runtime->StartRuntime();
$documentService = $runtime->GetService("DocumentService");
CUtil::DecodeUriComponent($_REQUEST);
CUtil::DecodeUriComponent($_POST);
if (LANG_CHARSET != "UTF-8" && isset($_REQUEST['Type']['Options']) && is_array($_REQUEST['Type']['Options'])) {
$newarr = array();
foreach ($_REQUEST['Type']['Options'] as $k => $v) {
$newarr[CharsetConverter::ConvertCharset($k, "UTF-8", LANG_CHARSET)] = $v;
}
$_REQUEST['Type']['Options'] = $newarr;
}
$v = $documentService->GetFieldInputValue($_REQUEST['DocumentType'], $_REQUEST['Type'], $_REQUEST['Field'], $_REQUEST, $arErrors);
$vp = $documentService->GetFieldInputValuePrintable($_REQUEST['DocumentType'], $_REQUEST['Type'], $v);
if (is_array($vp)) {
$vp = implode(", ", $vp);
}
echo CUtil::PhpToJSObject(array($v, $vp));
示例15: GetCurrentUserFriends
public function GetCurrentUserFriends($limit, &$next)
{
if ($this->access_token === false) {
return false;
}
$http = new HttpClient();
$http->setHeader('GData-Version', '3.0');
$http->setHeader('Authorization', 'Bearer ' . $this->access_token);
$url = static::FRIENDS_URL . '?';
$limit = intval($limit);
$next = intval($next);
if ($limit > 0) {
$url .= '&max-results=' . $limit;
}
if ($next > 0) {
$url .= '&start-index=' . $next;
}
$result = $http->get($url);
if (!defined("BX_UTF")) {
$result = CharsetConverter::ConvertCharset($result, "utf-8", LANG_CHARSET);
}
if ($http->getStatus() == 200) {
$obXml = new \CDataXML();
if ($obXml->loadString($result)) {
$tree = $obXml->getTree();
$total = $tree->elementsByName("totalResults");
$total = intval($total[0]->textContent());
$limitNode = $tree->elementsByName("itemsPerPage");
$next += intval($limitNode[0]->textContent());
if ($next >= $total) {
$next = '__finish__';
}
$arFriends = array();
$arEntries = $tree->elementsByName('entry');
foreach ($arEntries as $entry) {
$arEntry = array();
$entryChildren = $entry->children();
foreach ($entryChildren as $child) {
$tag = $child->name();
switch ($tag) {
case 'category':
case 'updated':
case 'edited':
break;
case 'name':
$arEntry[$tag] = array();
foreach ($child->children() as $subChild) {
$arEntry[$tag][$subChild->name()] = $subChild->textContent();
}
break;
case 'email':
if ($child->getAttribute('primary') == 'true') {
$arEntry[$tag] = $child->getAttribute('address');
}
break;
default:
$tagContent = $tag == 'link' ? $child->getAttribute('href') : $child->textContent();
if ($child->getAttribute('rel')) {
if (!isset($arEntry[$tag])) {
$arEntry[$tag] = array();
}
$arEntry[$tag][preg_replace("/^[^#]*#/", "", $child->getAttribute('rel'))] = $tagContent;
} elseif (isset($arEntry[$tag])) {
if (!is_array($arEntry[$tag][0]) || !isset($arEntry[$tag][0])) {
$arEntry[$tag] = array($arEntry[$tag], $tagContent);
} else {
$arEntry[$tag][] = $tagContent;
}
} else {
$arEntry[$tag] = $tagContent;
}
}
}
if ($arEntry['email']) {
$arFriends[] = $arEntry;
}
}
return $arFriends;
}
}
return false;
}