SSL detection correction

$protocol always equals 'https' because $_SERVER['HTTPS'] !== 'off' always evaluates to true which causes the shared links to always use https even if the server doesn't use ssl.