<?php

/***************************************************************************

 headeruserdata.php
 -------------------
 copyright : (C) 2002-2003 The ezContents Development Team

 ***************************************************************************/

/***************************************************************************
 The ezContents Development Team offers no warranties on this script.
 The owner/licensee of the script is solely responsible for any problems
 caused by installation of the script or use of the script.

 All copyright notices regarding ezContents must remain intact on the
 scripts and in the HTML for the scripts.

 For more info on ezContents,
 visit http://www.ezcontents.org/

/***************************************************************************

/***************************************************************************
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the License which can be found within the
 *	zipped package.
 *
 ***************************************************************************/

$GLOBALS["rootdp"] = './';
require_once ($GLOBALS["rootdp"]."include/config.php");
require_once ($GLOBALS["rootdp"]."include/db.php");
require_once ($GLOBALS["rootdp"]."include/session.php");

if (($GLOBALS["gsUseFrames"] == '') && ($EZ_SESSION_VARS["noframesbrowser"] != True)) {
	include ($GLOBALS["rootdp"]."include/settings.php");
	include ($GLOBALS["rootdp"]."include/functions.php");
	includeLanguageFiles('admin','main');
} // Frames includes
include ($GLOBALS["rootdp"]."include/userdata.php");


if (isset($HTTP_POST_VARS["topgroupname"])) { $HTTP_GET_VARS["topgroupname"] = $HTTP_POST_VARS["topgroupname"]; }
if (isset($HTTP_POST_VARS["groupname"])) { $HTTP_GET_VARS["groupname"] = $HTTP_POST_VARS["groupname"]; }
if (isset($HTTP_POST_VARS["subgroupname"])) { $HTTP_GET_VARS["subgroupname"] = $HTTP_POST_VARS["subgroupname"]; }

if ($HTTP_GET_VARS["topgroupname"] == '') { $HTTP_GET_VARS["topgroupname"] = hGetTopGroupName(); }
if ($HTTP_GET_VARS["groupname"] == '') { $HTTP_GET_VARS["groupname"] = hGetGroupName(); }


if (($GLOBALS["gsUseFrames"] == 'Y') && ($EZ_SESSION_VARS["noframesbrowser"] != True)) {
	HTMLHeader('userdata');
	StyleSheet();
	?>
	</head>
	<?php
	$HTTP_GET_VARS["link"] = hHomeLink($HTTP_GET_VARS["groupname"]);
	if ($GLOBALS["gsShowTopMenu"] == 'Y') {
		$topmenulink = BuildLink('topmenu.php').'&topgroupname='.$HTTP_GET_VARS["topgroupname"];
		$menulink = BuildLink('menu.php').'&topgroupname='.$HTTP_GET_VARS["topgroupname"].'&groupname='.$HTTP_GET_VARS["groupname"].'&subgroupname='.$HTTP_GET_VARS["subgroupname"];
		if ($HTTP_GET_VARS["link"] != "") {
			$contentlink = BuildLink('module.php').'&link='.$HTTP_GET_VARS["link"].'&topgroupname='.$HTTP_GET_VARS["topgroupname"].'&groupname='.$HTTP_GET_VARS["groupname"].'&subgroupname='.$HTTP_GET_VARS["subgroupname"];
		} else {
			$contentlink = BuildLink('showcontents.php').'&topgroupname='.$HTTP_GET_VARS["topgroupname"].'&groupname='.$HTTP_GET_VARS["groupname"].'&subgroupname='.$HTTP_GET_VARS["subgroupname"];
		}
		?>
		<body marginwidth="0" marginheight="0" leftmargin="0" topmargin="0" class="topback" onload="top.ezc.topmenu.location='<?php echo $topmenulink; ?>'; top.ezc.left.location='<?php echo $menulink; ?>'; top.ezc.contents.location='<?php echo $contentlink; ?>';">
		<?php
	} else {
		$menulink = BuildLink('menu.php').'&groupname='.$HTTP_GET_VARS["groupname"].'&subgroupname='.$HTTP_GET_VARS["subgroupname"];
		if ($HTTP_GET_VARS["link"] != "") {
			$contentlink = BuildLink('module.php').'&link='.$HTTP_GET_VARS["link"].'&groupname='.$HTTP_GET_VARS["groupname"].'&subgroupname='.$HTTP_GET_VARS["subgroupname"];
		} else {
			$contentlink = BuildLink('showcontents.php').'&groupname='.$HTTP_GET_VARS["groupname"].'&subgroupname='.$HTTP_GET_VARS["subgroupname"];
		}
		?>
		<body marginwidth="0" marginheight="0" leftmargin="0" topmargin="0" class="topback" onload="top.ezc.left.location='<?php echo $menulink; ?>'; top.ezc.contents.location='<?php echo $contentlink; ?>';">
		<?php
	}
} // Frames header



?>
<table border="0" width="100%" height="100%" cellpadding="3" cellspacing="3">
	<tr class="topback">
		<td align="<?php echo $GLOBALS["right"]; ?>" valign="top">
			<table border="0" width="100%" height="100%" cellpadding="1" cellspacing="0">
				<?php userdatamain('header'); ?>
			</table>
	</td></tr>
</table>
<?php


if (($GLOBALS["gsUseFrames"] == 'Y') && ($EZ_SESSION_VARS["noframesbrowser"] != True)) {
	?>
	</body>
	</html>
	<?php
} // Frames footer


function hGetTopGroupName()
{
	global $HTTP_GET_VARS;

	if ((isset($HTTP_GET_VARS["groupname"])) && ($HTTP_GET_VARS["groupname"] != '')) {
		$strQuery = "SELECT topgroupname FROM ".$GLOBALS["eztbGroups"]." WHERE groupname='".$HTTP_GET_VARS["groupname"]."' AND language='".$GLOBALS["gsLanguage"]."'";
		$result = dbRetrieve($strQuery,true,0,1);
		if ($rs = dbFetch($result)) { $topgroupname = $rs["topgroupname"];
		} else { $topgroupname = $GLOBALS["gsHomepageTopGroup"]; }
		dbFreeResult($result);
		return $topgroupname;
	}
	return $GLOBALS["gsHomepageTopGroup"];
} // function hGetTopGroupName()


function hGetGroupName()
{
	global $HTTP_GET_VARS;

	if ((isset($HTTP_GET_VARS["topgroupname"])) && ($HTTP_GET_VARS["topgroupname"] != '')) {
		if ($HTTP_GET_VARS["topgroupname"] != $GLOBALS["gsHomepageTopGroup"]) {
			$strQuery = "SELECT groupname FROM ".$GLOBALS["eztbGroups"]." WHERE topgroupname='".$HTTP_GET_VARS["topgroupname"]."' AND language='".$GLOBALS["gsDefault_language"]."' ORDER BY grouporderid";
			$result = dbRetrieve($strQuery,true,0,1);
			if ($rs = dbFetch($result)) { $groupname = $rs["groupname"];
			} else { $groupname = $GLOBALS["gsHomepageGroup"]; }
			dbFreeResult($result);
			return $groupname;
		}
	}
	return $GLOBALS["gsHomepageGroup"];
} // function hGetGroupName()


function hHomeLink($GroupName)
{
	global $EZ_SESSION_VARS, $groupname, $subgroupname;

	$link = '';
	if ($groupname != '') {
		$strQuery = "SELECT loginreq,groupname,grouplink FROM ".$GLOBALS["eztbGroups"]." WHERE groupname='".$groupname."' AND language='".$GLOBALS["gsLanguage"]."'";
	} else {
		$strQuery = "SELECT loginreq,groupname,grouplink FROM ".$GLOBALS["eztbGroups"]." WHERE groupname='".$GroupName."' AND language='".$GLOBALS["gsLanguage"]."'";
	}
	$result = dbRetrieve($strQuery,true,0,0);
	$rs	= dbFetch($result);
	if (($rs["loginreq"] == 'Y') && ($EZ_SESSION_VARS["PasswordCookie"] == '')) {
		$link = 'loginreq.php';
	} else {
		if ($rs["grouplink"] != '') { $link = $rs["grouplink"]; }
	}
	dbFreeResult($result);
	return $link;
} // function hHomeLink()


?>
