Sorry I don't know of any script that already exists, but you are right this is a fairly simple script. Personally I think you'd be better off writing it yourself, opposed to modifying someone elses code. And here is why:
1 - modifying someone elses code doesn't give you the same experience as coding it yourself.
2 - writing something from scratch gives you the whole experience from design to debugging, and you will know exactly what your code is doing at every step.
3 - you don't know what level of programmer wrote the script you are modifying, you may be looking at code from a guy who cut his teeth on punch cards and wrote some of the original Unix code, or you could be looking as code that came from someone like you who couldn't find a script to modify so they built one. This can be extreemly frustrating because you need to deal with someone elses logic or lack there of. Noone out there thinks like you do. What's logical to you isn't to someone else and this can lead to lots of frustration.
4 - in my oppinion you will simply learn more and better by doing it yourself.
Here is a simple example. I code all of my PHP pages. What that means is if my page is dynamic it starts with a <?php and ends with a ?> with no HTML code at all. I find it easier to think and code things when I deal with HTML as just the out put of my PHP program and enclose all of my HTML in print() or echo() statements. I've seen many people who code looking at PHP as just another HTML tag and so there pages use the PHP just where they need it. Whenever I use someones code who does this I usually re-write it to fit with my style since I'll have to maintain it and it'll be easier for me this way. If you start learning by using someone elses code you are going to be forcing yourself to use there style instead of figuring out your own.
Besides this message board is very friendly and helpful. I've recieved very good answers to any questions I've ever asked, and I do my best to answer any questions with very detailed answers so that someone can figure out there problem. And I know most of the other people answering questions do the same. I think most of the people here want PHP to grow and know that wont happen unless more people adopt the lanugage and make it a standard.