Skip to content
Snippets Groups Projects
login.php 1.51 KiB
Newer Older
  • Learn to ignore specific revisions
  • Jared Hancock's avatar
    Jared Hancock committed
    <?php
    /*********************************************************************
        login.php
    
        Handles staff authentication/logins
    
        Peter Rotich <peter@osticket.com>
    
        Copyright (c)  2006-2013 osTicket
    
    Jared Hancock's avatar
    Jared Hancock committed
        http://www.osticket.com
    
        Released under the GNU General Public License WITHOUT ANY WARRANTY.
        See LICENSE.TXT for details.
    
        vim: expandtab sw=4 ts=4 sts=4:
    **********************************************************************/
    require_once('../main.inc.php');
    if(!defined('INCLUDE_DIR')) die('Fatal Error. Kwaheri!');
    
    require_once(INCLUDE_DIR.'class.staff.php');
    
    require_once(INCLUDE_DIR.'class.csrf.php');
    
    $dest = $_SESSION['_staff']['auth']['dest'];
    $msg = $_SESSION['_staff']['auth']['msg'];
    $msg = $msg?$msg:'Authentication Required';
    if($_POST) {
    
    Jared Hancock's avatar
    Jared Hancock committed
        // Lookup support backends for this staff
        $username = trim($_POST['userid']);
        $sql = 'SELECT backend FROM '.STAFF_TABLE
            .' WHERE username='.db_input($username)
            .' OR email='.db_input($username);
        $backend = db_result(db_query($sql));
    
        if ($user = AuthenticationBackend::process($username,
                $_POST['passwd'], $backend, $errors)) {
    
    Jared Hancock's avatar
    Jared Hancock committed
            $dest=($dest && (!strstr($dest,'login.php') && !strstr($dest,'ajax.php')))?$dest:'index.php';
            @header("Location: $dest");
            require_once('index.php'); //Just incase header is messed up.
            exit;
        }
    
    
        $msg = $errors['err']?$errors['err']:'Invalid login';
    
    Jared Hancock's avatar
    Jared Hancock committed
    }
    define("OSTSCPINC",TRUE); //Make includes happy!
    include_once(INCLUDE_DIR.'staff/login.tpl.php');
    ?>