public function testLogoutWhileLoggedIn()
 {
     $this->simulateLogin('*****@*****.**');
     $controller = new LogoutController(true);
     $results = $controller->go();
     $this->assertPattern("/You have successfully logged out/", $results);
 }
 public function testLogoutWhileLoggedIn()
 {
     $this->simulateLogin('*****@*****.**');
     $controller = new LogoutController(true);
     $results = $controller->go();
     $this->assertTrue(strpos($results, "You have successfully logged out") > 0);
 }
Example #3
0
 public function testOfThinkUpLLCRedirect()
 {
     $this->simulateLogin('*****@*****.**');
     $config = Config::getInstance();
     $config->setValue('thinkupllc_endpoint', 'http://example.com/user/');
     $controller = new LogoutController(true);
     $result = $controller->go();
     $this->assertEqual($controller->redirect_destination, 'http://example.com/user/logout.php');
 }
Example #4
0
$_SESSION['base'] = $base;
$_SESSION['control'] = $control;
$_SESSION['action'] = $action;
$_SESSION['arguments'] = $arguments;
if (!isset($_SESSION['authenticated'])) {
    $_SESSION['authenticated'] = false;
}
switch ($control) {
    case "dataset":
        DatasetController::run();
        break;
    case "login":
        LoginController::run();
        break;
    case "logout":
        LogoutController::run();
        break;
    case "measurement":
        MeasurementController::run();
        break;
    case "profile":
        ProfileController::run();
        break;
    case "sensor":
        SensorController::run();
        break;
    case "signup":
        SignupController::run();
        break;
    case "user":
        UserController::run();
Example #5
0
/**
 *
 * ThinkUp/webapp/session/logout.php
 *
 * Copyright (c) 2009-2016 Gina Trapani
 *
 * LICENSE:
 *
 * This file is part of ThinkUp (http://thinkup.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-2016 Gina Trapani
 */
chdir('..');
require_once 'init.php';
$controller = new LogoutController();
echo $controller->go();
Example #6
0
 /**
  * Follows a route and produces a web page from it.
  */
 public function route()
 {
     $view = null;
     $exception = null;
     /* construct template engine */
     $smarty = new Smarty();
     $smarty->caching = true;
     $smarty->cache_lifetime = 120;
     $smarty->setTemplateDir(__DIR__ . '/layouts');
     $smarty->setCompileDir(__DIR__ . '/../../smarty/compiled_templates');
     $smarty->setCacheDir(__DIR__ . '/../../smarty/cache');
     switch ($this->path) {
         case 'index':
             $view = new IndexView($smarty);
             break;
         case 'statuses':
             if (!$this->isLoggedIn()) {
                 $exception = new Exception('You must be <a href="?action=login">logged in<a> to view the circuit board status list.');
                 break;
             }
             $view = new StatusesView($smarty);
             $model = new StatusesModel($view);
             $controller = new StatusesController($model);
             try {
                 $controller->fetchStatuses();
             } catch (Exception $e) {
                 $exception = $e;
             }
             break;
         case 'updates':
             if (!$this->isLoggedIn() || $_SESSION['rank'] != 'ADMIN') {
                 $exception = new Exception('You must be <a href="?action=login">logged in<a> to an administrator\'s account to poll the service for updates.');
                 break;
             }
             $view = new UpdatesView($smarty);
             $model = new UpdatesModel($view);
             $controller = new UpdatesController($model);
             try {
                 $controller->fetchUpdates();
             } catch (Exception $e) {
                 $exception = $e;
             }
             break;
         case 'register':
             $view = new RegisterView($smarty);
             $model = new RegisterModel($view);
             $controller = new RegisterController($model);
             try {
                 $controller->checkValidRegistration();
                 $username = $model->getUsername();
                 if ($model->isRegistered()) {
                     $view = new RegisteredView($smarty);
                     $model = new RegisteredModel($view);
                     $model->setUsername($username);
                 }
             } catch (Exception $e) {
                 $exception = $e;
             }
             break;
         case 'login':
             $view = new LoginView($smarty);
             $model = new LoginModel($view);
             $controller = new LoginController($model);
             try {
                 $controller->checkValidLogin();
                 if ($model->isLoggedIn()) {
                     // successful login
                     $view = new LoggedInView($smarty);
                     $model = new LoggedInModel($view);
                     $model->setUsername($_SESSION['username']);
                 }
             } catch (Exception $e) {
                 $exception = $e;
             }
             break;
         case 'logout':
             $view = new LogoutView($smarty);
             $model = new LogoutModel($view, $this->isLoggedIn());
             $controller = new LogoutController($model);
             try {
                 $controller->logout();
             } catch (Exception $e) {
                 $exception = $e;
             }
             break;
         case 'debug':
             if (!$this->isLoggedIn() || $_SESSION['rank'] != 'ADMIN') {
                 $exception = new Exception('You must be <a href="?action=login">logged in<a> to an administrator\'s account view the debug page.');
                 break;
             }
             $view = new DebugView($smarty);
             break;
             /* any unhandled action return them to the welcome screen */
         /* any unhandled action return them to the welcome screen */
         default:
             $this->path = 'index';
             $view = new IndexView($smarty);
             break;
     }
     if ($exception !== null) {
         $view = new ErrorView($smarty);
         $model = new ErrorModel($view);
         $model->setMessage($exception->getMessage());
     }
     if (!DEBUG_MODE) {
         /* optimize the output by removing whitespace */
         $smarty->loadFilter("output", "trimwhitespace");
     }
     /* apply view specific information to the template engine */
     $view->applyTemplate($this->isLoggedIn());
     /* display generated template */
     $smarty->display($view->getId() . '.tpl');
 }
Example #7
0
    /**
     * Constructor. Create instance of PageTemplate using default index_tpl.php file
     * @access public
     */
    public function __construct()
    {
        $this->template = new PageTemplate();
    }
    /**
     * Run method with main page logic
     * 
     * If a user has a valid session, kill old session data and start new anonymous session.
     * Populate template and display logout status in page.
     * @access public
     */
    public function run()
    {
        $session = Session::getInstance();
        $user = $session->getUser();
        if ($user == null) {
            $session->setMessage("Not currently logged in", Session::MESSAGE_ERROR);
            header("Location: " . BASE_URL);
            return;
        }
        $session->kill();
        $user = $session->getUser();
        $this->template->render(array("main_page" => "logout_tpl.php", "title" => "Logged out", "user" => $user));
    }
}
$controller = new LogoutController();
$controller->run();
 public function mappings()
 {
     //default values for error page
     $this->myPage->setTitle('404');
     $this->myPage->setBodyTemplate('testBodyTemplate');
     $this->myPage->setHtmlTemplate('testHtmlTemplate');
     $this->myPage->setAdditionalHead('default');
     $this->myPage->setMetaInformation('default');
     $this->myPage->useSource('css', 'default');
     $this->myPage->useSource('javascript', 'jquery-2.1.0.min');
     $this->myPage->useSource('javascript', 'default');
     //values if another url is called
     if ($this->basicInformationObject->getUriArray()[1] === 'index' || $this->basicInformationObject->getUriArray()[1] === '' || $this->basicInformationObject->getUriArray()[1] === 'de') {
         $this->myPage->setTitle('Index');
         $indexControllerObject = new IndexController('indexTemplate');
         $this->myPage->setContent($indexControllerObject->execute());
     } else {
         if ($this->basicInformationObject->getUriArray()[1] === 'uploadTest') {
             $this->addCroppic();
             $this->myPage->useSource('javascript', 'formHandler');
             $this->myPage->setTitle('uploadTest');
             $userListContentObject = new userListContentModule($mySession);
             $this->myPage->setContent($userListContentObject->generateHtml());
         } else {
             if ($this->basicInformationObject->getUriArray()[1] === 'register') {
                 $this->myPage->setTitle('Register');
                 $registerControllerObject = new RegisterController('registrationTemplate');
                 $this->myPage->setContent($registerControllerObject->execute());
             } else {
                 if ($this->basicInformationObject->getUriArray()[1] === 'login') {
                     $this->myPage->setTitle('Login');
                     $loginControllerObject = new LoginController('loginTemplate');
                     $this->myPage->setContent($loginControllerObject->execute());
                 } else {
                     if ($this->basicInformationObject->getUriArray()[1] === 'logout') {
                         $this->myPage->setTitle('Logout');
                         $logoutControllerObject = new LogoutController('logoutTemplate');
                         $this->myPage->setContent($logoutControllerObject->execute());
                     } else {
                         if ($this->basicInformationObject->getUriArray()[1] === 'search') {
                             $this->myPage->setTitle('Search');
                             $searchControllerObject = new SearchController('searchTemplate');
                             $this->myPage->setContent($searchControllerObject->execute());
                         } else {
                             if ($this->basicInformationObject->getUriArray()[1] === 'users') {
                                 if (count($this->basicInformationObject->getUriArray()) == 3) {
                                     $this->addCroppic();
                                     $this->addFancyBox();
                                     $this->myPage->useSource('javascript', 'formHandler');
                                     $this->myPage->setTitle($this->basicInformationObject->getUriArray()[2]);
                                     $userContentObject = new UserContentController('userTemplate');
                                     $this->myPage->setContent($userContentObject->execute());
                                 } else {
                                     if (count($this->basicInformationObject->getUriArray()) == 4 && $this->basicInformationObject->getUriArray()[3] == "newStory") {
                                         $newStoryControllerObject = new NewStoryController('userTemplate');
                                         $this->myPage->setContent($newStoryControllerObject->execute());
                                     } else {
                                         if (count($this->basicInformationObject->getUriArray()) == 4) {
                                             $this->myPage->setTitle($this->basicInformationObject->getUriArray()[3] . '/ ' . $this->basicInformationObject->getUriArray()[2]);
                                             $userStoryContentControllerObject = new UserStoryContentController('userStoryTemplate');
                                             $this->myPage->setContent($userStoryContentControllerObject->execute());
                                         } else {
                                             if (count($this->basicInformationObject->getUriArray()) == 5 && $this->basicInformationObject->getUriArray()[4] == "edit") {
                                                 $this->myPage->setTitle('Edit: ' . $this->basicInformationObject->getUriArray()[3]);
                                                 $this->addCroppic();
                                                 $this->myPage->useSource('javascript', 'storyEditHandler');
                                                 $this->myPage->useSource('javascript', 'konva');
                                                 $this->myPage->useSource('javascript', 'function');
                                                 $this->myPage->useSource('css', 'style');
                                                 $this->myPage->useSource('css', 'component');
                                                 $this->myPage->useSource('css', 'publishedView');
                                                 $this->myPage->useSource('javascript', 'classie');
                                                 $this->myPage->useSource('javascript', 'modernizr.custom');
                                                 $this->myPage->useSource('javascript', 'publishedStoryHandler');
                                                 $userStoryEditContentControllerObject = new UserStoryEditContentController('nodeEditorTemplate');
                                                 $this->myPage->setContent($userStoryEditContentControllerObject->execute());
                                             } else {
                                                 if (count($this->basicInformationObject->getUriArray()) == 5 && $this->basicInformationObject->getUriArray()[4] == "published") {
                                                     $this->myPage->setTitle($this->basicInformationObject->getUriArray()[3]);
                                                     $this->myPage->setBodyTemplate('publishedModeBodyTemplate');
                                                     $this->myPage->discardSource('css', 'default');
                                                     $this->myPage->useSource('css', 'publishedView');
                                                     $this->myPage->useSource('javascript', 'publishedStoryHandler');
                                                     $this->myPage->useSource('javascript', 'tracking');
                                                     $userStoryPresentationControllerObject = new UserStoryPresentationController('userStoryPresentationTemplate');
                                                     $this->myPage->setContent($userStoryPresentationControllerObject->execute());
                                                 } else {
                                                     header('Location: ' . $this->basicInformationObject->getUriArray()[0] . '/404');
                                                 }
                                             }
                                         }
                                     }
                                 }
                             } else {
                                 if ($this->basicInformationObject->getUriArray()[1] === '404') {
                                     $errorControllerObject = new ErrorController('errorTemplate');
                                     $this->myPage->setContent($errorControllerObject->execute());
                                 } else {
                                     header('Location: ' . $this->basicInformationObject->getUriArray()[0] . '/404');
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Example #9
0
 case 'categories':
     $controller_obj = new CategoriesController($path, $registry);
     $controller_obj->process($_POST);
     break;
 case 'contact':
     break;
 case 'profile':
     $controller_obj = new ProfileController($path, $registry);
     $controller_obj->process($_POST);
     break;
 case 'login':
     $controller_obj = new LoginController($path, $registry);
     $controller_obj->process($_POST);
     break;
 case 'logout':
     $controller_obj = new LogoutController($path, $registry);
     $controller_obj->process();
     break;
 case 'signup':
     $controller_obj = new SignupController($path, $registry);
     $controller_obj->process($_POST);
     break;
 case 'search':
     $controller_obj = new VideoSearchController($path, $registry);
     $controller_obj->process($_GET);
     break;
 case 'tos':
     break;
 case 'upload':
     $controller_obj = new VideoUploadController($path, $registry);
     $controller_obj->process($_POST);