1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | Plugin Name : Register_PhpBB | |
---|
4 | // | Plugin Version : 1.2a | |
---|
5 | // | File Version : 0.3 | |
---|
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 | // ** Add user to the PhpBB #_users table ** |
---|
29 | // ***************************************** |
---|
30 | |
---|
31 | // Load Plugin settings from database |
---|
32 | load_conf_from_db('param like \'phpbb\\_%\''); |
---|
33 | |
---|
34 | global $conf; |
---|
35 | |
---|
36 | // Password hashing method |
---|
37 | if (function_exists('sha1')) // Only in PHP 4.3.0+ |
---|
38 | { |
---|
39 | $password = sha1($_POST['password']); |
---|
40 | } |
---|
41 | else if (function_exists('mhash')) // Only if Mhash library is loaded |
---|
42 | { |
---|
43 | $password = bin2hex(mhash(MHASH_SHA1, $_POST['password'])); |
---|
44 | } |
---|
45 | else |
---|
46 | { |
---|
47 | $password = md5($_POST['password']); |
---|
48 | } |
---|
49 | |
---|
50 | // Getting the last user Id |
---|
51 | $query0 = ' |
---|
52 | SELECT MAX(user_id) AS total FROM |
---|
53 | '.$conf['phpbb_prefix'].'users; |
---|
54 | '; |
---|
55 | $result0 = pwg_query($query0); |
---|
56 | $row0 = mysql_fetch_array($result0); |
---|
57 | |
---|
58 | // New user Id is the last one + 1 |
---|
59 | $id_user_phpbb = $row0['total'] + 1; |
---|
60 | |
---|
61 | // Registration date and time |
---|
62 | $registred = time(); |
---|
63 | |
---|
64 | // Check wich email var is used |
---|
65 | if (defined('IN_ADMIN') and IN_ADMIN) /* This is for adding a user in admin panel */ |
---|
66 | { |
---|
67 | $mail = $_POST['email']; |
---|
68 | $query1 = " |
---|
69 | INSERT INTO ".$conf['phpbb_prefix']."users |
---|
70 | (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) |
---|
71 | VALUES ( |
---|
72 | '".$id_user_phpbb."', |
---|
73 | '1', |
---|
74 | '', |
---|
75 | '".$_POST['login']."', |
---|
76 | '".$password."', |
---|
77 | '0', |
---|
78 | '0', |
---|
79 | '".$registred."', |
---|
80 | '".$registred."', |
---|
81 | '0', |
---|
82 | '0', |
---|
83 | '".$conf['phpbb_style']."', |
---|
84 | '".$conf['phpbb_language']."', |
---|
85 | 'D M d, Y g:i a', |
---|
86 | '0', |
---|
87 | '0', |
---|
88 | '0', |
---|
89 | '0', |
---|
90 | '0', |
---|
91 | '0', |
---|
92 | '1', |
---|
93 | '0', |
---|
94 | '1', |
---|
95 | '1', |
---|
96 | '1', |
---|
97 | '1', |
---|
98 | '1', |
---|
99 | '0', |
---|
100 | '1', |
---|
101 | '1', |
---|
102 | '0', |
---|
103 | '0', |
---|
104 | '".$mail."' |
---|
105 | ); |
---|
106 | "; |
---|
107 | $result1 = pwg_query($query1); |
---|
108 | } |
---|
109 | else /* This is when a user registered himself with the register form */ |
---|
110 | { |
---|
111 | $query2 = " |
---|
112 | INSERT INTO ".$conf['phpbb_prefix']."users |
---|
113 | (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) |
---|
114 | VALUES ( |
---|
115 | '".$id_user_phpbb."', |
---|
116 | '1', |
---|
117 | '', |
---|
118 | '".$_POST['login']."', |
---|
119 | '".$password."', |
---|
120 | '0', |
---|
121 | '0', |
---|
122 | '".$registred."', |
---|
123 | '".$registred."', |
---|
124 | '0', |
---|
125 | '0', |
---|
126 | '".$conf['phpbb_style']."', |
---|
127 | '".$conf['phpbb_language']."', |
---|
128 | 'D M d, Y g:i a', |
---|
129 | '0', |
---|
130 | '0', |
---|
131 | '0', |
---|
132 | '0', |
---|
133 | '0', |
---|
134 | '0', |
---|
135 | '1', |
---|
136 | '0', |
---|
137 | '1', |
---|
138 | '1', |
---|
139 | '1', |
---|
140 | '1', |
---|
141 | '1', |
---|
142 | '0', |
---|
143 | '1', |
---|
144 | '1', |
---|
145 | '0', |
---|
146 | '0', |
---|
147 | '".$_POST['mail_address']."' |
---|
148 | ); |
---|
149 | "; |
---|
150 | $result2 = pwg_query($query2); |
---|
151 | } |
---|
152 | |
---|
153 | // Processing forum groups |
---|
154 | $query3 = " |
---|
155 | INSERT INTO ".$conf['phpbb_prefix']."groups |
---|
156 | (group_name, group_description, group_single_user, group_moderator) |
---|
157 | VALUES ('".$_POST['login']."', 'Personal User', 1, 0)"; |
---|
158 | $result3 = pwg_query($query3); |
---|
159 | |
---|
160 | $group_id = mysql_insert_id(); |
---|
161 | |
---|
162 | $query4 = " |
---|
163 | INSERT INTO ".$conf['phpbb_prefix']."user_group |
---|
164 | (group_id, user_id, user_pending) |
---|
165 | VALUES ('".$group_id."','".$id_user_phpbb."','0'); |
---|
166 | "; |
---|
167 | $result4 = pwg_query($query4); |
---|
168 | |
---|
169 | // Retrieve user ID in PhpBB user table |
---|
170 | //$id_user_phpbb = mysql_insert_id(); |
---|
171 | |
---|
172 | // Retrieve user ID in PWG user table |
---|
173 | $user_id_pwg = get_userid($_POST['login']); |
---|
174 | |
---|
175 | // Insertion of the ID in the pwg/phpbb correspondence table |
---|
176 | $query5 = " |
---|
177 | INSERT INTO ".PLUGIN_REGISTER_PHPBB_ID." (id_user_pwg, id_user_phpbb) |
---|
178 | VALUES('".$user_id_pwg."', '".$id_user_phpbb."');"; |
---|
179 | $result5 = pwg_query($query5); |
---|
180 | ?> |
---|