1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: Register FluxBB |
---|
4 | Version: 2.1.3 |
---|
5 | Description: Link user registration from Piwigo to FluxBB forum (registration, password changing, deletion) - Original Nicco's NBC_LinkUser2PunBB plugin upgraded to Piwigo / Liez l'inscription des utilisateurs de Piwigo avec votre forum FluxBB - Portage du plugin NBC_LinkUser2PunBB de Nicco vers Piwigo |
---|
6 | Plugin URI: http://phpwebgallery.net/ext/extension_view.php?eid=252 |
---|
7 | Author: Eric |
---|
8 | Author URI: http://www.infernoweb.net |
---|
9 | */ |
---|
10 | |
---|
11 | /* |
---|
12 | -------------------------------------------------------------------------------- |
---|
13 | Author : Eric |
---|
14 | email : lucifer@infernoweb.net |
---|
15 | website : http://www.infernoweb.net |
---|
16 | PWG user : http://forum.phpwebgallery.net/profile.php?id=1106 |
---|
17 | -------------------------------------------------------------------------------- |
---|
18 | |
---|
19 | :: HISTORY |
---|
20 | |
---|
21 | 2.0.0b - 23/11/08 - Initial release. Basic changes to be available for Piwigo 2.0RC4 |
---|
22 | |
---|
23 | 2.0.1b - 24/11/08 - Small bug correction on submit button display |
---|
24 | |
---|
25 | 2.0.2 - 19/02/09 - Language pack correction |
---|
26 | |
---|
27 | 2.1.0 - 25/04/09 - Admin panel with tabsheets |
---|
28 | - Radio buttons functionnalities corrections (now radio buttons show the configuration saved in database) |
---|
29 | - Language files (fr - en) improvement |
---|
30 | |
---|
31 | 2.1.1 - 30/04/09 - Bug fixed on profile update |
---|
32 | |
---|
33 | 2.1.2 - 22/08/09 - Compatibility bug fixed when used with DynamicRecentPeriod plugin |
---|
34 | |
---|
35 | 2.1.3 - 16/11/09 - Using sha1 hash instead of md5 for password hashing in FluxBB |
---|
36 | - Escaping all characters in login names and be able to retreive them without slashes - FluxBB does not allow this so Piwigo's user names with escaped characters will not been escaped in FluxBB (ie : "it's" in Piwigo will be "It\'s" in FluxBB) |
---|
37 | - Code refactoring |
---|
38 | - Full HTML 4.0 for tpl |
---|
39 | |
---|
40 | -------------------------------------------------------------------------------- |
---|
41 | */ |
---|
42 | |
---|
43 | // pour faciliter le debug - make debug easier :o) |
---|
44 | //ini_set('error_reporting', E_ALL); |
---|
45 | //ini_set('display_errors', true); |
---|
46 | |
---|
47 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
48 | |
---|
49 | define('Register_FluxBB_DIR' , basename(dirname(__FILE__))); |
---|
50 | define('Register_FluxBB_PATH' , PHPWG_PLUGINS_PATH . Register_FluxBB_DIR . '/'); |
---|
51 | include_once (Register_FluxBB_PATH.'include/functions_Register_FluxBB.inc.php'); |
---|
52 | |
---|
53 | /* plugin administration */ |
---|
54 | add_event_handler('get_admin_plugin_menu_links', 'Register_FluxBB_admin_menu'); |
---|
55 | |
---|
56 | function Register_FluxBB_admin_menu($menu) |
---|
57 | { |
---|
58 | array_push($menu, array( |
---|
59 | 'NAME' => 'Register FluxBB', |
---|
60 | 'URL' => get_admin_plugin_menu_link(Register_FluxBB_PATH.'admin/Register_FluxBB_admin.php'))); |
---|
61 | return $menu; |
---|
62 | } |
---|
63 | |
---|
64 | |
---|
65 | /* user creation*/ |
---|
66 | add_event_handler('register_user', 'Register_FluxBB_Adduser'); |
---|
67 | |
---|
68 | function Register_FluxBB_Adduser($register_user) |
---|
69 | { |
---|
70 | global $conf; |
---|
71 | |
---|
72 | include_once (Register_FluxBB_PATH.'include/functions_Register_FluxBB.inc.php'); |
---|
73 | |
---|
74 | // Warning : FluxBB uses Sha1 hash instead of md5 for Piwigo ! |
---|
75 | FluxBB_Adduser($register_user['id'], $register_user['username'], sha1($_POST['password']), $register_user['email']); |
---|
76 | } |
---|
77 | |
---|
78 | |
---|
79 | /* user deletion */ |
---|
80 | add_event_handler('delete_user', 'Register_FluxBB_Deluser'); |
---|
81 | |
---|
82 | function Register_FluxBB_Deluser($user_id) |
---|
83 | { |
---|
84 | include_once (Register_FluxBB_PATH.'include/functions_Register_FluxBB.inc.php'); |
---|
85 | |
---|
86 | FluxBB_Deluser( FluxBB_Searchuser($user_id), true ); |
---|
87 | } |
---|
88 | |
---|
89 | |
---|
90 | |
---|
91 | add_event_handler('init', 'Register_FluxBB_InitPage'); |
---|
92 | |
---|
93 | function Register_FluxBB_InitPage() |
---|
94 | { |
---|
95 | global $conf, $user ; |
---|
96 | include_once (Register_FluxBB_PATH.'include/functions_Register_FluxBB.inc.php'); |
---|
97 | |
---|
98 | /* user update */ |
---|
99 | if (script_basename() == 'profile') |
---|
100 | { |
---|
101 | if (isset($_POST['validate'])) |
---|
102 | { |
---|
103 | $errors = array(); |
---|
104 | |
---|
105 | $int_pattern = '/^\d+$/'; |
---|
106 | if (empty($_POST['nb_image_line']) |
---|
107 | or (!preg_match($int_pattern, $_POST['nb_image_line']))) |
---|
108 | { |
---|
109 | $errors[] = l10n('nb_image_line_error'); |
---|
110 | } |
---|
111 | |
---|
112 | if (empty($_POST['nb_line_page']) |
---|
113 | or (!preg_match($int_pattern, $_POST['nb_line_page']))) |
---|
114 | { |
---|
115 | $errors[] = l10n('nb_line_page_error'); |
---|
116 | } |
---|
117 | |
---|
118 | if ($_POST['maxwidth'] != '' |
---|
119 | and (!preg_match($int_pattern, $_POST['maxwidth']) |
---|
120 | or $_POST['maxwidth'] < 50)) |
---|
121 | { |
---|
122 | $errors[] = l10n('maxwidth_error'); |
---|
123 | } |
---|
124 | |
---|
125 | if ($_POST['maxheight'] |
---|
126 | and (!preg_match($int_pattern, $_POST['maxheight']) |
---|
127 | or $_POST['maxheight'] < 50)) |
---|
128 | { |
---|
129 | $errors[] = l10n('maxheight_error'); |
---|
130 | } |
---|
131 | |
---|
132 | if (isset($_POST['mail_address'])) |
---|
133 | { |
---|
134 | $mail_error = validate_mail_address($user['id'],$_POST['mail_address']); |
---|
135 | if (!empty($mail_error)) |
---|
136 | { |
---|
137 | $errors[] = $mail_error; |
---|
138 | } |
---|
139 | } |
---|
140 | |
---|
141 | if (!empty($_POST['use_new_pwd'])) |
---|
142 | { |
---|
143 | // password must be the same as its confirmation |
---|
144 | if ($_POST['use_new_pwd'] != $_POST['passwordConf']) |
---|
145 | { |
---|
146 | $errors[] = l10n('New password confirmation does not correspond'); |
---|
147 | } |
---|
148 | |
---|
149 | if ( !defined('IN_ADMIN') ) |
---|
150 | {// changing password requires old password |
---|
151 | $query = ' |
---|
152 | SELECT '.$conf['user_fields']['password'].' AS password |
---|
153 | FROM '.USERS_TABLE.' |
---|
154 | WHERE '.$conf['user_fields']['id'].' = \''.$user['id'].'\' |
---|
155 | ;'; |
---|
156 | |
---|
157 | list($current_password) = mysql_fetch_row(pwg_query($query)); |
---|
158 | |
---|
159 | if ($conf['pass_convert']($_POST['password']) != $current_password) |
---|
160 | { |
---|
161 | $errors[] = l10n('Current password is wrong'); |
---|
162 | } |
---|
163 | } |
---|
164 | } |
---|
165 | |
---|
166 | if (count($errors) == 0) |
---|
167 | { |
---|
168 | include_once (Register_FluxBB_PATH.'include/functions_Register_FluxBB.inc.php'); |
---|
169 | |
---|
170 | $query = ' |
---|
171 | SELECT '.$conf['user_fields']['username'].' AS username |
---|
172 | FROM '.USERS_TABLE.' |
---|
173 | WHERE '.$conf['user_fields']['id'].' = \''.$user['id'].'\' |
---|
174 | ;'; |
---|
175 | |
---|
176 | list($username) = mysql_fetch_row(pwg_query($query)); |
---|
177 | |
---|
178 | FluxBB_Updateuser($user['id'], stripslashes($username), sha1($_POST['use_new_pwd']), $_POST['mail_address']); |
---|
179 | } |
---|
180 | } |
---|
181 | } |
---|
182 | } |
---|
183 | ?> |
---|