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