v.2.30
Добавлен расширенный отчет по реализации Добавлен монитор активности
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Component\Models;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class Base
|
||||
{
|
||||
public static function tofloat($num) {
|
||||
@@ -70,4 +72,90 @@ class Base
|
||||
// everything is OK
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function data_decode($data)
|
||||
{
|
||||
$alph = [
|
||||
"А", "Б", "В", "Г", "Д",
|
||||
"Е", "Ё", "Ж", "З", "И",
|
||||
"Й", "К", "Л", "М", "Н",
|
||||
"О", "П", "Р", "С", "Т",
|
||||
"У", "Ф", "Х", "Ц", "Ч",
|
||||
"Ш", "Щ", "Ъ", "Ы", "Ь",
|
||||
"Э", "Ю", "Я",
|
||||
"а", "б", "в", "г", "д",
|
||||
"е", "ё", "ж", "з", "и",
|
||||
"й", "к", "л", "м", "н",
|
||||
"о", "п", "р", "с", "т",
|
||||
"у", "ф", "х", "ц", "ч",
|
||||
"ш", "щ", "ъ", "ы", "ь",
|
||||
"э", "ю", "я",
|
||||
];
|
||||
|
||||
foreach ($alph as $key => $letter) {
|
||||
$haystack = mb_convert_encoding($data, "CP1251", "UTF-8");
|
||||
$needle = $letter;
|
||||
$pos = strripos($haystack, $needle);
|
||||
if ($pos === false) {
|
||||
$after_conv = false;
|
||||
} else {
|
||||
$after_conv = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$after_conv) {
|
||||
foreach ($alph as $key => $letter) {
|
||||
$haystack = $data;
|
||||
$needle = $letter;
|
||||
$pos = strripos($haystack, $needle);
|
||||
if ($pos === false) {
|
||||
$before_conv = false;
|
||||
} else {
|
||||
$before_conv = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($after_conv) {
|
||||
$retval = mb_convert_encoding($data, "CP1251", "UTF-8");
|
||||
} elseif ($before_conv) {
|
||||
$retval = $data;
|
||||
} else {
|
||||
$retval = $data;
|
||||
}
|
||||
return $retval;
|
||||
}
|
||||
|
||||
public static function customBase64Decode($data) {
|
||||
$base64 = $data;
|
||||
$base64 = str_replace(array('\r\n', '\r', '\n'), '', $base64);
|
||||
$base64 = str_replace(' ', '', $base64);
|
||||
$decoded = base64_decode($base64);
|
||||
$decoded = mb_convert_encoding($decoded, 'UTF-8');
|
||||
log::debug(self::ascii2hex($decoded));
|
||||
|
||||
|
||||
return $decoded;
|
||||
}
|
||||
|
||||
public static function ascii2hex($ascii) {
|
||||
$hex = '';
|
||||
for ($i = 0; $i < strlen($ascii); $i++) {
|
||||
$byte = strtoupper(dechex(ord($ascii{$i})));
|
||||
$byte = str_repeat('0', 2 - strlen($byte)).$byte;
|
||||
$hex.=$byte." ";
|
||||
}
|
||||
return $hex;
|
||||
}
|
||||
|
||||
public static function in_array_r($needle, $haystack, $strict = false) {
|
||||
foreach ($haystack as $item) {
|
||||
if (($strict ? $item === $needle : $item == $needle) || (is_array($item) && self::in_array_r($needle, $item, $strict))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user