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']); } } }
<?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');
<?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); }
<?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'); }
<?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);