Refactored function name 'get_tot_rank_counts' to 'getTotalRankCounts'  to be PSR compatible. Adjusted query part to use PDO.
Removed page parameter from force_logged_in_app function as it is not used. Formatted source code of lib.php
Introduced count function in DB class to isolate DB counting. Refactored/renamed print_jlpt_levels function.