OSDN Git Service

BugTrack/791: Fix typo 0,91 => 0.91
[pukiwiki/pukiwiki.git] / plugin / md5.inc.php
1 <?php
2 // PukiWiki - Yet another WikiWikiWeb clone.
3 // $Id: md5.inc.php,v 1.7 2005/01/23 05:29:10 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         if (PKWK_SAFE_MODE || PKWK_READONLY) die_message('Prohibited');
13
14         // Wait POST
15         $key = isset($post['key']) ? $post['key'] : '';
16         if ($key != '') {
17                 plugin_md5_checklimit($key);
18                 // Compute (Don't show its $key at the same time)
19                 return array('msg'=>'MD5', 'body'=>'Hash: ' . md5($key));
20         } else {
21                 // If cmd=md5&md5=password, set only (Don't compute)
22                 $value = isset($get['md5']) ? $get['md5'] : '';
23                 if ($value != '') {
24                         plugin_md5_checklimit($value);
25                         $value  = 'value="' . htmlspecialchars($value) . '" ';
26                 }
27                 $form = <<<EOD
28 <form action="$script" method="post">
29  <div>
30   <input type="hidden" name="plugin" value="md5" />
31   <input type="text"   name="key" size="30" $value/>
32   <input type="submit" value="Compute" />
33  </div>
34 </form>
35 <br/>
36 EOD;
37                 return array('msg'=>'MD5', 'body'=>$form);
38         }
39 }
40
41 function plugin_md5_checklimit($text)
42 {
43         if (strlen($text) > PLUGIN_MD5_LIMIT_LENGTH)
44                 die_message('Limit: malicious message length');
45 }
46 ?>