/home/suroeste/public_html/gorbus.transportessuroeste.com/suroeste/_lib/prod/lib/php
Edit: /home/suroeste/public_html/gorbus.transportessuroeste.com/suroeste/_lib/prod/lib/php/nm_utf8.php (21320B)
128){
if(($c >= 254)) return false;
elseif($c >= 252) $bits=6;
elseif($c >= 248) $bits=5;
elseif($c >= 240) $bits=4;
elseif($c >= 224) $bits=3;
elseif($c >= 192) $bits=2;
else return false;
if(($i+$bits) > $len) return false;
while($bits > 1){
$i++;
$b=ord($str[$i]);
if($b < 128 || $b > 191) return false;
$bits--;
}
}
}
return true;
}
function NM_utf8_strlen($str)
{
if (NM_is_utf8($str))
{
$c = strlen($str);
$l = 0;
for ($i = 0; $i < $c; ++$i)
if ((ord($str[$i]) & 0xC0) != 0x80)
++$l;
return $l;
}
else
{
return strlen($str);
}
}
function NM_utf8_urldecode($str)
{
global $SC_arr_charset_sajax;
if (is_array($str))
{
return $str;
}
$aRep = array(
'&' => '&',
'<' => '<',
'>' => '>',
'"' => '"',
"'" => ''',
'+' => ',',
'�' => 'Á',
'�' => 'á',
'�' => 'Â',
'�' => 'â',
'�' => 'À',
'�' => 'à',
'�' => 'Å',
'�' => 'å',
'�' => 'Ã',
'�' => 'ã',
'�' => 'Ä',
'�' => 'ä',
'�' => '&Aelig;',
'�' => 'æ',
'�' => 'Ç',
'�' => 'ç',
'�' => 'É',
'�' => 'é',
'�' => 'Ê',
'�' => 'ê',
'�' => 'È',
'�' => 'è',
'�' => 'Ë',
'�' => 'ë',
'�' => 'Í',
'�' => 'í',
'�' => 'Î',
'�' => 'î',
'�' => 'Ì',
'�' => 'ì',
'�' => 'Ï',
'�' => 'ï',
'�' => 'Ñ',
'�' => 'ñ',
'�' => 'Ó',
'�' => 'ó',
'�' => 'Ô',
'�' => 'ô',
'�' => 'Ò',
'�' => 'ò',
'�' => 'Õ',
'�' => 'õ',
'�' => 'Ö',
'�' => 'ö',
'�' => 'Ú',
'�' => 'ú',
'�' => 'Û',
'�' => 'û',
'�' => 'Ù',
'�' => 'ù',
'�' => 'Ü',
'�' => 'ü',
'�' => '¨',
'�' => '¸',
'�' => '´',
'�' => '¡',
'�' => '¿',
'�' => '·',
'�' => '€',
'�' => '¢',
'�' => '£',
'�' => '¤',
'�' => '¥',
'�' => '§',
'�' => '©',
'�' => '®',
'�' => '°',
'�' => 'ª',
'�' => 'º',
'�' => '¹',
'�' => '²',
'�' => '³',
'�' => '¼',
'�' => '½',
'�' => '¾',
'�' => '«',
'�' => '»',
'�' => '¬',
'�' => '±',
'�' => 'µ',
'�' => '¶',
' ' => ' ',
'�' => '%u201C',
'�' => '%u201D',
'�' => '%u2018',
'�' => '%u2019',
);
$str = str_replace(array_values($aRep), array_keys($aRep), $str);
if (isset($_SESSION['scriptcase']['charset']) && 'UTF-8' == $_SESSION['scriptcase']['charset'])
{
$str = sc_convert_encoding($str, 'UTF-8', $_SESSION['scriptcase']['charset']);
}
elseif (isset($_SESSION['scriptcase']['charset']) && in_array($_SESSION['scriptcase']['charset'], $SC_arr_charset_sajax) && function_exists('mb_detect_encoding') && 'UTF-8' == mb_detect_encoding($str))
{
$str = sc_convert_encoding($str, $_SESSION['scriptcase']['charset'], 'UTF-8');
}
$str = str_replace('+', '__SC_PLUS__', $str);
$str = preg_replace("/%u([0-9a-f]{3,4})/i", "\\1;", urldecode($str));
$str = str_replace('__SC_PLUS__', '+', $str);
/*
if (isset($_SESSION['scriptcase']['charset']) && 'BIG-5' == $_SESSION['scriptcase']['charset'])
{
$str = @html_entity_decode($str, null, 'BIG5');
}
else
{
$str = @html_entity_decode($str, null, $_SESSION['scriptcase']['charset']);
}
*/
$str = sc_html_entity_decode($str);
$str = NM_charset_decode($str);
return NM_unprotect_chars($str);
}
function NM_charset_to_utf8($str)
{
if ('UTF-8' != $_SESSION['scriptcase']['charset'])
{
$str = sc_convert_encoding($str, 'UTF-8', $_SESSION['scriptcase']['charset']);
}
return $str;
}
function NM_unprotect_chars($str)
{
return str_replace(
array(
'__NM_PLUS__',
'__NM_PERC__',
),
array(
'+',
'%',
),
$str);
}
function NM_charset_decode($str)
{
if ('UTF-8' != $_SESSION['scriptcase']['charset'])
{
$str = sc_convert_encoding($str, 'UTF-8', $_SESSION['scriptcase']['charset']);
$str = @html_entity_decode($str, null, 'UTF-8');
$str = sc_convert_encoding($str, $_SESSION['scriptcase']['charset'], 'UTF-8');
}
return $str;
}
function NM_utf8_decode($str)
{
if (NM_is_utf8($str))
{
$str = utf8_decode($str);
}
return $str;
}
function NM_encode_input($str)
{
if ($str === null) {
return $str;
}
$aRep = array(
';' => ';',
'<' => '<',
'>' => '>',
'"' => '"',
''' => "'",
'(' => '(',
')' => ')',
);
$str = str_replace('
', '__SC_BREAK_LINE__', $str);
$str = str_replace('
', '__SC_BREAK_LINE__', $str);
$str = str_replace(' ', '__SC_SPACE_CHAR__', $str);
$str = str_replace('&', '__SC_AMP_CHAR__', $str);
$str = str_replace(array_values($aRep), array_keys($aRep), $str);
$str = str_replace('__SC_AMP_CHAR__', '&', $str);
$str = str_replace('__SC_BREAK_LINE__', '
', $str);
$str = str_replace('__SC_SPACE_CHAR__', ' ', $str);
return $str;
}
function NM_encode_input_js($str)
{
$aRep = array(
"\'" => "'",
);
$str = str_replace(array_values($aRep), array_keys($aRep), $str);
return $str;
}
function NM_decode_input($str)
{
if ($str === null) {
return $str;
}
$aRep = array(
'&' => '&',
'<' => '<',
'>' => '>',
'"' => '"',
"'" => ''',
"'" => ''',
"(" => '(',
")" => ')',
);
$str = str_replace(array_values($aRep), array_keys($aRep), $str);
return $str;
}
function NM_protect_string($sString)
{
$sString = (string) $sString;
if (!empty($sString))
{
if (function_exists('NM_is_utf8') && NM_is_utf8($sString))
{
return $sString;
}
else
{
/* return htmlentities($sString, ENT_COMPAT, $_SESSION['scriptcase']['charset']); */
return sc_htmlentities($sString);
}
}
elseif ('0' === $sString || 0 === $sString)
{
return '0';
}
else
{
return '';
}
}
function NM_conv_charset($val, $charset_new, $charset_old)
{
if (is_array($val))
{
$temp = array();
foreach ($val as $ind => $new)
{
$ind = NM_conv_charset($ind, $charset_new, $charset_old);
$temp[$ind] = NM_conv_charset($new, $charset_new, $charset_old);
}
return $temp;
}
else
{
return sc_convert_encoding($val, $charset_new, $charset_old);
}
}
function sc_strip_tags($sHtmlStrip, $sCharset = '')
{
$sHtmlFull = '';
while ($sHtmlFull != $sHtmlStrip) {
$sHtmlFull = $sHtmlStrip;
$sHtmlStrip = strip_tags($sHtmlFull);
}
return $sHtmlStrip;
}
function sc_strip_script($sHtmlStrip, $sCharset = '')
{
$sHtmlFull = '';
while ($sHtmlFull != $sHtmlStrip) {
$sHtmlFull = $sHtmlStrip;
$sHtmlStrip = preg_replace('##is', '', $sHtmlFull);
}
return $sHtmlStrip;
}
/*--- mantis 0019352 ---*/
function sc_sql_escape($db, $arg)
{
$_SESSION['sc_session']['sc_sql_escape'] = "";
$nm_bases_access = array("access", "ado_access", "ace_access");
$nm_bases_db2 = array("db2", "db2_odbc", "odbc_db2", "odbc_db2v6", "pdo_db2_odbc", "pdo_ibm");
$nm_bases_ibase = array("ibase", "firebird", "pdo_firebird", "borland_ibase");
$nm_bases_informix = array("informix", "informix72", "pdo_informix");
$nm_bases_mysql = array("mysql", "mysqlt", "mysqli", "maxsql", "pdo_mysql", "azure_mysql", "azure_mysqlt", "azure_mysqli", "azure_maxsql", "azure_pdo_mysql", "googlecloud_mysql", "googlecloud_mysqlt", "googlecloud_mysqli", "googlecloud_maxsql", "googlecloud_pdo_mysql", "amazonrds_mysql", "amazonrds_mysqlt", "amazonrds_mysqli", "amazonrds_maxsql", "amazonrds_pdo_mysql");
$nm_bases_sybase = array("sybase", "pdo_sybase_odbc", "pdo_sybase_dblib");
$nm_bases_vfp = array("vfp");
$nm_bases_progress = array("pdo_progress_odbc", "progress");
$nm_bases_postgres = array("postgres", "postgres64", "postgres7", "pdo_pgsql", "azure_postgres", "azure_postgres64", "azure_postgres7", "azure_pdo_pgsql", "googlecloud_postgres", "googlecloud_postgres64", "googlecloud_postgres7", "googlecloud_pdo_pgsql", "amazonrds_postgres", "amazonrds_postgres64", "amazonrds_postgres7", "amazonrds_pdo_pgsql");
$nm_bases_oracle = array("oci8", "oci805", "oci8po", "odbc_oracle", "oracle", "pdo_oracle", "oraclecloud_oci8", "oraclecloud_oci805", "oraclecloud_oci8po", "oraclecloud_odbc_oracle", "oraclecloud_oracle", "oraclecloud_pdo_oracle", "amazonrds_oci8", "amazonrds_oci805", "amazonrds_oci8po", "amazonrds_odbc_oracle", "amazonrds_oracle", "amazonrds_pdo_oracle");
$nm_bases_sqlite = array("sqlite", "sqlite3", "pdosqlite");
$nm_bases_odbc = array("odbc");
$nm_bases_mssql = array("mssql", "ado_mssql", "adooledb_mssql", "odbc_mssql", "mssqlnative", "pdo_sqlsrv", "pdo_dblib", "azure_mssql", "azure_ado_mssql", "azure_adooledb_mssql", "azure_odbc_mssql", "azure_mssqlnative", "azure_pdo_sqlsrv", "azure_pdo_dblib", "googlecloud_mssql", "googlecloud_ado_mssql", "googlecloud_adooledb_mssql", "googlecloud_odbc_mssql", "googlecloud_mssqlnative", "googlecloud_pdo_sqlsrv", "googlecloud_pdo_dblib", "amazonrds_mssql", "amazonrds_ado_mssql", "amazonrds_adooledb_mssql", "amazonrds_odbc_mssql", "amazonrds_mssqlnative", "amazonrds_pdo_sqlsrv", "amazonrds_pdo_dblib");
if (strpos($arg, "_") !== false) {
if (in_array(strtolower($db), $nm_bases_mssql) || in_array(strtolower($db), $nm_bases_access)) {
$arg = str_replace('_', '[_]', $arg);
}
if (in_array(strtolower($db), $nm_bases_mysql) || in_array(strtolower($db), $nm_bases_vfp) || in_array(strtolower($db), $nm_bases_progress)) {
$arg = str_replace('_', '\\\\_', $arg);
$_SESSION['sc_session']['sc_sql_escape'] = " ESCAPE '\\\\'";
}
if (in_array(strtolower($db), $nm_bases_postgres) || in_array(strtolower($db), $nm_bases_oracle) || in_array(strtolower($db), $nm_bases_sybase) || in_array(strtolower($db), $nm_bases_sqlite) ||
in_array(strtolower($db), $nm_bases_db2) || in_array(strtolower($db), $nm_bases_informix) || in_array(strtolower($db), $nm_bases_ibase)) {
$arg = str_replace('_', '\_', $arg);
$_SESSION['sc_session']['sc_sql_escape'] = " ESCAPE '\\'";
}
}
return $arg;
}
/*------*/
?>