<?php 

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

$sub = substr($pathtoroot,strlen($pathchar)*-1);
if($sub!=$pathchar)
{
  $pathtoroot = $pathtoroot.$pathchar;
}
//echo $pathtoroot;
//echo $pathtoroot;
require_once($pathtoroot."kernel/startup.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";
//admin only util
$pathtolocal = $pathtoroot."kernel/";
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");
//Set Section
$section = "in-portal:main_import";
//Set Environment Variable
$envar = "env=" . BuildEnv();

 $sec = $objSections->GetSection($section);
 $objCatToolBar = new clsToolBar();

// Clean Up Import DB Connection Variables
$objSession->SetVariable("import_sql_type",""); // sql server type
$objSession->SetVariable("import_server","");	// sql server address
$objSession->SetVariable("import_db","");		// database name
$objSession->SetVariable("import_user","");		// connection user
$objSession->SetVariable("import_pass","");		// connection password
$objSession->SetVariable("error_importing","");	// connection error

// Clean Up Last Step Variables
$objSession->SetVariable('import_table_prefix','');

$objSession->SetVariable('user_admin_names','');
$objSession->SetVariable('user_regular_names','');
$objSession->SetVariable('user_admin_values','');
$objSession->SetVariable('user_regular_values','');
$objSession->SetVariable('catnavbar','');
$objSession->SetVariable('init_cat','');
$objSession->SetVariable('user_input1',''); // in use ?
$objSession->SetVariable('user_input2',''); // in use ?
$objSession->SetVariable('importtodo','');

	$var="?env=".BuildEnv();
	
	// Prev Button (no use at a time :)
    $MouseOver="";
    $MouseOut="";
    $onClick="";
    $objCatToolBar->Add("moveleft",admin_language("la_ToolTip_Previous")." ".admin_language("la_Text_Step"),"#","","","","tool_prev_f3.gif");
    
	// Next Button  
    $MouseOver="if( UsedAgreed() ) swap('moveright','toolbar/tool_next_f2.gif');";
    $MouseOut="if( UsedAgreed() ) swap('moveright', 'toolbar/tool_next.gif');";
    
    $link2=$adminURL."/import/step2.php".$var;
    $onClick="if( UsedAgreed() ) document.location= '$link2';";
    $objCatToolBar->Add("moveright",admin_language("la_ToolTip_Next")." ".admin_language("la_Text_Step"),'#',$MouseOver,$MouseOut,$onClick,"tool_next_f3.gif");
  
  
  $title = admin_language("la_performing_import")." - ".admin_language("la_Step")." 1";
  
  int_header($objCatToolBar,NULL,$title,' onload="PageOnLoad(1);"');

?>
         
<table width="100%" border="0" cellspacing="0" cellpadding="4" class="tableborder">
<form name="import_form" METHOD="POST" action="<?php echo $_SERVER["PHP_SELF"]."?".$envar; ?>">	
<?php int_subsection_title(admin_language("la_Prompt_Warning"));  ?>
 <TR <?php echo int_table_color(); ?>> 
       <TD COLSPAN="2"><span class=\"text\">This utility allows you to import data from other databases and applications, including third party products and earlier versions of this software.
            </span> 
       </TD>
    </TR>
 <tr <?php echo int_table_color(); ?>>
     <TD>
 	<?php
      		echo int_hint(prompt_language("la_text_disclaimer_part1")." ".prompt_language("la_text_disclaimer_part2")); 
      ?>
   </td>
   </tr>
 <tr>
 <td COLSPAN="2">
	<input type="checkbox" value="0" id="agree" name="agree" onclick="if( UsedAgreed() ) swap('moveright', 'toolbar/tool_next.gif'); else swap('moveright', 'toolbar/tool_next_f3.gif'); "><label for="agree"><?php echo admin_language("la_Text_IAgree"); ?></label>
 </td>
 </tr>
</FORM>
</TABLE>

<?php
int_footer();
?>