예제 #1
0
파일: recover.php 프로젝트: rockerest/nox
$home = implode(DIRECTORY_SEPARATOR, array_slice(explode(DIRECTORY_SEPARATOR, $_SERVER["SCRIPT_FILENAME"]), 0, -3)) . '/';
require_once $home . 'components/system/Preload.php';
$acc = new \model\Access();
$em = $acc->getEntityManager();
$authRepo = $em->getRepository('model\\entities\\Authentication');
$businessQl = new \business\QuickLogin($em);
$mail = new \utilities\SwiftMailLoader();
$email = isset($_GET['email']) ? $_GET['email'] : null;
if ($email) {
    $auth = $authRepo->findOneBy(array('identity' => $email));
    if ($auth) {
        $user = $auth->getUser();
        if ($user) {
            $auth->setResetPassword(1);
            $ql = new \model\entities\QuickLogin();
            $ql->setHash($businessQl->createHash($auth->getIdentity()))->setUser($user);
            $acc->persistFlushRefresh($ql);
            //load email template
            ob_start();
            include $home . 'components/templates/account_recover.html';
            $body = ob_get_clean();
            $subject = "Nox System Account Recovery";
            $to = $user->getContacts()[0]->getEmail();
            $from = '*****@*****.**';
            $message = $mail->newMessage($subject, $body, 'text/html')->setTo($to)->setFrom($from);
            //strip HTML and format to be at least readable.
            $plain = strip_tags(preg_replace('#(</p>)|(<br />)|(<br/>)#i', "\n", preg_replace("#<a href=[\"|'](.*?)[\"|'].*?>(.*?)</a>#i", "\$2 \$1", $body)));
            $message->addPart($plain, 'text/plain');
            if ($mail->sendMessage($message)) {
                //redirect to login
예제 #2
0
<?php

$home = implode(DIRECTORY_SEPARATOR, array_slice(explode(DIRECTORY_SEPARATOR, $_SERVER["SCRIPT_FILENAME"]), 0, -3)) . '/';
require_once $home . 'components/system/Preload.php';
$acc = new \model\Access();
$em = $acc->getEntityManager();
$qlBusiness = new \business\QuickLogin($em);
$userRepo = $em->getRepository('model\\entities\\User');
$qlRepo = $em->getRepository('model\\entities\\QuickLogin');
$mail = new \utilities\SwiftMailLoader();
$userid = isset($_GET['uid']) ? $_GET['uid'] : null;
$user = $userRepo->find($userid);
$self = $userRepo->find($_SESSION['userid']);
if ($self->getAuthentication()->getRole()->getId() == 1 && $user) {
    //create login hash
    $ql = new \model\entities\QuickLogin();
    $ql->setHash($qlBusiness->createHash($user->getAuthentication()->getIdentity()))->setUser($user);
    $ql = $acc->persistFlushRefresh($ql);
    //load email template
    ob_start();
    include $home . 'components/templates/account_create.html';
    $body = ob_get_clean();
    $subject = 'Nox System Email Verification';
    $to = $user->getContacts()[0]->getEmail();
    $from = '*****@*****.**';
    $message = $mail->newMessage($subject, $body, 'text/html')->setTo($to)->setFrom($from);
    //strip HTML and format to be at least readable.
    $plain = strip_tags(preg_replace('#(</p>)|(<br />)|(<br/>)#i', "\n", preg_replace("#<a href=[\"|'](.*?)[\"|'].*?>(.*?)</a>#i", "\$2 \$1", $body)));
    $message->addPart($plain, 'text/plain');
    if ($mail->sendMessage($message)) {
        //redirect to user management
예제 #3
0
파일: create.php 프로젝트: rockerest/nox
$data['lname'] = isset($_POST['lname']) ? $_POST['lname'] : null;
if ($password == $vp && $data['email'] == $data['vemail'] && $password != null && $data['email'] != null) {
    if ($businessAuth->isIdentityFree($data['email'])) {
        //create user
        $user = new \model\entities\User();
        $user->setFname($data['fname'])->setLname($data['lname']);
        $em->persist($user);
        $contact = new \model\entities\Contact();
        $contact->setEmail($data['email'])->setUser($user);
        $em->persist($contact);
        $role = $roleRepo->find(2);
        $salt = $businessAuth->generateSalt();
        $auth = new \model\entities\Authentication();
        $auth->setIdentity($data['email'])->setPassword($businessAuth->createPassword($salt, $password))->setSalt($salt)->setUser($user)->setRole($role);
        $em->persist($auth);
        $ql = new \model\entities\QuickLogin();
        $ql->setHash($businessQl->createHash($auth->getIdentity()))->setUser($user);
        $em->persist($ql);
        $em->flush();
        $em->refresh($ql);
        $em->refresh($user);
        //load email template
        ob_start();
        include $home . 'components/templates/account_create.html';
        $body = ob_get_clean();
        $subject = 'Nox System Email Verification';
        $to = $user->getContacts()[0]->getEmail();
        $from = '*****@*****.**';
        $message = $mail->newMessage($subject, $body, 'text/html')->setTo($to)->setFrom($from);
        //strip HTML and format to be at least readable.
        $plain = strip_tags(preg_replace('#(</p>)|(<br />)|(<br/>)#i', "\n", preg_replace("#<a href=[\"|'](.*?)[\"|'].*?>(.*?)</a>#i", "\$2 \$1", $body)));