1<?php 2/** 3 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 4 * @author Tom Foerster <tom.foerster@hs-regensburg.de>, Andreas Gohr <andi@splitbrain.org> 5 */ 6 7// must be run within Dokuwiki 8if(!defined('DOKU_INC')) die(); 9if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 10require_once(DOKU_PLUGIN.'action.php'); 11 12class action_plugin_unameban extends DokuWiki_Action_Plugin { 13 14 /** 15 * register the eventhandlers and initialize some options 16 */ 17 function register(&$controller){ 18 19 $controller->register_hook('DOKUWIKI_STARTED', 20 'BEFORE', 21 $this, 22 'handle_start', 23 array()); 24 } 25 26 /** 27 * Do the magic 28 */ 29 function handle_start(&$event, $param){ 30 global $conf; 31 $bans = @file($conf['cachedir'].'/unamebanplugin.txt'); 32 $client = $_SERVER['REMOTE_USER']; 33 if(is_array($bans)) foreach($bans as $ban){ 34 $fields = explode("\t",$ban); 35 if($fields[0] == $client){ 36 $text = $this->locale_xhtml('banned'); 37 $text .= sprintf('<p>'.$this->getLang('banned').'</p>', 38 hsc($client), strftime($conf['dformat'],$fields[1]), 39 hsc($fields[3])); 40 $title = $this->getLang('denied'); 41 header("HTTP/1.0 403 Forbidden"); 42 echo<<<EOT 43<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 44"http://www.w3.org/TR/html4/loose.dtd"> 45<html> 46<head><title>$title</title></head> 47<body style="font-family: Arial, sans-serif"> 48 <div style="width:60%; margin: auto; background-color: #fcc; 49 border: 1px solid #faa; padding: 0.5em 1em;"> 50 $text 51 </div> 52</body> 53</html> 54EOT; 55 exit; 56 } 57 } 58 } 59 60} 61