Changeset 1858 in ExiteCMS for trunk/login.php


Ignore:
Timestamp:
10/17/08 16:40:38 (4 years ago)
Author:
hverton
Message:

rewritten the login/logout code, all code is now located in setuser.php
added a security setting "require SSL for logins"
added a security setting "require login before site access"
fixed small date display issue in several rev. upgrade files
added alternative login methods to the full-screen login

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/login.php

    r1765 r1858  
    11<?php 
    22/*---------------------------------------------------+ 
    3 | PHP-Fusion 6 Content Management System 
     3| ExiteCMS Content Management System                 | 
    44+----------------------------------------------------+ 
    5 | Copyright © 2002 - 2006 Nick Jones 
    6 | http://www.php-fusion.co.uk/ 
     5| Copyright 2007 Harro "WanWizard" Verton, Exite BV  | 
     6| for support, please visit http://exitecms.exite.eu | 
    77+----------------------------------------------------+ 
    8 | Released under the terms & conditions of v2 of the 
    9 | GNU General Public License. For details refer to 
    10 | the included gpl.txt file or visit http://gnu.org 
     8| Some portions copyright 2002 - 2006 Nick Jones     | 
     9| http://www.php-fusion.co.uk/                       | 
     10+----------------------------------------------------+ 
     11| Released under the terms & conditions of v2 of the | 
     12| GNU General Public License. For details refer to   | 
     13| the included gpl.txt file or visit http://gnu.org  | 
    1114+----------------------------------------------------*/ 
    1215require_once dirname(__FILE__)."/includes/core_functions.php"; 
    13 require_once dirname(__FILE__)."/includes/theme_functions.php"; 
     16require_once PATH_INCLUDES."theme_functions.php"; 
    1417 
    1518// redirect back to the homepage if already logged in 
    1619if (iMEMBER) { 
    1720    header("Location:".BASEDIR."index.php"); 
     21    exit; 
     22} 
     23 
     24// check if HTTPS if required, and if so, present. 
     25if ($settings['auth_ssl'] && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != "on")) { 
     26    header("Location:".BASEDIR."setuser.php?error=5"); 
     27    exit; 
    1828} 
    1929 
     
    2131$variables = array(); 
    2232 
     33$variables['loginerror'] = isset($loginerror) ? $loginerror : ""; 
     34$variables['remember_me'] = isset($_SESSION['remember_me']) ? $_SESSION['remember_me'] : "no"; 
     35$variables['login_expiry']  = (iADMIN && isset($_SESSION['login_expire'])) ? time_system2local($_SESSION['login_expire']) : ""; 
     36 
     37// get which authentication to show 
     38$variables['auth_methods'] = explode(",",$settings['auth_type']); 
     39$variables['method_count'] = count($variables['auth_methods']); 
     40$variables['auth_state'] = array(); 
     41foreach($variables['auth_methods'] as $key => $method) { 
     42    if (isset($_SESSION['box_login'.$key])) { 
     43        $variables['auth_state'][] = $_SESSION['box_login'.$key] == 0 ? 1 : 0; 
     44    } else { 
     45        $variables['auth_state'][] = 1; 
     46    } 
     47} 
     48 
     49// check if we need to display a registration link 
     50if ($settings['enable_registration']) { 
     51    $variables['show_reglink'] = true; 
     52    // get all menu items for this user 
     53    $linkinfo = array(); 
     54    require_once PATH_INCLUDES."menu_include.php"; 
     55    menu_generate_tree("", array(1,2,3), false); 
     56    foreach ($linkinfo as $link) { 
     57        if ($link['link_url'] == "/register.php") { 
     58            $variables['show_reglink'] = false; 
     59            break; 
     60        } 
     61    } 
     62} else { 
     63    $variables['show_reglink'] = false; 
     64} 
     65 
     66// check if we need to display links 
     67$variables['show_passlink'] = 1; 
     68 
    2369// define the first body panel variables 
    2470$template_panels[] = array('type' => 'body', 'name' => 'login', 'template' => 'main.login.tpl'); 
    2571$template_variables['login'] = $variables; 
    2672 
     73// make sure updates to session variables are written 
     74session_write_close(); 
     75 
    2776load_templates('body', ''); 
    2877 
    29 // close the database connection 
    30 mysql_close(); 
    31  
    32 // and flush any output remaining 
    33 ob_end_flush(); 
     78// and clean up 
     79theme_cleanup(); 
    3480?> 
Note: See TracChangeset for help on using the changeset viewer.