//count the number of topics and replies posted in each forum
					$kunena_db->setQuery("SELECT numTopics, numPosts FROM #__fb_categories WHERE id='{$singlerow->id}'");
					$obj_cat = $kunena_db->loadObject();
						check_dberror("Unable to load messages.");
					$numtopics = $obj_cat->numTopics;
					$numreplies = $obj_cat->numPosts;
 
					//Get the last post from each forum
					$kunena_db->setQuery("SELECT id FROM #__fb_categories WHERE id='{$singlerow->id}' OR `parent`='{$singlerow->id}'");
					$cats = $kunena_db->loadResultArray();
						check_dberror("");
					$cats = "catid=".implode(" OR catid=", $cats);
					$kunena_db->setQuery("SELECT time FROM #__fb_messages WHERE ".$cats." ORDER BY time DESC LIMIT 1");
					$lastPosttime = $kunena_db->loadResult();
						check_dberror("");
					$lastPosttime = (int)$lastPosttime;
					
					//changed lastPosttime to lastptime
					$lastptime = KUNENA_timeformat(CKunenaTools::fbGetShowTime($lastPosttime));