BioTorrents.de’s version of Gazelle
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

takeedit.php 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. #declare(strict_types=1);
  3. authorize();
  4. if (!isset($_POST['id']) || !is_number($_POST['id'])) {
  5. error(0);
  6. }
  7. $ArticleID = (int) $_POST['id'];
  8. include SERVER_ROOT.'/classes/validate.class.php';
  9. $Val = new Validate;
  10. $Val->SetFields('title', '1', 'string', 'The title must be between 3 and 100 characters', array('maxlength' => 100, 'minlength' => 3));
  11. $Err = $Val->ValidateForm($_POST);
  12. if ($Err) {
  13. error($Err);
  14. }
  15. $P = [];
  16. $P = db_array($_POST);
  17. $Article = Wiki::get_article($ArticleID);
  18. list($OldRevision, $OldTitle, $OldBody, $CurRead, $CurEdit, $OldDate, $OldAuthor) = array_shift($Article);
  19. if ($CurEdit > $LoggedUser['EffectiveClass']) {
  20. error(403);
  21. }
  22. if (check_perms('admin_manage_wiki')) {
  23. $Read=$_POST['minclassread'];
  24. $Edit=$_POST['minclassedit'];
  25. if (!is_number($Read)) {
  26. error(0); // int?
  27. }
  28. if (!is_number($Edit)) {
  29. error(0);
  30. }
  31. if ($Edit > $LoggedUser['EffectiveClass']) {
  32. error('You can\'t restrict articles above your own level.');
  33. }
  34. if ($Edit < $Read) {
  35. $Edit = $Read; // Human error fix
  36. }
  37. }
  38. $MyRevision = (int) $_POST['revision'];
  39. if ($MyRevision !== $OldRevision) {
  40. error('This article has already been modified from its original version.');
  41. }
  42. // Store previous revision
  43. $DB->query("
  44. INSERT INTO wiki_revisions
  45. (ID, Revision, Title, Body, Date, Author)
  46. VALUES
  47. ('".db_string($ArticleID)."', '".db_string($OldRevision)."', '".db_string($OldTitle)."', '".db_string($OldBody)."', '".db_string($OldDate)."', '".db_string($OldAuthor)."')");
  48. // Update wiki entry
  49. $SQL = "
  50. UPDATE wiki_articles
  51. SET
  52. Revision = '".db_string($OldRevision + 1)."',
  53. Title = '$P[title]',
  54. Body = '$P[body]',";
  55. if ($Read && $Edit) {
  56. $SQL .= "
  57. MinClassRead = '$Read',
  58. MinClassEdit = '$Edit',";
  59. }
  60. $SQL .= "
  61. Date = NOW(),
  62. Author = '$LoggedUser[ID]'
  63. WHERE ID = '$P[id]'";
  64. $DB->query($SQL);
  65. Wiki::flush_article($ArticleID);
  66. header("Location: wiki.php?action=article&id=$ArticleID");