| Server IP : 195.130.67.5 / Your IP : 216.73.217.154 Web Server : Microsoft-IIS/10.0 System : Windows NT WEBSERVER1 10.0 build 17763 (Windows Server 2016) i586 User : IUSR ( 0) PHP Version : 7.4.19 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /Old Sites/rescommittee/modules/mod_aridatatables/includes/kernel/String/ |
Upload File : |
<?php
/*
* ARI Framework Lite
*
* @package ARI Framework Lite
* @version 1.0.0
* @author ARI Soft
* @copyright Copyright (c) 2009 www.ari-soft.com. All rights reserved
* @license GNU/GPL (http://www.gnu.org/copyleft/gpl.html)
*
*/
defined('ARI_FRAMEWORK_LOADED') or die('Direct Access to this location is not allowed.');
if (J3_4)
{
jimport('vendor.joomla.string.src.phputf8.utf8');
jimport('vendor.joomla.string.src.phputf8.utils.unicode');
jimport('vendor.joomla.string.src.phputf8.utils.validation');
jimport('vendor.joomla.string.src.phputf8.strcasecmp');
jimport('vendor.joomla.string.src.phputf8.str_ireplace');
}
else
{
jimport('phputf8.utf8');
jimport('phputf8.utils.unicode');
jimport('phputf8.utils.validation');
jimport('phputf8.strcasecmp');
jimport('phputf8.str_ireplace');
}
require_once dirname(__FILE__) . DS . 'convertTable.php';
class AriString
{
public static function strToHex($data)
{
return array_shift(unpack('H*', $data));
}
public static function hexToStr($data)
{
$data = str_replace(' ', '', $data);
$data = str_replace('\x', '', $data);
return pack('H*', $data);
}
public static function stripslashes($value)
{
$ret = '';
if (is_string($value))
{
$ret = stripslashes($value);
}
else
{
if (is_array($value))
{
$ret = array();
foreach ($value as $key => $val)
{
$ret[$key] = self::stripslashes($val);
}
}
else
{
$ret = $value;
}
}
return $ret;
}
public static function detectUTF($str)
{
return utf8_is_valid($str);
}
public static function fromHtmlEntitiesToUTF($str)
{
if ($str)
{
$str = html_entity_decode($str, ENT_QUOTES, 'UTF-8');
$isUtf = self::detectUTF($str);
$str = preg_replace_callback('/&#([0-9]+);/' . ($isUtf ? 'u' : ''), function($matches) { return AriString::_uniChr($matches[1]); }, $str);
$str = preg_replace_callback('/&#x([a-f0-9]+);/mi' . ($isUtf ? 'u' : ''), function($matches) { return AriString::_uniChr(intval('0x' . $matches[1], 0)); }, $str);
}
return $str;
}
public static function toUTFHtmlEntities($str)
{
$unicode = utf8_to_unicode($str);
$retStr = '';
$cnt = count($unicode);
for ($i = 0; $i < $cnt; $i++)
{
$code = $unicode[$i];
$retStr .= $code < 256 ? chr($code) : '&#' . $unicode[$i] . ';';
}
return $retStr;
}
public static function translateParams($inputCharset, $outputCharset, $var, $group = null)
{
if ($var === null) return ;
$value = null;
if ($group == null)
{
$value = $var;
}
else if (isset($var[$group]) && is_array($var[$group]))
{
$value = $var[$group];
}
if ($value) self::_translateParams($inputCharset, $outputCharset, $value);
return $value;
}
public static function _translateParams($inputCharset, $outputCharset, &$value)
{
if ($value)
{
foreach ($value as $key => $val)
{
if (is_array($val))
{
self::_translateParams($inputCharset, $outputCharset, $val);
continue;
}
$value[$key] = self::translateParam($inputCharset, $outputCharset, $val);
}
}
}
public static function translateParam($inputCharset, $outputCharset, $value)
{
if ($value && $inputCharset != $outputCharset)
{
if ($outputCharset == 'UTF-8')
{
$notIconv = true;
if (function_exists('iconv'))
{
$value = @iconv($inputCharset, $outputCharset, $value);
if ($value !== false) $notIconv = false;
}
if ($notIconv)
{
$value = htmlentities($value, ENT_COMPAT, $inputCharset);
$value = self::fromHtmlEntitiesToUTF($value);
}
}
else if ($inputCharset == 'UTF-8')
{
if (self::detectUTF($value))
{
$value = self::fromHtmlEntitiesToUTF($value);
$value = self::toUTFHtmlEntities($value);
}
}
else if (function_exists('iconv'))
{
$value = iconv($inputCharset, $outputCharset, $value);
}
}
return $value;
}
static function _uniChr($c)
{
if ($c <= 0x7F)
{
return chr($c);
}
else if ($c <= 0x7FF)
{
return chr(0xC0 | $c >> 6) . chr(0x80 | $c & 0x3F);
}
else if ($c <= 0xFFFF)
{
return chr(0xE0 | $c >> 12) . chr(0x80 | $c >> 6 & 0x3F) . chr(0x80 | $c & 0x3F);
}
else if ($c <= 0x10FFFF)
{
return chr(0xF0 | $c >> 18) . chr(0x80 | $c >> 12 & 0x3F) . chr(0x80 | $c >> 6 & 0x3F) . chr(0x80 | $c & 0x3F);
}
else
{
return '';
}
}
}