I realize that there is no use for the viewers to see the listings that are closed/expired, so I decided to change the SQL queries to exclude these. Here is what I have done, and it's working (tested in version 3.0.2 and SMF 2.0.x). If you try it and see that I have missed something, please say so.
In classifieds2.template.php change:
for page count:
WHERE removed = 0 AND ID_CAT = $cat AND approved = 1");
to:
WHERE removed = 0 AND ID_CAT = $cat AND approved = 1 AND UNIX_TIMESTAMP() < expiredate");
for view listings:
WHERE i.removed = 0 AND i.ID_CAT = $cat AND i.approved = 1
to:
WHERE i.removed = 0 AND i.ID_CAT = $cat AND i.approved = 1 AND UNIX_TIMESTAMP() < i.expiredate
for search results:
WHERE i.approved = 1 " . $class_where ." AND (" . $context['class_search_query'] . ")
to:
WHERE i.approved = 1 " . $class_where ." AND (" . $context['class_search_query'] . ") AND UNIX_TIMESTAMP() < i.expiredate