logout() public method

The logout action Perform logout, redirect user to main-page
public logout ( )
Exemplo n.º 1
0
 function perform()
 {
     $login = new LoginController();
     $login->logout();
     header('Location: index.php');
     exit;
 }
Exemplo n.º 2
0
 * @copyright	Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
 * @license		GNU/GPL, see LICENSE.php
 * Joomla! is free software. This version may have been modified pursuant
 * to the GNU General Public License, and as distributed it includes or
 * is derivative of works licensed under the GNU General Public License or
 * other free or open source software licenses.
 * See COPYRIGHT.php for copyright notices and details.
 */
// no direct access
defined('_JEXEC') or die('Restricted access');
switch (JRequest::getCmd('task')) {
    case 'login':
        LoginController::login();
        break;
    case 'logout':
        LoginController::logout();
        break;
    default:
        LoginController::display();
        break;
}
/**
 * Static class to hold controller functions for the Login component
 *
 * @static
 * @package		Joomla
 * @subpackage	Login
 * @since		1.5
 */
class LoginController
{
Exemplo n.º 3
0
<?php

require_once "../config.php";
require_once $config->getIncludeURL(Config::INCLUDES_PATH, "common_includes.php.inc");
$dbConnection = null;
$loggedOut = false;
try {
    $dbConnection = DatabaseUtilities::getDatabaseConnection();
    $loggedOut = LoginController::logout($dbConnection);
    $dbConnection = null;
    if ($loggedOut) {
        echo "1";
    } else {
        echo "0";
    }
} catch (Exception $ex) {
    echo $ex->getMessage();
    $loggedOut = false;
}
Exemplo n.º 4
0
 public function renderView()
 {
     foreach ($this->model->getUris() as $key => $value) {
         if (preg_match("#^{$value}\$#", $this->uriView)) {
             if ($this->model->getView($key) === "PageView") {
                 //connect to db and get pageid
                 $db = DatabaseController::getInstance();
                 $mysqli = $db->getConnection();
                 $sql_query = "SELECT `page_id` FROM `pages` WHERE `nicename` = '" . str_replace('/', '', $value) . "' AND `hidden` != 1;";
                 $result = $mysqli->query($sql_query);
                 $page_id = $result->fetch_array();
                 $page_id = $page_id['page_id'];
                 //change language to language of selected page
                 $page = new Page($page_id);
                 $view = new PageView($page);
                 $langselect = new LanguageView($page);
                 $langselect->render();
             } else {
                 if ($this->model->getView($key) === "ProductView") {
                     $products = new Products();
                     $view = new ProductView($products);
                 } else {
                     if ($this->model->getView($key) === "SingleProductView") {
                         $params = $this->additionalParam;
                         if (!isset($params[2])) {
                             $product_id = 1;
                         } else {
                             //connect to db and get pageid
                             $db = DatabaseController::getInstance();
                             $mysqli = $db->getConnection();
                             $sql_query = "SELECT `product_id` FROM `product` WHERE `product_nicename` = '" . $params[2] . "' AND `hidden` != 1;";
                             if ($result = $mysqli->query($sql_query)) {
                                 $product_id = $result->fetch_array();
                                 $product_id = $product_id['product_id'];
                             } else {
                                 $product_id = 1;
                             }
                         }
                         $product = new Product($product_id);
                         $view = new SingleProductView($product);
                         $langselect = new LanguageView($product);
                         $langselect->render();
                     } else {
                         if ($this->model->getView($key) === "LoginView") {
                             if (isset($_SESSION['user'])) {
                                 //logout if logout link is called
                                 if (str_replace('/', '', $value) == "logout") {
                                     $view = new LoginView();
                                     $controller = new LoginController($view);
                                     $controller->logout();
                                 } else {
                                     $view = new CustomerView(unserialize($_SESSION['user']));
                                 }
                             } else {
                                 if (isset($_POST["login"]) && isset($_POST["password"])) {
                                     $username = $_POST["login"];
                                     $password = $_POST["password"];
                                     $view = new LoginView();
                                     $controller = new LoginController($view);
                                     //authenticate
                                     if ($controller->login($username, $password)) {
                                         $view = new CustomerView(unserialize($_SESSION['user']));
                                     }
                                 } else {
                                     $view = new LoginView();
                                 }
                             }
                         } else {
                             if ($this->model->getView($key) === "CustomerView") {
                                 if (isset($_SESSION['user'])) {
                                     $view = new CustomerView(unserialize($_SESSION['user']));
                                 } else {
                                     $view = new LoginView();
                                 }
                             } else {
                                 if ($this->model->getView($key) === "CartView") {
                                     if (isset($_SESSION['cart'])) {
                                         $cart = unserialize($_SESSION['cart']);
                                         $params = $this->additionalParam;
                                         //update article
                                         if (isset($params[2])) {
                                             $action = $params[2];
                                         }
                                         if (isset($params[3])) {
                                             $productnr = $params[3];
                                         }
                                         if (isset($params[4])) {
                                             $newamount = $params[4];
                                         }
                                         if (!empty($action) && $action == "update" && !empty($productnr) && !empty($newamount)) {
                                             $cart->update($productnr, $newamount);
                                         }
                                         if (!empty($action) && $action == "delete" && !empty($productnr)) {
                                             $cart->remove($productnr);
                                         }
                                         $_SESSION['cart'] = serialize($cart);
                                         $view = new CartView($cart);
                                     } else {
                                         $cart = new Cart();
                                         //test-data
                                         $cart->add(new Product(1));
                                         $cart->add(new Product(2));
                                         $cart->add(new Product(3));
                                         $cart->add(new Product(4));
                                         //$cart->remove(10001);
                                         $_SESSION['cart'] = serialize($cart);
                                         $view = new CartView($cart);
                                     }
                                 } else {
                                     $useView = $this->model->getView($key);
                                     $view = new $useView();
                                 }
                             }
                         }
                     }
                 }
             }
             $view->render();
         }
     }
 }
Exemplo n.º 5
0
function ru_logout()
{
    $controller = new LoginController();
    $logout = $controller->logout();
    $logout;
}
Exemplo n.º 6
0
 public function getRoute()
 {
     // Retrieve the URI
     if (strlen($this->_basepath) > 1) {
         // Local Server
         $uri = str_replace($this->_basepath, "", $_SERVER['REQUEST_URI']);
     } else {
         // AWS Server
         $uri = substr($_SERVER['REQUEST_URI'], 1);
     }
     // If the user is not logged in, go back to Home.
     if ($uri != 'Login') {
         if (!isset($_SESSION['loggedin'])) {
             $uri = 'Home';
         }
     }
     if (strrpos($uri, '/') !== false) {
         $uri = explode('/', $uri);
         $id = $uri[1];
         $uri = $uri[0] . '-';
     }
     // Calls the appropriate controller based on the URI.
     switch ($uri) {
         case 'Home':
             $home = new HomeController();
             $home->display();
             break;
         case 'Account-Summary':
             $summary = new SummaryController();
             $summary->display();
             break;
         case 'Transaction-History-':
             $_SESSION['accountID'] = $id;
             $pos = strrpos($_SERVER['HTTP_REFERER'], '/');
             $pos = strlen($_SERVER['HTTP_REFERER']) - $pos;
             header("Location: " . substr($_SERVER['HTTP_REFERER'], 0, -$pos + 1) . "Transaction-History");
             break;
         case 'Transaction-History':
             $history = new HistoryController();
             $history->display();
             break;
         case 'Account-Details-':
             $_SESSION['detAccountID'] = $id;
             $pos = strrpos($_SERVER['HTTP_REFERER'], '/');
             $pos = strlen($_SERVER['HTTP_REFERER']) - $pos;
             header("Location: " . substr($_SERVER['HTTP_REFERER'], 0, -$pos + 1) . "Account-Details");
             break;
         case 'Account-Details':
             $details = new DetailsController();
             $details->display();
             break;
         case 'New-Bill-Payment-':
             $payment = new Paymentamt();
             $payment->setAccountSelected($id);
             $pos = strrpos($_SERVER['HTTP_REFERER'], '/');
             $pos = strlen($_SERVER['HTTP_REFERER']) - $pos;
             header("Location: " . substr($_SERVER['HTTP_REFERER'], 0, -$pos + 1) . "New-Bill-Payment");
             break;
         case 'New-Bill-Payment':
             $payment = new PaymentController();
             $payment->display();
             break;
         case 'Bill-Payment-Amount':
             $paymentamt = new PaymentamtController();
             $paymentamt->display();
             break;
         case 'Bill-Payment-Confirmation':
             $paymentconf = new PaymentconfController();
             $paymentconf->display();
             break;
         case 'Bill-Payment-Acknowledgement':
             $paymentack = new PaymentackController();
             $paymentack->display();
             break;
         case 'Payment-List':
             $paymentlist = new PaymentlistController();
             $paymentlist->display();
             break;
         case 'Bill-Payment-List':
             $_SESSION['billPayment'] = true;
             unset($_SESSION['fundsTransferPayment']);
             $pos = strrpos($_SERVER['HTTP_REFERER'], '/');
             $pos = strlen($_SERVER['HTTP_REFERER']) - $pos;
             header("Location: " . substr($_SERVER['HTTP_REFERER'], 0, -$pos + 1) . "Payment-List");
             break;
         case 'Funds-Transfer-Payment-List':
             $_SESSION['fundsTransferPayment'] = true;
             unset($_SESSION['billPayment']);
             $pos = strrpos($_SERVER['HTTP_REFERER'], '/');
             $pos = strlen($_SERVER['HTTP_REFERER']) - $pos;
             header("Location: " . substr($_SERVER['HTTP_REFERER'], 0, -$pos + 1) . "Payment-List");
             break;
         case 'Payee-List':
             $payeelist = new PayeelistController();
             $payeelist->display();
             break;
         case 'Bill-Payee-List':
             $_SESSION['billPayee'] = true;
             unset($_SESSION['fundsTransferPayee']);
             $pos = strrpos($_SERVER['HTTP_REFERER'], '/');
             $pos = strlen($_SERVER['HTTP_REFERER']) - $pos;
             header("Location: " . substr($_SERVER['HTTP_REFERER'], 0, -$pos + 1) . "Payee-List");
             break;
         case 'Funds-Transfer-Payee-List':
             $_SESSION['fundsTransferPayee'] = true;
             unset($_SESSION['billPayee']);
             $pos = strrpos($_SERVER['HTTP_REFERER'], '/');
             $pos = strlen($_SERVER['HTTP_REFERER']) - $pos;
             header("Location: " . substr($_SERVER['HTTP_REFERER'], 0, -$pos + 1) . "Payee-List");
             break;
         case 'Biller-Add':
             $billeradd = new BilleraddController();
             $billeradd->display();
             break;
         case 'Biller-Modify-':
             $_SESSION['billerModifyID'] = $id;
             $pos = strrpos($_SERVER['HTTP_REFERER'], '/');
             $pos = strlen($_SERVER['HTTP_REFERER']) - $pos;
             header("Location: " . substr($_SERVER['HTTP_REFERER'], 0, -$pos + 1) . "Biller-Modify");
             break;
         case 'Biller-Modify':
             $billermodify = new BillermodifyController();
             $billermodify->display();
             break;
         case 'Biller-Delete-':
             $_SESSION['billerDeleteID'] = $id;
             $pos = strrpos($_SERVER['HTTP_REFERER'], '/');
             $pos = strlen($_SERVER['HTTP_REFERER']) - $pos;
             header("Location: " . substr($_SERVER['HTTP_REFERER'], 0, -$pos + 1) . "Biller-Delete");
             break;
         case 'Biller-Delete':
             $billerdelete = new BillerdeleteController();
             $billerdelete->display();
             break;
         case 'New-Funds-Transfer-':
             $transfer = new CheckTransfer();
             $transfer->setAccountSelected($id);
             $pos = strrpos($_SERVER['HTTP_REFERER'], '/');
             $pos = strlen($_SERVER['HTTP_REFERER']) - $pos;
             header("Location: " . substr($_SERVER['HTTP_REFERER'], 0, -$pos + 1) . "New-Funds-Transfer");
             break;
         case 'New-Funds-Transfer':
             $transfer = new TransferController();
             $transfer->display();
             break;
         case 'Check-Transfer':
             $checktransfer = new ChecktransferController();
             $checktransfer->display();
             break;
         case 'Funds-Transfer-Acknowledgement':
             $transferack = new TransferackController();
             $transferack->display();
             break;
         case 'Payee-Add':
             $payeeadd = new PayeeaddController();
             $payeeadd->display();
             break;
         case 'Payee-Modify-':
             $_SESSION['payeeModifyID'] = $id;
             $pos = strrpos($_SERVER['HTTP_REFERER'], '/');
             $pos = strlen($_SERVER['HTTP_REFERER']) - $pos;
             header("Location: " . substr($_SERVER['HTTP_REFERER'], 0, -$pos + 1) . "Payee-Modify");
             break;
         case 'Payee-Modify':
             $payeemodify = new PayeemodifyController();
             $payeemodify->display();
             break;
         case 'Payee-Delete-':
             $_SESSION['payeeDeleteID'] = $id;
             $pos = strrpos($_SERVER['HTTP_REFERER'], '/');
             $pos = strlen($_SERVER['HTTP_REFERER']) - $pos;
             header("Location: " . substr($_SERVER['HTTP_REFERER'], 0, -$pos + 1) . "Payee-Delete");
             break;
         case 'Payee-Delete':
             $payeedelete = new PayeedeleteController();
             $payeedelete->display();
             break;
         case 'Login':
             $login = new LoginController();
             $login->login();
             break;
         case 'Logout':
             $logout = new LoginController();
             $logout->logout();
             break;
         default:
             $home = new HomeController();
             $home->display();
             break;
     }
 }