Welcome to the nuBuilder Forums!
Register and log in to access exclusive forums and content available only to registered users.
Register and log in to access exclusive forums and content available only to registered users.
How can I get IP ?
-
- nuBuilder Team
- Posts: 4288
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 442 times
- Contact:
-
- Posts: 156
- Joined: Wed Dec 23, 2020 12:28 pm
- Location: Russia, Volgograd
- Has thanked: 32 times
- Been thanked: 7 times
- Contact:
Re: How can I get IP ?
I tried:
I get this error:
Code: Select all
// form CustomCode
function nuBeforeSave() {
if (nuFORM.edited === true) {
var ip=nuGetIPAddress(); // error below
//var ip='123456'; //--- is OK
$('#gam_ip').val(ip).change();
return true;
}
}
My version.txt file:Uncaught ReferenceError: nuGetIPAddress is not defined
at nuBeforeSave (<anonymous>:18:14)
at nuUpdateData (nuajax.js?ts=20210219130849:664)
at nuSaveAction (nuform.js?ts=20210219130849:3332)
at HTMLInputElement.onclick ((index):1)
Haw can I test real version? May be update is wrong?nuBuilder Forte 4.5
DB Version: V.4.5-2021.01.28.00
Files Version: V.4.5-2021.01.29.01
(V.MajorVersion-CurrentDate.BuildNumber)
Wbr, miasoft.
-
- nuBuilder Team
- Posts: 4288
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 442 times
- Contact:
-
- Posts: 156
- Joined: Wed Dec 23, 2020 12:28 pm
- Location: Russia, Volgograd
- Has thanked: 32 times
- Been thanked: 7 times
- Contact:
Re: How can I get IP ?
1. I added code in BS and now get IP. How can I return(or save) this IP-value in my EditForm?kev1n wrote:This is a PHP function, not JavaScript. Add your check in the BS event.
Code: Select all
$ip=nuGetIPAddress();
nuDebug();
nuSetFormValue('gam_ip', $ip); //don't work
Code: Select all
//my get_ip proc
$ip=nuGetIPAddress();
nuDebug($ip);
$v=" '$ip' ";
$j = " $('#gam_ip').val($v).change(); ";
nuDebug($j);
nuJavascriptCallback($j); // all work
Wbr, miasoft.
-
- nuBuilder Team
- Posts: 4288
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 442 times
- Contact:
Re: How can I get IP ?
In BS (latest 4.5. version), you can add this line:
Code: Select all
nuSetNuDataValue($nudata, '', 'gam_ip', nuGetIPAddress());
Re: How can I get IP ?
Cant you use the PHP function to grab ANY user environment variable?
Such as:
$IpAddress = getenv('REMOTE_ADDR')
Then assign it to your field via:
nuSetNuDataValue($nudata, '', 'cust_IPAddress', $IPAddress);
Could this be used in the Before Save BS or the Before Edit? If used in Before Edit would the form screen display the IP address?
Such as:
$IpAddress = getenv('REMOTE_ADDR')
Then assign it to your field via:
nuSetNuDataValue($nudata, '', 'cust_IPAddress', $IPAddress);
Could this be used in the Before Save BS or the Before Edit? If used in Before Edit would the form screen display the IP address?
Last edited by icoso on Fri Feb 19, 2021 4:18 pm, edited 1 time in total.
-
- Posts: 156
- Joined: Wed Dec 23, 2020 12:28 pm
- Location: Russia, Volgograd
- Has thanked: 32 times
- Been thanked: 7 times
- Contact:
Re: How can I get IP ?
I get error: I search "nuSetNuDataValue" in core-files and SQL-dump - no resultkev1n wrote:In BS (latest 4.5. version), you can add this line:Code: Select all
nuSetNuDataValue($nudata, '', 'gam_ip', nuGetIPAddress());
You do not have the required permissions to view the files attached to this post.
Wbr, miasoft.
Re: How can I get IP ?
You need the latest nudata.php file. I think you can download this from their github site
Look at this post.
https://forums.nubuilder.cloud/viewtopic.php?f=20&t=10823
Kev1n discussed this new function. There are two of them in this new nudata.php file.
function nuGetNuDataValue($nudata, $formId, $field)
function nuSetNuDataValue(&$nudata, $formId, $field, $value)
These allow you to get data from a field and then replace it with something else before it's saved in the BS event code. I would assume this would work in the BE too.
NOTE: Save your original nudata.php file BEFORE overwriting it in case it breaks something else. ie: change current one to nudata-orig1.php before you replace it with the new nudata.php.
Look at this post.
https://forums.nubuilder.cloud/viewtopic.php?f=20&t=10823
Kev1n discussed this new function. There are two of them in this new nudata.php file.
function nuGetNuDataValue($nudata, $formId, $field)
function nuSetNuDataValue(&$nudata, $formId, $field, $value)
These allow you to get data from a field and then replace it with something else before it's saved in the BS event code. I would assume this would work in the BE too.
NOTE: Save your original nudata.php file BEFORE overwriting it in case it breaks something else. ie: change current one to nudata-orig1.php before you replace it with the new nudata.php.