4WebHelp
 FAQ  •  Search  •  User Groups  •  Forum Admins  •  Smilies List  •  Statistics  •  Rules   •  Login   •  Register
Toggle Navigation Menu

 Problems Logging Into Forum After Restore
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic
Author Message
billdavies
Senior WebHelper
Senior WebHelper


Joined: 22 Jan 2002
Posts: 107
Location: UK

PostPosted: Sun Nov 24, 2002 9:05 pm (14 years, 11 months ago) Reply with QuoteBack to Top

Hi, I just posted this on the phpBB forum but thought you may be able to help too.

Hi,

I recently changed hosts and I have been trying to restore my forum database on my new forum. Here is what I did.

1) I tried using both the Restore Database via forum and restoring the database via phpMyAdmin. Both times I used a Forum Backup via the forum and a manual one via phpMyAdmin. These worked upto the table phpbb_posts_text where there was an error on line 1. Because of this everything before had been changed in the database, so all my different forums were etc.

2) After that I cleaned the database, reinstalled the forum and tried number one again, didn't work.

3) I cleaned the databse, reinstalled the forum and this time installed each table from the sql file on the old host. This meant I would have to export the file from my old host and then run it on my new host (this is all under phpMyAdmin). All of this worked, including the posts_text table etc, but now I cannot login to my forum! I know that I am using the correct pasword as if I do NOT use the correct password I am told that an invalid username/password has been used etc etc but if I use the CORRECT password then I am just taken back to the page I logged in from (so if I logged in via the index page, I would just be taken back to the index page - not logged in).

Does anyone know how to correct this? If it helps my login.php file looks like this:

Code:

<?php
/***************************************************************************
 *                                login.php
 *                            -------------------
 *   begin                : Saturday, Feb 13, 2001
 *   copyright            : (C) 2001 The phpBB Group
 *   email                : support@phpbb.com
 *
 *   $Id: login.php,v 1.47.2.3 2002/09/20 11:40:38 psotfx Exp $
 *
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/

//
// Allow people to reach login page if
// board is shut down
//
define("IN_LOGIN", true);

define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);

//
// Set page ID for session management
//
$userdata = session_pagestart($user_ip, PAGE_LOGIN);
init_userprefs($userdata);
//
// End session management
//

$header_location = ( @preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE')) ) ? 'Refresh: 0; URL=' : 'Location: ';

if( isset($HTTP_POST_VARS['login']) || isset($HTTP_GET_VARS['login']) || isset($HTTP_POST_VARS['logout']) || isset($HTTP_GET_VARS['logout']) )
{
   //
   // This appears to work for IIS5 CGI under Win2K. Uses getenv
   // since this doesn't exist for ISAPI mode and therefore the
   // normal Location redirector is used in preference
   //
   if( ( isset($HTTP_POST_VARS['login']) || isset($HTTP_GET_VARS['login']) ) && !$userdata['session_logged_in'] )
   {
      $username = isset($HTTP_POST_VARS['username']) ? $HTTP_POST_VARS['username'] : '';
      $password = isset($HTTP_POST_VARS['password']) ? $HTTP_POST_VARS['password'] : '';

      $sql = "SELECT user_id, username, user_password, user_active, user_level
         FROM " . USERS_TABLE . "
         WHERE username = '" . str_replace("\'", "''", $username) . "'";
      if ( !($result = $db->sql_query($sql)) )
      {
         message_die(GENERAL_ERROR, 'Error in obtaining userdata', '', __LINE__, __FILE__, $sql);
      }

      if( $row = $db->sql_fetchrow($result) )
      {
         if( $row['user_level'] != ADMIN && $board_config['board_disable'] )
         {
            header($header_location . append_sid("index.$phpEx", true));
            exit;
         }
         else
         {
            if( md5($password) == $row['user_password'] && $row['user_active'] )
            {
               $autologin = ( isset($HTTP_POST_VARS['autologin']) ) ? TRUE : 0;

               $session_id = session_begin($row['user_id'], $user_ip, PAGE_INDEX, FALSE, $autologin);

               if( $session_id )
               {
                  if( !empty($HTTP_POST_VARS['redirect']) )
                  {
                     header($header_location . append_sid($HTTP_POST_VARS['redirect'], true));
                     exit;
                  }
                  else
                  {
                     header($header_location . append_sid("index.$phpEx", true));
                     exit;
                  }
               }
               else
               {
                  message_die(CRITICAL_ERROR, "Couldn't start session : login", "", __LINE__, __FILE__);
               }
            }
            else
            {
               $redirect = ( !empty($HTTP_POST_VARS['redirect']) ) ? $HTTP_POST_VARS['redirect'] : '';
               $redirect = str_replace("?", "&", $redirect);

               $template->assign_vars(array(
                  'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("login.$phpEx?redirect=$redirect") . '">')
               );

               $message = $lang['Error_login'] . '<br /><br />' . sprintf($lang['Click_return_login'], '<a href="' . append_sid("login.$phpEx?redirect=$redirect") . '">', '</a>') . '<br /><br />' .  sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>');

               message_die(GENERAL_MESSAGE, $message);
            }
         }
      }
      else
      {
         $redirect = ( !empty($HTTP_POST_VARS['redirect']) ) ? $HTTP_POST_VARS['redirect'] : "";
         $redirect = str_replace("?", "&", $redirect);

         $template->assign_vars(array(
            'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("login.$phpEx?redirect=$redirect") . '">')
         );

         $message = $lang['Error_login'] . '<br /><br />' . sprintf($lang['Click_return_login'], '<a href="' . append_sid("login.$phpEx?redirect=$redirect") . '">', '</a>') . '<br /><br />' .  sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>');

         message_die(GENERAL_MESSAGE, $message);
      }
   }
   else if( ( isset($HTTP_GET_VARS['logout']) || isset($HTTP_POST_VARS['logout']) ) && $userdata['session_logged_in'] )
   {
      if( $userdata['session_logged_in'] )
      {
         session_end($userdata['session_id'], $userdata['user_id']);
      }

      if( !empty($HTTP_POST_VARS['redirect']) )
      {
         header($header_location . append_sid($HTTP_POST_VARS['redirect'], true));
         exit;
      }
      else
      {
         header($header_location . append_sid("index.$phpEx", true));
         exit;
      }
   }
   else
   {
      if( !empty($HTTP_POST_VARS['redirect']) )
      {
         header($header_location . append_sid($HTTP_POST_VARS['redirect'], true));
         exit;
      }
      else
      {
         header($header_location . append_sid("index.$phpEx", true));
         exit;
      }
   }
}
else
{
   //
   // Do a full login page dohickey if
   // user not already logged in
   //
   if( !$userdata['session_logged_in'] )
   {
      $page_title = $lang['Login'];
      include($phpbb_root_path . 'includes/page_header.'.$phpEx);

      $template->set_filenames(array(
         'body' => 'login_body.tpl')
      );

      if( isset($HTTP_POST_VARS['redirect']) || isset($HTTP_GET_VARS['redirect']) )
      {
         $forward_to = $HTTP_SERVER_VARS['QUERY_STRING'];

         if( preg_match("/^redirect=([a-z0-9\.#\/\?&=\+\-_]+)/si", $forward_to, $forward_matches) )
         {
            $forward_to = ( !empty($forward_matches[3]) ) ? $forward_matches[3] : $forward_matches[1];
            $forward_match = explode('&', $forward_to);

            if(count($forward_match) > 1)
            {
               $forward_page = '';

               for($i = 1; $i < count($forward_match); $i++)
               {
                  if( !ereg("sid=", $forward_match[$i]) )
                  {
                     if( $forward_page != '' )
                     {
                        $forward_page .= '&';
                     }
                     $forward_page .= $forward_match[$i];
                  }
               }
               $forward_page = $forward_match[0] . '?' . $forward_page;
            }
            else
            {
               $forward_page = $forward_match[0];
            }
         }
      }
      else
      {
         $forward_page = '';
      }

      $username = ( $userdata['user_id'] != ANONYMOUS ) ? $userdata['username'] : '';

      $s_hidden_fields = '<input type="hidden" name="redirect" value="' . $forward_page . '" />';

      make_jumpbox('viewforum.'.$phpEx, $forum_id);
      $template->assign_vars(array(
         'USERNAME' => $username,

         'L_ENTER_PASSWORD' => $lang['Enter_password'],
         'L_SEND_PASSWORD' => $lang['Forgotten_password'],

         'U_SEND_PASSWORD' => append_sid("profile.$phpEx?mode=sendpassword"),

         'S_HIDDEN_FIELDS' => $s_hidden_fields)
      );

      $template->pparse('body');

      include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
   }
   else
   {
      header($header_location . append_sid("index.$phpEx", true));
      exit;
   }

}

?>


Thanks
OfflineView User's ProfileFind all posts by billdaviesSend Personal MessageVisit Poster's WebsiteMSN Messenger
Daniel
Team Member



Joined: 06 Jan 2002
Posts: 2564

PostPosted: Mon Nov 25, 2002 7:15 am (14 years, 11 months ago) Reply with QuoteBack to Top

Try looking at your cookie settings in the config table. The domain or path might be incorrect, if you've changed domain names.

________________________________
Image
OfflineView User's ProfileFind all posts by DanielSend Personal Message
billdavies
Senior WebHelper
Senior WebHelper


Joined: 22 Jan 2002
Posts: 107
Location: UK

PostPosted: Mon Nov 25, 2002 6:26 pm (14 years, 11 months ago) Reply with QuoteBack to Top

Thanks, I had changed the domain but not the name of the cookie that was confusing everything.

Only problem now is that cookies don't work. What should I put under the path as it currently just says /

Thanks

Bill
OfflineView User's ProfileFind all posts by billdaviesSend Personal MessageVisit Poster's WebsiteMSN Messenger
Daniel
Team Member



Joined: 06 Jan 2002
Posts: 2564

PostPosted: Mon Nov 25, 2002 7:14 pm (14 years, 11 months ago) Reply with QuoteBack to Top

Where is your forum installed? If it is installed at site.com/forums/, the path should be "/forums/". If it is installed at site.com/, it should be "/".

________________________________
Image
OfflineView User's ProfileFind all posts by DanielSend Personal Message
billdavies
Senior WebHelper
Senior WebHelper


Joined: 22 Jan 2002
Posts: 107
Location: UK

PostPosted: Mon Nov 25, 2002 9:00 pm (14 years, 11 months ago) Reply with QuoteBack to Top

Nope, doesn't want to work! I have checked everything and it is correct but cookies still won't work. I checked it in phpMyAdmin and it's all good.

Bill
OfflineView User's ProfileFind all posts by billdaviesSend Personal MessageVisit Poster's WebsiteMSN Messenger
Daniel
Team Member



Joined: 06 Jan 2002
Posts: 2564

PostPosted: Mon Nov 25, 2002 9:02 pm (14 years, 11 months ago) Reply with QuoteBack to Top

OK, now try this:

Create a .php file, and enter the following in it:

Code:
md5('YOURCURRENTPASSWORD');


Then run it in your browser, and look at the output. Then compare the output with the value in 'user_password' in the users table. Tell me if it matches.

________________________________
Image
OfflineView User's ProfileFind all posts by DanielSend Personal Message
billdavies
Senior WebHelper
Senior WebHelper


Joined: 22 Jan 2002
Posts: 107
Location: UK

PostPosted: Mon Nov 25, 2002 9:05 pm (14 years, 11 months ago) Reply with QuoteBack to Top

I'll try that if this doesn't help but I have just tried going to the forum with the www. prefix and the cookies work, but without the www. prefix the cookies don't work. Is there a way to handle both?

Bill
OfflineView User's ProfileFind all posts by billdaviesSend Personal MessageVisit Poster's WebsiteMSN Messenger
Daniel
Team Member



Joined: 06 Jan 2002
Posts: 2564

PostPosted: Mon Nov 25, 2002 9:13 pm (14 years, 11 months ago) Reply with QuoteBack to Top

The way we have it here at 4WebHelp is without a domain name in the cookie settings. Seems to work... Otherwise try ".domain.com" instead of "www.domain.com". If all that doesn't work properly, try this in your .htaccess file:

Code:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.com$
RewriteRule ^(.*)$ http://www.domain.com/$1 [R]


That will redirect domain.com to www.domain.com.

________________________________
Image
OfflineView User's ProfileFind all posts by DanielSend Personal Message
Display posts from previous:      
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic


 Jump to:   




You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot edit your posts in this forum.
You cannot delete your posts in this forum.
You cannot vote in polls in this forum.


Page generation time: 0.077662 seconds :: 17 queries executed :: All Times are GMT
Powered by phpBB 2.0 © 2001, 2002 phpBB Group :: Based on an FI Theme