[fix]nuke/phpbb port to standalone phpbb for user_regdate

This is an archive of the phpBB 2.0.x convertors 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
Locked
msimonds
Registered User
Posts: 26
Joined: Sun Nov 03, 2002 3:16 pm
Location: Dallas
Contact:

[fix]nuke/phpbb port to standalone phpbb for user_regdate

Post by msimonds » Wed Jan 14, 2004 5:27 pm

I have a script that will correct the user regdate from nuke to phpbb if anyone is interested so when you convert your forums the correct registration date will appear and place the unix date back into the table!. Please let me know what you think of this script! I have tested this at least 10 times:

MAKE A BACKUP OF YOUR phpbb_users table and data before you run this script!

Code: Select all

<? 
/*******************************************************************/ 
/* Place this file in the same folder as config.php                */ 
/*******************************************************************/ 
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
$sql = "SELECT user_id, user_regdate FROM phpbb_users"; 
$result = $db->sql_query($sql); 
while($record = $db->sql_fetchrow($result)) { 
   extract($record); 
   $user_regdate = str_replace(',',' ',$user_regdate); 
   $date = explode(' ',$user_regdate,3); 
   switch($date[0]) { 
      case('Jan'): $m=1;  break; 
      case('Feb'): $m=2;  break; 
      case('Mar'): $m=3;  break; 
      case('Apr'): $m=4;  break; 
      case('May'): $m=5;  break; 
      case('Jun'): $m=6;  break; 
      case('Jul'): $m=7;  break; 
      case('Aug'): $m=8;  break; 
      case('Sep'): $m=9;  break; 
      case('Oct'): $m=10; break; 
      case('Nov'): $m=11; break; 
      case('Dec'): $m=12; break; 
   } 
   $newDate = mktime(0, 0, 0, $m, $date[1], $date[2]); 
   echo $user_id.' -- '.$user_regdate.' = '.$newDate.' = '.date('m d Y',$newDate).'<br />'; 
/*******************************************************************/ 
/* When you are satisfied that the code is working correctly,      */ 
/* uncomment the following 2 lines and resubmit the script.        */ 
/*******************************************************************/ 
   //$sql = "UPDATE phpbb_users set user_regdate = $newDate where user_id = $user_id"; 
   //$result1 = $db->sql_query($sql); 
} 
?>

name it whatever you want. I named it correct.php

thanks

Mike

User avatar
Corny
Registered User
Posts: 39
Joined: Sun Jun 15, 2003 6:48 am
Contact:

Post by Corny » Sat Feb 14, 2004 6:42 pm

Wow thanks.

I wish I found this before I copied/pasted 320 time entries in my database :lol:

tom-riddle
Registered User
Posts: 24
Joined: Thu May 08, 2003 9:16 pm

Very useful!

Post by tom-riddle » Tue Feb 24, 2004 9:35 pm

Oh, this is really useful! I wouldn't even try to do what Corny did with a 2386 users database. lol :lol:

I was going to set all regdates to the same time but that would ruin the posts/day average.

Thank you very much, msimonds! I'll try that out! :)
: rafael (tom-riddle)
: www.harry.com.br

tom-riddle
Registered User
Posts: 24
Joined: Thu May 08, 2003 9:16 pm

Script fix

Post by tom-riddle » Tue Feb 24, 2004 10:13 pm

Hello again!

I found a problem in your script...

The PHP-Nuke versions with phpBB (at least 6.5) allow users to registrate through phpnuke or phpbb, if you click on the "Register" on the forums. As soon as I noticed it I changed the template to redirect the "Register" link to phpnuke registration form. But a lot of users had already registered through the forums, and their regdate are already in unix time.

When your script tries to convert the regdate of this users, it returned a nonsense number.

I fixed the script so it worked fine for me (well, just added an 'if' clause and the problem was solved :roll: ). Maybe somebody has the same problem, so, here it is:

Code: Select all

<?
/*******************************************************************/
/* Place this file in the same folder as config.php                */
/*******************************************************************/
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
$sql = "SELECT user_id, user_regdate FROM phpbb_users";
$result = $db->sql_query($sql);
while($record = $db->sql_fetchrow($result)) {
   extract($record);
   if (!is_numeric($user_regdate)) {
      $user_regdate = str_replace(',',' ',$user_regdate);
      $date = explode(' ',$user_regdate,3);
      switch($date[0]) {
         case('Jan'): $m=1;  break;
         case('Feb'): $m=2;  break;
         case('Mar'): $m=3;  break;
         case('Apr'): $m=4;  break;
         case('May'): $m=5;  break;
         case('Jun'): $m=6;  break;
         case('Jul'): $m=7;  break;
         case('Aug'): $m=8;  break;
         case('Sep'): $m=9;  break;
         case('Oct'): $m=10; break;
         case('Nov'): $m=11; break;
         case('Dec'): $m=12; break;
      }
      $newDate = mktime(0, 0, 0, $m, $date[1], $date[2]);
   }
   echo $user_id.' -- '.$user_regdate.' = '.$newDate.' = '.date('m d Y',$newDate).'<br />';
/*******************************************************************/
/* When you are satisfied that the code is working correctly,      */
/* uncomment the following 2 lines and resubmit the script.        */
/*******************************************************************/
   //$sql = "UPDATE phpbb_users set user_regdate = $newDate where user_id = $user_id";
   //$result1 = $db->sql_query($sql);
}
?>
Thank you again, msimonds. This script was very helpful! ;)
: rafael (tom-riddle)
: www.harry.com.br

Greener
Registered User
Posts: 41
Joined: Mon Dec 01, 2003 11:01 pm
Location: Mission, Kansas
Contact:

Post by Greener » Sat Apr 03, 2004 5:01 pm

I get this error when I try to run the file, which i saved as changetime.pl:

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster@washington-county.net and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.


Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.


--------------------------------------------------------------------------------

Apache/1.3.29 Server at www.washington-county.net Port 80

christopherw
Registered User
Posts: 1
Joined: Mon Jun 06, 2005 2:46 am

Post by christopherw » Mon Jun 06, 2005 2:47 am

For the sake of completeness, that's because it's not a perl script, it's a php script.
hello.

m4ck
Registered User
Posts: 2
Joined: Tue Apr 25, 2006 6:22 am

Post by m4ck » Wed Apr 26, 2006 3:53 am

Thanks this worked perfectly
m4ck

luvcl
Registered User
Posts: 26
Joined: Sat Sep 22, 2007 7:27 pm

Re: [fix]nuke/phpbb port to standalone phpbb for user_regdate

Post by luvcl » Sun Dec 23, 2007 12:29 am

I am very new in this one! Could you show me step by step to fix the user-regdate? Thanks

Locked

Return to “[2.0.x] Convertors”