author.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php if (!defined('PmWiki')) exit();
  2. /* Copyright 2004-2006 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 handles author tracking.
  8. */
  9. SDV($AuthorNameChars, "- '\\w\\x80-\\xff");
  10. SDV($AuthorCookie, $CookiePrefix.'author');
  11. SDV($AuthorCookieExpires,$Now+60*60*24*30);
  12. SDV($AuthorCookieDir,'/');
  13. SDV($AuthorGroup,'Profiles');
  14. SDV($AuthorRequiredFmt,
  15. "<h3 class='wikimessage'>$[An author name is required.]</h3>");
  16. Markup('[[~','<links','/\\[\\[~(.*?)\\]\\]/',"[[$AuthorGroup/$1]]");
  17. $LogoutCookies[] = $AuthorCookie;
  18. if (!isset($Author)) {
  19. if (isset($_POST['author'])) {
  20. $x = stripmagic($_POST['author']);
  21. setcookie($AuthorCookie, $x, $AuthorCookieExpires, $AuthorCookieDir);
  22. } elseif (@$_COOKIE[$AuthorCookie]) {
  23. $x = stripmagic(@$_COOKIE[$AuthorCookie]);
  24. } else $x = @$AuthId;
  25. $Author = htmlspecialchars(preg_replace("/[^$AuthorNameChars]/", '', $x),
  26. ENT_QUOTES);
  27. }
  28. if (!isset($AuthorPage)) $AuthorPage =
  29. FmtPageName('$AuthorGroup/$Name', MakePageName($pagename, $Author));
  30. SDV($AuthorLink,($Author) ? "[[~$Author]]" : '?');
  31. if (IsEnabled($EnableAuthorSignature,1)) {
  32. $ROSPatterns['/(?<!~)~~~~(?!~)/'] = '[[~$Author]] $CurrentTime';
  33. $ROSPatterns['/(?<!~)~~~(?!~)/'] = '[[~$Author]]';
  34. Markup('~~~~','<links','/(?<!~)~~~~(?!~)/',"[[~$Author]] $CurrentTime");
  35. Markup('~~~','>~~~~','/(?<!~)~~~(?!~)/',"[[~$Author]]");
  36. }
  37. if (IsEnabled($EnablePostAuthorRequired,0))
  38. array_unshift($EditFunctions,'RequireAuthor');
  39. ## RequireAuthor forces an author to enter a name before posting.
  40. function RequireAuthor($pagename, &$page, &$new) {
  41. global $Author, $MessagesFmt, $AuthorRequiredFmt, $EnablePost;
  42. if (!$Author) {
  43. $MessagesFmt[] = $AuthorRequiredFmt;
  44. $EnablePost = 0;
  45. }
  46. }