.*|s', $sOutput, $aMatches) ) { header("HTTP/1.0 500 Internal server error."); foreach ($aMatches as $sMatch) { $errors .= strip_tags($sMatch)."\n"; } $sOutput = "$errors\n"; // Logging to a file does not work if the whole memory is exhausted... //SetupWebPage::log_error("Fatal error - in $__FILE__ , $errors"); } return $sOutput; } //Define some bogus, invalid HTML tags that no sane //person would ever put in an actual document and tell //PHP to delimit fatal error warnings with them. ini_set('error_prepend_string', ''); ini_set('error_append_string', ''); // Starts the capture of the ouput, and sets a filter to capture the fatal errors. ob_start('FatalErrorCatcher'); // Start capturing the output, and pass it through the fatal error catcher require_once('../core/config.class.inc.php'); require_once('../core/cmdbsource.class.inc.php'); require_once('./xmldataloader.class.inc.php'); define('TMP_CONFIG_FILE', '../tmp-config-itop.php'); //define('FINAL_CONFIG_FILE', '../config-itop.php'); // Never cache this page header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Fri, 17 Jul 1970 05:00:00 GMT"); // Date in the past /** * Main program */ $sFileName = Utils::ReadParam('file', ''); $sSessionStatus = Utils::ReadParam('session_status', ''); $iPercent = (integer)Utils::ReadParam('percent', 0); SetupWebPage::log_info("Loading file: $sFileName"); try { if (empty($sFileName) || !file_exists($sFileName)) { throw(new Exception("File $sFileName does not exist")); } $oDataLoader = new XMLDataLoader(TMP_CONFIG_FILE); // When called by the wizard, the final config is not yet there if ($sSessionStatus == 'start') { $oChange = MetaModel::NewObject("CMDBChange"); $oChange->Set("date", time()); $oChange->Set("userinfo", "Initialization"); $iChangeId = $oChange->DBInsert(); SetupWebPage::log_info("starting data load session"); $oDataLoader->StartSession($oChange); } $oDataLoader->LoadFile($sFileName); $sResult = sprintf("loading of %s done. (Overall %d %% completed).", basename($sFileName), $iPercent); echo $sResult; SetupWebPage::log_info($sResult); if ($sSessionStatus == 'end') { $oDataLoader->EndSession(); SetupWebPage::log_info("ending data load session"); } } catch(Exception $e) { echo "

An error happened while loading the data

\n"; echo '

'.$e."

\n"; SetupWebPage::log_error("An error happened while loading the data. ".$e); } if (function_exists('memory_get_peak_usage')) { SetupWebPage::log_info("loading file '$sFileName', peak memory usage. ".memory_get_peak_usage()); } ?>