6 |
kaklik |
1 |
<?php
|
|
|
2 |
/*************************
|
|
|
3 |
Coppermine Photo Gallery
|
|
|
4 |
************************
|
|
|
5 |
Copyright (c) 2003-2005 Coppermine Dev Team
|
|
|
6 |
v1.1 originaly written by Gregory DEMAR
|
|
|
7 |
|
|
|
8 |
This program is free software; you can redistribute it and/or modify
|
|
|
9 |
it under the terms of the GNU General Public License as published by
|
|
|
10 |
the Free Software Foundation; either version 2 of the License, or
|
|
|
11 |
(at your option) any later version.
|
|
|
12 |
********************************************
|
|
|
13 |
Coppermine version: 1.3.3
|
|
|
14 |
$Source: /cvsroot/coppermine/stable/login.php,v $
|
|
|
15 |
$Revision: 1.6 $
|
|
|
16 |
$Author: gaugau $
|
|
|
17 |
$Date: 2005/04/19 03:17:11 $
|
|
|
18 |
**********************************************/
|
|
|
19 |
|
|
|
20 |
define('IN_COPPERMINE', true);
|
|
|
21 |
define('LOGIN_PHP', true);
|
|
|
22 |
|
|
|
23 |
require('include/init.inc.php');
|
|
|
24 |
|
|
|
25 |
if (USER_ID) cpg_die(ERROR, $lang_login_php['err_already_logged_in'], __FILE__, __LINE__);
|
|
|
26 |
|
|
|
27 |
if (defined('UDB_INTEGRATION')) udb_login_page();
|
|
|
28 |
|
|
|
29 |
$referer = $HTTP_GET_VARS['referer'] ? $HTTP_GET_VARS['referer'] : 'index.php';
|
|
|
30 |
$login_failed = '';
|
|
|
31 |
$cookie_warning = '';
|
|
|
32 |
|
|
|
33 |
if (isset($HTTP_POST_VARS['submitted'])) {
|
|
|
34 |
$results = db_query("SELECT user_id, user_name, user_password FROM {$CONFIG['TABLE_USERS']} WHERE user_name = '" . addslashes($HTTP_POST_VARS['username']) . "' AND BINARY user_password = '" . addslashes($HTTP_POST_VARS['password']) . "' AND user_active = 'YES'");
|
|
|
35 |
$lastvisit = db_query("UPDATE {$CONFIG['TABLE_USERS']} SET user_lastvisit = NOW() WHERE user_name = '" . addslashes($HTTP_POST_VARS['username']) . "' AND BINARY user_password = '" . addslashes($HTTP_POST_VARS['password']) . "' AND user_active = 'YES'");
|
|
|
36 |
if (mysql_num_rows($results)) {
|
|
|
37 |
$USER_DATA = mysql_fetch_array($results);
|
|
|
38 |
if (isset($HTTP_POST_VARS['remember_me'])) {
|
|
|
39 |
$cookie_life_time = 86400 * 30;
|
|
|
40 |
} else {
|
|
|
41 |
$cookie_life_time = 86400;
|
|
|
42 |
}
|
|
|
43 |
setcookie($CONFIG['cookie_name'] . '_uid', $USER_DATA['user_id'], time() + $cookie_life_time, $CONFIG['cookie_path']);
|
|
|
44 |
setcookie($CONFIG['cookie_name'] . '_pass', md5($HTTP_POST_VARS['password']), time() + $cookie_life_time, $CONFIG['cookie_path']);
|
|
|
45 |
|
|
|
46 |
pageheader($lang_login_php['login'], "<META http-equiv=\"refresh\" content=\"3;url=$referer\">");
|
|
|
47 |
msg_box($lang_login_php['login'], sprintf($lang_login_php['welcome'], $USER_DATA['user_name']), $lang_continue, $referer);
|
|
|
48 |
pagefooter();
|
|
|
49 |
exit;
|
|
|
50 |
} else {
|
|
|
51 |
$login_failed = <<<EOT
|
|
|
52 |
<tr>
|
|
|
53 |
<td colspan="2" align="center" class="tableh2">
|
|
|
54 |
<font size="1" color="red"><b>{$lang_login_php['err_login']}<b></font>
|
|
|
55 |
</td>
|
|
|
56 |
</tr>
|
|
|
57 |
|
|
|
58 |
EOT;
|
|
|
59 |
}
|
|
|
60 |
}
|
|
|
61 |
|
|
|
62 |
if (!isset($HTTP_COOKIE_VARS[$CONFIG['cookie_name'] . '_data'])) {
|
|
|
63 |
$cookie_warning = <<<EOT
|
|
|
64 |
<tr>
|
|
|
65 |
<td colspan="2" align="center" class="tableh2">
|
|
|
66 |
<font size="1" color="red"><b>Warning your browser does not accept script's cookies<b></font>
|
|
|
67 |
</td>
|
|
|
68 |
</tr>
|
|
|
69 |
|
|
|
70 |
EOT;
|
|
|
71 |
}
|
|
|
72 |
|
|
|
73 |
pageheader($lang_login_php['login']);
|
|
|
74 |
$referer = urlencode($referer);
|
|
|
75 |
starttable('-1', $lang_login_php['enter_login_pswd'], 2);
|
|
|
76 |
echo <<< EOT
|
|
|
77 |
$login_failed
|
|
|
78 |
$cookie_warning
|
|
|
79 |
<tr>
|
|
|
80 |
<form action="login.php?referer=$referer" method="post" name="loginbox">
|
|
|
81 |
<td class="tableb" width="40%">{$lang_login_php['username']}</td>
|
|
|
82 |
<td class="tableb" width="60%"><input type="text" class="textinput" name="username" style="width: 100%"></td>
|
|
|
83 |
<script language="javascript" type="text/javascript">
|
|
|
84 |
<!--
|
|
|
85 |
document.loginbox.username.focus();
|
|
|
86 |
-->
|
|
|
87 |
</script>
|
|
|
88 |
</tr>
|
|
|
89 |
<tr>
|
|
|
90 |
<td class="tableb">{$lang_login_php['password']}</td>
|
|
|
91 |
<td class="tableb"><input type="password" class="textinput" name="password" style="width: 100%"></td>
|
|
|
92 |
</tr>
|
|
|
93 |
<tr>
|
|
|
94 |
<td colspan="2" align="center" class="tableb">{$lang_login_php['remember_me']} <input name="remember_me" type="checkbox" class="checkbox" value="1"></td>
|
|
|
95 |
</tr>
|
|
|
96 |
<tr>
|
|
|
97 |
<td align="center" class="tablef"><a href="forgot_passwd.php" class="topmenu">{$lang_login_php['forgot_password_link']}</a></td>
|
|
|
98 |
<td align="left" class="tablef"><input name="submitted" type="submit" class="button" value="{$lang_login_php['login']}"></td>
|
|
|
99 |
</form>
|
|
|
100 |
</tr>
|
|
|
101 |
|
|
|
102 |
EOT;
|
|
|
103 |
|
|
|
104 |
endtable();
|
|
|
105 |
pagefooter();
|
|
|
106 |
ob_end_flush();
|
|
|
107 |
|
|
|
108 |
?>
|