[5606] | 1 | <?php |
---|
| 2 | |
---|
| 3 | global $user, $lang, $conf, $template, $errors; |
---|
| 4 | |
---|
| 5 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 6 | |
---|
| 7 | if (!defined('REGFLUXBB_PATH')) define('REGFLUXBB_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/'); |
---|
| 8 | |
---|
[6898] | 9 | ini_set('error_reporting', E_ALL); |
---|
| 10 | ini_set('display_errors', true); |
---|
[5606] | 11 | |
---|
| 12 | include_once (PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); |
---|
| 13 | include_once (PHPWG_ROOT_PATH.'/include/constants.php'); |
---|
| 14 | |
---|
| 15 | $my_base_url = get_admin_plugin_menu_link(__FILE__); |
---|
| 16 | load_language('plugin.lang', REGFLUXBB_PATH); |
---|
| 17 | |
---|
| 18 | // +-----------------------------------------------------------------------+ |
---|
| 19 | // | Tabssheet | |
---|
| 20 | // +-----------------------------------------------------------------------+ |
---|
| 21 | if (!isset($_GET['tab'])) |
---|
| 22 | $page['tab'] = 'info'; |
---|
| 23 | else |
---|
| 24 | $page['tab'] = $_GET['tab']; |
---|
| 25 | |
---|
| 26 | $tabsheet = new tabsheet(); |
---|
| 27 | $tabsheet->add('info', |
---|
| 28 | l10n('Tab_Info'), |
---|
| 29 | $my_base_url.'&tab=info'); |
---|
| 30 | $tabsheet->add('manage', |
---|
| 31 | l10n('Tab_Manage'), |
---|
| 32 | $my_base_url.'&tab=manage'); |
---|
| 33 | $tabsheet->add('Migration', |
---|
| 34 | l10n('Tab_Migration'), |
---|
| 35 | $my_base_url.'&tab=Migration'); |
---|
| 36 | $tabsheet->add('Synchro', |
---|
| 37 | l10n('Tab_Synchro'), |
---|
| 38 | $my_base_url.'&tab=Synchro'); |
---|
| 39 | $tabsheet->select($page['tab']); |
---|
| 40 | $tabsheet->assign(); |
---|
| 41 | |
---|
| 42 | |
---|
| 43 | $page['infos'] = array(); |
---|
| 44 | $error = array(); |
---|
| 45 | |
---|
| 46 | // +-----------------------------------------------------------------------+ |
---|
| 47 | // | Getting plugin version | |
---|
| 48 | // +-----------------------------------------------------------------------+ |
---|
| 49 | $plugin = RegFluxBB_Infos(REGFLUXBB_PATH); |
---|
| 50 | $version = $plugin['version'] ; |
---|
| 51 | |
---|
| 52 | // +-----------------------------------------------------------------------+ |
---|
| 53 | // | Functions |
---|
| 54 | // +-----------------------------------------------------------------------+ |
---|
| 55 | function Audit_PWG_FluxBB() |
---|
| 56 | { |
---|
| 57 | global $page, $conf, $errors; |
---|
| 58 | |
---|
| 59 | $conf_Register_FluxBB = isset($conf['Register_FluxBB']) ? explode(";" , $conf['Register_FluxBB']) : array(); |
---|
| 60 | |
---|
| 61 | $page_Register_FluxBB_admin = get_admin_plugin_menu_link(__FILE__); |
---|
| 62 | |
---|
| 63 | |
---|
| 64 | |
---|
| 65 | $msg_error_PWG_Dup = ''; |
---|
| 66 | $msg_error_FluxBB_Dup = ''; |
---|
| 67 | $msg_error_Link_Break = ''; |
---|
| 68 | $msg_error_Link_Bad = ''; |
---|
| 69 | $msg_error_Synchro = ''; |
---|
| 70 | $msg_ok_Synchro = ''; |
---|
| 71 | $msg_error_PWG2FluxBB = ''; |
---|
| 72 | $msg_error_FluxBB2PWG = ''; |
---|
| 73 | |
---|
| 74 | |
---|
| 75 | |
---|
| 76 | $query = " |
---|
| 77 | SELECT COUNT(*) AS nbr_dup, id, username |
---|
| 78 | FROM ".USERS_TABLE." |
---|
| 79 | GROUP BY BINARY username |
---|
| 80 | HAVING COUNT(*) > 1 |
---|
| 81 | ;"; |
---|
| 82 | $result = pwg_query($query); |
---|
| 83 | |
---|
[5635] | 84 | while($row = pwg_db_fetch_assoc($result)) |
---|
[5606] | 85 | $msg_error_PWG_Dup .= '<br>'.l10n('Error_PWG_Dup').$row['nbr_dup'].' x '.stripslashes($row['username']); |
---|
| 86 | |
---|
| 87 | if ($msg_error_PWG_Dup == '') |
---|
| 88 | array_push($page['infos'], l10n('Audit_PWG_Dup').'<br>'.l10n('Audit_OK')); |
---|
| 89 | else |
---|
| 90 | $msg_error_PWG_Dup = l10n('Audit_PWG_Dup').$msg_error_PWG_Dup.'<br>'.l10n('Advise_PWG_Dup'); |
---|
| 91 | |
---|
| 92 | |
---|
| 93 | |
---|
| 94 | $query = " |
---|
| 95 | SELECT COUNT(*) AS nbr_dup, username |
---|
| 96 | FROM ".FluxBB_USERS_TABLE." |
---|
| 97 | GROUP BY BINARY username |
---|
| 98 | HAVING COUNT(*) > 1 |
---|
| 99 | ;"; |
---|
| 100 | $result = pwg_query($query); |
---|
| 101 | |
---|
[5635] | 102 | while($row = pwg_db_fetch_assoc($result)) |
---|
[5606] | 103 | { |
---|
| 104 | $msg_error_FluxBB_Dup .= '<br>'.l10n('Error_FluxBB_Dup').$row['nbr_dup'].' x '.stripslashes($row['username']); |
---|
| 105 | |
---|
| 106 | $subquery = " |
---|
| 107 | SELECT id, username, email |
---|
| 108 | FROM ".FluxBB_USERS_TABLE." |
---|
| 109 | WHERE BINARY username = BINARY '".$row['username']."' |
---|
| 110 | ;"; |
---|
| 111 | $subresult = pwg_query($subquery); |
---|
| 112 | |
---|
[5635] | 113 | while($subrow = pwg_db_fetch_assoc($subresult)) |
---|
[5606] | 114 | { |
---|
| 115 | $msg_error_FluxBB_Dup .= '<br>id:'.$subrow['id'].'='.stripslashes($subrow['username']).' ('.$subrow['email'].')'; |
---|
| 116 | |
---|
[8842] | 117 | $msg_error_FluxBB_Dup .= ' <a href="'; |
---|
[5606] | 118 | |
---|
[8842] | 119 | $msg_error_FluxBB_Dup .= add_url_params($page_Register_FluxBB_admin, array( |
---|
| 120 | 'action' => 'del_user', |
---|
| 121 | 'id' => $subrow['id'], |
---|
| 122 | )); |
---|
[5606] | 123 | |
---|
[8842] | 124 | $msg_error_FluxBB_Dup .= '" title="'.l10n('Del_User').stripslashes($subrow['username']).'"'; |
---|
[5606] | 125 | |
---|
[8842] | 126 | $msg_error_FluxBB_Dup .= $conf_Register_FluxBB[4]=='false' ? ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' '; |
---|
[5606] | 127 | |
---|
[8842] | 128 | $msg_error_FluxBB_Dup .= '><img src="'.REGFLUXBB_PATH.'/admin/template/icon/user_delete.png" alt="'.l10n('Del_User').$subrow['username'].'" /></a>'; |
---|
[5606] | 129 | } |
---|
| 130 | } |
---|
| 131 | |
---|
| 132 | if ($msg_error_FluxBB_Dup == '') |
---|
| 133 | array_push($page['infos'], l10n('Audit_FluxBB_Dup').'<br>'.l10n('Audit_OK')); |
---|
| 134 | else |
---|
| 135 | $msg_error_FluxBB_Dup = l10n('Audit_FluxBB_Dup').$msg_error_FluxBB_Dup.'<br>'.l10n('Advise_FluxBB_Dup'); |
---|
| 136 | |
---|
| 137 | |
---|
| 138 | |
---|
| 139 | $query = " |
---|
| 140 | SELECT pwg.id as pwg_id, bb.id as bb_id, pwg.username as pwg_user, pwg.mail_address as pwg_mail |
---|
| 141 | FROM ".FluxBB_USERS_TABLE." AS bb, ".USERS_TABLE." as pwg |
---|
| 142 | WHERE bb.id NOT in ( |
---|
| 143 | SELECT id_user_FluxBB |
---|
| 144 | FROM ".Register_FluxBB_ID_TABLE." |
---|
| 145 | ) |
---|
| 146 | AND pwg.id NOT in ( |
---|
| 147 | SELECT id_user_pwg |
---|
| 148 | FROM ".Register_FluxBB_ID_TABLE." |
---|
| 149 | ) |
---|
| 150 | AND pwg.username = bb.username |
---|
| 151 | AND pwg.mail_address = bb.email |
---|
| 152 | ;"; |
---|
| 153 | |
---|
| 154 | $result = pwg_query($query); |
---|
| 155 | |
---|
[5635] | 156 | while($row = pwg_db_fetch_assoc($result)) |
---|
[5606] | 157 | { |
---|
| 158 | $msg_error_Link_Break .= '<br>'.l10n('Error_Link_Break').stripslashes($row['pwg_user']).' ('.$row['pwg_mail'].')'; |
---|
| 159 | |
---|
[8842] | 160 | $msg_error_Link_Break .= ' <a href="'; |
---|
[5606] | 161 | |
---|
[8842] | 162 | $msg_error_Link_Break .= add_url_params($page_Register_FluxBB_admin, array( |
---|
| 163 | 'action' => 'new_link', |
---|
| 164 | 'pwg_id' => $row['pwg_id'], |
---|
| 165 | 'bb_id' => $row['bb_id'], |
---|
| 166 | )); |
---|
[5606] | 167 | |
---|
[8842] | 168 | $msg_error_Link_Break .= '" title="'.l10n('New_Link').stripslashes($row['pwg_user']).'"'; |
---|
| 169 | |
---|
| 170 | $msg_error_Link_Break .= $conf_Register_FluxBB[4]=='false' ? ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' '; |
---|
| 171 | |
---|
| 172 | $msg_error_Link_Break .= '><img src="'.REGFLUXBB_PATH.'/admin/template/icon/link_break.png" alt="'.l10n('New_Link').stripslashes($row['pwg_user']).'" /></a>'; |
---|
[5606] | 173 | } |
---|
| 174 | |
---|
| 175 | if ($msg_error_Link_Break == '') |
---|
| 176 | array_push($page['infos'], l10n('Audit_Link_Break').'<br>'.l10n('Audit_OK')); |
---|
| 177 | else |
---|
| 178 | $msg_error_Link_Break = l10n('Audit_Link_Break').$msg_error_Link_Break; |
---|
| 179 | |
---|
| 180 | |
---|
| 181 | |
---|
| 182 | $query = " |
---|
| 183 | SELECT pwg.username as pwg_user, pwg.id as pwg_id, pwg.mail_address as pwg_mail, bb.id as bb_id, bb.username as bb_user, bb.email as bb_mail |
---|
| 184 | FROM ".FluxBB_USERS_TABLE." AS bb |
---|
| 185 | INNER JOIN ".Register_FluxBB_ID_TABLE." AS link ON link.id_user_FluxBB = bb.id |
---|
| 186 | INNER JOIN ".USERS_TABLE." as pwg ON link.id_user_pwg = pwg.id |
---|
| 187 | WHERE pwg.username <> bb.username |
---|
| 188 | ;"; |
---|
| 189 | |
---|
| 190 | $result = pwg_query($query); |
---|
| 191 | |
---|
[5635] | 192 | while($row = pwg_db_fetch_assoc($result)) |
---|
[5606] | 193 | { |
---|
| 194 | $msg_error_Link_Bad .= '<br>'.l10n('Error_Link_Del').stripslashes($row['pwg_user']).' ('.$row['pwg_mail'].')'.' -- '.stripslashes($row['bb_user']).' ('.$row['bb_mail'].')'; |
---|
| 195 | |
---|
[8842] | 196 | $msg_error_Link_Bad .= ' <a href="'; |
---|
[5606] | 197 | |
---|
[8842] | 198 | $msg_error_Link_Bad .= add_url_params($page_Register_FluxBB_admin, array( |
---|
| 199 | 'action' => 'link_del', |
---|
| 200 | 'pwg_id' => $row['pwg_id'], |
---|
| 201 | 'bb_id' => $row['bb_id'], |
---|
| 202 | )); |
---|
[5606] | 203 | |
---|
[8842] | 204 | $msg_error_Link_Bad .= '" title="'.l10n('Link_Del').stripslashes($row['pwg_user']).' -- '.stripslashes($row['bb_user']).'"'; |
---|
[5606] | 205 | |
---|
[8842] | 206 | $msg_error_Link_Bad .= $conf_Register_FluxBB[4]=='false' ? ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' '; |
---|
| 207 | |
---|
| 208 | $msg_error_Link_Bad .= '><img src="'.REGFLUXBB_PATH.'/admin/template/icon/link_delete.png" alt="'.l10n('Link_Del').stripslashes($row['pwg_user']).' -- '.stripslashes($row['bb_user']).'" /></a>'; |
---|
| 209 | |
---|
| 210 | $msg_error_Link_Bad .= ' -- <a href="'; |
---|
| 211 | |
---|
| 212 | $msg_error_Link_Bad .= add_url_params($page_Register_FluxBB_admin, array( |
---|
| 213 | 'action' => 'sync_user', |
---|
| 214 | 'username' => stripslashes($row['pwg_user']), |
---|
| 215 | )); |
---|
| 216 | |
---|
| 217 | $msg_error_Link_Bad .= '" title="'.l10n('Sync_User').stripslashes($row['pwg_user']).' --> '.stripslashes($row['bb_user']).'"'; |
---|
| 218 | |
---|
| 219 | $msg_error_Link_Bad .= $conf_Register_FluxBB[4]=='false' ? ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' '; |
---|
| 220 | |
---|
| 221 | $msg_error_Link_Bad .= '><img src="'.REGFLUXBB_PATH.'/admin/template/icon/arrow_switch.png" alt="'.l10n('Sync_User').stripslashes($row['pwg_user']).' --> '.stripslashes($row['bb_user']).'" /></a>'; |
---|
[5606] | 222 | } |
---|
| 223 | |
---|
| 224 | |
---|
| 225 | $query = " |
---|
| 226 | SELECT COUNT(*) as nbr_dead |
---|
| 227 | FROM ".Register_FluxBB_ID_TABLE." AS Link |
---|
| 228 | WHERE id_user_FluxBB NOT IN ( |
---|
| 229 | SELECT id |
---|
| 230 | FROM ".FluxBB_USERS_TABLE." |
---|
| 231 | ) |
---|
| 232 | OR id_user_pwg NOT IN ( |
---|
| 233 | SELECT id |
---|
| 234 | FROM ".USERS_TABLE." |
---|
| 235 | ) |
---|
| 236 | ;"; |
---|
| 237 | |
---|
[5635] | 238 | $Compteur = pwg_db_fetch_assoc(pwg_query($query)); |
---|
[5606] | 239 | |
---|
| 240 | if (!empty($Compteur) and $Compteur['nbr_dead'] > 0) |
---|
| 241 | { |
---|
| 242 | $msg_error_Link_Bad .= '<br>'.l10n('Error_Link_Dead').$Compteur['nbr_dead']; |
---|
| 243 | |
---|
[8842] | 244 | $msg_error_Link_Bad .= ' <a href="'; |
---|
| 245 | |
---|
| 246 | $msg_error_Link_Bad .= add_url_params($page_Register_FluxBB_admin, array( |
---|
| 247 | 'action' => 'link_dead', |
---|
| 248 | )); |
---|
| 249 | |
---|
| 250 | $msg_error_Link_Bad .= '" title="'.l10n('Link_Dead').$Compteur['nbr_dead'].'"'; |
---|
| 251 | |
---|
| 252 | $msg_error_Link_Bad .= $conf_Register_FluxBB[4]=='false' ? ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' '; |
---|
| 253 | |
---|
| 254 | $msg_error_Link_Bad .= '><img src="'.REGFLUXBB_PATH.'/admin/template/icon/link_delete.png" alt="'.l10n('Link_Dead').$Compteur['nbr_dead'].'" /></a>'; |
---|
[5606] | 255 | } |
---|
| 256 | |
---|
| 257 | $query = " |
---|
| 258 | SELECT COUNT(*) AS nbr_dup, pwg.id AS pwg_id, pwg.username AS pwg_user, bb.username AS bb_user, bb.id AS bb_id |
---|
| 259 | FROM ".FluxBB_USERS_TABLE." AS bb |
---|
| 260 | INNER JOIN ".Register_FluxBB_ID_TABLE." AS link ON link.id_user_FluxBB = bb.id |
---|
| 261 | INNER JOIN ".USERS_TABLE." as pwg ON link.id_user_pwg = pwg.id |
---|
| 262 | GROUP BY link.id_user_pwg, link.id_user_FluxBB |
---|
| 263 | HAVING COUNT(*) > 1 |
---|
| 264 | ;"; |
---|
| 265 | |
---|
| 266 | $result = pwg_query($query); |
---|
| 267 | |
---|
[5635] | 268 | while($row = pwg_db_fetch_assoc($result)) |
---|
[5606] | 269 | { |
---|
| 270 | $msg_error_Link_Bad .= '<br>'.l10n('Error_Link_Dup').$row['nbr_dup'].' = '.stripslashes($row['pwg_user']).' -- '.stripslashes($row['bb_user']).')'; |
---|
| 271 | |
---|
[8842] | 272 | $msg_error_Link_Bad .= ' <a href="'; |
---|
[5606] | 273 | |
---|
[8842] | 274 | $msg_error_Link_Bad .= add_url_params($page_Register_FluxBB_admin, array( |
---|
| 275 | 'action' => 'new_link', |
---|
| 276 | 'pwg_id' => $row['pwg_id'], |
---|
| 277 | 'bb_id' => $row['bb_id'], |
---|
| 278 | )); |
---|
| 279 | |
---|
| 280 | $msg_error_Link_Bad .= '" title="'.l10n('Link_Dup').stripslashes($row['pwg_user']).' -- '.stripslashes($row['bb_user']).'"'; |
---|
| 281 | |
---|
| 282 | $msg_error_Link_Bad .= $conf_Register_FluxBB[4]=='false' ? ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' '; |
---|
| 283 | |
---|
| 284 | $msg_error_Link_Bad .= '><img src="'.REGFLUXBB_PATH.'/admin/template/icon/link_error.png" alt="'.l10n('Link_Dup').stripslashes($row['pwg_user']).' -- '.stripslashes($row['bb_user']).'" /></a>'; |
---|
[5606] | 285 | } |
---|
| 286 | |
---|
| 287 | if ($msg_error_Link_Bad == '') |
---|
| 288 | array_push($page['infos'], l10n('Audit_Link_Bad').'<br>'.l10n('Audit_OK')); |
---|
| 289 | else |
---|
| 290 | $msg_error_Link_Bad = l10n('Audit_Link_Bad').$msg_error_Link_Bad; |
---|
| 291 | |
---|
| 292 | |
---|
| 293 | |
---|
| 294 | $query = " |
---|
| 295 | SELECT pwg.username as username, pwg.password as pwg_pwd, pwg.mail_address as pwg_eml, FluxBB.password as bb_pwd, FluxBB.email as bb_eml |
---|
| 296 | FROM ".FluxBB_USERS_TABLE." AS FluxBB |
---|
| 297 | INNER JOIN ".Register_FluxBB_ID_TABLE." AS link ON link.id_user_FluxBB = FluxBB.id |
---|
| 298 | INNER JOIN ".USERS_TABLE." as pwg ON link.id_user_pwg = pwg.id |
---|
| 299 | AND BINARY pwg.username = BINARY FluxBB.username |
---|
| 300 | ORDER BY LOWER(pwg.username) |
---|
| 301 | ;"; |
---|
| 302 | |
---|
| 303 | $result = pwg_query($query); |
---|
| 304 | |
---|
[5635] | 305 | while($row = pwg_db_fetch_assoc($result)) |
---|
[5606] | 306 | { |
---|
| 307 | if ( ($row['pwg_pwd'] != $row['bb_pwd']) or ($row['pwg_eml'] != $row['bb_eml']) ) |
---|
| 308 | { |
---|
| 309 | $msg_error_Synchro .= '<br>'.l10n('Error_Synchro').stripslashes($row['username']); |
---|
| 310 | |
---|
[8842] | 311 | $msg_error_Synchro .= ' <a href="'; |
---|
| 312 | |
---|
| 313 | $msg_error_Synchro .= add_url_params($page_Register_FluxBB_admin, array( |
---|
| 314 | 'action' => 'sync_user', |
---|
| 315 | 'username' => stripslashes($row['username']), |
---|
| 316 | )); |
---|
| 317 | |
---|
| 318 | $msg_error_Synchro .= '" title="'.l10n('Sync_User').stripslashes($row['username']).'"'; |
---|
| 319 | |
---|
| 320 | $msg_error_Synchro .= $conf_Register_FluxBB[4]=='false' ? ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' '; |
---|
| 321 | |
---|
| 322 | $msg_error_Synchro .= '><img src="'.REGFLUXBB_PATH.'/admin/template/icon/user_refresh.png" alt="'.l10n('Sync_User').stripslashes($row['username']).'" /></a>'; |
---|
| 323 | |
---|
[5606] | 324 | if ($row['pwg_pwd'] != $row['bb_pwd']) |
---|
| 325 | $msg_error_Synchro .= '<br>'.l10n('Error_Synchro_Pswd'); |
---|
[8842] | 326 | |
---|
[5606] | 327 | if ($row['pwg_eml'] != $row['bb_eml']) |
---|
| 328 | $msg_error_Synchro .= '<br>'.l10n('Error_Synchro_Mail').'<br>-- PWG = '.$row['pwg_eml'].'<br>-- FluxBB = '.$row['bb_eml']; |
---|
| 329 | } |
---|
| 330 | else if ($conf_Register_FluxBB[5] == 'true') |
---|
| 331 | $msg_ok_Synchro .= '<br> - '.stripslashes($row['username']).' ('.$row['pwg_eml'].')'.l10n('Audit_Synchro_OK'); |
---|
| 332 | } |
---|
| 333 | |
---|
| 334 | if ($msg_error_Synchro <> '') |
---|
| 335 | $msg_error_Synchro = l10n('Audit_Synchro').$msg_error_Synchro; |
---|
| 336 | |
---|
| 337 | if ($msg_ok_Synchro <> '') |
---|
| 338 | if ($msg_error_Synchro <> '') |
---|
| 339 | array_push($page['infos'], l10n('Audit_Synchro').$msg_ok_Synchro.'<br><br>'); |
---|
| 340 | else |
---|
| 341 | array_push($page['infos'], l10n('Audit_Synchro').$msg_ok_Synchro.'<br><br>'.l10n('Audit_OK')); |
---|
| 342 | |
---|
| 343 | |
---|
| 344 | $query = " |
---|
| 345 | SELECT username, mail_address FROM ".USERS_TABLE." |
---|
| 346 | WHERE BINARY username <> BINARY 'guest' |
---|
| 347 | AND id not in ( |
---|
| 348 | SELECT id_user_pwg FROM ".Register_FluxBB_ID_TABLE." |
---|
| 349 | ) |
---|
| 350 | AND BINARY username not in ( |
---|
| 351 | SELECT username FROM ".FluxBB_USERS_TABLE." |
---|
| 352 | ) |
---|
| 353 | ORDER BY LOWER(username) |
---|
| 354 | ;"; |
---|
| 355 | |
---|
| 356 | $result = pwg_query($query); |
---|
| 357 | |
---|
[5635] | 358 | while($row = pwg_db_fetch_assoc($result)) |
---|
[5606] | 359 | { |
---|
| 360 | $msg_error_PWG2FluxBB .= '<br>'.l10n('Error_PWG2FluxBB').stripslashes($row['username']).' ('.$row['mail_address'].')'; |
---|
| 361 | |
---|
[8842] | 362 | $msg_error_PWG2FluxBB .= ' <a href="'; |
---|
[5606] | 363 | |
---|
[8842] | 364 | $msg_error_PWG2FluxBB .= add_url_params($page_Register_FluxBB_admin, array( |
---|
| 365 | 'action' => 'add_user', |
---|
| 366 | 'username' => stripslashes($row['username']), |
---|
| 367 | )); |
---|
[5606] | 368 | |
---|
[8842] | 369 | $msg_error_PWG2FluxBB .= '" title="'.l10n('Add_User').stripslashes($row['username']).'" '; |
---|
| 370 | |
---|
| 371 | $msg_error_PWG2FluxBB .= $conf_Register_FluxBB[4]=='false' ? ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' '; |
---|
| 372 | |
---|
| 373 | $msg_error_PWG2FluxBB .= '><img src="'.REGFLUXBB_PATH.'/admin/template/icon/user_add.png" alt="'.l10n('Add_User').stripslashes($row['username']).'" /></a>'; |
---|
[5606] | 374 | } |
---|
| 375 | |
---|
| 376 | if ($msg_error_PWG2FluxBB == '') |
---|
| 377 | array_push($page['infos'], l10n('Audit_PWG2FluxBB').'<br>'.l10n('Audit_OK')); |
---|
| 378 | else |
---|
| 379 | $msg_error_PWG2FluxBB = l10n('Audit_PWG2FluxBB').$msg_error_PWG2FluxBB; |
---|
| 380 | |
---|
| 381 | |
---|
| 382 | |
---|
| 383 | $query = " |
---|
| 384 | SELECT id, username, email FROM ".FluxBB_USERS_TABLE." |
---|
| 385 | WHERE BINARY username <> BINARY '".$conf_Register_FluxBB[2]."' |
---|
| 386 | AND id not in ( |
---|
| 387 | SELECT id_user_FluxBB FROM ".Register_FluxBB_ID_TABLE." |
---|
| 388 | ) |
---|
| 389 | AND BINARY username not in ( |
---|
| 390 | SELECT username FROM ".USERS_TABLE." |
---|
| 391 | ) |
---|
| 392 | ORDER BY LOWER(username) |
---|
| 393 | ;"; |
---|
| 394 | |
---|
| 395 | $result = pwg_query($query); |
---|
| 396 | |
---|
[5635] | 397 | while($row = pwg_db_fetch_assoc($result)) |
---|
[5606] | 398 | { |
---|
| 399 | $msg_error_FluxBB2PWG .= '<br>'.l10n('Error_FluxBB2PWG').stripslashes($row['username']).' ('.$row['email'].')'; |
---|
| 400 | |
---|
[8842] | 401 | $msg_error_FluxBB2PWG .= ' <a href="'; |
---|
[5606] | 402 | |
---|
[8842] | 403 | $msg_error_FluxBB2PWG .= add_url_params($page_Register_FluxBB_admin, array( |
---|
| 404 | 'action' => 'del_user', |
---|
| 405 | 'id' => $row['id'], |
---|
| 406 | )); |
---|
| 407 | |
---|
| 408 | $msg_error_FluxBB2PWG .= '" title="'.l10n('Del_User').stripslashes($row['username']).'"'; |
---|
| 409 | |
---|
| 410 | $msg_error_FluxBB2PWG .= $conf_Register_FluxBB[4]=='false' ? ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' '; |
---|
| 411 | |
---|
| 412 | $msg_error_FluxBB2PWG .= '><img src="'.REGFLUXBB_PATH.'/admin/template/icon/user_delete.png" alt="'.l10n('Del_User').stripslashes($row['username']).'" /></a>'; |
---|
[5606] | 413 | } |
---|
| 414 | |
---|
| 415 | if ($msg_error_FluxBB2PWG == '') |
---|
| 416 | array_push($page['infos'], l10n('Audit_FluxBB2PWG').'<br>'.l10n('Audit_OK')); |
---|
| 417 | else |
---|
| 418 | $msg_error_FluxBB2PWG = l10n('Audit_FluxBB2PWG').$msg_error_FluxBB2PWG; |
---|
| 419 | |
---|
| 420 | |
---|
| 421 | |
---|
| 422 | if ($msg_error_PWG_Dup <> '') |
---|
| 423 | $errors[] = $msg_error_PWG_Dup . ( ($msg_error_FluxBB_Dup == '' and $msg_error_Link_Break == '' and $msg_error_Link_Bad == '' and $msg_error_Synchro == '' and $msg_error_PWG2FluxBB == '' and $msg_error_FluxBB2PWG == '') ? '' : '<br><br>' ); |
---|
| 424 | |
---|
| 425 | if ($msg_error_FluxBB_Dup <> '') |
---|
| 426 | $errors[] = $msg_error_FluxBB_Dup . ( ($msg_error_Link_Break == '' and $msg_error_Link_Bad == '' and $msg_error_Synchro == '' and $msg_error_PWG2FluxBB == '' and $msg_error_FluxBB2PWG == '') ? '' : '<br><br>' ); |
---|
| 427 | |
---|
| 428 | if ($msg_error_Link_Break <> '') |
---|
| 429 | $errors[] = $msg_error_Link_Break . ( ($msg_error_Link_Bad == '' and $msg_error_Synchro == '' and $msg_error_PWG2FluxBB == '' and $msg_error_FluxBB2PWG == '') ? '' : '<br><br>' ); |
---|
| 430 | |
---|
| 431 | if ($msg_error_Link_Bad <> '') |
---|
| 432 | $errors[] = $msg_error_Link_Bad . ( ($msg_error_Synchro == '' and $msg_error_PWG2FluxBB == '' and $msg_error_FluxBB2PWG == '') ? '' : '<br><br>' ); |
---|
| 433 | |
---|
| 434 | if ($msg_error_Synchro <> '') |
---|
| 435 | $errors[] = $msg_error_Synchro . ( ($msg_error_PWG2FluxBB == '' and $msg_error_FluxBB2PWG == '') ? '' : '<br><br>' ); |
---|
| 436 | |
---|
| 437 | if ($msg_error_PWG2FluxBB <> '') |
---|
| 438 | $errors[] = $msg_error_PWG2FluxBB . ( ($msg_error_FluxBB2PWG == '') ? '' : '<br><br>' ); |
---|
| 439 | |
---|
| 440 | if ($msg_error_FluxBB2PWG <> '') |
---|
| 441 | $errors[] = $msg_error_FluxBB2PWG; |
---|
| 442 | } |
---|
| 443 | |
---|
| 444 | |
---|
| 445 | |
---|
| 446 | |
---|
| 447 | // +-----------------------------------------------------------------------+ |
---|
| 448 | // | Actions process |
---|
| 449 | // +-----------------------------------------------------------------------+ |
---|
| 450 | |
---|
[8842] | 451 | if (isset($_GET['action']) and ($_GET['action']=='link_dead')) |
---|
[5606] | 452 | { |
---|
| 453 | $query = " |
---|
| 454 | DELETE FROM ".Register_FluxBB_ID_TABLE." |
---|
| 455 | WHERE id_user_FluxBB NOT IN ( |
---|
| 456 | SELECT id |
---|
| 457 | FROM ".FluxBB_USERS_TABLE." |
---|
| 458 | ) |
---|
| 459 | OR id_user_pwg NOT IN ( |
---|
| 460 | SELECT id |
---|
| 461 | FROM ".USERS_TABLE." |
---|
| 462 | ) |
---|
| 463 | ;"; |
---|
| 464 | |
---|
| 465 | $result = pwg_query($query); |
---|
| 466 | |
---|
| 467 | Audit_PWG_FluxBB(); |
---|
| 468 | } |
---|
[8842] | 469 | else if (isset($_GET['action']) and ($_GET['action']=='link_del') and isset($_GET['pwg_id']) and isset($_GET['bb_id'])) |
---|
[5606] | 470 | { |
---|
| 471 | $query = " |
---|
| 472 | DELETE FROM ".Register_FluxBB_ID_TABLE." |
---|
| 473 | WHERE id_user_pwg = ".$_GET['pwg_id']." |
---|
| 474 | AND id_user_FluxBB = ".$_GET['bb_id']." |
---|
| 475 | ;"; |
---|
| 476 | |
---|
| 477 | $result = pwg_query($query); |
---|
| 478 | |
---|
| 479 | Audit_PWG_FluxBB(); |
---|
| 480 | } |
---|
[8842] | 481 | else if (isset($_GET['action']) and ($_GET['action']=='new_link') and isset($_GET['pwg_id']) and isset($_GET['bb_id'])) |
---|
[5606] | 482 | { |
---|
| 483 | FluxBB_Linkuser($_GET['pwg_id'], $_GET['bb_id']); |
---|
| 484 | |
---|
| 485 | Audit_PWG_FluxBB(); |
---|
| 486 | } |
---|
[8842] | 487 | else if (isset($_GET['action']) and ($_GET['action']=='sync_user') and isset($_GET['username'])) |
---|
[5606] | 488 | { |
---|
| 489 | $query = " |
---|
| 490 | SELECT id AS id_pwg, username, password, mail_address |
---|
| 491 | FROM ".USERS_TABLE." |
---|
[5635] | 492 | WHERE BINARY username = BINARY '".pwg_db_real_escape_string($_GET['username'])."' |
---|
[5606] | 493 | LIMIT 1 |
---|
| 494 | ;"; |
---|
| 495 | |
---|
[5635] | 496 | $data = pwg_db_fetch_assoc(pwg_query($query)); |
---|
[5606] | 497 | |
---|
| 498 | if (!empty($data)) |
---|
| 499 | { |
---|
| 500 | FluxBB_Updateuser($data['id_pwg'], stripslashes($data['username']), $data['password'], $data['mail_address']); |
---|
| 501 | } |
---|
| 502 | |
---|
| 503 | Audit_PWG_FluxBB(); |
---|
| 504 | } |
---|
[8842] | 505 | else if (isset($_GET['action']) and ($_GET['action']=='add_user') and isset($_GET['username'])) |
---|
[5606] | 506 | { |
---|
| 507 | $query = " |
---|
| 508 | SELECT id, username, password, mail_address |
---|
| 509 | FROM ".USERS_TABLE." |
---|
[5635] | 510 | WHERE BINARY username = BINARY '".pwg_db_real_escape_string($_GET['username'])."' |
---|
[5606] | 511 | LIMIT 1 |
---|
| 512 | ;"; |
---|
| 513 | |
---|
[5635] | 514 | $data = pwg_db_fetch_assoc(pwg_query($query)); |
---|
[5606] | 515 | |
---|
| 516 | if (!empty($data)) |
---|
| 517 | FluxBB_Adduser($data['id'], stripslashes($data['username']), $data['password'], $data['mail_address']); |
---|
| 518 | |
---|
| 519 | Audit_PWG_FluxBB(); |
---|
| 520 | } |
---|
[8842] | 521 | else if (isset($_GET['action']) and ($_GET['action']=='del_user') and isset($_GET['id'])) |
---|
[5606] | 522 | { |
---|
| 523 | FluxBB_Deluser( $_GET['id'], true ); |
---|
| 524 | |
---|
| 525 | Audit_PWG_FluxBB(); |
---|
| 526 | } |
---|
| 527 | |
---|
| 528 | |
---|
| 529 | // +-----------------------------------------------------------------------+ |
---|
| 530 | // | Tabssheet select | |
---|
| 531 | // +-----------------------------------------------------------------------+ |
---|
| 532 | |
---|
| 533 | switch ($page['tab']) |
---|
| 534 | { |
---|
| 535 | case 'info': |
---|
| 536 | |
---|
| 537 | $template->assign( |
---|
| 538 | array( |
---|
| 539 | 'REGFLUXBB_PATH' => REGFLUXBB_PATH, |
---|
| 540 | 'REGFLUXBB_VERSION' => $version, |
---|
| 541 | ) |
---|
| 542 | ); |
---|
| 543 | |
---|
| 544 | $template->set_filename('plugin_admin_content', dirname(__FILE__).'/template/info.tpl'); |
---|
| 545 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
| 546 | |
---|
| 547 | break; |
---|
| 548 | |
---|
| 549 | case 'manage': |
---|
| 550 | |
---|
[8842] | 551 | if (isset($_POST['submit']) and isset($_POST['FluxBB_prefix']) and isset($_POST['FluxBB_admin']) and isset($_POST['FluxBB_guest']) and isset($_POST['FluxBB_del_pt']) and isset($_POST['FluxBB_confirm']) and isset($_POST['FluxBB_details'])) |
---|
[5606] | 552 | { |
---|
| 553 | |
---|
[6898] | 554 | /* Configuration controls */ |
---|
| 555 | // Piwigo's admin username control |
---|
| 556 | $query1 = " |
---|
| 557 | SELECT username, id |
---|
| 558 | FROM ".USERS_TABLE." |
---|
| 559 | WHERE id = ".$conf['webmaster_id']." |
---|
| 560 | ;"; |
---|
| 561 | |
---|
| 562 | $pwgadmin = pwg_db_fetch_assoc(pwg_query($query1)); |
---|
| 563 | |
---|
| 564 | // FluxBB's admin username control |
---|
| 565 | $query2 = " |
---|
| 566 | SELECT username, id |
---|
| 567 | FROM ".FluxBB_USERS_TABLE." |
---|
| 568 | WHERE id = 2 |
---|
| 569 | ;"; |
---|
| 570 | |
---|
| 571 | $fbbadmin = pwg_db_fetch_assoc(pwg_query($query2)); |
---|
| 572 | |
---|
| 573 | // FluxBB's Guest username control |
---|
| 574 | $query3 = " |
---|
| 575 | SELECT username, id |
---|
| 576 | FROM ".FluxBB_USERS_TABLE." |
---|
| 577 | WHERE id = 1 |
---|
| 578 | ;"; |
---|
| 579 | |
---|
| 580 | $fbbguest = pwg_db_fetch_assoc(pwg_query($query3)); |
---|
| 581 | |
---|
| 582 | // Compute configuration errors |
---|
| 583 | if (stripslashes($pwgadmin['username']) != stripslashes($_POST['FluxBB_admin'])) |
---|
| 584 | { |
---|
| 585 | array_push($page['errors'], l10n('error_config_admin1')); |
---|
| 586 | } |
---|
| 587 | if (stripslashes($pwgadmin['username']) != stripslashes($fbbadmin['username'])) |
---|
| 588 | { |
---|
| 589 | array_push($page['errors'], l10n('error_config_admin2')); |
---|
| 590 | } |
---|
| 591 | if (stripslashes($fbbguest['username']) != stripslashes($_POST['FluxBB_guest'])) |
---|
| 592 | { |
---|
| 593 | array_push($page['errors'], l10n('error_config_guest')); |
---|
| 594 | } |
---|
| 595 | elseif (count($page['errors']) == 0) |
---|
| 596 | { |
---|
| 597 | if (!function_exists('FindAvailableConfirmMailID')) |
---|
| 598 | { |
---|
[10977] | 599 | $conf['Register_FluxBB'] = $_POST['FluxBB_prefix'].';'.pwg_db_real_escape_string($_POST['FluxBB_admin']).';'.pwg_db_real_escape_string($_POST['FluxBB_guest']).';'.$_POST['FluxBB_del_pt'].';'.$_POST['FluxBB_confirm'].';'.$_POST['FluxBB_details'].';false;0'; |
---|
[6898] | 600 | } |
---|
| 601 | elseif (function_exists('FindAvailableConfirmMailID')) |
---|
| 602 | { |
---|
| 603 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
| 604 | |
---|
| 605 | if (isset($conf_UAM[1]) and ($conf_UAM[1] == 'true' or $conf_UAM[1] == 'local') and isset($conf_UAM[2]) and $conf_UAM[2] != '-1') |
---|
| 606 | { |
---|
[10977] | 607 | $conf['Register_FluxBB'] = $_POST['FluxBB_prefix'].';'.pwg_db_real_escape_string($_POST['FluxBB_admin']).';'.pwg_db_real_escape_string($_POST['FluxBB_guest']).';'.$_POST['FluxBB_del_pt'].';'.$_POST['FluxBB_confirm'].';'.$_POST['FluxBB_details'].';'.$_POST['FluxBB_UAM'].';'.$_POST['FluxBB_group']; |
---|
[6898] | 608 | } |
---|
| 609 | else |
---|
| 610 | { |
---|
[10977] | 611 | $conf['Register_FluxBB'] = $_POST['FluxBB_prefix'].';'.pwg_db_real_escape_string($_POST['FluxBB_admin']).';'.pwg_db_real_escape_string($_POST['FluxBB_guest']).';'.$_POST['FluxBB_del_pt'].';'.$_POST['FluxBB_confirm'].';'.$_POST['FluxBB_details'].';false;0'; |
---|
[6898] | 612 | } |
---|
| 613 | } |
---|
| 614 | |
---|
[10977] | 615 | conf_update_param('Register_FluxBB', $conf['Register_FluxBB']); |
---|
[6898] | 616 | |
---|
| 617 | array_push($page['infos'], l10n('save_config')); |
---|
| 618 | } |
---|
[5606] | 619 | } |
---|
| 620 | |
---|
| 621 | $conf_Register_FluxBB = isset($conf['Register_FluxBB']) ? explode(";" , $conf['Register_FluxBB']) : array(); |
---|
| 622 | |
---|
[14918] | 623 | // If UAM exists and if UAM ConfirmMail is set, we can set this feature |
---|
| 624 | if (function_exists('FindAvailableConfirmMailID')) |
---|
| 625 | { |
---|
| 626 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
| 627 | |
---|
| 628 | if (isset($conf_UAM[1]) and ($conf_UAM[1] == 'true' or $conf_UAM[1] == 'local') and (isset($conf_UAM[2]) and $conf_UAM[2] <> '-1')) |
---|
| 629 | { |
---|
| 630 | $UAM_bridge = true; |
---|
| 631 | } |
---|
| 632 | else $UAM_bridge = false; |
---|
| 633 | } |
---|
| 634 | |
---|
[5606] | 635 | $template->assign( |
---|
| 636 | array |
---|
| 637 | ( |
---|
| 638 | 'REGFLUXBB_PATH' => REGFLUXBB_PATH, |
---|
| 639 | 'REGFLUXBB_VERSION' => $version, |
---|
| 640 | 'FluxBB_PREFIX' => $conf_Register_FluxBB[0], |
---|
| 641 | 'FluxBB_ADMIN' => stripslashes($conf_Register_FluxBB[1]), |
---|
| 642 | 'FluxBB_GUEST' => stripslashes($conf_Register_FluxBB[2]), |
---|
[6815] | 643 | 'FluxBB_DEL_PT_TRUE' => (isset($conf_Register_FluxBB[3]) and $conf_Register_FluxBB[3] == 'true') ? 'checked="checked"' : '', |
---|
| 644 | 'FluxBB_DEL_PT_FALSE' => (isset($conf_Register_FluxBB[3]) and $conf_Register_FluxBB[3] == 'false') ? 'checked="checked"' : '', |
---|
| 645 | 'FluxBB_CONFIRM_TRUE' => (isset($conf_Register_FluxBB[4]) and $conf_Register_FluxBB[4] == 'true') ? 'checked="checked"' : '', |
---|
| 646 | 'FluxBB_CONFIRM_FALSE' => (isset($conf_Register_FluxBB[4]) and $conf_Register_FluxBB[4] == 'false') ? 'checked="checked"' : '', |
---|
| 647 | 'FluxBB_DETAILS_TRUE' => (isset($conf_Register_FluxBB[5]) and $conf_Register_FluxBB[5] == 'true') ? 'checked="checked"' : '', |
---|
| 648 | 'FluxBB_DETAILS_FALSE' => (isset($conf_Register_FluxBB[5]) and $conf_Register_FluxBB[5] == 'false') ? 'checked="checked"' : '', |
---|
[14918] | 649 | 'UAM_BRIDGE' => $UAM_bridge, |
---|
| 650 | 'FluxBB_UAM_LINK_TRUE' => (isset($conf_Register_FluxBB[6]) and $conf_Register_FluxBB[6] == 'true') ? 'checked="checked"' : '', |
---|
| 651 | 'FluxBB_UAM_LINK_FALSE'=> (isset($conf_Register_FluxBB[6]) and $conf_Register_FluxBB[6] == 'false') ? 'checked="checked"' : '', |
---|
| 652 | 'FluxBB_GROUP' => $conf_Register_FluxBB[7], |
---|
[5606] | 653 | ) |
---|
| 654 | ); |
---|
| 655 | |
---|
| 656 | $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/manage.tpl'); |
---|
| 657 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
| 658 | |
---|
| 659 | break; |
---|
| 660 | |
---|
| 661 | case 'Migration': |
---|
[6898] | 662 | |
---|
| 663 | $conf_Register_FluxBB = isset($conf['Register_FluxBB']) ? explode(";" , $conf['Register_FluxBB']) : array(); |
---|
[5606] | 664 | |
---|
[8842] | 665 | if (isset($_POST['Migration'])) |
---|
[5606] | 666 | { |
---|
| 667 | array_push($page['infos'], l10n('Mig_Start').'<br><br>'); |
---|
| 668 | |
---|
| 669 | array_push($page['infos'], l10n('Mig_Del_Link').'<br><br>'); |
---|
| 670 | |
---|
| 671 | $query = "TRUNCATE ".Register_FluxBB_ID_TABLE.";"; |
---|
| 672 | $result = pwg_query($query); |
---|
| 673 | |
---|
| 674 | |
---|
| 675 | $msg_Mig_Del_AllUsers = ''; |
---|
| 676 | |
---|
| 677 | $query = " |
---|
| 678 | SELECT username, id |
---|
| 679 | FROM ".FluxBB_USERS_TABLE." |
---|
| 680 | ;"; |
---|
| 681 | |
---|
| 682 | $result = pwg_query($query); |
---|
[6898] | 683 | |
---|
[5635] | 684 | while ($row = pwg_db_fetch_assoc($result)) |
---|
[5606] | 685 | { |
---|
| 686 | if((stripslashes($row['username']) != stripslashes($conf_Register_FluxBB[2])) and (stripslashes($row['username']) != stripslashes($conf_Register_FluxBB[1]))) |
---|
| 687 | { |
---|
| 688 | $msg_Mig_Del_AllUsers .= '<br> - '.l10n('Mig_Del_User').stripslashes($row['username']); |
---|
| 689 | |
---|
| 690 | FluxBB_Deluser($row['id'], false); |
---|
| 691 | } |
---|
| 692 | } |
---|
| 693 | |
---|
| 694 | array_push($page['infos'], l10n('Mig_Del_AllUsers').$msg_Mig_Del_AllUsers.'<br><br>'); |
---|
| 695 | |
---|
| 696 | |
---|
| 697 | $query = " |
---|
| 698 | SELECT id, username, password, mail_address |
---|
| 699 | FROM ".USERS_TABLE." |
---|
| 700 | ;"; |
---|
| 701 | |
---|
| 702 | $result = pwg_query($query); |
---|
| 703 | |
---|
| 704 | $registred = time(); |
---|
| 705 | $registred_ip = $_SERVER['REMOTE_ADDR']; |
---|
| 706 | |
---|
| 707 | $msg_Mig_Add_AllUsers = ''; |
---|
| 708 | |
---|
[5635] | 709 | while ($row = pwg_db_fetch_assoc($result)) |
---|
[5606] | 710 | { |
---|
| 711 | if((stripslashes($row['username']) != 'guest') and (stripslashes($row['username']) != stripslashes($conf_Register_FluxBB[1]))) |
---|
| 712 | { |
---|
| 713 | $msg_Mig_Add_AllUsers .= '<br> - '.l10n('Mig_Add_User').stripslashes($row['username']); |
---|
| 714 | |
---|
| 715 | FluxBB_Adduser($row['id'], stripslashes($row['username']), $row['password'], $row['mail_address']); |
---|
| 716 | } |
---|
| 717 | } |
---|
| 718 | |
---|
| 719 | array_push($page['infos'], l10n('Mig_Add_AllUsers').$msg_Mig_Add_AllUsers.'<br><br>'); |
---|
| 720 | |
---|
| 721 | |
---|
| 722 | $query = " |
---|
| 723 | SELECT id, username, password, mail_address |
---|
| 724 | FROM ".USERS_TABLE." |
---|
| 725 | WHERE username = '".$conf_Register_FluxBB[1]."' |
---|
| 726 | ;"; |
---|
| 727 | |
---|
[5635] | 728 | $row = pwg_db_fetch_assoc(pwg_query($query)); |
---|
[5606] | 729 | |
---|
| 730 | if (!empty($row)) |
---|
| 731 | { |
---|
| 732 | array_push($page['infos'], l10n('Sync_User').stripslashes($row['username']).'<br><br>'); |
---|
| 733 | |
---|
| 734 | FluxBB_Updateuser($row['id'], stripslashes($row['username']), $row['password'], $row['mail_address']); |
---|
| 735 | } |
---|
| 736 | |
---|
| 737 | array_push($page['infos'], l10n('Mig_End')); |
---|
| 738 | } |
---|
| 739 | else if ( isset($_POST['Audit'])) |
---|
| 740 | { |
---|
| 741 | Audit_PWG_FluxBB(); |
---|
| 742 | } |
---|
| 743 | |
---|
| 744 | $template->assign( |
---|
| 745 | array |
---|
| 746 | ( |
---|
| 747 | 'REGFLUXBB_PATH' => REGFLUXBB_PATH, |
---|
| 748 | 'REGFLUXBB_VERSION' => $version, |
---|
| 749 | ) |
---|
| 750 | ); |
---|
| 751 | |
---|
| 752 | $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/migration.tpl'); |
---|
| 753 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
| 754 | |
---|
| 755 | break; |
---|
| 756 | |
---|
| 757 | case 'Synchro': |
---|
| 758 | |
---|
[8842] | 759 | if ( isset($_POST['Synchro'])) |
---|
[5606] | 760 | { |
---|
| 761 | global $page,$conf, $errors; |
---|
| 762 | |
---|
| 763 | $conf_Register_FluxBB = isset($conf['Register_FluxBB']) ? explode(";" , $conf['Register_FluxBB']) : array(); |
---|
| 764 | |
---|
| 765 | $page_Register_FluxBB_admin = get_admin_plugin_menu_link(__FILE__); |
---|
| 766 | |
---|
| 767 | |
---|
| 768 | $msg_error_PWG_Dup = ''; |
---|
| 769 | $msg_error_FluxBB_Dup = ''; |
---|
| 770 | $msg_error_Link_Break = ''; |
---|
| 771 | $msg_error_Link_Bad = ''; |
---|
| 772 | $msg_error_Synchro = ''; |
---|
| 773 | $msg_ok_Synchro = ''; |
---|
| 774 | $msg_error_FluxBB2PWG = ''; |
---|
| 775 | $msg_error_PWG2FluxBB = ''; |
---|
| 776 | |
---|
| 777 | |
---|
| 778 | $query = " |
---|
| 779 | SELECT COUNT(*) AS nbr_dup, id, username |
---|
| 780 | FROM ".USERS_TABLE." |
---|
| 781 | GROUP BY BINARY username |
---|
| 782 | HAVING COUNT(*) > 1 |
---|
| 783 | ;"; |
---|
| 784 | |
---|
| 785 | $result = pwg_query($query); |
---|
| 786 | |
---|
[5635] | 787 | while($row = pwg_db_fetch_assoc($result)) |
---|
[5606] | 788 | $msg_error_PWG_Dup .= '<br>'.l10n('Error_PWG_Dup').$row['nbr_dup'].' x '.stripslashes($row['username']); |
---|
| 789 | |
---|
| 790 | if ($msg_error_PWG_Dup <> '') |
---|
| 791 | $msg_error_PWG_Dup = l10n('Audit_PWG_Dup').$msg_error_PWG_Dup.'<br>'.l10n('Advise_PWG_Dup'); |
---|
| 792 | |
---|
| 793 | |
---|
| 794 | $query = " |
---|
| 795 | SELECT COUNT(*) AS nbr_dup, username |
---|
| 796 | FROM ".FluxBB_USERS_TABLE." |
---|
| 797 | GROUP BY BINARY username |
---|
| 798 | HAVING COUNT(*) > 1 |
---|
| 799 | ;"; |
---|
| 800 | |
---|
| 801 | $result = pwg_query($query); |
---|
| 802 | |
---|
[5635] | 803 | while($row = pwg_db_fetch_assoc($result)) |
---|
[5606] | 804 | { |
---|
| 805 | $msg_error_FluxBB_Dup .= '<br>'.l10n('Error_FluxBB_Dup').$row['nbr_dup'].' x '.stripslashes($row['username']); |
---|
| 806 | |
---|
| 807 | $subquery = " |
---|
| 808 | SELECT id, username, email |
---|
| 809 | FROM ".FluxBB_USERS_TABLE." |
---|
| 810 | WHERE BINARY username = BINARY '".$row['username']."' |
---|
| 811 | ;"; |
---|
| 812 | |
---|
| 813 | $subresult = pwg_query($subquery); |
---|
| 814 | |
---|
[5635] | 815 | while($subrow = pwg_db_fetch_assoc($subresult)) |
---|
[5606] | 816 | { |
---|
| 817 | $msg_error_FluxBB_Dup .= '<br>id:'.$subrow['id'].'='.stripslashes($subrow['username']).' ('.$subrow['email'].')'; |
---|
| 818 | |
---|
[8842] | 819 | $msg_error_FluxBB_Dup .= ' <a href="'; |
---|
[5606] | 820 | |
---|
[8842] | 821 | $msg_error_FluxBB_Dup .= add_url_params($page_Register_FluxBB_admin, array( |
---|
| 822 | 'action' => 'del_user', |
---|
| 823 | 'id' => $subrow['id'], |
---|
| 824 | )); |
---|
[5606] | 825 | |
---|
[8842] | 826 | $msg_error_FluxBB_Dup .= '" title="'.l10n('Del_User').stripslashes($subrow['username']).'"'; |
---|
[5606] | 827 | |
---|
[8842] | 828 | $msg_error_FluxBB_Dup .= $conf_Register_FluxBB[4]=='false' ? ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' '; |
---|
[5606] | 829 | |
---|
[8842] | 830 | $msg_error_FluxBB_Dup .= '><img src="'.REGFLUXBB_PATH.'/admin/template/icon/user_delete.png" alt="'.l10n('Del_User').stripslashes($subrow['username']).'" /></a>'; |
---|
[5606] | 831 | } |
---|
| 832 | } |
---|
| 833 | |
---|
| 834 | if ($msg_error_FluxBB_Dup <> '') |
---|
| 835 | $msg_error_FluxBB_Dup = l10n('Sync_Check_Dup').$msg_error_FluxBB_Dup.'<br>'.l10n('Advise_FluxBB_Dup'); |
---|
| 836 | |
---|
| 837 | |
---|
| 838 | if ($msg_error_FluxBB_Dup == '' and $msg_error_PWG_Dup == '') |
---|
| 839 | { |
---|
| 840 | $query = " |
---|
| 841 | SELECT pwg.id as pwg_id, bb.id as bb_id, pwg.username as pwg_user, pwg.mail_address as pwg_mail |
---|
| 842 | FROM ".FluxBB_USERS_TABLE." AS bb, ".USERS_TABLE." as pwg |
---|
| 843 | WHERE bb.id NOT in ( |
---|
| 844 | SELECT id_user_FluxBB |
---|
| 845 | FROM ".Register_FluxBB_ID_TABLE." |
---|
| 846 | ) |
---|
| 847 | AND pwg.id NOT in ( |
---|
| 848 | SELECT id_user_pwg |
---|
| 849 | FROM ".Register_FluxBB_ID_TABLE." |
---|
| 850 | ) |
---|
| 851 | AND pwg.username = bb.username |
---|
| 852 | AND pwg.mail_address = bb.email |
---|
| 853 | ;"; |
---|
| 854 | |
---|
| 855 | $result = pwg_query($query); |
---|
| 856 | |
---|
[5635] | 857 | while($row = pwg_db_fetch_assoc($result)) |
---|
[5606] | 858 | { |
---|
| 859 | $msg_error_Link_Break .= '<br>'.l10n('New_Link').stripslashes($row['pwg_user']).' ('.$row['pwg_mail'].')'; |
---|
| 860 | |
---|
| 861 | FluxBB_Linkuser($row['pwg_id'], $row['bb_id']); |
---|
| 862 | } |
---|
| 863 | |
---|
| 864 | if ($msg_error_Link_Break == '') |
---|
| 865 | array_push($page['infos'], l10n('Sync_Link_Break').'<br>'.l10n('Sync_OK')); |
---|
| 866 | else |
---|
| 867 | $msg_error_Link_Break = l10n('Sync_Link_Break').$msg_error_Link_Break; |
---|
| 868 | |
---|
| 869 | |
---|
| 870 | $query = " |
---|
| 871 | SELECT pwg.username as pwg_user, pwg.id as pwg_id, pwg.mail_address as pwg_mail, bb.id as bb_id, bb.username as bb_user, bb.email as bb_mail |
---|
| 872 | FROM ".FluxBB_USERS_TABLE." AS bb |
---|
| 873 | INNER JOIN ".Register_FluxBB_ID_TABLE." AS link ON link.id_user_FluxBB = bb.id |
---|
| 874 | INNER JOIN ".USERS_TABLE." as pwg ON link.id_user_pwg = pwg.id |
---|
| 875 | WHERE BINARY pwg.username <> BINARY bb.username |
---|
| 876 | ;"; |
---|
| 877 | |
---|
| 878 | $result = pwg_query($query); |
---|
| 879 | |
---|
[5635] | 880 | while($row = pwg_db_fetch_assoc($result)) |
---|
[5606] | 881 | { |
---|
| 882 | $msg_error_Link_Bad .= '<br>'.l10n('Link_Del').stripslashes($row['pwg_user']).' ('.$row['pwg_mail'].')'.' -- '.stripslashes($row['bb_user']).' ('.$row['bb_mail'].')'; |
---|
| 883 | |
---|
| 884 | $subquery = " |
---|
| 885 | DELETE FROM ".Register_FluxBB_ID_TABLE." |
---|
| 886 | WHERE id_user_pwg = ".$row['pwg_id']." |
---|
| 887 | AND id_user_FluxBB = ".$row['bb_id']." |
---|
| 888 | ;"; |
---|
| 889 | |
---|
| 890 | $subresult = pwg_query($subquery); |
---|
| 891 | } |
---|
| 892 | |
---|
| 893 | |
---|
| 894 | $query = " |
---|
| 895 | SELECT COUNT(*) as nbr_dead |
---|
| 896 | FROM ".Register_FluxBB_ID_TABLE." AS Link |
---|
| 897 | WHERE id_user_FluxBB NOT IN ( |
---|
| 898 | SELECT id |
---|
| 899 | FROM ".FluxBB_USERS_TABLE." |
---|
| 900 | ) |
---|
| 901 | OR id_user_pwg NOT IN ( |
---|
| 902 | SELECT id |
---|
| 903 | FROM ".USERS_TABLE." |
---|
| 904 | ) |
---|
| 905 | ;"; |
---|
| 906 | |
---|
[5635] | 907 | $Compteur = pwg_db_fetch_assoc(pwg_query($query)); |
---|
[5606] | 908 | |
---|
| 909 | if ( !empty($Compteur) and $Compteur['nbr_dead'] > 0) |
---|
| 910 | { |
---|
| 911 | $msg_error_Link_Bad .= '<br>'.l10n('Link_Dead').$Compteur['nbr_dead']; |
---|
| 912 | |
---|
| 913 | $query = " |
---|
| 914 | DELETE FROM ".Register_FluxBB_ID_TABLE." |
---|
| 915 | WHERE id_user_FluxBB NOT IN ( |
---|
| 916 | SELECT id |
---|
| 917 | FROM ".FluxBB_USERS_TABLE." |
---|
| 918 | ) |
---|
| 919 | OR id_user_pwg NOT IN ( |
---|
| 920 | SELECT id |
---|
| 921 | FROM ".USERS_TABLE." |
---|
| 922 | ) |
---|
| 923 | ;"; |
---|
| 924 | |
---|
| 925 | $result = pwg_query($query); |
---|
| 926 | } |
---|
| 927 | |
---|
| 928 | |
---|
| 929 | $query = " |
---|
| 930 | SELECT COUNT(*) AS nbr_dup, pwg.id AS pwg_id, pwg.username AS pwg_user, bb.username AS bb_user, bb.id AS bb_id |
---|
| 931 | FROM ".FluxBB_USERS_TABLE." AS bb |
---|
| 932 | INNER JOIN ".Register_FluxBB_ID_TABLE." AS link ON link.id_user_FluxBB = bb.id |
---|
| 933 | INNER JOIN ".USERS_TABLE." as pwg ON link.id_user_pwg = pwg.id |
---|
| 934 | GROUP BY link.id_user_pwg, link.id_user_FluxBB |
---|
| 935 | HAVING COUNT(*) > 1 |
---|
| 936 | ;"; |
---|
| 937 | |
---|
| 938 | $result = pwg_query($query); |
---|
| 939 | |
---|
[5635] | 940 | while($row = pwg_db_fetch_assoc($result)) |
---|
[5606] | 941 | { |
---|
| 942 | $msg_error_Link_Bad .= '<br>'.l10n('Link_Dup').$row['nbr_dup'].' = '.stripslashes($row['pwg_user']).' -- '.stripslashes($row['bb_user']).')'; |
---|
| 943 | |
---|
| 944 | FluxBB_Linkuser($row['pwg_id'], $row['bb_id']); |
---|
| 945 | } |
---|
| 946 | |
---|
| 947 | if ($msg_error_Link_Bad == '') |
---|
| 948 | array_push($page['infos'], l10n('Sync_Link_Bad').'<br>'.l10n('Sync_OK')); |
---|
| 949 | else |
---|
| 950 | $msg_error_Link_Bad = l10n('Sync_Link_Bad').$msg_error_Link_Bad; |
---|
| 951 | |
---|
| 952 | |
---|
| 953 | $query = " |
---|
| 954 | SELECT pwg.id as pwg_id, pwg.username as username, pwg.password as pwg_pwd, pwg.mail_address as pwg_eml, FluxBB.id as bb_id, FluxBB.password as bb_pwd, FluxBB.email as bb_eml |
---|
| 955 | FROM ".FluxBB_USERS_TABLE." AS FluxBB |
---|
| 956 | INNER JOIN ".Register_FluxBB_ID_TABLE." AS link ON link.id_user_FluxBB = FluxBB.id |
---|
| 957 | INNER JOIN ".USERS_TABLE." as pwg ON link.id_user_pwg = pwg.id |
---|
| 958 | AND BINARY pwg.username = BINARY FluxBB.username |
---|
| 959 | ORDER BY LOWER(pwg.username) |
---|
| 960 | ;"; |
---|
| 961 | |
---|
| 962 | $result = pwg_query($query); |
---|
| 963 | |
---|
[5635] | 964 | while($row = pwg_db_fetch_assoc($result)) |
---|
[5606] | 965 | { |
---|
| 966 | if ( ($row['pwg_pwd'] != $row['bb_pwd']) or ($row['pwg_eml'] != $row['bb_eml']) ) |
---|
| 967 | { |
---|
| 968 | $msg_error_Synchro .= '<br>'.l10n('Sync_User').stripslashes($row['username']); |
---|
| 969 | |
---|
| 970 | $query = " |
---|
| 971 | SELECT id, username, password, mail_address |
---|
| 972 | FROM ".USERS_TABLE." |
---|
| 973 | WHERE BINARY id = '".$row['pwg_id']."' |
---|
| 974 | ;"; |
---|
| 975 | |
---|
[5635] | 976 | $data = pwg_db_fetch_assoc(pwg_query($query)); |
---|
[5606] | 977 | |
---|
| 978 | if (!empty($data)) |
---|
| 979 | FluxBB_Updateuser($data['id'], stripslashes($data['username']), $data['password'], $data['mail_address']); |
---|
| 980 | } |
---|
| 981 | } |
---|
| 982 | |
---|
| 983 | if ($msg_error_Synchro == '') |
---|
| 984 | array_push($page['infos'], l10n('Sync_DataUser').'<br>'.l10n('Sync_OK')); |
---|
| 985 | else |
---|
| 986 | $msg_error_Synchro = l10n('Sync_DataUser').$msg_error_Synchro; |
---|
| 987 | |
---|
| 988 | |
---|
| 989 | $query = " |
---|
| 990 | SELECT username, mail_address FROM ".USERS_TABLE." |
---|
| 991 | WHERE BINARY username <> BINARY 'guest' |
---|
| 992 | AND id not in ( |
---|
| 993 | SELECT id_user_pwg FROM ".Register_FluxBB_ID_TABLE." |
---|
| 994 | ) |
---|
| 995 | AND BINARY username not in ( |
---|
| 996 | SELECT username FROM ".FluxBB_USERS_TABLE." |
---|
| 997 | ) |
---|
| 998 | ORDER BY LOWER(username) |
---|
| 999 | ;"; |
---|
| 1000 | |
---|
| 1001 | $result = pwg_query($query); |
---|
| 1002 | |
---|
[5635] | 1003 | while($row = pwg_db_fetch_assoc($result)) |
---|
[5606] | 1004 | { |
---|
| 1005 | $msg_error_PWG2FluxBB .= '<br>'.l10n('Add_User').stripslashes($row['username']).' ('.$row['mail_address'].')'; |
---|
| 1006 | |
---|
| 1007 | $query = " |
---|
| 1008 | SELECT id, username, password, mail_address |
---|
| 1009 | FROM ".USERS_TABLE." |
---|
| 1010 | WHERE BINARY username = BINARY '".$row['username']."' |
---|
| 1011 | LIMIT 1 |
---|
| 1012 | ;"; |
---|
| 1013 | |
---|
[5635] | 1014 | $data = pwg_db_fetch_assoc(pwg_query($query)); |
---|
[5606] | 1015 | |
---|
| 1016 | if (!empty($data)) |
---|
| 1017 | FluxBB_Adduser($data['id'], stripslashes($data['username']), $data['password'], $data['mail_address']); |
---|
| 1018 | } |
---|
| 1019 | |
---|
| 1020 | if ($msg_error_PWG2FluxBB == '') |
---|
| 1021 | array_push($page['infos'], l10n('Sync_PWG2FluxBB').'<br>'.l10n('Sync_OK')); |
---|
| 1022 | else |
---|
| 1023 | $msg_error_PWG2FluxBB = l10n('Sync_PWG2FluxBB').$msg_error_PWG2FluxBB; |
---|
| 1024 | |
---|
| 1025 | |
---|
| 1026 | $query = " |
---|
| 1027 | SELECT id, username, email FROM ".FluxBB_USERS_TABLE." |
---|
| 1028 | WHERE BINARY username <> BINARY '".$conf_Register_FluxBB[2]."' |
---|
| 1029 | AND id not in ( |
---|
| 1030 | SELECT id_user_FluxBB FROM ".Register_FluxBB_ID_TABLE." |
---|
| 1031 | ) |
---|
| 1032 | AND BINARY username not in ( |
---|
| 1033 | SELECT username FROM ".USERS_TABLE." |
---|
| 1034 | ) |
---|
| 1035 | ORDER BY LOWER(username) |
---|
| 1036 | ;"; |
---|
| 1037 | |
---|
| 1038 | $result = pwg_query($query); |
---|
| 1039 | |
---|
[5635] | 1040 | while($row = pwg_db_fetch_assoc($result)) |
---|
[5606] | 1041 | { |
---|
| 1042 | $msg_error_FluxBB2PWG .= '<br>'.l10n('Error_FluxBB2PWG').stripslashes($row['username']).' ('.$row['email'].')'; |
---|
| 1043 | |
---|
[8842] | 1044 | $msg_error_FluxBB2PWG .= ' <a href="'; |
---|
[5606] | 1045 | |
---|
[8842] | 1046 | $msg_error_FluxBB2PWG .= add_url_params($page_Register_FluxBB_admin, array( |
---|
| 1047 | 'action' => 'del_user', |
---|
| 1048 | 'id' => $row['id'], |
---|
| 1049 | )); |
---|
[5606] | 1050 | |
---|
[8842] | 1051 | $msg_error_FluxBB2PWG .= '" title="'.l10n('Del_User').stripslashes($row['username']).'"'; |
---|
[5606] | 1052 | |
---|
[8842] | 1053 | $msg_error_FluxBB2PWG .= $conf_Register_FluxBB[4]=='false' ? ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' '; |
---|
[5606] | 1054 | |
---|
[8842] | 1055 | $msg_error_FluxBB2PWG .= '><img src="'.REGFLUXBB_PATH.'/admin/template/icon/user_delete.png" alt="'.l10n('Del_User').stripslashes($row['username']).'" /></a>'; |
---|
[5606] | 1056 | } |
---|
| 1057 | |
---|
| 1058 | if ($msg_error_FluxBB2PWG == '') |
---|
| 1059 | array_push($page['infos'], l10n('Sync_FluxBB2PWG').'<br>'.l10n('Sync_OK')); |
---|
| 1060 | else |
---|
| 1061 | $msg_error_FluxBB2PWG = l10n('Sync_FluxBB2PWG').$msg_error_FluxBB2PWG; |
---|
| 1062 | } |
---|
| 1063 | else |
---|
| 1064 | $errors[] = l10n('Advise_Check_Dup'); |
---|
| 1065 | |
---|
| 1066 | |
---|
| 1067 | if ($msg_error_PWG_Dup <> '') |
---|
| 1068 | $errors[] = $msg_error_PWG_Dup . ( ($msg_error_FluxBB_Dup == '' and $msg_error_Link_Break == '' and $msg_error_Link_Bad == '' and $msg_error_Synchro == '' and $msg_error_PWG2FluxBB == '' and $msg_error_FluxBB2PWG == '') ? '' : '<br><br>' ); |
---|
| 1069 | |
---|
| 1070 | if ($msg_error_FluxBB_Dup <> '') |
---|
| 1071 | $errors[] = $msg_error_FluxBB_Dup . ( ($msg_error_Link_Break == '' and $msg_error_Link_Bad == '' and $msg_error_Synchro == '' and $msg_error_PWG2FluxBB == '' and $msg_error_FluxBB2PWG == '') ? '' : '<br><br>' ); |
---|
| 1072 | |
---|
| 1073 | if ($msg_error_Link_Break <> '') |
---|
| 1074 | $errors[] = $msg_error_Link_Break . ( ($msg_error_Link_Bad == '' and $msg_error_Synchro == '' and $msg_error_PWG2FluxBB == '' and $msg_error_FluxBB2PWG == '') ? '' : '<br><br>' ); |
---|
| 1075 | |
---|
| 1076 | if ($msg_error_Link_Bad <> '') |
---|
| 1077 | $errors[] = $msg_error_Link_Bad . ( ($msg_error_Synchro == '' and $msg_error_PWG2FluxBB == '' and $msg_error_FluxBB2PWG == '') ? '' : '<br><br>' ); |
---|
| 1078 | |
---|
| 1079 | if ($msg_error_Synchro <> '') |
---|
| 1080 | $errors[] = $msg_error_Synchro . ( ($msg_error_PWG2FluxBB == '' and $msg_error_FluxBB2PWG == '') ? '' : '<br><br>' ); |
---|
| 1081 | |
---|
| 1082 | if ($msg_error_PWG2FluxBB <> '') |
---|
| 1083 | $errors[] = $msg_error_PWG2FluxBB . ( ($msg_error_FluxBB2PWG == '') ? '' : '<br><br>' ); |
---|
| 1084 | |
---|
| 1085 | if ($msg_error_FluxBB2PWG <> '') |
---|
| 1086 | $errors[] = $msg_error_FluxBB2PWG; |
---|
| 1087 | } |
---|
| 1088 | else if ( isset($_POST['Audit'])) |
---|
| 1089 | { |
---|
| 1090 | Audit_PWG_FluxBB(); |
---|
| 1091 | } |
---|
| 1092 | |
---|
| 1093 | $template->assign( |
---|
| 1094 | array |
---|
| 1095 | ( |
---|
| 1096 | 'REGFLUXBB_PATH' => REGFLUXBB_PATH, |
---|
| 1097 | 'REGFLUXBB_VERSION' => $version, |
---|
| 1098 | ) |
---|
| 1099 | ); |
---|
| 1100 | |
---|
| 1101 | $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/synchro.tpl'); |
---|
| 1102 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
| 1103 | |
---|
| 1104 | break; |
---|
| 1105 | } |
---|
| 1106 | ?> |
---|