You wouldn't add this script into Ultimate.cgi, you would add Ultimate.cgi into this script.
Just copy and paste all the code from Ultimate.cgi into the place in login.cgi that says Insert HTML here... and then rename login.cgi as Ultimate.cgi and upload it.