Example #1
0
 public function __construct()
 {
     app_controller::$err = new errors_collector();
     $connection = new database_connect();
     app_controller::$db = $connection->getDb();
     app_controller::$strcln = new security_sqlinj();
     $pollGetter = new database_getpolls();
     $pollsData = $pollGetter->queryPolls(app_controller::$db);
     if (!$pollsData) {
         app_controller::$err->add('could_not_get_poll_data');
         return;
     }
     $pollPrinter = new printing_printoutpolls();
     if (isset($_POST['make_poll'])) {
         if (ADMIN_CAN_MAKE_POLLS) {
             if ($_SESSION[SESSION_ADMIN] == ADMIN_DECLARATION) {
                 $this->makeNewPoll();
             }
         } else {
             $this->makeNewPoll();
         }
     }
     if (isset($_POST['poll_id'])) {
         $this->getPostPollId();
     }
     if (isset($_GET['poll_id'])) {
         app_controller::$poll_id = app_controller::$strcln->esc($_GET['poll_id']);
     }
     //echo app_controller::$poll_id;
     if (isset(app_controller::$poll_id) && isset($_SESSION[SESSION_EMAIL]) && app_controller::$poll_id != null) {
         new app_pollpage();
     } else {
         $pollPrinter->printPoll($pollsData);
         if (ADMIN_CAN_MAKE_POLLS) {
             if ($_SESSION[SESSION_ADMIN] == ADMIN_DECLARATION) {
                 new printing_pollform();
             }
         } else {
             new printing_pollform();
         }
     }
     print_r(app_controller::$err->getErrors());
 }