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.
Merge pull request #545 from smandon/sma-bugcorrection

SSL detection correction