Changeset 2095 in ExiteCMS
- Timestamp:
- 12/07/08 01:22:46 (3 years ago)
- Location:
- trunk
- Files:
-
- 6 added
- 16 edited
- 1 moved
-
administration/db_backups/index.php (modified) (1 prop)
-
administration/settings_security.php (modified) (3 diffs)
-
administration/tools/language_pack_English.php (modified) (2 diffs)
-
administration/tools/language_pack_Nederlands.php (modified) (2 diffs)
-
administration/upgrade/rev02094.php (added)
-
edit_profile.php (modified) (1 diff)
-
files/locales/en.main.global.php (modified) (1 diff)
-
files/locales/en.main.setup.php (modified) (1 diff)
-
files/locales/nl.main.global.php (modified) (1 diff)
-
files/locales/nl.main.setup.php (modified) (1 diff)
-
includes/authentication (added)
-
includes/authentication/auth_local.php (added)
-
includes/authentication/auth_openid.php (added)
-
includes/authentication/authentication.php (added)
-
includes/authentication/class.openid.php (moved) (moved from trunk/includes/class.openid.php)
-
includes/authentication/index.php (added)
-
includes/templates/admin.settings_image.tpl (modified) (1 diff)
-
includes/templates/admin.settings_security.tpl (modified) (4 diffs)
-
includes/templates/main.login.tpl (modified) (1 diff)
-
includes/user_functions.php (modified) (3 diffs)
-
login.php (modified) (1 diff)
-
modules/user_info_panel/user_info_panel.php (modified) (1 diff)
-
setuser.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/administration/db_backups/index.php
- Property svn:keywords set to Date Revision Author Id
-
trunk/administration/settings_security.php
r2033 r2095 29 29 $variables['this_module'] = FUSION_SELF; 30 30 31 if (!isset($action)) $action = ""; 32 31 33 // check for the proper admin access rights 32 34 if (!checkrights("S4") || !defined("iAUTH") || $aid != iAUTH) fallback(BASEDIR."index.php"); … … 44 46 } 45 47 if ($variables['errormessage'] == "") { 46 // authentication method check47 $auth_method = $_POST['auth_method']{0};48 $auth_local = (isset($_POST['auth_method']{1}) && $_POST['auth_method']{1} == "+") ? "1" : "0";49 switch ($auth_method) {50 case "0": // Local only51 $result = dbquery("UPDATE ".$db_prefix."configuration SET cfg_value = 'local' WHERE cfg_name = 'auth_type'");52 break;53 case "1": // LDAP54 if ($auth_local) {55 $result = dbquery("UPDATE ".$db_prefix."configuration SET cfg_value = 'ldap,local' WHERE cfg_name = 'auth_type'");56 } else {57 $result = dbquery("UPDATE ".$db_prefix."configuration SET cfg_value = 'ldap' WHERE cfg_name = 'auth_type'");58 }59 break;60 case "2": // AD61 if ($auth_local) {62 $result = dbquery("UPDATE ".$db_prefix."configuration SET cfg_value = 'ad,local' WHERE cfg_name = 'auth_type'");63 } else {64 $result = dbquery("UPDATE ".$db_prefix."configuration SET cfg_value = 'ad' WHERE cfg_name = 'auth_type'");65 }66 break;67 case "3": // OpenID68 if ($auth_local) {69 $result = dbquery("UPDATE ".$db_prefix."configuration SET cfg_value = 'local,openid' WHERE cfg_name = 'auth_type'");70 } else {71 $result = dbquery("UPDATE ".$db_prefix."configuration SET cfg_value = 'openid' WHERE cfg_name = 'auth_type'");72 }73 break;74 default:75 $variables['errormessage'] = "Invalid authentication method. This may never happen!";76 }77 48 if ($variables['errormessage'] == "") { 78 49 $result = dbquery("UPDATE ".$db_prefix."configuration SET cfg_value = '".(isNum($_POST['enable_registration']) ? $_POST['enable_registration'] : "1")."' WHERE cfg_name = 'enable_registration'"); … … 114 85 } 115 86 116 // check if the PHP installation supports the OpenID class 117 $variables['has_curl'] = function_exists('curl_exec'); 87 // load the defined authentication methods 88 $methods = unserialize($settings2['authentication_methods']); 89 $selected = explode(",", $settings2['authentication_selected']); 90 foreach ($methods as $name => $method) { 91 $methods[$name]['status'] = 'old'; 92 } 118 93 119 // determine the auth_method defined 120 $auth_methods = explode(",",$settings2['auth_type']); 121 $auth_method = 0; 122 $auth_local = false; 123 foreach($auth_methods as $this_method) { 124 switch($this_method) { 125 case "ldap": 126 $auth_method = 1; 127 break; 128 case "ad": 129 $auth_method = 2; 130 break; 131 case "openid": 132 // OpenID requires CURL to be installed 133 if ($variables['has_curl']) { 134 $auth_method = 3; 135 } 136 case "local": 137 $auth_local = true; 138 break; 139 default: 140 $auth_method = 0; 94 // status update request? 95 if ($action == "setstatus") { 96 if ($status == 1 && array_search($authmethod,$selected) == false) { 97 // add the method to the selected array and update the configuration 98 $selected[] = $authmethod; 99 } elseif ($status == 0 && array_search($authmethod,$selected) !== false) { 100 // remove the method from the selected array and update the configuration 101 unset($selected[array_search($authmethod,$selected)]); 102 } 103 // write the update back 104 $settings2['authentication_selected'] = ""; 105 foreach($selected as $sel) { 106 $settings2['authentication_selected'] .= ($settings2['authentication_selected'] == "" ? "" : ",").$sel; 107 } 108 $result = dbquery("UPDATE ".$db_prefix."configuration SET cfg_value = '".$settings2['authentication_selected']."' WHERE cfg_name = 'authentication_selected'"); 109 } 110 111 // move up requested? 112 if ($action == "up") { 113 // swap the selected method with the previous in the list 114 $sel = $selected[$method_id-1]; 115 $selected[$method_id-1] = $selected[$method_id]; 116 $selected[$method_id] = $sel; 117 // write the update back 118 $settings2['authentication_selected'] = ""; 119 foreach($selected as $sel) { 120 $settings2['authentication_selected'] .= ($settings2['authentication_selected'] == "" ? "" : ",").$sel; 121 } 122 $result = dbquery("UPDATE ".$db_prefix."configuration SET cfg_value = '".$settings2['authentication_selected']."' WHERE cfg_name = 'authentication_selected'"); 123 } 124 125 // move down requested? 126 if ($action == "down") { 127 // swap the selected method with the previous in the list 128 $sel = $selected[$method_id+1]; 129 $selected[$method_id+1] = $selected[$method_id]; 130 $selected[$method_id] = $sel; 131 // write the update back 132 $settings2['authentication_selected'] = ""; 133 foreach($selected as $sel) { 134 $settings2['authentication_selected'] .= ($settings2['authentication_selected'] == "" ? "" : ",").$sel; 135 } 136 $result = dbquery("UPDATE ".$db_prefix."configuration SET cfg_value = '".$settings2['authentication_selected']."' WHERE cfg_name = 'authentication_selected'"); 137 } 138 139 // check if new authentication methods have been installed 140 $files = makefilelist(PATH_INCLUDES."authentication", ".|..", $sort=true, $type="files", $hidden=false); 141 foreach($files as $file) { 142 if (substr($file,0,5) == "auth_" && strrchr($file,".") == ".php") { 143 $class = substr($file, 0, strrpos($file, ".")); 144 $method = substr($class, strrpos($file, "_")+1); 145 if (!isset($methods[$method])) { 146 $methods[$method] = array('class' => $class, 'status' => "new"); 147 } else { 148 $methods[$method]['status'] = "found"; 149 } 141 150 } 142 151 } 143 152 144 // check if a local fallback is defined 145 $variables['auth_method'] = $auth_method . ($auth_local ? "+" : " "); 153 // delete old ones, add the others to the sortlist, and update the config 154 $sortlist = array(); 155 foreach ($methods as $name => $method) { 156 if ($method['status'] == "old") { 157 unset($methods[$name]); 158 } else { 159 // add to the sortlist 160 if (in_array($name, $selected)) { 161 $sortlist[] = substr('000'.array_search($name, $selected),-3).".".$name; 162 } else { 163 $sortlist[] = "zzz.".$name; 164 } 165 } 166 } 167 $result = dbquery("UPDATE ".$db_prefix."configuration SET cfg_value = '".mysql_real_escape_string(serialize($methods))."' WHERE cfg_name = 'authentication_methods'"); 168 169 // create the list of available methods, in the correct order 170 sort($sortlist); 171 $variables['methods'] = array(); 172 $c = count($selected);$i=1; 173 foreach($sortlist as $entry) { 174 $listentry = explode(".", $entry); 175 $variables['methods'][] = array('name' => $listentry[1], 'class' => $methods[$listentry[1]]['class'], 'status' => $listentry[0] == 'zzz' ? 0 :1, 'last' => ($i++ == $c ? 1 : 0)); 176 } 146 177 147 178 // define the admin body panel -
trunk/administration/tools/language_pack_English.php
r2092 r2095 1101 1101 $localestrings['575'] = "Login requires HTTPS:"; 1102 1102 $localestrings['576'] = "Site access requires login:"; 1103 $localestrings['577'] = "Installed authentication methods"; 1104 $localestrings['578'] = "Method"; 1105 $localestrings['579'] = "Class"; 1106 $localestrings['580'] = "Order"; 1107 $localestrings['581'] = "Status"; 1108 $localestrings['582'] = "Options"; 1109 $localestrings['583'] = "Move up"; 1110 $localestrings['584'] = "Move down"; 1111 $localestrings['585'] = "Enable"; 1112 $localestrings['586'] = "Enabled"; 1113 $localestrings['587'] = "Disable"; 1114 $localestrings['588'] = "Disabled"; 1103 1115 $localestrings['600'] = "Albums"; 1104 1116 $localestrings['601'] = "Thumbnail width:"; … … 3769 3781 if (!defined('LP_COUNTRIES')) define('LP_COUNTRIES', "us|gb|ca|au|nz|in|za|ir|mt|hk|pr"); 3770 3782 if (!defined('LP_VERSION')) define('LP_VERSION', "7.20"); 3771 if (!defined('LP_DATE')) define('LP_DATE', "1228 492311");3783 if (!defined('LP_DATE')) define('LP_DATE', "1228608894"); 3772 3784 $lp_date = LP_DATE; 3773 3785 -
trunk/administration/tools/language_pack_Nederlands.php
r2092 r2095 1101 1101 $localestrings['575'] = "Login vereist HTTPS:"; 1102 1102 $localestrings['576'] = "Login verplicht voor site toegang:"; 1103 $localestrings['577'] = "Geinstalleerde authenticatie methoden"; 1104 $localestrings['578'] = "Methode"; 1105 $localestrings['579'] = "Class"; 1106 $localestrings['580'] = "Volgorde"; 1107 $localestrings['581'] = "Status"; 1108 $localestrings['582'] = "Opties"; 1109 $localestrings['583'] = "Naar omhoog"; 1110 $localestrings['584'] = "Naar beneden"; 1111 $localestrings['585'] = "Activeren"; 1112 $localestrings['586'] = "Geactiveerd"; 1113 $localestrings['587'] = "Uitschakelen"; 1114 $localestrings['588'] = "Uitgeschakeld"; 1103 1115 $localestrings['600'] = "Albums"; 1104 1116 $localestrings['601'] = "Breedte miniatuur:"; … … 3769 3781 if (!defined('LP_COUNTRIES')) define('LP_COUNTRIES', "nl|be|sr|aw|an"); 3770 3782 if (!defined('LP_VERSION')) define('LP_VERSION', "7.20"); 3771 if (!defined('LP_DATE')) define('LP_DATE', "1228 492315");3783 if (!defined('LP_DATE')) define('LP_DATE', "1228608898"); 3772 3784 $lp_date = LP_DATE; 3773 3785 -
trunk/edit_profile.php
r2087 r2095 31 31 // load the OpenID class (if cURL is present) 32 32 if (function_exists('curl_exec')) { 33 require_once PATH_INCLUDES." class.openid.php";33 require_once PATH_INCLUDES."authentication/class.openid.php"; 34 34 $openid = new SimpleOpenID; 35 35 } -
trunk/files/locales/en.main.global.php
r2092 r2095 3 3 // locale : English 4 4 // locale name : main.global 5 // generated on : Fri Dec 5 2008, 16:52:09CET5 // generated on : Sun Dec 7 2008, 1:15:00 CET 6 6 // translators : ExiteCMS team,WanWizard 7 7 // ---------------------------------------------------------- -
trunk/files/locales/en.main.setup.php
r2092 r2095 3 3 // locale : English 4 4 // locale name : main.setup 5 // generated on : Thu Dec 4 2008, 15:56:51CET5 // generated on : Sun Dec 7 2008, 1:14:54 CET 6 6 // translators : ExiteCMS team,WanWizard 7 7 // ---------------------------------------------------------- -
trunk/files/locales/nl.main.global.php
r2092 r2095 3 3 // locale : English 4 4 // locale name : main.global 5 // generated on : Thu Dec 4 2008, 15:56:55CET5 // generated on : Sun Dec 7 2008, 1:14:58 CET 6 6 // translators : ExiteCMS team,WanWizard 7 7 // ---------------------------------------------------------- -
trunk/files/locales/nl.main.setup.php
r2092 r2095 3 3 // locale : English 4 4 // locale name : main.setup 5 // generated on : Thu Dec 4 2008, 15:56:55CET5 // generated on : Sun Dec 7 2008, 1:14:58 CET 6 6 // translators : ExiteCMS team,WanWizard 7 7 // ---------------------------------------------------------- -
trunk/includes/templates/admin.settings_image.tpl
r2033 r2095 21 21 {include file="admin.settings_links.tpl} 22 22 <form name='settingsform' method='post' action='{$smarty.const.FUSION_SELF}{$aidlink}'> 23 <table align='center' cellpadding='0' cellspacing='0' width=' 500'>23 <table align='center' cellpadding='0' cellspacing='0' width='100%'> 24 24 <tr> 25 25 <td class='tbl' width='50%'> -
trunk/includes/templates/admin.settings_security.tpl
r2035 r2095 91 91 <tr> 92 92 <td width='50%' class='tbl'> 93 {$locale.537}94 </td>95 <td width='50%' class='tbl'>96 <select name='auth_method' class='textbox'>97 <option value='0'{if $auth_method == "0"} selected="selected"{/if}>{$locale.538}</option>98 <option value='1'{if $auth_method == "1"} selected="selected"{/if}>{$locale.539}</option>99 <option value='1+'{if $auth_method == "1+"} selected="selected"{/if}>{$locale.539}{$locale.541}{$locale.538}</option>100 <option value='2'{if $auth_method == "2"} selected="selected"{/if}>{$locale.540}</option>101 <option value='2+'{if $auth_method == "2+"} selected="selected"{/if}>{$locale.540}{$locale.541}{$locale.538}</option>102 {if $has_curl}103 <option value='3+'{if $auth_method == "3+"} selected="selected"{/if}>{$locale.538}{$locale.542}</option>104 {/if}105 </select>106 </td>107 </tr>108 <tr>109 <td width='50%' class='tbl'>110 93 {$locale.575} 111 94 </td> … … 129 112 </tr> 130 113 <tr> 131 <td align='center' colspan='2' class='tbl'> 132 <hr /> 114 <td width='50%' class='tbl'> 115 {$locale.529} 116 </td> 117 <td width='50%' class='tbl'> 118 <select name='login_expire' class='textbox'> 119 {section name=min start=0 loop=721 step=15} 120 <option value='{$smarty.section.min.index}' {if $smarty.section.min.index == $login_expire|default:0}selected='selected'{/if}>{if $smarty.section.min.index == 0}{$locale.714}{else}{$smarty.section.min.index} {$locale.531}{/if}</option> 121 {/section} 122 </select> 123 </td> 124 </tr> 125 <tr> 126 <td width='50%' class='tbl'> 127 {$locale.530} 128 </td> 129 <td width='50%' class='tbl'> 130 <select name='login_extended_expire' class='textbox'> 131 {section name=days start=0 loop=1441 step=1} 132 <option value='{$smarty.section.days.index}' {if $smarty.section.days.index == $login_extended_expire|default:0}selected='selected'{/if}>{if $smarty.section.days.index == 0}{$locale.714}{elseif $smarty.section.days.index == 1}1 {$locale.527}{else}{$smarty.section.days.index} {$locale.518}{/if}</option> 133 {/section} 134 </select> 133 135 </td> 134 136 </tr> … … 150 152 </tr> 151 153 <tr> 152 <td width='50%' class='tbl'>153 {$locale.529}154 </td>155 <td width='50%' class='tbl'>156 <select name='login_expire' class='textbox'>157 {section name=min start=0 loop=721 step=15}158 <option value='{$smarty.section.min.index}' {if $smarty.section.min.index == $login_expire|default:0}selected='selected'{/if}>{if $smarty.section.min.index == 0}{$locale.714}{else}{$smarty.section.min.index} {$locale.531}{/if}</option>159 {/section}160 </select>161 </td>162 </tr>163 <tr>164 <td width='50%' class='tbl'>165 {$locale.530}166 </td>167 <td width='50%' class='tbl'>168 <select name='login_extended_expire' class='textbox'>169 {section name=days start=0 loop=1441 step=1}170 <option value='{$smarty.section.days.index}' {if $smarty.section.days.index == $login_extended_expire|default:0}selected='selected'{/if}>{if $smarty.section.days.index == 0}{$locale.714}{elseif $smarty.section.days.index == 1}1 {$locale.527}{else}{$smarty.section.days.index} {$locale.518}{/if}</option>171 {/section}172 </select>173 </td>174 </tr>175 <tr>176 154 <td align='center' colspan='2' class='tbl'> 177 155 <br /> … … 182 160 </form> 183 161 {include file="_closetable.tpl"} 162 {include file="_opentable.tpl" name=$_name title=$locale.577 state=$_state style=$_style} 163 <table align='center' cellpadding='0' cellspacing='1' width='80%' class='tbl-border'> 164 <tr> 165 <td align='center' width='1%' class='tbl2' style='white-space:nowrap'> 166 <b>{$locale.578}</b> 167 </td> 168 <td align='center' width='1%' class='tbl2' style='white-space:nowrap'> 169 <b>{$locale.579}</b> 170 </td> 171 <td align='center' width='1%' class='tbl2' style='white-space:nowrap'> 172 <b>{$locale.580}</b> 173 </td> 174 <td align='center' width='1%' class='tbl2' style='white-space:nowrap'> 175 <b>{$locale.581}</b> 176 </td> 177 <td align='center' width='1%' class='tbl2' style='white-space:nowrap'> 178 <b>{$locale.582}</b> 179 </td> 180 </tr> 181 <br /> 182 {section name=id loop=$methods} 183 <tr> 184 <td align='center' width='1%' class='tbl1' style='white-space:nowrap'> 185 {$methods[id].name} 186 </td> 187 <td align='center' width='1%' class='tbl1' style='white-space:nowrap'> 188 {$methods[id].class} 189 </td> 190 <td align='center' width='1%' class='tbl1' style='white-space:nowrap'> 191 {if $methods[id].status == 1} 192 {if !$smarty.section.id.first} 193 {imagelink link=$smarty.const.FUSION_SELF|cat:$aidlink|cat:"&action=up&method_id="|cat:$smarty.section.id.index image="up.gif" alt=$locale.583 title=$locale.583} 194 {/if} 195 {if !$methods[id].last} 196 {imagelink link=$smarty.const.FUSION_SELF|cat:$aidlink|cat:"&action=down&method_id="|cat:$smarty.section.id.index image="down.gif" alt=$locale.584 title=$locale.584} 197 {/if} 198 {/if} 199 </td> 200 <td align='center' width='1%' class='tbl1' style='white-space:nowrap'> 201 {if $methods[id].status == 1} 202 {$locale.586} 203 {else} 204 {$locale.588} 205 {/if} 206 </td> 207 <td align='center' width='1%' class='tbl1' style='white-space:nowrap'> 208 {if $methods[id].status == 1} 209 {imagelink link=$smarty.const.FUSION_SELF|cat:$aidlink|cat:"&action=setstatus&status=0&authmethod="|cat:$methods[id].name image="page_red.gif" alt=$locale.587 title=$locale.587} 210 {else} 211 {imagelink link=$smarty.const.FUSION_SELF|cat:$aidlink|cat:"&action=setstatus&status=1&authmethod="|cat:$methods[id].name image="page_green.gif" alt=$locale.585 title=$locale.585} 212 {/if} 213 </td> 214 </tr> 215 {/section} 216 </table> 217 <br /> 218 {include file="_closetable.tpl"} 184 219 {***************************************************************************} 185 220 {* End of template *} -
trunk/includes/templates/main.login.tpl
r2013 r2095 27 27 <body class='body'> 28 28 <div class='splashscreen-h'> 29 <div class='splashscreen-v' style='height: 250px;vertical-align:center;'>29 <div class='splashscreen-v' style='height:325px;vertical-align:center;'> 30 30 <table align='center' cellpadding='0' cellspacing='1' width='500'> 31 31 <tr> -
trunk/includes/user_functions.php
r2078 r2095 19 19 if (eregi("user_functions.php", $_SERVER['PHP_SELF']) || !defined('INIT_CMS_OK')) die(); 20 20 21 // load and instantiate the authentication class 22 require_once "authentication/authentication.php"; 23 $cms_authentication =& new authentication(); 24 21 25 // need the GeoIP functions to determine the users country of origin 22 26 require_once "geoip_include.php"; … … 58 62 if ($_COOKIE['site_visited'] == "yes") { 59 63 $site_visited = md5(uniqid(rand(), true)); 60 setcookie("site_visited", $site_visited, time() + 31536000, "/", "", "0");61 } else {64 } else { 65 // get the cookie value 62 66 $site_visited = $_COOKIE['site_visited']; 63 67 } 68 // refresh the cookie 69 setcookie("site_visited", $site_visited, time() + 31536000, "/", "", "0"); 64 70 } 65 71 } … … 67 73 // if not in the process of posting a form, did the login session expire? 68 74 if (count($_POST)==0 && !empty($_SESSION['login_expire']) && $_SESSION['login_expire'] < time()) { 69 // clear the login info from the session 70 unset($_SESSION['user']); 71 unset($_SESSION['userinfo']); 72 unset($_SESSION['login_expire']); 75 $cms_authentication->logoff(); 73 76 } 74 77 75 78 // Are we logged in? 76 if (isset($_SESSION['userinfo'])) { 77 $userinfo_vars = explode(".", $_SESSION['userinfo']); 78 $userinfo_1 = isNum($userinfo_vars['0']) ? $userinfo_vars['0'] : "0"; 79 $userinfo_2 = (preg_match("/^[0-9a-z]{32}$/", $userinfo_vars['1']) ? $userinfo_vars['1'] : ""); 80 $result = dbquery("SELECT * FROM ".$db_prefix."users WHERE user_id='$userinfo_1' AND user_password='$userinfo_2'"); 81 unset($userinfo_vars,$userinfo_1,$userinfo_2); 82 if (dbrows($result) != 0) { 83 $userdata = dbarray($result); 84 if ($userdata['user_status'] == 0) { 85 // set the user's theme 86 if (isset($_SESSION['set_theme']) && file_exists(PATH_THEMES.$_SESSION['set_theme']."/theme.php")) { 87 $userdata['user_theme'] = $_SESSION['set_theme']; 88 unset($_SESSION['set_theme']); 89 $result2 = dbquery("UPDATE ".$db_prefix."users SET user_theme = '".$userdata['user_theme']."' WHERE user_id='$userinfo_1' AND user_password='$userinfo_2'"); 90 define("PATH_THEME", PATH_THEMES.$userdata['user_theme']."/"); 91 define("THEME", THEMES.$userdata['user_theme']."/"); 92 } elseif ($userdata['user_theme'] != "Default" && file_exists(PATH_THEMES.$userdata['user_theme']."/theme.php")) { 93 define("PATH_THEME", PATH_THEMES.$userdata['user_theme']."/"); 94 define("THEME", THEMES.$userdata['user_theme']."/"); 95 } else { 96 define("PATH_THEME", PATH_THEMES.$settings['theme']."/"); 97 define("THEME", THEMES.$settings['theme']."/"); 98 // make sure the default theme exists! 99 if (!file_exists(PATH_THEMES.$settings['theme']."/theme.php")) { 100 die("<div style='font-family:Verdana;font-size:11px;text-align:center;'><b>FATAL ERROR: Unable to load the default theme</b></div>"); 101 } 102 } 103 if ($userdata['user_offset'] <> 0) { 104 $settings['timeoffset'] = $settings['timeoffset'] + $userdata['user_offset']; 105 } 106 if (empty($_SESSION['lastvisit'])) { 107 $_SESSION['lastvisit'] = $userdata['user_lastvisit']; 108 $lastvisited = $userdata['user_lastvisit']; 109 } else { 110 $lastvisited = $_SESSION['lastvisit']; 111 } 112 } else { 113 header("P3P: CP='NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM'"); 114 // make sure the user info is erased from the session 115 unset($_SESSION['user']); 116 unset($_SESSION['userinfo']); 117 unset($_SESSION['login_expire']); 118 redirect(BASEDIR."index.php", "script"); 119 exit; 120 } 121 // update the login expiration timestamp 122 if ($settings['login_expire']) { 123 if (isset($_SESSION['remember_me']) && $_SESSION['remember_me'] == "yes") { 124 $_SESSION['login_expire'] = time() + $settings['login_extended_expire']; 125 } else { 126 $_SESSION['login_expire'] = time() + $settings['login_expire']; 127 } 128 } else { 129 $_SESSION['login_expire'] = mktime(0,0,0,1,1,2038); // do not expire 130 } 131 } else { 132 header("P3P: CP='NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM'"); 133 // make sure the user info is erased from the session 134 unset($_SESSION['user']); 135 unset($_SESSION['userinfo']); 136 unset($_SESSION['login_expire']); 137 redirect(BASEDIR."index.php", "script"); 138 exit; 79 if ($cms_authentication->logged_on()) { 80 81 $userdata = $cms_authentication->get_userinfo(); 82 // set the user's theme 83 if (isset($_SESSION['set_theme']) && file_exists(PATH_THEMES.$_SESSION['set_theme']."/theme.php")) { 84 $userdata['user_theme'] = $_SESSION['set_theme']; 85 unset($_SESSION['set_theme']); 86 $result2 = dbquery("UPDATE ".$db_prefix."users SET user_theme = '".$userdata['user_theme']."' WHERE user_id='$userinfo_1' AND user_password='$userinfo_2'"); 87 define("PATH_THEME", PATH_THEMES.$userdata['user_theme']."/"); 88 define("THEME", THEMES.$userdata['user_theme']."/"); 89 } elseif ($userdata['user_theme'] != "Default" && file_exists(PATH_THEMES.$userdata['user_theme']."/theme.php")) { 90 define("PATH_THEME", PATH_THEMES.$userdata['user_theme']."/"); 91 define("THEME", THEMES.$userdata['user_theme']."/"); 92 } else { 93 define("PATH_THEME", PATH_THEMES.$settings['theme']."/"); 94 define("THEME", THEMES.$settings['theme']."/"); 95 // make sure the default theme exists! 96 if (!file_exists(PATH_THEMES.$settings['theme']."/theme.php")) { 97 die("<div style='font-family:Verdana;font-size:11px;text-align:center;'><b>FATAL ERROR: Unable to load the default theme</b></div>"); 98 } 99 } 100 if ($userdata['user_offset'] <> 0) { 101 $settings['timeoffset'] = $settings['timeoffset'] + $userdata['user_offset']; 102 } 103 if (empty($_SESSION['lastvisit'])) { 104 $_SESSION['lastvisit'] = $userdata['user_lastvisit']; 105 $lastvisited = $userdata['user_lastvisit']; 106 } else { 107 $lastvisited = $_SESSION['lastvisit']; 108 } 109 // update the login expiration timestamp 110 if ($settings['login_expire']) { 111 if (isset($_SESSION['remember_me']) && $_SESSION['remember_me'] == "yes") { 112 $_SESSION['login_expire'] = time() + $settings['login_extended_expire']; 113 } else { 114 $_SESSION['login_expire'] = time() + $settings['login_expire']; 115 } 116 } else { 117 $_SESSION['login_expire'] = mktime(0,0,0,1,1,2038); // do not expire 139 118 } 140 119 } else { -
trunk/login.php
r1936 r2095 40 40 41 41 // get which authentication to show 42 $variables['auth_methods'] = explode(",",$settings['auth _type']);42 $variables['auth_methods'] = explode(",",$settings['authentication_selected']); 43 43 $variables['method_count'] = count($variables['auth_methods']); 44 44 $variables['auth_state'] = array(); -
trunk/modules/user_info_panel/user_info_panel.php
r2079 r2095 80 80 81 81 // get which authentication to show 82 $variables['auth_methods'] = explode(",",$settings['auth_type']);82 $variables['auth_methods'] = $GLOBALS['cms_authentication']->selected; 83 83 $variables['method_count'] = count($variables['auth_methods']); 84 84 $variables['auth_state'] = array(); -
trunk/setuser.php
r2084 r2095 20 20 require_once PATH_INCLUDES."theme_functions.php"; 21 21 22 // used by the auth functions to store the retrieved local user_id23 // this value is needed in some of the error handling code24 $user_id = 0;25 26 /*---------------------------------------------------+27 | User authentication functions |28 +----------------------------------------------------*/29 30 // authentication against the local user database31 function auth_local($userid, $password) {32 global $db_prefix, $user_id;33 34 // check and validate the given userid and pasword35 $user_pass = md5(md5($password));36 $user_name = preg_replace(array("/\=/","/\#/","/\sOR\s/"), "", stripinput($userid));37 38 // check if we have a user record for this userid and password39 $result = dbquery("SELECT * FROM ".$db_prefix."users WHERE user_name='$user_name' AND user_password='".$user_pass."'");40 if (dbrows($result) == 0) {41 // not found, display an error message42 return 3;43 } else {44 // retrieve the record45 $data = dbarray($result);46 // store the global user_id for reference outside this function47 $user_id = $data['user_id'];48 // found, get the record and do some more validation49 $ret = auth_user_validate($data);50 return $ret;51 }52 }53 54 // authentication against an LDAP server55 function auth_ldap($userid, $password) {56 terminate('auth_ldap not defined yet!');57 }58 59 // authentication against an Active Directory server60 function auth_ad($userid, $password) {61 terminate('auth_ad not defined yet!');62 }63 64 // authentication using an OpenID65 function auth_openid($openid_url) {66 global $settings;67 68 // check if the URL is valid69 if (isURL($openid_url)) {70 require_once(PATH_INCLUDES."class.openid.php");71 $openid = new SimpleOpenID;72 $openid->SetIdentity($openid_url);73 $openid->SetApprovedURL($settings['siteurl']."setuser.php");74 $openid->SetTrustRoot($settings['siteurl']);75 $server_url = $openid->GetOpenIDServer();76 if ($server_url) {77 redirect($openid->GetRedirectURL() , "script");78 exit;79 }80 } else {81 // for now...82 return 0;83 }84 }85 86 // further validation on the userid found87 function auth_user_validate($userrecord) {88 global $settings;89 90 // if the account is suspended, check for an expiry date91 if ($userrecord['user_status'] == 1 && $userrecord['user_ban_expire'] > 0 && $userrecord['user_ban_expire'] < time() ) {92 // if this user's email address is marked as bad, reset the countdown counter93 $userrecord['user_bad_email'] = $userrecord['user_bad_email'] == 0 ? 0 : time();94 // reset the user status and the expiry date95 $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']."'");96 $userrecord['user_status'] = 0;97 }98 if ($userrecord['user_status'] == 0) {99 header("P3P: CP='NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM'");100 // set the 'remember me' status value101 $_SESSION['remember_me'] = isset($_POST['remember_me']) ? "yes" : "no";102 $_SESSION['userinfo'] = $userrecord['user_id'].".".$userrecord['user_password'];103 // login expiry defined?104 if ($settings['login_expire']) {105 if (isset($_POST['remember_me']) && $_POST['remember_me'] == "yes") {106 $_SESSION['login_expire'] = time() + $settings['login_extended_expire'];107 } else {108 $_SESSION['login_expire'] = time() + $settings['login_expire'];109 }110 } else {111 $_SESSION['login_expire'] = mktime(0,0,0,1,1,2038); // do not expire112 }113 return 4;114 } elseif ($userrecord['user_status'] == 1) {115 return 1;116 } elseif ($userrecord['user_status'] == 2) {117 return 2;118 } else {119 return 0;120 }121 }122 123 124 /*---------------------------------------------------+125 | Main code |126 +----------------------------------------------------*/127 128 22 // temp storage for template variables 129 23 $variables = array(); … … 131 25 // array to store the lines of the setuser message 132 26 $message = array(); 27 28 // set the P3P header 29 header("P3P: CP='NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM'"); 133 30 134 31 // make sure the error variable has a value … … 148 45 149 46 // process the logout request 47 $cms_authentication->logoff(); 150 48 151 header("P3P: CP='NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM'");152 49 // make sure the user info is erased from the session 153 unset($_SESSION['user']);154 unset($_SESSION['userinfo']);155 unset($_SESSION['login_expire']);156 $result = dbquery("DELETE FROM ".$db_prefix."online WHERE online_ip='".USER_IP."'");157 50 if (isset($userdata['user_name'])) { 158 51 $message['line2'] = "<b>".$locale['192'].$userdata['user_name']."</b>"; … … 161 54 } elseif (isset($_GET['login']) && $_GET['login'] == "yes") { 162 55 163 // process the login request 164 $auth_methods = isset($settings['auth_type']) ? explode(",",$settings['auth_type'].",") : array('local'); 165 foreach($auth_methods as $auth_method) { 166 switch($auth_method) { 167 case "local": 168 // authentication against the local user database 169 if (!empty($_POST['user_name']) && !empty($_POST['user_pass'])) { 170 $error = auth_local($_POST['user_name'], $_POST['user_pass']); 171 } 172 break; 173 case "ldap": 174 break; 175 case "ad": 176 break; 177 case "openid": 178 // authentication against an openid provider 179 if (!empty($_POST['user_openid_url'])) { 180 $error = auth_openid($_POST['user_openid_url']); 181 } 182 break; 183 case "default": 184 // empty or unknown entry, ignore 185 break; 186 } 56 // store any login parameters to be passed 57 $params = array(); 58 if (!empty($_POST['user_name'])) { 59 $params['username'] = stripinput($_POST['user_name']); 60 } 61 if (!empty($_POST['user_pass'])) { 62 $params['password'] = stripinput($_POST['user_pass']); 63 } 64 if (!empty($_POST['user_openid_url']) && isURL($_POST['user_openid_url'])) { 65 $params['openid_url'] = stripinput($_POST['user_openid_url']); 187 66 } 188 67 189 } else { 68 // process the logon request 69 if ($cms_authentication->logon($params)) { 70 // get the logon status 71 $error = $cms_authentication->status; 72 } else { 73 $error = 3; // // credentials not correct 74 } 190 75 191 if (isset($_GET['openid_mode'])) { 192 // handle openid login 193 require_once(PATH_INCLUDES."class.openid.php"); 194 $openid = new SimpleOpenID; 195 $openid->SetIdentity(urldecode($_GET['openid_identity'])); 196 if ($openid->ValidateWithServer()) { 197 $openid_url = strtolower($openid->OpenID_Standarize($_GET['openid_identity'])); 198 $result = dbquery("SELECT * FROM ".$db_prefix."users WHERE user_openid_url='".$openid_url."'"); 199 if (dbrows($result) != 0) { 200 // found, get the record and do some more validation 201 $error = auth_user_validate(dbarray($result)); 202 } else { 203 $message['line2'] = "<b>".$locale['196']."</b>"; 204 } 205 } else { 206 trigger_error($openid->GetError()); 207 exit; 208 } 76 } elseif (isset($_GET['openid_mode'])) { 77 78 // store any login parameters to be passed 79 $params = array(); 80 81 if (!empty($_GET['openid_mode'])) { 82 $params['openid_mode'] = stripinput($_GET['openid_mode']); 83 } 84 85 // process the openid logon request 86 if ($cms_authentication->logon($params)) { 87 $error = $cms_authentication->status; 88 } else { 89 $error = 3; // credentials not correct 209 90 } 210 91 … … 213 94 // check the result of the authentication attempt, and process it 214 95 switch($error) { 215 case 0: 96 case 0: // no errors 216 97 // 217 98 $refresh = 1; 218 99 break; 219 case 1: 100 case 1: // account is suspended 220 101 $message['line1'] = "<b>".$locale['194']."</b>"; 221 102 $data = dbarray(dbquery("SELECT user_ban_reason, user_ban_expire FROM ".$db_prefix."users WHERE user_id='".$user_id."'")); … … 226 107 $refresh = 10; 227 108 break; 228 case 2: 109 case 2: // account not activated (yet) 229 110 $message['line2'] = "<b>".$locale['195']."</b>"; 230 111 $refresh = 10; 231 112 break; 232 case 3: 113 case 3: // credentials not correct 233 114 $message['line2'] = "<b>".$locale['196']."</b>"; 234 115 $refresh = 10; 235 116 break; 236 case 4: 117 case 4: // successful logon 237 118 if (isset($_SESSION['userinfo'])) { 238 119 // now that we have user info, finish the login validation … … 257 138 } 258 139 break; 259 case 5: 140 case 5: // logon requires https 260 141 $message['line2'] = "<b>".$locale['https']."</b>"; 261 142 $refresh = 99999; 262 143 break; 263 case 6: 144 case 6: // user is banned 264 145 $message['line2'] = "<font style='color:red;font-weight:bold'>".($locale['banned'])."</font>"; 265 146 // get the reason for this ban
Note: See TracChangeset
for help on using the changeset viewer.
