Update cast.php to use new header parsing, misc tidy‐up

Used some HEREDOC to tidy up embedded HTML. TODO: do all.
Ditched some routines no longer used.
Added a TODO, while this is working it’s not identical to previous version.
Ditch that pointless one‐liner