e64ac5ab9ed785146f166b522b91f1f142be68e7
[mailer.git] / inc / modules / chk_login.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    Start: 11/26/2003 *
4  * ===============                              Last change: 02/27/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : chk_login.php                                    *
8  * -------------------------------------------------------------------- *
9  * Short description : Check if user has logged in (delay)              *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Pruefen ob die Login-Cookies gesetzt sind        *
12  * -------------------------------------------------------------------- *
13  *                                                                      *
14  * -------------------------------------------------------------------- *
15  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
16  * For more information visit: http://www.mxchange.org                  *
17  *                                                                      *
18  * This program is free software; you can redistribute it and/or modify *
19  * it under the terms of the GNU General Public License as published by *
20  * the Free Software Foundation; either version 2 of the License, or    *
21  * (at your option) any later version.                                  *
22  *                                                                      *
23  * This program is distributed in the hope that it will be useful,      *
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
26  * GNU General Public License for more details.                         *
27  *                                                                      *
28  * You should have received a copy of the GNU General Public License    *
29  * along with this program; if not, write to the Free Software          *
30  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
31  * MA  02110-1301  USA                                                  *
32  ************************************************************************/
33
34 // Some security stuff...
35 if (ereg(basename(__FILE__), $_SERVER['PHP_SELF']))
36 {
37         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
38         require($INC);
39 }
40
41 OPEN_TABLE("500", "guest_login_header dashed", "center");
42
43 OUTPUT_HTML("<br /><STRONG>".VALIDATING_LOGIN."</STRONG><br />");
44
45 if (!empty($GLOBALS['userid']) && !empty($_SESSION['u_hash']) && !empty($_SESSION['lifetime']))
46 {
47         // Get theme from profile
48         $result = SQL_QUERY_ESC("SELECT curr_theme FROM "._MYSQL_PREFIX."_user_data WHERE userid=%d LIMIT 1",
49          array($GLOBALS['userid']), __FILE__, __LINE__);
50         list($NewTheme) = SQL_FETCHROW($result);
51         SQL_FREERESULT($result);
52
53         // Change to new theme
54         set_session("mxchange_theme", $NewTheme, (time() + 60*60*24*365), COOKIE_PATH);
55         $_SESSION['mxchange_theme'] = $NewTheme;
56
57         $bonus = false;
58         if ((GET_EXT_VERSION("sql_patches") >= "0.2.8") && (GET_EXT_VERSION("bonus") >= "0.2.1") && ($_CONFIG['bonus_login_yn'] == 'N') && ($_CONFIG['bonus_login_yn'] == 'Y')) {
59                 // Update last login
60                 $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data
61 SET last_login=UNIX_TIMESTAMP()
62 WHERE userid=%d AND last_login < (UNIX_TIMESTAMP() - %d)
63 LIMIT 1", array($GLOBALS['userid'], $_CONFIG['login_timeout']),
64  __FILE__, __LINE__);
65                 if (SQL_AFFECTEDROWS($link) == 1) $bonus = true;
66         }
67         if (($bonus) && ($_GET['mode'] == "bonus") && (EXT_IS_ACTIVE("bonus")))         {
68                 // Output message with added points
69                 OUTPUT_HTML("<FONT class=\"tiny\">
70   ".BONUS_LOGIN_BONUS_ADDED_1."
71   <STRONG>".TRANSLATE_COMMA($_CONFIG['login_bonus'])." ".POINTS."</STRONG>
72   ".BONUS_LOGIN_BONUS_ADDED_2."
73 </FONT>");
74         }
75          elseif (EXT_IS_ACTIVE("bonus"))
76         {
77                 // No login bonus added!
78                 OUTPUT_HTML("<FONT class=\"member_failed\">".BONUS_LOGIN_BONUS_NOT_ADDED."</FONT>");
79         }
80
81         // Redirect to member area
82         LOAD_TEMPLATE("member_login_js");
83 }
84  else
85 {
86         // Login failed!
87         LOAD_TEMPLATE("login_failed_js");
88 }
89
90 // Close table
91 CLOSE_TABLE();
92
93 //
94 ?>