Exemplo n.º 1
0
 public function index()
 {
     if (!isset($_GET['code'])) {
         header("Location: ../sign-in/index");
         exit;
     }
     $testActivation = \Models\User::getUsernameByActivationCode($_GET['code']);
     if (!isset($testActivation['username'])) {
         echo \Core\View::make('header', ['title' => 'Activation unsuccessful']);
         echo \Core\View::make('activation.bad');
         echo \Core\View::make('footer');
     } else {
         $date = date('Y-m-d H:i:s');
         $user = \Models\User::setUserActivatedAt($date, $_GET['code']);
         if (isset($user['id'])) {
             $subject = 'Welcome';
             $body = "Congratulations. Your account is activated.";
             $result = Mailer::send($user['email'], $subject, $body);
             if ($result == 'Message has been sent') {
                 echo \Core\View::make('header');
                 echo \Core\View::make('activation.good', ['title' => 'Activation successful']);
                 echo \Core\View::make('footer');
             }
         }
     }
 }
Exemplo n.º 2
0
 public function activation()
 {
     $code = \Models\User::getActivationCode($_POST['input']['username']);
     $subject = 'Activation code';
     $body = "<a href='" . "test-task.dev/activation/index?code={$code['activation_code']}" . "'>Follow to finish registration</a>";
     $result = \Core\Mailer::send($_POST['input']['email'], $subject, $body);
     return $result;
 }
Exemplo n.º 3
0
 public function ajaxCheckUserEmailForRecovery()
 {
     if (isset($_POST['email'])) {
         $user = \Models\User::getUserByEmail($_POST['email']);
         if (!isset($user['id'])) {
             echo "This email is not registrated.";
         } else {
             $password = rand(100000, 999999);
             $data = \Models\User::changePassword($user['id'], sha1($password));
             if (isset($data['id'])) {
                 $subject = 'Password confirmation';
                 $body = "Your temporary password is: " . $password . " Please, change it after authentication in your profile.";
                 $result = Mailer::send($user['email'], $subject, $body);
                 if ($result == 'Message has been sent') {
                     echo $result;
                 }
             }
         }
     }
 }
 public function addRequestAction(Request $request)
 {
     if (($email = $request->post('email')) === null || ($name = $request->post('name')) === null || ($phone = $request->post('phone')) === null) {
         return $this->errorJSONResponse('Не определён один из параметров');
     }
     if ((new EmailValidator())->validate($email) === false) {
         return $this->errorJSONResponse('Не верный email. Email должен быть вида example@example.com');
     }
     if ((new PhoneValidator())->validate($phone) === false) {
         return $this->errorJSONResponse('Не верный телефон. Email должен быть вида +7(123)456-78-90');
     }
     if ((new StringValidator())->validate($name) === false) {
         return $this->errorJSONResponse('Имя не может быть пустым или больше 50 символов');
     }
     $subscriber = Subscribers::getOne(['email' => $email]);
     if ($subscriber === false) {
         $subscriber = new Subscribers();
         $subscriber->email = $email;
     }
     $subscriber->name = $name;
     $subscriber->phone = $phone;
     $subscriber->source = isset($_GET['utm_source']) ? $_GET['utm_source'] : (isset($_COOKIE['utm_source']) ? $_COOKIE['utm_source'] : '');
     $mailer = new Mailer();
     $mailer->setFrom('*****@*****.**', 'Поддержка Amethyst Web Studio');
     $mailer->addAddress($subscriber->email, $subscriber->name);
     $mailer->Subject = 'Спасибо за заявку.';
     $mailer->Body = '<html>
                         <head>
                             <meta charset="utf-8">
                         </head>
                         <body>
                             <h1>Здравствуйте, уважаемый, ' . $subscriber->name . '!</h1>
                             <p>Спасибо за оставленную заявку на нашем сайте. В ближайшее время с Вами свяжется наш представитель, и вы сможете обсудить с ним все детали касательно разработки Вашего сайта.</p>
                             <p>Спасибо за проявленный интерес к нашей Веб студии</p>
                             </br></br>
                             <p>С наилучшими пожеланиями технический директор Amethyst Web Studio, Лещёв Никита.</p>
                             <p>Если вдруг сотрудник с Вами не связался, напишите лично мне: <a href="mailto:nikita@amethyst-ws.ru">nikita@amethyst-ws.ru</a></p>
                         </body>
                     </html>';
     $mailer->AltBody = 'Здравствуйте, уважаемый, ' . $subscriber->name . '! Спасибо за оставленную заявку на нашем сайте.
                         В ближайшее время с Вами свяжется наш представитель, и вы сможете обсудить с ним все детали касательно разработки Вашего сайта.
                         Спасибо за проявленный интерес к нашей Веб студии.
                         С наилучшими пожеланиями технический директор Amethyst Web Studio, Лещёв Никита.
                         Если вдруг сотрудник с Вами не связался, напишите лично мне: nikita@amethyst-ws.ru';
     $clientMailSent = $mailer->send();
     if ($clientMailSent && $subscriber->save()) {
         $ourMailer = new Mailer();
         $ourMailer->setFrom('*****@*****.**', 'Поддержка Amethyst Web Studio');
         $ourMailer->addAddress('*****@*****.**');
         $ourMailer->addAddress('*****@*****.**');
         $ourMailer->Subject = 'Новый лид с сайта.';
         $ourMailer->Body = '<html>
                                 <head>
                                     <meta charset="utf-8">
                                 </head>
                                 <body>
                                     <p>У нас новая заявка:</p>
                                     <p>Имя: ' . $subscriber->name . '</p>
                                     <p>Телефон: <a href="tel:' . $subscriber->phone . '">' . $subscriber->phone . '</a></p>
                                     <p>Почта: <a href="mailto: ' . $subscriber->email . '">' . $subscriber->email . '</a></p>
                                 </body>
                             </html>';
         $ourMailer->AltBody = '';
         $ourMailer->send();
         return $this->successJSONResponse('Заявка успешно оформлена! В ближайшее время с Вами свяжется наш менеджер!');
     } else {
         return $this->successJSONResponse('Не удалось оформить заявку! Попробуйте позже.');
     }
 }