HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux vgpudjuxex 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64
User: cod67 (1010)
PHP: 8.2.29
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
Upload Files
File: /var/www/cod67/data/www/cod67.ru/public_html/recode_functions.php
<?php

declare(strict_types=1);

function rus2translit(string $string): string
{
    $converter = [
        'а' => 'a',   'б' => 'b',   'в' => 'v',
        'г' => 'g',   'д' => 'd',   'е' => 'e',
        'ё' => 'e',   'ж' => 'zh',  'з' => 'z',
        'и' => 'i',   'й' => 'y',   'к' => 'k',
        'л' => 'l',   'м' => 'm',   'н' => 'n',
        'о' => 'o',   'п' => 'p',   'р' => 'r',
        'с' => 's',   'т' => 't',   'у' => 'u',
        'ф' => 'f',   'х' => 'h',   'ц' => 'c',
        'ч' => 'ch',  'ш' => 'sh',  'щ' => 'sch',
        'ь' => '',    'ы' => 'y',   'ъ' => '',
        'э' => 'e',   'ю' => 'yu',  'я' => 'ya',
        
        'А' => 'A',   'Б' => 'B',   'В' => 'V',
        'Г' => 'G',   'Д' => 'D',   'Е' => 'E',
        'Ё' => 'E',   'Ж' => 'Zh',  'З' => 'Z',
        'И' => 'I',   'Й' => 'Y',   'К' => 'K',
        'Л' => 'L',   'М' => 'M',   'Н' => 'N',
        'О' => 'O',   'П' => 'P',   'Р' => 'R',
        'С' => 'S',   'Т' => 'T',   'У' => 'U',
        'Ф' => 'F',   'Х' => 'H',   'Ц' => 'C',
        'Ч' => 'Ch',  'Ш' => 'Sh',  'Щ' => 'Sch',
        'Ь' => '',    'Ы' => 'Y',   'Ъ' => '',
        'Э' => 'E',   'Ю' => 'Yu',  'Я' => 'Ya',
    ];
    
    return strtr($string, $converter);
}

function utf2Win(string $str, string $type = "w"): string
{
    static $conv = [];
    
    if (empty($conv)) {
        $conv = ['u' => [], 'w' => []];
        
        for ($x = 128; $x <= 143; $x++) {
            $conv['u'][] = chr(209) . chr($x);
            $conv['w'][] = chr($x + 112);
        }
        
        for ($x = 144; $x <= 191; $x++) {
            $conv['u'][] = chr(208) . chr($x);
            $conv['w'][] = chr($x + 48);
        }
        
        $conv['u'][] = chr(208) . chr(129);
        $conv['w'][] = chr(168);
        $conv['u'][] = chr(209) . chr(145);
        $conv['w'][] = chr(184);
        $conv['u'][] = chr(208) . chr(135);
        $conv['w'][] = chr(175);
        $conv['u'][] = chr(209) . chr(151);
        $conv['w'][] = chr(191);
        $conv['u'][] = chr(208) . chr(134);
        $conv['w'][] = chr(178);
        $conv['u'][] = chr(209) . chr(150);
        $conv['w'][] = chr(179);
        $conv['u'][] = chr(210) . chr(144);
        $conv['w'][] = chr(165);
        $conv['u'][] = chr(210) . chr(145);
        $conv['w'][] = chr(180);
        $conv['u'][] = chr(208) . chr(132);
        $conv['w'][] = chr(170);
        $conv['u'][] = chr(209) . chr(148);
        $conv['w'][] = chr(186);
        $conv['u'][] = chr(226) . chr(132) . chr(150);
        $conv['w'][] = chr(185);
    }
    
    if ($type === 'w') {
        return str_replace($conv['u'], $conv['w'], $str);
    } elseif ($type === 'u') {
        return str_replace($conv['w'], $conv['u'], $str);
    }
    
    return $str;
}

function punicode_enc(string $stringconv): string
{
    require_once 'idna_convert.class.php';
    $IDN = new idna_convert();
    return $IDN->encode($stringconv);
}

function punicode_dec(string $stringconv): string
{
    require_once 'idna_convert.class.php';
    $IDN = new idna_convert();
    return $IDN->decode($stringconv);
}

function win2utf(string $str): string
{
    static $table = [
        "\xA8" => "\xD0\x81",
        "\xB8" => "\xD1\x91",
        "\xA1" => "\xD0\x8E",
        "\xA2" => "\xD1\x9E",
        "\xAA" => "\xD0\x84",
        "\xAF" => "\xD0\x87",
        "\xB2" => "\xD0\x86",
        "\xB3" => "\xD1\x96",
        "\xBA" => "\xD1\x94",
        "\xBF" => "\xD1\x97",
        "\x8C" => "\xD3\x90",
        "\x8D" => "\xD3\x96",
        "\x8E" => "\xD2\xAA",
        "\x8F" => "\xD3\xB2",
        "\x9C" => "\xD3\x91",
        "\x9D" => "\xD3\x97",
        "\x9E" => "\xD2\xAB",
        "\x9F" => "\xD3\xB3",
    ];
    
    // Замена устаревшего preg_replace с модификатором /e
    return preg_replace_callback(
        '#[\x80-\xFF]#',
        static function ($matches) use ($table): string {
            $char = $matches[0];
            
            if (ord($char) >= 0xF0) {
                return "\xD1" . chr(ord($char) - 0x70);
            }
            
            if (ord($char) >= 0xC0) {
                return "\xD0" . chr(ord($char) - 0x30);
            }
            
            return $table[$char] ?? "";
        },
        $str
    );
}