CeratorIP Format

Please report bugs and any annoyances here. Kindly include all possible details: steps to reproduce, expected result, actual result, screenshots, ... etc.
Post Reply
SkayyHH
Veteran Member
Posts: 425
Joined: 2015-04-27 21:18

CeratorIP Format

Post by SkayyHH » 2020-12-16 23:26

The AppGini function CreatorIP does not give me the correct IP number format. But like this
2003:c0:ff29:ff00:71ba:3b70:d709:7a70

Database is UTF8. I have also tested other formats.

Does anyone have an idea what the problem is?

Thank you, Kai

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: CeratorIP Format

Post by jsetzer » 2020-12-17 04:38

... 2003:c0:ff29:ff00:71ba:3b70:d709:7a70 ...
That IP looks like a normal IP v6 (https://en.wikipedia.org/wiki/IPv6_address). So I guess the function (parseCode in incCommon.php) still works correctly and there is no problem with the code.

You can check your IP in PHP by yourself:

Code: Select all

$ip = $_SERVER['REMOTE_ADDR'];
If someone is interested:
I have written an article in March 2020 about storing the string representation of IP-addresses, both, IP-v4 and IP-v6, in relational databases:
https://appgini.bizzworxx.de/appgini/da ... databases/
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

SkayyHH
Veteran Member
Posts: 425
Joined: 2015-04-27 21:18

Re: CeratorIP Format

Post by SkayyHH » 2020-12-17 07:25

Hi Jan, thank you for the answer. I have looked at your page.

Is there a way to store the IP number in a numeric format in the database? So that on the page the field is displayed as e.g. 192.168.0.1 ?

Thanks a lot!

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: CeratorIP Format

Post by jsetzer » 2020-12-17 08:10

Is there a way to store the IP number in a numeric format in the database?
Well, of course you can convert each hexadecimal fragment of an IPv6 address into a numeric (integer) value and store 8 (or more) integers in the database, but this will not make any sense for various reasons.

--
Excerpt from wikipedia:
An IPv6 address is represented as eight groups of four hexadecimal digits, each group representing 16 bits (two octets, a group sometimes also called a hextet[6][7]). The groups are separated by colons (:). An example of an IPv6 address is:

Code: Select all

2001:0db8:85a3:0000:0000:8a2e:0370:7334
--
Obviously, 8 (or more) integers, converted from hex (IPv6), can never be stored in 4 bytes (IPv4) without data loss. It is like putting a trillion big elephants into 4 too small dog-houses.
So that on the page the field is displayed as e.g. 192.168.0.1 ?
No, you cannot convert every possible IPv6 addresses into a 4-byte-IPv4 representation without data loss.

The major reason why IPv6 was invented years ago was that IPv4 range is much too small for all publicly addressable devices in the world today. There may be hacks for looking up matching IPv4 addresses within a Local Area Network but this will probably never work for addresses outside a given subnet.

So, we all have to get used to the fact that an IP address no longer looks like it did in the 1990s ;)

IPv6 is a valid IP address representation. If you want to store the IP-address, just store the IP address :!:

PS: There is no place like 127.0.0.1 :D
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

SkayyHH
Veteran Member
Posts: 425
Joined: 2015-04-27 21:18

Re: CeratorIP Format

Post by SkayyHH » 2020-12-17 10:59

Hi Jan,

thank you for the effort to give me such a detailed answer.

I think I'll just leave out the ip in my audit log ;-)

Many greetings, Kai

Post Reply