public function action_submit()
 {
     // check CSRF token
     $token = new Token();
     if (!$token->validate('attribute_form_' . $this->bID, $this->post('_token'))) {
         throw new \Exception('Invalid token');
     }
     // get objects
     $aftID = $this->post('aftID');
     $aft = AttributeFormType::getByID($aftID);
     // create new form entry
     $af = AttributeForm::add(['aftID' => $aftID]);
     // get all attributes of type and save values from form to the database
     $attributes = $aft->getAttributeObjects();
     foreach ($attributes as $akID => $ak) {
         $af->setAttribute($ak, false);
     }
     // check SPAM
     $submittedData = $af->getAttributeDataString();
     $antispam = Core::make('helper/validation/antispam');
     if (!$antispam->check($submittedData, 'attribute_form')) {
         if ($aft->getDeleteSpam()) {
             $af->delete();
         } else {
             $af->markAsSpam();
         }
     }
 }
Example #2
0
 public function handle_register($token = null)
 {
     /** @var FlashBagInterface $flashbag */
     $flashbag = \Session::getFlashBag();
     $this->firstName = array_shift($flashbag->peek('firstname'));
     $this->lastName = array_shift($flashbag->peek('lastName'));
     $this->username = array_shift($flashbag->peek('username'));
     $this->token = array_shift($flashbag->peek('token'));
     $token_helper = new Token();
     if (!$token_helper->validate('twitter_register', $token) && !$token_helper->validate('twitter_register') || !$this->token) {
         $this->redirect('/login/');
         exit;
     }
     if (\Request::request('uEmail', false)) {
         $this->email = \Request::request('uEmail');
         $user = $this->createUser();
         if ($user && !$user->isError()) {
             $this->completeAuthentication($user);
         }
     }
     $this->set('username', $this->username);
     $this->set('show_email', true);
 }