OSDN Git Service

Replaced $_err_calendar_viewer_param into PLUGIN_CALENDAR_VIEWER_USAGE. Some Japanese...
[pukiwiki/pukiwiki.git] / plugin / md5.inc.php
index 346c52a..c827e46 100644 (file)
@@ -1,17 +1,44 @@
 <?php
-/////////////////////////////////////////////////
 // PukiWiki - Yet another WikiWikiWeb clone.
-//
-// $Id: md5.inc.php,v 1.2 2003/03/02 04:18:31 panda Exp $
-//
-//  MD5¥Ñ¥¹¥ï¡¼¥É¤Ø¤ÎÊÑ´¹
+// $Id: md5.inc.php,v 1.6 2004/11/28 13:20:23 henoheno Exp $
+//  MD5 plugin
+
+define('PLUGIN_MD5_LIMIT_LENGTH', 512);
+
 function plugin_md5_action()
 {
-       global $vars;
-       
-       return array(
-               'msg'=>'Make password of MD5',
-               'body'=> htmlspecialchars($vars['md5']).' : '.md5($vars['md5'])
-       );
+       global $script, $get, $post;
+
+       // Wait POST
+       $key = isset($post['key']) ? $post['key'] : '';
+       if ($key != '') {
+               plugin_md5_checklimit($key);
+               // Compute (Don't show its $key at the same time)
+               return array('msg'=>'MD5', 'body'=>'Hash: ' . md5($key));
+       } else {
+               // If cmd=md5&md5=password, set only (Don't compute)
+               $value = isset($get['md5']) ? $get['md5'] : '';
+               if ($value != '') {
+                       plugin_md5_checklimit($value);
+                       $value  = 'value="' . htmlspecialchars($value) . '" ';
+               }
+               $form = <<<EOD
+<form action="$script" method="post">
+ <div>
+  <input type="hidden" name="plugin" value="md5" />
+  <input type="text"   name="key" size="30" $value/>
+  <input type="submit" value="Compute" />
+ </div>
+</form>
+<br/>
+EOD;
+               return array('msg'=>'MD5', 'body'=>$form);
+       }
+}
+
+function plugin_md5_checklimit($text)
+{
+       if (strlen($text) > PLUGIN_MD5_LIMIT_LENGTH)
+               die_message('Limit: malicious message length');
 }
 ?>