コード例 #1
0
ファイル: verify.php プロジェクト: rockerest/nox
<?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();
$userRepo = $em->getRepository('model\\entities\\User');
$qlRepo = $em->getRepository('model\\entities\\QuickLogin');
$code = isset($_GET['code']) ? $_GET['code'] : null;
if ($code) {
    $ql = $qlRepo->findOneBy(array('hash' => $code));
    if ($ql) {
        $user = $ql->getUser();
        $auth = $user->getAuthentication();
        $auth->setDisabled(0);
        $_SESSION['active'] = true;
        $_SESSION['roleid'] = $user->getAuthentication()->getRole()->getId();
        $_SESSION['userid'] = $user->getId();
        $ql->setUsed(1);
        $acc->persistFlushRefresh($auth);
        $acc->persistFlushRefresh($ql);
        throw new \backbone\RedirectBrowserException(APPLICATION_ROOT_URL . 'home.php?code=0');
    } else {
        throw new \backbone\RedirectBrowserException(APPLICATION_ROOT_URL . 'index.php?code=9');
    }
} else {
    throw new \backbone\RedirectBrowserException(APPLICATION_ROOT_URL . 'index.php?code=9');
}
コード例 #2
0
ファイル: toggleAccount.php プロジェクト: rockerest/nox
if (!$_SESSION['active']) {
    throw new \backbone\RedirectBrowserException(APPLICATION_ROOT_URL . 'index.php?code=2');
}
$self = $userRepo->find($_SESSION['userid']);
$uid = isset($_GET['uid']) ? $_GET['uid'] : null;
$tb = isset($_GET['tb']) ? $_GET['tb'] : null;
if ($uid) {
    $user = $userRepo->find($uid);
} else {
    $user = false;
}
if ($self == $user || $_SESSION['roleid'] < 3) {
    $auth = $user->getAuthentication();
    if ($auth->getDisabled()) {
        $auth->setDisabled(0);
        if ($acc->persistFlushRefresh($auth)) {
            throw new \backbone\RedirectBrowserException(APPLICATION_ROOT_URL . 'users.php?code=6');
        } else {
            throw new \backbone\RedirectBrowserException(APPLICATION_ROOT_URL . 'users.php?code=8');
        }
    } else {
        $auth->setDisabled(1);
        if ($acc->persistFlushRefresh($auth)) {
            throw new \backbone\RedirectBrowserException(APPLICATION_ROOT_URL . 'users.php?code=5');
        } else {
            throw new \backbone\RedirectBrowserException(APPLICATION_ROOT_URL . 'users.php?code=7');
        }
    }
} else {
    throw new \backbone\RedirectBrowserException(APPLICATION_ROOT_URL . 'index.php?code=2');
}
コード例 #3
0
ファイル: resendVerification.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();
$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
        throw new \backbone\RedirectBrowserException(APPLICATION_ROOT_URL . 'users.php?code=19');
    } else {