crypt.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php if (!defined('PmWiki')) exit();
  2. /* Copyright 2002-2015 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. Script maintained by Petko YOTOV www.pmwiki.org/petko
  10. */
  11. SDV($HandleActions['crypt'],'HandleCrypt');
  12. SDV($ActionTitleFmt['crypt'],'| $[Password encryption]');
  13. function HandleCrypt($pagename, $auth='read') {
  14. global $ScriptUrl,$HTMLStartFmt,$HTMLEndFmt;
  15. PrintFmt($pagename,$HTMLStartFmt);
  16. $passwd = stripmagic(@$_POST["passwd"]);
  17. echo FmtPageName(
  18. "<form action='{\$ScriptUrl}' method='POST'><p>
  19. Enter password to encrypt:
  20. <input type='text' name='passwd' value='"
  21. . PHSC($passwd, ENT_QUOTES) ."' />
  22. <input type='submit' />
  23. <input type='hidden' name='n' value='{\$FullName}' />
  24. <input type='hidden' name='action' value='crypt' /></p></form>",
  25. $pagename);
  26. if ($passwd) {
  27. $crypt = pmcrypt($passwd);
  28. echo "<p class='vspace'>Encrypted password = $crypt</p>";
  29. echo "<p class='vspace'>To set a site-wide password, insert the line below
  30. in your <i>config.php</i> file, <br />replacing <tt>'type'</tt> with
  31. one of <tt>'admin'</tt>, <tt>'read'</tt>, <tt>'edit'</tt>,
  32. or <tt>'attr'</tt>. <br />See <a
  33. href='$ScriptUrl?n=PmWiki.PasswordsAdmin'>PasswordsAdmin</a> for more
  34. details.</p>
  35. <pre class='vspace'> \$DefaultPasswords['type']='$crypt';</pre>";
  36. }
  37. PrintFmt($pagename,$HTMLEndFmt);
  38. }