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 #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 #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 #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
|
|
|