<?php
/* $Id: wrapper.header.default 17853 2008-08-14 22:36:50Z JensT $
 *
 * This header file detects whether Gallery is embedded in any
 * known PHP applications and then decorates Gallery appropriately.
 * Also the css stylesheets are loaded if not already done.
 */

global $GALLERY_EMBEDDED_INSIDE;
global $GALLERY_EMBEDDED_INSIDE_TYPE;

if(isset($GALLERY_EMBEDDED_INSIDE)) {

	global $PHP_SELF;

	if (
		($GALLERY_EMBEDDED_INSIDE_TYPE == 'postnuke' && !defined("LOADED_AS_MODULE")) ||
		($GALLERY_EMBEDDED_INSIDE_TYPE == 'zikula' && !defined("LOADED_AS_MODULE")) ||
		($GALLERY_EMBEDDED_INSIDE_TYPE == 'phpnuke' && !eregi("modules.php", $PHP_SELF) && !isset($GLOBALS['nukeurl'])) ||
		($GALLERY_EMBEDDED_INSIDE_TYPE == 'cpgnuke' && !defined('CPG_NUKE')) ||
		($GALLERY_EMBEDDED_INSIDE_TYPE == 'nsnnuke' && !eregi("modules.php", $PHP_SELF)) ||
		($GALLERY_EMBEDDED_INSIDE_TYPE == 'phpBB2' && !defined("LOADED_AS_MODULE"))
	) {
			die ("You can't access this file directly...");
	}

	switch ($GALLERY_EMBEDDED_INSIDE_TYPE) {

	case 'phpnuke':
	case 'postnuke':
	case 'zikula':
	case 'cpgnuke':
		/*
		 * We can control whether we see the right side blocks
		 * by setting the value of the $index variable.  To
		 * see the blocks, set $index to 1.  To hide them set
		 * $index to 0.  We default to 0 to leave more room for
		 * the photos.  If you change this value, you should
		 * also change it in wrapper.footer
		 *
		 * Note that we save the current value of $index in
		 * $tmp_index and restore it when we're done.  If we
		 * don't do this, navigation won't work!
		 */
		global $index;
		$tmp_index = $index;
		$index = 0;

		include_once('./header.php');

		OpenTable();

		$index = $tmp_index;
	break;

	case 'phpBB2':
		/*
		 * PhpBB2 uses a templating system and also owns the HEAD tags. The
		 * easiest way at the moment to tackle this issue is therefore to
		 * simply make sure we don't call this function if phpBB2 is being used
		 * and put the style sheet link into the template manually
		 */

		global $phpbb_root_path;
		global $template;
		global $db;
		global $theme, $lang, $images;
		global $board_config;
		global $phpEx;
		global $userdata, $u_login_logout;
		global $s_privmsg_new, $s_last_visit;
		global $l_privmsgs_text_unread, $l_privmsgs_text, $l_online_users;
		global $page_title, $nav_links_html;

		// Sort out the page title
		$page_title .= $gallery->app->galleryTitle;

		// Verify that the $phpbb_root_path isn't overwritten with a remote exploit
		if (!realpath($phpbb_root_path)) {
                	print _("Security violation") ."\n";
			exit;
		} else {
			if (! defined("PHPBB_ROOT_PATH")) {
				define("PHPBB_ROOT_PATH", $phpbb_root_path);
			}
			include (PHPBB_ROOT_PATH . "includes/page_header.php");
		}
	break;

	case 'GeekLog':
		/*
		** Display header and left blocks
		*/
		echo COM_siteHeader();
	break;

	}
    /* Import Gallery CSS Stylesheet after embedding things are done. */
    echo getStyleSheetLink();
}

includeTemplate('header.tpl');
?>
