[ Index ]
 

Code source de LifeType 1.2.4

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/class/dao/ -> sitestatistics.class.php (source)

   1  <?php
   2  
   3      lt_include( PLOG_CLASS_PATH."class/dao/model.class.php" );
   4  
   5      /**
   6       * This class provides some statistics about the site.
   7       *
   8       * \ingroup DAO
   9       */
  10      class SiteStatistics extends Model 
  11      {
  12  
  13      	function SiteStatistics()
  14          {
  15              $this->Model();
  16          }
  17  
  18          function getTotalFromQuery( $query )
  19          {
  20              $result = $this->Execute( $query );
  21  
  22              $row = $result->FetchRow();
  23              $result->Close();
  24  
  25              return $row["total"];
  26          }
  27  
  28          function getNumberOfBlogs()
  29          {
  30              $query = "SELECT COUNT(id) AS total FROM ".$this->getPrefix()."blogs";
  31  
  32              return $this->getTotalFromQuery( $query );
  33          }
  34  
  35          function getNumberOfPosts()
  36          {
  37              $query = "SELECT COUNT(id) AS total FROM ".$this->getPrefix()."articles WHERE status = 1";
  38  
  39              return $this->getTotalFromQuery( $query );
  40          }
  41  
  42          function getNumberOfUsers()
  43          {
  44              $query = "SELECT COUNT(id) AS total FROM ".$this->getPrefix()."users";
  45  
  46              return $this->getTotalFromQuery( $query );
  47          }
  48  
  49          function getNumberOfPostsToday()
  50          {
  51              lt_include( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
  52  
  53              $today = new Timestamp();
  54              $todayTimestamp = $today->getYear().$today->getMonth().$today->getDay();
  55              $query = "SELECT COUNT(id) AS total FROM ".$this->getPrefix()."articles".
  56                       " WHERE date LIKE '$todayTimestamp%' AND status = 1";
  57  
  58              return $this->getTotalFromQuery( $query );
  59          }
  60  
  61          function getNumberOfPostsThisMonth()
  62          {
  63              lt_include( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
  64  
  65              $today = new Timestamp();
  66              $monthTimestamp = $today->getYear().$today->getMonth();
  67              $query = "SELECT COUNT(id) AS total FROM ".$this->getPrefix()."articles".
  68                       " WHERE date LIKE '$monthTimestamp%' AND status = 1";
  69  
  70              return $this->getTotalFromQuery( $query );
  71          }
  72  
  73          function getAllStatistics()
  74          {
  75              $stats = Array();
  76  
  77              $stats["totalblogs"] = $this->getNumberOfBlogs();
  78              $stats["totalusers"] = $this->getNumberOfUsers();
  79              $stats["totalposts"] = $this->getNumberOfPosts();
  80              $stats["poststoday"] = $this->getNumberOfPostsToday();
  81              $stats["poststhismonth"] = $this->getNumberOfPostsThisMonth();
  82  
  83              return $stats;
  84          }
  85      }
  86  ?>


Généré le : Mon Nov 26 21:04:15 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics