Get IP range by CIDR notation
📅
—
🧮 258 words
— 🏷️
tech
php
🔗 Permalink
I wanted to get the IPv4 range of a WHOIS record provided by LACNIC, because unlike other RIRs they don't supply you with the range, but with just a CIDR notation.
To make matters worse, they give 'incomplete' net numbers. The only working "CIDR to IP range" function I could find didn't accept it, so I had to sprinkle some magic.
💬 Read morePerfect separator for Shoutcast 7.html file
📅
—
🧮 173 words
— 🏷️
tech
php
🔗 Permalink
To go along nicely with my previous Shoutcast tip, here is a trick to separate the data in the Shoutcast 7.html for displaying.
If you, like me, use the Shoutcast 7.html trick to get some quick stats about your stream broadcast but are getting some inconsistencies with parsing the comma-separated input you get, try this:
<?php $data = preg_split("/[,]+/", $string, 7); ?>
A possible outcome would be this:
<?php
Array (
[0] => 1
[1] => 1
[2] => 1
[3] => 1000
[4] => 1
[5] => 192
[6] => "Woe, Is Me - Hell, or High Water"
)
?>
If you were to explode()
this string, you'd get the artist in 2 nodes and with this song title you'd get that one in 2 nodes as well.
How to programmatically add an IP address to a Shoutcast Reserved IP list in PHP
📅
—
🧮 353 words
— 🏷️
tech
php
🔗 Permalink
Pretty semantic title, huh? But that's basically what this is all about.
If you have a Shoutcast host that is set to private, only people whose IP address in the RIP list (Reserved IP) can access your stream.
A lot of free Shoutcast server providers do this, to make it a bit less profitable to free ride their services.
Let's have a quick look at the code and then analyze it to understand what it's doing.
💬 Read morearray_push_insert: Push new value into array with PHP
📅
—
🧮 326 words
— 🏷️
tech
php
🔗 Permalink
At work today, my colleague needed to add, or rather 'insert', a value into an existing array AND on a
specific index.
This because we fed it into a JS table sorter, once we pulled it through json_encode()
.
So what we really required: array_push_insert
We couldn't find any existing Array function at php.net, so I decided to make my own version.
💬 Read moreT-Mobile traffic through http://1.2.3.12
📅
—
🧮 524 words
— 🏷️
tech
🔗 Permalink
I'm at a place where there's no internet, so I hooked up my T-Mobile G1 (an HTC Dream) to my laptop through the PdaNet app.
When I was browsing a site, I noticed an image that wasn't working. So I opened it up in a new tab, where it seemed to work again, but I then noticed the URL.
The http:// part of the original source was dropped and replaced by http://1.2.3.12/bmi/
, i.e.:
http://1.2.3.9/bmi/www.gerbenjacobs.nl/wp-content/uploads/2011/01/cute-kitten-laughing-64x64.jpg
Gerben Jacobs is a 36-year-old software engineer from The Netherlands. My interests lie with (web)development, databases, design patterns, social media, communities, APIs and open data.
Check out my project-based site at gerben.dev
I don't have an About page, but I do have a Now page.