<?PHP

# if it appears that the software has not yet been installed
if ((!file_exists("config.php") || file_exists("NEWVERSION")) 
        && file_exists("installcwis.php"))
{
    # jump to installation
    ?><html>
    <head><meta http-equiv="refresh" content="0; URL=installcwis.php"></head>
    <body bgcolor="white"></body>
    </html><?PHP
    exit();
}

# load base configuration
require_once("config.php");
require_once("lib/AxisPHP/Axis--Database.php");
Database::SetGlobalServerInfo($SPT_DBUserName, $SPT_DBPassword, $SPT_DBHost);
Database::SetGlobalDatabaseName($SPT_DBName);

# initialize application framework
require_once("lib/ScoutLib/ApplicationFramework.php");
$ObjectDirectories = array(
        "objects" => "",
        "lib/AxisPHP" => "Axis--",
        "lib/ScoutLib" => "",
        );
if (is_dir("local/objects")) {  $ObjectDirectories["local/objects"] = "";  }
$AF = new ApplicationFramework($ObjectDirectories);
require_once("include/Events.php");
$AF->AddEnvInclude("include/Compat.php");

# set up environment
require_once("include/Compat.php");
CreateCompatabilityLinks();
require_once("include/StdLib.php");
require_once("include/EnvSetup.php");

# load plugins
$PluginDirs = array(
        "plugins",
        "local/plugins",
        );
$G_PluginManager = new PluginManager($AF, $PluginDirs);
$G_PluginManager->LoadPlugins();

# grab page to load
$Page = isset($_GET["P"]) ? $_GET["P"] : "Home";

$AF->ActiveUserInterface(GetActiveUI());
$AF->LoadPage($Page);

?>
