well this looks very familiar, since it's my code, LOL
anyway, i should have renamed it something other than index.php, probably login.php so you could go there from somewhere else, you can do that to, simply replace every instance of index.php with login.php, then save index.php as login.php, then create a different index.php that looks exactly the same as template.php (of course you can have different content) and give that a go
just don't navigate to login.php straight from your browser, or do some if's to check to see if they didn't come from somewhere else and if so just redirect them to index.php at that point
i did this quickly for someone, and haven't looked at it since, so there are a lot of things you can do