Changeset 308 for trunk/includes/global.php
- Timestamp:
- Jan 31, 2010, 9:41:08 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/global.php
r307 r308 198 198 echo('<strong>'.$Name.'</strong>'.$TextGM.'<br />'); 199 199 } 200 } 201 202 function CheckLogin() 203 { 204 global $Database; 205 206 if(!array_key_exists('UserID', $_SESSION)) $_SESSION['UserID'] = ''; 207 if(!array_key_exists('User', $_SESSION)) $_SESSION['User'] = 'NotRegistred'; 208 if(!array_key_exists('Pass', $_SESSION)) $_SESSION['Pass'] = ''; 209 210 // Přihlášení 211 if(array_key_exists('LoginUser', $_POST)) 212 { 213 $_SESSION['User'] = $_POST['LoginUser']; 214 $_SESSION['Pass'] = $_POST['LoginPass']; 215 216 $DbResult = $Database->SQLCommand('SELECT * FROM user WHERE LOWER(user) = LOWER("'.$_SESSION['User'].'") AND pass = sha1(CONCAT(sha1("'.$_SESSION['Pass'].'"), Salt))'); 217 if(mysql_num_rows($DbResult) == 0) 218 { 219 echo('<script> alert("Jméno nebo heslo bylo zadáno špatně!"); </script>'); 220 $_SESSION['UserID'] = ''; 221 $_SESSION['User'] = ''; 222 $_SESSION['Pass'] = ''; 223 } else 224 { 225 $User = mysql_fetch_assoc($DbResult); 226 $_SESSION['UserID'] = $User['ID']; 227 $_SESSION['User'] = $User['user']; 228 WriteLog('Login: '.$_SESSION['User'], 3); 229 } 230 } 231 232 // Odhlášení 233 if(array_key_exists('Logout', $_GET) and ($_SESSION['User'] != '')) 234 { 235 WriteLog('Odhlášení', 3); 236 if(is_numeric($_SESSION['UserID'])) 237 $Database->SQLCommand('UPDATE user SET LastLogout = NOW() WHERE ID = '.$_SESSION['UserID']); 238 $_SESSION['User'] = ''; 239 $_SESSION['Pass'] = ''; 240 $_SESSION['UserID'] = ''; 241 } 242 243 // Záznam o aktivitě 244 if(Licence(0) and array_key_exists('REMOTE_ADDR', $_SERVER)) 245 $Database->SQLCommand('UPDATE user SET LastIP = "'.$_SERVER['REMOTE_ADDR'].'", LastLogin = NOW() WHERE ID = '.$_SESSION['UserID']); 200 246 } 201 247 … … 227 273 </table>'); 228 274 229 if(!array_key_exists('UserID', $_SESSION)) $_SESSION['UserID'] = ''; 230 if(!array_key_exists('User', $_SESSION)) $_SESSION['User'] = 'NotRegistred'; 231 if(!array_key_exists('Pass', $_SESSION)) $_SESSION['Pass'] = ''; 232 233 234 // Odhlášení 235 if(array_key_exists('Logout', $_GET)) 236 { 237 WriteLog('Odhlášení', 3); 238 if(is_numeric($_SESSION['UserID'])) 239 $Database->SQLCommand('UPDATE user SET LastLogout = NOW() WHERE ID = '.$_SESSION['UserID']); 240 $_SESSION['User'] = ''; 241 $_SESSION['Pass'] = ''; 242 $_SESSION['UserID'] = ''; 243 } 244 245 // Přihlášení 246 if(array_key_exists('LoginUser', $_POST)) 247 { 248 $_SESSION['User'] = $_POST['LoginUser']; 249 $_SESSION['Pass'] = $_POST['LoginPass']; 250 251 $Line = mysql_fetch_array($Database->SQLCommand('SELECT * FROM user WHERE LOWER(user) = LOWER("'.$_SESSION['User'].'") AND pass = sha1("'.$_SESSION['Pass'].'")')); 252 if(!$Line) 253 { 254 echo('<script> alert("Jméno nebo heslo bylo zadáno špatně!"); </script>'); 255 $_SESSION['UserID'] = ''; 256 $_SESSION['User'] = ''; 257 $_SESSION['Pass'] = ''; 258 } else 259 { 260 $_SESSION['UserID'] = $Line['ID']; 261 $_SESSION['User'] = $Line['user']; 262 WriteLog('Login: '.$_SESSION['User'], 3); 263 } 264 } 265 266 // Záznam o aktivitě 267 if(Licence(0) and array_key_exists('REMOTE_ADDR', $_SERVER)) 268 $Database->SQLCommand('UPDATE user SET LastIP = "'.$_SERVER['REMOTE_ADDR'].'", LastLogin = NOW() WHERE ID = '.$_SESSION['UserID']); 269 275 CheckLogin(); 270 276 ShowTopBar(); 271 277
Note:
See TracChangeset
for help on using the changeset viewer.