Ok you could do something like this. You know that normally the http daemon sits on port 80 while the https daemon sits on port 443.
so you could say
if ($SERVER_PORT == 443) {
// then we are encrypted
}// end if
else
// we are not encrypted
There might be a cleaner way, but this way I think gets it done.
Hope this helps.