1<?php 2/** 3 * MD5 Password Tool 4 * 5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6 * @author Jan Rocho <jan@gesternwarnichtheute.de> 7 */ 8 9// must be run within Dokuwiki 10if(!defined('DOKU_INC')) die(); 11if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 12require_once(DOKU_PLUGIN.'syntax.php'); 13 14/** 15 * All DokuWiki plugins to extend the parser/rendering mechanism 16 * need to inherit from this class 17 */ 18class syntax_plugin_md5gen extends DokuWiki_Syntax_Plugin { 19 20 function getInfo(){ 21 return array( 22 'author' => 'Jan Rocho', 23 'email' => 'jan@gesternwarnichtheute.de', 24 'date' => '2008-10-18', 25 'name' => 'MD5 Generator Plugin', 26 'desc' => 'MD5 Generator Plugin, usage: ~~md5gen~~', 27 'url' => 'http://www.dokuwiki.org/plugin:md5gen' 28 ); 29 } 30 31 function getType() { return 'container'; } 32 function getPType() { return 'block'; } 33 function getSort() { return 319; } 34 35 function connectTo($mode) 36 { 37 $this->Lexer->addSpecialPattern('~~md5gen~~', $mode, 'plugin_md5gen'); 38 } 39 40 function handle($match, $state, $pos, &$handler){ 41 } 42 43 function render($mode, &$renderer, $data) { 44 if($mode == 'xhtml'){ 45 $renderer->doc .= $this->_md5gen($data); 46 return true; 47 } 48 return false; 49 } 50 51 52 function _md5gen($data){ 53 54 global $ID; 55 $buffer.="<form action='".script()."' method='POST'>"; 56 $buffer.="<input type='hidden' name='id' value='".$ID."' />"; 57 $buffer.="String to Encode: <input type='password' name='q'> <input type='submit' value='Get MD5'>"; 58 $buffer.="</form><br /><br /> "; 59 60 if($_POST['q']!=""){ 61 62 // Remove HTML / PHP 63 $_POST['q']=strip_tags($_POST['q']); 64 65 $result=md5(trim($_POST['q'])); 66 67 $buffer .= "MD5: ".$result; 68 69 } 70 71 return $buffer; 72 } 73 74} ?> 75