Jump to the post that solved this thread.
Solved: 6 Years, 3 Months, 2 Weeks ago How are IPs encoded in Database
#1
Solved: 6 Years, 3 Months, 2 Weeks ago
Hello!
How are IP-Adresses encoded in the Database?

My first idea was that they were splited by dots and every part was converted to hex. Sadly my attempt to change a IP for testing if it works failed.

Then I searched the MyBB-Code (just scanned) and found the my_inet_pton()-Function which returned unreadable results. Is this the function? How to get this values to phpmyadmin?

The $db->escape_binary()-Function seems to have no affect on MySql, has it?

Thanks in advance ...
Thomas131
Reply
#2
Solved: 6 Years, 3 Months, 2 Weeks ago
These are the two ip functions that I can find in /inc/functions.php:

/**
 * Converts a human readable IP address to its packed in_addr representation
 *
 * @param string The IP to convert
 * @return string IP in 32bit or 128bit binary format
 */
function my_inet_pton($ip)


/**
 * Converts a packed internet address to a human readable representation
 *
 * @param string IP in 32bit or 128bit binary format
 * @return string IP in human readable format
 */
function my_inet_ntop($ip)
Regards, Ad Bakker (NL)
Reply
#3
Solved: 6 Years, 3 Months, 2 Weeks ago
@Ad Bakker: Thanks, but I already knew that! The one function produces unreadable results and is already mentioned in my first post and the other one should do the opposit.

[english letter ending],
Thomas131
Reply
#4
Solved: 6 Years, 3 Months, 2 Weeks ago
OK, but when I set "Show Posting IP Addresses" to "all users", the correct IP address is shown at the bottom of posts. So the function my_inet_ntop seems to convert the IP address as stored in the database correctly.
Regards, Ad Bakker (NL)
Reply
#5
Solved: 6 Years, 3 Months, 2 Weeks ago
PHP documentions covers both functions:
http://php.net/inet_pton
http://php.net/inet_ntop
[Image: banner.png]
Reply
#6
Solved: 6 Years, 3 Months, 2 Weeks ago
Thanks for answering and sorry, the my_inet_*()-Functions were the key. My fault was that I tried to Copy&Paste binary Codes between phpMyAdmin, Terminal and another phpMyAdmin.

Thanks again for answering!
Thomas131
Reply
Jump to the post that solved this thread.


Forum Jump:


Users browsing this thread: 1 Guest(s)