예제 #1
0
 public static function Demo1()
 {
     $body = "return 3 + 3;";
     $docs = "/** This is a function generated by facundo! */";
     $f = new FunctionModel("MyDemoFunction", AccessLevel::AccessPrivate, true, $body);
     $f->SetDocs($docs);
     return $f;
 }
예제 #2
0
 public function insertFunctions($projectID)
 {
     // Authentication check
     $this->_checkSession();
     if (!isset($_POST['submit'])) {
         header('Location: /show/addFunctions');
     }
     // check CSRF token
     $this->_checkCsrf($_POST['token']);
     $errors = array();
     $check = true;
     for ($i = 0; $i < 100 - 1; $i++) {
         $functionName = isset($_POST['functionName']) ? trim($_POST['functionName']) : NULL;
         $functionDesc = isset($_POST['functionDesc']) ? trim($_POST['functionDesc']) : NULL;
         $tech = isset($_POST['tech' . $i . '']) ? trim($_POST['tech' . $i . '']) : NULL;
         if (empty($functionDesc)) {
             $check = false;
             array_push($errors, "Function description is required!");
         }
         if (empty($functionName)) {
             $check = false;
             array_push($errors, "Function name is required!");
         }
         if (!$check) {
             $this->_setView('addFunctions');
             $options = $this->_model->getFunction($projectID);
             $dropdown = $this->_model->getTechniques();
             $projectid = $this->_model->getProjectID($projectID);
             $this->_view->set('projects', $options);
             $this->_view->set('dropdown', $dropdown);
             $this->_view->set('projectID', $projectid);
             $this->_view->set('title', 'Security Knowledge Framework:: Invalid form data!');
             $this->_view->set('menuActiveProject', "class='active'");
             $this->_view->set('menuActiveProjectNew', "class='active'");
             $this->_view->set('errors', $errors);
             $this->_view->set('formData', $_POST);
             return $this->_view->output();
         }
         try {
             $function = new FunctionModel();
             $function->setFunctionName($functionName);
             $function->setFunctionDesc($functionDesc);
             $function->setTech($tech);
             $function->setProjectID($projectID);
             $function->storeFunction();
             $this->_setView('succes');
             $options = $this->_model->getProjectID($projectID);
             $this->_view->set('option', $options);
             $this->_view->set('title', 'Security Knowledge Framework::  Function is stored!');
             $this->_view->set('menuActiveProject', "class='active'");
             $this->_view->set('menuActiveProjectNew', "class='active'");
         } catch (Exception $e) {
             // var_dump($e);
             $this->_setView('addFunctions');
             $this->_view->set('title', 'Security Knowledge Framework:: There was an error saving the data!');
             $this->_view->set('formData', $_POST);
             $this->_view->set('saveError', $e->getMessage());
         }
     }
     //end for
     $this->_setView('succes');
     $options = $this->_model->getProjectID($projectID);
     $this->_view->set('option', $options);
     return $this->_view->output();
 }