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 who's 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.
First we get the IP address of the visitor, we explode() it on the dots to get 4 separate numbers, together forming a valid IP address.
Then we set up an URL that will look like this: http://myshoutcastserver.com:8080/admin.cgi?mode=ripip&ip1=127&ip2=0&ip3=0&ip4=1
This URL will submit (GET) a form that adds the IP to the RIP list. See why we had to separate the IP on the dots? 'Why' you ask, well because this is somewhat of a hack. We fill the form through GET parameters.
Of course the admin.cgi page is behind a password protected bit. This is however a simple Basic Authorization, so we create a stream context and add Basic Authorization.
Shoutcast Servers arean't completely dumb, only a little. But they're smart enough to notice 'robots'. So we also add some headers to make it believe we are a real browser and that we would like to accept normal HTML back. We don't really need anything back at all, so that's why you don't have to do anything with the data you get back from file_get_contents.
Just running the command, with the context stream and the pimped out URL is enough to add an IP to the Reserved IP List in Shoutcast. You're done!