Example #1
0
 /**
  * Check stream control
  * @param array $media_ids
  * @return boolean
  */
 public function stream_control($media_ids)
 {
     // No check if unlimited hits (= -1)
     if ($this->hits_max < 0) {
         return true;
     }
     $next_total = count($media_ids);
     $graph = new Graph();
     $end_date = time();
     $start_date = $end_date - $this->hits_days * 86400;
     $current_total = $graph->get_total_hits($this->user_id, $start_date, $end_date);
     $next_total += $current_total;
     debug_event('stream_control_bandwidth', 'Next stream hits will be ' . $next_total . ' / ' . $this->hits_max, 3);
     return $next_total <= $this->hits_max;
 }