Add get_networks() to replace pre-3.9 $sites

Also sets the global $sites for compatibility.

Fixes #1.