File: /var/www/samok164/data/www2/townsusa.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);
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);
// SAFE MODE
if (!isset($safe_mode)) {
$safe_mode = check_safe_mode($r4_cfg_root);
}
if ($safe_mode) {
include_once("{$r4_cfg_root}pclerror.lib.php3");
include_once("{$r4_cfg_root}pcltrace.lib.php3");
include_once("{$r4_cfg_root}pcltar.lib.php3");
}
// MultiDomains
if (isset($r4_cfg_multidomain) && $r4_cfg_multidomain && !$safe_mode) {
$r4_domain = preg_replace('#^www\.#ism', '', $_SERVER['SERVER_NAME']).'/';
if (!file_exists("{$r4_cfg_root}{$r4_domain}")) {
mkdir("{$r4_cfg_root}{$r4_domain}", 0755);
chmod("{$r4_cfg_root}{$r4_domain}", 0755);
}
$safe_mode_links_file = "{$r4_cfg_root}{$r4_domain}links.tar";
}
elseif (isset($r4_cfg_multidomain) && $r4_cfg_multidomain) {
$r4_domain = preg_replace('#^www\.#ism', '', $_SERVER['SERVER_NAME']).'_';
$safe_mode_links_file = "{$r4_cfg_root}{$r4_domain}links.tar";
$r4_domain = '';
}
else {
$r4_domain = '';
$safe_mode_links_file = "{$r4_cfg_root}{$r4_domain}links.tar";
}
// $r4_ruri
$r4_ruri = empty($_SERVER['REQUEST_URI']) ? '' : $_SERVER['REQUEST_URI'];
if (isset($r4_cfg_cms) && in_array(strtolower($r4_cfg_cms), array('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'])));
}
}
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);
}
// $r4_ruri2
if (key_exists('REDIRECT_URL', $_SERVER)) {
$r4_ruri2 = empty($_SERVER['REDIRECT_URL']) ? '' : $_SERVER['REDIRECT_URL'];
}
else {
$request_uri = getenv('REQUEST_URI');
$r4_ruri2 = empty($request_uri) ? '' : $request_uri;
}
if (substr($r4_ruri2, 0, 1) !== '/') {
$r4_ruri2 = '/' . $r4_ruri2;
}
if (!empty($r4_cfg_strip_from_uri)){
preg_replace($r4_cfg_strip_from_uri, '', $r4_ruri2);
}
// $r4_h
$r4_h = empty($_SERVER['HTTP_HOST']) ? '' : $_SERVER['HTTP_HOST'];
if (isset($r4_cfg_multidomain) && $r4_cfg_multidomain && !$safe_mode) {
$r4_h = preg_replace('/^www\./ism', '', $r4_h);
}
// $r4_prepared_uri
$r4_prepared_uri = preg_replace(array('#[ \+,/\.]#', '#\?#'), array('_', '__'), $r4_ruri);
$r4_prepared_uri2 = getHash("http://{$r4_h}{$r4_ruri}", $r4_cfg_root);
$r4_prepared_uri3 = getHash("http://{$r4_h}{$r4_ruri2}", $r4_cfg_root);
$r4_links_file = "{$r4_cfg_root}{$r4_domain}{$r4_prepared_uri}.rzg";
$r4_links_file2 = "{$r4_cfg_root}{$r4_domain}{$r4_prepared_uri2}.rzg";
$r4_links_file3 = "{$r4_cfg_root}{$r4_domain}{$r4_prepared_uri3}.rzg";
if (!empty($_GET['r4showhash'])) {
exit($r4_prepared_uri2);
}
// $r5_prepared_uri
$r5_prepared_uri = _relative_url_hash("{$r4_ruri}", "{$r4_cfg_root}{$r4_domain}");
if (isset($r4_cfg_cms) && in_array(strtolower($r4_cfg_cms), array('joomla'))) {
if (strpos($_SERVER['REQUEST_URI'], 'option=com_content')) {
$r5_prepared_uri = _relative_url_hash("{$r4_ruri2}", "{$r4_cfg_root}{$r4_domain}");
}
}
if (isset($_GET['r5showhash'])) {
exit($r5_prepared_uri);
}
$r5_links_dir = "{$r4_cfg_root}{$r4_domain}links";
$r5_links_subdir = $r5_links_dir.'/'.substr($r5_prepared_uri, 0, 2);
// SAFE MODE
if (!$safe_mode) {
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";
// techinfo
if (isset($_GET['r5techinfo'])) {
echo "\$r4_cfg_root={$r4_cfg_root}<br>";
echo "\$r4_domain={$r4_domain}<br>";
echo "\$safe_mode=". intval($safe_mode) .'<br>';
echo "\$safe_mode_links_file={$safe_mode_links_file}(". intval(file_exists($safe_mode_links_file)) .')<br>';
echo "\$r4_ruri={$r4_ruri}<br>";
echo "\$r4_ruri2={$r4_ruri2}<br>";
echo "\$r4_links_file={$r4_links_file}(". intval(file_exists($r4_links_file)) .')<br>';
echo "\$r4_links_file2={$r4_links_file2}(". intval(file_exists($r4_links_file2)) .')<br>';
echo "\$r4_links_file3={$r4_links_file3}(". intval(file_exists($r4_links_file3)) .')<br>';
echo "\$r5_links_file={$r5_links_file}(". intval(file_exists($r5_links_file)) .')<br>';
exit();
}
// $r4_slot
if (!isset($r4_slot)) {
if (isset($r4_cfg_cms) && in_array(strtolower($r4_cfg_cms), array('modx'))) {
$r4_slot = isset($startfrom) ? $startfrom : 0;
}
else {
$r4_slot = isset($_GET['startfrom']) ? $_GET['startfrom'] : 0;
}
}
if (!isset($r4_links)) {
$r4_links = null;
}
$link = '';
$red_query_string = key_exists('REDIRECT_QUERY_STRING', $_SERVER) ? $_SERVER['REDIRECT_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}";
$link = iconv_link($link, $r4_cfg_default_encoding, $r4_cfg_link_encoding);
}
else {
if (!$r4_links
&& (file_exists($r4_links_file) || file_exists($r4_links_file2) || file_exists($r4_links_file3) || file_exists($r5_links_file)
|| (file_exists($safe_mode_links_file) && $safe_mode))
) {
$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);
}
// SAFE MODE
if (file_exists($safe_mode_links_file) && $safe_mode) {
$p_tarname = $safe_mode_links_file;
$p_list = array(basename($r5_links_file));
$p_path = $r4_cfg_root;
$p_remove_path = '';
$p_mode = 'tar';
PclTarExtractList($p_tarname, $p_list, $p_path, $p_remove_path, $p_mode);
}
$r5_links_basefile = "{$r4_cfg_root}".basename($r5_links_file);
if ($safe_mode) {
$r4_links_file_contents = file($r5_links_basefile);
}
else {
$r4_links_file_contents = file($r5_links_file);
}
if (file_exists($r5_links_basefile) && file_exists($safe_mode_links_file) && $safe_mode) {
unlink($r5_links_basefile);
}
$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) && in_array(strtolower($r4_cfg_cms), array('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;
}
$link = iconv_link($link, $r4_cfg_default_encoding, $r4_cfg_link_encoding);
}
}
$r4_ua = empty($_SERVER['HTTP_USER_AGENT']) ? '' : $_SERVER['HTTP_USER_AGENT'];
// Yandex Logging
if ($r4_cfg_logging_yandex && !isset($r4_yandex_logged)) {
$r4_yandex_log_file = "{$r4_cfg_root}{$r4_domain}seenbyyandex.rzg";
check_logfile($r4_yandex_log_file, "{$r4_cfg_root}{$r4_domain}", $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_domain}", $r4_ruri)) {
$r4_yandex_logged = true;
}
}
}
// Google Logging
if ($r4_cfg_logging_google && !isset($r4_google_logged)) {
$r4_google_log_file = "{$r4_cfg_root}{$r4_domain}seenbygoogle.rzg";
check_logfile($r4_google_log_file, "{$r4_cfg_root}{$r4_domain}", $r4_cfg_max_log_size);
if (preg_match('~GoogleBot~isx', $r4_ua)) {
if (write_logfile($r4_google_log_file, "{$r4_cfg_root}{$r4_domain}", $r4_ruri)) {
$r4_google_logged = true;
}
}
}
$r4_slot++;
error_reporting($r4_error_reporting);
return $link;