/Quản lý website đọc truyện online PHP/forum/includes/filter.php

https://gitlab.com/phamngsinh/baitaplon_sinhvien · PHP · 81 lines · 51 code · 4 blank · 26 comment · 6 complexity · 67f25afa644a8452b6c3c8b840e6a161 MD5 · raw file

  1. <?php
  2. /*
  3. ////////////////////////////////////////////////////////////////////////////////
  4. // JohnCMS Mobile Content Management System //
  5. // Project site: http://johncms.com //
  6. // Support site: http://gazenwagen.com //
  7. ////////////////////////////////////////////////////////////////////////////////
  8. // Lead Developer: Oleg Kasyanov (AlkatraZ) alkatraz@gazenwagen.com //
  9. // Development Team: Eugene Ryabinin (john77) john77@gazenwagen.com //
  10. // Dmitry Liseenko (FlySelf) flyself@johncms.com //
  11. ////////////////////////////////////////////////////////////////////////////////
  12. */
  13. defined('_IN_JOHNCMS') or die('Error: restricted access');
  14. require('../incfiles/head.php');
  15. if (!$id) {
  16. echo functions::display_error($lng['error_wrong_data'], '<a href="index.php">' . $lng['to_forum'] . '</a>');
  17. require('../incfiles/end.php');
  18. exit;
  19. }
  20. switch ($do) {
  21. case 'unset':
  22. /*
  23. -----------------------------------------------------------------
  24. Удаляем фильтр
  25. -----------------------------------------------------------------
  26. */
  27. unset($_SESSION['fsort_id']);
  28. unset($_SESSION['fsort_users']);
  29. header("Location: index.php?id=$id");
  30. break;
  31. case 'set':
  32. /*
  33. -----------------------------------------------------------------
  34. Устанавливаем фильтр по авторам
  35. -----------------------------------------------------------------
  36. */
  37. $users = isset($_POST['users']) ? $_POST['users'] : '';
  38. if (empty($_POST['users'])) {
  39. echo '<div class="rmenu"><p>' . $lng_forum['error_author_select'] . '<br /><a href="index.php?act=filter&amp;id=' . $id . '&amp;start=' . $start . '">' . $lng['back'] . '</a></p></div>';
  40. require('../incfiles/end.php');
  41. exit;
  42. }
  43. $array = array ();
  44. foreach ($users as $val) {
  45. $array[] = intval($val);
  46. }
  47. $_SESSION['fsort_id'] = $id;
  48. $_SESSION['fsort_users'] = serialize($array);
  49. header("Location: index.php?id=$id");
  50. break;
  51. default :
  52. /*
  53. -----------------------------------------------------------------
  54. Показываем список авторов темы, с возможностью выбора
  55. -----------------------------------------------------------------
  56. */
  57. $req = mysql_query("SELECT *, COUNT(`from`) AS `count` FROM `forum` WHERE `website` = '$website' AND `refid` = '$id' GROUP BY `from` ORDER BY `from`");
  58. $req = mysql_query("SELECT *, COUNT(`from`) AS `count` FROM `forum` WHERE `website` = '$website' AND `refid` = '$id' GROUP BY `from` ORDER BY `from`");
  59. $total = mysql_num_rows($req);
  60. if ($total > 0) {
  61. echo '<div class="phdr"><a href="index.php?id=' . $id . '&amp;start=' . $start . '"><b>' . $lng['forum'] . '</b></a> | ' . $lng_forum['filter_on_author'] . '</div>' .
  62. '<form action="index.php?act=filter&amp;id=' . $id . '&amp;start=' . $start . '&amp;do=set" method="post">';
  63. while ($res = mysql_fetch_assoc($req)) {
  64. echo $i % 2 ? '<div class="list2">' : '<div class="list1">';
  65. echo '<input type="checkbox" name="users[]" value="' . $res['user_id'] . '"/>&#160;' .
  66. '<a href="../users/profile.php?user=' . $res['user_id'] . '">' . $res['from'] . '</a> [' . $res['count'] . ']</div>';
  67. ++$i;
  68. }
  69. echo '<div class="gmenu"><input type="submit" value="' . $lng_forum['filter_to'] . '" name="submit" /></div>' .
  70. '<div class="phdr"><small>' . $lng_forum['filter_on_author_help'] . '</small></div>' .
  71. '</form>';
  72. } else {
  73. echo functions::display_error($lng['error_wrong_data']);
  74. }
  75. }
  76. echo '<p><a href="index.php?id=' . $id . '&amp;start=' . $start . '">' . $lng_forum['return_to_topic'] . '</a></p>';
  77. ?>