OSDN Git Service

Rename defines only. (Added PLUGIN_ prefix etc)
[pukiwiki/pukiwiki.git] / plugin / md5.inc.php
1 <?php
2 // PukiWiki - Yet another WikiWikiWeb clone.
3 // $Id: md5.inc.php,v 1.6 2004/11/28 13:20:23 henoheno Exp $
4 //  MD5 plugin
5
6 define('PLUGIN_MD5_LIMIT_LENGTH', 512);
7
8 function plugin_md5_action()
9 {
10         global $script, $get, $post;
11
12         // Wait POST
13         $key = isset($post['key']) ? $post['key'] : '';
14         if ($key != '') {
15                 plugin_md5_checklimit($key);
16                 // Compute (Don't show its $key at the same time)
17                 return array('msg'=>'MD5', 'body'=>'Hash: ' . md5($key));
18         } else {
19                 // If cmd=md5&md5=password, set only (Don't compute)
20                 $value = isset($get['md5']) ? $get['md5'] : '';
21                 if ($value != '') {
22                         plugin_md5_checklimit($value);
23                         $value  = 'value="' . htmlspecialchars($value) . '" ';
24                 }
25                 $form = <<<EOD
26 <form action="$script" method="post">
27  <div>
28   <input type="hidden" name="plugin" value="md5" />
29   <input type="text"   name="key" size="30" $value/>
30   <input type="submit" value="Compute" />
31  </div>
32 </form>
33 <br/>
34 EOD;
35                 return array('msg'=>'MD5', 'body'=>$form);
36         }
37 }
38
39 function plugin_md5_checklimit($text)
40 {
41         if (strlen($text) > PLUGIN_MD5_LIMIT_LENGTH)
42                 die_message('Limit: malicious message length');
43 }
44 ?>