Example #1
0
 public function run()
 {
     if ($this->em == null) {
         $doctrineFactory = new \model\Access();
         $this->em = $doctrineFactory->getEntityManager();
     }
     $this->businessUser = new \business\User();
     $this->businessPermission = new \business\Permission();
     $userRepo = $this->em->getRepository('model\\entities\\User');
     if (isset($_SESSION['active'])) {
         $this->self = $userRepo->find($_SESSION['userid']);
         if (isset($_SESSION['realUserId'])) {
             $this->realSelf = $userRepo->find($_SESSION['realUserId']);
         }
     }
 }
Example #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();
$userRepo = $em->getRepository('model\\entities\\User');
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');
Example #3
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();
$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');
}
Example #4
0
<?php

$home = implode(DIRECTORY_SEPARATOR, array_slice(explode(DIRECTORY_SEPARATOR, $_SERVER["SCRIPT_FILENAME"]), 0, -3)) . '/';
require_once $home . 'components/system/Preload.php';
$doctrineFactory = new \model\Access();
$em = $doctrineFactory->getEntityManager();
$userRepo = $em->getRepository('model\\entities\\User');
if (!$_SESSION['active']) {
    throw new \backbone\RedirectBrowserException(APPLICATION_ROOT_URL . 'index.php?code=2');
} elseif ($_SESSION['roleid'] > 1) {
    throw new \backbone\RedirectBrowserException(APPLICATION_ROOT_URL . 'index.php?code=2');
}
$self = $userRepo->find($_SESSION['userid']);
$uid = isset($_GET['uid']) ? $_GET['uid'] : null;
if ($uid) {
    $user = $userRepo->find($uid);
} else {
    $user = false;
}
if ($_SESSION['roleid'] == 1) {
    $em->remove($user);
    $em->flush();
    throw new \backbone\RedirectBrowserException(APPLICATION_ROOT_URL . 'users.php?code=3');
} else {
    throw new \backbone\RedirectBrowserException(APPLICATION_ROOT_URL . 'index.php?code=2');
}
Example #5
0
<?php

$home = implode(DIRECTORY_SEPARATOR, array_slice(explode(DIRECTORY_SEPARATOR, __FILE__), 0, -3)) . '/';
require_once $home . 'components/system/Preload.php';
$acc = new \model\Access();
$auth = new \business\Authentication($acc->getEntityManager());
$password = isset($_POST['password']) ? $_POST['password'] : null;
$identity = isset($_POST['email']) ? $_POST['email'] : null;
if ($password != null && $identity != null) {
    $tmp = $auth->validateCredentials($identity, $password);
    if ($tmp) {
        $_SESSION['active'] = true;
        $_SESSION['roleid'] = $tmp->getAuthentication()->getRole()->getId();
        $_SESSION['userid'] = $tmp->getId();
        throw new \backbone\RedirectBrowserException(APPLICATION_ROOT_URL . 'home.php?code=0');
    } else {
        throw new \backbone\RedirectBrowserException(APPLICATION_ROOT_URL . 'index.php?code=1&email=' . $identity);
    }
} else {
    throw new \backbone\RedirectBrowserException(APPLICATION_ROOT_URL . 'index.php?code=0&email=' . $identity);
}
Example #6
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();
$businessAuth = new \business\Authentication($em);
$businessQl = new \business\QuickLogin($em);
$userRepo = $em->getRepository('model\\entities\\User');
$roleRepo = $em->getRepository('model\\entities\\Role');
$authRepo = $em->getRepository('model\\entities\\Authentication');
$qlRepo = $em->getRepository('model\\entities\\QuickLogin');
$mail = new \utilities\SwiftMailLoader();
$password = isset($_POST['password']) ? $_POST['password'] : null;
$vp = isset($_POST['vpass']) ? $_POST['vpass'] : null;
$data['email'] = isset($_POST['email']) ? $_POST['email'] : null;
$data['vemail'] = isset($_POST['vemail']) ? $_POST['vemail'] : null;
$data['fname'] = isset($_POST['fname']) ? $_POST['fname'] : null;
$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();
Example #7
0
<?php

require_once 'components/system/Preload.php';
$allowed = array(1 => 'Admin');
$page = new \render\Page("Menus", 'menus', $allowed);
$tmpl = new \backbone\Template();
$doctrineFactory = new \model\Access();
$menuRepo = $doctrineFactory->getEntityManager()->getRepository('model\\entities\\Menu');
$page->run();
$tmpl->user = $tmpl->control = $tmpl->data = new \stdClass();
$tmpl->user->self = $page->self;
$tmpl->control->action = isset($_GET['action']) ? $_GET['action'] : null;
$tmpl->control->code = isset($_GET['code']) ? $_GET['code'] : -1;
$tmpl->data->menus = $menuRepo->findAll();
$tmpl->data->permit = new \business\Permission();
switch ($tmpl->control->code) {
    case 0:
        // filler error
        $tmpl->control->alert['type'] = "error";
        $tmpl->control->alert['message'] = "I'm sorry Dave, I can't let you do that.";
        break;
    default:
        break;
}
$html = $tmpl->build('menus.html');
$css = $tmpl->build('menus.css');
$js = $tmpl->build('menus.js');
$appContent = array('html' => $html, 'css' => array('code' => $css, 'link' => 'menus'), 'js' => array('code' => $js, 'link' => 'menus'));
echo $page->build($appContent);