mirror of https://github.com/MISP/MISP
Attribute distributions
Added feature to block distribution levels that would get overruled by the event distribution. The distribution of the event will be the currently selected distribution when creating an attribute.pull/63/head
parent
b0448c4a92
commit
6afc1e993f
|
@ -259,10 +259,6 @@ class AttributesController extends AppController {
|
|||
} else {
|
||||
// set the event_id in the form
|
||||
$this->request->data['Attribute']['event_id'] = $eventId;
|
||||
// set distribution in the form
|
||||
$this->loadModel('Event');
|
||||
$events = $this->Event->findById($eventId);
|
||||
$this->request->data['Attribute']['distribution'] = $events['Event']['distribution'];
|
||||
}
|
||||
|
||||
// combobox for types
|
||||
|
@ -274,8 +270,22 @@ class AttributesController extends AppController {
|
|||
array_pop($categories);
|
||||
$categories = $this->_arrayToValuesIndexArray($categories);
|
||||
$this->set('categories', compact('categories'));
|
||||
$this->loadModel('Event');
|
||||
$events = $this->Event->findById($eventId);
|
||||
$maxDist = $events['Event']['distribution'];
|
||||
$this->set('maxDist', $maxDist);
|
||||
// combobox for distribution
|
||||
$distributions = array_keys($this->Attribute->distributionDescriptions);
|
||||
$count = 0;
|
||||
$distributionsBeforeCut = array_keys($this->Attribute->distributionDescriptions);
|
||||
if(isset($maxDist)){
|
||||
foreach($distributionsBeforeCut as $current){
|
||||
$distributions[$count] = $current;
|
||||
if($distributions[$count] == $maxDist)break;
|
||||
$count++;
|
||||
}
|
||||
}else{
|
||||
$distributions = array_keys($this->Attribute->distributionDescriptions);
|
||||
}
|
||||
$distributions = $this->_arrayToValuesIndexArray($distributions);
|
||||
$this->set('distributions', $distributions);
|
||||
// tooltip for distribution
|
||||
|
@ -327,7 +337,6 @@ class AttributesController extends AppController {
|
|||
*/
|
||||
public function add_attachment($eventId = null) {
|
||||
if ($this->request->is('post')) {
|
||||
$this->loadModel('Event');
|
||||
// only own attributes verified by isAuthorized
|
||||
|
||||
// Check if there were problems with the file upload
|
||||
|
@ -423,6 +432,10 @@ class AttributesController extends AppController {
|
|||
} else {
|
||||
// set the event_id in the form
|
||||
$this->request->data['Attribute']['event_id'] = $eventId;
|
||||
$this->loadModel('Event');
|
||||
$events = $this->Event->findById($eventId);
|
||||
$maxDist = $events['Event']['distribution'];
|
||||
$this->set('maxDist', $maxDist);
|
||||
}
|
||||
|
||||
// combobos for categories
|
||||
|
@ -454,7 +467,17 @@ class AttributesController extends AppController {
|
|||
$this->set('uploadDefinitions', $this->Attribute->uploadDefinitions);
|
||||
|
||||
// combobox for distribution
|
||||
$distributions = array_keys($this->Attribute->distributionDescriptions);
|
||||
if(isset($maxDist)){
|
||||
$distributionsBeforeCut = array_keys($this->Attribute->distributionDescriptions);
|
||||
$count = 0;
|
||||
foreach($distributionsBeforeCut as $current){
|
||||
$distributions[$count] = $current;
|
||||
if($distributions[$count] == $maxDist)break;
|
||||
$count++;
|
||||
}
|
||||
}else{
|
||||
$distributions = array_keys($this->Attribute->distributionDescriptions);
|
||||
}
|
||||
$distributions = $this->_arrayToValuesIndexArray($distributions);
|
||||
$this->set('distributions', $distributions);
|
||||
// tooltip for distribution
|
||||
|
@ -554,8 +577,22 @@ class AttributesController extends AppController {
|
|||
array_pop($categories); // remove that last empty/space option
|
||||
$categories = $this->_arrayToValuesIndexArray($categories);
|
||||
$this->set('categories', $categories);
|
||||
$this->loadModel('Event');
|
||||
$events = $this->Event->findById($eventId);
|
||||
$maxDist = $events['Event']['distribution'];
|
||||
$this->set('maxDist', $maxDist);
|
||||
// combobox for distribution
|
||||
$distributions = array_keys($this->Attribute->distributionDescriptions);
|
||||
if(isset($maxDist)){
|
||||
$distributionsBeforeCut = array_keys($this->Attribute->distributionDescriptions);
|
||||
$count = 0;
|
||||
foreach($distributionsBeforeCut as $current){
|
||||
$distributions[$count] = $current;
|
||||
if($distributions[$count] == $maxDist)break;
|
||||
$count++;
|
||||
}
|
||||
}else{
|
||||
$distributions = array_keys($this->Attribute->distributionDescriptions);
|
||||
}
|
||||
$distributions = $this->_arrayToValuesIndexArray($distributions);
|
||||
$this->set('distributions', $distributions);
|
||||
// tooltip for distribution
|
||||
|
|
|
@ -1,124 +1,124 @@
|
|||
|
||||
<div class="attributes form">
|
||||
<?php echo $this->Form->create('Attribute');?>
|
||||
<fieldset>
|
||||
<legend><?php echo __('Add Attribute'); ?></legend>
|
||||
<?php
|
||||
echo $this->Form->hidden('event_id');
|
||||
echo $this->Form->input('category', array(
|
||||
'between' => $this->Html->div('forminfo', '', array('id' => 'AttributeCategoryDiv')),
|
||||
'empty' => '(choose one)'
|
||||
));
|
||||
echo $this->Form->input('type', array(
|
||||
'between' => $this->Html->div('forminfo', '', array('id' => 'AttributeTypeDiv')),
|
||||
'empty' => '(first choose category)'
|
||||
));
|
||||
if ('true' == Configure::read('CyDefSIG.sync')) {
|
||||
if ('true' == Configure::read('CyDefSIG.private')) {
|
||||
echo $this->Form->input('distribution', array('label' => 'Distribution', 'selected' => 'All communities',
|
||||
'between' => $this->Html->div('forminfo', '', array('id' => 'AttributeDistributionDiv'))
|
||||
));
|
||||
} else {
|
||||
echo $this->Form->input('private', array(
|
||||
'before' => $this->Html->div('forminfo', isset($attrDescriptions['private']['formdesc']) ? $attrDescriptions['private']['formdesc'] : $attrDescriptions['private']['desc']),
|
||||
));
|
||||
}
|
||||
}
|
||||
echo $this->Form->input('to_ids', array(
|
||||
'checked' => true,
|
||||
'before' => $this->Html->div('forminfo', isset($attrDescriptions['signature']['formdesc']) ? $attrDescriptions['signature']['formdesc'] : $attrDescriptions['signature']['desc']),
|
||||
'label' => 'IDS Signature?'
|
||||
));
|
||||
echo $this->Form->input('value', array(
|
||||
'type' => 'textarea',
|
||||
'error' => array('escape' => false),
|
||||
));
|
||||
echo $this->Form->input('batch_import', array(
|
||||
'type' => 'checkbox',
|
||||
'after' => $this->Html->div('forminfo', 'Create multiple attributes one per line'),
|
||||
));
|
||||
|
||||
// link an onchange event to the form elements
|
||||
$this->Js->get('#AttributeCategory')->event('change', 'formCategoryChanged("#AttributeCategory")');
|
||||
$this->Js->get('#AttributeType')->event('change', 'showFormInfo("#AttributeType")');
|
||||
$this->Js->get('#AttributeDistribution')->event('change', 'showFormInfo("#AttributeDistribution")');
|
||||
?>
|
||||
</fieldset>
|
||||
<?php echo $this->Form->end(__('Submit'));?>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<ul>
|
||||
<?php echo $this->element('actions_menu'); ?>
|
||||
</ul>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
//
|
||||
//Generate Category / Type filtering array
|
||||
//
|
||||
var category_type_mapping = new Array();
|
||||
<?php
|
||||
foreach ($categoryDefinitions as $category => $def) {
|
||||
echo "category_type_mapping['" . addslashes($category) . "'] = {";
|
||||
$first = true;
|
||||
foreach ($def['types'] as $type) {
|
||||
if ($first) $first = false;
|
||||
else echo ', ';
|
||||
echo "'" . addslashes($type) . "' : '" . addslashes($type) . "'";
|
||||
}
|
||||
echo "}; \n";
|
||||
}
|
||||
?>
|
||||
|
||||
function formCategoryChanged(id) {
|
||||
showFormInfo(id); // display the tooltip
|
||||
// fill in the types
|
||||
var options = $('#AttributeType').prop('options');
|
||||
$('option', $('#AttributeType')).remove();
|
||||
$.each(category_type_mapping[$('#AttributeCategory').val()], function(val, text) {
|
||||
options[options.length] = new Option(text, val);
|
||||
});
|
||||
// enable the form element
|
||||
$('#AttributeType').prop('disabled', false);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Generate tooltip information
|
||||
//
|
||||
var formInfoValues = new Array();
|
||||
<?php
|
||||
foreach ($typeDefinitions as $type => $def) {
|
||||
$info = isset($def['formdesc']) ? $def['formdesc'] : $def['desc'];
|
||||
echo "formInfoValues['" . addslashes($type) . "'] = \"" . addslashes($info) . "\";\n"; // as we output JS code we need to add slashes
|
||||
}
|
||||
foreach ($categoryDefinitions as $category => $def) {
|
||||
$info = isset($def['formdesc']) ? $def['formdesc'] : $def['desc'];
|
||||
echo "formInfoValues['" . addslashes($category) . "'] = \"" . addslashes($info) . "\";\n"; // as we output JS code we need to add slashes
|
||||
}
|
||||
foreach ($distributionDescriptions as $type => $def) {
|
||||
$info = isset($def['formdesc']) ? $def['formdesc'] : $def['desc'];
|
||||
echo "formInfoValues['" . addslashes($type) . "'] = \"" . addslashes($info) . "\";\n"; // as we output JS code we need to add slashes
|
||||
}
|
||||
?>
|
||||
|
||||
function showFormInfo(id) {
|
||||
idDiv = id+'Div';
|
||||
// LATER use nice animations
|
||||
//$(idDiv).hide('fast');
|
||||
// change the content
|
||||
var value = $(id).val(); // get the selected value
|
||||
$(idDiv).html(formInfoValues[value]); // search in a lookup table
|
||||
|
||||
// show it again
|
||||
$(idDiv).fadeIn('slow');
|
||||
}
|
||||
|
||||
// hide the formInfo things
|
||||
$('#AttributeTypeDiv').hide();
|
||||
$('#AttributeCategoryDiv').hide();
|
||||
$('#AttributeType').prop('disabled', true);
|
||||
$('#AttributeDistributionDiv').hide();
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<div class="attributes form">
|
||||
<?php echo $this->Form->create('Attribute');?>
|
||||
<fieldset>
|
||||
<legend><?php echo __('Add Attribute'); ?></legend>
|
||||
<?php
|
||||
echo $this->Form->hidden('event_id');
|
||||
echo $this->Form->input('category', array(
|
||||
'between' => $this->Html->div('forminfo', '', array('id' => 'AttributeCategoryDiv')),
|
||||
'empty' => '(choose one)'
|
||||
));
|
||||
echo $this->Form->input('type', array(
|
||||
'between' => $this->Html->div('forminfo', '', array('id' => 'AttributeTypeDiv')),
|
||||
'empty' => '(first choose category)'
|
||||
));
|
||||
if ('true' == Configure::read('CyDefSIG.sync')) {
|
||||
if ('true' == Configure::read('CyDefSIG.private')) {
|
||||
echo $this->Form->input('distribution', array('label' => 'Distribution', 'selected' => $maxDist,
|
||||
'between' => $this->Html->div('forminfo', '', array('id' => 'AttributeDistributionDiv'))
|
||||
));
|
||||
} else {
|
||||
echo $this->Form->input('private', array(
|
||||
'before' => $this->Html->div('forminfo', isset($attrDescriptions['private']['formdesc']) ? $attrDescriptions['private']['formdesc'] : $attrDescriptions['private']['desc']),
|
||||
));
|
||||
}
|
||||
}
|
||||
echo $this->Form->input('to_ids', array(
|
||||
'checked' => true,
|
||||
'before' => $this->Html->div('forminfo', isset($attrDescriptions['signature']['formdesc']) ? $attrDescriptions['signature']['formdesc'] : $attrDescriptions['signature']['desc']),
|
||||
'label' => 'IDS Signature?'
|
||||
));
|
||||
echo $this->Form->input('value', array(
|
||||
'type' => 'textarea',
|
||||
'error' => array('escape' => false),
|
||||
));
|
||||
echo $this->Form->input('batch_import', array(
|
||||
'type' => 'checkbox',
|
||||
'after' => $this->Html->div('forminfo', 'Create multiple attributes one per line'),
|
||||
));
|
||||
|
||||
// link an onchange event to the form elements
|
||||
$this->Js->get('#AttributeCategory')->event('change', 'formCategoryChanged("#AttributeCategory")');
|
||||
$this->Js->get('#AttributeType')->event('change', 'showFormInfo("#AttributeType")');
|
||||
$this->Js->get('#AttributeDistribution')->event('change', 'showFormInfo("#AttributeDistribution")');
|
||||
?>
|
||||
</fieldset>
|
||||
<?php echo $this->Form->end(__('Submit'));?>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<ul>
|
||||
<?php echo $this->element('actions_menu'); ?>
|
||||
</ul>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
//
|
||||
//Generate Category / Type filtering array
|
||||
//
|
||||
var category_type_mapping = new Array();
|
||||
<?php
|
||||
foreach ($categoryDefinitions as $category => $def) {
|
||||
echo "category_type_mapping['" . addslashes($category) . "'] = {";
|
||||
$first = true;
|
||||
foreach ($def['types'] as $type) {
|
||||
if ($first) $first = false;
|
||||
else echo ', ';
|
||||
echo "'" . addslashes($type) . "' : '" . addslashes($type) . "'";
|
||||
}
|
||||
echo "}; \n";
|
||||
}
|
||||
?>
|
||||
|
||||
function formCategoryChanged(id) {
|
||||
showFormInfo(id); // display the tooltip
|
||||
// fill in the types
|
||||
var options = $('#AttributeType').prop('options');
|
||||
$('option', $('#AttributeType')).remove();
|
||||
$.each(category_type_mapping[$('#AttributeCategory').val()], function(val, text) {
|
||||
options[options.length] = new Option(text, val);
|
||||
});
|
||||
// enable the form element
|
||||
$('#AttributeType').prop('disabled', false);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Generate tooltip information
|
||||
//
|
||||
var formInfoValues = new Array();
|
||||
<?php
|
||||
foreach ($typeDefinitions as $type => $def) {
|
||||
$info = isset($def['formdesc']) ? $def['formdesc'] : $def['desc'];
|
||||
echo "formInfoValues['" . addslashes($type) . "'] = \"" . addslashes($info) . "\";\n"; // as we output JS code we need to add slashes
|
||||
}
|
||||
foreach ($categoryDefinitions as $category => $def) {
|
||||
$info = isset($def['formdesc']) ? $def['formdesc'] : $def['desc'];
|
||||
echo "formInfoValues['" . addslashes($category) . "'] = \"" . addslashes($info) . "\";\n"; // as we output JS code we need to add slashes
|
||||
}
|
||||
foreach ($distributionDescriptions as $type => $def) {
|
||||
$info = isset($def['formdesc']) ? $def['formdesc'] : $def['desc'];
|
||||
echo "formInfoValues['" . addslashes($type) . "'] = \"" . addslashes($info) . "\";\n"; // as we output JS code we need to add slashes
|
||||
}
|
||||
?>
|
||||
|
||||
function showFormInfo(id) {
|
||||
idDiv = id+'Div';
|
||||
// LATER use nice animations
|
||||
//$(idDiv).hide('fast');
|
||||
// change the content
|
||||
var value = $(id).val(); // get the selected value
|
||||
$(idDiv).html(formInfoValues[value]); // search in a lookup table
|
||||
|
||||
// show it again
|
||||
$(idDiv).fadeIn('slow');
|
||||
}
|
||||
|
||||
// hide the formInfo things
|
||||
$('#AttributeTypeDiv').hide();
|
||||
$('#AttributeCategoryDiv').hide();
|
||||
$('#AttributeType').prop('disabled', true);
|
||||
$('#AttributeDistributionDiv').hide();
|
||||
|
||||
|
||||
</script>
|
||||
<?php echo $this->Js->writeBuffer(); // Write cached scripts
|
|
@ -1,143 +1,143 @@
|
|||
<div class="attributes form">
|
||||
<?php echo $this->Form->create('Attribute', array('enctype' => 'multipart/form-data','onSubmit' => 'document.getElementById("AttributeMalware").removeAttribute("disabled");'));?>
|
||||
<fieldset>
|
||||
<legend><?php echo __('Add Attachment'); ?></legend>
|
||||
<?php
|
||||
echo $this->Form->hidden('event_id');
|
||||
echo $this->Form->input('category', array('between' => $this->Html->div('forminfo', '', array('id' => 'AttributeCategoryDiv'))));
|
||||
echo $this->Form->file('value', array(
|
||||
'error' => array('escape' => false),
|
||||
));
|
||||
echo $this->Form->input('malware', array(
|
||||
'type' => 'checkbox',
|
||||
'checked' => false,
|
||||
'after' => '<br>Tick this box to neutralize the sample. Every malware sample will be zipped with the password "infected"',
|
||||
));
|
||||
if ('true' == Configure::read('CyDefSIG.sync')) {
|
||||
if ('true' == Configure::read('CyDefSIG.private')) {
|
||||
echo $this->Form->input('distribution', array('label' => 'Distribution', 'selected' => 'All communities',
|
||||
'between' => $this->Html->div('forminfo', '', array('id' => 'AttributeDistributionDiv'))
|
||||
));
|
||||
//'before' => $this->Html->div('forminfo', isset($attrDescriptions['distribution']['formdesc']) ? $attrDescriptions['distribution']['formdesc'] : $attrDescriptions['distribution']['desc']),));
|
||||
} else {
|
||||
echo $this->Form->input('private', array(
|
||||
'before' => $this->Html->div('forminfo', isset($attrDescriptions['private']['formdesc']) ? $attrDescriptions['private']['formdesc'] : $attrDescriptions['private']['desc']),));
|
||||
}
|
||||
}
|
||||
// link an onchange event to the form elements
|
||||
$this->Js->get('#AttributeType')->event('change', 'showFormInfo("#AttributeType")');
|
||||
$this->Js->get('#AttributeCategory')->event('change', 'showFormInfo("#AttributeCategory")');
|
||||
$this->Js->get('#AttributeDistribution')->event('change', 'showFormInfo("#AttributeDistribution")');
|
||||
?>
|
||||
</fieldset>
|
||||
<?php echo $this->Form->end(__('Upload'));?>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<ul>
|
||||
<?php echo $this->element('actions_menu'); ?>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
var formInfoValues = new Array();
|
||||
<?php
|
||||
foreach ($categoryDefinitions as $category => $def) {
|
||||
$info = isset($def['formdesc']) ? $def['formdesc'] : $def['desc'];
|
||||
echo "formInfoValues['$category'] = \"$info\";\n";
|
||||
}
|
||||
foreach ($distributionDescriptions as $type => $def) {
|
||||
$info = isset($def['formdesc']) ? $def['formdesc'] : $def['desc'];
|
||||
echo "formInfoValues['" . addslashes($type) . "'] = \"" . addslashes($info) . "\";\n"; // as we output JS code we need to add slashes
|
||||
}
|
||||
?>
|
||||
|
||||
var formZipTypeValues = new Array();
|
||||
<?php
|
||||
foreach ($categoryDefinitions as $category => $def) {
|
||||
$types = $def['types'];
|
||||
$alreadySet = false;
|
||||
foreach ($types as $type) {
|
||||
if (in_array($type, $zippedDefinitions) && !$alreadySet) {
|
||||
$alreadySet = true;
|
||||
echo "formZipTypeValues['$category'] = \"true\";\n";
|
||||
}
|
||||
}
|
||||
if (!$alreadySet) {
|
||||
echo "formZipTypeValues['$category'] = \"false\";\n";
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
var formAttTypeValues = new Array();
|
||||
<?php
|
||||
foreach ($categoryDefinitions as $category => $def) {
|
||||
$types = $def['types'];
|
||||
$alreadySet = false;
|
||||
foreach ($types as $type) {
|
||||
if (in_array($type, $uploadDefinitions) && !$alreadySet) {
|
||||
$alreadySet = true;
|
||||
echo "formAttTypeValues['$category'] = \"true\";\n";
|
||||
}
|
||||
}
|
||||
if (!$alreadySet) {
|
||||
echo "formAttTypeValues['$category'] = \"false\";\n";
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
function showFormType(id) {
|
||||
idDiv = id+'Div';
|
||||
// LATER use nice animations
|
||||
//$(idDiv).hide('fast');
|
||||
// change the content
|
||||
var value = $(id).val(); // get the selected value
|
||||
//$(idDiv).html(formInfoValues[value]); // search in a lookup table
|
||||
|
||||
// do checkbox un/ticked when the document is changed
|
||||
if (formZipTypeValues[value] == "true") {
|
||||
document.getElementById("AttributeMalware").setAttribute("checked", "checked");
|
||||
if (formAttTypeValues[value] == "false") document.getElementById("AttributeMalware").setAttribute("disabled", "disabled");
|
||||
else document.getElementById("AttributeMalware").removeAttribute("disabled");
|
||||
} else {
|
||||
document.getElementById("AttributeMalware").removeAttribute("checked");
|
||||
if (formAttTypeValues[value] == "true") document.getElementById("AttributeMalware").setAttribute("disabled", "disabled");
|
||||
else document.getElementById("AttributeMalware").removeAttribute("disabled");
|
||||
}
|
||||
}
|
||||
|
||||
function showFormInfo(id) {
|
||||
idDiv = id+'Div';
|
||||
// LATER use nice animations
|
||||
//$(idDiv).hide('fast');
|
||||
// change the content
|
||||
var value = $(id).val(); // get the selected value
|
||||
$(idDiv).html(formInfoValues[value]); // search in a lookup table
|
||||
|
||||
// show it again
|
||||
$(idDiv).fadeIn('slow');
|
||||
|
||||
// do checkbox un/ticked when the document is changed
|
||||
if (formZipTypeValues[value] == "true") {
|
||||
document.getElementById("AttributeMalware").setAttribute("checked", "checked");
|
||||
if (formAttTypeValues[value] == "false") document.getElementById("AttributeMalware").setAttribute("disabled", "disabled");
|
||||
else document.getElementById("AttributeMalware").removeAttribute("disabled");
|
||||
} else {
|
||||
document.getElementById("AttributeMalware").removeAttribute("checked");
|
||||
if (formAttTypeValues[value] == "true") document.getElementById("AttributeMalware").setAttribute("disabled", "disabled");
|
||||
else document.getElementById("AttributeMalware").removeAttribute("disabled");
|
||||
}
|
||||
}
|
||||
|
||||
// hide the formInfo things
|
||||
$('#AttributeTypeDiv').hide();
|
||||
$('#AttributeCategoryDiv').hide();
|
||||
$(function(){
|
||||
// do checkbox un/ticked when the document is ready
|
||||
showFormType("#AttributeCategory");
|
||||
}
|
||||
);
|
||||
|
||||
//hide the formInfo things
|
||||
$('#AttributeDistributionDiv').hide();
|
||||
</script>
|
||||
<div class="attributes form">
|
||||
<?php echo $this->Form->create('Attribute', array('enctype' => 'multipart/form-data','onSubmit' => 'document.getElementById("AttributeMalware").removeAttribute("disabled");'));?>
|
||||
<fieldset>
|
||||
<legend><?php echo __('Add Attachment'); ?></legend>
|
||||
<?php
|
||||
echo $this->Form->hidden('event_id');
|
||||
echo $this->Form->input('category', array('between' => $this->Html->div('forminfo', '', array('id' => 'AttributeCategoryDiv'))));
|
||||
echo $this->Form->file('value', array(
|
||||
'error' => array('escape' => false),
|
||||
));
|
||||
echo $this->Form->input('malware', array(
|
||||
'type' => 'checkbox',
|
||||
'checked' => false,
|
||||
'after' => '<br>Tick this box to neutralize the sample. Every malware sample will be zipped with the password "infected"',
|
||||
));
|
||||
if ('true' == Configure::read('CyDefSIG.sync')) {
|
||||
if ('true' == Configure::read('CyDefSIG.private')) {
|
||||
echo $this->Form->input('distribution', array('label' => 'Distribution', 'selected' => $maxDist,
|
||||
'between' => $this->Html->div('forminfo', '', array('id' => 'AttributeDistributionDiv'))
|
||||
));
|
||||
//'before' => $this->Html->div('forminfo', isset($attrDescriptions['distribution']['formdesc']) ? $attrDescriptions['distribution']['formdesc'] : $attrDescriptions['distribution']['desc']),));
|
||||
} else {
|
||||
echo $this->Form->input('private', array(
|
||||
'before' => $this->Html->div('forminfo', isset($attrDescriptions['private']['formdesc']) ? $attrDescriptions['private']['formdesc'] : $attrDescriptions['private']['desc']),));
|
||||
}
|
||||
}
|
||||
// link an onchange event to the form elements
|
||||
$this->Js->get('#AttributeType')->event('change', 'showFormInfo("#AttributeType")');
|
||||
$this->Js->get('#AttributeCategory')->event('change', 'showFormInfo("#AttributeCategory")');
|
||||
$this->Js->get('#AttributeDistribution')->event('change', 'showFormInfo("#AttributeDistribution")');
|
||||
?>
|
||||
</fieldset>
|
||||
<?php echo $this->Form->end(__('Upload'));?>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<ul>
|
||||
<?php echo $this->element('actions_menu'); ?>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
var formInfoValues = new Array();
|
||||
<?php
|
||||
foreach ($categoryDefinitions as $category => $def) {
|
||||
$info = isset($def['formdesc']) ? $def['formdesc'] : $def['desc'];
|
||||
echo "formInfoValues['$category'] = \"$info\";\n";
|
||||
}
|
||||
foreach ($distributionDescriptions as $type => $def) {
|
||||
$info = isset($def['formdesc']) ? $def['formdesc'] : $def['desc'];
|
||||
echo "formInfoValues['" . addslashes($type) . "'] = \"" . addslashes($info) . "\";\n"; // as we output JS code we need to add slashes
|
||||
}
|
||||
?>
|
||||
|
||||
var formZipTypeValues = new Array();
|
||||
<?php
|
||||
foreach ($categoryDefinitions as $category => $def) {
|
||||
$types = $def['types'];
|
||||
$alreadySet = false;
|
||||
foreach ($types as $type) {
|
||||
if (in_array($type, $zippedDefinitions) && !$alreadySet) {
|
||||
$alreadySet = true;
|
||||
echo "formZipTypeValues['$category'] = \"true\";\n";
|
||||
}
|
||||
}
|
||||
if (!$alreadySet) {
|
||||
echo "formZipTypeValues['$category'] = \"false\";\n";
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
var formAttTypeValues = new Array();
|
||||
<?php
|
||||
foreach ($categoryDefinitions as $category => $def) {
|
||||
$types = $def['types'];
|
||||
$alreadySet = false;
|
||||
foreach ($types as $type) {
|
||||
if (in_array($type, $uploadDefinitions) && !$alreadySet) {
|
||||
$alreadySet = true;
|
||||
echo "formAttTypeValues['$category'] = \"true\";\n";
|
||||
}
|
||||
}
|
||||
if (!$alreadySet) {
|
||||
echo "formAttTypeValues['$category'] = \"false\";\n";
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
function showFormType(id) {
|
||||
idDiv = id+'Div';
|
||||
// LATER use nice animations
|
||||
//$(idDiv).hide('fast');
|
||||
// change the content
|
||||
var value = $(id).val(); // get the selected value
|
||||
//$(idDiv).html(formInfoValues[value]); // search in a lookup table
|
||||
|
||||
// do checkbox un/ticked when the document is changed
|
||||
if (formZipTypeValues[value] == "true") {
|
||||
document.getElementById("AttributeMalware").setAttribute("checked", "checked");
|
||||
if (formAttTypeValues[value] == "false") document.getElementById("AttributeMalware").setAttribute("disabled", "disabled");
|
||||
else document.getElementById("AttributeMalware").removeAttribute("disabled");
|
||||
} else {
|
||||
document.getElementById("AttributeMalware").removeAttribute("checked");
|
||||
if (formAttTypeValues[value] == "true") document.getElementById("AttributeMalware").setAttribute("disabled", "disabled");
|
||||
else document.getElementById("AttributeMalware").removeAttribute("disabled");
|
||||
}
|
||||
}
|
||||
|
||||
function showFormInfo(id) {
|
||||
idDiv = id+'Div';
|
||||
// LATER use nice animations
|
||||
//$(idDiv).hide('fast');
|
||||
// change the content
|
||||
var value = $(id).val(); // get the selected value
|
||||
$(idDiv).html(formInfoValues[value]); // search in a lookup table
|
||||
|
||||
// show it again
|
||||
$(idDiv).fadeIn('slow');
|
||||
|
||||
// do checkbox un/ticked when the document is changed
|
||||
if (formZipTypeValues[value] == "true") {
|
||||
document.getElementById("AttributeMalware").setAttribute("checked", "checked");
|
||||
if (formAttTypeValues[value] == "false") document.getElementById("AttributeMalware").setAttribute("disabled", "disabled");
|
||||
else document.getElementById("AttributeMalware").removeAttribute("disabled");
|
||||
} else {
|
||||
document.getElementById("AttributeMalware").removeAttribute("checked");
|
||||
if (formAttTypeValues[value] == "true") document.getElementById("AttributeMalware").setAttribute("disabled", "disabled");
|
||||
else document.getElementById("AttributeMalware").removeAttribute("disabled");
|
||||
}
|
||||
}
|
||||
|
||||
// hide the formInfo things
|
||||
$('#AttributeTypeDiv').hide();
|
||||
$('#AttributeCategoryDiv').hide();
|
||||
$(function(){
|
||||
// do checkbox un/ticked when the document is ready
|
||||
showFormType("#AttributeCategory");
|
||||
}
|
||||
);
|
||||
|
||||
//hide the formInfo things
|
||||
$('#AttributeDistributionDiv').hide();
|
||||
</script>
|
||||
<?php echo $this->Js->writeBuffer(); // Write cached scripts
|
Loading…
Reference in New Issue