FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum Development » Plugins and Code Hacks » sync up group members with wow roster [Works with 1.7.x]
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
sync up group members with wow roster [Works with 1.7.x] [message #38629] Sun, 19 August 2007 18:37 Go to previous message
Marticus   United States
Messages: 272
Registered: June 2002
Karma:
Senior Member
Please note that there is a new 2.x release of wow roster and I have not tested this tool with it. Please look into my armory version of the tool as the armory is more popular. I do not intend to update this version of the tool.

I have written the following code that will grab a list of members in our roster and dump it into the members group in fudforum. The options are 378639. Please set the options you want for a user, then look in the database for the number and update the code accordingly. Or, you may calculate the permissions and add 65536 to it (it took me a while to figure this out). Also change id 97 to whatever group with which you want to control guild membership access. This will override any existing member with the new options, excluding anyone with higher access.

Update: added UTF-8 support. Forum account must have been created using the alt+#### method for special characters.

The code:
set_time_limit(600);
define('forum_debug', 1);
unset($_SERVER['REMOTE_ADDR']);

require ( '/home/website/.fudforumdata/scripts/GLOBALS.php' );

if (!($FUD_OPT_1 & 1))
    eexit("Forum is currently disabled.\n");

fud_use('forum_adm.inc', true);
fud_use('groups_adm.inc', true);
fud_use('err.inc');
fud_use('db.inc');
fud_use('post_proc.inc');
fud_use('is_perms.inc');
fud_use('users.inc');
fud_use('groups.inc');
fud_use('users_reg.inc');
fud_use('users_adm.inc', true);
fud_use('scripts_common.inc', true);

define('sql_p', $GLOBALS['DBHOST_TBL_PREFIX']);

list($GLOBALS['usr']->lang, $locale) = db_saq("SELECT lang, locale FROM ".sql_p."themes WHERE theme_opt=1|2 LIMIT 1");

$GLOBALS['good_locale'] = setlocale(LC_ALL, $locale);

list($GLOBALS['usr']->lang, $locale) = db_saq("SELECT lang, locale FROM ".sql_p."themes WHERE theme_opt=1|2 LIMIT 1");

$GLOBALS['good_locale'] = setlocale(LC_ALL, $locale);

require_once( 'settings.php' );

$query = 'SELECT `name` from `roster_members` ORDER BY `name`';
$result = $wowdb->query( $query ) or die_quietly($wowdb->error(),'Database Error',basename(__FILE__),__LINE__,$query);
while ( $row = $wowdb->fetch_assoc( $result ) )
{
   $login = xmlEntities(htmlentities(utf8_decode($row['name'])));
   $id = get_id_by_login($login);
   if ( ! empty ( $id ) ) {
      print ( $login . ' - ' . $id . ': ' );
      $r = q('SELECT id,group_members_opt,group_id FROM fud26_group_members WHERE group_id=97 AND user_id='.$id);
      $e = db_rowarr($r);
      if ( ! empty ( $e ) ) {
          print_r ( $e );
          print ( ' ' );
          if ( $e[1] < 378639 ) {
/*             q('UPDATE fud26_group_members SET group_members_opt=378639 WHERE id='.$id); WHY THE HELL DOESN'T This Update the TABLE!!! */
             grp_delete_member(97, $id);
             q('INSERT INTO fud26_group_members (group_members_opt, user_id, group_id) VALUES (378639, '.$id.', 97)'); /* 313103 + 65536 */
             grp_rebuild_cache(array($id));
             print ( "Updating Member!<br>\n" );
          } else {
             print ( "Skipping Member!<br>\n" );
          }
      } else {
         q('INSERT INTO fud26_group_members (group_members_opt, user_id, group_id) VALUES (378639, '.$id.', 97)'); /* 313103 + 65536 */
         grp_rebuild_cache(array($id));
         print ( "Adding Member!<br>\n" );
      }
   }
}

function xmlEntities($s){
    //build first an assoc. array with the entities we want to match
    $table1 = get_html_translation_table(HTML_ENTITIES, ENT_QUOTES);

    //now build another assoc. array with the entities we want to replace (numeric entities)
    foreach ($table1 as $k=>$v){
      $table1[$k] = "/$v/";
      $c = htmlentities($k,ENT_QUOTES,"UTF-8");
      $table2[$c] = "&#".ord($k).";";
    }

    $s = preg_replace($table1,$table2,$s);
    return $s;
}

[Updated on: Thu, 05 February 2009 07:34]

Report message to a moderator

[Message index]
 
Read Message
Read Message
Previous Topic: Anti-Bot Modification for FUDForum
Next Topic: sync up group members with wow roster [Works with armory as of Feb 04, 2009]
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Nov 26 03:04:13 GMT 2024

Total time taken to generate the page: 0.04105 seconds