<?php
if( ! defined( 'DATALIFEENGINE' ) ) {die( "Hacking attempt!" );}

$name = @$db->safesql( trim( totranslit( $_GET['page'], true, false ) ) );

if( ! $static_result['id'] ) $static_result = $db->super_query( "SELECT * FROM " . PREFIX . "_static WHERE name='$name'" );
if( $static_result['id'] ) {
	$db->query( "UPDATE " . PREFIX . "_static set views=views+1 where id='{$static_result['id']}'" );
	$static_result['grouplevel'] = explode( ',', $static_result['grouplevel'] );
	if( $static_result['date'] ) $_DOCUMENT_DATE = $static_result['date'];
	if( $static_result['grouplevel'][0] != "all" and ! in_array( $member_id['user_group'], $static_result['grouplevel'] ) ) {msgbox( $lang['all_err_1'], $lang['static_denied'] );
	} else {
		$template = stripslashes( $static_result['template'] );
		$static_descr = stripslashes( strip_tags( $static_result['descr'] ) );
		
		if( $static_result['metakeys'] == '' AND $static_result['metadescr'] == '' ) create_keywords( $template );
		else {
			$metatags['keywords'] = $static_result['metakeys'];
			$metatags['description'] = $static_result['metadescr'];
		}

		if ($static_result['metatitle']) $metatags['header_title'] = $static_result['metatitle'];
			$tpl->load_template( 'static.tpl' );

			if( @date( "Ymd", $static_result['date'] ) == date( "Ymd", $_TIME ) ) {
				$tpl->set( '{date}', $lang['time_heute'] . langdate( ", H:i", $static_result['date'] ) );
			} elseif( @date( "Ymd", $static_result['date'] ) == date( "Ymd", ($_TIME - 86400) ) ) {
				$tpl->set( '{date}', $lang['time_gestern'] . langdate( ", H:i", $static_result['date'] ) );
			} else {
				$tpl->set( '{date}', langdate( $config['timestamp_active'], $static_result['date'] ) );
			}
	
			$tpl->copy_template = preg_replace ( "#\{date=(.+?)\}#ie", "langdate('\\1', '{$static_result['date']}')", $tpl->copy_template );

			$tpl->set( '{description}', $static_descr );
			$tpl->set( '{static}', $template );
			$tpl->set( '{views}', $static_result['views'] );

			$tpl->compile( 'content' );

			if( $user_group[$member_id['user_group']]['allow_hide'] ) $tpl->result['content'] = preg_replace( "'\[hide\](.*?)\[/hide\]'si", "\\1", $tpl->result['content']);
			else $tpl->result['content'] = preg_replace ( "'\[hide\](.*?)\[/hide\]'si", "<div class=\"quote\">" . $lang['news_regus'] . "</div>", $tpl->result['content'] );

			$tpl->clear();
	}
	
	if( $config['files_allow'] == "yes" ){
        if( strpos( $tpl->result['content'], "[file=" ) !== false ) {$tpl->result['content'] = show_file( $tpl->result['content'], $static_result['id'], true );}
	    if( strpos( $tpl->result['content'], "[torrent=" ) !== false ) {$tpl->result['content'] = show_torrent( $tpl->result['content'], $static_result['id'], true );}
    }
} else {
	@header( "HTTP/1.0 404 Not Found" );
	require_once ROOT_DIR.'/404.php';
    die();
}
?>