News:

Join the Facebook Fan Page.

Main Menu

IP to Country

Started by vbgamer45, March 06, 2012, 12:01:14 PM

Previous topic - Next topic

vbgamer45

Link to the mod

This mod is based on Ip to Country mod. After attaining the proper permission from the mod author it became possible to update the mod for SMF 2.x branch. A huge thanks to SONSiVRi for that.

This mod makes use of the GeoLite data created by MaxMind, available from MaxMind which is released under an OPEN DATA LICENSE.

Installation may take as long as minutes because of IP database (inserting 158,068 rows into database)

This mod basically shows country name of the user with the IP address in posts and profiles.

With this mod membergroups who are able to see the IP address will be able to know the country name of concerned user without using whois.

After installation to show the country names associated with earlier posted messages, please go to
Administration Center >> Forum Maintenance >> Routine -- (Created index number of IP's associated with message) Run this task.


License
* This SMF Modification is subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this SMF modification except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Gryzor

This is very interesting and useful for battling spam and other tasks.

However, I'm worried about the amount of stuff it puts into the db; won't it affect performance?

Joker™

Quote from: Gryzor on March 10, 2012, 03:49:02 AM
However, I'm worried about the amount of stuff it puts into the db; won't it affect performance?
The amount of testing I've done on a test board provide by a team member having some thousand posts and members, showed fine results. Still if you find thing to worry about please notify in this topic.
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Gryzor

Ok, fair enough. I thought that maybe so many more lines would affect performance, but after looking around a bit it seems this is not the case!

makv

I would very much like to use this mod, but am currently getting a warning during install. I am in 2.0.6 and have also tried installing under 2.0.2 compatibility:

(Find)
$messages_request = $smcFunc['db_query']('', '
SELECT
id_msg, icon, subject, poster_time, poster_ip, id_member, modified_time, modified_name, body,
smileys_enabled, poster_name, poster_email, approved,
id_msg_modified < {int:new_from} AS is_read
FROM {db_prefix}messages
WHERE id_msg IN ({array_int:message_list})
ORDER BY id_msg' . (empty($options['view_newest_first']) ? '' : ' DESC'),
array(
'message_list' => $messages,
'new_from' => $topicinfo['new_from'],
)
);


(Replace)
$messages_request = $smcFunc['db_query']('', '
SELECT
m.id_msg, m.icon, m.subject, m.poster_time, m.poster_ip, m.id_member, m.modified_time, m.modified_name, m.body,
m.smileys_enabled, m.poster_name, m.poster_email, m.approved,
m.id_msg_modified < {int:new_from} AS is_read, c.country_abbr, c.country_name
FROM {db_prefix}messages AS m
LEFT JOIN {db_prefix}ip_lookup_countries AS c ON (c.index_number = m.ip_index_number)
WHERE m.id_msg IN ({array_int:message_list})
ORDER BY m.id_msg' . (empty($options['view_newest_first']) ? '' : ' DESC'),
array(
'message_list' => $messages,
'new_from' => $topicinfo['new_from'],
)
);


Thanks in advance for any suggestions.

Joker™

Quote from: makv on January 17, 2014, 08:40:06 AM
I would very much like to use this mod, but am currently getting a warning during install. I am in 2.0.6 and have also tried installing under 2.0.2 compatibility:
Some other mod must have made edits in the same code block. Attach the concerned file over here.
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

makv

Quote from: Joker™ on January 17, 2014, 08:48:36 AM
Quote from: makv on January 17, 2014, 08:40:06 AM
I would very much like to use this mod, but am currently getting a warning during install. I am in 2.0.6 and have also tried installing under 2.0.2 compatibility:
Some other mod must have made edits in the same code block. Attach the concerned file over here.

Thanks for the prompt reply. Here it is.

Joker™

Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

makv

Quote from: Joker™ on January 17, 2014, 09:23:43 AM
Try the attached file

Do you mean install the mod and then overwrite with the attached?

Joker™

Quote from: makv on January 17, 2014, 09:48:22 AM
Quote from: Joker™ on January 17, 2014, 09:23:43 AM
Try the attached file

Do you mean install the mod and then overwrite with the attached?
Yup.

- Install the mod
- Make backup of file you have
- Override the file with the one attached above

Moreover if you face similar kind of issue again, you can parse the mod and make the edits manually too. How to manually install the mods
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

makv

Bit of a bug in the file, I had to change:


FROM {db_prefix}messages
LEFT JOIN {db_prefix}ip_lookup_countries AS c ON (c.index_number = m.ip_index_number)


to


FROM {db_prefix}messages m
LEFT JOIN {db_prefix}ip_lookup_countries AS c ON (c.index_number = m.ip_index_number)


But other than that, seems to have worked. Am running the update process now, so I'll let you know :)

Joker™

Quote from: makv on January 17, 2014, 10:52:59 AM
Bit of a bug in the file, I had to change:


FROM {db_prefix}messages
LEFT JOIN {db_prefix}ip_lookup_countries AS c ON (c.index_number = m.ip_index_number)


to


FROM {db_prefix}messages m
LEFT JOIN {db_prefix}ip_lookup_countries AS c ON (c.index_number = m.ip_index_number)


But other than that, seems to have worked. Am running the update process now, so I'll let you know :)

Ahhh, missed that. It seems like you are also having a bit of fun with mods :).
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

makv

Quote from: Joker™ on January 17, 2014, 11:31:02 AM
Ahhh, missed that. It seems like you are also having a bit of fun with mods :).

A heap of fun, yes.

So ... the mod seems to be OK, but I have notice a lot of errors in the Logs like this:

8: Undefined index: country_name
File: /var/www/smf/Sources/Display.php
Line: 1283

Any clues?

Joker™

Umm just make sure all edits required for the mod are there.
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

makv

Quote from: Joker™ on January 17, 2014, 11:52:47 AM
Umm just make sure all edits required for the mod are there.

Everything seems to be there. As the problem seems to be with Display.php, I'm wondering if it's another small problem in the file you sent me?

makv

Quote from: makv on January 17, 2014, 12:27:19 PM
Quote from: Joker™ on January 17, 2014, 11:52:47 AM
Umm just make sure all edits required for the mod are there.

Everything seems to be there. As the problem seems to be with Display.php, I'm wondering if it's another small problem in the file you sent me?

This is the code which seems to be causing the error message.


$output = array(
'attachment' => loadAttachmentContext($message['id_msg']),
'alternate' => $counter % 2,
'id' => $message['id_msg'],
'href' => $scripturl . '?topic=' . $topic . '.msg' . $message['id_msg'] . '#msg' . $message['id_msg'],
'link' => '<a href="' . $scripturl . '?topic=' . $topic . '.msg' . $message['id_msg'] . '#msg' . $message['id_msg'] . '" rel="nofollow">' . $message['subject'] . '</a>',
'member' => &$memberContext[$message['id_member']],
'icon' => $message['icon'],
'icon_url' => $settings[$context['icon_sources'][$message['icon']]] . '/post/' . $message['icon'] . '.gif',
'subject' => $message['subject'],
'time' => timeformat($message['poster_time']),
'timestamp' => forum_time(true, $message['poster_time']),
'counter' => $counter,
'modified' => array(
'time' => timeformat($message['modified_time']),
'timestamp' => forum_time(true, $message['modified_time']),
'name' => $message['modified_name']
),
'body' => $message['body'],
'ua_os' => $message['ua_os'],
'ua_browser' => $message['ua_browser'],
'ua_os_icon' => $message['ua_os_icon'],
'ua_browser_icon' => $message['ua_browser_icon'],
'new' => empty($message['is_read']),
'approved' => $message['approved'],
'first_new' => isset($context['start_from']) && $context['start_from'] == $counter,
'is_ignored' => !empty($modSettings['enable_buddylist']) && !empty($options['posts_apply_ignore_list']) && in_array($message['id_member'], $context['user']['ignoreusers']),
'can_approve' => !$message['approved'] && $context['can_approve'],
'can_unapprove' => $message['approved'] && $context['can_approve'],
'can_modify' => (!$context['is_locked'] || allowedTo('moderate_board')) && (allowedTo('modify_any') || (allowedTo('modify_replies') && $context['user']['started']) || (allowedTo('modify_own') && $message['id_member'] == $user_info['id'] && (empty($modSettings['edit_disable_time']) || !$message['approved'] || $message['poster_time'] + $modSettings['edit_disable_time'] * 60 > time()))),
'can_remove' => allowedTo('delete_any') || (allowedTo('delete_replies') && $context['user']['started']) || (allowedTo('delete_own') && $message['id_member'] == $user_info['id'] && (empty($modSettings['edit_disable_time']) || $message['poster_time'] + $modSettings['edit_disable_time'] * 60 > time())),
'can_see_ip' => allowedTo('moderate_forum') || ($message['id_member'] == $user_info['id'] && !empty($user_info['id'])),
'country_abbr' => $message['country_abbr'],
'country_name' => $message['country_name'],
);
Quote from: makv on January 17, 2014, 11:39:53 AM
Quote from: Joker™ on January 17, 2014, 11:31:02 AM
Ahhh, missed that. It seems like you are also having a bit of fun with mods :).

So ... the mod seems to be OK, but I have notice a lot of errors in the Logs like this:

8: Undefined index: country_name
File: /var/www/smf/Sources/Display.php
Line: 1283

Any clues?

Line 1283 is the last line in the above code.

makv

Got it, I think. Earlier on in Display.php is this:


SELECT
id_msg, icon, subject, poster_time, poster_ip, id_member, modified_time, modified_name, body,
smileys_enabled, poster_name, poster_email, approved,
id_msg_modified < {int:new_from} AS is_read, c.country_abbr, c.country_name
ua_os, ua_browser, ua_os_icon, ua_browser_icon
FROM {db_prefix}messages m
LEFT JOIN {db_prefix}ip_lookup_countries AS c ON (c.index_number = m.ip_index_number)
WHERE id_msg IN ({array_int:message_list})
ORDER BY id_msg' . (empty($options['view_newest_first']) ? '' : ' DESC'),


I think there is a missing comma after c.country_name

I've made that change in my local file and that has got rid of the error messages in the log.

Joker™

Quote from: makv on January 17, 2014, 01:41:35 PM
Got it, I think. Earlier on in Display.php is this:


SELECT
id_msg, icon, subject, poster_time, poster_ip, id_member, modified_time, modified_name, body,
smileys_enabled, poster_name, poster_email, approved,
id_msg_modified < {int:new_from} AS is_read, c.country_abbr, c.country_name
ua_os, ua_browser, ua_os_icon, ua_browser_icon
FROM {db_prefix}messages m
LEFT JOIN {db_prefix}ip_lookup_countries AS c ON (c.index_number = m.ip_index_number)
WHERE id_msg IN ({array_int:message_list})
ORDER BY id_msg' . (empty($options['view_newest_first']) ? '' : ' DESC'),


I think there is a missing comma after c.country_name

I've made that change in my local file and that has got rid of the error messages in the log.
Great. Nice work :).
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

LiBen

During install I get this error:

Unknown column 'ip_from' in 'field list'
File: /myforum/Packages/temp/ip-to-country-i.php
Regel: 162


The DB used to be on SMF 1.1.21, now using SMF 2.0.11
Do I need te remove the table: prefix_ip_lookup prior to install or an edit to ip-to-country-i.php?

LiBen


Unknown column 'ip_from' in 'field list'
Bestand: /data/sites/web/filippijnenorg/www/Packages/temp/IP_to_Country/ip-to-country-i.php
Regel: 161


Any news after 5 years?

Advertisement: