A new, object-oriented, better vesion of μForum
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.1 KiB

  1. <?php
  2. require_once('./inc/model.class.php');
  3. class StatisticsModel extends Model
  4. {
  5. private $logged_users = null;
  6. public function getPostsCount()
  7. {
  8. $out = $this->select(POSTS_TABLE, 'count(post_id) AS posts_count');
  9. return $out[0]['posts_count'];
  10. }
  11. public function getTopicsCount()
  12. {
  13. $out = $this->select(TOPICS_TABLE, 'count(topic_id) AS topics_count');
  14. return $out[0]['topics_count'];
  15. }
  16. public function getUsersCount()
  17. {
  18. $out = $this->select(USERS_TABLE, 'count(user_id) AS users_count');
  19. return $out[0]['users_count'];
  20. }
  21. public function getLastRegisteredUser()
  22. {
  23. $out = $this->select(USERS_TABLE, 'user_id, nick, rank', '', 'user_id DESC', '1');
  24. return $out[0];
  25. }
  26. private function retrieveLoggedUsers()
  27. {
  28. if ($this->logged_users == null)
  29. {
  30. $this->logged_users = $this->select(LOGGED_USERS_VIEW);
  31. }
  32. }
  33. public function getLoggedUsersCount()
  34. {
  35. $this->retrieveLoggedUsers();
  36. return count($this->logged_users);
  37. }
  38. public function getLoggedUsers()
  39. {
  40. $this->retrieveLoggedUsers();
  41. return $this->logged_users;
  42. }
  43. }
  44. ?>