1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: Register FluxBB |
---|
4 | Version: 2.1.1 |
---|
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 - Bux fixed on profile update |
---|
32 | |
---|
33 | -------------------------------------------------------------------------------- |
---|
34 | */ |
---|
35 | |
---|
36 | // pour faciliter le debug - make debug easier :o) |
---|
37 | //ini_set('error_reporting', E_ALL); |
---|
38 | //ini_set('display_errors', true); |
---|
39 | |
---|
40 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
41 | |
---|
42 | define('Register_FluxBB_DIR' , basename(dirname(__FILE__))); |
---|
43 | define('Register_FluxBB_PATH' , PHPWG_PLUGINS_PATH . Register_FluxBB_DIR . '/'); |
---|
44 | include_once (Register_FluxBB_PATH.'include/functions_Register_FluxBB.inc.php'); |
---|
45 | |
---|
46 | /* plugin administration */ |
---|
47 | add_event_handler('get_admin_plugin_menu_links', 'Register_FluxBB_admin_menu'); |
---|
48 | |
---|
49 | function Register_FluxBB_admin_menu($menu) |
---|
50 | { |
---|
51 | array_push($menu, array( |
---|
52 | 'NAME' => 'Register FluxBB', |
---|
53 | 'URL' => get_admin_plugin_menu_link(Register_FluxBB_PATH.'admin/Register_FluxBB_admin.php'))); |
---|
54 | return $menu; |
---|
55 | } |
---|
56 | |
---|
57 | |
---|
58 | /* user creation*/ |
---|
59 | add_event_handler('register_user', 'Register_FluxBB_Adduser'); |
---|
60 | |
---|
61 | function Register_FluxBB_Adduser($register_user) |
---|
62 | { |
---|
63 | global $conf; |
---|
64 | |
---|
65 | include_once (Register_FluxBB_PATH.'include/functions_Register_FluxBB.inc.php'); |
---|
66 | |
---|
67 | FluxBB_Adduser($register_user['id'], $register_user['username'], $conf['pass_convert']($_POST['password']), $register_user['email']); |
---|
68 | } |
---|
69 | |
---|
70 | |
---|
71 | /* user deletion */ |
---|
72 | add_event_handler('delete_user', 'Register_FluxBB_Deluser'); |
---|
73 | |
---|
74 | function Register_FluxBB_Deluser($user_id) |
---|
75 | { |
---|
76 | include_once (Register_FluxBB_PATH.'include/functions_Register_FluxBB.inc.php'); |
---|
77 | |
---|
78 | FluxBB_Deluser( FluxBB_Searchuser($user_id), true ); |
---|
79 | } |
---|
80 | |
---|
81 | |
---|
82 | |
---|
83 | add_event_handler('init', 'Register_FluxBB_InitPage'); |
---|
84 | |
---|
85 | function Register_FluxBB_InitPage() |
---|
86 | { |
---|
87 | global $conf, $user ; |
---|
88 | include_once (Register_FluxBB_PATH.'include/functions_Register_FluxBB.inc.php'); |
---|
89 | |
---|
90 | /* user update */ |
---|
91 | if (script_basename() == 'profile') |
---|
92 | { |
---|
93 | if (isset($_POST['validate'])) |
---|
94 | { |
---|
95 | $errors = array(); |
---|
96 | |
---|
97 | $int_pattern = '/^\d+$/'; |
---|
98 | if (empty($_POST['nb_image_line']) |
---|
99 | or (!preg_match($int_pattern, $_POST['nb_image_line']))) |
---|
100 | { |
---|
101 | $errors[] = l10n('nb_image_line_error'); |
---|
102 | } |
---|
103 | |
---|
104 | if (empty($_POST['nb_line_page']) |
---|
105 | or (!preg_match($int_pattern, $_POST['nb_line_page']))) |
---|
106 | { |
---|
107 | $errors[] = l10n('nb_line_page_error'); |
---|
108 | } |
---|
109 | |
---|
110 | if ($_POST['maxwidth'] != '' |
---|
111 | and (!preg_match($int_pattern, $_POST['maxwidth']) |
---|
112 | or $_POST['maxwidth'] < 50)) |
---|
113 | { |
---|
114 | $errors[] = l10n('maxwidth_error'); |
---|
115 | } |
---|
116 | if ($_POST['maxheight'] |
---|
117 | and (!preg_match($int_pattern, $_POST['maxheight']) |
---|
118 | or $_POST['maxheight'] < 50)) |
---|
119 | { |
---|
120 | $errors[] = l10n('maxheight_error'); |
---|
121 | } |
---|
122 | // periods must be integer values, they represents number of days |
---|
123 | if (!preg_match($int_pattern, $_POST['recent_period']) |
---|
124 | or $_POST['recent_period'] <= 0) |
---|
125 | { |
---|
126 | $errors[] = l10n('periods_error') ; |
---|
127 | } |
---|
128 | |
---|
129 | if (isset($_POST['mail_address'])) |
---|
130 | { |
---|
131 | $mail_error = validate_mail_address($user['id'],$_POST['mail_address']); |
---|
132 | if (!empty($mail_error)) |
---|
133 | { |
---|
134 | $errors[] = $mail_error; |
---|
135 | } |
---|
136 | } |
---|
137 | |
---|
138 | if (!empty($_POST['use_new_pwd'])) |
---|
139 | { |
---|
140 | // password must be the same as its confirmation |
---|
141 | if ($_POST['use_new_pwd'] != $_POST['passwordConf']) |
---|
142 | { |
---|
143 | $errors[] = l10n('New password confirmation does not correspond'); |
---|
144 | } |
---|
145 | |
---|
146 | if ( !defined('IN_ADMIN') ) |
---|
147 | {// changing password requires old password |
---|
148 | $query = ' |
---|
149 | SELECT '.$conf['user_fields']['password'].' AS password |
---|
150 | FROM '.USERS_TABLE.' |
---|
151 | WHERE '.$conf['user_fields']['id'].' = \''.$user['id'].'\' |
---|
152 | ;'; |
---|
153 | list($current_password) = mysql_fetch_row(pwg_query($query)); |
---|
154 | |
---|
155 | if ($conf['pass_convert']($_POST['password']) != $current_password) |
---|
156 | { |
---|
157 | $errors[] = l10n('Current password is wrong'); |
---|
158 | } |
---|
159 | } |
---|
160 | } |
---|
161 | |
---|
162 | if (count($errors) == 0) |
---|
163 | { |
---|
164 | include_once (Register_FluxBB_PATH.'include/functions_Register_FluxBB.inc.php'); |
---|
165 | |
---|
166 | $query = ' |
---|
167 | SELECT '.$conf['user_fields']['username'].' AS username |
---|
168 | FROM '.USERS_TABLE.' |
---|
169 | WHERE '.$conf['user_fields']['id'].' = \''.$user['id'].'\' |
---|
170 | ;'; |
---|
171 | list($username) = mysql_fetch_row(pwg_query($query)); |
---|
172 | |
---|
173 | FluxBB_Updateuser($user['id'], $username, $conf['pass_convert']($_POST['use_new_pwd']), $_POST['mail_address']); |
---|
174 | } |
---|
175 | } |
---|
176 | } |
---|
177 | } |
---|
178 | |
---|
179 | ?> |
---|