Index: trunk/admin/advanced_view.php
===================================================================
diff -u -r2772 -r2853
--- trunk/admin/advanced_view.php	(.../advanced_view.php)	(revision 2772)
+++ trunk/admin/advanced_view.php	(.../advanced_view.php)	(revision 2853)
@@ -39,97 +39,16 @@
 $b_topmargin = "0";
 //$b_header_addon = "<DIV style='position:relative; z-Index: 1; background-color: #ffffff; padding-top:1px;'><div style='position:absolute; width:100%;top:0px;' align='right'><img src='images/logo_bg.gif'></div><img src='images/spacer.gif' width=1 height=15><br><div style='z-Index:1; position:relative'>";
 
-if( !(isset($pathtoroot) && $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 */
-    if( !isset($pathtoroot) ) $pathtoroot = '';
-    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( !(isset($pathtoroot) && $pathtoroot) )
-      $pathtoroot = ".".$pathchar;
-  }
-  else
-  {
-    $pathtoroot = ".".$pathchar;
-  }
-}
+require_once(FULL_PATH.'/kernel/startup.php');
 
-$sub = substr($pathtoroot,strlen($pathchar)*-1);
-if($sub!=$pathchar)
-{
-  $pathtoroot = $pathtoroot.$pathchar;
-}
-//echo $pathtoroot;
+require_login();
 
-require_once($pathtoroot."kernel/startup.php");
-
-if (!admin_login())
-{            
-    if(!headers_sent())
-      setcookie("sid"," ",time()-3600, '', $_SERVER['HTTP_HOST']);
-    $objSession->Logout();
-    header("Location: ".$adminURL."/index.php?logout=1");
-    die();
-	//require_once($pathtoroot."admin/login.php");
-}
-
-$rootURL="http://".ThisDomain().$objConfig->Get("Site_Path");
-$admin = $objConfig->Get("AdminDirectory");
-if(!strlen($admin))
-    $admin = "admin";
-
-$localURL=$rootURL."kernel/";
-$adminURL = $rootURL.$admin;
-$imagesURL = $adminURL."/images";
-$browseURL = $adminURL."/browse";
-$cssURL = $adminURL."/include";
-
 $indexURL = $rootURL."index.php";
+$homeURL = "javascript:AdminCatNav('".$_SERVER["PHP_SELF"]."?env=".BuildEnv()."');";
 
 $m_var_list_update["cat"] = 0;
-$homeURL = "javascript:AdminCatNav('".$_SERVER["PHP_SELF"]."?env=".BuildEnv()."');";
 unset($m_var_list_update["cat"]);
 
-//admin only util
-
 $pathtolocal = $pathtoroot."kernel/";
 require_once ($pathtoroot.$admin."/include/elements.php");
 //require_once ($pathtoroot."kernel/admin/include/navmenu.php");
@@ -158,19 +77,9 @@
 	$$a_var = $application->ParseBlock(Array('name'=>$a_template), 0, true);
 }
 
-if(!defined('IS_INSTALL'))define('IS_INSTALL',0);
-if(!IS_INSTALL)
-{
-  if (!admin_login())
-  {            
-    if(!headers_sent())
-      setcookie("sid"," ",time()-3600, '', $_SERVER['HTTP_HOST']);
-    $objSession->Logout();
-    header("Location: ".$adminURL."/index.php?logout=1");
-    die();
-	//require_once($pathtoroot."admin/login.php");
-  }
-}
+if (!defined('IS_INSTALL') ) define('IS_INSTALL', 0);
+if( !IS_INSTALL ) require_login();
+
 //Set Section
 $section = 'in-portal:advanced_view';