<?php
/*
=====================================================
 DataLife Engine - by SoftNews Media Group 
-----------------------------------------------------
 http://dle-news.ru/
-----------------------------------------------------
 Copyright (c) 2004,2010 SoftNews Media Group
=====================================================
 Данный код защищен авторскими правами
=====================================================
 Файл: index.php
-----------------------------------------------------
 Назначение: Главная страница
=====================================================
*/

function getmicrotime() { list($usec, $sec) = explode(" ",microtime()); return ((float)$usec + (float)$sec); }
GLOBAL $g_start_time;
$g_start_time = getmicrotime();

/*
if($_SERVER['HTTP_HOST'] == "hchan.live") {
    if($_COOKIE["dle_params_times22"] == 'set') {
    }
    else if($_COOKIE["dle_restore_pass22"]) {
    }
    else {
        setcookie("dle_restore_pass22", true, time()+3600 * 60 * 24 * 365);
        header('Location: http://s.hentaichan.live/loginchan');
        die();
    }
}
*/

@session_start ();
//session_regenerate_id(true);
//session_regenerate_id();
@ob_start ();
@ob_implicit_flush ( 0 );

@error_reporting ( E_ALL ^ E_WARNING ^ E_NOTICE );
@ini_set ( 'display_errors', true );
@ini_set ( 'html_errors', false );
@ini_set ( 'error_reporting', E_ALL ^ E_WARNING ^ E_NOTICE );

define ( 'DATALIFEENGINE', true );

$member_id = FALSE;
$is_logged = FALSE;

define ( 'ROOT_DIR', dirname ( __FILE__ ) );
define ( 'ENGINE_DIR', ROOT_DIR . '/engine' );

require_once ROOT_DIR . '/engine/init.php';

if (clean_url ( $_SERVER['HTTP_HOST'] ) != clean_url ( $config['http_home_url'] )) {
	
	$replace_url = array ();
	$replace_url[0] = clean_url ( $config['http_home_url'] );
	$replace_url[1] = clean_url ( $_SERVER['HTTP_HOST'] );

} else
	$replace_url = false;

////// chan mod. удаляем тупую замену ссылок
$replace_url = false;

$tpl->load_template ( 'main.tpl' );

$tpl->set ( '{calendar}', $tpl->result['calendar'] );
$tpl->set ( '{archives}', $tpl->result['archive'] );
$tpl->set ( '{tags}', $tpl->result['tags_cloud'] );
$tpl->set ( '{vote}', $tpl->result['vote'] );
$tpl->set ( '{topnews}', $topnews );
$tpl->set ( '{login}', $login_panel );
$tpl->set ( '{info}',  $tpl->result['info'] );
$tpl->set ( '{speedbar}', $tpl->result['speedbar'] );

if ($config['allow_skin_change'] == "yes") $tpl->set ( '{changeskin}', ChangeSkin ( ROOT_DIR . '/templates', $config['skin'] ) );

if (count ( $banners ) and $config['allow_banner']) {
	
	foreach ( $banners as $name => $value ) {
		$tpl->copy_template = str_replace ( "{banner_" . $name . "}", $value, $tpl->copy_template );
	}

}

$tpl->set_block ( "'{banner_(.*?)}'si", "" );

if (count ( $informers ) and $config['rss_informer']) {
	foreach ( $informers as $name => $value ) {
		$tpl->copy_template = str_replace ( "{inform_" . $name . "}", $value, $tpl->copy_template );
	}
}

if ($allow_active_news AND $config['allow_change_sort'] AND $do != "userinfo") {
	
	$tpl->set ( '[sort]', "" );
	$tpl->set ( '{sort}', news_sort ( $do ) );
	$tpl->set ( '[/sort]', "" );

} else {
	
	$tpl->set_block ( "'\\[sort\\](.*?)\\[/sort\\]'si", "" );

}

if ($dle_module == "showfull" ) {

	if (is_array($cat_list) AND count($cat_list) > 1 ) $category_id = implode(",", $cat_list);

}

if (stripos ( $tpl->copy_template, "[category=" ) !== false) {
//	$tpl->copy_template = @preg_replace ( "#\\[category=(.+?)\\](.*?)\\[/category\\]#ies", "check_category('\\1', '\\2', '{$category_id}')", $tpl->copy_template );
	GLOBAL $temppp;
	$temppp = $category_id;
	$tpl->copy_template = preg_replace_callback("#\\[category=(.+?)\\](.*?)\\[/category\\]#is", function($m) { GLOBAL $temppp; return check_category($m[1], $m[2], $temppp); }, $tpl->copy_template );
}

if (stripos ( $tpl->copy_template, "[not-category=" ) !== false) {
//	$tpl->copy_template = @preg_replace ( "#\\[not-category=(.+?)\\](.*?)\\[/not-category\\]#ies", "check_category('\\1', '\\2', '{$category_id}', false)", $tpl->copy_template );
	GLOBAL $temppp;
	$temppp = $category_id;
	$tpl->copy_template = preg_replace_callback("#\\[not-category=(.+?)\\](.*?)\\[/not-category\\]#is", function($m) { GLOBAL $temppp; return check_category($m[1], $m[2], $temppp, false); }, $tpl->copy_template );
}


if (stripos ( $tpl->copy_template, "[static=" ) !== false) {
//	$tpl->copy_template = @preg_replace ( "#\\[static=(.+?)\\](.*?)\\[/static\\]#ies", "check_static('\\1', '\\2')", $tpl->copy_template );
	$tpl->copy_template = preg_replace_callback("#\\[static=(.+?)\\](.*?)\\[/static\\]#is", function($m) { return check_static($m[1], $m[2]); }, $tpl->copy_template );
}

if (stripos ( $tpl->copy_template, "[not-static=" ) !== false) {
//	$tpl->copy_template = @preg_replace ( "#\\[not-static=(.+?)\\](.*?)\\[/not-static\\]#ies", "check_static('\\1', '\\2', false)", $tpl->copy_template );
	$tpl->copy_template = preg_replace_callback("#\\[not-static=(.+?)\\](.*?)\\[/not-static\\]#is", function($m) { return check_static($m[1], $m[2], false); }, $tpl->copy_template );
}

if (stripos ( $tpl->copy_template, "{custom" ) !== false) {
//	$tpl->copy_template = @preg_replace ( "#\\{custom category=['\"](.+?)['\"] template=['\"](.+?)['\"] aviable=['\"](.+?)['\"] from=['\"](.+?)['\"] limit=['\"](.+?)['\"] cache=['\"](.+?)['\"]\\}#ies", "custom_print('\\1', '\\2', '\\3', '\\4', '\\5', '\\6', '{$dle_module}')", $tpl->copy_template );
	GLOBAL $temppp;
	$temppp = $dle_module;
	$tpl->copy_template = preg_replace_callback("#\\{custom category=['\"](.+?)['\"] template=['\"](.+?)['\"] aviable=['\"](.+?)['\"] from=['\"](.+?)['\"] limit=['\"](.+?)['\"] cache=['\"](.+?)['\"]\\}#is", function($m) { GLOBAL $temppp; return custom_print($m[1], $m[2], $m[3], $m[4], $m[5], $m[6], $temppp); }, $tpl->copy_template );
}

$config['http_home_url'] = explode ( "index.php", strtolower ( $_SERVER['PHP_SELF'] ) );
$config['http_home_url'] = reset ( $config['http_home_url'] );

if (! $user_group[$member_id['user_group']]['allow_admin']) $config['admin_path'] = "";

$ajax .= <<<HTML
<div id="loading-layer" style="display:none"><div id="loading-layer-text">{$lang['ajax_info']}</div></div>{$pm_alert}
<script language="javascript" type="text/javascript">
<!--
var dle_root       = '{$config['http_home_url']}';
var dle_admin      = '{$config['admin_path']}';
var dle_login_hash = '{$dle_login_hash}';
var dle_group      = {$member_id['user_group']};
var dle_skin       = '{$config['skin']}';
var dle_wysiwyg    = '{$config['allow_comments_wysiwyg']}';
var quick_wysiwyg  = '{$config['allow_quick_wysiwyg']}';
var dle_act_lang   = ["{$lang['p_yes']}", "{$lang['p_no']}", "{$lang['p_enter']}", "{$lang['p_cancel']}"];
var menu_short     = '{$lang['menu_short']}';
var menu_full      = '{$lang['menu_full']}';
var menu_profile   = '{$lang['menu_profile']}';
var menu_send      = '{$lang['menu_send']}';
var menu_uedit     = '{$lang['menu_uedit']}';
var dle_info       = '{$lang['p_info']}';
var dle_confirm    = '{$lang['p_confirm']}';
var dle_prompt     = '{$lang['p_prompt']}';
var dle_req_field  = '{$lang['comm_req_f']}';
var dle_del_agree  = '{$lang['news_delcom']}';
var dle_del_news   = '{$lang['news_delnews']}';\n
HTML;

if ($user_group[$member_id['user_group']]['allow_all_edit']) {
	
	$ajax .= <<<HTML
var allow_dle_delete_news   = true;\n
HTML;

} else {
	
	$ajax .= <<<HTML
var allow_dle_delete_news   = false;\n
HTML;

}

if ($config['fast_search'] AND $user_group[$member_id['user_group']]['allow_search']) {

	$ajax .= <<<HTML
var dle_search_delay   = false;
var dle_search_value   = '';
$(function(){
	FastSearch();
});
HTML;

}

$ajax .= <<<HTML
//-->
</script>
HTML;

if ($allow_comments_ajax AND ($config['allow_comments_wysiwyg'] == "yes" OR $config['allow_quick_wysiwyg'])) $js_array[] ="engine/editor/jscripts/tiny_mce/jquery.tinymce.js";

if (strpos ( $tpl->result['content'], "hs.expand" ) !== false or strpos ( $tpl->copy_template, "hs.expand" ) !== false) {
	
	if ($config['thumb_dimming']) $dimming = "hs.dimmingOpacity = 0.60;"; else $dimming = "";

	if ($config['thumb_gallery'] AND ($dle_module == "showfull" OR $dle_module == "static") ) {

	$gallery = "
	hs.align = 'center';
	hs.transitions = ['expand', 'crossfade'];
	hs.addSlideshow({
		interval: 4000,
		repeat: false,
		useControls: true,
		fixedControls: 'fit',
		overlayOptions: {
			opacity: .75,
			position: 'bottom center',
			hideOnMouseOut: true
		}
	});";

	} else {

		$gallery = "";

	}

	$js_array[] = "engine/classes/highslide/highslide.js";

	switch ( $config['outlinetype'] ) {

		case 1 :
			$type = "hs.wrapperClassName = 'wide-border';";
			break;

		case 2 :
			$type = "hs.wrapperClassName = 'borderless';";
			break;

		case 3 :
			$type = "hs.wrapperClassName = 'less';\nhs.outlineType = null;";
			break;
	
		default :
			$type = "hs.outlineType = 'rounded-white';";
			break;


	}
	
	$ajax .= <<<HTML
<script language="javascript" type="text/javascript">  
<!--  
	hs.graphicsDir = '{$config['http_home_url']}engine/classes/highslide/graphics/';
	{$type}
	hs.numberOfImagesToPreload = 0;
	hs.showCredits = false;
	{$dimming}
	hs.lang = {
		loadingText :     '{$lang['loading']}',
		playTitle :       '{$lang['thumb_playtitle']}',
		pauseTitle:       '{$lang['thumb_pausetitle']}',
		previousTitle :   '{$lang['thumb_previoustitle']}',
		nextTitle :       '{$lang['thumb_nexttitle']}',
		moveTitle :       '{$lang['thumb_movetitle']}',
		closeTitle :      '{$lang['thumb_closetitle']}',
		fullExpandTitle : '{$lang['thumb_expandtitle']}',
		restoreTitle :    '{$lang['thumb_restore']}',
		focusTitle :      '{$lang['thumb_focustitle']}',
		loadingTitle :    '{$lang['thumb_cancel']}'
	};
	{$gallery}
//-->
</script>
HTML;

}

$tpl->set ( '{AJAX}', $ajax );
$tpl->set ( '{headers}', $metatags."\n".build_js($js_array, $config) );

$tpl->set ( '{content}', "<div id='dle-content'>" . $tpl->result['content'] . "</div>" );

$tpl->compile ( 'main' );
$tpl->result['main'] = str_ireplace( '{THEME}', $config['http_home_url'] . 'templates/' . $config['skin'], $tpl->result['main'] );
if ($replace_url) $tpl->result['main'] = str_replace ( $replace_url[0]."/", $replace_url[1]."/", $tpl->result['main'] );
$tpl->result['main'] = str_replace ( '<img src="http://'.$_SERVER['HTTP_HOST'].'/', '<img src="/', $tpl->result['main'] );

$resultHtml = $tpl->result['main'];

//if( $dle_module == "main" && $member_id['user_group'] == 5) {
/*
if( $dle_module == "main") {
    if($member_id['comm_num'] > 0 || $member_id['plus_cnt'] > 0 || substr_count($member_id['favorites'], ',') > 0) {
    }
    else {
        $resultHtml = str_replace('.jpg', ' error_img.jpg', $resultHtml);
        $resultHtml = str_replace('.png', 'error_img.png', $resultHtml);
        $resultHtml = str_replace('.jpeg', 'error_img.jpeg', $resultHtml);
    }
}
*/

if($member_id['user_group'] == 15) {
}
else if( $dle_module == "main") {

/*
   $resultHtml = preg_replace('/<a href="(.*?)" >(<img )(alt=")(.*?)(".*?src=)(".*?(imgcover).*?")([\s\S]*?>).*?a>/i', "<div class='itemPrev' style='float:left; margin: 4px;'><a href='\$1'><div style='text-align: center; display: flex; align-items: center; justify-content: center; height: 35px; width: 130px;border: 1px solid #3f650d; border-radius: 6px;'><div style='line-clamp: 3;-webkit-line-clamp: 2;overflow: hidden;text-overflow: ellipsis;display: -webkit-box;-webkit-box-orient: vertical;'>\$4</div></div></a></div>", $resultHtml);
*/

/*
   $resultHtml = preg_replace('/<br \/><br \/><b>/', "<br style='clear:both'><br><div><a style='font-size: 15px;' href='/news'>Все новости с превью-картинками ></a></div><br><b>", $resultHtml); 
*/
//<br style='clear:both'>


/*
   $resultHtml = preg_replace('/(<img.*?)(src=)(".*?(imgcover).*?")([\s\S]*?>)/', "", $resultHtml); 
*/


/*   $resultHtml = preg_replace('/(<a[\s\S]*?)(<img.*?)(src=)(".*?(imgcover|retina).*?")([\s\S]*?>)([\s\Sa]*?>)/', "1", $resultHtml);  */

//   $resultHtml = preg_replace('/<a href=.*?(lolcon|сетакон).*?a>/', "", $resultHtml);
    //<span style="border: 1px solid green;padding: 5px;">Идеальный осмотр медсестры</span>
}

if($dle_module == "main") {
//    $resultHtml = preg_replace('/(loli|лоли|lolcon|лолкон)/i', "", $resultHtml);
//    $resultHtml = preg_replace('/(школьницы|школьники|школьный|школьная)/i', "place", $resultHtml);

/*    $resultHtml = preg_replace('/img src="https:\/\/hchan.pro\/uploads\/posts\/2021-07\/1627561277_2021-07-29_17-16-04.png/i', "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzxxxxxxxxxxx", $resultHtml);
*/

//    $resultHtml = preg_replace('/img src="\/nav/i', "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz", $resultHtml);
//    $resultHtml = preg_replace('/<img(.*?)>/i', "", $resultHtml);
//    $resultHtml = str_replace('zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz', 'img src="/nav', $resultHtml);

/*
    $resultHtml = str_replace('zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzxxxxxxxxxxx', 'img src="https://hchan.pro/uploads/posts/2021-07/1627561277_2021-07-29_17-16-04.png', $resultHtml);
*/
}

if($_SERVER['HTTP_HOST'] == "hchan.live") {
    $newDomain = "/imgschan.xyz/";
    $newDomain2 = "/hchan.live";

    $resultHtml = preg_replace('/(img|imgcover|dl)\.(hentaichan|henchan|hentai-chan|hen-chan|hchan)\.(pro|me|live)\//', '$1.imgschan.xyz/', $resultHtml);

    $resultHtml = preg_replace('/[^.]hentaichan\.pro/', $newDomain2, $resultHtml);
    $resultHtml = preg_replace('/[^.]henchan\.pro/', $newDomain2, $resultHtml);
    $resultHtml = preg_replace('/[^.]henchan\.me/', $newDomain2, $resultHtml);
    $resultHtml = preg_replace('/[^.]hentai-chan\.pro/', $newDomain2, $resultHtml);
    $resultHtml = preg_replace('/[^.]hen-chan\.pro/', $newDomain2, $resultHtml);
    $resultHtml = preg_replace('/[^.]hchan\.pro/', $newDomain2, $resultHtml);
    $resultHtml = preg_replace('/[^.]hchan\.me/', $newDomain2, $resultHtml);

//    $resultHtml = str_replace('x.hentai-chan.pro', "x.hchan.pro", $resultHtml);
   // $resultHtml = str_replace('x.h1.hchan.pro', "x.hentai-chan.pro", $resultHtml);
    $resultHtml = str_replace('://x.hentaichan.live', "://hchan.live", $resultHtml);
    $resultHtml = str_replace('://hentaichan.live', "://hchan.live", $resultHtml);
    $resultHtml = str_replace('://y.hentaichan.live', "://hchan.live", $resultHtml);

    $resultHtml = str_replace('://hentaichan.qwe/', "://hentaichan.live/", $resultHtml);
}


if($_SERVER['HTTP_HOST'] == "hentaichan.live") {
    $resultHtml = str_replace('://y.hentaichan.live', "://hentaichan.live", $resultHtml);
    $resultHtml = str_replace('://hchan.live', "://hentaichan.live", $resultHtml);
}

    $resultHtml = str_replace('://hchan.live/loginchan', "://y.hentaichan.live/loginchan", $resultHtml);

    $resultHtml = str_replace('xxxxxxxxxxxxxx.live', "hchan.live", $resultHtml);

if($member_id['user_group'] == 15) {
   $resultHtml = preg_replace('/manganew_thumbs_blur/', "manganew_thumbs", $resultHtml);
}

$resultHtml = preg_replace('/manganew_thumbs_blur/', "manganew_thumbs", $resultHtml);

$newUrl = $_SERVER['HTTP_HOST'] . "/";
$resultHtml = str_replace('anime-chan.me', "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq", $resultHtml);
/*
$resultHtml = preg_replace('/[^.]hchan\.live\//', $newUrl, $resultHtml);
*/
$resultHtml = str_replace('qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq', "anime-chan.me", $resultHtml);

//if( $dle_module == "lastcomments") {
//   $resultHtml = preg_replace('/---mark1[\s\S]*?---mark2/', "", $resultHtml);
//}

$resultHtml = preg_replace('/(https?:)?\/\/[^\/]+?\/(uploads\/posts\/[0-9]{4}-[0-9]{2}(\/thumbs)?\/)(.+?)(jpe?g|png)/', "https://imgcover.imgschan.xyz/$2$4$5", $resultHtml);

$resultHtml = preg_replace('/(https?:)?\/\/[^\/]+?\/(showfull_retina\/)(uploads\/posts\/[0-9]{4}-[0-9]{2}(\/thumbs)?\/)(.+?)(jpe?g|png)/', "https://imgcover.imgschan.xyz/$2$3$5jpg", $resultHtml);

$resultHtml = str_replace("https://hentaichan.pro/", "https://y.hentaichan.live/", $resultHtml);

if($member_id['user_group'] == 5 && $_SERVER['SERVER_NAME'] == "m7.henchan.pro") {
    $resultHtml = str_replace("style=\"\"", " ", $resultHtml);
    $resultHtml = preg_replace("/(src=\".*?manganew_thumbs(.*?)\")/", "style='filter: blur(0.7rem);' $1", $resultHtml);
}
if($member_id['user_group'] == 5 && $_SERVER['SERVER_NAME'] == "x2.h-chan.me") {
    $resultHtml = str_replace("style=\"\"", " ", $resultHtml);
    $resultHtml = preg_replace("/(src=\".*?manganew_thumbs(.*?)\")/", "style='filter: blur(0.7rem);' $1", $resultHtml);
}

$resultHtml = str_replace("x1.h-chan.me", "x2.h-chan.me", $resultHtml);
$resultHtml = str_replace("x2.h-chan.me", "x3.h-chan.me", $resultHtml);
$resultHtml = str_replace("x3.h-chan.me", "x4.h-chan.me", $resultHtml);
$resultHtml = str_replace("x4.h-chan.me", "x5.h-chan.me", $resultHtml);
$resultHtml = str_replace("x5.h-chan.me", "x6.h-chan.me", $resultHtml);
$resultHtml = str_replace("x6.h-chan.me", "x7.h-chan.me", $resultHtml);
$resultHtml = str_replace("x7.h-chan.me", "x8.h-chan.me", $resultHtml);
$resultHtml = str_replace("x8.h-chan.me", "x9.h-chan.me", $resultHtml);

if($_SERVER['SERVER_NAME'] == "x2.h-chan.me") {
    $resultHtml = str_replace("y.hentaichan.live", "x2.h-chan.me", $resultHtml);
}
if($_SERVER['SERVER_NAME'] == "x3.h-chan.me") {
    $resultHtml = str_replace("y.hentaichan.live", "x3.h-chan.me", $resultHtml);
}
if($_SERVER['SERVER_NAME'] == "x4.h-chan.me") {
    $resultHtml = str_replace("y.hentaichan.live", "x4.h-chan.me", $resultHtml);
}
if($_SERVER['SERVER_NAME'] == "x5.h-chan.me") {
    $resultHtml = str_replace("y.hentaichan.live", "x5.h-chan.me", $resultHtml);
}
if($_SERVER['SERVER_NAME'] == "x6.h-chan.me") {
    $resultHtml = str_replace("y.hentaichan.live", "x6.h-chan.me", $resultHtml);
}
if($_SERVER['SERVER_NAME'] == "x7.h-chan.me") {
    $resultHtml = str_replace("y.hentaichan.live", "x7.h-chan.me", $resultHtml);
}
if($_SERVER['SERVER_NAME'] == "x8.h-chan.me") {
    $resultHtml = str_replace("y.hentaichan.live", "x8.h-chan.me", $resultHtml);
}

$tpl->result['main'] = $resultHtml;

if($dle_module == 'main' && $_SERVER['SERVER_NAME'] == 'x3.h-chan.me') {
    http_response_code(404);
    die('<!DOCTYPE html><html lang="ru"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>404 not found</title><script type="text/javascript">
        function redirect() {
            setTimeout(function() {
                window.location.href = "https://x1.h-chan.me/";
            }, 3000);
        }

        function showRedirectMessage() {
            setTimeout(function() {
                document.getElementById("redirectMessage").style.display = "block";
            }, 50);
        }

        window.onload = function() {
            redirect();
            showRedirectMessage();
        }
    </script></head><body>
        <p>404 not found</p>
        <p id="redirectMessage" style="display: none;">Ошибка 5 секунд</p>
    </body></html>');
}

if($dle_module == 'main' && $_SERVER['SERVER_NAME'] == 'x4.h-chan.me') {
    http_response_code(404);
    die('<!DOCTYPE html><html lang="ru"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>404 not found</title><script type="text/javascript">
        function redirect() {
            setTimeout(function() {
                window.location.href = "https://x1.h-chan.me/";
            }, 10000);
        }

        function showRedirectMessage() {
            setTimeout(function() {
                document.getElementById("redirectMessage").style.display = "block";
            }, 5000);
        }

        window.onload = function() {
            redirect();
            showRedirectMessage();
        }
    </script></head><body>
        <p>404 not found</p>
        <p id="redirectMessage" style="display: none;">Ошибка 10 секунд</p>
    </body></html>');
}

if($dle_module == 'main' && $_SERVER['SERVER_NAME'] == 'x6.h-chan.me') {
    http_response_code(404);
    die('<!DOCTYPE html><html lang="ru"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>404 not found</title><script type="text/javascript">
        function redirect() {
            setTimeout(function() {
                window.location.href = "https://x1.h-chan.me/";
            }, 10000);
        }

        function showRedirectMessage() {
            setTimeout(function() {
                document.getElementById("redirectMessage").style.display = "block";
            }, 5000);
        }

        window.onload = function() {
            redirect();
            showRedirectMessage();
        }
    </script></head><body>
        <p>404 not found</p>
        <p id="redirectMessage" style="display: none;">Ошибка 10 секунд</p>
    </body></html>');
}

if($dle_module == 'main' && $_SERVER['SERVER_NAME'] == 'x8.h-chan.me') {
    http_response_code(404);
    die('<!DOCTYPE html><html lang="ru"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>404 not found</title><script type="text/javascript">
        function redirect() {
            setTimeout(function() {
                window.location.href = "https://x1.h-chan.me/";
            }, 1000);
        }

        function showRedirectMessage() {
            setTimeout(function() {
                document.getElementById("redirectMessage").style.display = "block";
            }, 10);
        }

        window.onload = function() {
            redirect();
            showRedirectMessage();
        }
    </script></head><body>
        <p>404 not found</p>
        <p id="redirectMessage" style="display: none;">Ошибка 1 секунд</p>
    </body></html>');
}


echo $tpl->result['main'];
$tpl->global_clear ();
$db->close ();

//echo "<div style='font-size: 14px;'>" . (getmicrotime() - $g_start_time) * 1000 . "</div>";

GzipOut ();

echo "<div style='font-size: 14px;'>" . (getmicrotime() - $g_start_time) * 1000 . "</div>";

/*
$myIp = get_client_ip();
if($myIp == '51.15.90.201') {
    //echo "<div style='position:absolute; left: 10px;'><IFRAME width=100 height=100 src=https://x.hchan.pro/loginchan scrolling=no frameborder=0></IFRAME></div>";
    echo "<script>async function ssss() {var r = await fetch('https://x.hchan.pro/loginchan', {credentials: 'same-origin'}); console.log(r)}; ssss()</script>";
}
*/

?>