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

Home » FUDforum » FUDforum Suggestions » Groups and supergroups
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
Groups and supergroups [message #33910] Tue, 26 September 2006 18:48 Go to next message
otherbird is currently offline  otherbird   Israel
Messages: 25
Registered: September 2006
Karma: 0
Junior Member
Hi Ilia,

Situation: I want to use incoming IP addresses to ascertain membership of a group on the fly, based on CURRENT geographic location. This group would of necessity be a 'supergroup' along the lines of 'All Registered Users' and 'Anonymous' rather than one whose membership is controlled manually.

I'm looking rather gloomily at the huge amount of code to crawl through to figure this one out :\ Is there any chance of FUDforum offering a home-made supergroup with configurable and/or scriptable 'rules' as an option in future releases?

[Updated on: Tue, 26 September 2006 21:11]

Report message to a moderator

Re: Groups and supergroups [message #33927 is a reply to message #33910] Wed, 27 September 2006 23:07 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
There are no plans to add anything like that natively. The forum's group system uses a cache meaning no real-time group work is done. Anytime a query for group information it needed it access the cache table and nothing else.

Adding something like what you suggest would create a significant performance penalty, so I am loathe to add it into the forum.


FUDforum Core Developer
Re: Groups and supergroups [message #33930 is a reply to message #33910] Thu, 28 September 2006 01:09 Go to previous messageGo to next message
otherbird is currently offline  otherbird   Israel
Messages: 25
Registered: September 2006
Karma: 0
Junior Member
Hey Ilia,

I think perhaps we're both looking at this the wrong way - we've been thinking in terms of individual users.

Geo-data's picked up during the log-in, right? - so there'd be no real slowdown in storing country info, IP address and maybe a timestamp from every currently logged-in user whose geo-data happens to match Supergroup III's criteria, at the point of log-in. Effectively, that'd give us an on-the-fly IP whitelist for that forum.

I think I'm going to plod in this direction a little further, it smells quite promising to me!

Wink

PS Third supergroup is practically there now - I just have to reinstate everything I took out when I was debugging the compile issues... which turned out to be unrelated...





Re: Groups and supergroups [message #33946 is a reply to message #33930] Thu, 28 September 2006 13:57 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
Actually not entirely correct, geo-data is stored on registration or profile update (it is not updated on login). It is also stored on a per-message basis and is created when a message is being posted. This means that if you register from country A and post messages from country B, the flags would reflect that.

I suppose one way you could hack it in would be to create 'special' user accounts to the likes of "All Registered/All Anonymous" and store an array of country code <> special user id and then add a wrapper for all group selection code to possibly overwrite the user's own id with this value.


FUDforum Core Developer
Re: Groups and supergroups [message #33950 is a reply to message #33930] Thu, 28 September 2006 15:03 Go to previous messageGo to next message
otherbird is currently offline  otherbird   Israel
Messages: 25
Registered: September 2006
Karma: 0
Junior Member
Sorry, I'm having real trouble finding my way around source files I can only see on the server, I should pull them down to local for messing with I guess. There was a class named something like login which contained a method called something like login, so I leapt to the assumption that this had something to do with the login Confused

I'll go investigate the message setup, since messages themselves are IP aware (something that hadn't sunk in til you said it).

Cheers!
Re: Groups and supergroups [message #33952 is a reply to message #33950] Thu, 28 September 2006 16:41 Go to previous messageGo to next message
otherbird is currently offline  otherbird   Israel
Messages: 25
Registered: September 2006
Karma: 0
Junior Member
Um, actually Ilia, it _does_ check and update the db with country info during user_login(), although it probably shouldn't! (Maybe it doesn't in CVS?) Even if the db update goes from there, I can still call ret_flag(), set a global boolean flag in user_info() if my whitelist criteria applies and check against that flag at the beginning of post.php where needed.

Your msg info is useful too - I can override the geo-ip info in tmpl_drawmsg() when it's wrong (as well as in user_info() in this case). Would you believe one of the 8 users on a 3-day-old site already has that issue? (Yeah, I'm about to tell the geo-ip guys that Beirut is NOT in Canada...!)

So I didn't need my supergroup after all. But it'd be nice to be able to do something like this via the admin interface.
Re: Groups and supergroups [message #33963 is a reply to message #33952] Fri, 29 September 2006 14:30 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
You're right, I've added the flag update to login and complete forgot about it Wink. I actually think that's fine, although perhaps we need an option to allow the admin to disable this bit of functionality.

Here is a patch to this effect:
http://cvs.prohost.org/c/index.cgi/FUDforum/chngview?cn=11616


FUDforum Core Developer
Re: Groups and supergroups [message #33972 is a reply to message #33963] Sat, 30 September 2006 03:50 Go to previous messageGo to next message
otherbird is currently offline  otherbird   Israel
Messages: 25
Registered: September 2006
Karma: 0
Junior Member
OK, I have it automatically adding users to the relevant group at login (the only way I found around it in the end), but for some reason the permissions I set at that point are overridden by 'anonymous' permissions ... any clue why that might be?
Re: Groups and supergroups [message #33973 is a reply to message #33972] Sat, 30 September 2006 05:23 Go to previous messageGo to next message
otherbird is currently offline  otherbird   Israel
Messages: 25
Registered: September 2006
Karma: 0
Junior Member
Ignore me, I've been smoking that funny stuff again.

All's working now Wink although I had to hard-code the group_id to make it so. Everything's towards the end of user_login() in users_reg.inc.t:

($arr is an array of allowed country codes)

        
if ($flag) {
    $flag_start = substr($flag, 9);
    $flag_cc = substr($flag_start, 0, strpos($flag_start, "'"));

    /* assign privileges */
    if (in_array($flag_cc, $arr)) {
        $perms = '378767'; // standard registered user
    } else {
        $perms = '327683'; // standard anonymous user
    }         

    if (!q_singleval('SELECT id FROM {SQL_TABLE_PREFIX}group_members 
                      WHERE group_id=19 AND user_id='.$id)) {
        // insert one if there isn't
        q('INSERT INTO {SQL_TABLE_PREFIX}group_members (group_members_opt, user_id, group_id) 
           VALUES ('.$perms.', '.$id.', 19)');
    } else {
        // update the entry if it exists
        q('UPDATE {SQL_TABLE_PREFIX}group_members 
           SET group_members_opt='.$perms.' 
           WHERE group_id=19 AND user_id='.$id);
    }

} // if flag


GeoIP overrides come a little earlier, just before the 'users' table is updated:

if ($id == 7) $flag = "flag_cc='lb', flag_country='LEBANON',";


- I was going wrong in thinking this would be an array. Hrm hrm. 'Course that override actually _is_ an array in tmpl_drawmsg() (in drawmsg.inc.t):

if (!$hide_controls && $GLOBALS['FUD_OPT_3'] & 524288) {
    $geo = db_saq("SELECT cc,country FROM {SQL_TABLE_PREFIX}geoip 
                   WHERE ".sprintf("%u", ip2long($obj->ip_addr))." 
                   BETWEEN ips AND ipe");
} elseif ($obj->poster_id == 7) {
    $geo = array('lb', 'LEBANON');
} else {
    $geo = null;
}


So, my immediate issues are solved. I still think it could be nice to have some option via the interface for setting scripted on-the-fly permissions in this way though - no?

[Updated on: Sun, 01 October 2006 19:44]

Report message to a moderator

Re: Groups and supergroups [message #33981 is a reply to message #33973] Sat, 30 September 2006 17:23 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
I think on-the-fly permissions are something that is very situation specific requirement and it would be difficult to retrain forum performance while adding a flexible option to manage those. To give an example in your case are you doing based on geo-location, something I've not seen done before Wink which is what your situation demands. Other people may do so based on browser language preference, time of day (yes, there are at least 6 forums that do that), etc...

In those instances it is better to add a custom handler (ideally in a form of an include) to facilitate an upgrade proof solution to real-time permissions handling.


FUDforum Core Developer
Re: Groups and supergroups [message #33992 is a reply to message #33981] Sun, 01 October 2006 04:23 Go to previous messageGo to next message
otherbird is currently offline  otherbird   Israel
Messages: 25
Registered: September 2006
Karma: 0
Junior Member
I'd agree that on-the-fly permissions are situation specific.

However you've just given an upgrade-proof way of working through this and many other scenarios where they're needed.

So find a way to make it easy for us plebs, eh?

Thanks for everything Ilia by the way - and my group are saying much the same, ever since they figured I didn't actually write FUDforum (nah, I told 'em). But that's about 10 people saying 'thanks', anyway, so I guess some code-monkey's going to heaven Wink
Re: Groups and supergroups [message #34016 is a reply to message #33992] Sun, 01 October 2006 19:22 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
Well, again it is impossible to anticipate the kind of solutions when it comes to permissions different applications of FUDforum will require. The solution is largely dependent on the problem.

The basic approach is:

1) Identify the section requiring adjusted permissions
2) Decide what will be the "controller" for customized settings
3) Insert require() statement that loads the real-time permission code.
4) Enjoy the rest of your day Wink


FUDforum Core Developer
Re: Groups and supergroups [message #34021 is a reply to message #34016] Sun, 01 October 2006 19:34 Go to previous messageGo to next message
otherbird is currently offline  otherbird   Israel
Messages: 25
Registered: September 2006
Karma: 0
Junior Member
Gmah hatimah tovah to you too Smile

D'oh, coming back to this forum means I just realized why the message part wasn't working! That'll teach me to code overnight... maybe...

Quote:


if (!$hide_controls && $GLOBALS['FUD_OPT_3'] & 524288) {
    $geo = db_saq("SELECT cc,country FROM {SQL_TABLE_PREFIX}geoip 
                   WHERE ".sprintf("%u", ip2long($obj->ip_addr))." 
                   BETWEEN ips AND ipe");
    } elseif ($obj->poster_id == 7) {
$geo = array('lb', 'LEBANON');
    } else {
$geo = null;
}



should of course read:

$geo = null;

if (!$hide_controls && $GLOBALS['FUD_OPT_3'] & 524288) {
    $geo = db_saq("SELECT cc,country FROM {SQL_TABLE_PREFIX}geoip 
                   WHERE ".sprintf("%u", ip2long($obj->ip_addr))." 
                   BETWEEN ips AND ipe");
}
if ($obj->poster_id == 7) {
    $geo = array('lb', 'LEBANON');
}

[Updated on: Sun, 01 October 2006 19:36]

Report message to a moderator

Re: Groups and supergroups [message #34025 is a reply to message #34021] Sun, 01 October 2006 20:16 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
Gmar hatima tova to you too Wink



FUDforum Core Developer
Re: Groups and supergroups [message #34069 is a reply to message #33910] Tue, 03 October 2006 19:35 Go to previous messageGo to next message
otherbird is currently offline  otherbird   Israel
Messages: 25
Registered: September 2006
Karma: 0
Junior Member
Just a FYI - that geoip call in drawmsg.inc.t doesn't appear to do anything.

Looking through the code there I found a few anomalies (either that or I've badly misunderstood what I'm seeing) - e.g. object properties referenced that don't exist in the 'fud_msg' class.

I ended up fixing the message data in fud_msg_edit::add()in imsg_edt.inc.t, which actually retains _all_ the message info and stores it in the *msg db table. Searching through, I couldn't find anywhere else that does so - despite the name. So it looks like the drawmsg code isn't used (?) despite the fact that it compiles into msg.php.

Horribly confused here... I'll come back and ask support questions in the appropriate forum if this 'fix' fails too!
Re: Groups and supergroups [message #34080 is a reply to message #34069] Wed, 04 October 2006 23:10 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
I presume you are referring a SELECT query that talks to the the database, yeah its a left over that should've been removed.

The flag data actually comes from an object passed to the drawmsg function.


FUDforum Core Developer
Re: Groups and supergroups [message #34082 is a reply to message #34080] Thu, 05 October 2006 00:01 Go to previous messageGo to next message
otherbird is currently offline  otherbird   Israel
Messages: 25
Registered: September 2006
Karma: 0
Junior Member
Yep, so I found. All's working fine in that area now, thanks.

All I have to do now is figure out why _one_ of the users (and only one) gets his session suspended every time he tries to create a new topic! It's the same guy too... this poor kid's in Beirut trying to have a serious discussion and suddenly he's not only in Canada but he's also Mickey Mouse... (this before the flags were fixed obviously)... still, it made for a bit of light relief Wink

Before you say it - the events don't appear to be related. I've two users with flag overrides, the other is a more frequent poster and has had no session issues. I think he probably turned off cookies in his browser but I can't prove it. Ever come across that happening for any other reason?
Re: Groups and supergroups [message #34084 is a reply to message #34082] Thu, 05 October 2006 00:51 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
Is the user going through a filtering proxy perhaps?

FUDforum Core Developer
Re: Groups and supergroups [message #34085 is a reply to message #33910] Thu, 05 October 2006 01:02 Go to previous messageGo to next message
otherbird is currently offline  otherbird   Israel
Messages: 25
Registered: September 2006
Karma: 0
Junior Member
Didn't think of that. I'll see if he knows, tomorrow.

Is there anything I can do about it if he is?
Re: Groups and supergroups [message #34088 is a reply to message #34085] Thu, 05 October 2006 14:37 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
Use another proxy? Or tell his browser not to use a proxy.

FUDforum Core Developer
Re: Groups and supergroups [message #34089 is a reply to message #34088] Thu, 05 October 2006 14:42 Go to previous messageGo to next message
otherbird is currently offline  otherbird   Israel
Messages: 25
Registered: September 2006
Karma: 0
Junior Member
I meant from this end Smile

Evidently not. 'K thanks...
Re: Groups and supergroups [message #34143 is a reply to message #34088] Sun, 08 October 2006 14:12 Go to previous messageGo to next message
otherbird is currently offline  otherbird   Israel
Messages: 25
Registered: September 2006
Karma: 0
Junior Member
Hey Ilia, you'll like this one.

I just managed to reproduce my user's problem - by copy/pasting some text from MS Word and trying to open a forum topic.

Once I removed the Word-specific chars in it, it posted fine. Up until then - session expiry notice, every time.

I realise of course that this is a bug in Word Wink but it'd probably be an idea to patch FUDforum against the specialist quotemarks, apostrophe, and the stupid thing Word puts there when you do '...' at the end of a sentence. (I'll let you know if I find any more 'bad' chars.)

The funny thing is that this only happens when you're opening a topic. You can put any old rubbish into a reply...
Re: Groups and supergroups [message #34148 is a reply to message #34143] Sun, 08 October 2006 17:24 Go to previous messageGo to next message
otherbird is currently offline  otherbird   Israel
Messages: 25
Registered: September 2006
Karma: 0
Junior Member
BTW it occurs to me I've had these issues before (and yes only with those chars).

/* clean up non-standard MS Word shiznit */
$data = preg_replace("'(”|“)'", "\"", $data);
$data = preg_replace("'(’|‘)'", "'", $data);
$data = str_replace("…", "...", $data);

Hopefully it won't get transformed along the way... I've no idea what the entities for these look like, or even if there are any.
Re: Groups and supergroups [message #34161 is a reply to message #34148] Mon, 09 October 2006 14:24 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
Good idea, this should now be addressed in CVS. Here is the patch:
http://cvs.prohost.org/c/index.cgi/FUDforum/chngview?cn=11622


FUDforum Core Developer
Re: Groups and supergroups [message #34165 is a reply to message #34161] Mon, 09 October 2006 14:38 Go to previous messageGo to next message
otherbird is currently offline  otherbird   Israel
Messages: 25
Registered: September 2006
Karma: 0
Junior Member
I've no idea what those 'b 's are, but I'll take your word for it Smile

I'll apply the patch here later and let you know the outcome.

Thanks!
Re: Groups and supergroups [message #34184 is a reply to message #33910] Wed, 11 October 2006 11:54 Go to previous messageGo to next message
otherbird is currently offline  otherbird   Israel
Messages: 25
Registered: September 2006
Karma: 0
Junior Member
Curiouser and curiouser...

I applied patch, no effect. I applied my own fix, no effect. I stole someone else's better fix for MS Word chars from the manual (see ord()), no effect.

On investigation, eliminating the call in post.php.t to check_post_form() fixes the problem. (Huh?)

check_post_form() (in postcheck.inc.t) checks the status of fud_bad_sq along the way. Throwing that define check out, also fixes the problem. (Huh?)

sq_check() is the only place fud_bad_sq is defined. It checks POST['SQ'] against the current 'sq'. If I use MS Word's dodgy characters in a post that opens a topic - and only then - there's nothing in POST['SQ'] when sq_check() is called, and that's how come fud_bad_sq gets defined. (Huh?)

For now I've simply thrown out the fud_bad_sq check in check_post_form() to keep people happy. It seems to work OK most of the time, and throws out a vague error message when it fails (aka 'There was an error'), but it's obviously not optimal.

This is totally bizarre... check_post_form() is the very first call in the submit processing. The only time the message body is even touched prior to reaching here is when it's first picked up in post.php.t, where you put the char fixes earlier. Most of the POST data is obviously intact, so how come POST['SQ'] gets to be empty? and only when bad chars are used, and only in a new forum topic?
Re: Groups and supergroups [message #34187 is a reply to message #34184] Wed, 11 October 2006 14:35 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
Can you attach a word document (zip it up) from which I can copy & paste allowing me to replicate the problem.

FUDforum Core Developer
Re: Groups and supergroups [message #34188 is a reply to message #33910] Wed, 11 October 2006 15:00 Go to previous messageGo to next message
otherbird is currently offline  otherbird   Israel
Messages: 25
Registered: September 2006
Karma: 0
Junior Member
Consider it done...
Re: Groups and supergroups [message #34189 is a reply to message #34188] Wed, 11 October 2006 20:13 Go to previous message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
Ok, I've opened the file in MS Word 2003 and using IE and Firefox on WinXP tried to create new topics or post replies to existing topics.

So, far after about a dozen attempts I have yet to replicate the error you are reporting :/

For you reference I was copying & pasting the entire text in the word file.


FUDforum Core Developer
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: the system for insert image isn't good
Next Topic: Flagging threads with own involvement
Goto Forum:
  

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

Current Time: Wed Nov 27 17:53:13 GMT 2024

Total time taken to generate the page: 0.02864 seconds