本文整理汇总了PHP中MAX_commonConvertEncoding函数的典型用法代码示例。如果您正苦于以下问题:PHP MAX_commonConvertEncoding函数的具体用法?PHP MAX_commonConvertEncoding怎么用?PHP MAX_commonConvertEncoding使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MAX_commonConvertEncoding函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _iterateTableFields
/**
* This function iterates over the table fields, and either gathers data which would be changed, or changes the data
*
* @param array $aTableFields
* @return array
*/
function _iterateTableFields($aTableFields, $execute = false)
{
$aChanged = array();
$encTo = !empty($_POST['encTo']) ? $_POST['encTo'] : 'UTF-8';
$encFrom = !empty($_POST['encFrom']) ? $_POST['encFrom'] : 'UTF-8';
foreach ($aTableFields as $table => $tableData) {
$doTable = OA_Dal::factoryDO($table);
$doTable->find();
while ($doTable->fetch()) {
$changed = false;
foreach ($tableData['fields'] as $field) {
$converted = MAX_commonConvertEncoding($doTable->{$field}, $encTo, $encFrom);
if ($converted === $doTable->{$field}) {
continue;
}
$id = array();
foreach ($tableData['idfields'] as $idField) {
$id[$idField] = $doTable->{$idField};
}
if ($execute && !in_array(implode('.', $id), $_POST['aExecute'][$table][$field])) {
continue;
}
$aChanged[$table][$field][] = array('from' => $doTable->{$field}, 'to' => $converted, 'id' => $id);
$doTable->{$field} = $converted;
$changed = true;
}
if ($changed && $execute) {
$doTable->update();
}
}
}
return $aChanged;
}
示例2: MAX_commonConvertEncoding
function MAX_commonConvertEncoding($content, $toEncoding, $fromEncoding = 'UTF-8', $aExtensions = null)
{
if ($toEncoding == $fromEncoding || empty($toEncoding)) {
return $content;
}
if (!isset($aExtensions) || !is_array($aExtensions)) {
$aExtensions = array('iconv', 'mbstring', 'xml');
}
if (is_array($content)) {
foreach ($content as $key => $value) {
$content[$key] = MAX_commonConvertEncoding($value, $toEncoding, $fromEncoding, $aExtensions);
}
return $content;
} else {
$toEncoding = strtoupper($toEncoding);
$fromEncoding = strtoupper($fromEncoding);
$aMap = array();
$aMap['mbstring']['WINDOWS-1255'] = 'ISO-8859-8';
$aMap['xml']['ISO-8859-15'] = 'ISO-8859-1';
$converted = false;
foreach ($aExtensions as $extension) {
$mappedFromEncoding = isset($aMap[$extension][$fromEncoding]) ? $aMap[$extension][$fromEncoding] : $fromEncoding;
$mappedToEncoding = isset($aMap[$extension][$toEncoding]) ? $aMap[$extension][$toEncoding] : $toEncoding;
switch ($extension) {
case 'iconv':
if (function_exists('iconv')) {
$converted = @iconv($mappedFromEncoding, $mappedToEncoding, $content);
}
break;
case 'mbstring':
if (function_exists('mb_convert_encoding')) {
$converted = @mb_convert_encoding($content, $mappedToEncoding, $mappedFromEncoding);
}
break;
case 'xml':
if (function_exists('utf8_encode')) {
if ($mappedToEncoding == 'UTF-8' && $mappedFromEncoding == 'ISO-8859-1') {
$converted = utf8_encode($content);
} elseif ($mappedToEncoding == 'ISO-8859-1' && $mappedFromEncoding == 'UTF-8') {
$converted = utf8_decode($content);
}
}
break;
}
}
return $converted ? $converted : $content;
}
}
示例3: MAX_adRender
function MAX_adRender(&$aBanner, $zoneId = 0, $source = '', $target = '', $ct0 = '', $withText = false, $charset = '', $logClick = true, $logView = true, $richMedia = true, $loc = '', $referer = '', &$context = array())
{
$conf = $GLOBALS['_MAX']['CONF'];
if (empty($target)) {
$target = !empty($aBanner['target']) ? $aBanner['target'] : '_blank';
}
$target = htmlspecialchars($target, ENT_QUOTES);
$source = htmlspecialchars($source, ENT_QUOTES);
$aBanner['bannerContent'] = "";
OX_Delivery_Common_hook('preAdRender', array(&$aBanner, &$zoneId, &$source, &$ct0, &$withText, &$logClick, &$logView, null, &$richMedia, &$loc, &$referer));
$functionName = _getAdRenderFunction($aBanner, $richMedia);
$code = OX_Delivery_Common_hook('adRender', array(&$aBanner, &$zoneId, &$source, &$ct0, &$withText, &$logClick, &$logView, null, &$richMedia, &$loc, &$referer), $functionName);
list($usec, $sec) = explode(' ', microtime());
$time = (double) $usec + (double) $sec;
$random = MAX_getRandomNumber();
global $cookie_random;
$cookie_random = $random;
$clickUrl = _adRenderBuildClickUrl($aBanner, $zoneId, $source, $ct0, $logClick, true);
$urlPrefix = substr(MAX_commonGetDeliveryUrl(), 0, -1);
$code = str_replace('{clickurl}', $clickUrl, $code);
if (strpos($code, '{logurl}') !== false) {
$logUrl = _adRenderBuildLogURL($aBanner, $zoneId, $source, $loc, $referer, '&');
$code = str_replace('{logurl}', $logUrl, $code);
}
if (strpos($code, '{logurl_enc}') !== false) {
$logUrl_enc = urlencode(_adRenderBuildLogURL($aBanner, $zoneId, $source, $loc, $referer, '&'));
$code = str_replace('{logurl_enc}', $logUrl_enc, $code);
}
if (strpos($code, '{clickurlparams}')) {
$maxparams = _adRenderBuildParams($aBanner, $zoneId, $source, urlencode($ct0), $logClick, true);
$code = str_replace('{clickurlparams}', $maxparams, $code);
}
$search = array('{timestamp}', '{random}', '{target}', '{url_prefix}', '{bannerid}', '{zoneid}', '{source}', '{pageurl}', '{width}', '{height}', '{websiteid}', '{campaignid}', '{advertiserid}', '{referer}');
$locReplace = isset($GLOBALS['loc']) ? $GLOBALS['loc'] : '';
$websiteid = !empty($aBanner['affiliate_id']) ? $aBanner['affiliate_id'] : '0';
$replace = array($time, $random, $target, $urlPrefix, $aBanner['ad_id'], $zoneId, $source, urlencode($locReplace), $aBanner['width'], $aBanner['height'], $websiteid, $aBanner['campaign_id'], $aBanner['client_id'], $referer);
preg_match_all('#{(.*?)(_enc)?}#', $code, $macros);
for ($i = 0; $i < count($macros[1]); $i++) {
if (!in_array($macros[0][$i], $search) && isset($_REQUEST[$macros[1][$i]])) {
$search[] = $macros[0][$i];
$replace[] = !empty($macros[2][$i]) ? urlencode(stripslashes($_REQUEST[$macros[1][$i]])) : htmlspecialchars(stripslashes($_REQUEST[$macros[1][$i]]), ENT_QUOTES);
}
}
$componentParams = OX_Delivery_Common_hook('addUrlParams', array($aBanner));
if (!empty($componentParams) && is_array($componentParams)) {
foreach ($componentParams as $params) {
if (!empty($params) && is_array($params)) {
foreach ($params as $key => $value) {
$search[] = '{' . $key . '}';
$replace[] = urlencode($value);
}
}
}
}
$code = str_replace($search, $replace, $code);
$clickUrl = str_replace($search, $replace, $clickUrl);
$aBanner['clickUrl'] = $clickUrl;
if (strpos($code, '{clickurl_enc}') !== false) {
$code = str_replace('{clickurl_enc}', urlencode($clickUrl), $code);
}
$logUrl = _adRenderBuildLogURL($aBanner, $zoneId, $source, $loc, $referer, '&');
$logUrl = str_replace($search, $replace, $logUrl);
$aBanner['logUrl'] = $logUrl;
$aBanner['aSearch'] = $search;
$aBanner['aReplace'] = $replace;
OX_Delivery_Common_hook('postAdRender', array(&$code, $aBanner, &$context));
return MAX_commonConvertEncoding($code, $charset);
}
示例4: MAX_adRender
function MAX_adRender(&$aBanner, $zoneId = 0, $source = '', $target = '', $ct0 = '', $withText = false, $charset = '', $logClick = true, $logView = true, $richMedia = true, $loc = '', $referer = '', $context = array())
{
$conf = $GLOBALS['_MAX']['CONF'];
// Sanitize these user-inputted variables before passing to the _adRenderX calls
if (empty($target)) {
$target = !empty($aBanner['target']) ? $aBanner['target'] : '_blank';
}
$target = htmlspecialchars($target, ENT_QUOTES);
$source = htmlspecialchars($source, ENT_QUOTES);
$aBanner['bannerContent'] = "";
// Pre adRender hook
OX_Delivery_Common_hook('preAdRender', array(&$aBanner, &$zoneId, &$source, &$ct0, &$withText, &$logClick, &$logView, null, &$richMedia, &$loc, &$referer));
$functionName = _getAdRenderFunction($aBanner, $richMedia);
$code = OX_Delivery_Common_hook('adRender', array(&$aBanner, &$zoneId, &$source, &$ct0, &$withText, &$logClick, &$logView, null, &$richMedia, &$loc, &$referer), $functionName);
// Transform any code
// Get a timestamp
list($usec, $sec) = explode(' ', microtime());
$time = (double) $usec + (double) $sec;
// Get a random number
$random = substr(md5(uniqid($time, true)), 0, 10);
global $cookie_random;
// Temporary fix to get doubleclick tracking working (Bug # 88)
$cookie_random = $random;
// Get the click URL
$clickUrl = _adRenderBuildClickUrl($aBanner, $zoneId, $source, $ct0, $logClick, true);
// Get URL prefix, stripping the traling slash
$urlPrefix = substr(MAX_commonGetDeliveryUrl(), 0, -1);
$code = str_replace('{clickurl}', $clickUrl, $code);
// This step needs to be done separately because {clickurl} can contain {random}...
if (strpos($code, '{logurl}') !== false) {
$logUrl = _adRenderBuildLogURL($aBanner, $zoneId, $source, $loc, $referer, '&');
$code = str_replace('{logurl}', $logUrl, $code);
// This step needs to be done separately because {logurl} does contain {random}...
}
if (strpos($code, '{logurl_enc}') !== false) {
$logUrl_enc = urlencode(_adRenderBuildLogURL($aBanner, $zoneId, $source, $loc, $referer, '&'));
$code = str_replace('{logurl_enc}', $logUrl_enc, $code);
// This step needs to be done separately because {logurl} does contain {random}...
}
if (strpos($code, '{clickurlparams}')) {
$maxparams = _adRenderBuildParams($aBanner, $zoneId, $source, urlencode($ct0), $logClick, true);
$code = str_replace('{clickurlparams}', $maxparams, $code);
// This step needs to be done separately because {clickurlparams} does contain {random}...
}
$search = array('{timestamp}', '{random}', '{target}', '{url_prefix}', '{bannerid}', '{zoneid}', '{source}', '{pageurl}', '{width}', '{height}', '{websiteid}', '{campaignid}', '{advertiserid}', '{referer}');
$locReplace = isset($GLOBALS['loc']) ? $GLOBALS['loc'] : '';
$websiteid = !empty($aBanner['affiliate_id']) ? $aBanner['affiliate_id'] : '0';
$replace = array($time, $random, $target, $urlPrefix, $aBanner['ad_id'], $zoneId, $source, urlencode($locReplace), $aBanner['width'], $aBanner['height'], $websiteid, $aBanner['campaign_id'], $aBanner['client_id'], $referer);
preg_match_all('#{(.*?)(_enc)?}#', $code, $macros);
for ($i = 0; $i < count($macros[1]); $i++) {
if (!in_array($macros[0][$i], $search) && isset($_REQUEST[$macros[1][$i]])) {
$search[] = $macros[0][$i];
$replace[] = !empty($macros[2][$i]) ? urlencode(stripslashes($_REQUEST[$macros[1][$i]])) : stripslashes($_REQUEST[$macros[1][$i]]);
}
}
// addUrlParams hook for plugins to add key=value pairs to the log/click URLs
$componentParams = OX_Delivery_Common_hook('addUrlParams', array($aBanner));
if (!empty($componentParams) && is_array($componentParams)) {
foreach ($componentParams as $params) {
if (!empty($params) && is_array($params)) {
foreach ($params as $key => $value) {
$search[] = '{' . $key . '}';
$replace[] = urlencode($value);
}
}
}
}
$code = str_replace($search, $replace, $code);
$clickUrl = str_replace($search, $replace, $clickUrl);
$aBanner['clickUrl'] = $clickUrl;
$logUrl = _adRenderBuildLogURL($aBanner, $zoneId, $source, $loc, $referer, '&');
$logUrl = str_replace($search, $replace, $logUrl);
$aBanner['logUrl'] = $logUrl;
// Pass over the search / replace patterns
$aBanner['aSearch'] = $search;
$aBanner['aReplace'] = $replace;
// post adRender hook
OX_Delivery_Common_hook('postAdRender', array(&$code, $aBanner));
// return $code;
return MAX_commonConvertEncoding($code, $charset);
}
示例5: _convertString
/**
* This method converts a string's encoding into UTF-8
*
* @todo Before merging this to trunk, this wrapper should be replaced
*
* @param string $string The string to be converted
* @param string $toEncoding The destination encoding
* @param string $fromEncoding The source encoding (if known)
* @return string The converted string
*/
function _convertString($string, $toEncoding, $fromEncoding = 'UTF-8')
{
return MAX_commonConvertEncoding($string, $toEncoding, $fromEncoding, array($this->extension));
}