Oppaitime'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.

forum_alter.php 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?
  2. authorize();
  3. if (!check_perms('admin_manage_forums')) {
  4. error(403);
  5. }
  6. $P = db_array($_POST);
  7. if (isset($_POST['submit']) && $_POST['submit'] == 'Delete') { //Delete
  8. if (!is_number($_POST['id']) || $_POST['id'] == '') {
  9. error(0);
  10. }
  11. $DB->query('
  12. DELETE FROM forums
  13. WHERE ID = '.$_POST['id']);
  14. } else { //Edit & Create, Shared Validation
  15. $Val->SetFields('name', '1', 'string', 'The name must be set, and has a max length of 40 characters', array('maxlength' => 40, 'minlength' => 1));
  16. $Val->SetFields('description', '0', 'string', 'The description has a max length of 255 characters', array('maxlength' => 255));
  17. $Val->SetFields('sort', '1', 'number', 'Sort must be set');
  18. $Val->SetFields('categoryid', '1', 'number', 'Category must be set');
  19. $Val->SetFields('minclassread', '1', 'number', 'MinClassRead must be set');
  20. $Val->SetFields('minclasswrite', '1', 'number', 'MinClassWrite must be set');
  21. $Val->SetFields('minclasscreate', '1', 'number', 'MinClassCreate must be set');
  22. $Err = $Val->ValidateForm($_POST); // Validate the form
  23. if ($Err) {
  24. error($Err);
  25. }
  26. if ($P['minclassread'] > $LoggedUser['Class'] || $P['minclasswrite'] > $LoggedUser['Class'] || $P['minclasscreate'] > $LoggedUser['Class']) {
  27. error(403);
  28. }
  29. if (isset($_POST['submit']) && $_POST['submit'] == 'Edit') { //Edit
  30. if (!is_number($_POST['id']) || $_POST['id'] == '') {
  31. error(0);
  32. }
  33. $DB->query('
  34. SELECT MinClassRead
  35. FROM forums
  36. WHERE ID = ' . $P['id']);
  37. if (!$DB->has_results()) {
  38. error(404);
  39. } else {
  40. list($MinClassRead) = $DB->next_record();
  41. if ($MinClassRead > $LoggedUser['Class']) {
  42. error(403);
  43. }
  44. }
  45. $DB->query("
  46. UPDATE forums
  47. SET
  48. Sort = '$P[sort]',
  49. CategoryID = '$P[categoryid]',
  50. Name = '$P[name]',
  51. Description = '$P[description]',
  52. MinClassRead = '$P[minclassread]',
  53. MinClassWrite = '$P[minclasswrite]',
  54. MinClassCreate = '$P[minclasscreate]'
  55. WHERE ID = '$P[id]'");
  56. } else { //Create
  57. $DB->query("
  58. INSERT INTO forums
  59. (Sort, CategoryID, Name, Description, MinClassRead, MinClassWrite, MinClassCreate)
  60. VALUES
  61. ('$P[sort]', '$P[categoryid]', '$P[name]', '$P[description]', '$P[minclassread]', '$P[minclasswrite]', '$P[minclasscreate]')");
  62. }
  63. }
  64. $Cache->delete_value('forums_list'); // Clear cache
  65. // Go back
  66. header('Location: tools.php?action=forum')
  67. ?>