0) { $where[] = 'software_id = ?'; $args[] = $swId; } if ($curCat) { $where[] = 'category_id = ?'; $args[] = (int)$curCat['id']; } if ($st !== '') { $where[] = 'status = ?'; $args[] = $st; } if ($q !== '') { $like = '%' . addcslashes($q, '%_\\') . '%'; $where[] = "(title LIKE ? ESCAPE '\\' OR body LIKE ? ESCAPE '\\')"; $args[] = $like; $args[] = $like; } $wsql = $where ? (' WHERE ' . implode(' AND ', $where)) : ''; $order = ($sort === 'new') ? 'created_at DESC' : 'updated_at DESC'; $stc = $pdo->prepare('SELECT COUNT(*) FROM threads' . $wsql); $stc->execute($args); $total = (int)$stc->fetchColumn(); $pageSize = max(5, (int)fb_cfg('page_size', 20)); $pages = max(1, (int)ceil($total / $pageSize)); $page = isset($_GET['page']) ? (int)$_GET['page'] : 1; if ($page < 1) { $page = 1; } if ($page > $pages){ $page = $pages; } $offset = ($page - 1) * $pageSize; $sql = 'SELECT id, title, category, category_id, software_id, status, author_name, reply_count, created_at, updated_at,' . ' substr(body, 1, 300) AS excerpt FROM threads' . $wsql . ' ORDER BY ' . $order . ' LIMIT ' . $pageSize . ' OFFSET ' . $offset; $sth = $pdo->prepare($sql); $sth->execute($args); $threads = $sth->fetchAll(); // 附件缩略图与数量(只在有附件时才有开销) $tids = []; foreach ($threads as $t) { $tids[] = (int)$t['id']; } $attImgs = $tids ? fb_attach_map_images($pdo, $tids, 3) : []; $attCount = $tids ? fb_attach_count_map($pdo, $tids) : []; $siteName = (string)fb_cfg('site_name'); $headTitle = $siteName !== '' ? $siteName . ' · 问题反馈' : '问题反馈'; fb_layout_head($sw ? ((string)$sw['name']) : $headTitle); ?>
1): ?> 0): ?>