<?php
if(!strlen($pathtoroot))
{
  $path=dirname(realpath(__FILE__));
  if(strlen($path))
  {
    /* determine the OS type for path parsing */
    $pos = strpos($path,":");
    if ($pos === false)
    {
      $gOS_TYPE="unix";
      $pathchar = "/";
    }
    else
    {
      $gOS_TYPE="win";
      $pathchar="\\";
    }
    $p = $path.$pathchar;
    /*Start looking for the root flag file */
    while(!strlen($pathtoroot) && strlen($p))
    {
      $sub = substr($p,strlen($pathchar)*-1);
      if($sub==$pathchar)
      {
        $filename = $p."root.flg";
      }
      else
        $filename = $p.$pathchar."root.flg";
      if(file_exists($filename))
      {
        $pathtoroot = $p;
      }
      else
      {
        $parent = realpath($p.$pathchar."..".$pathchar);
	if($parent!=$p)
	{
	  $p = $parent;
	}
	else
	  $p = "";
      }
    }
    if(!strlen($pathtoroot))
      $pathtoroot = ".".$pathchar;
  }
  else
  {
    $pathtoroot = ".".$pathchar;
  }
}

$sub = substr($pathtoroot,strlen($pathchar)*-1);
if($sub!=$pathchar)
{
  $pathtoroot = $pathtoroot.$pathchar;
}
//echo $pathtoroot;

require_once($pathtoroot."kernel/startup.php");
//admin only util
$rootURL="http://".ThisDomain().$objConfig->Get("Site_Path");

$localURL=$rootURL."kernel/";

$admin = $objConfig->Get("AdminDirectory");
if(!strlen($admin))
    $admin = "admin";
$adminURL = $rootURL.$admin;
$imagesURL = $adminURL."/images"; 
$pathtolocal = $pathtoroot;
//require_once ($pathtoroot."admin/include/elements.php"); 
//require_once ($pathtoroot."kernel/admin/include/navmenu.php"); 
//require_once ($pathtolocal."admin/include/navmenu.php"); 
//require_once($pathtoroot."admin/toolbar.php");
  //print_r($objSession);

 $userid= $objSession->Get("PortalUserId"); 
 if($userid!=-1)
 { 
   $userobj=$objUsers->GetItem($userid); 
   $loginname= $userobj->Get("Login"); 
 }
 else
     $loginname = "root";

 $logout = $rootURL."admin/";
 $mainpage = $rootURL."admin/subitems.php?"."env=".BuildEnv()."&section=in-portal:root";
 $objLang = $objLanguages->GetItem($m_var_list["lang"]);
 $charset = GetRegionalOption('Charset');
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title>HEAD</title>
<meta http-equiv="content-type" content="text/html;charset=<?php echo $charset; ?>">
<meta name="generator" content="Notepad">
<link rel="stylesheet" type="text/css" href="include/style.css">
</head>
<body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0" bgcolor="#FFFFFF">
<table cellpadding="0" cellspacing="0" border="0" width="100%" height="100%">
<tr>
	<td valign="bottom">
		<table cellpadding="0" cellspacing="0" border="0" width="100%" height="90">
		<tr>
			<td rowspan="3" valign="top"><a href="<?php echo $mainpage; ?>" target="main"><img alt="In-portal" src="images/globe.gif" width="84" height="91" border="0"></a></td>
			<td rowspan="3" valign="top"><a href="<?php echo $mainpage; ?>" target="main"><img alt="In-portal" src="images/logo.gif" width="150" height="91" border="0"></a></td>
			<td rowspan="3" width="100000" align="right">&nbsp;</td>
			<td width="400"><img alt="" src="images/blocks.gif" width="400" height="73"></td>
		</tr>
		<tr>
  			<td align="right" background="images/version_bg.gif" class="head_version" valign="bottom"><img alt="" src="images/spacer.gif" width="1" height="10"  align="absmiddle">

  	<?php echo prompt_language("la_Logged_in_as")." "; ?><B><?php echo $loginname." "; ?></B>
  	<a href="<?php echo $logout."login.php?logout=1"; ?>" target="_parent"><img src="images/blue_bar_logout.gif" height="16" WIDTH="16" align="absmiddle" BORDER="0"></A></td>
		</tr>
		<tr>
			<td><img alt="" src="images/blocks2.gif" width="400" height="1"></td>
		</tr>                                                                                              <tr>
			<td bgcolor="black" colspan="4"><img alt="" src="images/spacer.gif" width="1" height="1"></td>
		</tr>
	</table>
</td>
</tr>
</table>

</body>
</html>