viewer.php 845 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. session_start();
  3. $admin = isset($_SESSION['auth']);
  4. require_once('../templates/templates.php');
  5. require_once('../controller/forms.php');
  6. require_once('../controller/validator.php');
  7. require_once('../controller/formparser.php');
  8. require_once('../controller/generateform.php');
  9. Validator::check(['id'],$_GET);
  10. $view_hash = Validator::str($_GET['id']);
  11. $info = getQuestionaireInfo($view_hash,$admin);
  12. if (is_null($info)) {
  13. $template = getTemplate('no_form.html');
  14. echo parseTemplate($template,[]);
  15. exit;
  16. }
  17. $form = ['title'=>$info['title'], 'description' => $info['description']];
  18. $reader = new SourceReader($info['source']);
  19. $parser = new Parser($reader);
  20. $form['questions'] = $parser->parse();
  21. if (boolval($info['active'])) {
  22. $form['id'] = $view_hash;
  23. } else {
  24. $form['id'] = "null";
  25. }
  26. echo generateFormHTML($form);