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.

search.php 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. /**********************************************************************
  3. *>>>>>>>>>>>>>>>>>>>>>>>>>>> User search <<<<<<<<<<<<<<<<<<<<<<<<<<<<*
  4. **********************************************************************/
  5. if (!empty($_GET['search'])) {
  6. $_GET['username'] = $_GET['search'];
  7. }
  8. define('USERS_PER_PAGE', 30);
  9. if (isset($_GET['username'])) {
  10. $_GET['username'] = trim($_GET['username']);
  11. // form submitted
  12. $Val->SetFields('username', '1', 'username', 'Please enter a username.');
  13. $Err = $Val->ValidateForm($_GET);
  14. if (!$Err) {
  15. // Passed validation. Let's rock.
  16. list($Page, $Limit) = Format::page_limit(USERS_PER_PAGE);
  17. if ($Page > 10) {
  18. $Page = 10;
  19. $Limit = sprintf("%d, %d", ($Page - 1) * USERS_PER_PAGE, USERS_PER_PAGE);
  20. }
  21. $DB->query("
  22. SELECT
  23. SQL_CALC_FOUND_ROWS
  24. ID,
  25. Username,
  26. Enabled,
  27. PermissionID,
  28. Donor,
  29. Warned
  30. FROM users_main AS um
  31. JOIN users_info AS ui ON ui.UserID = um.ID
  32. WHERE Username LIKE '%".db_string($_GET['username'], true)."%'
  33. ORDER BY Username
  34. LIMIT $Limit");
  35. $Results = $DB->to_array();
  36. $DB->query('SELECT FOUND_ROWS()');
  37. list($NumResults) = $DB->next_record();
  38. if ($NumResults > 300) {
  39. $NumResults = 300;
  40. }
  41. }
  42. }
  43. View::show_header('User search');
  44. ?>
  45. <div class="thin">
  46. <div class="header">
  47. <h3>Search results</h3>
  48. </div>
  49. <? $Pages = Format::get_pages($Page, $NumResults, USERS_PER_PAGE, 9);
  50. if ($Pages) { ?>
  51. <div class="linkbox pager"><?=($Pages)?></div>
  52. <? } ?>
  53. <form class="search_form" name="users" action="user.php" method="get">
  54. <input type="hidden" name="action" value="search" />
  55. <table class="layout" width="100%">
  56. <tr>
  57. <td class="label nobr">Username:</td>
  58. <td>
  59. <input type="text" name="username" size="60" value="<?=display_str($_GET['username'])?>" />
  60. &nbsp;
  61. <input type="submit" value="Search users" />
  62. </td>
  63. </tr>
  64. </table>
  65. </form>
  66. <br />
  67. <div class="box pad center">
  68. <table style="width: 400px; margin: 0px auto;">
  69. <tr class="colhead">
  70. <td width="50%">Username</td>
  71. <td>Primary class</td>
  72. </tr>
  73. <?
  74. foreach ($Results as $Result) {
  75. list($UserID, $Username, $Enabled, $PermissionID, $Donor, $Warned) = $Result;
  76. ?>
  77. <tr>
  78. <td><?=Users::format_username($UserID, true, true, true, true);?></td>
  79. <td><?=Users::make_class_string($PermissionID);?></td>
  80. </tr>
  81. <? } ?>
  82. </table>
  83. </div>
  84. <div class="linkbox">
  85. <?=$Pages?>
  86. </div>
  87. </div>
  88. <? View::show_footer(); ?>