[4287] | 1 | <?php |
---|
| 2 | /* |
---|
| 3 | Plugin Name: Register FluxBB |
---|
[6991] | 4 | Version: 2.3.4 |
---|
[4287] | 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 | |
---|
[5606] | 40 | 2.2.0 - 03/04/10 - Piwigo 2.1 compatibility |
---|
| 41 | - Adding css file |
---|
| 42 | - Templates refactory: Moved with css in a "template" subdirectory of admin directory, Moving icons in template directory, using css rules to improve important text display |
---|
| 43 | - functions_Register_FluxBB.inc.php renamed in functions.inc.php |
---|
| 44 | - Language files revision |
---|
| 45 | - Obsolete files management |
---|
| 46 | |
---|
[5638] | 47 | 2.2.1 - 04/04/10 - Bug 1577 fixed : Multiple database support |
---|
| 48 | |
---|
[6294] | 49 | 2.2.2 - 23/05/10 - Bug 1674 fixed : Adding of mods for Fluxbb when users loose their password |
---|
| 50 | - Adding of German language (Thx to duke) |
---|
| 51 | |
---|
[6310] | 52 | 2.2.3 - 23/05/10 - Bug 1674 re-fixed : Bad link fixed |
---|
| 53 | - Re-adding of German language that was missed at last release :-( (Thx to duke) |
---|
[6791] | 54 | |
---|
| 55 | 2.2.4 - 22/08/10 - Bug 1812 fixed : Compliance with FluxBB 1.4 |
---|
[6815] | 56 | |
---|
[6826] | 57 | 2.3.0 - 28/08/10 - Bug 1434 fixed : Bridge between Register_FluxBB and UserAdvManager for new users validation |
---|
| 58 | |
---|
[6880] | 59 | 2.3.1 - 31/08/10 - Bug 1825 fixed : Password corruption after Piwigo's profile page visit |
---|
| 60 | |
---|
[6898] | 61 | 2.3.2 - 11/09/10 - Bug 1847 fixed : Admins and webmasters was not excluded from registration validation |
---|
| 62 | |
---|
| 63 | 2.3.3 - 13/09/10 - Bug 1853 fixed : Add of controls on plugin configuration settings to avoid some mistakes |
---|
| 64 | - Bug 1855 fixed : Improvement of use of UAM bridge (fixes php notices) |
---|
| 65 | - Several language files fix |
---|
[6991] | 66 | |
---|
| 67 | 2.3.4 - 22/09/10 - Compatibility with Plugin Adult_Content |
---|
[4287] | 68 | -------------------------------------------------------------------------------- |
---|
| 69 | */ |
---|
| 70 | |
---|
| 71 | // pour faciliter le debug - make debug easier :o) |
---|
| 72 | //ini_set('error_reporting', E_ALL); |
---|
| 73 | //ini_set('display_errors', true); |
---|
| 74 | |
---|
| 75 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 76 | |
---|
[5606] | 77 | if (!defined('REGFLUXBB_DIR')) define('REGFLUXBB_DIR' , basename(dirname(__FILE__))); |
---|
| 78 | if (!defined('REGFLUXBB_PATH')) define('REGFLUXBB_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/'); |
---|
[4287] | 79 | |
---|
[5606] | 80 | include_once (REGFLUXBB_PATH.'include/constants.php'); |
---|
| 81 | include_once (REGFLUXBB_PATH.'include/functions.inc.php'); |
---|
| 82 | |
---|
| 83 | |
---|
[4287] | 84 | /* plugin administration */ |
---|
| 85 | add_event_handler('get_admin_plugin_menu_links', 'Register_FluxBB_admin_menu'); |
---|
| 86 | |
---|
| 87 | function Register_FluxBB_admin_menu($menu) |
---|
| 88 | { |
---|
| 89 | array_push($menu, array( |
---|
| 90 | 'NAME' => 'Register FluxBB', |
---|
[5606] | 91 | 'URL' => get_admin_plugin_menu_link(REGFLUXBB_PATH.'admin/admin.php'))); |
---|
[4287] | 92 | return $menu; |
---|
| 93 | } |
---|
| 94 | |
---|
| 95 | |
---|
| 96 | /* user creation*/ |
---|
| 97 | add_event_handler('register_user', 'Register_FluxBB_Adduser'); |
---|
| 98 | |
---|
| 99 | function Register_FluxBB_Adduser($register_user) |
---|
| 100 | { |
---|
| 101 | global $conf; |
---|
| 102 | |
---|
[6991] | 103 | // Exclusion of Adult_Content users |
---|
| 104 | if ($register_user['username'] != "16" and $register_user['username'] != "18") |
---|
| 105 | { |
---|
| 106 | include_once (REGFLUXBB_PATH.'include/functions.inc.php'); |
---|
[4287] | 107 | |
---|
[6991] | 108 | // Warning : FluxBB uses Sha1 hash instead of md5 for Piwigo! |
---|
| 109 | FluxBB_Adduser($register_user['id'], $register_user['username'], sha1($_POST['password']), $register_user['email']); |
---|
| 110 | } |
---|
[4287] | 111 | } |
---|
| 112 | |
---|
| 113 | |
---|
| 114 | /* user deletion */ |
---|
| 115 | add_event_handler('delete_user', 'Register_FluxBB_Deluser'); |
---|
| 116 | |
---|
| 117 | function Register_FluxBB_Deluser($user_id) |
---|
| 118 | { |
---|
[5606] | 119 | include_once (REGFLUXBB_PATH.'include/functions.inc.php'); |
---|
[4287] | 120 | |
---|
| 121 | FluxBB_Deluser( FluxBB_Searchuser($user_id), true ); |
---|
| 122 | } |
---|
| 123 | |
---|
| 124 | |
---|
[6826] | 125 | /* Profile management */ |
---|
| 126 | if (script_basename() == 'profile') |
---|
[4287] | 127 | { |
---|
[6826] | 128 | add_event_handler('loc_begin_profile', 'Register_FluxBB_InitPage', EVENT_HANDLER_PRIORITY_NEUTRAL, 2); |
---|
[4287] | 129 | |
---|
[6826] | 130 | function Register_FluxBB_InitPage() |
---|
[4287] | 131 | { |
---|
[6826] | 132 | global $conf, $user; |
---|
| 133 | include_once (REGFLUXBB_PATH.'include/functions.inc.php'); |
---|
| 134 | |
---|
| 135 | if (isset($_POST['validate']) and !is_admin()) |
---|
[4287] | 136 | { |
---|
[6826] | 137 | if (!empty($_POST['use_new_pwd'])) |
---|
[4287] | 138 | { |
---|
[6826] | 139 | $query = ' |
---|
[4287] | 140 | SELECT '.$conf['user_fields']['username'].' AS username |
---|
| 141 | FROM '.USERS_TABLE.' |
---|
| 142 | WHERE '.$conf['user_fields']['id'].' = \''.$user['id'].'\' |
---|
| 143 | ;'; |
---|
| 144 | |
---|
[6826] | 145 | list($username) = pwg_db_fetch_row(pwg_query($query)); |
---|
[4287] | 146 | |
---|
[6826] | 147 | FluxBB_Updateuser($user['id'], stripslashes($username), sha1($_POST['use_new_pwd']), $_POST['mail_address']); |
---|
[4287] | 148 | } |
---|
| 149 | } |
---|
| 150 | } |
---|
| 151 | } |
---|
[6815] | 152 | |
---|
| 153 | |
---|
| 154 | /* Access validation in FluxBB when validated in Piwigo through UAM plugin */ |
---|
[6826] | 155 | add_event_handler('login_success', 'UAM_Bridge', EVENT_HANDLER_PRIORITY_NEUTRAL, 2); |
---|
[6815] | 156 | |
---|
| 157 | function UAM_Bridge() |
---|
| 158 | { |
---|
| 159 | global $conf, $user; |
---|
| 160 | |
---|
| 161 | $conf_Register_FluxBB = isset($conf['Register_FluxBB']) ? explode(";" , $conf['Register_FluxBB']) : array(); |
---|
| 162 | |
---|
| 163 | // Check if UAM is installed and if bridge is set - Exception for admins and webmasters |
---|
[6880] | 164 | $query =' |
---|
| 165 | SELECT user_id, status |
---|
| 166 | FROM '.USER_INFOS_TABLE.' |
---|
| 167 | WHERE user_id = '.$user['id'].' |
---|
| 168 | ;'; |
---|
| 169 | $data = pwg_db_fetch_assoc(pwg_query($query)); |
---|
| 170 | |
---|
| 171 | if ($data['status'] <> "admin" and $data['status'] <> "webmaster") |
---|
[6815] | 172 | { |
---|
[6880] | 173 | if (function_exists('FindAvailableConfirmMailID') and isset($conf_Register_FluxBB[6]) and $conf_Register_FluxBB[6] == 'true') |
---|
| 174 | { |
---|
| 175 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
[6815] | 176 | |
---|
[6880] | 177 | // Getting unvalidated users group else Piwigo's default group |
---|
| 178 | if (isset($conf_UAM[2]) and $conf_UAM[2] != '-1') |
---|
| 179 | { |
---|
| 180 | $Waitingroup = $conf_UAM[2]; |
---|
| 181 | } |
---|
| 182 | else |
---|
| 183 | { |
---|
| 184 | $query = ' |
---|
[6815] | 185 | SELECT id |
---|
| 186 | FROM '.GROUPS_TABLE.' |
---|
| 187 | WHERE is_default = "true" |
---|
| 188 | LIMIT 1 |
---|
| 189 | ;'; |
---|
[6880] | 190 | $data = pwg_db_fetch_assoc(pwg_query($query)); |
---|
| 191 | $Waitingroup = $data['id']; |
---|
| 192 | } |
---|
[6815] | 193 | |
---|
[6880] | 194 | // check if logged in user is in a Piwigo's validated or unvalidated users group |
---|
| 195 | $query = ' |
---|
[6815] | 196 | SELECT * |
---|
| 197 | FROM '.USER_GROUP_TABLE.' |
---|
| 198 | WHERE user_id = '.$user['id'].' |
---|
| 199 | AND group_id = '.$Waitingroup.' |
---|
| 200 | ;'; |
---|
[6880] | 201 | $count = pwg_db_num_rows(pwg_query($query)); |
---|
[6815] | 202 | |
---|
[6880] | 203 | // Check if logged in user is in a FluxBB's unvalidated group |
---|
| 204 | $query = " |
---|
[6815] | 205 | SELECT group_id |
---|
| 206 | FROM ".FluxBB_USERS_TABLE." |
---|
| 207 | WHERE id = ".FluxBB_Searchuser($user['id'])." |
---|
| 208 | ;"; |
---|
| 209 | |
---|
[6880] | 210 | $data = pwg_db_fetch_assoc(pwg_query($query)); |
---|
[6815] | 211 | |
---|
[6880] | 212 | // Logged in user switch to the default FluxBB's group if he'is validated |
---|
| 213 | if ($count == 0 and $data['group_id'] = $conf_Register_FluxBB[7]) |
---|
| 214 | { |
---|
| 215 | $query = " |
---|
[6815] | 216 | SELECT conf_value |
---|
| 217 | FROM ".FluxBB_CONFIG_TABLE." |
---|
| 218 | WHERE conf_name = 'o_default_user_group' |
---|
| 219 | ;"; |
---|
| 220 | |
---|
[6880] | 221 | $o_default_user_group = pwg_db_fetch_assoc(pwg_query($query)); |
---|
[6815] | 222 | |
---|
[6880] | 223 | $query = " |
---|
[6815] | 224 | UPDATE ".FluxBB_USERS_TABLE." |
---|
| 225 | SET group_id = ".$o_default_user_group['conf_value']." |
---|
| 226 | WHERE id = ".FluxBB_Searchuser($user['id'])." |
---|
| 227 | ;"; |
---|
[6880] | 228 | pwg_query($query); |
---|
| 229 | } |
---|
[6815] | 230 | } |
---|
| 231 | } |
---|
| 232 | } |
---|
[4287] | 233 | ?> |
---|