HEX
Server: Apache/2.4.6 (CloudLinux) OpenSSL/1.0.2k-fips mod_fcgid/2.3.9 PHP/5.4.16
System: Linux s1.gigspace.ru 3.10.0-962.3.2.lve1.5.77.el7.x86_64 #1 SMP Mon Dec 12 07:06:14 EST 2022 x86_64
User: samok164 (6070)
PHP: 7.2.34
Disabled: NONE
Upload Files
File: /var/www/samok164/data/www2/mirneboskrebov.ru/rzgn/razgon2006return.php
<?php #r4 v3.0

    $r4_cfg_root = dirname(__FILE__);
    $r4_cfg_root .= '/';
    $r4_cfg_root = preg_replace('|([/]+)|is', '/', $r4_cfg_root);

    if (!empty($_GET['r4getVersion'])) {
        exit(file_get_contents("{$r4_cfg_root}r4_version"));
    }

    include("{$r4_cfg_root}r4_vars.php");

    include_once("{$r4_cfg_root}r4_libs.php");
    include_once("{$r4_cfg_root}r4_getHash.php");

    $r4_error_reporting = error_reporting($r4_cfg_error_reporting);

    $r4_ua = empty($_SERVER['HTTP_USER_AGENT']) ? '' : $_SERVER['HTTP_USER_AGENT'];
    $r4_ruri = empty($_SERVER['REQUEST_URI']) ? '' : $_SERVER['REQUEST_URI'];

    // Для Webasyst и некоторых на Joomla
    if (strpos($_SERVER["QUERY_STRING"], '__furl_path') && strpos($_SERVER["QUERY_STRING"], 'frontend')) {
        $r4_ruri  = '/'.str_replace('&', '?', str_replace('__furl_path=', '', str_replace('&frontend=1', '', $_SERVER["QUERY_STRING"])));
    }

    $r4_h = empty($_SERVER['HTTP_HOST']) ? '' : $_SERVER['HTTP_HOST'];

    // Для сайтов OZPP
    if (isset($r4_cfg_cms) && strtolower($r4_cfg_cms) === 'ozpp') {
        $r4_h = preg_replace('#^www\.#ism', '', $r4_h);

        $domain = $_SERVER['SERVER_NAME'];
        $domain = preg_replace('#^www\.#ism', '', $domain);

        $r4_cfg_root = "{$r4_cfg_root}{$domain}/";

        if (!file_exists($r4_cfg_root)) {
            @mkdir($r4_cfg_root);
        }

        $f = fopen("{$r4_cfg_root}r4_knownparams.list", 'w');

        if ($f) {
            if(fwrite($f, '') == -1) {
                die('fwrite error');
            }
            fclose($f);
            @chmod("{$r4_cfg_root}r4_knownparams.list", 0777);
        }
        else {
            die('fopen error');
        }
    }

    // Для сайтов с "лишним слешом"
    if (substr($r4_ruri, 0, 1) !== '/') {
        $r4_ruri = '/'.$r4_ruri;
    }

    if (!empty($r4_cfg_strip_from_uri)) {
        preg_replace($r4_cfg_strip_from_uri, '', $r4_ruri);
    }

    // Для сайтов с редиректом
    if (key_exists('REDIRECT_URL', $_SERVER)) {
        $r4_ruri2 = empty($_SERVER['REDIRECT_URL']) ? '' : $_SERVER['REDIRECT_URL']; // для REDIRECT_URL
    }
    else {
        $getenv = getenv('REQUEST_URI');
        $r4_ruri2 = empty($getenv) ? '' : $getenv;
    }

    if (!empty($r4_cfg_strip_from_uri)){
        preg_replace($r4_cfg_strip_from_uri, '', $r4_ruri2);
    }

    $r4_prepared_uri = preg_replace(array('#[ \+,/\.]#', '#\?#'), array('_', '__'), $r4_ruri);
    $r4_prepared_uri2 = getHash("http://{$r4_h}{$r4_ruri}", $r4_cfg_root);  // для REQUEST_URI
    $r4_prepared_uri3 = getHash("http://{$r4_h}{$r4_ruri2}", $r4_cfg_root); // для REDIRECT_URL

    $r4_links_file = "{$r4_cfg_root}{$r4_prepared_uri}.rzg";
    $r4_links_file2 = "{$r4_cfg_root}{$r4_prepared_uri2}.rzg";
    $r4_links_file3 = "{$r4_cfg_root}{$r4_prepared_uri3}.rzg";

    if (!empty($_GET['r4showhash'])) {
        exit($r4_prepared_uri2);
    }

    if (isset($_GET['r5_show_links_files'])) {
        $r4_ruri = preg_replace('/r5_show_links_files(=[^&]*)?/', '', $r4_ruri);
    }

    if (isset($_GET['r5showhash'])) {
        $r4_ruri = preg_replace('/r5showhash(=[^&]*)?/', '', $r4_ruri);
    }

    $r5_prepared_uri = _relative_url_hash("{$r4_ruri}", $r4_cfg_root);

    if (isset($_GET['r5showhash'])) {
        exit($r5_prepared_uri);
    }

    $r5_links_dir = "{$r4_cfg_root}links/";
    $r5_links_subdir = $r5_links_dir . substr($r5_prepared_uri, 0, 2);
    if (!file_exists($r5_links_dir)) {
        @mkdir($r5_links_dir, 0777);
        @chmod($r5_links_dir, 0777);
    }
    if (!file_exists($r5_links_subdir) && file_exists($r5_links_dir)) {
        @mkdir($r5_links_subdir, 0777);
        @chmod($r5_links_subdir, 0777);
    }
    $r5_prepared_uri = "{$r5_links_subdir}/{$r5_prepared_uri}";
    $r5_links_file = "{$r5_prepared_uri}.rzg";

    if (isset($_GET['r5_show_links_files'])) {
        echo '$r5_links_file='.$r5_links_file.'('.(file_exists($r5_links_file) + 0).')<br>';
        echo '$r4_links_file='.$r4_links_file.'('.(file_exists($r4_links_file) + 0).')<br>';
        echo '$r4_links_file2='.$r4_links_file2.'('.(file_exists($r4_links_file2) + 0).')<br>';
        echo '$r4_links_file3='.$r4_links_file3.'('.(file_exists($r4_links_file3) + 0).')<br>';

        exit();
    }

    if (!isset($r4_slot)) {
        if (isset($r4_cfg_cms) && strtolower($r4_cfg_cms) === 'modx') {
            $r4_slot = isset($startfrom) ? $startfrom : 0;
        }
        else {
            $r4_slot = isset($_GET['startfrom']) ? $_GET['startfrom'] : 0;
        }
    }

    if (!isset($r4_links)) {
        $r4_links = null;
    }

    $link = '';

    if (key_exists('REDIRECT_QUERY_STRING', $_SERVER)) {
        $red_query_string = $_SERVER['REDIRECT_QUERY_STRING'];
    }
    else {
        $red_query_string = '';
    }

    if (false !== strpos($r4_ruri, $r4_cfg_testpattern) || false !== strpos($r4_ruri2, $r4_cfg_testpattern) || !empty($_GET[str_replace('?', '', $r4_cfg_testpattern)]) ||
            false !== strpos($_SERVER['QUERY_STRING'], $r4_cfg_testpattern) || false !== strpos($red_query_string, str_replace('?', '', $r4_cfg_testpattern))) {

        $link = "<a href=\"#\" class=\"[[R4_2_PLACEHOLDER]]\">{$r4_cfg_testtext}</a>{$r4_cfg_separator}";

        if (function_exists('iconv')) {
            if (!isset($r4_cfg_default_encoding)) {
                $r4_cfg_default_encoding = 'UTF-8';
            }

            if ($r4_cfg_link_encoding != $r4_cfg_default_encoding) {
                $iconv_link = iconv($r4_cfg_default_encoding, $r4_cfg_link_encoding, $link);
                $error = error_get_last();
                $error_message = isset($error['message']) ? $error['message'] : '';
                if (strpos($error_message, 'iconv') === FALSE) {
                    $link = $iconv_link;
                }
            }
        }
    }
    else {
        if (!$r4_links && (file_exists($r4_links_file) || file_exists($r4_links_file2) || file_exists($r4_links_file3) || file_exists($r5_links_file))) {
            $r4_links = array();

            if (file_exists($r4_links_file) && !file_exists($r4_links_file2)) {
                rename($r4_links_file, $r4_links_file2);
            }

            if (file_exists($r4_links_file2) && !file_exists($r4_links_file3)) {
                rename($r4_links_file2, $r4_links_file3);
            }

            if (file_exists($r4_links_file3) && !file_exists($r5_links_file)) {
                rename($r4_links_file3, $r5_links_file);
            }

            $r4_links_file_contents = file($r5_links_file);

            $r4_info_str = trim(array_shift($r4_links_file_contents));

            $r4_info_fields = explode('|', $r4_info_str);

            $r4_cell_config = array();

            if (isset($r4_info_fields[1])) {
                $r4_cell_config = unserialize($r4_info_fields[1]);
            }

            foreach ($r4_links_file_contents as $r4_line) {
                $r4_line = trim($r4_line);

                if (!empty($r4_line)) {
                    $r4_links[] = $r4_line;
                }
            }
        }

        $r4_lindex = $r4_slot;

        if (!empty($r4_cell_config)) {
            $r4_lindex = array_search($r4_slot, $r4_cell_config);
        }

        if ($r4_lindex !== false && !empty($r4_links[$r4_lindex])) {
            if (isset($r4_cfg_cms) && strtolower($r4_cfg_cms) === 'yandex') {
                $link_yd = explode('<', $r4_links[$r4_lindex]);
                $link_dom = explode('">', $link_yd[1]);
                $link_text = explode('>', $link_yd[2]);
                $link_dom2 = explode('="', $link_dom[0]);

                $link = '<span style="color:#4444DA;">'.$link_yd[0].'</span><br>';
                $link .= '<'.$link_yd[1].'</a>';
                $link .= $link_text[1].'<br>';

                $matches = array();
                preg_match("/^(http:\/\/)?([^\/]+)/i", $link_dom2[1], $matches); // Извлекаем имя хоста из URL

                $link .= '<span style="color:#177317;" >'.$matches[2].'</span>';
                $link .= '<br><br>';
            }
            else {
                $link = $r4_links[$r4_lindex] . $r4_cfg_separator;
            }

            if (function_exists('iconv')) {
                if (!isset($r4_cfg_default_encoding)) {
                    $r4_cfg_default_encoding = 'UTF-8';
                }

                if ($r4_cfg_link_encoding != $r4_cfg_default_encoding) {
                    $iconv_link = iconv($r4_cfg_default_encoding, $r4_cfg_link_encoding, $link);
                    $error = error_get_last();
                    $error_message = isset($error['message']) ? $error['message'] : '';
                    if (strpos($error_message, 'iconv') === FALSE) {
                        $link = $iconv_link;
                    }
                }
            }
        }
    }


    /*
     * Yandex Logging
     */
    if ($r4_cfg_logging_yandex && !isset($r4_yandex_logged)) {
        $r4_yandex_log_file = "{$r4_cfg_root}seenbyyandex.rzg";

        check_logfile($r4_yandex_log_file, $r4_cfg_root, $r4_cfg_max_log_size);

        if (preg_match('~Yandex(Bot|Direct)/3\.0;\s+\+http~isx', $r4_ua)) {
            if (write_logfile($r4_yandex_log_file, $r4_cfg_root, $r4_ruri)) {
                $r4_yandex_logged = true;
            }
        }
    }


    /*
     * Google Logging
     */
    if ($r4_cfg_logging_google && !isset($r4_google_logged)) {
        $r4_google_log_file = "{$r4_cfg_root}seenbygoogle.rzg";

        check_logfile($r4_google_log_file, $r4_cfg_root, $r4_cfg_max_log_size);

        if (preg_match('~GoogleBot~isx', $r4_ua)) {
            if (write_logfile($r4_google_log_file, $r4_cfg_root, $r4_ruri)) {
                $r4_google_logged = true;
            }
        }
    }


    $r4_slot++;

    return $link;

    error_reporting($r4_error_reporting);
?>