You'd want to do it as a WordPress plugin, this way you're not fucking around with any core files and it should be upgrade proof (for the most part). Start Here: http://codex.wordpress.org/Writing_a_Plugin
One small thing to take note of though with private plugins is to make sure the name of the plugin is unique enough that it won't collide with another one in the repository. A minor issue though.