| [ Index ] |
|
Code source de CMS made simple 1.0.5 |
1 <?php 2 #CMS - CMS Made Simple 3 #(c)2004 by Ted Kulp (wishy@users.sf.net) 4 #This project's homepage is: http://cmsmadesimple.sf.net 5 # 6 #This program is free software; you can redistribute it and/or modify 7 #it under the terms of the GNU General Public License as published by 8 #the Free Software Foundation; either version 2 of the License, or 9 #(at your option) any later version. 10 # 11 #This program is distributed in the hope that it will be useful, 12 #but WITHOUT ANY WARRANTY; without even the implied warranty of 13 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 #GNU General Public License for more details. 15 #You should have received a copy of the GNU General Public License 16 #along with this program; if not, write to the Free Software 17 #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 # 19 #$Id: login.php 3601 2006-12-20 21:04:54Z calguy1000 $ 20 21 $CMS_ADMIN_PAGE=1; 22 23 require_once ("../include.php"); 24 require_once ("../lib/classes/class.user.inc.php"); 25 global $gCms; 26 $db =& $gCms->GetDb(); 27 28 $error = ""; 29 30 if (isset($_SESSION['logout_user_now'])) 31 { 32 debug_buffer("Logging out. Clearning cookies and session variables."); 33 unset($_SESSION['logout_user_now']); 34 unset($_SESSION['cms_admin_user_id']); 35 setcookie('cms_admin_user_id', '', time() - 3600); 36 setcookie('cms_passhash', '', time() - 3600); 37 } 38 else 39 { 40 $no_redirect = true; 41 $is_logged_in = check_login($no_redirect); 42 if (true == $is_logged_in) 43 { 44 redirect($gCms->config['root_url'].'/'.$config['admin_dir'].'/index.php'); 45 } 46 } 47 if (isset($_POST["logincancel"])) 48 { 49 debug_buffer("Login cancelled. Returning to content."); 50 redirect($config["root_url"].'/index.php', true); 51 } 52 53 if (isset($_POST["username"]) && isset($_POST["password"])) { 54 55 $username = ""; 56 if (isset($_POST["username"])) $username = cleanValue($_POST["username"]); 57 58 $password = ""; 59 if (isset($_POST["password"])) $password = $_POST["password"]; 60 61 global $gCms; 62 $userops =& $gCms->GetUserOperations(); 63 $oneuser =& $userops->LoadUserByUsername($username, $password, true, true); 64 65 debug_buffer("Got user by username"); 66 debug_buffer($oneuser); 67 68 if ($username != "" && $password != "" && isset($oneuser) && $oneuser == true && isset($_POST["loginsubmit"])) 69 { 70 debug_buffer("Starting login procedure. Setting userid so that other pages will pick it up and set a cookie."); 71 #generate_user_object($oneuser->id); 72 $_SESSION['login_user_id'] = $oneuser->id; 73 $_SESSION['login_user_username'] = $oneuser->username; 74 $default_cms_lang = get_preference($oneuser->id, 'default_cms_language'); 75 if ($default_cms_lang != '') 76 { 77 #setcookie('cms_language', $default_cms_lang); 78 $_SESSION['login_cms_language'] = $default_cms_lang; 79 } 80 audit($oneuser->id, $oneuser->username, 'User Login'); 81 82 #Perform the login_post callback TODO: Remove me 83 foreach($gCms->modules as $key=>$value) 84 { 85 if ($gCms->modules[$key]['installed'] == true && 86 $gCms->modules[$key]['active'] == true) 87 { 88 $gCms->modules[$key]['object']->LoginPost($oneuser); 89 } 90 } 91 92 #Now call the event 93 Events::SendEvent('Core', 'LoginPost', array('user' => &$oneuser)); 94 95 // redirect to upgrade if db_schema it's old 96 $current_version = $CMS_SCHEMA_VERSION; 97 98 $query = "SELECT version from ".cms_db_prefix()."version"; 99 $row = $db->GetRow($query); 100 if ($row) $current_version = $row["version"]; 101 102 if ($current_version < $CMS_SCHEMA_VERSION) 103 { 104 redirect($gCms->config['root_url'] . "/install/upgrade.php"); 105 } 106 // end of version check 107 108 if (isset($_SESSION["redirect_url"])) 109 { 110 if (isset($gCms->config) and $gCms->config['debug'] == true) 111 { 112 echo "Debug is on. Redirecting disabled... Please click this link to continue.<br />"; 113 echo "<a href=\"".$_SESSION["redirect_url"]."\">".$_SESSION["redirect_url"]."</a><br />"; 114 foreach ($gCms->errors as $globalerror) 115 { 116 echo $globalerror; 117 } 118 } 119 else 120 { 121 #echo ('<html><head><title>Logging in... please wait</title><meta http-equiv="refresh" content="1; url='.$_SESSION["redirect_url"].'"></head><body>Logging in and redirecting to <a href="'.$_SESSION["redirect_url"].'">'.$_SESSION["redirect_url"].'</a>, one moment please...</body></html>'); 122 $tmp = $_SESSION["redirect_url"]; 123 unset($_SESSION["redirect_url"]); 124 redirect($tmp); 125 } 126 unset($_SESSION["redirect_url"]); 127 } 128 else 129 { 130 if (isset($config) and $config['debug'] == true) 131 { 132 echo "Debug is on. Redirecting disabled... Please click this link to continue.<br />"; 133 echo "<a href=\"index.php\">index.php</a><br />"; 134 foreach ($gCms->errors as $globalerror) 135 { 136 echo $globalerror; 137 } 138 } 139 else 140 { 141 #echo ('<html><head><title>Logging in... please wait</title><meta http-equiv="refresh" content="1; url=./index.php"></head><body>Logging in and redirecting to <a href="./index.php">index.php</a>, one moment please...</body></html>'); 142 redirect("index.php"); 143 } 144 } 145 return; 146 #redirect("index.php"); 147 } 148 else if (isset($_POST['loginsubmit'])) { //No error if changing languages 149 $error .= lang('usernameincorrect'); 150 debug_buffer("Login failed. Error is: " . $error); 151 } 152 else 153 { 154 debug_buffer($_POST["loginsubmit"]); 155 } 156 157 } 158 159 // Language shizzle 160 //header("Content-Encoding: " . get_encoding()); 161 header("Content-Language: " . $current_language); 162 header("Content-Type: text/html; charset=" . get_encoding()); 163 164 //CHANGED 165 $theme=get_site_preference('logintheme', 'default'); 166 //echo "theme:$theme"; 167 debug_buffer('debug is:' . $error); 168 if (file_exists(dirname(__FILE__)."/themes/$theme/login.php")) { 169 include(dirname(__FILE__)."/themes/$theme/login.php"); 170 } else { 171 include(dirname(__FILE__)."/themes/default/login.php"); 172 } 173 //STOP 174 ?> 175 176 <?php 177 if (isset($gCms->config) and $gCms->config['debug'] == true) 178 { 179 foreach ($gCms->errors as $globalerror) 180 { 181 echo $globalerror; 182 } 183 } 184 # vim:ts=4 sw=4 noet 185 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Tue Apr 3 18:50:37 2007 | par Balluche grâce à PHPXref 0.7 |