If you have an Apple laptop with Airport this bash line returns the SSID of the current network:
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -I | awk '/ SSID/ {printf $2}'
With that in mind i made a smart homepage script in php. I run it on my local webserver and use it as my homepage.
Given a list of trusted SSID's it will test internet connection and:
There's other ways I could imagine running this, but it should be pretty easy to modify for diferent behavior.