<commit_before><?php
$xmlArray = array();
// rearrange things to be compatible with the Xml::fromArray()
$event['Event']['Attribute'] = $event['Attribute'];
unset($event['Attribute']);

// cleanup the array from things we do not want to expose
unset($event['Event']['user_id']);
// remove value1 and value2 from the output
foreach($event['Event']['Attribute'] as $key => $value) {
    unset($event['Event']['Attribute'][$key]['value1']);
    unset($event['Event']['Attribute'][$key]['value2']);
}

// hide the private fields is we are not in sync mode
if ('true' != Configure::read('CyDefSIG.sync')) {
    unset($event['Event']['private']);
    foreach($event['Event']['Attribute'] as $key => $value) {
        unset($event['Event']['Attribute'][$key]['private']);
    }
}
// hide the org field is we are not in showorg mode
if ('true' != Configure::read('CyDefSIG.showorg') && !$isAdmin) {
    unset($event['Event']['org']);
}

// build up a list of the related events
foreach ($relatedEvents as $relatedEvent) {
    $event['Event']['RelatedEvent'][] = $relatedEvent['Event'];
}

// display the XML to the user
$xmlArray['response']['Event'][] = $event['Event'];
$xmlObject = Xml::fromArray($xmlArray, array('format' => 'tags'));
echo $xmlObject->asXML();<commit_msg>do not show related events if the variable was not set<commit_after><?php
$xmlArray = array();
// rearrange things to be compatible with the Xml::fromArray()
$event['Event']['Attribute'] = $event['Attribute'];
unset($event['Attribute']);

// cleanup the array from things we do not want to expose
unset($event['Event']['user_id']);
// remove value1 and value2 from the output
foreach($event['Event']['Attribute'] as $key => $value) {
    unset($event['Event']['Attribute'][$key]['value1']);
    unset($event['Event']['Attribute'][$key]['value2']);
}

// hide the private fields is we are not in sync mode
if ('true' != Configure::read('CyDefSIG.sync')) {
    unset($event['Event']['private']);
    foreach($event['Event']['Attribute'] as $key => $value) {
        unset($event['Event']['Attribute'][$key]['private']);
    }
}
// hide the org field is we are not in showorg mode
if ('true' != Configure::read('CyDefSIG.showorg') && !$isAdmin) {
    unset($event['Event']['org']);
}

// build up a list of the related events
if (isset($relatedEvents)) {
    foreach ($relatedEvents as $relatedEvent) {
        $event['Event']['RelatedEvent'][] = $relatedEvent['Event'];
    }
}

// display the XML to the user
$xmlArray['response']['Event'][] = $event['Event'];
$xmlObject = Xml::fromArray($xmlArray, array('format' => 'tags'));
echo $xmlObject->asXML();
{'fraction_non_alphanumeric': 0.2148854961832061, 'fraction_numerical': 0.0030534351145038168, 'mean_word_length': 5.5361596009975065, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 10}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4983230', 'n_tokens_mistral': 774, 'n_tokens_neox': 773, 'n_words': 217}