source: extensions/Register_PunBB/reg_punbb_migration.php @ 9885

Revision 7809, 3.6 KB checked in by Eric, 9 years ago (diff)

Commit of latest plugin version (1.3a) as a startup base for further developpements

  • Property svn:eol-style set to LF
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Plugin Name : Register_PunBB                                          |
4// | Plugin Version : 1.3a                                                 |
5// | File Version : 0.2                                                    |
6// | Plugin Version author : Eric <lucifer@infernoweb.net>                 |
7// | Plugin description :                                                  |
8// | Ce plugin permet l'enregistrement d'un utilisateur directement dans   |
9// | PunBB (http://www.punbb.org) - This plugin allows to automatically    |
10// | register a PWG user in a PunBB forum (http://www.punbb.org)           |
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 PunBB **
29// **************************************
30
31include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
32
33echo '<h2>Migration des comptes PhpWebGallery vers PunBB</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['punbb_admin']))
45    {
46        echo '<b>Transfert du compte :</b> '.$row['username'].' --> ';
47        $query_1 = "
48            INSERT INTO ".$conf['punbb_prefix']."users (username, group_id, password, email, email_setting, save_pass, timezone, language, style, registered, registration_ip, last_visit)
49            VALUES('".$row['username']."', '".$conf['punbb_id_default_group']."',
50            '".$row['password']."', '".$row['mail_address']."', '".$conf['punbb_email_setting']."',
51            '".$conf['punbb_save_pass']."', '".$conf['punbb_timezone']."', '".$conf['punbb_language']."',
52            '".$conf['punbb_style']."','".$registred."', '".$registred_ip."', '".$registred."');";
53        $result_1 = pwg_query($query_1);
54
55        // Get PunBB user Id
56        $id_user_punbb = mysql_insert_id();
57
58        // Get PWG user Id
59        $user_id_pwg = get_userid($row['username']);
60
61        // Insert of PWG user id and PunBB user id on correspondence table
62        $query_2 = "
63                INSERT INTO ".PLUGIN_REGISTER_PUNBB_ID." (id_user_pwg, id_user_punbb)
64                VALUES('".$user_id_pwg."', '".$id_user_punbb."');";
65        $result_2 = pwg_query($query_2);
66        echo '<b>Migration done !</b><br>';
67    }
68}
69
70//TODO: Get the migration result into a template
71?>
Note: See TracBrowser for help on using the repository browser.