<?php
// This header file detects whether Gallery is embedded in any 
// known PHP applications and then decorates Gallery appropriately.

global $GALLERY_EMBEDDED_INSIDE;

switch($GALLERY_EMBEDDED_INSIDE) {
	case "nuke":
		global $PHP_SELF;
		if (!eregi("modules.php", $PHP_SELF)) {
			die ("You can't access this file directly...");
		}

		/*
		 * Nuke owns the <head> tag and doesn't share.  So, if we want to get our
		 * style sheet in place we've got to intercept Nuke's header and modify it 
		 * to insert a few lines of our own in place.  We could speed this process 
		 * up greatly if we cached the results and saved it somewhere handy (like
		 * the session) but then we'd be vulnerable to attack by somebody who has
		 * write permissions in the directory that the session files live.  They
		 * could create a bogus session file, set that ID into their cookie and 
		 * then pass their own code into our eval() below.
		 */
		$header = "";
		if ($fd = fopen("header.php", "r")) {
			while (!feof($fd)) {
				$line = fgets($fd, 1024);
				$line = str_replace('<?php', '', $line);
				$line = str_replace('?>', '', $line);
				$header .= $line;
				if (strstr($line, "<head")) {
					$links = getStyleSheetLink();
					$links = str_replace('"', '\"', $links);
					$header .= 'echo "' . $links . '\n";' . "\n";
				}
			}
		}

		/*
		 * 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;

		eval($header);

		OpenTable();

		$index = $tmp_index;
		break;
}
?>
