OSDN Git Service

Added / Correct messages only
[pukiwiki/pukiwiki.git] / plugin / md5.inc.php
1 <?php
2 // PukiWiki - Yet another WikiWikiWeb clone.
3 // $Id: md5.inc.php,v 1.18 2005/06/04 01:44:10 henoheno Exp $
4 //
5 //  MD5 plugin
6
7 // User interface of pkwk_hash_compute() for system admin
8 function plugin_md5_action()
9 {
10         global $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         $submit = isset($post['key']);
17         if ($key != '') {
18                 // Compute (Don't show its $key at the same time)
19
20                 $prefix = isset($post['prefix']);
21                 $salt   = isset($post['salt']) ? $post['salt'] : '';
22
23                 // With scheme-prefix or not
24                 if (! preg_match('/^\{.+\}.*$/', $salt)) {
25                         $scheme = isset($post['scheme']) ? '{' . $post['scheme'] . '}': '';
26                         $salt   = $scheme . $salt;
27                 }
28
29                 return array(
30                         'msg' =>'Result',
31                         'body'=>
32                                 //($prefix ? 'userPassword: ' : '') .
33                                 pkwk_hash_compute($salt, $key, $prefix, TRUE));
34
35         } else {
36                 // If plugin=md5&md5=password, only set it (Don't compute)
37                 $value = isset($get['md5']) ? $get['md5'] : '';
38                 if (strlen($value) > PKWK_PASSPHRASE_LIMIT_LENGTH)
39                         die_message('Limit: malicious message length');
40                 if ($value != '') $value  = 'value="' . htmlspecialchars($value) . '" ';
41
42                 $self = get_script_uri();
43                 $form = '';
44                 if ($submit) $form .= '<strong>NO PHRASE</strong><br />';
45                 $form .= <<<EOD
46 <p><strong>NOTICE: Don't use this feature via untrustful or unsure network</strong></p>
47 <hr>
48 <form action="$self" method="post">
49  <div>
50   <input type="hidden" name="plugin" value="md5" />
51   <label for="_p_md5_phrase">Phrase:</label>
52   <input type="text" name="key"  id="_p_md5_phrase" size="60" $value/><br />
53
54   <input type="radio" name="scheme" id="_p_md5_sha1" value="x-php-sha1" />
55   <label for="_p_md5_sha1">PHP sha1()</label><br />
56   <input type="radio" name="scheme" id="_p_md5_md5"  value="x-php-md5" checked="checked" />
57   <label for="_p_md5_md5">PHP md5()</label><br />
58   <input type="radio" name="scheme" id="_p_md5_crpt" value="x-php-crypt" />
59   <label for="_p_md5_crpt">PHP crypt() *</label><br />
60
61   <input type="radio" name="scheme" id="_p_md5_lssha" value="SSHA" />
62   <label for="_p_md5_lssha">LDAP SSHA (sha-1 with a seed) *</label><br />
63   <input type="radio" name="scheme" id="_p_md5_lsha" value="SHA" />
64   <label for="_p_md5_lsha">LDAP SHA (sha-1)</label><br />
65
66   <input type="radio" name="scheme" id="_p_md5_lsmd5" value="SMD5" />
67   <label for="_p_md5_lsmd5">LDAP SMD5 (md5 with a seed) *</label><br />
68   <input type="radio" name="scheme" id="_p_md5_lmd5" value="MD5" />
69   <label for="_p_md5_lmd5">LDAP MD5</label><br />
70
71   <input type="radio" name="scheme" id="_p_md5_lcrpt" value="CRYPT" />
72   <label for="_p_md5_lcrpt">LDAP CRYPT *</label><br />
73
74   <input type="checkbox" name="prefix" id="_p_md5_prefix" checked="checked" />
75   <label for="_p_md5_prefix">Add scheme prefix (RFC2307, Using LDAP as NIS)</label><br />
76
77   <label for="_p_md5_salt">Salt, '{scheme}', '{scheme}salt', or userPassword itself to specify:</label><br />
78   <input type="text" name="salt" id="_p_md5_salt" size="60" /><br />
79
80   <input type="submit" value="Compute" /><br />
81
82   <hr>
83   <p>* = Salt enabled<p/>
84  </div>
85 </form>
86 EOD;
87                 return array('msg'=>'Compute userPassword', 'body'=>$form);
88         }
89 }
90 ?>