forcessllogin Plugin

Compatible with DokuWiki

  • 2012-01-25 "Angua" yes
  • 2011-05-25 "Rincewind" unknown
  • 2010-11-07 "Anteater" unknown

plugin force ssl on login

Last updated on
2012-02-06
Provides
Action

Tagged with login, ssl

Download and Installation

copy paste this code into your lib/plugins/ondeniedlogin/action.php.

action.php
<?php
if(!defined('DOKU_INC')) die();
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
require_once(DOKU_PLUGIN.'action.php');
 
class action_plugin_forcessllogin extends DokuWiki_Action_Plugin {
 
  function getInfo( ) {
    return array(
        'author' => 'Samuel Fischer',
        'email'  => 'sf@notomorrow.de',
        'date'   => '2012-01-23',
        'name'   => 'forcessllogin',
        'desc'   => 'redirects login requests to ssl',
        'url'    => 'http://www.dokuwiki.org/plugin:forcessllogin',
    );
  }
 
  function register(&$controller) {
    $controller->register_hook('ACTION_ACT_PREPROCESS', 'AFTER',  $this, 'forcessllogin');
    $controller->register_hook('TPL_ACT_RENDER', 'AFTER',  $this, 'forcessllogin');   //catch action change
  }
 
  function forcessllogin(&$event, $param) {
    global $ACT, $INFO, $ID;
    if($ACT != 'login') return;
    if( !is_ssl( )) {
        send_redirect( 'https://'.$this->host( ).wl( $ID ).'?do=login' );
        exit;
    }
  }
 
  function host( ) {
    if(isset($_SERVER['HTTP_HOST'])){
        $parsed_host = parse_url('http://'.$_SERVER['HTTP_HOST']);
        $host = $parsed_host['host'];
    }elseif(isset($_SERVER['SERVER_NAME'])){
        $parsed_host = parse_url('http://'.$_SERVER['SERVER_NAME']);
        $host = $parsed_host['host'];
    }else{
        $host = php_uname('n');
    }
    return $host;
  }
 
}
plugin/forcessllogin.txt · Last modified: 2012/02/06 06:24 by 2001:7f0:3003:b00b:3659:4ff:fe91:5796
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 3.0 Unported
Imprint Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki
WikiForumIRCBugsGitXRefTranslate