Move livestream event blocks into its own function.

This relates to issue #1.

Now also checks for execution within a SL CMS environment on
cms_index.php