1 <?php 2 require_once __DIR__ . '/../includes/bootstrap.php'; 3 4 $q = get('q'); 5 $results = []; 6 7 if (mb_strlen($q) >= 2) { 8 $results = DB::rows( 9 "SELECT u.id, u.username, u.avatar, u.role, u.karma, u.post_count, u.topic_count, 10 u.joined_at, u.bio 11 FROM users u 12 WHERE (u.username LIKE ? OR u.bio LIKE ?) AND u.suspended=0 13 ORDER BY u.post_count DESC LIMIT 40", 14 ['%'.$q.'%', '%'.$q.'%'] 15 ); 16 } 17 18 $PAGE_TITLE = 'Find Users'; 19 include __DIR__ . '/../views/partials/layout.php'; 20 ?> 21 <div style="max-width:720px"> 22 <div class="sec-title" style="margin-bottom:20px"> 23 <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.35-4.35"/></svg> 24 Find Users 25 </div> 26 27 <form method="GET" style="display:flex;gap:10px;margin-bottom:24px"> 28 <input type="text" name="q" value="<?= e($q) ?>" class="fi" style="flex:1;max-width:500px" 29 placeholder="Search by username or bio…" autofocus autocomplete="off"> 30 <button type="submit" class="btn-primary">Search</button> 31 </form> 32 33 <?php if ($q && mb_strlen($q) >= 2): ?> 34 <p style="color:var(--muted);font-size:14px;margin-bottom:16px"> 35 <?= count($results) ?> result<?= count($results) !== 1 ? 's' : '' ?> for 36 "<strong><?= e($q) ?></strong>" 37 </p> 38 39 <?php if (empty($results)): ?> 40 <div class="empty-state"> 41 <p>No users found matching "<?= e($q) ?>".</p> 42 </div> 43 <?php else: ?> 44 <div class="user-search-grid"> 45 <?php foreach ($results as $u): 46 $kt = karma_tier((int)$u['karma']); ?> 47 <a href="<?= u('users/profile.php?u=' . urlencode($u['username'])) ?>" class="user-search-card"> 48 <div class="usc-av"> 49 <?php if ($u['avatar']): ?> 50 <img src="<?= e($u['avatar']) ?>" class="av-lg" alt=""> 51 <?php else: ?> 52 <span class="av-lg av-init"><?= strtoupper($u['username'][0]) ?></span> 53 <?php endif; ?> 54 </div> 55 <div class="usc-body"> 56 <div class="usc-name"> 57 @<?= e($u['username']) ?> 58 <span class="role-tag role-<?= e($u['role']) ?>"><?= e($u['role']) ?></span> 59 </div> 60 <?php if ($u['bio']): ?> 61 <div class="usc-bio"><?= e(mb_substr($u['bio'], 0, 80)) ?><?= mb_strlen($u['bio']) > 80 ? '…' : '' ?></div> 62 <?php endif; ?> 63 <div class="usc-stats"> 64 <span><?= number_format($u['post_count']) ?> posts</span> 65 <span>·</span> 66 <span style="color:<?= e($kt['color']) ?>"><?= $kt['icon'] ?> <?= number_format((int)$u['karma']) ?> karma</span> 67 </div> 68 </div> 69 <?php if ($USER && (int)$USER['id'] !== (int)$u['id']): ?> 70 <div class="usc-actions"> 71 <a href="<?= u('messages/chat.php?with=' . urlencode($u['username'])) ?>" 72 class="btn-ghost btn-sm" onclick="event.preventDefault();event.stopPropagation();window.location=this.href"> 73 💬 Message 74 </a> 75 </div> 76 <?php endif; ?> 77 </a> 78 <?php endforeach; ?> 79 </div> 80 <?php endif; ?> 81 <?php elseif ($q): ?> 82 <div class="alert warn">Please enter at least 2 characters to search.</div> 83 <?php endif; ?> 84 </div> 85 <?php include __DIR__ . '/../views/partials/layout_end.php'; ?>