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.

news.php 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?
  2. enforce_login();
  3. if (!check_perms('admin_manage_news')) {
  4. error(403);
  5. }
  6. View::show_header('Manage news', 'bbcode');
  7. switch ($_GET['action']) {
  8. case 'takeeditnews':
  9. if (!check_perms('admin_manage_news')) {
  10. error(403);
  11. }
  12. if (is_number($_POST['newsid'])) {
  13. authorize();
  14. $DB->query("
  15. UPDATE news
  16. SET Title = '".db_string($_POST['title'])."', Body = '".db_string($_POST['body'])."'
  17. WHERE ID = '".db_string($_POST['newsid'])."'");
  18. $Cache->delete_value('news');
  19. $Cache->delete_value('feed_news');
  20. }
  21. header('Location: index.php');
  22. break;
  23. case 'editnews':
  24. if (is_number($_GET['id'])) {
  25. $NewsID = $_GET['id'];
  26. $DB->query("
  27. SELECT Title, Body
  28. FROM news
  29. WHERE ID = $NewsID");
  30. list($Title, $Body) = $DB->next_record();
  31. }
  32. }
  33. ?>
  34. <div class="thin">
  35. <div class="header">
  36. <h2><?= ($_GET['action'] == 'news') ? 'Create a news post' : 'Edit news post';?></h2>
  37. </div>
  38. <form class="<?= ($_GET['action'] == 'news') ? 'create_form' : 'edit_form';?>" name="news_post" action="tools.php" method="post">
  39. <div class="box pad">
  40. <input type="hidden" name="action" value="<?= ($_GET['action'] == 'news') ? 'takenewnews' : 'takeeditnews';?>" />
  41. <input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
  42. <? if ($_GET['action'] == 'editnews') { ?>
  43. <input type="hidden" name="newsid" value="<?=$NewsID; ?>" />
  44. <? } ?>
  45. <h3>Title</h3>
  46. <input type="text" name="title" size="95"<? if (!empty($Title)) { echo ' value="'.display_str($Title).'"'; } ?> />
  47. <!-- Why did someone add this? <input type="datetime" name="datetime" value="<?=sqltime()?>" /> -->
  48. <br />
  49. <h3>Body</h3>
  50. <textarea name="body" cols="95" rows="15"><? if (!empty($Body)) { echo display_str($Body); } ?></textarea> <br /><br />
  51. <div class="center">
  52. <input type="submit" value="<?= ($_GET['action'] == 'news') ? 'Create news post' : 'Edit news post';?>" />
  53. </div>
  54. </div>
  55. </form>
  56. <h2>News archive</h2>
  57. <?
  58. $DB->query('
  59. SELECT
  60. ID,
  61. Title,
  62. Body,
  63. Time
  64. FROM news
  65. ORDER BY Time DESC');// LIMIT 20
  66. while (list($NewsID, $Title, $Body, $NewsTime) = $DB->next_record()) {
  67. ?>
  68. <div class="box vertical_space news_post">
  69. <div class="head">
  70. <strong><?=display_str($Title) ?></strong> - posted <?=time_diff($NewsTime) ?>
  71. - <a href="tools.php?action=editnews&amp;id=<?=$NewsID?>" class="brackets">Edit</a>
  72. <a href="tools.php?action=deletenews&amp;id=<?=$NewsID?>&amp;auth=<?=$LoggedUser['AuthKey']?>" class="brackets">Delete</a>
  73. </div>
  74. <div class="pad"><?=Text::full_format($Body) ?></div>
  75. </div>
  76. <? } ?>
  77. </div>
  78. <? View::show_footer();?>