source: extensions/Register_PunBB/reg_punbb_update_profile.php @ 9624

Last change on this file since 9624 was 7809, checked in by Eric, 14 years ago

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

  • Property svn:eol-style set to LF
File size: 2.9 KB
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// Password hashing method
28if (function_exists('sha1'))    // Only in PHP 4.3.0+
29{
30    $password = sha1($_POST['use_new_pwd']);
31}
32else if (function_exists('mhash'))      // Only if Mhash library is loaded
33{
34    $password =  bin2hex(mhash(MHASH_SHA1, $_POST['use_new_pwd']));
35}
36else
37{
38    $password =  md5($_POST['use_new_pwd']);
39}
40
41// Retrieve user ID in PunBB user table
42$query = '
43        SELECT id_user_punbb
44        FROM '.PLUGIN_REGISTER_PUNBB_ID
45        .' WHERE id_user_pwg = '.$userdata['id'].';
46    ';
47$result = pwg_query($query);
48
49while($row = mysql_fetch_array($result))
50{
51    // Email modification
52    $query = '
53            UPDATE '.$conf['punbb_prefix'].'users
54            SET email = \''.$_POST['mail_address'].'\'';
55
56            // If new password field is empty
57            // the change is set in the PunBB
58            // users table with password hashing.
59            if (!empty($_POST['use_new_pwd']))
60            {
61                $query.= ', password = \''.$password.'\'';
62            }
63            $query.= ' WHERE id = '.$row['id_user_punbb'].';
64        ';
65    $result = pwg_query($query);
66}
67?>
Note: See TracBrowser for help on using the repository browser.