Ejemplo n.º 1
0
 /**
  * Retrieves the latest usage statistics from the database
  */
 public function getUsageStatistics()
 {
     // Are usage stats enabled?
     if (!HV_ENABLE_STATISTICS_COLLECTION) {
         throw new Exception('Sorry, usage statistics are not collected ' . 'for this site.', 26);
     }
     // Determine resolution to use
     $validResolutions = array('hourly', 'daily', 'weekly', 'monthly', 'yearly');
     if (isset($this->_options['resolution'])) {
         // Make sure a valid resolution was specified
         if (!in_array($this->_options['resolution'], $validResolutions)) {
             $msg = 'Invalid resolution specified. Valid options include ' . 'hourly, daily, weekly, monthly, and yearly';
             throw new Exception($msg, 25);
         }
     } else {
         // Default to daily
         $this->_options['resolution'] = 'daily';
     }
     include_once HV_ROOT_DIR . '/../src/Database/Statistics.php';
     $statistics = new Database_Statistics();
     $this->_printJSON($statistics->getUsageStatistics($this->_options['resolution']));
 }