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.

news_ajax.php 885B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. #declare(strict_types=1);
  3. // Don't allow bigger queries than specified below regardless of called function
  4. $SizeLimit = 10;
  5. $Count = (int)$_GET['count'];
  6. $Offset = (int)$_GET['offset'];
  7. if (!isset($_GET['count']) || !isset($_GET['offset']) || $Count <= 0 || $Offset < 0 || $Count > $SizeLimit) {
  8. json_die('failure');
  9. }
  10. Text::$TOC = true;
  11. global $DB;
  12. $DB->query("
  13. SELECT
  14. ID,
  15. Title,
  16. Body,
  17. Time
  18. FROM news
  19. ORDER BY Time DESC
  20. LIMIT $Offset, $Count");
  21. $News = $DB->to_array(false, MYSQLI_NUM, false);
  22. $NewsResponse = [];
  23. foreach ($News as $NewsItem) {
  24. list($NewsID, $Title, $Body, $NewsTime) = $NewsItem;
  25. array_push(
  26. $NewsResponse,
  27. array(
  28. $NewsID,
  29. Text::full_format($Title),
  30. time_diff($NewsTime),
  31. Text::full_format($Body)
  32. )
  33. );
  34. }
  35. json_die('success', json_encode($NewsResponse));