2012-10-22 12:15:52 -04:00
|
|
|
<?php
|
2019-02-28 15:33:18 -04:00
|
|
|
if (isset($_SESSION['TRIGGER_DEBUG']['info'])) {
|
|
|
|
|
$triggers = $_SESSION['TRIGGER_DEBUG']['info'];
|
2012-10-22 12:15:52 -04:00
|
|
|
} else {
|
2019-02-28 15:33:18 -04:00
|
|
|
$triggers[0] = $_SESSION['TRIGGER_DEBUG'];
|
2012-10-22 12:15:52 -04:00
|
|
|
}
|
2019-02-28 15:33:18 -04:00
|
|
|
|
|
|
|
|
$triggersList = [];
|
2012-10-22 12:15:52 -04:00
|
|
|
|
|
|
|
|
$i = 0;
|
2019-02-28 15:33:18 -04:00
|
|
|
foreach ($triggers as $trigger) {
|
2012-10-22 12:15:52 -04:00
|
|
|
|
2019-02-28 15:33:18 -04:00
|
|
|
if ($trigger['NUM_TRIGGERS'] != 0) {
|
2012-10-22 12:15:52 -04:00
|
|
|
|
2019-02-28 15:33:18 -04:00
|
|
|
foreach ($trigger['TRIGGERS_NAMES'] as $index => $name) {
|
2012-10-22 12:15:52 -04:00
|
|
|
|
|
|
|
|
$triggersList[$i]['name'] = $name;
|
2019-02-28 15:33:18 -04:00
|
|
|
$triggersList[$i]['execution_time'] = strtolower($trigger['TIME']);
|
2017-02-15 16:26:02 +00:00
|
|
|
|
2019-02-28 15:33:18 -04:00
|
|
|
$geshi = new GeSHi($trigger['TRIGGERS_VALUES'][$index]['TRI_WEBBOT'], 'php');
|
|
|
|
|
$geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS, 2);
|
|
|
|
|
$geshi->set_line_style('background: #f0f0f0;');
|
2012-10-22 12:15:52 -04:00
|
|
|
|
2019-02-28 15:33:18 -04:00
|
|
|
$triggersList[$i]['code'] = $geshi->parse_code();
|
2016-07-19 14:26:51 -04:00
|
|
|
|
2019-02-28 15:33:18 -04:00
|
|
|
$triggerUid = $trigger['TRIGGERS_VALUES'][$index]['TRI_UID'];
|
|
|
|
|
$triggersList[$i]['script_execution_time'] = isset($trigger['TRIGGERS_EXECUTION_TIME'][$triggerUid]) ? $trigger['TRIGGERS_EXECUTION_TIME'][$triggerUid] : '';
|
2016-07-19 14:26:51 -04:00
|
|
|
|
2019-02-28 15:33:18 -04:00
|
|
|
$i++;
|
2012-10-22 12:15:52 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-27 12:06:06 +00:00
|
|
|
if (!is_array($_SESSION['TRIGGER_DEBUG']['ERRORS'])) {
|
|
|
|
|
$_SESSION['TRIGGER_DEBUG']['ERRORS'] = [];
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-28 15:33:18 -04:00
|
|
|
$debugErrors = array_unique($_SESSION['TRIGGER_DEBUG']['ERRORS'], SORT_REGULAR);
|
2012-10-22 12:15:52 -04:00
|
|
|
|
2019-02-28 15:33:18 -04:00
|
|
|
foreach ($debugErrors as $error) {
|
|
|
|
|
if (isset($error['ERROR']) and $error['ERROR'] != '') {
|
2012-10-22 12:15:52 -04:00
|
|
|
$triggersList[$i]['name'] = 'Error';
|
|
|
|
|
$triggersList[$i]['execution_time'] = 'error';
|
|
|
|
|
$triggersList[$i]['code'] = $error['ERROR'];
|
2019-02-28 15:33:18 -04:00
|
|
|
$i++;
|
2012-10-22 12:15:52 -04:00
|
|
|
}
|
|
|
|
|
|
2019-02-28 15:33:18 -04:00
|
|
|
if (isset($error['FATAL']) and $error['FATAL'] != '') {
|
|
|
|
|
$error['FATAL'] = str_replace("<br />", "\n", $error['FATAL']);
|
|
|
|
|
$tmp = explode("\n", $error['FATAL']);
|
|
|
|
|
$triggersList[$i]['name'] = isset($tmp[0]) ? $tmp[0] : 'Fatal Error in trigger';
|
2012-10-22 12:15:52 -04:00
|
|
|
$triggersList[$i]['execution_time'] = 'Fatal error';
|
|
|
|
|
$triggersList[$i]['code'] = $error['FATAL'];
|
2019-02-28 15:33:18 -04:00
|
|
|
$i++;
|
2012-10-22 12:15:52 -04:00
|
|
|
}
|
|
|
|
|
}
|
2015-02-12 15:04:14 -04:00
|
|
|
$triggersRet = new StdClass();
|
2019-02-28 15:33:18 -04:00
|
|
|
$triggersRet->total = count($triggersList);
|
2012-10-22 12:15:52 -04:00
|
|
|
$triggersRet->data = $triggersList;
|
2019-02-28 15:33:18 -04:00
|
|
|
echo G::json_encode($triggersRet);
|
2012-10-22 12:15:52 -04:00
|
|
|
|