Newer
Older
/**
* Copyright Maarch since 2008 under licence GPLv3.
* See LICENCE.txt file at the root folder for more details.
* This file is part of Maarch software.
*/
/**
* @brief process the event stack
*
* @file
* @author Cyril Vazquez <dev@maarch.org>
* @date $date$
* @version $Revision$
* @ingroup notification
*/
/**
* @brief Class to include the file error
*
*/
class IncludeFileError extends Exception
{
{
$this->file = $file;
parent :: __construct('Include File \'$file\' is missing!', 1);
}
}
// Globals variables definition
$GLOBALS['batchName'] = 'process_event_stack';
$GLOBALS['wb'] = '';
$batchDirectory = '';
$options = getopt("c:n:", ["config:", "notif:"]);
if (empty($options['c']) && empty($options['config'])) {
print("Configuration file missing\n");
exit(101);
} elseif (!empty($options['c']) && empty($options['config'])) {
$options['config'] = $options['c'];
unset($options['c']);
}
if (empty($options['n']) && empty($options['notif'])) {
print("Notification id missing\n");
exit(102);
} elseif (!empty($options['n']) && empty($options['notif'])) {
$options['notif'] = $options['n'];
unset($options['n']);
}
$txt = '';
foreach (array_keys($options) as $key) {
if (isset($options[$key]) && $options[$key] == false) {
$txt .= $key . '=false,';
} else {
$txt .= $key . '=' . $options[$key] . ',';
}
}
print($txt . "\n");
print("Load xml config file:" . $GLOBALS['configFile'] . "\n");
// Tests existence of config file
if (!file_exists($GLOBALS['configFile'])) {
print(
"Configuration file " . $GLOBALS['configFile']
. " does not exist\n"
print("Load xml config file:" . $GLOBALS['configFile'] . "\n");
$xmlconfig = simplexml_load_file($GLOBALS['configFile']);
print("Error on loading config file:" . $GLOBALS['configFile'] . "\n");
$maarchDirectory = (string)$config->MaarchDirectory;
$customID = (string)$config->customID;
$customIDPath = '';
$maarchUrl = (string)$config->MaarchUrl;
$GLOBALS['customId'] = $customID;
$GLOBALS['batchDirectory'] = $maarchDirectory . 'modules'
. DIRECTORY_SEPARATOR . 'notifications'
. DIRECTORY_SEPARATOR . 'batch';
set_include_path(get_include_path() . PATH_SEPARATOR . $maarchDirectory);
try {
Bt_myInclude('vendor/autoload.php');
Bt_writeLog(['level' => 'ERROR', 'message' => 'Problem with the php include path:' .$e .' '. get_include_path()]);
\SrcCore\models\DatabasePDO::reset();
new \SrcCore\models\DatabasePDO(['customId' => $customID]);
$GLOBALS['errorLckFile'] = $GLOBALS['batchDirectory'] . DIRECTORY_SEPARATOR
. $customIDPath . $GLOBALS['batchName'] . '_error.lck';
$GLOBALS['lckFile'] = $GLOBALS['batchDirectory'] . DIRECTORY_SEPARATOR
. $customIDPath . $GLOBALS['batchName'] . '.lck';
Bt_writeLog(['level' => 'ERROR', 'message' => 'Error persists, please solve this before launching a new batch']);