public function authControl() { $this->app_session->logout(); $controller = new DashboardController(true); $controller->addSuccessMessage("You have successfully logged out."); return $controller->go(); }
public function control() { $this->setPageTitle('Log in'); $this->setViewTemplate('session.login.tpl'); $this->view_mgr->addHelp('login', 'userguide/accounts/index'); $this->disableCaching(); //don't show login form if already logged in if ($this->isLoggedIn()) { $controller = new DashboardController(true); return $controller->go(); } else { $owner_dao = DAOFactory::getDAO('OwnerDAO'); if (isset($_POST['Submit']) && $_POST['Submit'] == 'Log In' && isset($_POST['email']) && isset($_POST['pwd'])) { if ($_POST['email'] == '' || $_POST['pwd'] == '') { if ($_POST['email'] == '') { $this->addErrorMessage("Email must not be empty"); return $this->generateView(); } else { $this->addErrorMessage("Password must not be empty"); return $this->generateView(); } } else { $session = new Session(); $user_email = $_POST['email']; if (get_magic_quotes_gpc()) { $user_email = stripslashes($user_email); } $this->addToView('email', $user_email); $owner = $owner_dao->getByEmail($user_email); if (!$owner) { $this->addErrorMessage("Incorrect email"); return $this->generateView(); } elseif (!$owner->is_activated) { $this->addErrorMessage("Inactive account. " . $owner->account_status . ". " . '<a href="forgot.php">Reset your password.</a>'); return $this->generateView(); } elseif (!$session->pwdCheck($_POST['pwd'], $owner_dao->getPass($user_email))) { //failed login if ($owner->failed_logins >= 10) { $owner_dao->deactivateOwner($user_email); $owner_dao->setAccountStatus($user_email, "Account deactivated due to too many failed logins"); } $owner_dao->incrementFailedLogins($user_email); $this->addErrorMessage("Incorrect password"); return $this->generateView(); } else { // this sets variables in the session $session->completeLogin($owner); $owner_dao->updateLastLogin($user_email); $owner_dao->resetFailedLogins($user_email); $owner_dao->clearAccountStatus(''); $controller = new DashboardController(true); return $controller->control(); } } } else { return $this->generateView(); } } }
/** * Bounce user to public page or to error page. * @TODO bounce back to original action once signed in */ protected function bounce() { if (get_class($this)=='DashboardController' || get_class($this)=='PostController') { $controller = new DashboardController(true); return $controller->go(); } else { $config = Config::getInstance(); throw new Exception('You must <a href="'.$config->getValue('site_root_path'). 'session/login.php">log in</a> to do this.'); } }
/** * Bounce user to public page or to error page. * @TODO bounce back to original action once signed in */ protected function bounce() { $config = Config::getInstance(); if (get_class($this) == 'DashboardController' || get_class($this) == 'PostController') { $controller = new DashboardController(true); return $controller->go(); } else { throw new ControllerAuthException('You must log in to access this controller: ' . get_class($this)); } }
public function go() { if ($this->isLoggedIn()) { // If logged in, we go to DashboardController $controller = new DashboardController(); echo $controller->go(); } else { // If is not logged in, we go to LoginController $controller = new LoginController(); echo $controller->go(); } }
public function control() { $this->setPageTitle('Log in'); $this->setViewTemplate('session.login.tpl'); $this->disableCaching(); //don't show login form if already logged in if ($this->isLoggedIn()) { $controller = new DashboardController(true); return $controller->go(); } else { $od = DAOFactory::getDAO('OwnerDAO'); if (isset($_POST['Submit']) && $_POST['Submit'] == 'Log In' && isset($_POST['email']) && isset($_POST['pwd'])) { if ($_POST['email'] == '' || $_POST['pwd'] == '') { if ($_POST['email'] == '') { $this->addErrorMessage("Email must not be empty"); return $this->generateView(); } else { $this->addErrorMessage("Password must not be empty"); return $this->generateView(); } } else { $session = new Session(); $user_email = $_POST['email']; $this->addToView('email', $user_email); $owner = $od->getByEmail($user_email); if (!$owner) { $this->addErrorMessage("Incorrect email"); return $this->generateView(); } elseif (!$session->pwdCheck($_POST['pwd'], $od->getPass($user_email))) { $this->addErrorMessage("Incorrect password"); return $this->generateView(); } else { // this sets variables in the session $session->completeLogin($owner); $od->updateLastLogin($user_email); $controller = new DashboardController(true); return $controller->control(); } } } else { return $this->generateView(); } } }
public function control() { if ($this->isLoggedIn()) { $controller = new DashboardController(true); return $controller->go(); } else { $this->disableCaching(); $config = Config::getInstance(); if (!$config->getValue('is_registration_open')) { $this->addToView('closed', true); $this->addErrorMessage('<p>Sorry, registration is closed on this ThinkUp installation.</p>' . '<p><a href="http://github.com/ginatrapani/thinkup/tree/master">Install ThinkUp on your own ' . 'server.</a></p>'); } else { $owner_dao = DAOFactory::getDAO('OwnerDAO'); $this->addToView('closed', false); $captcha = new Captcha(); if (isset($_POST['Submit']) && $_POST['Submit'] == 'Register') { foreach ($this->REQUIRED_PARAMS as $param) { if (!isset($_POST[$param]) || $_POST[$param] == '') { $this->addErrorMessage('Please fill out all required fields.'); $this->is_missing_param = true; } } if (!$this->is_missing_param) { if (!Utils::validateEmail($_POST['email'])) { $this->addErrorMessage("Incorrect email. Please enter valid email address."); } elseif (strcmp($_POST['pass1'], $_POST['pass2']) || empty($_POST['pass1'])) { $this->addErrorMessage("Passwords do not match."); } elseif (!$captcha->check()) { // Captcha not valid, captcha handles message... } else { if ($owner_dao->doesOwnerExist($_POST['email'])) { $this->addErrorMessage("User account already exists."); } else { $es = new SmartyThinkUp(); $es->caching = false; $session = new Session(); $activ_code = rand(1000, 9999); $cryptpass = $session->pwdcrypt($_POST['pass2']); $server = $_SERVER['HTTP_HOST']; $owner_dao->create($_POST['email'], $cryptpass, $activ_code, $_POST['full_name']); $es->assign('server', $server); $es->assign('email', urlencode($_POST['email'])); $es->assign('activ_code', $activ_code); $message = $es->fetch('_email.registration.tpl'); Mailer::mail($_POST['email'], "Activate Your " . $config->getValue('app_title') . " Account", $message); unset($_SESSION['ckey']); $this->addSuccessMessage("Success! Check your email for an activation link."); } } } if (isset($_POST["full_name"])) { $this->addToView('name', $_POST["full_name"]); } if (isset($_POST["email"])) { $this->addToView('mail', $_POST["email"]); } } $challenge = $captcha->generate(); $this->addToView('captcha', $challenge); } return $this->generateView(); } }
/** * * ThinkUp/webapp/index.php * * Copyright (c) 2009-2012 Gina Trapani * * LICENSE: * * This file is part of ThinkUp (http://thinkupapp.com). * * ThinkUp is free software: you can redistribute it and/or modify it under the terms of the GNU General Public * License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any * later version. * * ThinkUp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with ThinkUp. If not, see * <http://www.gnu.org/licenses/>. * * * @author Gina Trapani <ginatrapani[at]gmail[dot]com> * @license http://www.gnu.org/licenses/gpl.html * @copyright 2009-2012 Gina Trapani */ require_once 'init.php'; $controller = new DashboardController(); echo $controller->go();
public function control() { $this->setPageTitle('Log in'); $this->setViewTemplate('session.login.tpl'); $this->view_mgr->addHelp('login', 'userguide/accounts/index'); $this->disableCaching(); //don't show login form if already logged in if ($this->isLoggedIn()) { $controller = new DashboardController(true); return $controller->go(); } else { $owner_dao = DAOFactory::getDAO('OwnerDAO'); if (isset($_POST['Submit']) && $_POST['Submit'] == 'Log In' && isset($_POST['email']) && isset($_POST['pwd'])) { if ($_POST['email'] == '' || $_POST['pwd'] == '') { if ($_POST['email'] == '') { $this->addErrorMessage("Email must not be empty"); return $this->generateView(); } else { $this->addErrorMessage("Password must not be empty"); return $this->generateView(); } } else { $session = new Session(); $user_email = $_POST['email']; if (get_magic_quotes_gpc()) { $user_email = stripslashes($user_email); } $this->addToView('email', $user_email); $owner = $owner_dao->getByEmail($user_email); if (!$owner) { $this->addErrorMessage("Incorrect email"); return $this->generateView(); } elseif (!$owner->is_activated) { $error_msg = 'Inactive account. '; if ($owner->failed_logins == 0) { $error_msg .= '<a href="http://thinkupapp.com/docs/install/install.html#activate-your-account">' . 'You must activate your account.</a>'; } elseif ($owner->failed_logins == 10) { $error_msg .= $owner->account_status . '. <a href="forgot.php">Reset your password.</a>'; } $this->addErrorMessage($error_msg); return $this->generateView(); // If the credentials supplied by the user are incorrect } elseif (!$owner_dao->isOwnerAuthorized($user_email, $_POST['pwd'])) { $error_msg = 'Incorrect password'; if ($owner->failed_logins == 9) { // where 9 represents the 10th attempt! $owner_dao->deactivateOwner($user_email); $status = 'Account deactivated due to too many failed logins'; $owner_dao->setAccountStatus($user_email, $status); $error_msg = 'Inactive account. ' . $status . '. <a href="forgot.php">Reset your password.</a>'; } $owner_dao->incrementFailedLogins($user_email); $this->addErrorMessage($error_msg); return $this->generateView(); } else { // user has logged in sucessfully this sets variables in the session $session->completeLogin($owner); $owner_dao->updateLastLogin($user_email); $owner_dao->resetFailedLogins($user_email); $owner_dao->clearAccountStatus($user_email); $controller = new DashboardController(true); return $controller->go(); } } } else { return $this->generateView(); } } }
public function testLoggedInUserNoAutoLinkEmail() { $builders = $this->buildData(); $this->simulateLogin('*****@*****.**'); //required params $_GET['u'] = 'ev'; $_GET['n'] = 'twitter'; $_GET['v'] = ''; $controller = new DashboardController(true); $results = $controller->go(); $config = Config::getInstance(); $this->assertPattern('/<script>var logged_in_user = \'me@example.com\';<\\/script>/', $results); }
public function control() { if ($this->isLoggedIn()) { $controller = new DashboardController(true); return $controller->go(); } else { $config = Config::getInstance(); $is_registration_open = $config->getValue('is_registration_open'); $this->disableCaching(); $invite_dao = DAOFactory::getDAO('InviteDAO'); if (isset($_GET['code'])) { $invite_code = $_GET['code']; } else { $invite_code = null; } $this->addToView('invite_code', $invite_code); $is_invite_code_valid = $invite_dao->isInviteValid($invite_code); if (!$is_registration_open && !$is_invite_code_valid) { $this->addToView('closed', true); $this->addErrorMessage('<p>Sorry, registration is closed on this ThinkUp installation.</p>' . '<p><a href="http://thinkupapp.com">Install ThinkUp on your own server.</a></p>'); } else { $owner_dao = DAOFactory::getDAO('OwnerDAO'); $this->addToView('closed', false); $captcha = new Captcha(); if (isset($_POST['Submit']) && $_POST['Submit'] == 'Register') { foreach ($this->REQUIRED_PARAMS as $param) { if (!isset($_POST[$param]) || $_POST[$param] == '') { $this->addErrorMessage('Please fill out all required fields.'); $this->is_missing_param = true; } } if (!$this->is_missing_param) { $valid_input = true; if (!Utils::validateEmail($_POST['email'])) { $this->addErrorMessage("Incorrect email. Please enter valid email address.", 'email'); $valid_input = false; } if (strcmp($_POST['pass1'], $_POST['pass2']) || empty($_POST['pass1'])) { $this->addErrorMessage("Passwords do not match.", 'password'); $valid_input = false; } else { if (strlen($_POST['pass1']) < 5) { $this->addErrorMessage("Password must be at least 5 characters.", 'password'); $valid_input = false; } } if (!$captcha->doesTextMatchImage()) { $this->addErrorMessage("Entered text didn't match the image. Please try again.", 'captcha'); $valid_input = false; } if ($valid_input) { if ($owner_dao->doesOwnerExist($_POST['email'])) { $this->addErrorMessage("User account already exists.", 'email'); } else { // Insert the details into the database $activation_code = $owner_dao->create($_POST['email'], $_POST['pass2'], $_POST['full_name']); if ($activation_code != false) { $es = new SmartyThinkUp(); $es->caching = false; $server = $_SERVER['HTTP_HOST']; $es->assign('server', $server); $es->assign('email', urlencode($_POST['email'])); $es->assign('activ_code', $activation_code); $message = $es->fetch('_email.registration.tpl'); Mailer::mail($_POST['email'], "Activate Your " . $config->getValue('app_title') . " Account", $message); SessionCache::unsetKey('ckey'); $this->addSuccessMessage("Success! Check your email for an activation link."); //delete invite code if ($is_invite_code_valid) { $invite_dao->deleteInviteCode($invite_code); } } else { $this->addErrorMessage("Unable to register a new user. Please try again."); } } } } if (isset($_POST["full_name"])) { $this->addToView('name', $_POST["full_name"]); } if (isset($_POST["email"])) { $this->addToView('mail', $_POST["email"]); } } $challenge = $captcha->generate(); $this->addToView('captcha', $challenge); } $this->view_mgr->addHelp('register', 'userguide/accounts/index'); return $this->generateView(); } }
public function control() { if (isset($_GET['redirect'])) { $this->redirectToEmpoddyLabsEndpoint($page = null, $redirect = $_GET['redirect']); } else { $this->redirectToEmpoddyLabsEndpoint(); } //var_dump($_GET); //var_dump($_SERVER);exit; $this->setPageTitle('Log in'); $this->setViewTemplate('login.tpl'); $this->disableCaching(); // set var for open registration $config = Config::getInstance(); // Set successful login redirect destination if (isset($_GET['redirect'])) { $this->addToView('redirect', $_GET['redirect']); } // If form has been submitted if (isset($_POST['redirect'])) { $this->addToView('redirect', $_POST['redirect']); } //don't show login form if already logged in if ($this->isLoggedIn()) { if ($this->isSuperAdmin()) { $controller = new DashboardController(true); return $controller->go(); } else { $controller = new DashboardController(true); return $controller->go(); } } else { //$user_dao = DAOFactory::getDAO('UserDAO'); //$_POST['email'] = '*****@*****.**'; //$_POST['pwd'] = 'abcde_12345'; //if (isset($_POST['Submit']) && $_POST['Submit']=='Log In' && isset($_POST['email']) && //isset($_POST['pwd']) ) { if (isset($_POST['email']) && isset($_POST['pwd'])) { $user_dao = DAOFactory::getDAO('UserDAO'); if ($_POST['email'] == '' || $_POST['pwd'] == '') { if ($_POST['email'] == '') { $this->addErrorMessage("Email must not be empty"); return $this->generateView(); } else { $this->addErrorMessage("Password must not be empty"); return $this->generateView(); } } else { $session = new Session(); $user_email = $_POST['email']; $user_email = stripslashes($user_email); $this->addToView('email', $user_email); $user = $user_dao->getByEmail($user_email); if (!$user) { $this->addErrorMessage("Hmm, that email seems wrong."); return $this->generateView(); } elseif ($user->account_status != 11) { $error_msg = 'Inactive account. '; if ($user->failed_logins == 0) { $error_msg .= '<a href=\\"http://localhost/EFC/webapp/session/login.php#activate-your-account\\">' . 'You must be registered to get login in your account.</a>'; } elseif ($owner->failed_logins == 10) { $error_msg .= $user->account_status . '. <a href=\\"http://localhost/EFC/webapp/session/forgot.php\\">Reset your password.</a>'; } $disable_xss = true; $this->addErrorMessage($error_msg, null, $disable_xss); return $this->generateView(); // If the credentials supplied by the user are incorrect } elseif (!$user_dao->isUserAuthorized($user_email, $_POST['pwd'])) { $error_msg = "Hmm, that password seems wrong."; if ($user->failed_logins == 9) { // where 9 represents the 10th attempt! $user_dao->deactivateUser($user_email); $status = 'Account deactivated due to too many failed logins'; $user_dao->setAccountStatus($user_email, $status); $error_msg = 'Inactive account. ' . $status . '. <a href=\\"http://localhost/EFC/webapp/session/forgot.php\\">Reset your password.</a>'; } $user_dao->incrementFailedLogins($user_email); $disable_xss = true; $this->addErrorMessage($error_msg, null, $disable_xss); return $this->generateView(); } else { // user has logged in sucessfully this sets variables in the session $session->completelogin($user); $user_dao->updatelastlogin($user_email); $user_dao->resetfailedlogins($user_email); //$user_logon = daofactory::getdao('userlogondao'); //$user_logon->insertlogininfo(); if (isset($_post['redirect']) && $_post['redirect'] != '') { $success_redir = $_post['redirect']; } else { $success_redir = $config->getvalue('site_root_path'); } //$_get['action'] = 'add'; //$controller = new usercontroller(); //$controller = new dashboardcontroller(true); // /return $controller->go(); if (!$this->redirect($success_redir)) { if ($this->issuperadmin()) { $controller = new dashboardcontroller(true); return $controller->go(); } else { $controller = new dashboardcontroller(true); return $controller->go(); } } } } } else { if ($this->getFbAccessToken()) { Session::completeLoginUsingFb($this->fb_token); //echo $this->fb_token;exit; $this->facebook->setDefaultAccessToken($this->fb_token); $resp = $this->facebook->get('/me'); var_dump($resp); exit; if (isset($_post['redirect']) && $_post['redirect'] != '') { $success_redir = $_post['redirect']; } else { $success_redir = $config->getvalue('site_root_path'); } if (!$this->redirect($success_redir)) { $controller = new DashboardController(true); return $controller->go(); } $resp = $this->facebook->get('/me'); // user has logged in sucessfully this sets variables in the session /* $session->completelogin($user); $user_dao->updatelastlogin($user_email); $user_dao->resetfailedlogins($user_email); //$user_logon = daofactory::getdao('userlogondao'); //$user_logon->insertlogininfo(); if (isset($_post['redirect']) && $_post['redirect'] != '') { $success_redir = $_post['redirect']; } else { $success_redir = $config->getvalue('site_root_path'); } if (!$this->redirect($success_redir)) { $controller = new dashboardcontroller(true); return $controller->go(); } } SessionCache::put('fb_token',$this->fb_token); */ } else { $this->addToView('fb_login_url', $this->getFbLoingUrl()); return $this->generateView(); } } } }
public function testNonexistentPluginIsActive() { $builders = $this->buildData(); //add a plugin which is activatd, but doesn't exist on the file system $plugin_builder = FixtureBuilder::build('plugins', array( 'name'=>'Flickr Thumbnails', 'folder_name'=>'flickrthumbnails', 'is_active'=>1) ); $controller = new DashboardController(true); $results = $controller->go(); //make sure there's no fatal error because the plugin files don't exist }
public function control() { $this->redirectToEmpoddyLabsEndpoint(); if ($this->isLoggedIn()) { $controller = new DashboardController(true); return $controller->go(); } else { $this->disableCaching(); $has_been_registered = false; $is_registration_open = true; if (!$is_registration_open && !$is_invite_code_valid) { $this->addToView('closed', true); $disable_xss = true; $this->addErrorMessage('Sorry, registration is closed on ' . $config->getValue('app_title_prefix') . "EFC Labs. " . 'Try <a href="https://EFC">EFC</a>.', null, $disable_xss); } else { $user_arr = array(); $user_dao = DAOFactory::getDAO('UserDAO'); $this->addToView('closed', false); $captcha = new Captcha(); if (isset($_POST['Submit']) && $_POST['Submit'] == 'Register') { foreach ($this->REQUIRED_PARAMS as $param) { if (!isset($_POST[$param]) || $_POST[$param] == '') { $this->addErrorMessage('Please fill out all required fields.'); $this->is_missing_param = true; } else { $user_arr[$param] = $_POST[$param]; } } if (!$this->is_missing_param) { $valid_input = true; if (!Utils::validateEmail($_POST['email'])) { $this->addErrorMessage("Sorry, that email address looks wrong. Can you double-check it?", 'email'); $valid_input = false; } if (strcmp($_POST['pwd'], $_POST['cpwd']) || empty($_POST['pwd'])) { $this->addErrorMessage("Passwords do not match.", 'password'); $valid_input = false; } else { if (!preg_match("/(?=.{8,})(?=.*[a-zA-Z])(?=.*[0-9])/", $_POST['pass1'])) { $this->addErrorMessage("Password must be at least 8 characters and contain both numbers " . "and letters.", 'password'); $valid_input = false; } } if ($valid_input) { if ($user_dao->doesUserExist($_POST['email'])) { $this->addErrorMessage("User account already exists.", 'email'); } else { // Insert the details into the database $activation_code = $user_dao->create($user_arr); if ($activation_code != false) { /* $es = new ViewManager(); $es->caching=false; $es->assign('application_url', Utils::getApplicationURL(false) ); $es->assign('email', urlencode($_POST['email']) ); $es->assign('activ_code', $activation_code ); $message = $es->fetch('_email.registration.tpl'); Mailer::mail($_POST['email'], "Activate Your Account on ". $config->getValue('app_title_prefix')."EFC", $message); $this->addSuccessMessage("Success! Check your email for an activation link."); //delete invite code if ( $is_invite_code_valid ) { $invite_dao->deleteInviteCode($invite_code); } */ $has_been_registered = true; $this->addToView('success', $has_been_registered); } else { $this->addErrorMessage("Unable to register a new user. Please try again."); } } } } if (isset($_POST["first_name"])) { $this->addToView('first_name', $_POST["first_name"]); } } } return $this->generateView(); } }
public function testCleanXSS() { $with_xss = true; $builders = $this->buildData($with_xss); $this->simulateLogin('*****@*****.**'); //required params $_GET['u'] = 'ev'; $_GET['n'] = 'twitter'; $_GET['v'] = 'tweets-all'; $controller = new DashboardController(true); $results = $controller->go(); $this->assertNoPattern("/This is post <script>alert\\('wa'\\);<\\/script>\\d+/", $results); $this->assertPattern("/This is post <script>alert\\('wa'\\);<\\/script>\\d+/", $results); }
public function control() { if ($this->isLoggedIn()) { $controller = new DashboardController(true); return $controller->go(); } else { // register form validation $this->addHeaderCSS('assets/css/validate_password.css'); $this->addHeaderJavaScript('assets/js/jquery.validate.min.js'); $this->addHeaderJavaScript('assets/js/jquery.validate.password.js'); $this->addHeaderJavaScript('assets/js/validate_password.js'); $config = Config::getInstance(); $is_registration_open = $config->getValue('is_registration_open'); $this->disableCaching(); $invite_dao = DAOFactory::getDAO('InviteDAO'); if (isset($_GET['code'])) { $invite_code = $_GET['code']; } else { $invite_code = null; } $this->addToView('invite_code', $invite_code); $is_invite_code_valid = $invite_dao->isInviteValid($invite_code); if ($invite_code != null && $is_invite_code_valid) { $this->addSuccessMessage("Welcome, VIP! You've been invited to register on " . $config->getValue('app_title_prefix') . "ThinkUp."); } $has_been_registered = false; if (!$is_registration_open && !$is_invite_code_valid) { $this->addToView('closed', true); $disable_xss = true; $this->addErrorMessage('<p>Sorry, registration is closed on this installation of ' . $config->getValue('app_title_prefix') . "ThinkUp.</p>" . '<p><a href="http://thinkupapp.com">Install ThinkUp on your own server.</a></p>', null, $disable_xss); } else { $owner_dao = DAOFactory::getDAO('OwnerDAO'); $this->addToView('closed', false); $captcha = new Captcha(); if (isset($_POST['Submit']) && $_POST['Submit'] == 'Register') { foreach ($this->REQUIRED_PARAMS as $param) { if (!isset($_POST[$param]) || $_POST[$param] == '') { $this->addErrorMessage('Please fill out all required fields.'); $this->is_missing_param = true; } } if (!$this->is_missing_param) { $valid_input = true; if (!Utils::validateEmail($_POST['email'])) { $this->addErrorMessage("Incorrect email. Please enter valid email address.", 'email'); $valid_input = false; } if (strcmp($_POST['pass1'], $_POST['pass2']) || empty($_POST['pass1'])) { $this->addErrorMessage("Passwords do not match.", 'password'); $valid_input = false; } else { if (!preg_match("/(?=.{8,})(?=.*[a-zA-Z])(?=.*[0-9])/", $_POST['pass1'])) { $this->addErrorMessage("Password must be at least 8 characters and contain both numbers " . "and letters.", 'password'); $valid_input = false; } } if (!$captcha->doesTextMatchImage()) { $this->addErrorMessage("Entered text didn't match the image. Please try again.", 'captcha'); $valid_input = false; } if ($valid_input) { if ($owner_dao->doesOwnerExist($_POST['email'])) { $this->addErrorMessage("User account already exists.", 'email'); } else { // Insert the details into the database $activation_code = $owner_dao->create($_POST['email'], $_POST['pass2'], $_POST['full_name']); if ($activation_code != false) { $es = new ViewManager(); $es->caching = false; $es->assign('application_url', Utils::getApplicationURL(false)); $es->assign('email', urlencode($_POST['email'])); $es->assign('activ_code', $activation_code); $message = $es->fetch('_email.registration.tpl'); Mailer::mail($_POST['email'], "Activate Your Account on " . $config->getValue('app_title_prefix') . "ThinkUp", $message); SessionCache::unsetKey('ckey'); $this->addSuccessMessage("Success! Check your email for an activation link."); //delete invite code if ($is_invite_code_valid) { $invite_dao->deleteInviteCode($invite_code); } $has_been_registered = true; } else { $this->addErrorMessage("Unable to register a new user. Please try again."); } } } } if (isset($_POST["full_name"])) { $this->addToView('name', $_POST["full_name"]); } if (isset($_POST["email"])) { $this->addToView('mail', $_POST["email"]); } $this->addToView('has_been_registered', $has_been_registered); } $challenge = $captcha->generate(); $this->addToView('captcha', $challenge); } $this->view_mgr->addHelp('register', 'userguide/accounts/index'); return $this->generateView(); } }
public function testLoggedInPeople() { $builders = $this->buildData(); //first, add some people $user1_builder = FixtureBuilder::build('users', array('user_name' => 'ginatrapani', 'user_id' => '930061', 'network' => 'twitter')); $user2_builder = FixtureBuilder::build('users', array('user_name' => 'anildash', 'user_id' => '123456', 'network' => 'twitter')); $follower_builders = array(); $follower_builders[] = FixtureBuilder::build('follows', array('user_id' => '930061', 'follower_id' => '13')); $follower_builders[] = FixtureBuilder::build('follows', array('user_id' => '123456', 'follower_id' => '13')); //must be logged in $this->simulateLogin('*****@*****.**'); //required params $_GET['u'] = 'ev'; $_GET['n'] = 'twitter'; $_GET['v'] = 'friends-mostactive'; $controller = new DashboardController(true); $results = $controller->go(); //test if view variables were set correctly $v_mgr = $controller->getViewManager(); $this->assertEqual($v_mgr->getTemplateDataItem('header'), 'Chatterboxes', 'Header'); $this->assertEqual($v_mgr->getTemplateDataItem('description'), '', 'Description'); $this->assertIsA($v_mgr->getTemplateDataItem('people'), 'array', 'Array of users'); $this->assertEqual(sizeof($v_mgr->getTemplateDataItem('people')), 2, '2 users in listing'); $config = Config::getInstance(); $this->assertEqual($controller->getCacheKeyString(), 'dashboard.tpl-me@example.com-ev-twitter-friends-mostactive', 'Cache key'); }