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.

takecreate.php 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. #declare(strict_types=1);
  3. authorize();
  4. $P = [];
  5. $P = db_array($_POST);
  6. include SERVER_ROOT.'/classes/validate.class.php';
  7. $Val = new Validate;
  8. $Val->SetFields('title', '1', 'string', 'The title must be between 3 and 100 characters', array('maxlength' => 100, 'minlength' => 3));
  9. //$Val->SetFields('alias', '1', 'string', 'Please include at least 1 alias, the entire string should be between 2 and 100 characters.', array('maxlength' => 100, 'minlength' => 2));
  10. $Err = $Val->ValidateForm($_POST);
  11. if (!$Err) {
  12. $DB->query("
  13. SELECT ID
  14. FROM wiki_articles
  15. WHERE Title = '$P[title]'");
  16. if ($DB->has_results()) {
  17. list($ID) = $DB->next_record();
  18. $Err = 'An article with that name already exists <a href="wiki.php?action=article&amp;id='.$ID.'">here</a>.';
  19. }
  20. }
  21. if ($Err) {
  22. error($Err);
  23. }
  24. if (check_perms('admin_manage_wiki')) {
  25. $Read = $_POST['minclassread'];
  26. $Edit = $_POST['minclassedit'];
  27. if (!is_number($Read)) {
  28. error(0); // int?
  29. }
  30. if (!is_number($Edit)) {
  31. error(0);
  32. }
  33. if ($Edit > $LoggedUser['EffectiveClass']) {
  34. error('You can\'t restrict articles above your own level');
  35. }
  36. if ($Edit < $Read) {
  37. $Edit = $Read; //Human error fix.
  38. }
  39. } else {
  40. $Read = 100;
  41. $Edit = 100;
  42. }
  43. $DB->query("
  44. INSERT INTO wiki_articles
  45. (Revision, Title, Body, MinClassRead, MinClassEdit, Date, Author)
  46. VALUES
  47. ('1', '$P[title]', '$P[body]', '$Read', '$Edit', NOW(), '$LoggedUser[ID]')");
  48. $ArticleID = $DB->inserted_id();
  49. $TitleAlias = Wiki::normalize_alias($_POST['title']);
  50. $Dupe = Wiki::alias_to_id($_POST['title']);
  51. if ($TitleAlias !== '' && $Dupe === false) {
  52. $DB->query("
  53. INSERT INTO wiki_aliases (Alias, ArticleID)
  54. VALUES ('".db_string($TitleAlias)."', '$ArticleID')");
  55. Wiki::flush_aliases();
  56. }
  57. Misc::write_log("Wiki article $ArticleID (".$_POST['title'].") was created by ".$LoggedUser['Username']);
  58. header("Location: wiki.php?action=article&id=$ArticleID");