SECURITY: Validate period param for top topic routes (PR #13818)

Fixes a possible SQL injection vector.

GitHub