login.php problems

This is an archive of the phpBB 2.0.x support forum. Support for phpBB2 has now ended.
Forum rules
Following phpBB2's EoL, this forum is now archived for reference purposes only.
Please see the following announcement for more information: viewtopic.php?f=14&t=1385785

login.php problems

Postby giopas » Thu Dec 08, 2005 1:25 pm

Hi!

I wondering if some angel could hel me fixing a problem that I've made in my login.php.

I was installing the eZportal on my forum, but I decided to change and move back without that feature because my default style is softmetal and not subsilver and I had to change too many things making the forum as I would like it would be.

So, I moved back replacing the original lines in login.php and delated the ez-files, but I get two errors when I login:

1) even if the login works, the page is not authomatically redirected to the right page, dispaying a blank page instead.

2) I don't know why but since my (unluky) experiment I don't need the duble login when I try to enter in the admin panel.

That's my login.php, I'd really appreciate your help! :(

Code: Select all
001: <?php
002: /***************************************************************************
003:  *                                login.php
004:  *                            -------------------
005:  *   begin                : Saturday, Feb 13, 2001
006:  *   copyright            : (C) 2001 The phpBB Group
007:  *   email                : support@phpbb.com
008:  *
009:  *   $Id: login.php,v 1.47.2.20 2005/10/30 15:17:13 acydburn Exp $
010:  *
011:  *
012:  ***************************************************************************/
013:
014: /***************************************************************************
015:  *
016:  *   This program is free software; you can redistribute it and/or modify
017:  *   it under the terms of the GNU General Public License as published by
018:  *   the Free Software Foundation; either version 2 of the License, or
019:  *   (at your option) any later version.
020:  *
021:  ***************************************************************************/
022:
023: //
024: // Allow people to reach login page if
025: // board is shut down
026: //
027: define("IN_LOGIN", true);
028:
029: define('IN_PHPBB', true);
030: $phpbb_root_path = './';
031: include($phpbb_root_path . 'extension.inc');
032: include($phpbb_root_path . 'common.'.$phpEx);
033:
034: //
035: // Set page ID for session management
036: //
037: $userdata = session_pagestart($user_ip, PAGE_LOGIN);
038: init_userprefs($userdata);
039: //
040: // End session management
041: //
042:
043: // session id check
044: if (!empty($HTTP_POST_VARS['sid']) || !empty($HTTP_GET_VARS['sid']))
045: {
046:     $sid = (!empty($HTTP_POST_VARS['sid'])) ? $HTTP_POST_VARS['sid'] : $HTTP_GET_VARS['sid'];
047: }
048: else
049: {
050:     $sid = '';
051: }
052:
053: if( isset($HTTP_POST_VARS['login']) || isset($HTTP_GET_VARS['login']) || isset($HTTP_POST_VARS['logout']) || isset($HTTP_GET_VARS['logout']) )
054: {
055:     if( ( isset($HTTP_POST_VARS['login']) || isset($HTTP_GET_VARS['login']) ) && (!$userdata['session_logged_in'] || isset($HTTP_POST_VARS['admin'])) )
056:     {
057:         $username = isset($HTTP_POST_VARS['username']) ? phpbb_clean_username($HTTP_POST_VARS['username']) : '';
058:         $password = isset($HTTP_POST_VARS['password']) ? $HTTP_POST_VARS['password'] : '';
059:
060:         $sql = "SELECT user_id, username, user_password, user_active, user_level
061:             FROM " . USERS_TABLE . "
062:             WHERE username = '" . str_replace("\\'", "''", $username) . "'";
063:         if ( !($result = $db->sql_query($sql)) )
064:         {
065:             message_die(GENERAL_ERROR, 'Error in obtaining userdata', '', __LINE__, __FILE__, $sql);
066:         }
067:
068:         if( $row = $db->sql_fetchrow($result) )
069:         {
070:             if( $row['user_level'] != ADMIN && $board_config['board_disable'] )
071:             {
072: redirect(append_sid("index.$phpEx", true));
073:             }
074:             else
075:             {
076:                 if( md5($password) == $row['user_password'] && $row['user_active'] )
077:                 {
078:                     $autologin = ( isset($HTTP_POST_VARS['autologin']) ) ? TRUE : 0;
079:
080:                     $admin = (isset($HTTP_POST_VARS['admin'])) ? 1 : 0;
081:                     $session_id = session_begin($row['user_id'], $user_ip, PAGE_INDEX, FALSE, $autologin, $admin);
082:
083:                     if( $session_id )
084:                     {
085: $url = ( !empty($HTTP_POST_VARS['redirect']) ) ? str_replace('&amp;', '&', htmlspecialchars($HTTP_POST_VARS['redirect'])) : "index.$phpEx";
086:                     }
087:                     else
088:                     {
089:                         message_die(CRITICAL_ERROR, "Couldn't start session : login", "", __LINE__, __FILE__);
090:                     }
091:                 }
092:                 else
093:                 {
094:                     $redirect = ( !empty($HTTP_POST_VARS['redirect']) ) ? str_replace('&amp;', '&', htmlspecialchars($HTTP_POST_VARS['redirect'])) : '';
095:                     $redirect = str_replace('?', '&', $redirect);
096:
097:                     if (strstr(urldecode($redirect), "\n") || strstr(urldecode($redirect), "\r"))
098:                     {
099:                         message_die(GENERAL_ERROR, 'Tried to redirect to potentially insecure url.');
100:                     }
101:
102:                     $template->assign_vars(array(
103:                         'META' => "<meta http-equiv=\"refresh\" content=\"3;url=login.$phpEx?redirect=$redirect\">")
104:                     );
105:
106:                     $message = $lang['Error_login'] . '<br /><br />' . sprintf($lang['Click_return_login'], "<a href=\"login.$phpEx?redirect=$redirect\">", '</a>') . '<br /><br />' .  sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
107:
108:                     message_die(GENERAL_MESSAGE, $message);
109:                 }
110:             }
111:         }
112:         else
113:         {
114:             $redirect = ( !empty($HTTP_POST_VARS['redirect']) ) ? str_replace('&amp;', '&', htmlspecialchars($HTTP_POST_VARS['redirect'])) : "";
115:             $redirect = str_replace("?", "&", $redirect);
116:
117:             if (strstr(urldecode($redirect), "\n") || strstr(urldecode($redirect), "\r"))
118:             {
119:                 message_die(GENERAL_ERROR, 'Tried to redirect to potentially insecure url.');
120:             }
121:
122:             $template->assign_vars(array(
123:                 'META' => "<meta http-equiv=\"refresh\" content=\"3;url=login.$phpEx?redirect=$redirect\">")
124:             );
125:
126:             $message = $lang['Error_login'] . '<br /><br />' . sprintf($lang['Click_return_login'], "<a href=\"login.$phpEx?redirect=$redirect\">", '</a>') . '<br /><br />' .  sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
127:
128:             message_die(GENERAL_MESSAGE, $message);
129:         }
130:     }
131:     else if( ( isset($HTTP_GET_VARS['logout']) || isset($HTTP_POST_VARS['logout']) ) && $userdata['session_logged_in'] )
132:     {
133:         // session id check
134:         if ($sid == '' || $sid != $userdata['session_id'])
135:         {
136:             message_die(GENERAL_ERROR, 'Invalid_session');
137:         }
138:
139:         if( $userdata['session_logged_in'] )
140:         {
141:             session_end($userdata['session_id'], $userdata['user_id']);
142:         }
143:
144:         if (!empty($HTTP_POST_VARS['redirect']) || !empty($HTTP_GET_VARS['redirect']))
145:         {
146:             $url = (!empty($HTTP_POST_VARS['redirect'])) ? htmlspecialchars($HTTP_POST_VARS['redirect']) : htmlspecialchars($HTTP_GET_VARS['redirect']);
147:             $url = str_replace('&amp;', '&', $url);
148: redirect(append_sid("index.$phpEx", true));
149:         }
150:         else
151:         {
152: redirect(append_sid("index.$phpEx", true));
153:         }
154:     }
155:     else
156:     {
157: $url = ( !empty($HTTP_POST_VARS['redirect']) ) ? str_replace('&amp;', '&', htmlspecialchars($HTTP_POST_VARS['redirect'])) : "index.$phpEx";
158:         redirect(append_sid($url, true));
159:     }
160: }
161: else
162: {
163:     //
164:     // Do a full login page dohickey if
165:     // user not already logged in
166:     //
167:     if( !$userdata['session_logged_in'] || (isset($HTTP_GET_VARS['admin']) && $userdata['session_logged_in'] && $userdata['user_level'] == ADMIN))
168:     {
169:         $page_title = $lang['Login'];
170:         include($phpbb_root_path . 'includes/page_header.'.$phpEx);
171:
172:         $template->set_filenames(array(
173:             'body' => 'login_body.tpl')
174:         );
175:
176:         $forward_page = '';
177:
178:         if( isset($HTTP_POST_VARS['redirect']) || isset($HTTP_GET_VARS['redirect']) )
179:         {
180:             $forward_to = $HTTP_SERVER_VARS['QUERY_STRING'];
181:
182:             if( preg_match("/^redirect=([a-z0-9\.#\/\?&=\+\-_]+)/si", $forward_to, $forward_matches) )
183:             {
184:                 $forward_to = ( !empty($forward_matches[3]) ) ? $forward_matches[3] : $forward_matches[1];
185:                 $forward_match = explode('&', $forward_to);
186:
187:                 if(count($forward_match) > 1)
188:                 {
189:                     for($i = 1; $i < count($forward_match); $i++)
190:                     {
191:                         if( !ereg("sid=", $forward_match[$i]) )
192:                         {
193:                             if( $forward_page != '' )
194:                             {
195:                                 $forward_page .= '&';
196:                             }
197:                             $forward_page .= $forward_match[$i];
198:                         }
199:                     }
200:                     $forward_page = $forward_match[0] . '?' . $forward_page;
201:                 }
202:                 else
203:                 {
204:                     $forward_page = $forward_match[0];
205:                 }
206:             }
207:         }
208:
209:         $username = ( $userdata['user_id'] != ANONYMOUS ) ? $userdata['username'] : '';
210:
211:         $s_hidden_fields = '<input type="hidden" name="redirect" value="' . $forward_page . '" />';
212:         $s_hidden_fields .= (isset($HTTP_GET_VARS['admin'])) ? '<input type="hidden" name="admin" value="1" />' : '';
213:
214:         make_jumpbox('viewforum.'.$phpEx);
215:         $template->assign_vars(array(
216:             'USERNAME' => $username,
217:
218:             'L_ENTER_PASSWORD' => (isset($HTTP_GET_VARS['admin'])) ? $lang['Admin_reauthenticate'] : $lang['Enter_password'],
219:             'L_SEND_PASSWORD' => $lang['Forgotten_password'],
220:
221:             'U_SEND_PASSWORD' => append_sid("profile.$phpEx?mode=sendpassword"),
222:
223:             'S_HIDDEN_FIELDS' => $s_hidden_fields)
224:         );
225:
226:         $template->pparse('body');
227:
228:         include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
229:     }
230:     else
231:     {
232: redirect(append_sid("index.$phpEx", true));
233:     }
234:
235: }
236:
237: ?>
Last edited by giopas on Thu Dec 08, 2005 2:54 pm, edited 1 time in total.
giopas
Registered User
 
Posts: 5
Joined: Wed Dec 07, 2005 10:29 am
Location: Italy

Postby giopas » Thu Dec 08, 2005 1:58 pm

I just add that sometimes the second admin login is displayed, but when I submit my nick and pass, I obtain the usual blank page... :(

can someone post his login.php or help m, please? Thnx a bunch

giopas
giopas
Registered User
 
Posts: 5
Joined: Wed Dec 07, 2005 10:29 am
Location: Italy

Postby giopas » Thu Dec 08, 2005 3:34 pm

I fixed it just uploading a default installation login.php
giopas
Registered User
 
Posts: 5
Joined: Wed Dec 07, 2005 10:29 am
Location: Italy


Return to 2.0.x Support Forum

Who is online

Users browsing this forum: No registered users and 10 guests