<?php
set_time_limit(0);
include("./DB/system/ini.php");
include($O__libPath . "/functions/server/O__dataRead.php");
include($O__libPath . "/functions/server/O__launchProgram.php");
include($O__libPath . "/functions/server/O__XMLdata.php");
include($O__libPath . "/functions/server/O__XMLgetData.php");
include($O__libPath . "/pageTypes/O__logs/libraries/O__logger.php");

// Load settings from O__menu
$O__fileData = O__XMLdata($O__DBpath . "/pageTypes/O__boot/configs/settings.xml", 0, 0);
$O__menuStoragePath = O__XMLgetData($O__fileData,"/settings/setting[@id='menuStoragePath']/value");
unset($O__fileData);

// Load settings from O__launch
$O__fileData = O__XMLdata($O__DBpath . "/pageTypes/O__launch/configs/settings.xml", 0, 0);
$O__launchMethod = O__XMLgetData($O__fileData,"/settings/setting[@id='launchMethod']/value");
$O__launchUser = O__XMLgetData($O__fileData,"/settings/setting[@id='launchUser']/value");
$O__launchPW = O__XMLgetData($O__fileData,"/settings/setting[@id='launchPW']/value");
$O__launchDisplay = O__XMLgetData($O__fileData,"/settings/setting[@id='launchDisplay']/value");
unset($O__fileData);

O__logger("access","boot","Request","LOCALHOST","Starting");

// Load menu file with boot settings
$O__fileData = O__XMLdata($O__DBpath . $O__menuStoragePath . "boot.xml", 0, 0);

for ($i=0; $i< count($O__fileData); $i++){
	// Get the menu item vars
	$O__menuActive = $O__fileData->item[$i]->active;
	$O__menuName = $O__fileData->item[$i]->name;
	$O__menuBinPath = $O__fileData->item[$i]->path;
	$O__menuBin = $O__fileData->item[$i]->bin;
	$O__menuBinArgs = $O__fileData->item[$i]->args;
	$O__menuWait = $O__fileData->item[$i]->wait;
	
	if ($O__menuActive == 1){	
		$O__logNotes = "Starting '" . $O__menuName . "' with " . $O__menuBinPath . $O__menuBin;
			if(trim($O__menuBinArgs) != "") { $O__logNotes .= " using the parameters '" . $O__menuBinArgs . "'."; }
		O__logger("access","boot","Request","LOCALHOST",$O__logNotes);
		O__launchProgram($O__menuBinPath,$O__menuBin,$O__menuBinArgs);
		if ($O__menuWait > 0){ sleep($O__menuWait); }
	}
}

O__logger("access","boot","Success","LOCALHOST","Finished");
?>
