Automatically exported from code.google.com/p/planningalerts
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

47 行
1.0 KiB

  1. <?php
  2. require_once ("config.php");
  3. require_once ("DB.php");
  4. class stats{
  5. public static function get_stats (){
  6. //this should really be properly cached at some point.
  7. $return = false;
  8. //is the data already in the session?
  9. if (isset($_SESSION['stats'])){
  10. $return = $_SESSION['stats'];
  11. }else{
  12. $db = DB::connect(DB_CONNECTION_STRING);
  13. $alert_count = 0;
  14. $authority_count = 0;
  15. //Count of applications
  16. $alert_sql = "select value from stats where `key` = 'applications_sent'";
  17. $results = $db->getAll($alert_sql);
  18. if(sizeof($results) >0){
  19. $alert_count = $results[0][0];
  20. }
  21. //Count of authorities
  22. $authority_sql = "select count(authority_id) from authority";
  23. $results = $db->getAll($authority_sql);
  24. if(sizeof($results) >0){
  25. $authority_count = $results[0][0];
  26. }
  27. //save to session
  28. $return = array('alert_count' => $alert_count, 'authority_count' => $authority_count);
  29. $_SESSION['stats'] = $return;
  30. }
  31. return $return;
  32. }
  33. }
  34. ?>