Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Forum Module /

Discuss the Forum Module.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Problem with GeoIP


Reply


3 Posts   3428 Views

Avatar
Webdoc

Community Member, 333 Posts

7 September 2009 at 4:11am

i cand edit admin profile in admin section and also edit profile in forum section

In admin errori is

ERROR [Warning]: exec() has been disabled for security reasons
IN GET /admin/security/EditForm/field/Members/item/1/edit?ajax=1
Line 285 in /var/www/virtual/leeviland.org/htdocs/sapphire/integration/Geoip.php

Source
======
276:     *
277:     * @param string $address The IP address to get the country of
278:     * @param boolean $codeOnly Returns just the country code
279:     */
280:    static function ip2country($address, $codeOnly = false) {
281:       // Return if in CLI, or you'll get this error: "sh: geoiplookup: command not found"
282:       if(Director::is_cli()) return false;
283:       
284:       $cmd = 'geoiplookup ' . escapeshellarg($address);
* 285:       exec($cmd, $result, $code);
286:
287:       // Note: At time of writing, $result is always zero for this program
288:
289:       if($code == 127) return false;
290:       if($result == false) return false;
291:       

<ul>exec(geoiplookup '88.196.203.66',,)
line 285 of Geoip.php

Geoip::ip2country(88.196.203.66,1)
line 324 of Geoip.php

Geoip::visitor_country()
line 13 of CountryDropdownField.php

CountryDropdownField->__construct(Country,Country)
line 204 of ForumRole.php

ForumRole->updateCMSFields(FieldSet,,,,,,)
line 777 of Object.php

Object->extend(updateCMSFields,FieldSet)
line 1727 of DataObject.php

DataObject->getCMSFields()
line 833 of Member.php

Member->getCMSFields()
line 474 of ComplexTableField.php

ComplexTableField->getCustomFieldsFor(Member)
line 514 of ComplexTableField.php

ComplexTableField->getFieldsFor(Member)
line 769 of ComplexTableField.php

ComplexTableField_ItemRequest->DetailForm()

call_user_func_array(Array,Array)
line 408 of ViewableData.php

ViewableData->XML_val(DetailForm,,1)
line 20 of .cache.var.www.virtual.leeviland.org.htdocs.sapphire.templates.ComplexTableField_popup.ss

include(/var/www/virtual/leeviland.org/htdocs/silverstripe-cache/.cache.var.www.virtual.leeviland.org.htdocs.sapphire.templates.ComplexTableField_popup.ss)
line 354 of SSViewer.php

SSViewer->process(MemberTableField_ItemRequest)
line 773 of ViewableData.php

ViewableData->renderWith(ComplexTableField_popup)
line 730 of ComplexTableField.php

ComplexTableField_ItemRequest->edit(HTTPRequest)
line 129 of RequestHandler.php

RequestHandler->handleRequest(HTTPRequest)
line 143 of RequestHandler.php

RequestHandler->handleRequest(HTTPRequest)
line 143 of RequestHandler.php

RequestHandler->handleRequest(HTTPRequest)
line 143 of RequestHandler.php

RequestHandler->handleRequest(HTTPRequest)
line 122 of Controller.php

Controller->handleRequest(HTTPRequest)
line 277 of Director.php

Director::handleRequest(HTTPRequest,Session)
line 121 of Director.php

Director::direct(/admin/security/EditForm/field/Members/item/1/edit)
line 118 of main.php

</ul>

In http://www.leeviland.org/ForumMemberProfile/edit error is:

[Warning] exec() has been disabled for security reasons
GET /ForumMemberProfile/edit
Line 285 in /var/www/virtual/leeviland.org/htdocs/sapphire/integration/Geoip.php

Source
276     *
277     * @param string $address The IP address to get the country of
278     * @param boolean $codeOnly Returns just the country code
279     */
280    static function ip2country($address, $codeOnly = false) {
281       // Return if in CLI, or you'll get this error: "sh: geoiplookup: command not found"
282       if(Director::is_cli()) return false;
283       
284       $cmd = 'geoiplookup ' . escapeshellarg($address);
285       exec($cmd, $result, $code);
286
287       // Note: At time of writing, $result is always zero for this program
288
289       if($code == 127) return false;
290       if($result == false) return false;
291       
Trace
•exec(geoiplookup '88.196.203.66',,)
Line 285 of Geoip.php
•Geoip::ip2country(88.196.203.66,1)
Line 324 of Geoip.php
•Geoip::visitor_country()
Line 13 of CountryDropdownField.php
•CountryDropdownField->__construct(Country,Riik)
Line 168 of ForumRole.php
•ForumRole->getForumFields()

•call_user_func_array(Array,Array)
Line 525 of Object.php
•Object->__call(getForumFields,Array)

•Member->getForumFields()
Line 471 of ForumMemberProfile.php
•ForumMemberProfile->EditProfileForm()
Line 449 of ForumMemberProfile.php
•ForumMemberProfile->edit(HTTPRequest)
Line 162 of Controller.php
•Controller->handleAction(HTTPRequest)
Line 129 of RequestHandler.php
•RequestHandler->handleRequest(HTTPRequest)
Line 122 of Controller.php
•Controller->handleRequest(HTTPRequest)
Line 277 of Director.php
•Director::handleRequest(HTTPRequest,Session)
Line 121 of Director.php
•Director::direct(/ForumMemberProfile/edit)
Line 118 of main.php

how to fix it

Avatar
Willr

Forum Moderator, 5513 Posts

7 September 2009 at 11:41am

See if this helps - open up that file (sapphire/integration/Geoip.php). Go down to line 285 and change it to

$code = "";
$result = false;
@exec($cmd, $result, $code);

Otherwise you can get round it by just putting a return false; at the top of that function though a nicer fallback that we can get into core like above would be good

Avatar
tutalib

Community Member, 1 Post

17 February 2013 at 4:01pm

Edited: 17/02/2013 4:02pm

good answer
__________
[url=http://www.higgingtonpost.com]tutalib[/url]