Within Formbuilder is the feature that also records the "$_SERVER['REMOTE_ADDR']" and adds this to the message/file/database record of the submitted form.
$_SERVER['REMOTE_ADDR'] contains the IP address of the client who filled out the form and submitted it.
Having that is nice for some backtracking, but then more an engineering thing, average users are not necessarily familiar with tools to do this.
Thus to "please" them..., I added some extra code to the Modules/formbuilder/classes/form.class.php
@ line 2096 in mentioned php script
if ($theFields[$i]->GetAlias() != '')
{
$mod->smarty->assign($theFields[$i]->GetAlias(),$replVal);
$mod->smarty->assign($theFields[$i]->GetAlias().'_obj',$fldobj);
}
}
// mod to fetch geo-ip data (limited to available information in GEOIP.DAT file...
include_once(dirname(__FILE__)."/geoip/geoip.inc");
$handle = geoip_open(dirname(__FILE__)."/geoip/GeoIP.dat", GEOIP_STANDARD);
if ($handle) {
$countrycode=geoip_country_code_by_addr($handle, $_SERVER['REMOTE_ADDR']);
if ($countrycode) {
$result=" (".$countrycode.")";
}
// close database handler
geoip_close($handle);
// end of geo-ip handler
}
// general form details
$mod->smarty->assign('sub_form_name',$this->GetName());
$mod->smarty->assign('sub_date',date('r'));
$mod->smarty->assign('sub_host',$_SERVER['SERVER_NAME']);
$mod->smarty->assign('sub_source_ip',$_SERVER['REMOTE_ADDR'].$result);// generate country information to
$mod->smarty->assign('sub_url',(empty($_SERVER['HTTP_REFERER'])?$mod->Lang('no_referrer_info'):$_SERVER['HTTP_REFERER']));
$mod->smarty->assign('fb_version',$mod->GetVersion());
$mod->smarty->assign('TAB',"\t");
Additionally, I copied the /geoip folder that is part of "Statistics" into Modules/formbuilder/classes/
Result is that now after the IP address in the message there is also a reference to the country.
How useful this is for the CMSMS community, I don't know, but my "client" is certainly happy with it.
Now he immediately knows from what country the message came and if he can provide services to the one who send him the message/form.
(The client is located in Thailand and normally only provides services in that country)
I don't know if this "patch" ever makes it to be part of formbuilder, but since it's a minor thing, it can manually be added after an upgrade.
Just wanted to share it with the community....
SM...
Formbuilder & IP address of the one who submits...
Re: Formbuilder & IP address of the one who submits...
I think it's cool!
Nice job
Nice job
