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.

index.php 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <?
  2. enforce_login();
  3. if (!check_perms('users_mod')) {
  4. error(403);
  5. }
  6. $DB->query("
  7. INSERT INTO staff_blog_visits
  8. (UserID, Time)
  9. VALUES
  10. (".$LoggedUser['ID'].", NOW())
  11. ON DUPLICATE KEY UPDATE
  12. Time = NOW()");
  13. $Cache->delete_value('staff_blog_read_'.$LoggedUser['ID']);
  14. // WHY
  15. //define('ANNOUNCEMENT_FORUM_ID', 19);
  16. if (check_perms('admin_manage_blog')) {
  17. if (!empty($_REQUEST['action'])) {
  18. switch ($_REQUEST['action']) {
  19. case 'takeeditblog':
  20. authorize();
  21. if (empty($_POST['title'])) {
  22. error("Please enter a title.");
  23. }
  24. if (is_number($_POST['blogid'])) {
  25. $DB->query("
  26. UPDATE staff_blog
  27. SET Title = '".db_string($_POST['title'])."', Body = '".db_string($_POST['body'])."'
  28. WHERE ID = '".db_string($_POST['blogid'])."'");
  29. $Cache->delete_value('staff_blog');
  30. $Cache->delete_value('staff_feed_blog');
  31. }
  32. header('Location: staffblog.php');
  33. break;
  34. case 'editblog':
  35. if (is_number($_GET['id'])) {
  36. $BlogID = $_GET['id'];
  37. $DB->query("
  38. SELECT Title, Body
  39. FROM staff_blog
  40. WHERE ID = $BlogID");
  41. list($Title, $Body, $ThreadID) = $DB->next_record();
  42. }
  43. break;
  44. case 'deleteblog':
  45. if (is_number($_GET['id'])) {
  46. authorize();
  47. $DB->query("
  48. DELETE FROM staff_blog
  49. WHERE ID = '".db_string($_GET['id'])."'");
  50. $Cache->delete_value('staff_blog');
  51. $Cache->delete_value('staff_feed_blog');
  52. }
  53. header('Location: staffblog.php');
  54. break;
  55. case 'takenewblog':
  56. authorize();
  57. if (empty($_POST['title'])) {
  58. error("Please enter a title.");
  59. }
  60. $Title = db_string($_POST['title']);
  61. $Body = db_string($_POST['body']);
  62. $DB->query("
  63. INSERT INTO staff_blog
  64. (UserID, Title, Body, Time)
  65. VALUES
  66. ('$LoggedUser[ID]', '".db_string($_POST['title'])."', '".db_string($_POST['body'])."', NOW())");
  67. $Cache->delete_value('staff_blog');
  68. $Cache->delete_value('staff_blog_latest_time');
  69. send_irc("PRIVMSG ".ADMIN_CHAN." :!mod New staff blog: " . $_POST['title'] . " - https://".SITE_DOMAIN."/staffblog.php#blog" . $DB->inserted_id());
  70. header('Location: staffblog.php');
  71. break;
  72. }
  73. }
  74. View::show_header('Staff Blog','bbcode');
  75. ?>
  76. <div class="box box2 thin">
  77. <div class="head">
  78. <?=((empty($_GET['action'])) ? 'Create a staff blog post' : 'Edit staff blog post')?>
  79. <span style="float: right;">
  80. <a toggle-target="#postform" toggle-replace="<?=(($_REQUEST['action'] != 'editblog') ? 'Hide' : 'Show')?>" class="brackets"><?=(($_REQUEST['action'] != 'editblog') ? 'Show' : 'Hide')?></a>
  81. </span>
  82. </div>
  83. <form class="<?=((empty($_GET['action'])) ? 'create_form' : 'edit_form')?>" name="blog_post" action="staffblog.php" method="post">
  84. <div id="postform" class="pad<?=($_REQUEST['action'] != 'editblog') ? ' hidden' : '' ?>">
  85. <input type="hidden" name="action" value="<?=((empty($_GET['action'])) ? 'takenewblog' : 'takeeditblog')?>" />
  86. <input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
  87. <? if (!empty($_GET['action']) && $_GET['action'] == 'editblog') { ?>
  88. <input type="hidden" name="blogid" value="<?=$BlogID; ?>" />
  89. <? } ?>
  90. <div class="field_div">
  91. <h3>Title</h3>
  92. <input type="text" name="title" size="95"<? if (!empty($Title)) { echo ' value="'.display_str($Title).'"'; } ?> />
  93. </div>
  94. <div class="field_div">
  95. <h3>Body</h3>
  96. <textarea name="body" cols="95" rows="15"><? if (!empty($Body)) { echo display_str($Body); } ?></textarea> <br />
  97. </div>
  98. <div class="submit_div center">
  99. <input type="submit" value="<?=((!isset($_GET['action'])) ? 'Create blog post' : 'Edit blog post') ?>" />
  100. </div>
  101. </div>
  102. </form>
  103. </div>
  104. <?
  105. } else {
  106. View::show_header('Staff Blog','bbcode');
  107. }
  108. ?>
  109. <div class="thin">
  110. <?
  111. if (($Blog = $Cache->get_value('staff_blog')) === false) {
  112. $DB->query("
  113. SELECT
  114. b.ID,
  115. um.Username,
  116. b.Title,
  117. b.Body,
  118. b.Time
  119. FROM staff_blog AS b
  120. LEFT JOIN users_main AS um ON b.UserID = um.ID
  121. ORDER BY Time DESC");
  122. $Blog = $DB->to_array(false, MYSQLI_NUM);
  123. $Cache->cache_value('staff_blog', $Blog, 1209600);
  124. }
  125. foreach ($Blog as $BlogItem) {
  126. list($BlogID, $Author, $Title, $Body, $BlogTime) = $BlogItem;
  127. $BlogTime = strtotime($BlogTime);
  128. ?>
  129. <div id="blog<?=$BlogID?>" class="box box2 blog_post">
  130. <div class="head">
  131. <strong><?=$Title?></strong> - posted <?=time_diff($BlogTime);?> by <?=$Author?>
  132. <? if (check_perms('admin_manage_blog')) { ?>
  133. - <a href="staffblog.php?action=editblog&amp;id=<?=$BlogID?>" class="brackets">Edit</a>
  134. <a href="staffblog.php?action=deleteblog&amp;id=<?=$BlogID?>&amp;auth=<?=$LoggedUser['AuthKey']?>" onclick="return confirm('Do you want to delete this?');" class="brackets">Delete</a>
  135. <? } ?>
  136. </div>
  137. <div class="pad">
  138. <?=Text::full_format($Body)?>
  139. </div>
  140. </div>
  141. <?
  142. }
  143. ?>
  144. </div>
  145. <?
  146. View::show_footer();
  147. ?>