source: extensions/Register_PhpBB/reg_phpbb_migration.php @ 7727

Last change on this file since 7727 was 7727, checked in by Eric, 13 years ago

Initial repository based on old 1.2a version

  • Property svn:eol-style set to LF
File size: 4.9 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Plugin Name : Register_PhpBB                                          |
4// | Plugin Version : 1.2a                                                 |
5// | File Version : 0.1                                                    |
6// | Plugin Version author : Eric <lucifer@infernoweb.net>                 |
7// | Plugin description :                                                  |
8// | Ce plugin permet l'enregistrement d'un utilisateur directement dans   |
9// | phpbb - This plugin allows to automatically register a PWG user in a  |
10// | phpbb forum                                                           |
11// +-----------------------------------------------------------------------+
12// | This program is free software; you can redistribute it and/or modify  |
13// | it under the terms of the GNU General Public License as published by  |
14// | the Free Software Foundation                                          |
15// |                                                                       |
16// | This program is distributed in the hope that it will be useful, but   |
17// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
18// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
19// | General Public License for more details.                              |
20// |                                                                       |
21// | You should have received a copy of the GNU General Public License     |
22// | along with this program; if not, write to the Free Software           |
23// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
24// | USA.                                                                  |
25// +-----------------------------------------------------------------------+
26
27// **************************************
28// ** User migration from PWG to PhpBB **
29// **************************************
30
31include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
32
33echo '<h2>Migration des comptes PhpWebGallery vers PhpBB</h2>';
34
35// Select of PWG users
36$query = 'SELECT username, password, mail_address FROM '.USERS_TABLE.';';
37$result = pwg_query($query);
38
39$registred = time();
40$registred_ip = '127.0.0.1';
41
42while ($row = mysql_fetch_array($result))
43{
44    if(($row['username'] != 'guest') AND ($row['username'] != $conf['phpbb_admin']))
45    {
46        echo '<b>Transfert du compte :</b> '.$row['username'].' --> ';
47       
48        // Getting the last user Id
49        $query_1 = '
50                                SELECT MAX(user_id) AS total
51                                FROM '.$conf['phpbb_prefix'].'users;
52                        ';
53                $result_1 = pwg_query($query_1);
54        $row_1 = mysql_fetch_array($result_1);
55                // The new user Id is the last one + 1
56                $user_id = $row_1['total'] + 1;
57       
58        $query_2 = "
59                        INSERT INTO ".$conf['phpbb_prefix']."users
60                        (user_id, user_active, user_actkey, username, user_password, user_session_time, user_session_page, user_lastvisit, user_regdate, user_level, user_posts, user_style, user_lang, user_dateformat, user_new_privmsg, user_unread_privmsg, user_last_privmsg, user_login_tries, user_last_login_try, user_viewemail, user_attachsig, user_allowhtml, user_allowbbcode, user_allowsmile, user_allowavatar, user_allow_pm, user_allow_viewonline, user_notify, user_notify_pm, user_popup_pm, user_rank, user_avatar_type, user_email)
61                        VALUES (
62                                '".$user_id."',
63                                '1',
64                            '',
65                            '".$row['username']."',
66                            '".$row['password']."',
67                            '0',
68                            '0',
69                            '".$registred."',
70                            '".$registred."',
71                                    '0',
72                            '0',
73                            '".$conf['phpbb_style']."',
74                            '".$conf['phpbb_language']."',
75                            'D M d, Y g:i a',
76                            '0',
77                            '0',
78                            '0',
79                            '0',
80                        '0',
81                            '0',
82                            '1',
83                            '0',
84                        '1',
85                            '1',
86                            '1',
87                            '1',
88                        '1',
89                            '0',
90                            '1',
91                            '1',
92                        '0',
93                            '0',
94                            '".$row['mail_address']."'
95                        );
96                ";
97        $result_2 = pwg_query($query_2);
98
99        // Get PhpBB user Id
100        $id_user_phpbb = mysql_insert_id();
101
102                $query_3 = "
103                                INSERT INTO ".$conf['phpbb_prefix']."groups
104                                (group_name, group_description, group_single_user, group_moderator)
105                                VALUES ('".$row['username']."', 'Personal User', 1, 0);
106                        ";
107        $result_3 = pwg_query($query_3);
108
109        $group_id = mysql_insert_id();
110
111        $query_4 = "
112                                INSERT INTO ".$conf['phpbb_prefix']."user_group
113                                (group_id, user_id, user_pending)
114                                VALUES ('".$group_id."','".$id_user_phpbb."','0');
115                        ";
116        $result_4 = pwg_query($query_4);
117
118        // Get PWG user Id
119        $user_id_pwg = get_userid($row['username']);
120
121        // Insert of PWG user id and PhpBB user id on correspondence table
122        $query_5 = "
123                INSERT INTO ".PLUGIN_REGISTER_PHPBB_ID." (id_user_pwg, id_user_phpbb)
124                VALUES('".$user_id_pwg."', '".$id_user_phpbb."');
125                        ";
126        $result_5 = pwg_query($query_5);
127        echo '<b>Migration done !</b><br>';
128    }
129}
130
131//TODO: Get the migration result into a template
132?>
Note: See TracBrowser for help on using the repository browser.