"Fossies" - the Fresh Open Source Software Archive

Member "openmailadmin-1.0.1/inc/miniauth.inc.php" (6 Nov 2007, 1603 Bytes) of package /linux/privat/old/openmailadmin-1.0.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 <?php
    2 //  Mini-Auth
    3 ini_set('session.use_only_cookies', 1);
    4 session_start();
    5 
    6 // authentification
    7 if(isset($_GET['login']) && $_GET['login'] == 'change') {
    8     session_destroy();
    9     $_SESSION = array();
   10 } else if(isset($_POST['frm']) && $_POST['frm'] == 'login' && trim($_POST['mboxname']) != '') {
   11     if(!(isset($_POST['server']) && is_numeric($_POST['server'])))
   12         $_POST['server'] = 0;
   13     $db = ADONewConnection($cfg['Servers']['DB'][$_POST['server']]['DSN'])
   14         or die('Cannot connect to database.');
   15     $db->SetFetchMode(ADODB_FETCH_ASSOC);
   16 
   17     User::$db       = $db;
   18     User::$tablenames   = array('user' => $cfg['Servers']['DB'][$_POST['server']]['PREFIX'].'user');
   19 
   20     try {
   21         $authinfo = User::authenticate($_POST['mboxname'], $_POST['password']);
   22         unset($_POST['password']);
   23         session_regenerate_id();
   24         $_SESSION['authinfo']       = $authinfo;
   25         $_SESSION['server']     = $_POST['server'];
   26         $_SESSION['REMOTE_ADDR']    = $_SERVER['REMOTE_ADDR'];
   27     } catch (Exception $e) {
   28         $login_error = $e->getMessage();
   29     }
   30 } else if(isset($_SESSION['REMOTE_ADDR']) && $_SESSION['REMOTE_ADDR'] == $_SERVER['REMOTE_ADDR']) {
   31     $authinfo   = $_SESSION['authinfo'];
   32     $db = ADONewConnection($cfg['Servers']['DB'][$_SESSION['server']]['DSN'])
   33         or die('Cannot connect to database.');
   34     $db->SetFetchMode(ADODB_FETCH_ASSOC);
   35 }
   36 
   37 if(!isset($authinfo)) {
   38     // form
   39     include('./templates/'.$cfg['theme'].'/login.tpl');
   40 
   41     if(@is_readable($cfg['motd'])) {
   42         include('./templates/'.$cfg['theme'].'/motd.tpl');
   43     }
   44 
   45     include('./templates/'.$cfg['theme'].'/common-footer_nv.tpl');
   46     session_regenerate_id();
   47     hsys_ob_end($cfg['remove_whitespace']);
   48     exit();
   49 }
   50 
   51 ?>