PmwikiSsl

include_once("scripts/authuser.php");

##  Set URL to http or https,
##  Open Source 2007/09/13pm jtankers/PmWiki 2.2.0-beta63
## Modified by mmckinley 03/2013
function ChangeUrlScheme($urlscheme) {  
  $url = array();
  $query = '';
  reset($_GET);
  while(list($name,$value) = each($_GET)) {
    if (!empty($value)) {
      $url[$name] = $name."=".urlencode($value);
      $query = '?';
    }
  }
  header("Location: ".$urlscheme."://".$_SERVER['HTTP_HOST']
         .$_SERVER['PHP_SELF'].$query.implode("&",$url));
  exit;
}

# check to see if logged in or attempting to login, if so switch to ssl
$SSLActions = array(
                    '1'=>'login', 'edit', 'post', 'postattr', 'attr', 'upload', 'loginadmin');
$SSLActions = array_flip($SSLActions);
if (@$AuthId
    || substr_count($pagename, 'SiteAdmin')
    || $SSLActions[$action]
    ) {
  $ScriptUrl = 'https://www.example.com/pmwiki';
  $PubDirUrl = 'https://www.example.com/pmwiki/pub';
  $UploadUrlFmt = "https:/www.example.com/pmwiki/uploads";
  $UploadDir = "/var/www/pmwiki/uploads";
  if (@$_SERVER['SERVER_PORT'] != '443') ChangeUrlScheme('https');
 } else {
  if (@$_SERVER['SERVER_PORT'] == '443') ChangeUrlScheme('http');
 }
  LinkedIn