Groups and supergroups [message #33910] |
Tue, 26 September 2006 18:48 |
otherbird
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 |
Ilia
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 #33946 is a reply to message #33930] |
Thu, 28 September 2006 13:57 |
Ilia
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 #33973 is a reply to message #33972] |
Sat, 30 September 2006 05:23 |
otherbird
Messages: 25 Registered: September 2006
Karma: 0
|
Junior Member |
|
|
Ignore me, I've been smoking that funny stuff again.
All's working now 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 #34021 is a reply to message #34016] |
Sun, 01 October 2006 19:34 |
otherbird
Messages: 25 Registered: September 2006
Karma: 0
|
Junior Member |
|
|
Gmah hatimah tovah to you too
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 #34080 is a reply to message #34069] |
Wed, 04 October 2006 23:10 |
Ilia
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 #34184 is a reply to message #33910] |
Wed, 11 October 2006 11:54 |
otherbird
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 |
Ilia
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 #34189 is a reply to message #34188] |
Wed, 11 October 2006 20:13 |
Ilia
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
|
|
|