mirror of https://github.com/MISP/MISP
parent
6124489e2b
commit
3b8f9b9e2b
|
@ -275,52 +275,6 @@ class AppController extends Controller {
|
|||
return false;
|
||||
}
|
||||
|
||||
public function generatePrivate() {
|
||||
$this->generatePrivateForAttributes();
|
||||
$this->generatePrivateForEvents();
|
||||
}
|
||||
|
||||
public function generatePrivateForAttributes() {
|
||||
if (!self::_isSiteAdmin()) throw new NotFoundException();
|
||||
|
||||
$this->loadModel('Attribute');
|
||||
$attributes = $this->Attribute->find('all', array('recursive' => 0));
|
||||
foreach ($attributes as $attribute) {
|
||||
if ($attribute['Attribute']['private']) {
|
||||
$attribute['Attribute']['private'] = true;
|
||||
$attribute['Attribute']['cluster'] = false;
|
||||
$attribute['Attribute']['communitie'] = false;
|
||||
} else {
|
||||
$attribute['Attribute']['private'] = false;
|
||||
$attribute['Attribute']['cluster'] = false;
|
||||
$attribute['Attribute']['communitie'] = false;
|
||||
}
|
||||
$this->Attribute->save($attribute);
|
||||
}
|
||||
}
|
||||
|
||||
public function generatePrivateForEvents() {
|
||||
if (!self::_isSiteAdmin()) throw new NotFoundException();
|
||||
|
||||
$this->loadModel('Event');
|
||||
$events = $this->Event->find('all', array('recursive' => 0));
|
||||
foreach ($events as $event) {
|
||||
if ($event['Event']['private']) {
|
||||
$event['Event']['private'] = true;
|
||||
$event['Event']['cluster'] = false;
|
||||
$event['Event']['communitie'] = false;
|
||||
} else {
|
||||
$event['Event']['private'] = false;
|
||||
$event['Event']['cluster'] = false;
|
||||
$event['Event']['communitie'] = false;
|
||||
}
|
||||
$event['Event']['orgc'] = $event['Event']['org'];
|
||||
$event['Event']['dist_change'] = 0;
|
||||
$event['Event']['analysis'] = 2;
|
||||
$this->Event->save($event);
|
||||
}
|
||||
}
|
||||
|
||||
public function generateCount() {
|
||||
if (!self::_isSiteAdmin()) throw new NotFoundException();
|
||||
// do one SQL query with the counts
|
||||
|
@ -340,61 +294,4 @@ class AppController extends Controller {
|
|||
$this->Session->setFlash(__('All done. attribute_count generated from scratch for ' . $k . ' events.'));
|
||||
$this->redirect(array('controller' => 'pages', 'action' => 'display', 'administration'));
|
||||
}
|
||||
|
||||
/**
|
||||
* CakePHP returns false if filesize is 0 at lib/cake/Utility/File.php:384
|
||||
*/
|
||||
public function checkEmpty($fileP = '/var/www/MISP/app/files/test') {
|
||||
// Check if there were problems with the file upload
|
||||
// only keep the last part of the filename, this should prevent directory attacks
|
||||
$filename = basename($fileP);
|
||||
$tmpfile = new File($fileP);
|
||||
|
||||
debug($fileP);
|
||||
debug($tmpfile);
|
||||
debug($tmpfile->size());
|
||||
debug($tmpfile->md5());
|
||||
debug(md5_file($fileP));
|
||||
$md5 = !$tmpfile->size() ? md5_file($fileP) : $tmpfile->md5();
|
||||
debug($md5);
|
||||
}
|
||||
|
||||
/**
|
||||
* generateAllFor<FieldName>
|
||||
*
|
||||
* @throws NotFoundException // TODO Exception
|
||||
**/
|
||||
public function generateAllFor($field) {
|
||||
if (!self::_isSiteAdmin()) throw new NotFoundException();
|
||||
|
||||
// contain the newValue and oldValue
|
||||
$methodArgs = $this->params['pass'];
|
||||
// use call_user_func_array() to pass the newValue and oldValue
|
||||
$success = call_user_func_array(array($this->{$this->defaultModel}, 'generateAllFor' . $field), $methodArgs);
|
||||
|
||||
// give feedback
|
||||
$this->set('succes', $success);
|
||||
$this->render('succes');
|
||||
}
|
||||
|
||||
public function call($method, $dummySecond) {
|
||||
$this->__call($method, $dummySecond);
|
||||
}
|
||||
|
||||
public function __call($method, $dummySecond) {
|
||||
$args = $this->params['pass']; // TODO this is naughty
|
||||
if (strpos($method, 'generateAllFor') === 0) {
|
||||
// massage the args
|
||||
$methodArgs = $args;
|
||||
$methodArgs[0] = str_replace('generateAllFor', '', $method); // TODO
|
||||
//array_unshift($methodArgs, str_replace('generateAllFor', '', $method));
|
||||
// do the actual call
|
||||
return call_user_func_array(array($this, 'generateAllFor'), $methodArgs);
|
||||
}
|
||||
|
||||
//if (strpos($method, 'findBy') === 0) {
|
||||
// //debug(true);debug(tru);
|
||||
//}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -578,26 +578,6 @@ class UsersController extends AppController {
|
|||
return $result;
|
||||
}
|
||||
|
||||
public function setRoleId($fk = '2') { // TODO generateAllFor<FieldName>
|
||||
$params = array(
|
||||
'conditions' => array('User.role_id' => ''),
|
||||
'recursive' => 0,
|
||||
'fields' => array('User.id'),
|
||||
);
|
||||
$users = $this->User->find('all', $params);
|
||||
foreach ($users as $user) {
|
||||
$this->User->id = $user['User']['id'];
|
||||
$this->User->saveField('role_id', $fk);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* generateAllFor<FieldName>
|
||||
**/
|
||||
public function generateAllFor($field) {
|
||||
parent::generateAllFor($field);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws NotFoundException
|
||||
**/
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
<?php
|
||||
|
||||
App::uses('AppController', 'Controller');
|
||||
|
||||
/**
|
||||
* WorkerLogs Controller
|
||||
*
|
||||
* @property WorkerLog $WorkerLog
|
||||
*/
|
||||
class WorkerLogsController extends AppController {
|
||||
public function beforeFilter() {
|
||||
parent::beforeFilter();
|
||||
}
|
||||
|
||||
public function index() {
|
||||
$this->recursive = 0;
|
||||
$this->set('list', $this->paginate());
|
||||
}
|
||||
|
||||
public function add() {
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue