author.php 1.9 KB

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