crypt.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php if (!defined('PmWiki')) exit();
  2. /* Copyright 2002-2004 Patrick R. Michaud (pmichaud@pobox.com)
  3. This file is part of PmWiki; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published
  5. by the Free Software Foundation; either version 2 of the License, or
  6. (at your option) any later version. See pmwiki.php for full details.
  7. This script defines ?action=crypt, providing help for WikiAdministrators
  8. to set up site-wide passwords in the installation.
  9. */
  10. SDV($HandleActions['crypt'],'HandleCrypt');
  11. SDV($ActionTitleFmt['crypt'],'| $[Password encryption]');
  12. function HandleCrypt($pagename, $auth='read') {
  13. global $ScriptUrl,$HTMLStartFmt,$HTMLEndFmt;
  14. PrintFmt($pagename,$HTMLStartFmt);
  15. $passwd = @$_POST["passwd"];
  16. echo "<form action='{$PageUrl}' method='POST'><p>
  17. Enter password to encrypt: <input type='text' name='passwd' value='$passwd' />
  18. <input type='submit' />
  19. <input type='hidden' name='n' value='{$FullName}' />
  20. <input type='hidden' name='action' value='crypt' /></p></form>";
  21. if ($passwd) {
  22. $crypt = crypt($passwd);
  23. echo "<p class='vspace'>Encrypted password = $crypt</p>";
  24. echo "<p class='vspace'>To set a site-wide password, insert the line below
  25. in your <i>config.php</i> file, <br />replacing <tt>'type'</tt> with
  26. one of <tt>'admin'</tt>, <tt>'read'</tt>, <tt>'edit'</tt>,
  27. or <tt>'attr'</tt>. <br />See <a
  28. href='$ScriptUrl?n=PmWiki.PasswordsAdmin'>PasswordsAdmin</a> for more
  29. details.</p>
  30. <pre class='vspace'> \$DefaultPasswords['type']='$crypt';</pre>";
  31. }
  32. PrintFmt($pagename,$HTMLEndFmt);
  33. }