<?php 
##############################################################
##In-portal													##
##############################################################
##					      In-portal							##
##					Intechnic Corporation					##
##			   All Rights Reserved, 1998-2002				##
##															##	
##	No portion of this code may be copied, reproduced or	##	
##	   otherwise redistributed without proper written		##
##	  consent of Intechnic Corporation.  Violation will		##
##	   result in revocation of the license and support		##
##	 privileges along maximum prosecution allowed by law.	##
##############################################################
$pathtoroot = "";
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;
  }
}

if (!file_exists($pathtoroot."/config.php")) {
	echo "In-Portal is probably not installed, or configuration file is missing.<br>";
	echo "Please use the installation script to fix the problem.<br><br>";
	echo "<a href='install.php'>Go to installation script</a><br><br>";
	flush();
	die();
}

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

//echo "<PRE>"; print_r($_POST); echo "</PRE>";
require_once($pathtoroot."/kernel/startup.php");

$rootURL="http://".ThisDomain().$objConfig->Get("Site_Path");
$admin = substr($path,strlen($pathtoroot));
$objConfig->Set("AdminDirectory",$admin,0,TRUE);
$objConfig->Save();

//echo "Setting admin to $admin <br>\n";
$localURL=$rootURL."kernel/";
$adminURL = $rootURL.$admin;
$imagesURL = $adminURL."/images";
$browseURL = $adminURL."/browse";
$cssURL = $adminURL."/include";


// !admin_login() - admin, but not logged in

if (!admin_login() || GetVar('logout') || GetVar('expired') )
{            
    if(!headers_sent())
      setcookie("sid"," ",time()-3600);
    $objSession->Logout();
	require_once($pathtoroot.$admin."/login.php");
}

$envar = "env=" . BuildEnv();

require_once ($pathtoroot.$admin."/include/elements.php"); 
require_once ($pathtoroot."kernel/admin/include/navmenu.php"); 

$pathtolocal = $pathtoroot;
$charset = GetRegionalOption('Charset');
?>

<html>

	<head>
		<meta http-equiv="content-type" content="text/html;charset=<?php echo $charset; ?>">
		<meta name="generator" content="kwrite">
		<link rel="stylesheet" type="text/css" href="include/style.css">
		<title>In-portal Administration</title>
	</head>
<script type="text/javascript">
	window.name = 'main_frame';
</script>
<script language="JavaScript1.2">

lala = navigator.appVersion.substring(0,1);

if (navigator.appName == "Netscape") {
	if (lala != "5") {
		document.write("<frameset rows='96,*' framespacing='0' scrolling='no' frameborder='0'>");
	} else {
		document.write("<frameset rows='95,*' framespacing='0' scrolling='no' frameborder='0'>");
	}
} else {
	document.write("<frameset rows='94,*' framespacing='0' scrolling='no' frameborder='0'>");
}
</script>
	<!--<frameset rows="92,*" border="0">-->
		<frame src="head.php?<?php echo $envar; ?>" name="head" scrolling="no" noresize>		
		<frameset cols="200,*" border="0">
			<frame src="tree/tree.php?<?php echo $envar; ?>" name="menu" target="_main" noresize scrolling="auto" marginwidth="0" marginheight="0">
			<frame src="subitems.php?<?php echo $envar."&section=in-portal:root"; ?>" name="main" marginwidth="0" marginheight="0" frameborder="NO" noresize scrolling="auto">
		</frameset>
	</frameset>
	<noframes>
		<body bgcolor="#ffffff">
			<p></p>
		</body>
	</noframes>
</html>