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