示例#1
0
 public function claimpost()
 {
     $f3 = \Base::instance();
     if ($f3->get('user')) {
         if ($f3->get('user')['rank'] == 1) {
             new Notification('You cannot claim an invite while logged in.', 'danger', true);
             $f3->reroute('/dashboard');
             return;
         }
     }
     $key = $f3->get('PARAMS.invite');
     if (\Helpers\Invites::isValidKey($key)) {
         if ($f3->get('POST.register-password') != $f3->get('POST.register-password-verify')) {
             $f3->set('errors', ['Password verify must match the first password.']);
         } else {
             $user = User::createUser(array('name' => $f3->get("POST.register-name"), 'username' => $f3->get("POST.register-username"), 'email' => $f3->get("POST.register-email"), 'password' => $f3->get("POST.register-password")));
             // Data missing
             if ($user == false) {
                 $f3->set('errors', ['Some information has not been entered correctly or is not long enough.']);
             } elseif (is_array($user)) {
                 $f3->set('errors', $user);
             } else {
                 $f3->set('SESSION.id', $user->id);
                 // Delete the key
                 \Helpers\Invites::deleteInvite($key);
                 // Send a mail
                 $f3->set('tplData', ['name' => $f3->get("POST.register-username")]);
                 SendingAPI::send(['mailTo' => $f3->get("POST.register-email"), 'mailSubject' => 'Thank you for registering on SquareMS !', 'mailContents' => ['html' => \Template::instance()->render('mails/register.html'), 'text' => "Thank you for registering on SquareMS ! \n" . "You can access your account now on https://squarems.net/ ! \n\n" . "Please do not respond to this email, it is sent by an automated system."]]);
                 $f3->reroute("/dashboard");
                 return;
             }
         }
         $f3->set('css', array('/static/css/auth.css'));
         $f3->set('target', 'invite.html');
         $this->_render('base.html');
     } else {
         $f3->error(404);
     }
 }
示例#2
0
 /**
  * Controller made to launch temporary tests
  */
 public function tests()
 {
     echo 'tests';
     $f3 = \Base::instance();
     $sendgrid = new \SendGrid('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');
     $emails = explode("\n", file_get_contents('app/controllers/emails.txt'));
     //$emails = array('*****@*****.**', '*****@*****.**');
     foreach ($emails as $email) {
         $mail = new \SendGrid\Email();
         $mail->addTo($email)->setFrom('*****@*****.**')->setSubject('Lunch')->setHtml(\Template::instance()->render('mail.html'));
         try {
             $sendgrid->send($mail);
             echo "Mail to (sha1 of the email) " . sha1($email) . " sent !<br />\n";
         } catch (\SendGrid\Exception $e) {
             echo $e->getCode();
             foreach ($e->getErrors() as $er) {
                 echo $er;
             }
         }
     }
     /*$email = new \SendGrid\Email();
             $email
                 ->addTo('*****@*****.**')
                 ->setFrom('*****@*****.**')
                 ->setSubject('Subject goes here')
                 ->setText('Hello World!')
                 ->setHtml('<strong>Hello World!</strong>')
             ;
     
             try {
                 $sendgrid->send($email);
                 echo 'Mail sent !';
             } catch(\SendGrid\Exception $e) {
                 echo $e->getCode();
                 foreach($e->getErrors() as $er) {
                     echo $er;
                 }
             }*/
 }