Hook into node operation from theme template.php?
You want to create a custom module. Note that nothing stops you from creating content types through the user interface, it is in fact the suggested way to do so nowadays with fields and stuff (instead of using hook_node_info())

Node API Hooks contains an overview of all hooks that can be used to interact with nodes at different events like create, view, delete..