Changeset 1858 in ExiteCMS


Ignore:
Timestamp:
10/17/08 16:40:38 (3 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

Location:
trunk
Files:
1 added
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/administration/settings_security.php

    r1639 r1858  
    8080            $result = dbquery("UPDATE ".$db_prefix."configuration SET cfg_value = '$login_expire' WHERE cfg_name = 'login_expire'"); 
    8181            $result = dbquery("UPDATE ".$db_prefix."configuration SET cfg_value = '$login_extended_expire' WHERE cfg_name = 'login_extended_expire'"); 
     82            $result = dbquery("UPDATE ".$db_prefix."configuration SET cfg_value = '".(isNum($_POST['auth_ssl']) ? $_POST['auth_ssl'] : "0")."' WHERE cfg_name = 'auth_ssl'"); 
     83            $result = dbquery("UPDATE ".$db_prefix."configuration SET cfg_value = '".(isNum($_POST['auth_required']) ? $_POST['auth_required'] : "0")."' WHERE cfg_name = 'auth_required'"); 
    8284        } 
    8385    } 
  • trunk/administration/tools/language_pack_English.php

    r1836 r1858  
    10821082        $localestrings['573'] = "News:"; 
    10831083        $localestrings['574'] = "Downloads:"; 
     1084        $localestrings['575'] = "Login requires HTTPS:"; 
     1085        $localestrings['576'] = "Site access requires login:"; 
    10841086        $localestrings['600'] = "Albums"; 
    10851087        $localestrings['601'] = "Thumb size:"; 
     
    30323034        $localestrings['ac04'] = "Installed Modules"; 
    30333035        $localestrings['ac05'] = "Webmaster Toolbox"; 
     3036        $localestrings['https'] = "This website allows only logins secured by HTTPS"; 
    30343037        $localestrings['sysusr'] = "Automatic Post"; 
    30353038        $localestrings['user0'] = "Public"; 
     
    37433746if (!defined('LP_COUNTRIES')) define('LP_COUNTRIES', "us|gb|ca|au|nz|in|za|ir|mt|hk|pr"); 
    37443747if (!defined('LP_VERSION')) define('LP_VERSION', "7.20"); 
    3745 if (!defined('LP_DATE')) define('LP_DATE', "1223543930"); 
     3748if (!defined('LP_DATE')) define('LP_DATE', "1224253694"); 
    37463749$lp_date = LP_DATE; 
    37473750 
  • trunk/administration/tools/language_pack_Nederlands.php

    r1841 r1858  
    10821082        $localestrings['573'] = "Nieuws:"; 
    10831083        $localestrings['574'] = "Downloads:"; 
     1084        $localestrings['575'] = "Login vereist HTTPS:"; 
     1085        $localestrings['576'] = "Login verplicht voor site toegang:"; 
    10841086        $localestrings['600'] = "Albums"; 
    10851087        $localestrings['601'] = "Formaat miniatuur:"; 
     
    30323034        $localestrings['ac04'] = "Optionele Modules"; 
    30333035        $localestrings['ac05'] = "Gereedschapskist"; 
     3036        $localestrings['https'] = "Deze website staat alleen via HTTPS beveiligde logins toe"; 
    30343037        $localestrings['sysusr'] = "Automatisch Bericht"; 
    30353038        $localestrings['user0'] = "Publiek"; 
     
    37433746if (!defined('LP_COUNTRIES')) define('LP_COUNTRIES', "nl|be|sr|aw|an"); 
    37443747if (!defined('LP_VERSION')) define('LP_VERSION', "7.20"); 
    3745 if (!defined('LP_DATE')) define('LP_DATE', "1223544215"); 
     3748if (!defined('LP_DATE')) define('LP_DATE', "1224253697"); 
    37463749$lp_date = LP_DATE; 
    37473750 
  • trunk/administration/upgrade/rev01782.php

    r1803 r1858  
    2222// register this revision update 
    2323$revisions[] = array('revision' => $_revision,  
    24                     'date' => mktime(18,00,0,19,9,2008),  
     24                    'date' => mktime(18,00,0,9,19,2008),  
    2525                    'title' => "Required updates for ExiteCMS v7.1 rev.".$_revision, 
    2626                    'description' => "Database modifications for the new Photo Albums module."); 
  • trunk/administration/upgrade/rev01804.php

    r1804 r1858  
    2222// register this revision update 
    2323$revisions[] = array('revision' => $_revision,  
    24                     'date' => mktime(17,00,0,4,10,2008),  
     24                    'date' => mktime(17,00,0,10,4,2008),  
    2525                    'title' => "Required updates for ExiteCMS v7.1 rev.".$_revision, 
    2626                    'description' => "Photo Albums side panels."); 
  • trunk/administration/upgrade/rev01818.php

    r1818 r1858  
    2222// register this revision update 
    2323$revisions[] = array('revision' => $_revision,  
    24                     'date' => mktime(23,00,0,5,10,2008),  
     24                    'date' => mktime(23,00,0,10,5,2008),  
    2525                    'title' => "Required updates for ExiteCMS v7.1 rev.".$_revision, 
    2626                    'description' => "Moved the release to version 7.2."); 
  • trunk/files/locales/en.main.global.php

    r1841 r1858  
    33// locale       : English 
    44// locale name  : main.global 
    5 // generated on : Thu Oct 9 2008, 11:18:53 CEST 
     5// generated on : Fri Oct 17 2008, 16:28:20 CEST 
    66// translators  : ExiteCMS team,WanWizard 
    77// ---------------------------------------------------------- 
     
    141141$locale['ac04'] = "Installed Modules"; 
    142142$locale['ac05'] = "Webmaster Toolbox"; 
     143$locale['https'] = "This website allows only logins secured by HTTPS"; 
    143144$locale['sysusr'] = "Automatic Post"; 
    144145$locale['user0'] = "Public"; 
  • trunk/files/locales/en.main.setup.php

    r1841 r1858  
    33// locale       : English 
    44// locale name  : main.setup 
    5 // generated on : Thu Oct 9 2008, 11:18:50 CEST 
     5// generated on : Fri Oct 17 2008, 16:28:14 CEST 
    66// translators  : ExiteCMS team,WanWizard 
    77// ---------------------------------------------------------- 
  • trunk/files/locales/nl.main.global.php

    r1841 r1858  
    33// locale       : English 
    44// locale name  : main.global 
    5 // generated on : Thu Oct 9 2008, 11:23:35 CEST 
     5// generated on : Fri Oct 17 2008, 16:28:17 CEST 
    66// translators  : ExiteCMS team,WanWizard 
    77// ---------------------------------------------------------- 
     
    141141$locale['ac04'] = "Optionele Modules"; 
    142142$locale['ac05'] = "Gereedschapskist"; 
     143$locale['https'] = "Deze website staat alleen via HTTPS beveiligde logins toe"; 
    143144$locale['sysusr'] = "Automatisch Bericht"; 
    144145$locale['user0'] = "Publiek"; 
  • trunk/files/locales/nl.main.setup.php

    r1841 r1858  
    33// locale       : English 
    44// locale name  : main.setup 
    5 // generated on : Thu Oct 9 2008, 11:23:35 CEST 
     5// generated on : Fri Oct 17 2008, 16:28:17 CEST 
    66// translators  : ExiteCMS team,WanWizard 
    77// ---------------------------------------------------------- 
  • trunk/includes/session_functions.php

    r1853 r1858  
    5555 
    5656// store the last_url cookie if found 
    57 if (isset($_COOKIE['last_url']) && isURL($_COOKIE['last_url'])) { 
     57if (isset($_COOKIE['last_url']) && (isURL($_COOKIE['last_url']) || isURL($settings['siteurl'].$_COOKIE['last_url'])) && $_COOKIE['last_url'] != BASEDIR."setuser.php?login=yes") { 
    5858    $_SESSION['last_url'] = stripinput($_COOKIE['last_url']); 
    5959} 
  • trunk/includes/templates/admin.settings_security.tpl

    r1639 r1858  
    102102        </tr> 
    103103        <tr> 
     104            <td width='50%' class='tbl'> 
     105                {$locale.575} 
     106            </td> 
     107            <td width='50%' class='tbl'> 
     108                <select name='auth_ssl' class='textbox'> 
     109                    <option value='0'{if $settings2.auth_ssl == "0"} selected="selected"{/if}>{$locale.509}</option> 
     110                    <option value='1'{if $settings2.auth_ssl == "1"} selected="selected"{/if}>{$locale.508}</option> 
     111                </select> 
     112            </td> 
     113        </tr> 
     114        <tr> 
     115            <td width='50%' class='tbl'> 
     116                {$locale.576} 
     117            </td> 
     118            <td width='50%' class='tbl'> 
     119                <select name='auth_required' class='textbox'> 
     120                    <option value='0'{if $settings2.auth_required == "0"} selected="selected"{/if}>{$locale.509}</option> 
     121                    <option value='1'{if $settings2.auth_required == "1"} selected="selected"{/if}>{$locale.508}</option> 
     122                </select> 
     123            </td> 
     124        </tr> 
     125        <tr> 
    104126            <td align='center' colspan='2' class='tbl'> 
    105127                <hr /> 
  • trunk/includes/templates/main.login.tpl

    r929 r1858  
    99{* Revision History:                                                        *} 
    1010{* 2007-07-09 - WW - Initial version                                        *} 
     11{* 2008-10-17 - WW - Rewritten to support OpenId etc.                       *} 
    1112{*                                                                          *} 
    1213{****************************************************************************} 
     
    1516{*                                                                          *} 
    1617{****************************************************************************} 
    17 <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'> 
    18 <html> 
    19 <head> 
    20 <title>{$settings.sitename}</title> 
    21 <meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'> 
    22 {include file='_stylesheets.tpl'} 
    23 </head> 
    24 <body class='tbl2'> 
    25  
    26 <table width='100%' height='100%'> 
    27 <tr> 
    28 <td> 
    29  
    30 <table align='center' cellpadding='0' cellspacing='1' width='500' class='tbl-border'> 
    31 <tr> 
    32 <td class='tbl1' style='font-size:11px'> 
    33 <center> 
    34 <br /> 
    35 <img src='{$smarty.const.THEME}images/{$settings.sitebanner}' alt='{$settings.sitename}'><br /><br /> 
    36 <form name='loginform' method='post' action='{$smarty.const.FUSION_SELF}'> 
    37     {$locale.061}<br /><input type='text' name='user_name' class='textbox' style='width:100px' /><br /> 
    38     {$locale.062}<br /><input type='password' name='user_pass' class='textbox' style='width:100px' /><br /> 
    39     <br /> 
    40     <input type='checkbox' name='remember_me' value='y' title='{$locale.063}' style='vertical-align:middle;'{if $remember_me|default:"no" == "yes"} checked{/if}/> 
    41     <input type='submit' name='login' value='{$locale.064}' class='button' /> 
    42     <input type='hidden' name='javascript_check' value='n' /> 
    43     <br /><br /> 
    44 </form> 
    45 </center> 
    46 </td> 
    47 </tr> 
    48 </table> 
    49  
    50 </td> 
    51 </tr> 
    52 </table> 
    53  
    54 </body> 
     18<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
     19<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="{$settings.locale_code|truncate:2:""}" lang="{$settings.locale_code|truncate:2:""}" dir="{$smarty.const.LOCALEDIR}"> 
     20    <head> 
     21        <title>{$settings.sitename}{if defined('PAGETITLE')} - {$smarty.const.PAGETITLE}{/if}</title> 
     22        <meta http-equiv='Content-Type' content='text/html; charset={$settings.charset}' /> 
     23        <meta http-equiv='Content-Language' content='{$settings.locale_code|truncate:2:""}' /> 
     24        <meta http-equiv='refresh' content='{$refresh}; url={$url}'> 
     25        <link href="{$smarty.const.THEME}exitecms__0001.css" rel="stylesheet" type="text/css" /> 
     26    </head> 
     27    <body class='body'> 
     28        <div class='splashscreen-h'> 
     29            <div class='splashscreen-v' style='height:350px;vertical-align:center;'> 
     30                <table align='center' cellpadding='0' cellspacing='1' width='500'> 
     31                    <tr> 
     32                        <td class='tbl1' align='center'> 
     33                            <form name='loginform1' method='post' action='{$smarty.const.BASEDIR}setuser.php?login=yes'> 
     34                                <img src='{$smarty.const.THEME}images/{$settings.sitebanner}' alt='{$settings.sitename}' style='width:480px;margin:5px;'/> 
     35                                {foreach from=$auth_methods item=method key=i} 
     36                                    {if $method_count > 1} 
     37                                        {if $method == "ldap"} 
     38                                            <div class='side-label'> 
     39                                                {$locale.069} {$method|upper} {$locale.061}: 
     40                                            </div> 
     41                                            <div id='box_login{$i}' name='login{$i}' style='display:{if $auth_state.$i}block{else}none{/if};'> 
     42                                        {elseif $method == "ad"} 
     43                                            <div class='side-label'> 
     44                                                {$locale.069} {$method|upper} {$locale.061}: 
     45                                            </div> 
     46                                            <div id='box_login{$i}' name='login{$i}' style='display:{if $auth_state.$i}block{else}none{/if};'> 
     47                                        {elseif $method == "local"} 
     48                                            <div class='side-label'> 
     49                                                {$locale.069} {$locale.061}: 
     50                                            </div> 
     51                                            <div id='box_login{$i}' name='login{$i}' style='display:{if $auth_state.$i}block{else}none{/if};'> 
     52                                        {elseif $method == "openid"} 
     53                                            <div class='side-label'> 
     54                                                {$locale.069} {$locale.067}: 
     55                                            </div> 
     56                                            <div id='box_login{$i}' name='login{$i}' style='display:{if $auth_state.$i}block{else}none{/if};'> 
     57                                        {/if} 
     58                                    {/if} 
     59                                    <div style='padding:5px;'> 
     60                                    {if $method == "ldap"} 
     61                                        {$locale.061}: <input type='text' name='ldap_name' class='textbox' style='width:145px' /> 
     62                                        &nbsp;&nbsp;&nbsp; 
     63                                        {$locale.062}: <input type='password' name='ldap_pass' class='textbox' style='width:145px' /><br /> 
     64                                    {elseif $method == "ad"} 
     65                                        {$locale.061}: <input type='text' name='ad_name' class='textbox' style='width:145px' /> 
     66                                        &nbsp;&nbsp;&nbsp; 
     67                                        {$locale.062}: <input type='password' name='ad_pass' class='textbox' style='width:145px' /><br /> 
     68                                    {elseif $method == "local"} 
     69                                        {$locale.061}: <input type='text' name='user_name' class='textbox' style='width:145px' /> 
     70                                        &nbsp;&nbsp;&nbsp; 
     71                                        {$locale.062}: <input type='password' name='user_pass' class='textbox' style='width:145px' /><br /> 
     72                                    {elseif $method == "openid"} 
     73                                        <input type='text' name='user_openid_url' class='textbox' style='width:128px;background: url({$smarty.const.IMAGES}openid_small_logo.gif) no-repeat; padding-left: 18px;' /> 
     74                                        &nbsp;&nbsp;&nbsp; 
     75                                        <span class='small' style='font-size:90%;'>  <a href="http://{$settings.locale_code}.wikipedia.org/wiki/OpenID"  target="_blank">{$locale.068}</a></span><br /> 
     76                                    {/if} 
     77                                    </div> 
     78                                    {if $method_count > 1} 
     79                                        </div> 
     80                                    {/if}            
     81                                {/foreach} 
     82                                    <hr /> 
     83                                    <div style='text-align:center'> 
     84                                        <input type='checkbox' name='remember_me' value='yes' title='{$locale.063}' style='vertical-align:middle;'{if $remember_me|default:"no" == "yes"} checked="checked"{/if}/> 
     85                                        <input type='submit' name='login' value='{$locale.064}' class='button' /><br /> 
     86                                        <input type='hidden' name='javascript_check' value='n' /> 
     87                                    </div> 
     88                                </form> 
     89                            {literal} 
     90                            <script type='text/javascript'> 
     91                            /* <![CDATA[ */ 
     92                                if (document.loginform1.javascript_check.value == 'n') 
     93                                { 
     94                                    document.loginform1.javascript_check.value = 'y'; 
     95                                } 
     96                                /* ]]> */ 
     97                            </script> 
     98                                {/literal} 
     99                            {if $show_reglink || $show_passlink} 
     100                                <hr /> 
     101                            {/if} 
     102                            {if $show_reglink}{$settings.siteurl|string_format:$locale.065}<br /><br />{/if} 
     103                            {if $show_passlink}{$settings.siteurl|string_format:$locale.066}{/if} 
     104                        </td> 
     105                    </tr> 
     106                </table> 
     107            </div> 
     108        </div> 
     109    </body> 
    55110</html> 
    56111{***************************************************************************} 
  • trunk/includes/templates/main.setuser.tpl

    r1802 r1858  
    3939                {$message.line3|default:""}<br /> 
    4040                {$message.line4|default:""}<br /> 
    41                 <br /> 
    42                 {$locale.183} 
    43                 <br /> 
    44                 {if $error != 0}[ <a href='{$url}'>{$locale.184}</a> ]{/if} 
    45                 <br /><br /> 
     41                {if $refresh < 99999} 
     42                    <br /> 
     43                    {$locale.183} 
     44                    <br /> 
     45                    {if $refresh > 1}[ <a href='{$url}'>{$locale.184}</a> ]{/if} 
     46                    <br /><br /> 
     47                {/if} 
    4648                </center> 
    4749            </div> 
  • trunk/includes/user_functions.php

    r1840 r1858  
    5656} 
    5757 
    58 // Check if a user wants to logging in 
    59 if (isset($_POST['login'])) { 
    60     $auth_result = false; 
    61     $auth_methods = isset($settings['auth_type']) ? explode(",",$settings['auth_type'].",") : array('local'); 
    62     foreach($auth_methods as $auth_method) { 
    63         switch($auth_method) { 
    64             case "local": 
    65                 // authentication against the local user database 
    66                 if (!empty($_POST['user_name']) && !empty($_POST['user_pass'])) { 
    67                     $auth_result = auth_local($_POST['user_name'], $_POST['user_pass']); 
    68                 } 
    69                 break; 
    70             case "ldap": 
    71                 break; 
    72             case "ad": 
    73                 break; 
    74             case "openid": 
    75                 // authentication against an openid provider 
    76                 if (!empty($_POST['user_openid_url'])) { 
    77                     $auth_result = auth_openid($_POST['user_openid_url']); 
    78                 } 
    79                 break; 
    80             case "default": 
    81                 // empty or unknown entry, ignore 
    82                 break; 
    83         } 
    84     } 
    85     // check the result of the authentication attempt, and process it 
    86     if (is_array($auth_result)) { 
    87         switch($auth_result[0]) { 
    88             case "redirect": 
    89                 redirect($auth_result[1], $auth_result[2]); 
    90                 exit;  
    91             default: 
    92                 // unknown result code 
    93                 _debug($auth_result); 
    94                 terminate("unknown result code from an authentication module!"); 
    95         } 
    96     } 
    97 } 
    98  
    99 // if not in the process of posting a form, did the login session expired? 
     58// if not in the process of posting a form, did the login session expire? 
    10059if (count($_POST)==0 && !empty($_SESSION['login_expire']) && $_SESSION['login_expire'] < time()) { 
    10160    // clear the login info from the session 
     
    164123    } 
    165124} else { 
     125    // is login required? 
     126    if ($settings['auth_required'] && FUSION_SELF != "login.php" && FUSION_SELF != "setuser.php") { 
     127        redirect(BASEDIR."login.php", "script"); 
     128        exit; 
     129    } 
    166130    define("PATH_THEME", PATH_THEMES.$settings['theme']."/"); 
    167131    define("THEME", THEMES.$settings['theme']."/"); 
     
    275239        // deny all non-webmasters access to the site 
    276240        redirect(BASEDIR.'maintenance.php?reason='.$settings['maintenance']); 
    277     } 
    278 } 
    279  
    280  
    281 /*---------------------------------------------------+ 
    282 | User authentication functions                      | 
    283 +----------------------------------------------------*/ 
    284  
    285 // authentication against the local user database 
    286 function auth_local($userid, $password) { 
    287     global $db_prefix; 
    288      
    289     // check and validate the given userid and pasword 
    290     $user_pass = md5(md5($password)); 
    291     $user_name = preg_replace(array("/\=/","/\#/","/\sOR\s/"), "", stripinput($userid)); 
    292  
    293     // check if we have a user record for this userid and password 
    294     $result = dbquery("SELECT * FROM ".$db_prefix."users WHERE user_name='$user_name' AND user_password='".$user_pass."'"); 
    295     if (dbrows($result) == 0) { 
    296         // not found, display an error message 
    297         return array("redirect", BASEDIR."setuser.php?error=3", "script"); 
    298     } else { 
    299         // found, get the record and do some more validation 
    300         $ret = auth_user_validate(dbarray($result)); 
    301         return $ret; 
    302     } 
    303 } 
    304  
    305 // authentication against an LDAP server 
    306 function auth_ldap($userid, $password) { 
    307     return array('auth_ldap not defined yet!'); 
    308 } 
    309  
    310 // authentication against an Active Directory server 
    311 function auth_ad($userid, $password) { 
    312     return array('auth_ad not defined yet!'); 
    313 } 
    314  
    315 // authentication using an OpenID 
    316 function auth_openid($openid_url) { 
    317     global $settings; 
    318  
    319     // check if the URL is valid 
    320     if (isURL($openid_url)) { 
    321         require_once(PATH_INCLUDES."class.openid.php"); 
    322         $openid = new SimpleOpenID; 
    323         $openid->SetIdentity($openid_url); 
    324         $openid->SetApprovedURL($settings['siteurl']."setuser.php"); 
    325         $openid->SetTrustRoot($settings['siteurl']); 
    326         $server_url = $openid->GetOpenIDServer(); 
    327         if ($server_url) { 
    328             return array("redirect", $openid->GetRedirectURL() , "script"); 
    329         } 
    330     } else { 
    331         // for now... 
    332         return false; 
    333     } 
    334 } 
    335  
    336 // further validation on the userid found 
    337 function auth_user_validate($userrecord) { 
    338  
    339     // if the account is suspended, check for an expiry date 
    340     if ($userrecord['user_status'] == 1 && $userrecord['user_ban_expire'] > 0 && $userrecord['user_ban_expire'] < time() ) { 
    341         // if this user's email address is marked as bad, reset the countdown counter 
    342         $userrecord['user_bad_email'] = $userrecord['user_bad_email'] == 0 ? 0 : time(); 
    343         // reset the user status and the expiry date 
    344         $result = dbquery("UPDATE ".$db_prefix."users SET user_status='0', user_ban_expire='0', user_bad_email = '".$userrecord['user_bad_email']."' WHERE user_id='".$userrecord['user_id']."'"); 
    345         $userrecord['user_status'] = 0; 
    346     } 
    347     if ($userrecord['user_status'] == 0) {   
    348         header("P3P: CP='NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM'"); 
    349         // set the 'remember me' status value  
    350         $_SESSION['remember_me'] = isset($_POST['remember_me']) ? "yes" : "no"; 
    351         $_SESSION['userinfo'] = $userrecord['user_id'].".".$userrecord['user_password']; 
    352         // login expiry defined? 
    353         if ($settings['login_expire']) { 
    354             if (isset($_POST['remember_me']) && $_POST['remember_me'] == "yes") { 
    355                 $_SESSION['login_expire'] = time() + $settings['login_extended_expire']; 
    356             } else { 
    357                 $_SESSION['login_expire'] = time() + $settings['login_expire']; 
    358             } 
    359         } else { 
    360             $_SESSION['login_expire'] = mktime(0,0,0,1,1,2038); // do not expire 
    361         } 
    362         return array("redirect", BASEDIR."setuser.php?user=".$userrecord['user_name'], "script"); 
    363     } elseif ($userrecord['user_status'] == 1) { 
    364         return array("redirect", BASEDIR."setuser.php?user_id=".$userrecord['user_id']."&error=1", "script"); 
    365     } elseif ($userrecord['user_status'] == 2) { 
    366         return array("redirect", BASEDIR."setuser.php?error=2", "script"); 
    367241    } 
    368242} 
  • 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?> 
  • trunk/modules/user_info_panel/templates/modules.user_info_panel.tpl

    r1844 r1858  
    5555        </div> 
    5656    </div> 
    57 {else} 
     57    {include file="_closeside_x.tpl"} 
     58{elseif $settings.auth_ssl == 0 || $_SERVER.HTTPS|default:"" == "on"} 
    5859    {include file="_openside.tpl" name=$_name title=$locale.060 state=$_state style=$_style} 
    5960    <div style='text-align:center'> 
    6061        {$loginerror|default:""} 
    6162    </div> 
    62     <form name='loginform1' method='post' action='{$smarty.const.FUSION_SELF}'> 
     63    <form name='loginform1' method='post' action='{$smarty.const.BASEDIR}setuser.php?login=yes'> 
    6364        {foreach from=$auth_methods item=method key=i} 
    6465            {if $method_count > 1} 
     
    138139    {if $show_reglink}{$settings.siteurl|string_format:$locale.065}<br /><br />{/if} 
    139140    {if $show_passlink}{$settings.siteurl|string_format:$locale.066}{/if} 
    140 {/if} 
    141 {if $smarty.const.iMEMBER|default:false} 
    142     {include file="_closeside_x.tpl"} 
    143 {else} 
    144141    {include file="_closeside.tpl"} 
    145142{/if} 
  • trunk/setuser.php

    r1853 r1858  
    33| ExiteCMS Content Management System                 | 
    44+----------------------------------------------------+ 
    5 | Copyright 2007 Harro "WanWizard" Verton, Exite BV  | 
     5| Copyright 2008 Harro "WanWizard" Verton, Exite BV  | 
    66| for support, please visit http://exitecms.exite.eu | 
    77+----------------------------------------------------+ 
     
    1414+----------------------------------------------------*/ 
    1515require_once dirname(__FILE__)."/includes/core_functions.php"; 
    16 require_once dirname(__FILE__)."/includes/theme_functions.php"; 
     16require_once PATH_INCLUDES."theme_functions.php"; 
     17 
     18/*---------------------------------------------------+ 
     19| User authentication functions                      | 
     20+----------------------------------------------------*/ 
     21 
     22// authentication against the local user database 
     23function auth_local($userid, $password) { 
     24    global $db_prefix; 
     25     
     26    // check and validate the given userid and pasword 
     27    $user_pass = md5(md5($password)); 
     28    $user_name = preg_replace(array("/\=/","/\#/","/\sOR\s/"), "", stripinput($userid)); 
     29 
     30    // check if we have a user record for this userid and password 
     31    $result = dbquery("SELECT * FROM ".$db_prefix."users WHERE user_name='$user_name' AND user_password='".$user_pass."'"); 
     32    if (dbrows($result) == 0) { 
     33        // not found, display an error message 
     34        return 3; 
     35    } else { 
     36        // found, get the record and do some more validation 
     37        $ret = auth_user_validate(dbarray($result)); 
     38        return $ret; 
     39    } 
     40} 
     41 
     42// authentication against an LDAP server 
     43function auth_ldap($userid, $password) { 
     44    terminate('auth_ldap not defined yet!'); 
     45} 
     46 
     47// authentication against an Active Directory server 
     48function auth_ad($userid, $password) { 
     49    terminate('auth_ad not defined yet!'); 
     50} 
     51 
     52// authentication using an OpenID 
     53function auth_openid($openid_url) { 
     54    global $settings; 
     55 
     56    // check if the URL is valid 
     57    if (isURL($openid_url)) { 
     58        require_once(PATH_INCLUDES."class.openid.php"); 
     59        $openid = new SimpleOpenID; 
     60        $openid->SetIdentity($openid_url); 
     61        $openid->SetApprovedURL($settings['siteurl']."setuser.php"); 
     62        $openid->SetTrustRoot($settings['siteurl']); 
     63        $server_url = $openid->GetOpenIDServer(); 
     64        if ($server_url) { 
     65            redirect($openid->GetRedirectURL() , "script"); 
     66            exit; 
     67        } 
     68    } else { 
     69        // for now... 
     70        return 0; 
     71    } 
     72} 
     73 
     74// further validation on the userid found 
     75function auth_user_validate($userrecord) { 
     76    global $settings; 
     77 
     78    // if the account is suspended, check for an expiry date 
     79    if ($userrecord['user_status'] == 1 && $userrecord['user_ban_expire'] > 0 && $userrecord['user_ban_expire'] < time() ) { 
     80        // if this user's email address is marked as bad, reset the countdown counter 
     81        $userrecord['user_bad_email'] = $userrecord['user_bad_email'] == 0 ? 0 : time(); 
     82        // reset the user status and the expiry date 
     83        $result = dbquery("UPDATE ".$db_prefix."users SET user_status='0', user_ban_expire='0', user_bad_email = '".$userrecord['user_bad_email']."' WHERE user_id='".$userrecord['user_id']."'"); 
     84        $userrecord['user_status'] = 0; 
     85    } 
     86    if ($userrecord['user_status'] == 0) {   
     87        header("P3P: CP='NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM'"); 
     88        // set the 'remember me' status value  
     89        $_SESSION['remember_me'] = isset($_POST['remember_me']) ? "yes" : "no"; 
     90        $_SESSION['userinfo'] = $userrecord['user_id'].".".$userrecord['user_password']; 
     91        // login expiry defined? 
     92        if ($settings['login_expire']) { 
     93            if (isset($_POST['remember_me']) && $_POST['remember_me'] == "yes") { 
     94                $_SESSION['login_expire'] = time() + $settings['login_extended_expire']; 
     95            } else { 
     96                $_SESSION['login_expire'] = time() + $settings['login_expire']; 
     97            } 
     98        } else { 
     99            $_SESSION['login_expire'] = mktime(0,0,0,1,1,2038); // do not expire 
     100        } 
     101        return 4; 
     102    } elseif ($userrecord['user_status'] == 1) { 
     103        return 1; 
     104    } elseif ($userrecord['user_status'] == 2) { 
     105        return 2; 
     106    } else { 
     107        return 0; 
     108    } 
     109} 
     110 
     111 
     112/*---------------------------------------------------+ 
     113| Main code                                          | 
     114+----------------------------------------------------*/ 
     115 
    17116// temp storage for template variables 
    18117$variables = array(); 
     118 
     119// array to store the lines of the setuser message 
     120$message = array(); 
     121 
     122// make sure the error variable has a value 
     123if (!isset($error) || !isNum($error)) $error = 0; 
    19124 
    20125// set the redirect url (set in theme_cleanup), butnot when in maintenance! 
     
    29134} 
    30135 
    31 // array to store the lines of the setuser message 
    32 $message = array(); 
    33  
    34 // make sure the error parameter has a value 
    35 if (!isset($error) || !isNum($error)) $error = 0; 
    36  
    37 if (isset($_REQUEST['logout']) && $_REQUEST['logout'] == "yes") { 
     136if (isset($_GET['logout']) && $_GET['logout'] == "yes") { 
     137 
     138    // process the logout request 
     139 
    38140    header("P3P: CP='NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM'"); 
    39141    // make sure the user info is erased from the session 
     
    45147        $message['line2'] =  "<b>".$locale['192'].$userdata['user_name']."</b>"; 
    46148    } 
     149 
     150} elseif (isset($_GET['login']) && $_GET['login'] == "yes") { 
     151 
     152    // process the login request 
     153    $auth_methods = isset($settings['auth_type']) ? explode(",",$settings['auth_type'].",") : array('local'); 
     154    foreach($auth_methods as $auth_method) { 
     155        switch($auth_method) { 
     156            case "local": 
     157                // authentication against the local user database 
     158                if (!empty($_POST['user_name']) && !empty($_POST['user_pass'])) { 
     159                    $error = auth_local($_POST['user_name'], $_POST['user_pass']); 
     160                } 
     161                break; 
     162            case "ldap": 
     163                break; 
     164            case "ad": 
     165                break; 
     166            case "openid": 
     167                // authentication against an openid provider 
     168                if (!empty($_POST['user_openid_url'])) { 
     169                    $error = auth_openid($_POST['user_openid_url']); 
     170                } 
     171                break; 
     172            case "default": 
     173                // empty or unknown entry, ignore 
     174                break; 
     175        } 
     176    } 
     177 
    47178} else { 
    48     if ($error == 1) { 
     179 
     180    if (isset($_GET['openid_mode'])) { 
     181        // handle openid login 
     182        require_once(PATH_INCLUDES."class.openid.php"); 
     183        $openid = new SimpleOpenID; 
     184        $openid->SetIdentity(urldecode($_GET['openid_identity'])); 
     185        if ($openid->ValidateWithServer()) { 
     186            $openid_url = strtolower($openid->OpenID_Standarize($_GET['openid_identity'])); 
     187            $result = dbquery("SELECT * FROM ".$db_prefix."users WHERE user_openid_url='".$openid_url."'"); 
     188            if (dbrows($result) != 0) { 
     189                // found, get the record and do some more validation 
     190                $error = auth_user_validate(dbarray($result)); 
     191            } else { 
     192                $message['line2'] =  "<b>".$locale['196']."</b>"; 
     193            } 
     194        } else { 
     195            trigger_error($openid->GetError()); 
     196            exit; 
     197        } 
     198    } 
     199 
     200} 
     201 
     202// check the result of the authentication attempt, and process it 
     203switch($error) { 
     204    case 0: 
     205        //  
     206        $refresh = 1; 
     207        break; 
     208    case 1: 
    49209        $message['line1'] = "<b>".$locale['194']."</b>"; 
    50210        $data = dbarray(dbquery("SELECT user_ban_reason, user_ban_expire FROM ".$db_prefix."users WHERE user_id='$user_id'")); 
     
    53213            if ($data['user_ban_expire'] > 0) $message['line4']  = "<b>".$locale['181']." ".showdate('forumdate', $data['user_ban_expire'])."</b>"; 
    54214        } 
    55     } elseif ($error == 2) { 
     215        $refresh = 10; 
     216        break; 
     217    case 2: 
    56218        $message['line2'] =  "<b>".$locale['195']."</b>"; 
    57     } elseif ($error == 3) { 
     219        $refresh = 10; 
     220        break; 
     221    case 3: 
    58222        $message['line2'] =  "<b>".$locale['196']."</b>"; 
    59     } else { 
    60         if (isset($_GET['openid_mode'])) { 
    61             // handle openid login 
    62             require_once(PATH_INCLUDES."class.openid.php"); 
    63             $openid = new SimpleOpenID; 
    64             $openid->SetIdentity(urldecode($_GET['openid_identity'])); 
    65             if ($openid->ValidateWithServer()) { 
    66                 $openid_url = strtolower($openid->OpenID_Standarize($_GET['openid_identity'])); 
    67                 $result = dbquery("SELECT * FROM ".$db_prefix."users WHERE user_openid_url='".$openid_url."'"); 
    68                 if (dbrows($result) != 0) { 
    69                     // found, get the record and do some more validation 
    70                     $res = auth_user_validate(dbarray($result)); 
    71                     if (!is_array($res)) { 
    72                         $message['line2'] =  "<b>Internal error: Invalid auth_user_validate() return code!</b>"; 
    73                     } 
    74                 } else { 
    75                     $message['line2'] =  "<b>".$locale['196']."</b>"; 
    76                 } 
    77             } else { 
    78                 trigger_error($openid->GetError()); 
    79                 exit; 
    80             } 
    81         } 
     223        $refresh = 10; 
     224        break; 
     225    case 4: 
    82226        if (isset($_SESSION['userinfo'])) { 
    83             // handle local login 
     227            // now that we have user info, finish the login validation 
    84228            $userinfo_vars = explode(".", $_SESSION['userinfo']); 
    85229            $user_pass = (preg_match("/^[0-9a-z]{32}$/", $userinfo_vars['1']) ? $userinfo_vars['1'] : ""); 
     
    92236                $result = dbquery("DELETE FROM ".$db_prefix."online WHERE online_user='0' AND online_ip='".USER_IP."'"); 
    93237                $message['line2'] =  "<b>".$locale['193'].$data['user_name']."</b>"; 
     238                $refresh = 1; 
    94239            } else { 
    95240                $message['line2'] =  "<b>".$locale['196']."</b>"; 
     241                $refresh = 10; 
    96242            } 
    97243        } else { 
    98244            $message['line2'] =  "<b>SESSION ERROR. Please report this to the Webmaster</b>"; 
    99         } 
    100     } 
     245            $refresh = 99999; 
     246        } 
     247        break; 
     248    case 5: 
     249        $message['line2'] =  "<b>".$locale['https']."</b>"; 
     250        $refresh = 99999; 
     251        break; 
     252    default: 
     253        // unknown result code 
     254        _debug($error); 
     255        terminate("unknown result code from an authentication module!"); 
     256        break; 
    101257} 
    102258 
     
    106262// auto-redirect counter (in seconds) 
    107263$variables['error'] = $error; 
    108 $variables['refresh'] = $error==0 ? 1 : 10; 
     264$variables['refresh'] = isset($refresh) ? $refresh : 10; 
    109265 
    110266// define the first body panel variables 
Note: See TracChangeset for help on using the changeset viewer.