<?php
/************************************************************************/
/* Maximus CMS: Web Portal System                                       */
/* ==============================                                       */
/*                                                                      */
/* Copyright (c) 2002 - 2006                                            */
/* http://www.php-maximus.fr                                            */
/* dev@php-maximus.org                                                  */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/
/* Based on PHP-NUKE: Web Portal System                                 */
/************************************************************************/
if (stristr(htmlentities($_SERVER['SCRIPT_NAME']), 'header.php')) {
	Header('Location: index.php');
	die();
}

if (is_file('kernel/addons/pre_header.php')) {
	include_once('kernel/addons/pre_header.php');
}

global $rewrite;
if ( (!empty($rewrite) ) && ( !defined('ADMIN_MAX') ) ) {
GTv2_header();
}

function head() {
global $sitename, $nukeurl, $cookie, $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $textcolor1, $textcolor2, $pagetitle, $db, $admintheme, $ThemeSel, $name, $ab_config;
// template system maximus
	if (!defined('ADMIN_MAX')) {
		if (is_file("themes/".$ThemeSel."/theme.php")) {
			include_once("themes/".$ThemeSel."/theme.php");
		}
		if (file_exists("themes/".$ThemeSel."/credits.php")) {
			if (is_file('kernel/templates/themes_maximus.php')) {
				include_once('kernel/templates/themes_maximus.php');
			}
		} else {
			if (is_file('kernel/templates/themes_phpnuke.php')) {
				include_once('kernel/templates/themes_phpnuke.php');}
			}
		} else {
			if (is_file("admin/themes/".$admintheme."/index.php")) {
				include_once("admin/themes/".$admintheme."/index.php");
		}
	}
	echo "<?xml version='1.0' encoding='iso-8859-1'?>\n"
	    ."<!DOCTYPE html PUBLIC
    '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>\n"
	    ."<html xmlns='http://www.w3.org/1999/xhtml'>\n"
	    ."<head>\n\n"
	    ."<!-- PHP Maximus Cms XHTML 1.0 Transitional valide -->\n\n";
if ( $name != 'Forums' ) {
	echo "<title>$sitename $pagetitle</title>\n";
}
// load meta
	if (is_file('kernel/meta.php')) { include_once('kernel/meta.php');}
// load javascript
	if (is_file('kernel/javascript.php')) {include_once('kernel/javascript.php');}
// load favicon
	if (file_exists("themes/".$ThemeSel."/images/favicon.ico")) {
		echo "<link rel='shortcut icon' href=\"themes/".$ThemeSel."/images/favicon.ico\" type='image/x-icon' />\n";
	}
// backend links
	if (is_file('backend.php')) {
		echo "<link rel='alternate' type='application/rss+xml' title='RSS' href='backend.php' />\n";
	}
	//echo "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS2\" href=\"backend2.php\">\n";
	//echo "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"ATOM\" href=\"backend3.php\">\n";

// load css
	if (is_file("kernel/style.css")) {
		echo "<style type='text/css'> @import url(kernel/style.css); </style>";
	}
	if (!defined('ADMIN_MAX')) {
        	if (is_file("themes/".$ThemeSel."/style/style_".$name.".css")) {
			echo "<style type='text/css'> @import url(themes/".$ThemeSel."/style/style_".$name.".css); </style>";
		} else {
			echo "<style type='text/css'> @import url(themes/".$ThemeSel."/style/style.css); </style>";
		}
	} else {
	if (is_file("admin/themes/".$admintheme."/style/style.css")) {
		echo "<link rel='stylesheet' href=\"admin/themes/".$admintheme."/style/style.css\" type='text/css' />\n\n\n";
		}
	}
// custom head
        if ( MAXADV_CUSTOM_HEAD == 0 ) {
		if (file_exists('includes/custom_files/custom_head.php')) {
			include_once('includes/custom_files/custom_head.php');
		}
	}
// load tabs
	if (defined('CREATE_HEADER')) {
		if (is_file('kernel/addons/create_header.php')) {
       			include_once('kernel/addons/create_header.php');
		}
	CreateHeader();
	}
	echo "\n\n</head>\n\n";
// custom header
	if ( MAXADV_CUSTOM_HEADER == 0 ) {
		if (file_exists('includes/custom_files/custom_header.php')) {
			include_once('includes/custom_files/custom_header.php');
		}
	}
// close website
	if($ab_config['site_switch'] == 1) {
        	echo "<center><img src='images/nukesentinel/disabled.png' border='0' width='120' height='34' alt='WebSite Closed' title='WebSite Closed' /></center><br />\n";
        }
	themeheader();
}

// sessions maximus
online();

// load header
head();

// message
if (!defined('ADMIN_MAX')){
	if(defined('HOME_FILE')) {
		if ( MAXADV_MESSAGE_BOX == 0 ) {
			if (is_file('kernel/addons/message_box.php')) {
				include_once('kernel/addons/message_box.php');
			}
		message_box();
	}
}

// center blocks header
if ( MAXADV_CENTER_BLOCKS == 0 ) {
	if (is_file('kernel/addons/center_blocks.php')) {
		include_once('kernel/addons/center_blocks.php');
	}

	if (defined('HOME_FILE')) {
		if (is_file('kernel/cblocks1.php')) {
			include_once('kernel/cblocks1.php');
		}
	} else {
		if (is_file('kernel/cblocks2.php')) {
			include_once('kernel/cblocks2.php');
			}
		}
	}
}

// blocks center header
if ( MAXADV_BLOCKS_CENTER == 0 ) {
	blocks('Center');
}