PHP 02 Feb 2018 22:02:37

PHP Expand IPv4 to IPv6

Simple function for turning IPv6 and IPv4 into a blob that’s suitable for SQL type binary(16). This maps IPv4 to the IPv6 address space reserved for them.

function ip2binary($ip) {
	$rv = inet_pton($ip);
	if (strlen($rv) == 4) {
		// https://tools.ietf.org/html/rfc2765#section-2.1
		$rv = inet_pton('::ffff:'.$ip);
	}
	return $rv;
}

Stories 12 Oct 2017 21:13:04

De-escalation

My 6th sci-fi flash fiction short story. Written around 2016-11-05 (Google Docs).


Continue Reading »

Stories 12 Oct 2017 21:12:41

The New Order

My 5th sci-fi flash fiction short story. Written around 2016-09-15 (Google Docs).


Continue Reading »

Stories 04 May 2016 16:27:22

365 tomorrows: Sinker

My 4th published piece of sci-fi flash fiction: Sinker.

Continue Reading »

Stories 03 Jan 2016 13:11:49

365 tomorrows: Emergency Power

My 3rd published piece of sci-fi flash fiction: Emergency Power.

Continue Reading »

Next Page »