Automatically exported from code.google.com/p/planningalerts
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 where disabled = 0 or disabled is null";
  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. ?>