public function execute($args = null) { if (!empty($_POST)) { $_POST['id'] = null; $_POST['hash'] = ServiceAuth::createHash($_POST['pass1']); $_POST['inBounds'] = 0; $_POST['outBounds'] = 0; $u = ModelUser::newInstance()->hydrate($_POST); $p = ModelProfile::newInstance(); if ($_POST['pass1'] != $_POST['pass2']) { ServiceMessage::getInstance()->addMessage('Les mots de passes ne correspondent pas', 'error'); } elseif (CollectionUser::newInstance()->findBy('login', $_POST['login'])) { ServiceMessage::getInstance()->addMessage('Ce login est déjà utilisé', 'error'); } else { if (ServiceDb::getInstance()->persist($u)) { if ($i = ServiceDb::getInstance()->lastInsertId()) { if (ServiceDb::getInstance()->persist($p->hydrate(array('user_id' => $i)))) { ServiceMessage::getInstance()->addMessage('Votre compte a bien été créé', 'success'); ServiceDb::getInstance()->persist(ModelAction::newInstance()->setUser_id($i)->setType('create')->setObject('profile')->setWhen()); return header('Location: /logout/quiet'); } else { ServiceDb::getInstance()->delete($u); ServiceMessage::getInstance()->addMessage('Une erreur est survenue #2', 'error'); } } else { ServiceMessage::getInstance()->addMessage('Une erreur est survenue #1', 'error'); } } } } ServiceRenderHtml::newInstance()->load('subscribe')->setData('hideNavigation', true)->render(); }
public function execute($args = null) { if (!ServiceAuth::getInstance()->isAuth()) { header('Location: /login'); } else { if (empty($_POST)) { return ServiceRenderHtml::newInstance()->load('search')->render(); } $res = array(); if (isset($_POST['search1'])) { $res = CollectionProfile::newInstance()->findByWithUser('prog', $_POST['prog']); } elseif (isset($_POST['search2'])) { $res = CollectionProfile::newInstance()->findByWithUser(array('prog', 'semester'), array($_POST['prog'], $_POST['semester'])); } elseif (isset($_POST['search3'])) { $res = CollectionProfile::newInstance()->findByWithUser('sex', $_POST['sex']); } elseif (isset($_POST['search4'])) { $resx = CollectionUser_has_user::newInstance()->findByWithUserLoose('user_id1', ServiceAuth::getInstance()->getUser()->getId()); foreach ($resx as $v) { $res[] = $v->getUser2(); } } elseif (isset($_POST['search5'])) { $res = CollectionProfile::newInstance()->findAllWithUser(); } else { return ControllerError::newInstance()->execute($args); } $_SESSION['search'] = $res; header('Location: /search/result'); } }
public function execute($args = null) { if (!ServiceAuth::getInstance()->isAdmin()) { return header('Location: /admin/login'); } ServiceRenderHtml::newInstance()->load('admin/home')->render(); }
public function execute($args = null) { if (!ServiceAuth::getInstance()->isAdmin()) { return header('Location: /admin/login'); } ServiceRenderHtml::newInstance()->load('admin/stats')->setData('res1', CollectionAction::newInstance()->countDesc())->setData('res2', CollectionUser::newInstance()->findAllWithReputation())->setData('res3', CollectionUser_has_user::newInstance()->findAllCoworkers())->render(); }
public function execute($args = null) { $p = ServiceRenderHtml::newInstance()->load('lost')->setData('page', $args)->setData('hideMessages', true); if (!ServiceAuth::getInstance()->isAuth()) { $p->setData('hideNavigation', true); } $p->render(); }
public function execute($args = null) { if (!ServiceAuth::getInstance()->isAdmin()) { return header('Location: /admin/login'); } $res = CollectionAction::newInstance()->findAll(); rsort($res); ServiceRenderHtml::newInstance()->load('admin/logs')->setData('res', $res)->render(); }
public function execute($args = null) { if (!ServiceAuth::getInstance()->isAuth()) { header('Location: /login'); } else { if (isset($_SESSION['search'])) { $p = ServiceRenderHtml::newInstance()->load('search_result')->setData('result', $_SESSION['search'])->render(); } else { header('Location: /search'); } } }
public function execute($args = null) { if (ServiceAuth::getInstance()->isAdmin()) { die(header('Location: /admin')); } if (!empty($_POST)) { if (ServiceAuth::getInstance()->adminAuth($_POST['password'])) { ServiceMessage::getInstance()->addMessage('Vous avez bien été connecté', 'success'); header('Location: /admin'); return; } else { ServiceMessage::getInstance()->addMessage('Mauvaise mot de passe', 'error'); } } ServiceRenderHtml::newInstance()->load('admin/login')->setData('hideNavigation', true)->render(); }
public function execute($args = null) { if (!ServiceAuth::getInstance()->isAuth()) { header('Location: /login'); } else { $p = ServiceRenderHtml::newInstance()->load('profile')->setData('user', ServiceAuth::getInstance()->getUser())->setData('guest', false); if ($q = $this->getQueryNext()) { if ($q != ServiceAuth::getInstance()->getUser()->getLogin()) { if ($user = CollectionUser::newInstance()->findBy('login', $q)) { $p->setData('user', $user)->setData('guest', true); } else { $p->load('profile_not_found'); } } } $p->render(); } }
public function execute($args = null) { if (ServiceAuth::getInstance()->isAuth()) { die(header('Location: /home')); } elseif (ServiceAuth::getInstance()->isAdmin()) { die(header('Location: /admin')); } if (!empty($_POST)) { if (ServiceAuth::getInstance()->regularAuth($_POST['login'], $_POST['password'])) { if (isset($_POST['remember_me'])) { setcookie('login', ServiceAuth::getInstance()->getUser()->getLogin(), time() + 3600 * 24 * 365); setcookie('hash', ServiceAuth::getInstance()->getUser()->gethash(), time() + 3600 * 24 * 365); } ServiceMessage::getInstance()->addMessage('Vous avez bien été connecté', 'success'); header('Location: /home'); return; } else { ServiceMessage::getInstance()->addMessage('Mauvaise combinaison', 'error'); } } ServiceRenderHtml::newInstance()->load('login')->setData('hideNavigation', true)->render(); }
public function execute($args = null) { ServiceRenderHtml::newInstance()->load('chuck')->render(); }