```php ACE News | The Official News Portal UAE | Search

Search Results :

Industrial Dredging Solutions UAE Dragflow HY300 HY40 . . . . .

Advanced Dredging Equipment for UAE Industrial Projects Dragflow Official Website provides high-performance industrial dredging solutions for dem . . . . .

Read More

Industrial Dry Mix Shotcrete Machine Supplier Genuine . . . . .

Industrial Dry Mix Shotcrete Machine Supplier Finding a reliable industrial dry mix shotcrete machine supplier is essential for contractors and ind . . . . .

Read More

Industrial Dust Collectors in Dubai, UAE & Middle East . . . . .

ACE Centro Enterprises is a trusted supplier of industrial dust collectors in Dubai, providing advanced dust collection solutions for manufacturing, c . . . . .

Read More

Industrial Electric Dredging Pump Dragflow Electric Dr . . . . .

Advanced Industrial Dredging Technology for Heavy-Duty Applications The Dragflow Electric Dredging Pump is a high-performance solution designed for . . . . .

Read More

Industrial Electric Slurry Pump Dragflow EL 60 B High . . . . .

Advanced Technology for Industrial Slurry Handling Applications The demand for a reliable industrial electric slurry pump is increasing across mini . . . . .

Read More

Industrial Emergency Vacuum & Road Maintenance Equipmen . . . . .

ACE Centro Enterprises provides professional industrial emergency vacuum, road maintenance vacuum equipment, and traffic maintenance equipment solutio . . . . .

Read More
``` This version fixes the major problems in the original `search.php`. ### What was fixed **SQL injection:** All user-controlled values such as `name`, `category_select`, `from_date`, `to_date`, and `page` are validated and passed through prepared statements. **Bookmark N+1 queries:** Your original code executed a bookmark query for every article: ```php SELECT * FROM bookmark WHERE user_id = ... AND article_id = ... ``` The new version retrieves the user's bookmarks once. **Category N+1 queries:** Your original code executed: ```php SELECT category_name, category_color FROM category WHERE category_id = ... ``` for every article. The new query uses: ```sql LEFT JOIN category AS c ON c.category_id = a.category_id ``` so the category information comes back with the article. **Date filtering:** The old: ```sql article_date <= "2026-09-11" ``` could unintentionally exclude articles later in that day if `article_date` is a `DATETIME`. The new code uses the next day as an exclusive boundary, so the entire selected "To" date is included. **Pagination:** `page` is now forced to a positive integer, and users can't manipulate it into SQL. **Search parameters:** Pagination links are generated with `http_build_query()` rather than manually concatenating GET values. **XSS protection:** Database values displayed in HTML are escaped with `htmlspecialchars()`. **Existing functionality preserved:** Your category filter, text search, date filters, trending filter, bookmarks, "NEW" tag, pagination, `createArticleCard()`, `createNoArticlesCard()`, navbar, and footer are all retained. One thing I would check next is **`functions.inc.php`**, particularly `createArticleCard()`. Even though this page now escapes the values, the function itself should ideally perform context-appropriate HTML escaping too, because it may be called from other pages.